diff --git a/.eslintrc.json b/.eslintrc.json index 3a0ad10..0228d30 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -10,7 +10,6 @@ "prettier/prettier": "error", "prefer-template": "error", "no-console": "off", - "no-empty": "warn", "no-inner-declarations": "warn", "no-global-assign": "warn", "no-redeclare": "warn", @@ -19,7 +18,6 @@ "no-useless-concat": "warn", "no-useless-escape": "warn", "no-unused-vars": "warn", - "no-var": "warn", - "use-isnan": "warn" + "no-var": "warn" } } diff --git a/batch-add-recording-relationships.user.js b/batch-add-recording-relationships.user.js index 5fd6b41..feaf217 100644 --- a/batch-add-recording-relationships.user.js +++ b/batch-add-recording-relationships.user.js @@ -453,10 +453,11 @@ function batch_recording_rels() { let parsedDate = parseDate(this.value); if ( - (parsedDate.year || parsedDate.month || parsedDate.day) && - isDateValid(parsedDate.year, parsedDate.month, parsedDate.day) + !( + (parsedDate.year || parsedDate.month || parsedDate.day) && + isDateValid(parsedDate.year, parsedDate.month, parsedDate.day) + ) ) { - } else { $input.css('border-color', '#f00'); parsedDate = null; } @@ -532,7 +533,7 @@ function batch_recording_rels() { get_filtered_page(0); } else { queue_recordings_request( - `/ws/2/recording?artist=${ARTIST_MBID}&inc=work-rels` + `&limit=100` + `&offset=${(CURRENT_PAGE - 1) * 100}&fmt=json` + `/ws/2/recording?artist=${ARTIST_MBID}&inc=work-rels&limit=100&offset=${(CURRENT_PAGE - 1) * 100}&fmt=json` ); } @@ -599,10 +600,9 @@ function batch_recording_rels() { } function get_filtered_page(page) { - let url = - `/ws/2/recording?query=${NAME_FILTER ? `${encodeURIComponent(NAME_FILTER)}%20AND%20` : ''}${ - ARTIST_FILTER ? `creditname:${encodeURIComponent(ARTIST_FILTER)}%20AND%20` : '' - } arid:${ARTIST_MBID}&limit=100` + `&offset=${page * 100}&fmt=json`; + let url = `/ws/2/recording?query=${NAME_FILTER ? `${encodeURIComponent(NAME_FILTER)}%20AND%20` : ''}${ + ARTIST_FILTER ? `creditname:${encodeURIComponent(ARTIST_FILTER)}%20AND%20` : '' + } arid:${ARTIST_MBID}&limit=100&offset=${page * 100}&fmt=json`; ws_requests.push_get(url, function(data) { _.each(data.recordings, function(r) { diff --git a/dgdecca_importer.user.js b/dgdecca_importer.user.js index 75b5b2e..5ce7c4c 100644 --- a/dgdecca_importer.user.js +++ b/dgdecca_importer.user.js @@ -53,7 +53,7 @@ var labels = { } }; -var editNote = `Imported from ${document.URL}\n —\n` + `GM script: "${meta.name}" (${meta.version})\n\n`; +var editNote = `Imported from ${document.URL}\n —\nGM script: "${meta.name}" (${meta.version})\n\n`; function _clean(s) { return s diff --git a/lib/logger.js b/lib/logger.js index f911374..35609e3 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -37,7 +37,9 @@ var LOGGER = (function() { if (console && console.log && console.log.apply) { try { console.log.apply(this, args); - } catch (e) {} + } catch (e) { + // do nothing + } } } diff --git a/lib/mbimport.js b/lib/mbimport.js index 7085d03..0fe93ae 100644 --- a/lib/mbimport.js +++ b/lib/mbimport.js @@ -322,7 +322,7 @@ var MBImport = (function() { // convert HH:MM:SS or MM:SS to milliseconds function hmsToMilliSeconds(str) { - if (typeof str == 'undefined' || str === null || str === NaN || str === '') return NaN; + if (typeof str == 'undefined' || str === null || isNaN(str) || str === '') return NaN; if (typeof str == 'number') return str; let t = str.split(':'); let s = 0; diff --git a/lib/mbimportstyle.js b/lib/mbimportstyle.js index 99bd1b5..ad31cb9 100644 --- a/lib/mbimportstyle.js +++ b/lib/mbimportstyle.js @@ -3,73 +3,71 @@ function _add_css(css) { } function MBImportStyle() { - let css_import_button = - ' \ - .musicbrainz_import button { \ - -moz-border-radius:5px; \ - -webkit-border-radius:5px; \ - border-radius:5px; \ - display:inline-block; \ - cursor:pointer; \ - font-family:Arial; \ - font-size:12px !important; \ - padding:3px 6px; \ - text-decoration:none; \ - border: 1px solid rgba(180,180,180,0.8) !important; \ - background-color: rgba(240,240,240,0.8) !important; \ - color: #334 !important; \ - height: 26px ;\ - } \ - .musicbrainz_import button:hover { \ - background-color: rgba(250,250,250,0.9) !important; \ - } \ - .musicbrainz_import button:active { \ - background-color: rgba(170,170,170,0.8) !important; \ - } \ - .musicbrainz_import button img { \ - vertical-align: middle !important; \ - margin-right: 4px !important; \ - height: 16px; \ - } \ - .musicbrainz_import button span { \ - min-height: 16px; \ - display: inline-block; \ - } \ - '; + let css_import_button = ` + .musicbrainz_import button { + -moz-border-radius:5px; + -webkit-border-radius:5px; + border-radius:5px; + display:inline-block; + cursor:pointer; + font-family:Arial; + font-size:12px !important; + padding:3px 6px; + text-decoration:none; + border: 1px solid rgba(180,180,180,0.8) !important; + background-color: rgba(240,240,240,0.8) !important; + color: #334 !important; + height: 26px ; + } + .musicbrainz_import button:hover { + background-color: rgba(250,250,250,0.9) !important; + } + .musicbrainz_import button:active { + background-color: rgba(170,170,170,0.8) !important; + } + .musicbrainz_import button img { + vertical-align: middle !important; + margin-right: 4px !important; + height: 16px; + } + .musicbrainz_import button span { + min-height: 16px; + display: inline-block; + } + `; _add_css(css_import_button); } function MBSearchItStyle() { - let css_search_it = - ' \ - .mb_valign { \ - display: inline-block; \ - vertical-align: top; \ - } \ - .mb_searchit { \ - width: 16px; \ - height: 16px; \ - margin: 0; \ - padding: 0; \ - background-color: #FFF7BE; \ - border: 0px; \ - vertical-align: top; \ - font-size: 11px; \ - text-align: center; \ - } \ - a.mb_search_link { \ - color: #888; \ - text-decoration: none; \ - } \ - a.mb_search_link small { \ - font-size: 8px; \ - } \ - .mb_searchit a.mb_search_link:hover { \ - color: darkblue; \ - } \ - .mb_wrapper { \ - display: inline-block; \ - } \ - '; + let css_search_it = ` + .mb_valign { + display: inline-block; + vertical-align: top; + } + .mb_searchit { + width: 16px; + height: 16px; + margin: 0; + padding: 0; + background-color: #FFF7BE; + border: 0px; + vertical-align: top; + font-size: 11px; + text-align: center; + } + a.mb_search_link { + color: #888; + text-decoration: none; + } + a.mb_search_link small { + font-size: 8px; + } + .mb_searchit a.mb_search_link:hover { + color: darkblue; + } + .mb_wrapper { + display: inline-block; + } + `; _add_css(css_search_it); } diff --git a/mb_discids_detector.user.js b/mb_discids_detector.user.js index ba036cd..b503d9e 100644 --- a/mb_discids_detector.user.js +++ b/mb_discids_detector.user.js @@ -190,7 +190,7 @@ function gazellePageHandler() { // Common functions function computeAttachURL(mb_toc_numbers, artistName, releaseName) { - let url = `${'http://musicbrainz.org/cdtoc/attach' + '?toc='}${mb_toc_numbers.join('%20')}&artist-name=${encodeURIComponent( + let url = `${'http://musicbrainz.org/cdtoc/attach?toc='}${mb_toc_numbers.join('%20')}&artist-name=${encodeURIComponent( artistName )}&release-name=${encodeURIComponent(releaseName)}`; return url; @@ -377,12 +377,10 @@ var MBDiscid = (function() { while (input.length < totalChars) { input = padWith + input; } - } else { } if (input.length > totalChars) { //if padWith was a multiple character string and num was overpadded input = input.substring(input.length - totalChars, totalChars); - } else { } return input;