rather use ''.slice than ''.substr
This commit is contained in:
parent
018eb899f2
commit
5110267971
13 changed files with 29 additions and 29 deletions
|
@ -157,7 +157,7 @@ function constructList() {
|
||||||
else
|
else
|
||||||
info.html(app.site.default_info);
|
info.html(app.site.default_info);
|
||||||
|
|
||||||
document.location.hash = hash.substring(0, hash.length-1);
|
document.location.hash = hash.slice(0, -1);
|
||||||
app.$ui.actionInfo.html(info);
|
app.$ui.actionInfo.html(info);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -145,10 +145,10 @@ Ox.load('UI', {
|
||||||
|
|
||||||
function parseQuery() {
|
function parseQuery() {
|
||||||
var vars = window.location.search.length
|
var vars = window.location.search.length
|
||||||
? window.location.search.substring(1).split('&')
|
? window.location.search.slice(1).split('&')
|
||||||
: [],
|
: [],
|
||||||
query = {
|
query = {
|
||||||
item: window.location.pathname.substring(1).split('/')[0]
|
item: window.location.pathname.slice(1).split('/')[0]
|
||||||
},
|
},
|
||||||
defaults = {
|
defaults = {
|
||||||
view: 'video',
|
view: 'video',
|
||||||
|
|
|
@ -270,7 +270,7 @@ appPanel
|
||||||
pandora.site.listSettings = {};
|
pandora.site.listSettings = {};
|
||||||
Ox.forEach(pandora.site.user.ui, function(val, key) {
|
Ox.forEach(pandora.site.user.ui, function(val, key) {
|
||||||
if (/^list[A-Z]/.test(key)) {
|
if (/^list[A-Z]/.test(key)) {
|
||||||
pandora.site.listSettings[key] = key[4].toLowerCase() + key.substr(5);
|
pandora.site.listSettings[key] = key[4].toLowerCase() + key.slice(5);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -110,8 +110,8 @@ pandora.URL = (function() {
|
||||||
set['mapSelection'] = state.span;
|
set['mapSelection'] = state.span;
|
||||||
set['mapFind'] = '';
|
set['mapFind'] = '';
|
||||||
} else {
|
} else {
|
||||||
//pandora.user.ui.mapFind = state.span.substr(1);
|
//pandora.user.ui.mapFind = state.span.slice(1);
|
||||||
set['mapFind'] = state.span.substr(1);
|
set['mapFind'] = state.span.slice(1);
|
||||||
set['mapSelection'] = '';
|
set['mapSelection'] = '';
|
||||||
}
|
}
|
||||||
} else if (state.view == 'calendar') {
|
} else if (state.view == 'calendar') {
|
||||||
|
@ -301,8 +301,8 @@ pandora.URL = (function() {
|
||||||
|
|
||||||
// on page load, this sets the state from the URL
|
// on page load, this sets the state from the URL
|
||||||
that.parse = function(callback) {
|
that.parse = function(callback) {
|
||||||
if (document.location.pathname.substr(0, 4) == 'url=') {
|
if (document.location.pathname.slice(0, 4) == 'url=') {
|
||||||
document.location.href = decodeURI(document.location.pathname.substr(4));
|
document.location.href = decodeURI(document.location.pathname.slice(4));
|
||||||
} else {
|
} else {
|
||||||
self.URL.parse(function(state) {
|
self.URL.parse(function(state) {
|
||||||
setState(state, callback); // setState -> UI.set -> URL.update
|
setState(state, callback); // setState -> UI.set -> URL.update
|
||||||
|
|
|
@ -5,14 +5,14 @@
|
||||||
pandora.autovalidateCode = function(value, blur, callback) {
|
pandora.autovalidateCode = function(value, blur, callback) {
|
||||||
value = value.toUpperCase().split('').map(function(v) {
|
value = value.toUpperCase().split('').map(function(v) {
|
||||||
return /[A-Z]/.test(v) ? v : null;
|
return /[A-Z]/.test(v) ? v : null;
|
||||||
}).join('').substr(0, 16);
|
}).join('').slice(0, 16);
|
||||||
callback({valid: value.length == 16, value: value});
|
callback({valid: value.length == 16, value: value});
|
||||||
};
|
};
|
||||||
|
|
||||||
pandora.autovalidateEmail = function(value, blur, callback) {
|
pandora.autovalidateEmail = function(value, blur, callback) {
|
||||||
value = value.toLowerCase().split('').map(function(v, i) {
|
value = value.toLowerCase().split('').map(function(v, i) {
|
||||||
return /[0-9a-z\.\+\-_@]/.test(v) ? v : null;
|
return /[0-9a-z\.\+\-_@]/.test(v) ? v : null;
|
||||||
}).join('').substr(0, 255);
|
}).join('').slice(0, 255);
|
||||||
callback({valid: Ox.isValidEmail(value), value: value});
|
callback({valid: Ox.isValidEmail(value), value: value});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ pandora.autovalidateListname = function(value, blur, callback) {
|
||||||
value = value.toLowerCase().split('').map(function(v, i) {
|
value = value.toLowerCase().split('').map(function(v, i) {
|
||||||
return /\s/.test(v) && (i == 0 || (i == length - 1 && blur)) ? null : v;
|
return /\s/.test(v) && (i == 0 || (i == length - 1 && blur)) ? null : v;
|
||||||
}).join('');
|
}).join('');
|
||||||
value = value.replace(/\s+/g, ' ').substr(0, 255);
|
value = value.replace(/\s+/g, ' ').slice(0, 255);
|
||||||
callback({valid: !!value.length, value: value});
|
callback({valid: !!value.length, value: value});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ pandora.autovalidateUsername = function(value, blur, callback) {
|
||||||
value = value.toLowerCase().split('').map(function(v, i) {
|
value = value.toLowerCase().split('').map(function(v, i) {
|
||||||
return /\s/.test(v) && (i == 0 || (i == length - 1 && blur)) ? null : v;
|
return /\s/.test(v) && (i == 0 || (i == length - 1 && blur)) ? null : v;
|
||||||
}).join('');
|
}).join('');
|
||||||
value = value.replace(/\s+/g, ' ').substr(0, 255);
|
value = value.replace(/\s+/g, ' ').slice(0, 255);
|
||||||
callback({valid: !!value.length, value: value});
|
callback({valid: !!value.length, value: value});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ pandora.validateUser = function(key, existing) {
|
||||||
callback({
|
callback({
|
||||||
message: existing ?
|
message: existing ?
|
||||||
'Unknown ' + string :
|
'Unknown ' + string :
|
||||||
string[0].toUpperCase() + string.substr(1) + ' already exists',
|
string[0].toUpperCase() + string.slice(1) + ' already exists',
|
||||||
valid: valid
|
valid: valid
|
||||||
});
|
});
|
||||||
}) : callback({
|
}) : callback({
|
||||||
|
|
|
@ -127,7 +127,7 @@ pandora.ui.editor = function(data) {
|
||||||
function callback(result) {
|
function callback(result) {
|
||||||
Ox.Log('', 'editAnnotation result', result);
|
Ox.Log('', 'editAnnotation result', result);
|
||||||
result.data.date = Ox.formatDate(
|
result.data.date = Ox.formatDate(
|
||||||
result.data.modified.substr(0, 10), '%B %e, %Y'
|
result.data.modified.slice(0, 10), '%B %e, %Y'
|
||||||
);
|
);
|
||||||
pandora.$ui.editor.updateAnnotation(data.id, result.data);
|
pandora.$ui.editor.updateAnnotation(data.id, result.data);
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,7 +20,7 @@ pandora.ui.infoView = function(data) {
|
||||||
iconHeight = iconRatio < 1 ? iconSize : Math.round(iconSize / iconRatio),
|
iconHeight = iconRatio < 1 ? iconSize : Math.round(iconSize / iconRatio),
|
||||||
iconLeft = iconSize == 256 ? Math.floor((iconSize - iconWidth) / 2) : 0,
|
iconLeft = iconSize == 256 ? Math.floor((iconSize - iconWidth) / 2) : 0,
|
||||||
borderRadius = ui.icons == 'posters' ? 0 : iconSize / 8,
|
borderRadius = ui.icons == 'posters' ? 0 : iconSize / 8,
|
||||||
isEditable = canEdit && data.id.substr(0, 2) == '0x',
|
isEditable = canEdit && data.id.slice(0, 2) == '0x',
|
||||||
listWidth = 144 + Ox.UI.SCROLLBAR_SIZE,
|
listWidth = 144 + Ox.UI.SCROLLBAR_SIZE,
|
||||||
margin = 16,
|
margin = 16,
|
||||||
statisticsWidth = 128,
|
statisticsWidth = 128,
|
||||||
|
|
|
@ -241,11 +241,11 @@ pandora.ui.mainMenu = function() {
|
||||||
pandora.UI.set(set);
|
pandora.UI.set(set);
|
||||||
} else if (data.id == 'viewicons') {
|
} else if (data.id == 'viewicons') {
|
||||||
pandora.UI.set({icons: value});
|
pandora.UI.set({icons: value});
|
||||||
} else if (data.id.substr(0, 8) == 'viewlist') {
|
} else if (data.id.slice(0, 8) == 'viewlist') {
|
||||||
pandora.UI.set({
|
pandora.UI.set({
|
||||||
find: {
|
find: {
|
||||||
conditions: data.checked ? [
|
conditions: data.checked ? [
|
||||||
{key: 'list', value: data.id.substr(8), operator: '=='}
|
{key: 'list', value: data.id.slice(8), operator: '=='}
|
||||||
] : [],
|
] : [],
|
||||||
operator: '&'
|
operator: '&'
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,10 +128,10 @@ pandora.ui.statisticsDialog = function() {
|
||||||
var city, continent, country, countryData, name = {}, region, split;
|
var city, continent, country, countryData, name = {}, region, split;
|
||||||
if (mode == 'all' || item.level != 'guest') {
|
if (mode == 'all' || item.level != 'guest') {
|
||||||
['firstseen', 'lastseen'].forEach(function(key, i) {
|
['firstseen', 'lastseen'].forEach(function(key, i) {
|
||||||
var year = item[key].substr(0, 4) + '-' + key,
|
var year = item[key].slice(0, 4) + '-' + key,
|
||||||
month = item[key].substr(0, 7) + '-' + key,
|
month = item[key].slice(0, 7) + '-' + key,
|
||||||
day = Ox.formatDate(item[key], '%u'),
|
day = Ox.formatDate(item[key], '%u'),
|
||||||
hour = item[key].substr(11, 2);
|
hour = item[key].slice(11, 13);
|
||||||
data[mode].year[year] = data[mode].year[year] || {};
|
data[mode].year[year] = data[mode].year[year] || {};
|
||||||
data[mode].year[year][month] = (data[mode].year[year][month] || 0) + 1;
|
data[mode].year[year][month] = (data[mode].year[year][month] || 0) + 1;
|
||||||
data[mode].month[month] = (data[mode].month[month] || 0) + 1;
|
data[mode].month[month] = (data[mode].month[month] || 0) + 1;
|
||||||
|
@ -181,7 +181,7 @@ pandora.ui.statisticsDialog = function() {
|
||||||
|
|
||||||
var keys, firstKey, lastKey;
|
var keys, firstKey, lastKey;
|
||||||
keys = Object.keys(data[mode].month).map(function(key) {
|
keys = Object.keys(data[mode].month).map(function(key) {
|
||||||
return key.substr(0, 7)
|
return key.slice(0, 7);
|
||||||
}).sort();
|
}).sort();
|
||||||
firstKey = keys[0].split('-').map(function(str) {
|
firstKey = keys[0].split('-').map(function(str) {
|
||||||
return parseInt(str, 10);
|
return parseInt(str, 10);
|
||||||
|
|
|
@ -77,7 +77,7 @@ pandora.ui.toolbar = function() {
|
||||||
return '<b>' + (
|
return '<b>' + (
|
||||||
listId == ''
|
listId == ''
|
||||||
? 'All ' + pandora.site.itemName.plural
|
? 'All ' + pandora.site.itemName.plural
|
||||||
: Ox.encodeHTMLEntities(listId.substr(listId.indexOf(':') + 1))
|
: Ox.encodeHTMLEntities(listId.slice(listId.indexOf(':') + 1))
|
||||||
) + '</b>';
|
) + '</b>';
|
||||||
}
|
}
|
||||||
function getListTitleLeft() {
|
function getListTitleLeft() {
|
||||||
|
|
|
@ -33,7 +33,7 @@ pandora.ui.tv = function() {
|
||||||
lists = [''];
|
lists = [''];
|
||||||
Ox.loop(3, function(f) {
|
Ox.loop(3, function(f) {
|
||||||
menu.items[f + 1].items.forEach(function(l) {
|
menu.items[f + 1].items.forEach(function(l) {
|
||||||
lists.push(l.id.substr(8));
|
lists.push(l.id.slice(8));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -804,9 +804,9 @@ pandora.ui.usersDialog = function() {
|
||||||
textarea = $input.find('textarea')[0],
|
textarea = $input.find('textarea')[0],
|
||||||
value = $input.value();
|
value = $input.value();
|
||||||
$input.value(
|
$input.value(
|
||||||
value.substr(0, textarea.selectionStart)
|
value.slice(0, textarea.selectionStart)
|
||||||
+ '{' + data.id + '}'
|
+ '{' + data.id + '}'
|
||||||
+ value.substr(textarea.selectionEnd)
|
+ value.slice(textarea.selectionEnd)
|
||||||
)
|
)
|
||||||
.focusInput(textarea.selectionStart + data.id.length + 2);
|
.focusInput(textarea.selectionStart + data.id.length + 2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -675,7 +675,7 @@ pandora.getMetadataByIdOrName = function(item, view, str, callback) {
|
||||||
) && item && !isName,
|
) && item && !isName,
|
||||||
canBeEvent = !view || view == 'calendar',
|
canBeEvent = !view || view == 'calendar',
|
||||||
canBePlace = !view || view == 'map';
|
canBePlace = !view || view == 'map';
|
||||||
str = isName ? str.substr(1) : str;
|
str = isName ? str.slice(1) : str;
|
||||||
getId(canBeAnnotation ? 'annotation' : '', function(id) {
|
getId(canBeAnnotation ? 'annotation' : '', function(id) {
|
||||||
if (id) {
|
if (id) {
|
||||||
Ox.Log('URL', 'id?', id)
|
Ox.Log('URL', 'id?', id)
|
||||||
|
@ -764,7 +764,7 @@ pandora.getPageTitle = function(stateOrURL) {
|
||||||
].concat(pandora.site.sitePages),
|
].concat(pandora.site.sitePages),
|
||||||
page = Ox.getObjectById(
|
page = Ox.getObjectById(
|
||||||
pages,
|
pages,
|
||||||
Ox.isObject(stateOrURL) ? stateOrURL.page : stateOrURL.substr(1)
|
Ox.isObject(stateOrURL) ? stateOrURL.page : stateOrURL.slice(1)
|
||||||
);
|
);
|
||||||
return page
|
return page
|
||||||
? pandora.site.site.name
|
? pandora.site.site.name
|
||||||
|
@ -840,7 +840,7 @@ pandora.getVideoOptions = function(data) {
|
||||||
pandora.site.layers.forEach(function(layer, i) {
|
pandora.site.layers.forEach(function(layer, i) {
|
||||||
options.annotations[i] = Ox.extend({}, layer, {
|
options.annotations[i] = Ox.extend({}, layer, {
|
||||||
items: data.layers[layer.id].map(function(annotation) {
|
items: data.layers[layer.id].map(function(annotation) {
|
||||||
annotation.date = Ox.formatDate(annotation.modified.substr(0, 10), '%B %e, %Y');
|
annotation.date = Ox.formatDate(annotation.modified.slice(0, 10), '%B %e, %Y');
|
||||||
annotation.duration = Math.abs(annotation.out - annotation['in']);
|
annotation.duration = Math.abs(annotation.out - annotation['in']);
|
||||||
annotation.editable = annotation.editable
|
annotation.editable = annotation.editable
|
||||||
|| annotation.user == pandora.user.username
|
|| annotation.user == pandora.user.username
|
||||||
|
|
Loading…
Reference in a new issue