SOLR-7588: Fix javascript bug introduced by SOLR-7409 that broke dataimport in admin UI.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1684234 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shawn Heisey 2015-06-08 17:57:22 +00:00
parent 517d362a7f
commit 121707d591
2 changed files with 76 additions and 57 deletions

View File

@ -152,6 +152,28 @@ Other Changes
* SOLR-7645: Remove explicitly defined request handlers from example and test solrconfig's that are * SOLR-7645: Remove explicitly defined request handlers from example and test solrconfig's that are
already defined implicitly, such as /admin/ping, /admin/system, and several others. (ehatcher) already defined implicitly, such as /admin/ping, /admin/system, and several others. (ehatcher)
================== 5.2.1 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release
Versions of Major Components
---------------------
Apache Tika 1.7
Carrot2 3.9.0
Velocity 1.7 and Velocity Tools 2.0
Apache UIMA 2.3.1
Apache ZooKeeper 3.4.6
Jetty 9.2.10.v20150310
Detailed Change List
----------------------
Bug Fixes
----------------------
* SOLR-7588: Fix javascript bug introduced by SOLR-7409 that breaks the
dataimport screen in the admin UI. (Bill Bell via Shawn Heisey)
================== 5.2.0 ================== ================== 5.2.0 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release

View File

@ -1,5 +1,4 @@
/* /*
naturalSort.js naturalSort.js
- by Jim Palmer and other contributors - by Jim Palmer and other contributors
@ -24,62 +23,60 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
*/ */
# naturalSort.js 0.7.0 // naturalSort.js 0.7.0
# https://github.com/jarinudom/naturalSort.js // https://github.com/jarinudom/naturalSort.js
# (c) 2011 Jim Palmer and other contributors // (c) 2011 Jim Palmer and other contributors
# naturalSort.js may be freely distributed under the MIT license. // naturalSort.js may be freely distributed under the MIT license.
window.naturalSort = (a, b) -> // Generated by CoffeeScript 1.7.1
re = /(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/g (function() {
sre = /(^[ ]*|[ ]*$)/g window.naturalSort = function(a, b) {
dre = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/ var cLoc, dre, hre, i, numS, oFxNcL, oFyNcL, ore, re, sre, x, xD, xN, y, yD, yN;
hre = /^0x[0-9a-f]+$/i re = /(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/g;
ore = /^0/ sre = /(^[ ]*|[ ]*$)/g;
i = (s) -> dre = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/;
naturalSort.insensitive and ('' + s).toLowerCase() or '' + s hre = /^0x[0-9a-f]+$/i;
ore = /^0/;
i = function(s) {
return naturalSort.insensitive && ('' + s).toLowerCase() || '' + s;
};
x = i(a).replace(sre, '') || '';
y = i(b).replace(sre, '') || '';
xN = x.replace(re, '\u0000$1\u0000').replace(/\0$/, '').replace(/^\0/, '').split('\u0000');
yN = y.replace(re, '\u0000$1\u0000').replace(/\0$/, '').replace(/^\0/, '').split('\u0000');
xD = parseInt(x.match(hre), 16) || (xN.length !== 1 && x.match(dre) && Date.parse(x));
yD = parseInt(y.match(hre), 16) || xD && y.match(dre) && Date.parse(y) || null;
oFxNcL = void 0;
oFyNcL = void 0;
if (yD) {
if (xD < yD) {
return -1;
}
if (xD > yD) {
return 1;
}
}
cLoc = 0;
numS = Math.max(xN.length, yN.length);
while (cLoc < numS) {
oFxNcL = !(xN[cLoc] || '').match(ore) && parseFloat(xN[cLoc]) || xN[cLoc] || 0;
oFyNcL = !(yN[cLoc] || '').match(ore) && parseFloat(yN[cLoc]) || yN[cLoc] || 0;
if (isNaN(oFxNcL) !== isNaN(oFyNcL)) {
return (isNaN(oFxNcL) ? 1 : -1);
} else if (typeof oFxNcL !== typeof oFyNcL) {
oFxNcL += '';
oFyNcL += '';
}
if (oFxNcL < oFyNcL) {
return -1;
}
if (oFxNcL > oFyNcL) {
return 1;
}
cLoc++;
}
return 0;
};
# convert all to strings strip whitespace }).call(this);
x = i(a).replace(sre, '') or ''
y = i(b).replace(sre, '') or ''
# chunk/tokenize
xN = x.replace(re, '\u0000$1\u0000').replace(/\0$/, '').replace(/^\0/, '').split('\u0000')
yN = y.replace(re, '\u0000$1\u0000').replace(/\0$/, '').replace(/^\0/, '').split('\u0000')
# numeric, hex or date detection
xD = parseInt(x.match(hre), 16) or (xN.length isnt 1 and x.match(dre) and Date.parse(x))
yD = parseInt(y.match(hre), 16) or xD and y.match(dre) and Date.parse(y) or null
oFxNcL = undefined
oFyNcL = undefined
# first try and sort Hex codes or Dates
if yD
return -1 if xD < yD
return 1 if xD > yD
# natural sorting through split numeric strings and default strings
cLoc = 0
numS = Math.max(xN.length, yN.length)
while cLoc < numS
# find floats not starting with '0', string or 0 if not defined (Clint Priest)
oFxNcL = !(xN[cLoc] || '').match(ore) && parseFloat(xN[cLoc]) || xN[cLoc] || 0
oFyNcL = !(yN[cLoc] || '').match(ore) && parseFloat(yN[cLoc]) || yN[cLoc] || 0
# handle numeric vs string comparison - number < string - (Kyle Adams)
if isNaN(oFxNcL) != isNaN(oFyNcL)
return (if (isNaN(oFxNcL)) then 1 else -1)
# Rely on string comparison of different types - i.e. '02' < 2 != '02' < '2'
else if typeof oFxNcL != typeof oFyNcL
oFxNcL += ''
oFyNcL += ''
return -1 if oFxNcL < oFyNcL
return 1 if oFxNcL > oFyNcL
cLoc++
return 0