mirror of
https://github.com/murdos/musicbrainz-userscripts
synced 2024-12-12 19:32: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
|
||||
var match = /^\d+ track album$/.exec($("meta[property='og:description']").attr("content"));
|
||||
if (match) {
|
||||
numtracks = parseInt(match);
|
||||
numtracks = parseInt(match, 10);
|
||||
}
|
||||
if (numtracks > 0 && numtracks > showntracks) {
|
||||
// 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.
|
||||
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...)
|
||||
var title = row.find('td.tracklist-content-title').text().replace(/^[0-9A-F][0-9]* /, '');
|
||||
|
@ -164,9 +164,9 @@ var CD1DImporter = {
|
|||
.replace('December', '12')
|
||||
.split(' ');
|
||||
return {
|
||||
'year': parseInt(date[2]),
|
||||
'month': parseInt(date[1]),
|
||||
'day': parseInt(date[0])
|
||||
'year': parseInt(date[2], 10),
|
||||
'month': parseInt(date[1], 10),
|
||||
'day': parseInt(date[0], 10)
|
||||
};
|
||||
},
|
||||
|
||||
|
|
|
@ -210,7 +210,7 @@ function hmsToSeconds(str) {
|
|||
var s = 0;
|
||||
var m = 1;
|
||||
while (t.length > 0) {
|
||||
s += m * parseInt(t.pop());
|
||||
s += m * parseInt(t.pop(), 10);
|
||||
m *= 60;
|
||||
}
|
||||
return s;
|
||||
|
@ -219,8 +219,8 @@ function hmsToSeconds(str) {
|
|||
// convert seconds to H:M:S or M:SS
|
||||
function secondsToHms(secs) {
|
||||
var sep = ':';
|
||||
var h = parseInt(secs/3600) % 24;
|
||||
var m = parseInt(secs/60) % 60;
|
||||
var h = parseInt(secs/3600, 10) % 24;
|
||||
var m = parseInt(secs/60, 10) % 60;
|
||||
var s = secs % 60;
|
||||
var r = "";
|
||||
if (h > 0) {
|
||||
|
|
|
@ -250,7 +250,7 @@ function parseEncyclopedisquePage() {
|
|||
}
|
||||
|
||||
// Barcode ?
|
||||
if (parseInt(release.year) <= 1982) {
|
||||
if (parseInt(release.year, 10) <= 1982) {
|
||||
// FIXME: not working
|
||||
release.no_barcode = '1';
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ var MBLinks = function (cachekey, expiration) {
|
|||
}
|
||||
};
|
||||
this.cache = {};
|
||||
this.expirationMinutes = parseInt(expiration);
|
||||
this.expirationMinutes = parseInt(expiration, 10);
|
||||
this.cache_key = cachekey;
|
||||
this.mb_server = '//musicbrainz.org';
|
||||
// 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);
|
||||
if (m) {
|
||||
// New disc
|
||||
if (parseInt(m[1]) == 1) {
|
||||
if (parseInt(m[1], 10) == 1) {
|
||||
if (entries.length > 0) { discs.push(entries); }
|
||||
entries = [];
|
||||
}
|
||||
|
@ -272,7 +272,7 @@ var log_input_to_entries = function(text) {
|
|||
var get_layout_type = function(entries) {
|
||||
var type = "standard";
|
||||
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 (i == entries.length-2 && gap == DATA_TRACK_GAP) {
|
||||
type = "with_data";
|
||||
|
@ -290,10 +290,10 @@ var calculate_mb_toc_numbers = function(entries) {
|
|||
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) {
|
||||
return parseInt(entry[4]) + PREGAP;
|
||||
return parseInt(entry[4], 10) + PREGAP;
|
||||
})
|
||||
return [1, entries.length, leadout_offset].concat(offsets);
|
||||
}
|
||||
|
@ -317,11 +317,11 @@ var calculate_cddb_id = function(entries) {
|
|||
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);
|
||||
var checksum = 0;
|
||||
$.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;
|
||||
|
|
Loading…
Reference in a new issue