X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=skins%2Fcommon%2Fwikibits.js;h=95b2e06974cc8ebe9f5a0f5d054ecd49bc9b3aeb;hb=4f278f513d5bf24c7252732a168e3646cc5af101;hp=0485cdff98f150d1d60c512ff1ec19b088e9d7af;hpb=8272d56034b1d85a19e81eb621dcc50b8c78ed00;p=lhc%2Fweb%2Fwiklou.git diff --git a/skins/common/wikibits.js b/skins/common/wikibits.js index 0485cdff98..95b2e06974 100644 --- a/skins/common/wikibits.js +++ b/skins/common/wikibits.js @@ -36,7 +36,6 @@ if (!window.onloadFuncts) { var onloadFuncts = []; } -// code that is dependent on js2 functions should use js2AddOnloadHook function addOnloadHook(hookFunct) { // Allows add-on scripts to add onload functions if(!doneOnloadHook) { @@ -594,8 +593,8 @@ function ts_resortTable(lnk) { preprocessor = ts_dateToSortKey; } else if (/^\d\d[\/.-]\d\d[\/.-]\d\d$/.test(itm)) { preprocessor = ts_dateToSortKey; - // pound dollar euro yen currency cents - } else if (/(^[\u00a3$\u20ac\u00a4\u00a5]|\u00a2$)/.test(itm)) { + // (minus sign)([pound dollar euro yen currency]|cents) + } else if (/(^([-\u2212] *)?[\u00a3$\u20ac\u00a4\u00a5]|\u00a2$)/.test(itm)) { preprocessor = ts_currencyToSortKey; } else if (ts_number_regex.test(itm)) { preprocessor = ts_parseFloat; @@ -706,9 +705,9 @@ function ts_initTransformTable() { // if percents and regular numbers aren't being mixed. ts_number_regex = new RegExp( "^(" + - "[+-]?[0-9][0-9,]*(\\.[0-9,]*)?(E[+-]?[0-9][0-9,]*)?" + // Fortran-style scientific + "[+-\u2212]?[0-9][0-9,]*(\\.[0-9,]*)?(E[+-\u2212]?[0-9][0-9,]*)?" + // Fortran-style scientific "|" + - "[+-]?" + digitClass + "+%?" + // Generic localised + "[+-\u2212]?" + digitClass + "+%?" + // Generic localised ")$", "i" ); } @@ -775,13 +774,12 @@ function ts_parseFloat( s ) { } s = newNum; } - - num = parseFloat(s.replace(/,/g, "")); - return (isNaN(num) ? 0 : num); + num = parseFloat(s.replace(/[, ]/g, "").replace("\u2212", "-")); + return (isNaN(num) ? -Infinity : num); } function ts_currencyToSortKey( s ) { - return ts_parseFloat(s.replace(/[^0-9.,]/g,'')); + return ts_parseFloat(s.replace(/[^-\u22120-9.,]/g,'')); } function ts_sort_generic(a, b) {