Reformat with prettier 2.0

This commit is contained in:
Aurélien Mino 2020-04-05 16:01:21 +02:00 committed by Aurélien Mino
parent 650eb91b04
commit 0e864d8c59
27 changed files with 597 additions and 823 deletions

View file

@ -48,7 +48,7 @@ var BandcampImport = {
language: 'eng',
script: 'Latn',
urls: [],
url: bandcampAlbumData.url.fix_bandcamp_url()
url: bandcampAlbumData.url.fix_bandcamp_url(),
};
// Grab release title
@ -83,7 +83,7 @@ var BandcampImport = {
// Tracks
let disc = {
tracks: [],
format: release.format
format: release.format,
};
release.discs.push(disc);
@ -121,7 +121,7 @@ var BandcampImport = {
let track = {
title: title,
duration: Math.round(bctrack.duration * 1000),
artist_credit: MBImport.makeArtistCredits(artist)
artist_credit: MBImport.makeArtistCredits(artist),
};
disc.tracks.push(track);
});
@ -147,7 +147,7 @@ var BandcampImport = {
let track = {
title: '[unknown]',
duration: null,
artist_credit: []
artist_credit: [],
};
disc.tracks.push(track);
}
@ -166,13 +166,13 @@ var BandcampImport = {
) {
release.urls.push({
url: release.url,
link_type: link_type.download_for_free
link_type: link_type.download_for_free,
});
}
if (bandcampAlbumData.current.download_pref === 2) {
release.urls.push({
url: release.url,
link_type: link_type.purchase_for_download
link_type: link_type.purchase_for_download,
});
}
}
@ -180,14 +180,14 @@ var BandcampImport = {
if (bandcampAlbumData.hasAudio && !nostream && disc.tracks.length > 0 && disc.tracks.length == tracks_streamable) {
release.urls.push({
url: release.url,
link_type: link_type.stream_for_free
link_type: link_type.stream_for_free,
});
}
// Check if release is Creative Commons licensed
if ($('div#license a.cc-icons').length > 0) {
release.urls.push({
url: $('div#license a.cc-icons').attr('href'),
link_type: link_type.license
link_type: link_type.license,
});
}
// Check if album has a back link to a label
@ -196,7 +196,7 @@ var BandcampImport = {
release.labels.push({
name: label,
mbid: '',
catno: 'none'
catno: 'none',
});
}
@ -229,7 +229,7 @@ var BandcampImport = {
return {
year: d.getUTCFullYear(),
month: d.getUTCMonth() + 1,
day: d.getUTCDate()
day: d.getUTCDate(),
};
}
return false;
@ -237,14 +237,12 @@ var BandcampImport = {
// get label name from back link if possible
getlabelname: function () {
let label = $('a.back-to-label-link span.back-link-text')
.contents()
.get(2);
let label = $('a.back-to-label-link span.back-link-text').contents().get(2);
if (typeof label == 'undefined') {
return '';
}
return label.textContent;
}
},
};
$(document).ready(function () {
@ -311,17 +309,14 @@ $(document).ready(function() {
label_name = BandcampImport.getlabelname();
} else {
label_mbid = mblinks.resolveMBID(`label:${root_url}`);
if (label_mbid)
label_name = $('p#band-name-location span.title')
.text()
.trim();
if (label_mbid) label_name = $('p#band-name-location span.title').text().trim();
}
if (label_mbid || label_name) {
if (release.labels.length == 0) {
release.labels.push({
name: '',
mbid: '',
catno: 'none'
catno: 'none',
});
}
release.labels[0].name = label_name;
@ -347,9 +342,7 @@ $(document).ready(function() {
$('div.tralbum-tags a:not(:last-child).tag').after(', ');
// append a link to the full size image
let fullsizeimageurl = $('div#tralbumArt a')
.attr('href')
.replace('_10', '_0');
let fullsizeimageurl = $('div#tralbumArt a').attr('href').replace('_10', '_0');
$('div#tralbumArt').after(
`<div id='bci_link'><a class='custom-color' href='${fullsizeimageurl}' title='Open original image in a new tab (Bandcamp importer)' target='_blank'>Original image</a></div>`
);

View file

@ -144,7 +144,7 @@ function batch_recording_rels() {
return {
year: parseIntegerOrNull(match[1]),
month: parseIntegerOrNull(match[2]),
day: parseIntegerOrNull(match[3])
day: parseIntegerOrNull(match[3]),
};
}
@ -154,7 +154,7 @@ function batch_recording_rels() {
let daysInMonth = {
true: [0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
false: [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
false: [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
};
function isDateValid(y, m, d) {
@ -298,7 +298,7 @@ function batch_recording_rels() {
[//g, '-'],
[//g, '-'],
[/—/g, '-'],
[/―/g, '--']
[/―/g, '--'],
];
function normalizeTitle(title) {
@ -368,9 +368,7 @@ function batch_recording_rels() {
let hide_pending_edits = setting('hide_pending_edits') === 'true' ? true : false;
function make_checkbox(func, default_val, lbl) {
let chkbox = $('<input type="checkbox"/>')
.on('change', func)
.attr('checked', default_val);
let chkbox = $('<input type="checkbox"/>').on('change', func).attr('checked', default_val);
return label(chkbox, lbl);
}
@ -389,15 +387,8 @@ function batch_recording_rels() {
let $recordings_load_msg = $('<span>Loading performance relationships…</span>');
$container
.find('table')
.find('td')
.css('width', 'auto');
$container
.children('tbody')
.children('tr')
.children('td')
.css({ padding: '0.5em', 'vertical-align': 'top' });
$container.find('table').find('td').css('width', 'auto');
$container.children('tbody').children('tr').children('td').css({ padding: '0.5em', 'vertical-align': 'top' });
// Get actual work types/languages
ws_requests.unshift_get('/dialog?path=%2Fwork%2Fcreate', function (data) {
@ -412,9 +403,7 @@ function batch_recording_rels() {
_.each($work_options, populate);
});
$('<span></span>')
.append('<img src="/static/images/icons/loading.gif"/> ', $recordings_load_msg)
.insertBefore($relate_table);
$('<span></span>').append('<img src="/static/images/icons/loading.gif"/> ', $recordings_load_msg).insertBefore($relate_table);
// Add additional column
@ -472,7 +461,7 @@ function batch_recording_rels() {
$this.data('checked', checked).css({
background: checked ? 'blue' : 'inherit',
color: checked ? 'white' : 'black'
color: checked ? 'white' : 'black',
});
});
@ -484,7 +473,7 @@ function batch_recording_rels() {
'background-color': '#FFFFFF',
border: '1px solid #D0D0D0',
'border-top': '1px solid #EAEAEA',
'border-left': '1px solid #EAEAEA'
'border-left': '1px solid #EAEAEA',
});
}
@ -523,11 +512,7 @@ function batch_recording_rels() {
}
let NAME_FILTER = $.trim($('#id-filter\\.name').val());
let ARTIST_FILTER = $.trim(
$('#id-filter\\.artist_credit_id')
.find('option:selected')
.text()
);
let ARTIST_FILTER = $.trim($('#id-filter\\.artist_credit_id').find('option:selected').text());
if (NAME_FILTER || ARTIST_FILTER) {
get_filtered_page(0);
@ -550,10 +535,7 @@ function batch_recording_rels() {
if (row === undefined) {
for (let j = 0; j < $recordings.length; j++) {
let row_ = $recordings[j];
let row_id = $(row_)
.find(TITLE_SELECTOR)
.attr('href')
.match(MBID_REGEX)[0];
let row_id = $(row_).find(TITLE_SELECTOR).attr('href').match(MBID_REGEX)[0];
if (node.id === row_id) {
row = row_;
@ -630,10 +612,7 @@ function batch_recording_rels() {
}
if (rel.begin) {
$attrs
.find('input.date')
.val(rel.begin)
.trigger('input');
$attrs.find('input.date').val(rel.begin).trigger('input');
}
let attrs = [];
@ -657,10 +636,7 @@ function batch_recording_rels() {
let comment = node.disambiguation;
let date = comment && comment.match && comment.match(/live(?: .+)?, ([0-9]{4}(?:-[0-9]{2}(?:-[0-9]{2})?)?)(?:\: .+)?$/);
if (date) {
$attrs
.find('input.date')
.val(date[1])
.trigger('input');
$attrs.find('input.date').val(date[1]).trigger('input');
}
if (!performed) {
@ -750,9 +726,7 @@ function batch_recording_rels() {
.prependTo($button_cell);
$msg.text(`Loading works for ${name}...`).css('color', 'green'), $table_row.append($msg, $button_cell);
$('tr#bpr-works-row')
.css('display', 'none')
.before($table_row);
$('tr#bpr-works-row').css('display', 'none').before($table_row);
let works_date = localStorage.getItem(`bpr_works_date ${mbid}`);
let result = [];
@ -920,10 +894,7 @@ function batch_recording_rels() {
for (let i = 0; i < $not_performed.length; i++) {
let $rec = $not_performed.eq(i);
let mbid = $rec
.find(TITLE_SELECTOR)
.attr('href')
.match(MBID_REGEX)[0];
let mbid = $rec.find(TITLE_SELECTOR).attr('href').match(MBID_REGEX)[0];
to_recording($rec, RECORDING_TITLES[mbid]);
}
@ -937,9 +908,7 @@ function batch_recording_rels() {
.append(
$('<span>Suggested work:</span>').css({ color: 'green', 'font-weight': 'bold' }),
'&#160;',
$('<a></a>')
.attr('href', `/work/${mbid}`)
.text(title),
$('<a></a>').attr('href', `/work/${mbid}`).text(title),
comment ? '&#160;' : null,
comment ? $('<span></span>').text(`(${comment})`) : null
)
@ -1032,12 +1001,7 @@ function batch_recording_rels() {
for (let i = 0; i < total; i++) {
let $row = $rows.eq(i);
$row.children('td')
.not(':has(input)')
.first()
.css('color', 'LightSlateGray')
.find('a')
.css('color', 'LightSlateGray');
$row.children('td').not(':has(input)').first().css('color', 'LightSlateGray').find('a').css('color', 'LightSlateGray');
let promise = relate_to_work($row, mbid, title, comment, false, false);
if (i === total - 1) {
@ -1066,9 +1030,7 @@ function batch_recording_rels() {
ws_requests.stopped = true;
let $button = $(this)
.attr('disabled', true)
.css('color', '#EAEAEA');
let $button = $(this).attr('disabled', true).css('color', '#EAEAEA');
function callback() {
ws_requests.stopped = false;
@ -1113,19 +1075,14 @@ function batch_recording_rels() {
ws_requests.stopped = true;
let $button = $(this)
.attr('disabled', true)
.css('color', '#EAEAEA');
let $button = $(this).attr('disabled', true).css('color', '#EAEAEA');
$.each($rows, function (i, row) {
let $row = $(row);
let $title_cell = rowTitleCell($row);
let title = $title_cell.find(TITLE_SELECTOR).text();
$title_cell
.css('color', 'LightSlateGray')
.find('a')
.css('color', 'LightSlateGray');
$title_cell.css('color', 'LightSlateGray').find('a').css('color', 'LightSlateGray');
create_new_work(title, function (data) {
let work = data.match(/\/work\/([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/);
@ -1169,9 +1126,7 @@ function batch_recording_rels() {
return;
}
let $button = $(this)
.attr('disabled', true)
.css('color', '#EAEAEA');
let $button = $(this).attr('disabled', true).css('color', '#EAEAEA');
ws_requests.stopped = true;
function callback() {
@ -1186,10 +1141,7 @@ function batch_recording_rels() {
let title = $row.data('suggested_work_title');
let $title_cell = rowTitleCell($row);
$title_cell
.css('color', 'LightSlateGray')
.find('a')
.css('color', 'LightSlateGray');
$title_cell.css('color', 'LightSlateGray').find('a').css('color', 'LightSlateGray');
let promise = relate_to_work($row, mbid, title, '', false, false);
if (i === total - 1) {
@ -1207,9 +1159,7 @@ function batch_recording_rels() {
.text(`${attrs.join(' ')} recording of `)
.css({ 'font-size': '0.9em', padding: '0.3em', 'padding-left': '1em' })
.append(
$('<a></a>')
.attr('href', `/work/${mbid}`)
.text(title),
$('<a></a>').attr('href', `/work/${mbid}`).text(title),
comment ? '&#160;' : null,
comment ? $('<span></span>').text(`(${comment})`) : null
)
@ -1231,10 +1181,7 @@ function batch_recording_rels() {
$row.data('performances', [work_mbid]);
}
let rec_mbid = $row
.find(TITLE_SELECTOR)
.attr('href')
.match(MBID_REGEX)[0];
let rec_mbid = $row.find(TITLE_SELECTOR).attr('href').match(MBID_REGEX)[0];
let $title_cell = rowTitleCell($row);
let title_link = $title_cell.children('a')[0];
let $attrs = $row.children('td.bpr_attrs');
@ -1254,7 +1201,7 @@ function batch_recording_rels() {
'rel-editor.rels.0.entity.1.type': 'work',
'rel-editor.rels.0.entity.1.gid': work_mbid,
'rel-editor.rels.0.entity.0.type': 'recording',
'rel-editor.rels.0.entity.0.gid': rec_mbid
'rel-editor.rels.0.entity.0.gid': rec_mbid,
};
let attrs = [];
@ -1316,10 +1263,7 @@ function batch_recording_rels() {
for (let i = 0; i < $recordings.length; i++) {
let $rec = $recordings.eq(i);
let title = $rec
.find(TITLE_SELECTOR)
.text()
.toLowerCase();
let title = $rec.find(TITLE_SELECTOR).text().toLowerCase();
if (title.indexOf(string) !== -1) {
$rec.data('filtered', false);
@ -1352,11 +1296,7 @@ function batch_recording_rels() {
function toggle_pending_edits(event, checked) {
let $pending = $recordings.filter(function () {
return $(this)
.find(TITLE_SELECTOR)
.parent()
.parent()
.is('span.mp');
return $(this).find(TITLE_SELECTOR).parent().parent().is('span.mp');
});
hide_pending_edits = checked !== undefined ? checked : this.checked;
@ -1397,10 +1337,7 @@ function batch_recording_rels() {
out_data.comment = data.disambiguation;
}
$input
.val(value)
.data(out_data)
.css('background', '#bbffbb');
$input.val(value).data(out_data).css('background', '#bbffbb');
})
.fail(function () {
$input.css('background', '#ffaaaa');

View file

@ -42,7 +42,7 @@ function retrieveReleaseInfo(release_url) {
'Data de lançamento',
'Releasedatum',
'Data di uscita',
'リリース予定日'
'リリース予定日',
];
let labels_strings = ['Labels', 'Sello', 'Gravadoras', 'Label', 'Etichetta', 'Editora', 'レーベル'];
let catalog_strings = ['Catalog', 'Catálogo', 'Catalogue', 'Katalog', 'Catalogus', 'Catalogo', 'カタログ'];
@ -55,25 +55,18 @@ function retrieveReleaseInfo(release_url) {
release.urls = [];
release.urls.push({
url: release_url,
link_type: MBImport.URL_TYPES.purchase_for_download
link_type: MBImport.URL_TYPES.purchase_for_download,
});
let releaseDate = $(contains_or('td.meta-data-label', release_date_strings))
.next()
.text()
.split('-');
let releaseDate = $(contains_or('td.meta-data-label', release_date_strings)).next().text().split('-');
release.year = releaseDate[0];
release.month = releaseDate[1];
release.day = releaseDate[2];
release.labels = [];
release.labels.push({
name: $(contains_or('td.meta-data-label', labels_strings))
.next()
.text(),
catno: $(contains_or('td.meta-data-label', catalog_strings))
.next()
.text()
name: $(contains_or('td.meta-data-label', labels_strings)).next().text(),
catno: $(contains_or('td.meta-data-label', catalog_strings)).next().text(),
});
let release_artists = [];
@ -96,7 +89,7 @@ function retrieveReleaseInfo(release_url) {
tracks.push({
artist_credit: MBImport.makeArtistCredits(artists),
title: title,
duration: t.lengthMs
duration: t.lengthMs,
});
});
@ -115,7 +108,7 @@ function retrieveReleaseInfo(release_url) {
release.discs = [];
release.discs.push({
tracks: tracks,
format: 'Digital Media'
format: 'Digital Media',
});
LOGGER.info('Parsed release: ', release);

View file

@ -48,18 +48,18 @@ function retrieveReleaseInfo(release_url) {
type: '',
urls: [],
labels: [],
discs: []
discs: [],
};
// URLs
release.urls.push({
url: release_url,
link_type: MBImport.URL_TYPES.purchase_for_download
link_type: MBImport.URL_TYPES.purchase_for_download,
});
release.labels.push({
name: ProductDetail.label.name,
catno: ProductDetail.catalog
catno: ProductDetail.catalog,
});
// Reload Playables if empty
@ -95,7 +95,7 @@ function retrieveReleaseInfo(release_url) {
tracks.push({
artist_credit: MBImport.makeArtistCredits(artists),
title: title,
duration: track.duration.minutes
duration: track.duration.minutes,
});
});
@ -113,7 +113,7 @@ function retrieveReleaseInfo(release_url) {
}
release.discs.push({
tracks: tracks,
format: release.format
format: release.format,
});
LOGGER.info('Parsed release: ', release);

View file

@ -28,14 +28,8 @@ var CD1DImporter = {
// get a list of existing formats, return id of the fragment and name
let formats = $('#container-1 ul li.ui-state-default').map(function () {
return {
id: $(this)
.find('a:first')
.attr('href')
.split('#')[1]
.split('-'),
name: $(this)
.find('span:first')
.text()
id: $(this).find('a:first').attr('href').split('#')[1].split('-'),
name: $(this).find('span:first').text(),
};
});
// remove "parent" formats : ie. digital when mp3 and flac are present
@ -58,7 +52,7 @@ var CD1DImporter = {
if (!formats[i].toremove) {
cleanformats.push({
id: formats[i].id.join('-'),
name: formats[i].name
name: formats[i].name,
});
}
}
@ -78,11 +72,7 @@ var CD1DImporter = {
// For each row that's "mapped", return an object that
// describes the first and second <td> in the row.
let duration = row
.find('td.tracklist-content-length')
.text()
.replace('"', '')
.replace("' ", ':');
let duration = row.find('td.tracklist-content-length').text().replace('"', '').replace("' ", ':');
// drop track number prefix (A A2 C3 01 05 etc...)
let title = row
@ -91,7 +81,7 @@ var CD1DImporter = {
.replace(/^[0-9A-F][0-9]* /, '');
return {
title: title,
duration: MBImport.hmsToMilliSeconds(duration)
duration: MBImport.hmsToMilliSeconds(duration),
};
})
.get();
@ -127,7 +117,7 @@ var CD1DImporter = {
return {
year: yyyy,
month: mm,
day: dd
day: dd,
};
},
@ -169,7 +159,7 @@ var CD1DImporter = {
return {
year: parseInt(date[2], 10),
month: parseInt(date[1], 10),
day: parseInt(date[0], 10)
day: parseInt(date[0], 10),
};
},
@ -189,7 +179,7 @@ var CD1DImporter = {
script: 'latn',
barcode: '',
urls: [],
discs: []
discs: [],
};
// Grab release event information
@ -205,14 +195,14 @@ var CD1DImporter = {
release.format = 'Vinyl';
release.urls.push({
url: this.currentURL(),
link_type: link_type.purchase_for_mail_order
link_type: link_type.purchase_for_mail_order,
});
} else if (format.name.match(/cd/i)) {
release.country = 'FR';
release.format = 'CD';
release.urls.push({
url: this.currentURL(),
link_type: link_type.purchase_for_mail_order
link_type: link_type.purchase_for_mail_order,
});
} else if (format.name.match(/digital|mp3|flac|ogg|wav/i)) {
release.country = 'XW';
@ -220,7 +210,7 @@ var CD1DImporter = {
release.format = 'Digital Media';
release.urls.push({
url: this.currentURL(),
link_type: link_type.purchase_for_download
link_type: link_type.purchase_for_download,
});
}
@ -229,7 +219,7 @@ var CD1DImporter = {
return {
name: $(this).text(),
mbid: '',
catno: 'none'
catno: 'none',
};
})
.get();
@ -238,14 +228,14 @@ var CD1DImporter = {
$.each(this.getTracks(format.id), function (ndisc, disc) {
let thisdisc = {
tracks: [],
format: release.format
format: release.format,
};
release.discs.push(thisdisc);
$.each(this, function (ntrack, track) {
thisdisc.tracks.push({
title: track.title,
duration: track.duration,
artist_credit: []
artist_credit: [],
});
});
});
@ -267,7 +257,7 @@ var CD1DImporter = {
$('#mb_buttons').css({ 'margin-top': '6px' });
$('form.musicbrainz_import').css({ display: 'inline-block', 'margin-right': '5px' });
mbUI.slideDown();
}
},
};
$(document).ready(function () {

View file

@ -24,9 +24,7 @@ $(document).ready(function() {
let release;
let buttons = '';
$('div.album-page-buy-button-container a').each(function () {
let format = $(this)
.attr('title')
.trim();
let format = $(this).attr('title').trim();
release = retrieveReleaseInfo(release_url, format);
buttons += getImportButton(release, release_url, format);
});
@ -40,9 +38,7 @@ function retrieveReleaseInfo(release_url, format) {
// Release defaults
let release = {
artist_credit: '',
title: $("h1 span[itemprop='name']")
.text()
.trim(),
title: $("h1 span[itemprop='name']").text().trim(),
year: 0,
month: 0,
day: 0,
@ -55,7 +51,7 @@ function retrieveReleaseInfo(release_url, format) {
type: '',
urls: [],
labels: [],
discs: []
discs: [],
};
let link_type = MBImport.URL_TYPES;
@ -66,14 +62,14 @@ function retrieveReleaseInfo(release_url, format) {
release.format = 'Vinyl';
release.urls.push({
url: release_url,
link_type: link_type.purchase_for_mail_order
link_type: link_type.purchase_for_mail_order,
});
} else if (format.match(/^cd/i)) {
release.country = 'US';
release.format = 'CD';
release.urls.push({
url: release_url,
link_type: link_type.purchase_for_mail_order
link_type: link_type.purchase_for_mail_order,
});
} else if (format.match(/^download/i)) {
release.country = 'XW';
@ -81,14 +77,12 @@ function retrieveReleaseInfo(release_url, format) {
release.format = 'Digital Media';
release.urls.push({
url: release_url,
link_type: link_type.purchase_for_download
link_type: link_type.purchase_for_download,
});
}
// Release artist
let artist = $("h2 span[itemprop='byArtist'] a")
.text()
.trim();
let artist = $("h2 span[itemprop='byArtist'] a").text().trim();
let various_artists = artist == 'Various';
if (various_artists) {
release.artist_credit = [MBImport.specialArtist('various_artists')];
@ -96,9 +90,7 @@ function retrieveReleaseInfo(release_url, format) {
release.artist_credit = MBImport.makeArtistCredits([artist]);
}
release.year = $("span[itemprop='datePublished']")
.text()
.trim();
release.year = $("span[itemprop='datePublished']").text().trim();
// Tracks
let tracks = [];
@ -110,27 +102,19 @@ function retrieveReleaseInfo(release_url, format) {
// multiple "discs"
release.discs.push({
tracks: tracks,
format: release.format
format: release.format,
});
tracks = [];
}
let trackname = $(this)
.find("meta[itemprop='name']")
.attr('content')
.trim();
let tracklength = $(this)
.find("meta[itemprop='duration']")
.attr('content')
.trim();
let trackname = $(this).find("meta[itemprop='name']").attr('content').trim();
let tracklength = $(this).find("meta[itemprop='duration']").attr('content').trim();
let track_artists = [];
// FIXME various artists releases ...
$(this)
.find('div.track-artist')
.each(function () {
let artistname = $(this)
.text()
.trim();
let artistname = $(this).text().trim();
if (artistname) {
track_artists.push(artistname);
}
@ -139,7 +123,7 @@ function retrieveReleaseInfo(release_url, format) {
let ac = {
artist_credit: '',
title: trackname,
duration: MBImport.ISO8601toMilliSeconds(tracklength)
duration: MBImport.ISO8601toMilliSeconds(tracklength),
};
if (!track_artists.length && various_artists) {
ac.artist_credit = [MBImport.specialArtist('unknown')];
@ -151,7 +135,7 @@ function retrieveReleaseInfo(release_url, format) {
release.discs.push({
tracks: tracks,
format: release.format
format: release.format,
});
LOGGER.info('Parsed release: ', release);
@ -169,11 +153,11 @@ function insertImportLinks(release, buttons) {
$('#mb_buttons').css({
'margin-bottom': '5px',
padding: '2%',
'background-color': '#fff'
'background-color': '#fff',
});
$('form.musicbrainz_import').css({
'margin-bottom': '5px'
'margin-bottom': '5px',
});
$('#mb_buttons').slideDown();

View file

@ -51,7 +51,7 @@ $(document).ready(function() {
onerror: function (resp) {
LOGGER.error('AJAX status:', resp.status);
LOGGER.error('AJAX response:', resp.responseText);
}
},
});
}, 1000);
});
@ -73,7 +73,7 @@ function parseDeezerRelease(releaseUrl, data) {
type: '',
urls: [],
labels: [],
discs: []
discs: [],
};
$.each(data.contributors, function (index, artist) {
@ -81,7 +81,7 @@ function parseDeezerRelease(releaseUrl, data) {
let ac = {
artist_name: artist.name,
joinphrase: index == data.contributors.length - 1 ? '' : ', '
joinphrase: index == data.contributors.length - 1 ? '' : ', ',
};
if (artist.name == 'Various Artists') {
@ -94,7 +94,7 @@ function parseDeezerRelease(releaseUrl, data) {
let disc = {
format: 'Digital Media',
title: '',
tracks: []
tracks: [],
};
$.each(data.tracks.data, function (index, track) {
@ -102,7 +102,7 @@ function parseDeezerRelease(releaseUrl, data) {
number: index + 1,
title: track.title_short,
duration: track.duration * 1000,
artist_credit: []
artist_credit: [],
};
// ignore pointless "(Original Mix)" in title version
@ -119,7 +119,7 @@ function parseDeezerRelease(releaseUrl, data) {
release.urls.push({
link_type: MBImport.URL_TYPES.stream_for_free,
url: releaseUrl
url: releaseUrl,
});
release.labels.push({ name: data.label });
release.type = data.record_type;

View file

@ -38,19 +38,19 @@ var months = {
'Sep.': 9,
'Oct.': 10,
'Nov.': 11,
'Dec.': 12
'Dec.': 12,
};
var labels = {
'deutschegrammophon.com': {
name: 'Deutsche Grammophon',
mbid: '5a584032-dcef-41bb-9f8b-19540116fb1c',
catno: document.URL.split('/')[5]
catno: document.URL.split('/')[5],
},
'deccaclassics.com': {
name: 'Decca Classics',
mbid: '89a9993d-1dad-4445-a3d7-1d8df04f7e7b',
catno: document.URL.split('/')[5]
}
catno: document.URL.split('/')[5],
},
};
var editNote = `Imported from ${document.URL}\n\nGM script: "${meta.name}" (${meta.version})\n\n`;
@ -102,7 +102,7 @@ function extract_release_data() {
credited_name: artist,
artist_name: artist,
artist_mbid: '',
joinphrase: ', '
joinphrase: ', ',
};
});
list[list.length - 1]['joinphrase'] = '';
@ -116,8 +116,8 @@ function extract_release_data() {
credited_name: composer,
artist_name: composer,
artist_mbid: '',
joinphrase: '; '
}
joinphrase: '; ',
},
];
return list.concat(_setReleasePerformers());
}
@ -205,7 +205,7 @@ function extract_release_data() {
discs.push({
title: '', // medium_title,
format: 'CD',
tracks: tracks
tracks: tracks,
});
}
medium_title = item.title;
@ -216,7 +216,7 @@ function extract_release_data() {
discs.push({
title: '', // nodes[0].title,
format: 'CD',
tracks: tracks
tracks: tracks,
});
return {
@ -236,10 +236,10 @@ function extract_release_data() {
urls: [
{
link_type: 288, // 'discography'
url: document.URL
}
url: document.URL,
},
],
discs: discs
discs: discs,
};
}
@ -253,7 +253,7 @@ function extract_track_data(node) {
credited_name: artist.split(',')[0],
artist_name: artist.split(',')[0],
artist_mbid: '',
joinphrase: ', '
joinphrase: ', ',
};
});
} else {
@ -264,7 +264,7 @@ function extract_track_data(node) {
credited_name: artist,
artist_name: artist,
artist_mbid: mbid,
joinphrase: ', '
joinphrase: ', ',
};
});
}
@ -282,14 +282,8 @@ function extract_track_data(node) {
} else {
console.log('no meta data on ', node);
schema.name = node.querySelectorAll('div.track-text > a.fancy')[0].textContent;
schema.byArtist = $(node)
.parent()
.nextAll('div.container-container')
.children('.artists-container')[0].textContent;
let previousComposers = $(node)
.parent()
.prevAll('div.container-container')
.children('.first-composer-container');
schema.byArtist = $(node).parent().nextAll('div.container-container').children('.artists-container')[0].textContent;
let previousComposers = $(node).parent().prevAll('div.container-container').children('.first-composer-container');
schema.creator = previousComposers[previousComposers.length - 1].textContent;
}
console.info('schema', schema);
@ -300,7 +294,7 @@ function extract_track_data(node) {
artist_credit: _setTrackArtists(schema.byArtist), // CSG
performer: schema.byArtist,
composer: schema.creator,
url: node.querySelectorAll('div.track-text > a.fancy')[0].href
url: node.querySelectorAll('div.track-text > a.fancy')[0].href,
};
}
@ -321,7 +315,7 @@ function insertMBSection(release) {
$('#mb_buttons').css({
display: 'inline-block',
width: '100%'
width: '100%',
});
$('form.musicbrainz_import').css({ width: '49%', display: 'inline-block' });
$('form.musicbrainz_import_search').css({ float: 'right' });

View file

@ -41,10 +41,7 @@ $(document).ready(function() {
MBSearchItStyle();
let current_page_key = getDiscogsLinkKey(
window.location.href
.replace(/\?.*$/, '')
.replace(/#.*$/, '')
.replace('/master/view/', '/master/')
window.location.href.replace(/\?.*$/, '').replace(/#.*$/, '').replace('/master/view/', '/master/')
);
if (!current_page_key) return;
@ -89,7 +86,7 @@ $(document).ready(function() {
error: function (jqXHR, textStatus, errorThrown) {
LOGGER.error('AJAX Status: ', textStatus);
LOGGER.error('AJAX error thrown: ', errorThrown);
}
},
});
}
});
@ -134,7 +131,7 @@ function insertMBLinks(current_page_key) {
release: { mark: 'R' },
'release-group': { mark: 'G' },
place: { mark: 'P' },
label: { mark: 'L' }
label: { mark: 'L' },
};
let mark = '';
let entity_name = 'entity';
@ -153,10 +150,7 @@ function insertMBLinks(current_page_key) {
}
let insert_normal = function (link) {
$link.closest('span.mb_valign').before(`<span class="mb_valign">${link}</span>`);
$link
.closest('span.mb_wrapper')
.find('.mb_searchit')
.remove();
$link.closest('span.mb_wrapper').find('.mb_searchit').remove();
};
let insert_stop = function (link) {
@ -188,7 +182,7 @@ function insertMBLinks(current_page_key) {
'#B3FFC6',
'#B3FFEC',
'#B3ECFF',
'#7598FF'
'#7598FF',
];
if (DEBUG) {
$(what).css('border', `2px dotted ${colors[n % colors.length]}`);
@ -301,7 +295,7 @@ function getDiscogsLinkKey(url) {
link_infos[key] = {
type: m[1],
id: m[2],
clean_url: `https://www.discogs.com/${m[1]}/${m[2]}`
clean_url: `https://www.discogs.com/${m[1]}/${m[2]}`,
};
LOGGER.debug(`getDiscogsLinkKey:${url} --> ${key}`);
} else {
@ -415,7 +409,7 @@ function insertMBSection(release, current_page_key) {
$('#mb_buttons').css({
display: 'inline-block',
width: '100%'
width: '100%',
});
$('form.musicbrainz_import').css({ width: '49%', display: 'inline-block' });
$('form.musicbrainz_import_search').css({ float: 'right' });
@ -477,7 +471,7 @@ function parseDiscogsRelease(data) {
artist_name: artistNoNum(artist.name),
credited_name: artist.anv != '' ? artist.anv : artistNoNum(artist.name),
joinphrase: decodeDiscogsJoinphrase(artist.join),
mbid: MBIDfromUrl(artist.resource_url, 'artist')
mbid: MBIDfromUrl(artist.resource_url, 'artist'),
};
if (artist.id == 194) {
// discogs place holder for various
@ -512,7 +506,7 @@ function parseDiscogsRelease(data) {
let labelinfo = {
name: label.name,
catno: label.catno == 'none' ? '[none]' : label.catno,
mbid: MBIDfromUrl(label.resource_url, 'label')
mbid: MBIDfromUrl(label.resource_url, 'label'),
};
release.labels.push(labelinfo);
});
@ -615,7 +609,7 @@ function parseDiscogsRelease(data) {
artist_name: artistNoNum(artist.name),
credited_name: artist.anv != '' ? artist.anv : artistNoNum(artist.name),
joinphrase: decodeDiscogsJoinphrase(artist.join),
mbid: MBIDfromUrl(artist.resource_url, 'artist')
mbid: MBIDfromUrl(artist.resource_url, 'artist'),
};
track.artist_credit.push(ac);
});
@ -712,7 +706,7 @@ function parseDiscogsRelease(data) {
if (!release.discs[discindex]) {
let newdisc = {
tracks: [],
format: release_formats[discindex]
format: release_formats[discindex],
};
if (heading) {
newdisc.title = heading;
@ -811,7 +805,7 @@ var MediaTypes = {
'Vinyl7"': '7" Vinyl',
'Vinyl10"': '10" Vinyl',
'Vinyl12"': '12" Vinyl',
'Lathe Cut': 'Phonograph record'
'Lathe Cut': 'Phonograph record',
};
var Countries = {
@ -1071,5 +1065,5 @@ var Countries = {
'Iran, Islamic Republic of': 'IR',
'Saint Pierre and Miquelon': 'PM',
'Saint Helena': 'SH',
'Svalbard and Jan Mayen': 'SJ'
'Svalbard and Jan Mayen': 'SJ',
};

View file

@ -77,7 +77,7 @@ function fastCancelScript() {
background: '#FFBA58',
'border-top': '1px #000 solid',
'border-left': '1px #000 solid',
padding: '0.5em'
padding: '0.5em',
})
.appendTo('body')
.hide();
@ -113,7 +113,7 @@ function fastCancelScript() {
.css({
background: 'red',
color: 'yellow',
cursor: 'help'
cursor: 'help',
})
.attr('title', `Error cancelling this edit: “${error}`);
$edit.css({ border: '6px solid red' }).show();
@ -122,7 +122,7 @@ function fastCancelScript() {
$edit.remove();
totalCancels -= 1;
updateStatus();
}
},
});
});
$edit.hide();

View file

@ -123,9 +123,7 @@ $(document).ready(function() {
let album_link = window.location.href;
let url = $(location)
.attr('href')
.split('/');
let url = $(location).attr('href').split('/');
let artist_url = url[url.length - 3];
let base_url = 'http://freemusicarchive.org/music/';
let artist_link = `${base_url + artist_url}/`;
@ -169,7 +167,7 @@ function insertAPISection() {
if (DEBUG)
fmaUI.css({
border: '1px dotted red'
border: '1px dotted red',
});
let fmaStatusBlock = $(
@ -183,7 +181,7 @@ function insertAPISection() {
display: 'inline-block',
float: 'left',
height: '120px',
width: '49%'
width: '49%',
});
fmaUI.slideDown();
@ -212,19 +210,19 @@ var updateAPISection = {
case 'completed': // Definition is that api call was successfull hence busy retrieving data
//test chaging status of album api to error retrieving data after 2 seconds
$('#lbut-lt-fma-api-album').css({
'background-color': 'green'
'background-color': 'green',
});
break;
case 'busy': // Definition is that api call was successfull hence busy retrieving data
//test chaging status of album api to error retrieving data after 2 seconds
$('#lbut-lt-fma-api-album').css({
'background-color': 'orange'
'background-color': 'orange',
});
break;
case 'fail': // Definition is that api call was successfull hence busy retrieving data
//test chaging status of album api to error retrieving data after 2 seconds
$('#lbut-lt-fma-api-album').css({
'background-color': 'red'
'background-color': 'red',
});
break;
}
@ -240,23 +238,23 @@ var updateAPISection = {
case 'completed': // Definition is that api call was successfull hence busy retrieving data
//test chaging status of album api to error retrieving data after 2 seconds
$('#lbut-lt-fma-api-tracks').css({
'background-color': 'green'
'background-color': 'green',
});
break;
case 'busy': // Definition is that api call was successfull hence busy retrieving data
//test chaging status of album api to error retrieving data after 2 seconds
$('#lbut-lt-fma-api-tracks').css({
'background-color': 'orange'
'background-color': 'orange',
});
break;
case 'fail': // Definition is that api call was successfull hence busy retrieving data
//test chaging status of album api to error retrieving data after 2 seconds
$('#lbut-lt-fma-api-tracks').css({
'background-color': 'red'
'background-color': 'red',
});
break;
}
}
},
};
// Insert MusicBrainz section on FMA page
@ -268,7 +266,7 @@ function insertMBSection(release) {
).hide();
if (DEBUG)
mbUI.css({
border: '1px dotted red'
border: '1px dotted red',
});
let mbContentBlock = $('<div class="section_content"></div>');
@ -279,7 +277,7 @@ function insertMBSection(release) {
color: 'red',
float: 'left',
'margin-top': '4px',
'margin-bottom': '4px'
'margin-bottom': '4px',
});
mbContentBlock.prepend(warning_buggy);
}
@ -300,25 +298,25 @@ function insertMBSection(release) {
display: 'block',
float: 'right',
height: '120px',
width: '49%'
width: '49%',
});
$('#mb_buttons').css({
display: 'inline-block',
float: 'right',
height: '80px'
height: '80px',
});
$('form.musicbrainz_import').css({
width: '49%',
display: 'inline-block'
display: 'inline-block',
});
$('form.musicbrainz_import_search').css({
float: 'right'
float: 'right',
});
$('form.musicbrainz_import > button').css({
width: '63px',
height: '80px',
'box-sizing': 'border-box'
'box-sizing': 'border-box',
});
mbUI.slideDown();
@ -333,7 +331,7 @@ function insertAPIKEYSection() {
).hide();
if (DEBUG)
mbUI.css({
border: '1px dotted red'
border: '1px dotted red',
});
let mbContentBlock = $('<div class="section_content"></div>');
@ -351,13 +349,13 @@ function insertAPIKEYSection() {
display: 'block',
float: 'right',
height: '120px',
width: '49%'
width: '49%',
});
$('#mb_buttons').css({
display: 'inline-block',
float: 'right',
height: '80px'
height: '80px',
});
mbUI.slideDown();
@ -448,15 +446,9 @@ function parseFMApage() {
// Label parsed from webpage as it is not in API
$('div.sbar-stat span.lf105.stathd').each(function () {
//var tester = $(this).eq(0).text().trim().toLowerCase(); // working
let taglist = $(this)
.eq(0)
.text()
.trim()
.toLowerCase();
let taglist = $(this).eq(0).text().trim().toLowerCase();
if (taglist == 'label:') {
release_attributes.label = $(this)
.next()
.text();
release_attributes.label = $(this).next().text();
// fmarelease.labels.push({
// name: FMAAlbumLabel
// });
@ -557,13 +549,13 @@ function Parsefmarelease(albumobject, trackobject) {
// Release URL
fmarelease.urls.push({
url: albumobject.album_url,
link_type: MBImport.URL_TYPES.download_for_free
link_type: MBImport.URL_TYPES.download_for_free,
});
} else {
// Release URL
fmarelease.urls.push({
url: albumobject.album_url,
link_type: MBImport.URL_TYPES.other_databases
link_type: MBImport.URL_TYPES.other_databases,
});
}
@ -572,7 +564,7 @@ function Parsefmarelease(albumobject, trackobject) {
// Release URL
fmarelease.urls.push({
url: albumobject.album_url,
link_type: MBImport.URL_TYPES.stream_for_free
link_type: MBImport.URL_TYPES.stream_for_free,
});
}
@ -583,7 +575,7 @@ function Parsefmarelease(albumobject, trackobject) {
// Label parsed from webpage as it is not in API
fmarelease.labels.push({
name: release_attributes.label
name: release_attributes.label,
});
let discarray = [];
@ -646,7 +638,7 @@ function Parsefmarelease(albumobject, trackobject) {
let disc = {
position: disccount,
format: 'Digital Media',
tracks: tracklist_per_disc
tracks: tracklist_per_disc,
};
fmarelease.discs.push(disc);
}

View file

@ -37,7 +37,7 @@ function parseReleaseDate(rdate) {
September: 9,
October: 10,
November: 11,
December: 12
December: 12,
};
let m = rdate.match(/(\d{1,2}) ([a-z]+), (\d{4})/i);
@ -45,7 +45,7 @@ function parseReleaseDate(rdate) {
return {
year: m[3],
month: months[m[2]],
day: m[1]
day: m[1],
};
}
@ -55,9 +55,7 @@ function parseReleaseDate(rdate) {
function retrieveReleaseInfo(release_url) {
let release = {
artist_credit: [],
title: $('meta[itemProp="name"]')
.attr('content')
.trim(),
title: $('meta[itemProp="name"]').attr('content').trim(),
year: 0,
month: 0,
day: 0,
@ -70,14 +68,10 @@ function retrieveReleaseInfo(release_url) {
type: '',
urls: [],
labels: [],
discs: []
discs: [],
};
let releaseDate = parseReleaseDate(
$('span[itemProp="datePublished"]')
.text()
.trim()
);
let releaseDate = parseReleaseDate($('span[itemProp="datePublished"]').text().trim());
if (releaseDate) {
release.year = releaseDate.year;
@ -87,48 +81,30 @@ function retrieveReleaseInfo(release_url) {
release.urls.push({
url: release_url,
link_type: MBImport.URL_TYPES.purchase_for_download
link_type: MBImport.URL_TYPES.purchase_for_download,
});
release.labels.push({
name: $('meta[itemProp="author"]')
.attr('content')
.trim(),
catno: $('strong:contains("Cat:")')
.parent()
.contents()
.slice(2, 3)
.text()
.trim()
name: $('meta[itemProp="author"]').attr('content').trim(),
catno: $('strong:contains("Cat:")').parent().contents().slice(2, 3).text().trim(),
});
let tracks = [];
$('.product-tracklist-track[itemprop="track"]').each(function () {
// element only present if VA release or track has multiple artists
let artist = $(this)
.find('meta[itemprop="byArtist"]')
.attr('content');
let artist = $(this).find('meta[itemprop="byArtist"]').attr('content');
if (artist !== undefined) {
artist = artist.trim();
}
let trackname = $(this)
.find('span[itemprop="name"]')
.text()
.trim();
let tracklength = $(this)
.find('meta[itemprop="duration"]')
.parent()
.contents()
.slice(0, 1)
.text()
.trim();
let trackname = $(this).find('span[itemprop="name"]').text().trim();
let tracklength = $(this).find('meta[itemprop="duration"]').parent().contents().slice(0, 1).text().trim();
if (artist !== undefined && trackname.startsWith(`${artist} - `)) {
trackname = trackname.replace(`${artist} - `, '');
}
tracks.push({
artist_credit: MBImport.makeArtistCredits(artist === undefined ? [] : [artist]),
title: trackname,
duration: tracklength
duration: tracklength,
});
});
@ -151,7 +127,7 @@ function retrieveReleaseInfo(release_url) {
release.discs.push({
tracks: tracks,
format: release.format
format: release.format,
});
LOGGER.info('Parsed release: ', release);
@ -168,9 +144,7 @@ function insertLink(release, releaseUrl) {
)}</div></div>`
).hide();
$('.product-share')
.parent()
.after(mbUI);
$('.product-share').parent().after(mbUI);
$('#mb_buttons form').css({ display: 'inline', 'margin-right': '5px' });
mbUI.slideDown();
}

View file

@ -44,6 +44,6 @@ var LOGGER = (function() {
debug: fnDebug,
info: fnInfo,
error: fnError,
setLevel: fnSetLevel
setLevel: fnSetLevel,
};
})();

View file

@ -64,12 +64,12 @@ var MBImport = (function() {
let special_artists = {
various_artists: {
name: 'Various Artists',
mbid: '89ad4ac3-39f7-470e-963a-56509c546377'
mbid: '89ad4ac3-39f7-470e-963a-56509c546377',
},
unknown: {
name: '[unknown]',
mbid: '125ec42a-7229-4250-afc5-e057484327fe'
}
mbid: '125ec42a-7229-4250-afc5-e057484327fe',
},
};
let url_types = {
@ -79,7 +79,7 @@ var MBImport = (function() {
purchase_for_mail_order: 79,
other_databases: 82,
stream_for_free: 85,
license: 301
license: 301,
};
function fnSpecialArtist(key, ac) {
@ -92,7 +92,7 @@ var MBImport = (function() {
artist_name: special_artists[key].name,
credited_name: credited_name,
joinphrase: joinphrase,
mbid: special_artists[key].mbid
mbid: special_artists[key].mbid,
};
}
@ -277,7 +277,7 @@ var MBImport = (function() {
} else {
new_items[n++] = {
artist_name: splitted[i].trim(),
joinphrase: ''
joinphrase: '',
};
}
}
@ -411,6 +411,6 @@ var MBImport = (function() {
searchUrlFor: fnSearchUrlFor,
URL_TYPES: url_types,
SPECIAL_ARTISTS: special_artists,
specialArtist: fnSpecialArtist
specialArtist: fnSpecialArtist,
};
})();

View file

@ -56,7 +56,7 @@ var MBLinks = function(user_cache_key, version, expiration) {
this.first = this[key].next;
delete this[key]; // delete this property
return $.proxy(handler, context);
}
},
};
this.cache = {};
this.expirationMinutes = typeof expiration != 'undefined' && expiration !== false ? parseInt(expiration, 10) : 90 * 24 * 60; // default to 90 days
@ -67,11 +67,11 @@ var MBLinks = function(user_cache_key, version, expiration) {
// overrides link title and img src url (per type), see createMusicBrainzLink()
this.type_link_info = {
release_group: {
title: 'See this release group on MusicBrainz'
title: 'See this release group on MusicBrainz',
},
place: {
img_src: `<img src="${this.mb_server}/static/images/entity/place.svg" height=16 width=16 />`
}
img_src: `<img src="${this.mb_server}/static/images/entity/place.svg" height=16 width=16 />`,
},
};
this.initAjaxEngine = function () {
@ -203,7 +203,7 @@ var MBLinks = function(user_cache_key, version, expiration) {
if ('relations' in data) {
mbl.cache[ctx.key] = {
timestamp: new Date().getTime(),
urls: []
urls: [],
};
$.each(data['relations'], function (idx, relation) {
if (ctx._type in relation) {
@ -229,7 +229,7 @@ var MBLinks = function(user_cache_key, version, expiration) {
mb_type: mb_type, // musicbrainz type ie. release-group
_type: _type, // musicbrainz type '-' replaced, ie. release_group
query: query, // json request url
mblinks: mblinks // MBLinks object
mblinks: mblinks, // MBLinks object
}
);
}

View file

@ -71,7 +71,7 @@ function insertMBSection(release) {
if (DEBUG)
mbUI.css({
border: '1px dotted red'
border: '1px dotted red',
});
let mbContentBlock = $('<div class="section_content"></div>');
@ -83,7 +83,7 @@ function insertMBSection(release) {
).css({
color: 'red',
'margin-top': '4px',
'margin-bottom': '4px'
'margin-bottom': '4px',
});
mbContentBlock.prepend(warning_buggy);
}
@ -102,18 +102,18 @@ function insertMBSection(release) {
$('#mb_buttons').css({
display: 'inline-block',
width: '100%'
width: '100%',
});
$('form.musicbrainz_import').css({
width: '49%',
display: 'inline-block'
display: 'inline-block',
});
$('form.musicbrainz_import_search').css({
float: 'right'
float: 'right',
});
$('form.musicbrainz_import > button').css({
width: '100%',
'box-sizing': 'border-box'
'box-sizing': 'border-box',
});
mbUI.slideDown();
@ -132,14 +132,14 @@ function parseReleaseDate(rdate) {
September: 9,
October: 10,
November: 11,
December: 12
December: 12,
};
let m = rdate.match(/([a-zA-Z]+) (\d{4})/i);
if (m) {
return {
year: m[2],
month: months[m[1]]
month: months[m[1]],
};
}
return false;
@ -203,24 +203,15 @@ function ParseLootPage() {
// extract all tr from table with class productDetails
$('table.productDetails tr').each(function () {
// get text from first td, trim and convert it to lowercase
let prodinfolabellowcase = $(this)
.children('td')
.eq(0)
.text()
.trim()
.toLowerCase();
let prodinfolabellowcase = $(this).children('td').eq(0).text().trim().toLowerCase();
prodinfolabellowcase = prodinfolabellowcase.replace(/\s+/g, ''); //removing white spaces as switch isnt matching spaces for some reason
// get test from second td, which is the corresponding value
let value = $(this)
.children('td')
.eq(1)
.text()
.trim();
let value = $(this).children('td').eq(1).text().trim();
// now compare and process
switch (prodinfolabellowcase) {
case 'label:': // use these cases to select the spesific text values
prodlabels.push({
name: value
name: value,
});
break;
case 'releasedate:':
@ -234,7 +225,7 @@ function ParseLootPage() {
case 'performers:':
LOGGER.debug(' ** performers: **', value);
release_artist_array.push({
name: value
name: value,
});
break;
case 'format:':
@ -360,7 +351,7 @@ function ParseLootPage() {
let disc = {
position: l + 1,
format: release_format,
tracks: disclistarray[l]
tracks: disclistarray[l],
};
release.discs.push(disc);
}
@ -371,7 +362,7 @@ function ParseLootPage() {
release.urls = new Array();
release.urls.push({
url: window.location.href,
link_type: MBImport.URL_TYPES.purchase_for_mail_order
link_type: MBImport.URL_TYPES.purchase_for_mail_order,
});
// TODO check format then change purchase medium

View file

@ -369,9 +369,7 @@ var MBDiscid = (function() {
this.calculate_mb_discid = function (entries) {
let hex_left_pad = function (input, totalChars) {
input = `${parseInt(input, 10)
.toString(16)
.toUpperCase()}`;
input = `${parseInt(input, 10).toString(16).toUpperCase()}`;
let padWith = '0';
if (input.length < totalChars) {
while (input.length < totalChars) {
@ -401,10 +399,7 @@ var MBDiscid = (function() {
b64pad = '=';
let discid = b64_sha1(message);
discid = discid
.replace(/\+/g, '.')
.replace(/\//g, '_')
.replace(/=/g, '-');
discid = discid.replace(/\+/g, '.').replace(/\//g, '_').replace(/=/g, '-');
return discid;
};

View file

@ -23,29 +23,29 @@ var relationsIconsURLs = {
'cover art link': 'http://www.cdcovers.cc/favicon.ico',
secondhandsongs: 'https://musicbrainz.org/static/images/favicons/secondhandsongs-32.png',
lyrics: 'http://www.nomy.nu/img/lyrics-icon.gif',
allmusic: 'https://musicbrainz.org/static/images/favicons/allmusic-16.png'
allmusic: 'https://musicbrainz.org/static/images/favicons/allmusic-16.png',
},
'release-group': {
'single from': 'http://www.amaesingtools.com/images/left_arrow_icon.gif'
'single from': 'http://www.amaesingtools.com/images/left_arrow_icon.gif',
},
release: {
'part of set': 'http://web.archive.org/web/20060709091901/http://wiki.musicbrainz.org/-/musicbrainz/img/moin-inter.png',
remaster: 'http://web.archive.org/web/20060708200714/http://wiki.musicbrainz.org/-/musicbrainz/img/moin-www.png'
}
remaster: 'http://web.archive.org/web/20060708200714/http://wiki.musicbrainz.org/-/musicbrainz/img/moin-www.png',
},
};
var otherDatabasesIconURLs = {
'd-nb.info': 'https://musicbrainz.org/static/images/favicons/dnb-16.png',
'www.musik-sammler.de': 'https://musicbrainz.org/static/images/favicons/musiksammler-32.png',
'www.worldcat.org': 'https://musicbrainz.org/static/images/favicons/worldcat-32.png',
'rateyourmusic.com': 'https://musicbrainz.org/static/images/favicons/rateyourmusic-32.png'
'rateyourmusic.com': 'https://musicbrainz.org/static/images/favicons/rateyourmusic-32.png',
};
var incOptions = {
'release-group': ['release-group-rels', 'url-rels'],
release: ['release-rels', 'url-rels', 'discids'],
recording: ['work-rels'],
work: ['url-rels']
work: ['url-rels'],
};
// prevent JQuery conflicts, see http://wiki.greasespot.net/@grant
@ -82,15 +82,7 @@ $(document).ready(function() {
$(this)
.children('td')
.each(function () {
if (
$(this)
.find('a')
.attr('href') !== undefined &&
$(this)
.find('a')
.attr('href')
.match(mbidRE)
) {
if ($(this).find('a').attr('href') !== undefined && $(this).find('a').attr('href').match(mbidRE)) {
return false;
}
columnindex++;
@ -139,9 +131,7 @@ $(document).ready(function() {
.find("relation-list[target-type='url'] relation")
.each(function () {
let reltype = $(this).attr('type');
let target = $(this)
.children('target')
.text();
let target = $(this).children('target').text();
if (Object.prototype.hasOwnProperty.call(relationsIconsURLs.url, reltype)) {
$(`#${mbid} td.relationships`).append(
`<a href='${target.replace(/'/g, '&apos;')}'>` +
@ -164,9 +154,7 @@ $(document).ready(function() {
$(this)
.find("relation-list[target-type!='url']")
.each(function () {
let targettype = $(this)
.attr('target-type')
.replace('release_group', 'release-group');
let targettype = $(this).attr('target-type').replace('release_group', 'release-group');
let relations = {};
if (relationsIconsURLs[targettype] === undefined) {
@ -177,9 +165,7 @@ $(document).ready(function() {
.children('relation')
.each(function () {
let reltype = $(this).attr('type');
let target = $(this)
.children('target')
.text();
let target = $(this).children('target').text();
let url = targettype == 'url' ? target : `/${targettype}/${target}`;
if (Object.prototype.hasOwnProperty.call(relationsIconsURLs[targettype], reltype)) {

View file

@ -103,9 +103,7 @@ $(document).ready(function() {
if (window.location.href.match(re)) {
$('form')
.filter(function () {
return $(this)
.prop('action')
.match('merge_queue');
return $(this).prop('action').match('merge_queue');
})
.attr('target', '_blank');
}
@ -114,13 +112,8 @@ $(document).ready(function() {
re = new RegExp('musicbrainz.org/.*/(open_)?edits', 'i');
if (window.location.href.match(re)) {
$('div.edit-description ~ h2').each(function () {
let parts = $(this)
.find('a')
.text()
.split(' - ');
$(this)
.find('a')
.text(parts[0]);
let parts = $(this).find('a').text().split(' - ');
$(this).find('a').text(parts[0]);
$(this).append(` - ${parts[1]}`);
});
}
@ -129,9 +122,7 @@ $(document).ready(function() {
re = new RegExp('musicbrainz.org/(.*/(open_)?edits|edit/d+)', 'i');
if (window.location.href.match(re)) {
$("div.edit-description ~ h2:contains('cover art')").each(function () {
$editdetails = $(this)
.parents('.edit-header')
.siblings('.edit-details');
$editdetails = $(this).parents('.edit-header').siblings('.edit-details');
mbid = $editdetails
.find("a[href*='musicbrainz.org/release/']")
.attr('href')
@ -177,10 +168,7 @@ $(document).ready(function() {
let reg = new RegExp('([A-Z]{2}[A-Z0-9]{3}[0-9]{7})');
$('#content table.tbl tbody tr').each(function () {
let $td = $(this).find(`td:eq(${isrcColNo})`);
let isrcs = $td
.text()
.trim()
.split('\n<br>\n');
let isrcs = $td.text().trim().split('\n<br>\n');
let newHTML = '';
$.each(isrcs, function (index, isrc) {
isrc = isrc.trim();
@ -241,14 +229,7 @@ $(document).ready(function() {
$medium.find('thead tr').each(function () {
$(this)
.find('th:eq(0)')
.attr(
'colspan',
$(this)
.find('th:eq(0)')
.attr('colspan') *
1 +
1
);
.attr('colspan', $(this).find('th:eq(0)').attr('colspan') * 1 + 1);
});
// Table sub-header
$medium
@ -264,11 +245,7 @@ $(document).ready(function() {
let recording = track.recording;
// Recording comment
if (recording.disambiguation != '') {
let td_title_index = $(`#${track_mbid}`)
.find('td:eq(1)')
.hasClass('video')
? 2
: 1;
let td_title_index = $(`#${track_mbid}`).find('td:eq(1)').hasClass('video') ? 2 : 1;
$(`#${track_mbid}`)
.find(`td:eq(${td_title_index}) a:eq(0)`)
.after(` <span class="comment">(${recording.disambiguation})</span>`);

View file

@ -62,12 +62,7 @@ function getGenericalData() {
}
function getArtistsList() {
return $.map(
$('h2.band_name')
.text()
.split('/'),
$.trim
);
return $.map($('h2.band_name').text().split('/'), $.trim);
}
function retrieveReleaseInfo(release_url) {
@ -87,7 +82,7 @@ function retrieveReleaseInfo(release_url) {
packaging: '',
language: '',
script: '',
urls: []
urls: [],
};
let rdata = getGenericalData();
@ -104,7 +99,7 @@ function retrieveReleaseInfo(release_url) {
release.artist_credit.push({
artist_name: artists[i],
credited_name: artists[i],
joinphrase: i != artists.length - 1 ? joinphrase : ''
joinphrase: i != artists.length - 1 ? joinphrase : '',
});
}
release.title = $('h1.album_name').text();
@ -125,7 +120,7 @@ function retrieveReleaseInfo(release_url) {
release.labels.push({
name: label,
catno: catno,
mbid: label_mbid
mbid: label_mbid,
});
}
@ -150,9 +145,7 @@ function retrieveReleaseInfo(release_url) {
}
}
let identifiers = $('#album_tabs_notes > div:nth-child(2)')
.find('p:not([class])')
.contents();
let identifiers = $('#album_tabs_notes > div:nth-child(2)').find('p:not([class])').contents();
for (let j = 0; j < identifiers.length; j++) {
if (identifiers[j].textContent.indexOf('Barcode:') != -1) {
release.barcode = $.trim(identifiers[j].textContent.substring(8));
@ -164,13 +157,13 @@ function retrieveReleaseInfo(release_url) {
let link_type = MBImport.URL_TYPES;
release.urls.push({
url: release_url,
link_type: link_type.other_databases
link_type: link_type.other_databases,
});
let releaseNumber = 0;
let disc = {
tracks: [],
format: release.format
format: release.format,
};
release.discs.push(disc);
@ -182,7 +175,7 @@ function retrieveReleaseInfo(release_url) {
releaseNumber++;
release.discs.push({
tracks: [],
format: release.format
format: release.format,
});
}
@ -191,7 +184,7 @@ function retrieveReleaseInfo(release_url) {
number: trackNumber,
title: $.trim(element.children[1].textContent.replace(/\s+/g, ' ')),
duration: $.trim(element.children[2].textContent),
artist_credit: [release.artist_credit]
artist_credit: [release.artist_credit],
};
release.discs[releaseNumber].tracks.push(track);
});
@ -207,14 +200,14 @@ function insertLink(release, release_url) {
$('h2.band_name').after(mbUI);
$('#musicbrainz-import form').css({
padding: '0'
padding: '0',
});
$('form.musicbrainz_import').css({
display: 'inline-block',
margin: '1px'
margin: '1px',
});
$('form.musicbrainz_import img').css({
display: 'inline-block'
display: 'inline-block',
});
mbUI.slideDown();
@ -249,7 +242,7 @@ var ReleaseTypes = {
EP: ['ep'],
Compilation: ['album', 'compilation'],
Split: ['album'],
Collaboration: ['']
Collaboration: [''],
};
//ReleaseFormat[MAformat]="MBformat";
@ -265,5 +258,5 @@ var ReleaseFormat = {
'2 12" vinyls': '12" Vinyl',
'12" vinyl (33⅓ RPM)': '12" Vinyl',
Cassette: 'Cassette',
Digital: 'Digital Media'
Digital: 'Digital Media',
};

View file

@ -99,7 +99,7 @@ function parseRelease(data) {
release.urls = [];
release.urls.push({
url: release.url,
link_type: MBImport.URL_TYPES.purchase_for_download
link_type: MBImport.URL_TYPES.purchase_for_download,
});
// release timestamps are using France time + daylight saving (GMT+1 or GMT+2),
@ -113,7 +113,7 @@ function parseRelease(data) {
$.each(data.label.name.split(' - '), function (index, label) {
release.labels.push({
name: label,
catno: '[none]' // no catno on qobuz ?
catno: '[none]', // no catno on qobuz ?
});
});
release.isrcs = [];
@ -127,12 +127,12 @@ function parseRelease(data) {
if (trackobj.media_number != old_media_num) {
release.discs.push({
tracks: tracks,
format: 'Digital Media'
format: 'Digital Media',
});
if (is_classical) {
release.classical.discs.push({
tracks: classical_tracks,
format: 'Digital Media'
format: 'Digital Media',
});
classical_tracks = [];
}
@ -187,12 +187,12 @@ function parseRelease(data) {
});
release.discs.push({
tracks: tracks,
format: 'Digital Media'
format: 'Digital Media',
});
if (is_classical) {
release.classical.discs.push({
tracks: classical_tracks,
format: 'Digital Media'
format: 'Digital Media',
});
}
@ -232,9 +232,7 @@ function insertLink(release) {
parameters = MBImport.buildFormParameters(release, edit_note),
$album_form = $(MBImport.buildFormHTML(parameters)),
search_form = MBImport.buildSearchButton(release);
let mbUI = $('<p class="musicbrainz_import">')
.append($album_form, search_form)
.hide();
let mbUI = $('<p class="musicbrainz_import">').append($album_form, search_form).hide();
if (is_classical) {
let classical_release = $.extend({}, release);
@ -271,12 +269,12 @@ function insertLink(release) {
$('#info div.meta').append(mbUI);
$('form.musicbrainz_import').css({
display: 'inline-block',
margin: '1px'
margin: '1px',
});
$('form.musicbrainz_import img').css({
display: 'inline-block',
width: '16px',
height: '16px'
height: '16px',
});
$('label.musicbrainz_import').css({
'white-space': 'nowrap',
@ -292,10 +290,10 @@ function insertLink(release) {
'background-color': 'rgba(240,240,240,0.8)',
color: '#334',
height: '26px',
'box-sizing': 'border-box'
'box-sizing': 'border-box',
});
$('label.musicbrainz_import input').css({
margin: '0 4px 0 0'
margin: '0 4px 0 0',
});
mbUI.slideDown();
}
@ -326,9 +324,7 @@ $(document).ready(function() {
MBImportStyle();
// replace image zoom link by the maximum size image link
let maximgurl = $('#product-cover-link')
.attr('href')
.replace('_600', '_max');
let maximgurl = $('#product-cover-link').attr('href').replace('_600', '_max');
let maximg = new Image();
maximg.onerror = function (evt) {
LOGGER.debug('No max image');

View file

@ -66,13 +66,9 @@ function setRecordingComments() {
}
$tracks.each(function () {
let $td = $(this)
.children('td:not(.pos):not(.video):not(.rating):not(.treleases)')
.has('a[href^=\\/recording\\/]'),
let $td = $(this).children('td:not(.pos):not(.video):not(.rating):not(.treleases)').has('a[href^=\\/recording\\/]'),
node = $td.children('td > .mp, td > .name-variation, td > a[href^=\\/recording\\/]').filter(':first'),
$input = $('<input />')
.addClass('recording-comment')
.insertAfter(node);
$input = $('<input />').addClass('recording-comment').insertAfter(node);
if (!editing) {
$input.hide();
@ -88,10 +84,7 @@ function setRecordingComments() {
for (let i = 0, len = comments.length; i < len; i++) {
let comment = comments[i];
$inputs
.eq(i)
.val(comment)
.data('old', comment);
$inputs.eq(i).val(comment).data('old', comment);
}
});
}, 1000);
@ -114,9 +107,7 @@ function setRecordingComments() {
.addClass('styled-button')
.on('click', function () {
editing = !editing;
$('#set-recording-comments')
.add($inputs)
.toggle(editing);
$('#set-recording-comments').add($inputs).toggle(editing);
$(this).text(`${editing ? 'Hide' : 'Edit'} recording comments`);
if (editing) {
$('#all-recording-comments').focus();
@ -154,10 +145,7 @@ function setRecordingComments() {
$('#set-recording-comments').hide();
$('#all-recording-comments').on('input', function () {
$inputs
.filter(':visible')
.val(this.value)
.trigger('input.rc');
$inputs.filter(':visible').val(this.value).trigger('input.rc');
});
var $submitButton = $('#submit-recording-comments').on('click', function () {
@ -186,10 +174,7 @@ function setRecordingComments() {
deferred
.done(function () {
$input
.data('old', comment)
.trigger('input.rc')
.prop('disabled', false);
$input.data('old', comment).trigger('input.rc').prop('disabled', false);
})
.fail(function () {
$input.css('border-color', 'red').prop('disabled', false);
@ -214,7 +199,7 @@ function setRecordingComments() {
url: '/ws/js/edit/create',
dataType: 'json',
data: JSON.stringify({ edits: editData, editNote: editNote, makeVotable: makeVotable }),
contentType: 'application/json; charset=utf-8'
contentType: 'application/json; charset=utf-8',
})
.always(function () {
$submitButton.prop('disabled', false).text('Submit changes (marked red)');

View file

@ -114,7 +114,7 @@ function insertAPISection() {
if (DEBUG)
fmaUI.css({
border: '1px dotted red'
border: '1px dotted red',
});
let fmaStatusBlock = $(
@ -128,7 +128,7 @@ function insertAPISection() {
display: 'inline-block',
float: 'left',
height: '120px',
width: '49%'
width: '49%',
});
fmaUI.slideDown();
@ -157,23 +157,23 @@ var updateAPISection = {
case 'completed': // Definition is that api call was successfull hence busy retrieving data
//test chaging status of album api to error retrieving data after 2 seconds
$('#lbut-lt-fma-api-album').css({
'background-color': 'green'
'background-color': 'green',
});
break;
case 'busy': // Definition is that api call was successfull hence busy retrieving data
//test chaging status of album api to error retrieving data after 2 seconds
$('#lbut-lt-fma-api-album').css({
'background-color': 'orange'
'background-color': 'orange',
});
break;
case 'fail': // Definition is that api call was successfull hence busy retrieving data
//test chaging status of album api to error retrieving data after 2 seconds
$('#lbut-lt-fma-api-album').css({
'background-color': 'red'
'background-color': 'red',
});
break;
}
}
},
};
// function to determine if JSON or sub objects exist
@ -199,7 +199,7 @@ function insertMBSection(release) {
).hide();
if (DEBUG)
mbUI.css({
border: '1px dotted red'
border: '1px dotted red',
});
let mbContentBlock = $(
@ -212,7 +212,7 @@ function insertMBSection(release) {
color: 'red',
float: 'left',
'margin-top': '4px',
'margin-bottom': '4px'
'margin-bottom': '4px',
});
mbContentBlock.prepend(warning_buggy);
}
@ -235,7 +235,7 @@ function insertMBSection(release) {
'background-color': '#eb743b',
position: 'absolute',
top: '150px',
width: '100%'
width: '100%',
});
$('form.musicbrainz_import').css({
@ -256,7 +256,7 @@ function insertMBSection(release) {
'text-align': 'center',
cursor: 'pointer',
'background-color': '#0b79bf',
color: '#fefefe'
color: '#fefefe',
});
$('form.musicbrainz_import_search').css({
@ -277,7 +277,7 @@ function insertMBSection(release) {
'text-align': 'center',
cursor: 'pointer',
'background-color': '#0b79bf',
color: '#fefefe'
color: '#fefefe',
});
/* $('#mb_buttons').css({
@ -310,7 +310,7 @@ function insertAPIKEYSection() {
).hide();
if (DEBUG)
mbUI.css({
border: '1px dotted red'
border: '1px dotted red',
});
let mbContentBlock = $('<div class="section_content"></div>');
@ -328,13 +328,13 @@ function insertAPIKEYSection() {
display: 'block',
float: 'right',
height: '120px',
width: '49%'
width: '49%',
});
$('#mb_buttons').css({
display: 'inline-block',
float: 'right',
height: '80px'
height: '80px',
});
mbUI.slideDown();
@ -560,13 +560,13 @@ function Parsefmarelease(albumobject, trackobject) {
// Release URL
fmarelease.urls.push({
url: albumobject.uri,
link_type: MBImport.URL_TYPES.purchase_for_mail_order
link_type: MBImport.URL_TYPES.purchase_for_mail_order,
});
} else {
// Release URL
fmarelease.urls.push({
url: albumobject.uri,
link_type: MBImport.URL_TYPES.purchase_for_mail_order
link_type: MBImport.URL_TYPES.purchase_for_mail_order,
});
}
@ -588,7 +588,7 @@ function Parsefmarelease(albumobject, trackobject) {
//labels
if (hasProp(albumobject, 'meta.Label')) {
fmarelease.labels.push({
name: albumobject.meta.Label
name: albumobject.meta.Label,
});
}
@ -761,7 +761,7 @@ function Parsefmarelease(albumobject, trackobject) {
let disc = {
position: l + 1,
format: DiscFormats[fmarelease.disc_format],
tracks: disclistarray[l]
tracks: disclistarray[l],
};
fmarelease.discs.push(disc);
}