change code style to ffrgb/meshviewer fork
This commit is contained in:
parent
59ba0ba29e
commit
418b630e02
42 changed files with 3505 additions and 3154 deletions
|
|
@ -1,60 +1,68 @@
|
|||
define([], function () {
|
||||
function order(c) {
|
||||
if (/^\d$/.test(c))
|
||||
return 0
|
||||
else if (/^[a-z]$/i.test(c))
|
||||
return c.charCodeAt(0)
|
||||
else if (c === "~")
|
||||
return -1
|
||||
else if (c)
|
||||
return c.charCodeAt(0) + 256
|
||||
else
|
||||
return 0
|
||||
if (/^\d$/.test(c)) {
|
||||
return 0;
|
||||
} else if (/^[a-z]$/i.test(c)) {
|
||||
return c.charCodeAt(0);
|
||||
} else if (c === "~") {
|
||||
return -1;
|
||||
} else if (c) {
|
||||
return c.charCodeAt(0) + 256;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Based on dpkg code
|
||||
function vercomp(a, b) {
|
||||
var apos = 0, bpos = 0
|
||||
var apos = 0, bpos = 0;
|
||||
while (apos < a.length || bpos < b.length) {
|
||||
var firstDiff = 0
|
||||
var firstDiff = 0;
|
||||
|
||||
while ((apos < a.length && !/^\d$/.test(a[apos])) || (bpos < b.length && !/^\d$/.test(b[bpos]))) {
|
||||
var ac = order(a[apos])
|
||||
var bc = order(b[bpos])
|
||||
var ac = order(a[apos]);
|
||||
var bc = order(b[bpos]);
|
||||
|
||||
if (ac !== bc)
|
||||
return ac - bc
|
||||
if (ac !== bc) {
|
||||
return ac - bc;
|
||||
}
|
||||
|
||||
apos++
|
||||
bpos++
|
||||
apos++;
|
||||
bpos++;
|
||||
}
|
||||
|
||||
while (a[apos] === "0")
|
||||
apos++
|
||||
while (a[apos] === "0") {
|
||||
apos++;
|
||||
}
|
||||
|
||||
while (b[bpos] === "0")
|
||||
bpos++
|
||||
while (b[bpos] === "0") {
|
||||
bpos++;
|
||||
}
|
||||
|
||||
while (/^\d$/.test(a[apos]) && /^\d$/.test(b[bpos])) {
|
||||
if (firstDiff === 0)
|
||||
firstDiff = a.charCodeAt(apos) - b.charCodeAt(bpos)
|
||||
if (firstDiff === 0) {
|
||||
firstDiff = a.charCodeAt(apos) - b.charCodeAt(bpos);
|
||||
}
|
||||
|
||||
apos++
|
||||
bpos++
|
||||
apos++;
|
||||
bpos++;
|
||||
}
|
||||
|
||||
if (/^\d$/.test(a[apos]))
|
||||
return 1
|
||||
if (/^\d$/.test(a[apos])) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (/^\d$/.test(b[bpos]))
|
||||
return -1
|
||||
if (/^\d$/.test(b[bpos])) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (firstDiff !== 0)
|
||||
return firstDiff
|
||||
if (firstDiff !== 0) {
|
||||
return firstDiff;
|
||||
}
|
||||
}
|
||||
|
||||
return 0
|
||||
return 0;
|
||||
}
|
||||
|
||||
return vercomp
|
||||
})
|
||||
return vercomp;
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue