Additional glyphicons for music on search and author page
Fix duplicate user and email (now case insensitive) Output of calibre on stderr is now logged (full traceback in debug-log, otherwise, only errormessage) Natural sorting for comic reader Fix for long running tasks
This commit is contained in:
@@ -1,3 +1,67 @@
|
||||
/* alphanum.js (C) Brian Huisman
|
||||
* Based on the Alphanum Algorithm by David Koelle
|
||||
* The Alphanum Algorithm is discussed at http://www.DaveKoelle.com
|
||||
*
|
||||
* Distributed under same license as original
|
||||
*
|
||||
* Released under the MIT License - https://opensource.org/licenses/MIT
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER 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 SOFTWARE.
|
||||
*/
|
||||
/* ********************************************************************
|
||||
* Alphanum sort() function version - case insensitive
|
||||
* - Slower, but easier to modify for arrays of objects which contain
|
||||
* string properties
|
||||
*
|
||||
*/
|
||||
function alphanumCase(a, b) {
|
||||
function chunkify(t) {
|
||||
var tz = new Array();
|
||||
var x = 0, y = -1, n = 0, i, j;
|
||||
|
||||
while (i = (j = t.charAt(x++)).charCodeAt(0)) {
|
||||
var m = (i == 46 || (i >=48 && i <= 57));
|
||||
if (m !== n) {
|
||||
tz[++y] = "";
|
||||
n = m;
|
||||
}
|
||||
tz[y] += j;
|
||||
}
|
||||
return tz;
|
||||
}
|
||||
|
||||
var aa = chunkify(a.filename.toLowerCase());
|
||||
var bb = chunkify(b.filename.toLowerCase());
|
||||
|
||||
for (x = 0; aa[x] && bb[x]; x++) {
|
||||
if (aa[x] !== bb[x]) {
|
||||
var c = Number(aa[x]), d = Number(bb[x]);
|
||||
if (c == aa[x] && d == bb[x]) {
|
||||
return c - d;
|
||||
} else return (aa[x] > bb[x]) ? 1 : -1;
|
||||
}
|
||||
}
|
||||
return aa.length - bb.length;
|
||||
}
|
||||
// ===========================================================================
|
||||
|
||||
|
||||
/**
|
||||
* archive.js
|
||||
*
|
||||
@@ -13,22 +77,6 @@
|
||||
var bitjs = bitjs || {};
|
||||
bitjs.archive = bitjs.archive || {};
|
||||
|
||||
function naturalCompare(a, b) {
|
||||
var ax = [], bx = [];
|
||||
|
||||
a.filename.toLowerCase().replace(/(\d+)|(\D+)/g, function(_, $1, $2) { ax.push([$1 || Infinity, $2 || ""]) });
|
||||
b.filename.toLowerCase().replace(/(\d+)|(\D+)/g, function(_, $1, $2) { bx.push([$1 || Infinity, $2 || ""]) });
|
||||
|
||||
while(ax.length && bx.length) {
|
||||
var an = ax.shift();
|
||||
var bn = bx.shift();
|
||||
var nn = (an[0] - bn[0]) || an[1].localeCompare(bn[1]);
|
||||
if(nn) return nn;
|
||||
}
|
||||
|
||||
return ax.length - bx.length;
|
||||
}
|
||||
|
||||
(function() {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
@@ -1332,13 +1332,7 @@ var unrar = function(arrayBuffer) {
|
||||
totalFilesInArchive = localFiles.length;
|
||||
|
||||
// now we have all information but things are unpacked
|
||||
// TODO: unpack
|
||||
localFiles.sort(naturalCompare);
|
||||
/*localFiles = localFiles.sort(function(a, b) {
|
||||
var aname = a.filename.toLowerCase();
|
||||
var bname = b.filename.toLowerCase();
|
||||
return aname > bname ? 1 : -1;
|
||||
});*/
|
||||
localFiles.sort(alphanumCase);
|
||||
|
||||
info(localFiles.map(function(a) {
|
||||
return a.filename;
|
||||
|
||||
@@ -136,7 +136,8 @@ var untar = function(arrayBuffer) {
|
||||
allLocalFiles.push(localFile);
|
||||
postProgress();
|
||||
}
|
||||
allLocalFiles.sort(naturalCompare);
|
||||
// got all local files, now sort them
|
||||
allLocalFiles.sort(alphanumCase);
|
||||
|
||||
allLocalFiles.forEach(function(oneLocalFile) {
|
||||
// While we don't encounter an empty block, keep making TarLocalFiles.
|
||||
|
||||
@@ -162,12 +162,7 @@ var unzip = function(arrayBuffer) {
|
||||
totalFilesInArchive = localFiles.length;
|
||||
|
||||
// got all local files, now sort them
|
||||
localFiles.sort(naturalCompare);
|
||||
/*localFiles.sort(function(a, b) {
|
||||
var aname = a.filename.toLowerCase();
|
||||
var bname = b.filename.toLowerCase();
|
||||
return aname > bname ? 1 : -1;
|
||||
});*/
|
||||
localFiles.sort(alphanumCase);
|
||||
|
||||
// archive extra data record
|
||||
if (bstream.peekNumber(4) === zArchiveExtraDataSignature) {
|
||||
@@ -663,51 +658,3 @@ function inflate(compressedData, numDecompressedBytes) {
|
||||
onmessage = function(event) {
|
||||
unzip(event.data.file, true);
|
||||
};
|
||||
|
||||
/*
|
||||
function naturalCompare(a, b) {
|
||||
var ax = [], bx = [];
|
||||
|
||||
a.filename.toLowerCase().replace(/(\d+)|(\D+)/g, function(_, $1, $2) { ax.push([$1 || Infinity, $2 || ""]) });
|
||||
b.filename.toLowerCase().replace(/(\d+)|(\D+)/g, function(_, $1, $2) { bx.push([$1 || Infinity, $2 || ""]) });
|
||||
|
||||
while(ax.length && bx.length) {
|
||||
var an = ax.shift();
|
||||
var bn = bx.shift();
|
||||
var nn = (an[0] - bn[0]) || an[1].localeCompare(bn[1]);
|
||||
if(nn) return nn;
|
||||
}
|
||||
|
||||
return ax.length - bx.length;
|
||||
}*/
|
||||
|
||||
|
||||
/*var re = /([a-z]+)(\d+)(.+)/i;
|
||||
function naturalCompare(a, b) {
|
||||
var ma = a.match(re),
|
||||
mb = b.match(re),
|
||||
a_str = ma[1],
|
||||
b_str = mb[1],
|
||||
a_num = parseInt(ma[2],10),
|
||||
b_num = parseInt(mb[2],10),
|
||||
a_rem = ma[3],
|
||||
b_rem = mb[3];
|
||||
return a_str > b_str ? 1 : a_str < b_str ? -1 : a_num > b_num ? 1 : a_num < b_num ? -1 : a_rem > b_rem;
|
||||
}*/
|
||||
|
||||
/*function naturalCompare(a, b) {
|
||||
var ax = [], bx = [];
|
||||
|
||||
a.replace(/(\d+)|(\D+)/g, function(_, $1, $2) { ax.push([$1 || Infinity, $2 || ""]) });
|
||||
b.replace(/(\d+)|(\D+)/g, function(_, $1, $2) { bx.push([$1 || Infinity, $2 || ""]) });
|
||||
|
||||
while(ax.length && bx.length) {
|
||||
var an = ax.shift();
|
||||
var bn = bx.shift();
|
||||
var nn = (an[0] - bn[0]) || an[1].localeCompare(bn[1]);
|
||||
if(nn) return nn;
|
||||
}
|
||||
|
||||
return ax.length - bx.length;
|
||||
}*/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user