Make chunkify an internal function to prevent context errors

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
This commit is contained in:
Christoph Wurst 2019-02-01 08:51:46 +01:00
parent 0d43ef06f5
commit 799a0fbb78
No known key found for this signature in database
GPG Key ID: CC42AC2A7F0E56D8
3 changed files with 67 additions and 26 deletions

47
core/js/dist/main.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -28,6 +28,26 @@ import History from './util-history'
import OC from './index'
import humanFileSize from '../Util/human-file-size'
function chunkify(t) {
// Adapted from http://my.opera.com/GreyWyvern/blog/show.dml/1671288
let tz = [], x = 0, y = -1, n = 0, code, c;
while (x < t.length) {
c = t.charAt(x);
// only include the dot in strings
var m = ((!n && c === '.') || (c >= '0' && c <= '9'));
if (m !== n) {
// next chunk
y++;
tz[y] = '';
n = m;
}
tz[y] += c;
x++;
}
return tz;
}
/**
* Utility functions
* @namespace OC.Util
@ -169,26 +189,6 @@ export default {
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
},
_chunkify: function (t) {
// Adapted from http://my.opera.com/GreyWyvern/blog/show.dml/1671288
var tz = [], x = 0, y = -1, n = 0, code, c;
while (x < t.length) {
c = t.charAt(x);
// only include the dot in strings
var m = ((!n && c === '.') || (c >= '0' && c <= '9'));
if (m !== n) {
// next chunk
y++;
tz[y] = '';
n = m;
}
tz[y] += c;
x++;
}
return tz;
},
/**
* Compare two strings to provide a natural sort
* @param a first string to compare
@ -198,8 +198,8 @@ export default {
*/
naturalSortCompare: function (a, b) {
var x;
var aa = this._chunkify(a);
var bb = this._chunkify(b);
var aa = chunkify(a);
var bb = chunkify(b);
for (x = 0; aa[x] && bb[x]; x++) {
if (aa[x] !== bb[x]) {