mirror of
https://github.com/murdos/musicbrainz-userscripts
synced 2024-12-13 20:02:27 +00:00
Ensure parseInt() base to be 10
Octal as default was dropped since ECMAScript 5, but better safe than sorry. Also it ensures parsing '0xa' returns 0, and not 10 (hexa->dec)
This commit is contained in:
parent
b2cf577bd3
commit
0da85a03dc
6 changed files with 16 additions and 16 deletions
|
@ -105,7 +105,7 @@ var BandcampImport = {
|
||||||
// album description indicates number of tracks in the download
|
// album description indicates number of tracks in the download
|
||||||
var match = /^\d+ track album$/.exec($("meta[property='og:description']").attr("content"));
|
var match = /^\d+ track album$/.exec($("meta[property='og:description']").attr("content"));
|
||||||
if (match) {
|
if (match) {
|
||||||
numtracks = parseInt(match);
|
numtracks = parseInt(match, 10);
|
||||||
}
|
}
|
||||||
if (numtracks > 0 && numtracks > showntracks) {
|
if (numtracks > 0 && numtracks > showntracks) {
|
||||||
// display a warning if tracks in download differs from tracks shown
|
// display a warning if tracks in download differs from tracks shown
|
||||||
|
|
|
@ -67,7 +67,7 @@ var CD1DImporter = {
|
||||||
// describes the first and second <td> in the row.
|
// describes the first and second <td> in the row.
|
||||||
var duration = row.find('td.tracklist-content-length').text().replace('"', '').replace('\' ', ':').split(
|
var duration = row.find('td.tracklist-content-length').text().replace('"', '').replace('\' ', ':').split(
|
||||||
':');
|
':');
|
||||||
duration = 60 * parseInt(duration[0]) + parseInt(duration[1]); // convert MM:SS to seconds
|
duration = 60 * parseInt(duration[0], 10) + parseInt(duration[1], 10); // convert MM:SS to seconds
|
||||||
|
|
||||||
// drop track number prefix (A A2 C3 01 05 etc...)
|
// drop track number prefix (A A2 C3 01 05 etc...)
|
||||||
var title = row.find('td.tracklist-content-title').text().replace(/^[0-9A-F][0-9]* /, '');
|
var title = row.find('td.tracklist-content-title').text().replace(/^[0-9A-F][0-9]* /, '');
|
||||||
|
@ -164,9 +164,9 @@ var CD1DImporter = {
|
||||||
.replace('December', '12')
|
.replace('December', '12')
|
||||||
.split(' ');
|
.split(' ');
|
||||||
return {
|
return {
|
||||||
'year': parseInt(date[2]),
|
'year': parseInt(date[2], 10),
|
||||||
'month': parseInt(date[1]),
|
'month': parseInt(date[1], 10),
|
||||||
'day': parseInt(date[0])
|
'day': parseInt(date[0], 10)
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -210,7 +210,7 @@ function hmsToSeconds(str) {
|
||||||
var s = 0;
|
var s = 0;
|
||||||
var m = 1;
|
var m = 1;
|
||||||
while (t.length > 0) {
|
while (t.length > 0) {
|
||||||
s += m * parseInt(t.pop());
|
s += m * parseInt(t.pop(), 10);
|
||||||
m *= 60;
|
m *= 60;
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
|
@ -219,8 +219,8 @@ function hmsToSeconds(str) {
|
||||||
// convert seconds to H:M:S or M:SS
|
// convert seconds to H:M:S or M:SS
|
||||||
function secondsToHms(secs) {
|
function secondsToHms(secs) {
|
||||||
var sep = ':';
|
var sep = ':';
|
||||||
var h = parseInt(secs/3600) % 24;
|
var h = parseInt(secs/3600, 10) % 24;
|
||||||
var m = parseInt(secs/60) % 60;
|
var m = parseInt(secs/60, 10) % 60;
|
||||||
var s = secs % 60;
|
var s = secs % 60;
|
||||||
var r = "";
|
var r = "";
|
||||||
if (h > 0) {
|
if (h > 0) {
|
||||||
|
|
|
@ -250,7 +250,7 @@ function parseEncyclopedisquePage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Barcode ?
|
// Barcode ?
|
||||||
if (parseInt(release.year) <= 1982) {
|
if (parseInt(release.year, 10) <= 1982) {
|
||||||
// FIXME: not working
|
// FIXME: not working
|
||||||
release.no_barcode = '1';
|
release.no_barcode = '1';
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ var MBLinks = function (cachekey, expiration) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.cache = {};
|
this.cache = {};
|
||||||
this.expirationMinutes = parseInt(expiration);
|
this.expirationMinutes = parseInt(expiration, 10);
|
||||||
this.cache_key = cachekey;
|
this.cache_key = cachekey;
|
||||||
this.mb_server = '//musicbrainz.org';
|
this.mb_server = '//musicbrainz.org';
|
||||||
// overrides link title and img src url (per type), see createMusicBrainzLink()
|
// overrides link title and img src url (per type), see createMusicBrainzLink()
|
||||||
|
|
|
@ -246,7 +246,7 @@ var log_input_to_entries = function(text) {
|
||||||
var m = toc_entry_matcher.exec(value);
|
var m = toc_entry_matcher.exec(value);
|
||||||
if (m) {
|
if (m) {
|
||||||
// New disc
|
// New disc
|
||||||
if (parseInt(m[1]) == 1) {
|
if (parseInt(m[1], 10) == 1) {
|
||||||
if (entries.length > 0) { discs.push(entries); }
|
if (entries.length > 0) { discs.push(entries); }
|
||||||
entries = [];
|
entries = [];
|
||||||
}
|
}
|
||||||
|
@ -272,7 +272,7 @@ var log_input_to_entries = function(text) {
|
||||||
var get_layout_type = function(entries) {
|
var get_layout_type = function(entries) {
|
||||||
var type = "standard";
|
var type = "standard";
|
||||||
for (var i=0; i<entries.length-1; i++) {
|
for (var i=0; i<entries.length-1; i++) {
|
||||||
var gap = parseInt(entries[i+1][4]) - parseInt(entries[i][5]) - 1;
|
var gap = parseInt(entries[i+1][4], 10) - parseInt(entries[i][5], 10) - 1;
|
||||||
if (gap != 0) {
|
if (gap != 0) {
|
||||||
if (i == entries.length-2 && gap == DATA_TRACK_GAP) {
|
if (i == entries.length-2 && gap == DATA_TRACK_GAP) {
|
||||||
type = "with_data";
|
type = "with_data";
|
||||||
|
@ -290,10 +290,10 @@ var calculate_mb_toc_numbers = function(entries) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var leadout_offset = parseInt(entries[entries.length - 1][5]) + PREGAP + 1;
|
var leadout_offset = parseInt(entries[entries.length - 1][5], 10) + PREGAP + 1;
|
||||||
|
|
||||||
var offsets = $.map(entries, function(entry) {
|
var offsets = $.map(entries, function(entry) {
|
||||||
return parseInt(entry[4]) + PREGAP;
|
return parseInt(entry[4], 10) + PREGAP;
|
||||||
})
|
})
|
||||||
return [1, entries.length, leadout_offset].concat(offsets);
|
return [1, entries.length, leadout_offset].concat(offsets);
|
||||||
}
|
}
|
||||||
|
@ -317,11 +317,11 @@ var calculate_cddb_id = function(entries) {
|
||||||
return number.toString(16).toUpperCase();
|
return number.toString(16).toUpperCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
var length_seconds = Math.floor((parseInt(entries[entries.length-1][5]) - parseInt(entries[0][4]) + 1)
|
var length_seconds = Math.floor((parseInt(entries[entries.length-1][5], 10) - parseInt(entries[0][4], 10) + 1)
|
||||||
/ SECTORS_PER_SECOND);
|
/ SECTORS_PER_SECOND);
|
||||||
var checksum = 0;
|
var checksum = 0;
|
||||||
$.each(entries, function(index, entry) {
|
$.each(entries, function(index, entry) {
|
||||||
checksum += sum_of_digits(Math.floor((parseInt(entry[4]) + PREGAP) / SECTORS_PER_SECOND));
|
checksum += sum_of_digits(Math.floor((parseInt(entry[4], 10) + PREGAP) / SECTORS_PER_SECOND));
|
||||||
})
|
})
|
||||||
|
|
||||||
var xx = checksum % 255;
|
var xx = checksum % 255;
|
||||||
|
|
Loading…
Reference in a new issue