From: Vincent Vanwaelscappel Date: Thu, 6 May 2021 17:23:30 +0000 (+0200) Subject: wip #4459 @0:05 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=61cacea4e3c090d119e025b1b0fc0c70cbad6c78;p=fluidbook-html5.git wip #4459 @0:05 --- diff --git a/js/libs/fluidbook/fluidbook.utils.js b/js/libs/fluidbook/fluidbook.utils.js index 0c87ea3b..5354347e 100644 --- a/js/libs/fluidbook/fluidbook.utils.js +++ b/js/libs/fluidbook/fluidbook.utils.js @@ -121,32 +121,3 @@ function getIframeDocument(iframe) { return doc; } -function parseRange(string) { - let res = []; - let m; - - for (let str of string.split(",").map((str) => str.trim())) { - // just a number - if (/^-?\d+$/.test(str)) { - res.push(parseInt(str, 10)); - } else if ( - (m = str.match(/^(-?\d+)(-|\.\.\.?|\u2025|\u2026|\u22EF)(-?\d+)$/)) - ) { - // 1-5 or 1..5 (equivalent) or 1...5 (doesn't include 5) - let [_, lhs, sep, rhs] = m; - - if (lhs && rhs) { - lhs = parseInt(lhs); - rhs = parseInt(rhs); - const incr = lhs < rhs ? 1 : -1; - - // Make it inclusive by moving the right 'stop-point' away by one. - if (sep === "-" || sep === ".." || sep === "\u2025") rhs += incr; - - for (let i = lhs; i !== rhs; i += incr) res.push(i); - } - } - } - - return res; -} \ No newline at end of file diff --git a/js/libs/fluidbook/special/wescosales.js b/js/libs/fluidbook/special/wescosales.js index f635649b..bbf8193e 100644 --- a/js/libs/fluidbook/special/wescosales.js +++ b/js/libs/fluidbook/special/wescosales.js @@ -454,4 +454,34 @@ WescoSalesSearchPlugin.prototype = { clearHighlights: function () { $('[data-wescosales-ref].highlight').removeClass('highlight'); }, -}; \ No newline at end of file +}; + +function parseRange(string) { + let res = []; + let m; + + for (let str of string.split(",").map((str) => str.trim())) { + // just a number + if (/^-?\d+$/.test(str)) { + res.push(parseInt(str, 10)); + } else if ( + (m = str.match(/^(-?\d+)(-|\.\.\.?|\u2025|\u2026|\u22EF)(-?\d+)$/)) + ) { + // 1-5 or 1..5 (equivalent) or 1...5 (doesn't include 5) + let [_, lhs, sep, rhs] = m; + + if (lhs && rhs) { + lhs = parseInt(lhs); + rhs = parseInt(rhs); + const incr = lhs < rhs ? 1 : -1; + + // Make it inclusive by moving the right 'stop-point' away by one. + if (sep === "-" || sep === ".." || sep === "\u2025") rhs += incr; + + for (let i = lhs; i !== rhs; i += incr) res.push(i); + } + } + } + + return res; +} \ No newline at end of file