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
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -145,10 +145,10 @@ Ox.load('UI', {
|
|||
|
||||
function parseQuery() {
|
||||
var vars = window.location.search.length
|
||||
? window.location.search.substring(1).split('&')
|
||||
? window.location.search.slice(1).split('&')
|
||||
: [],
|
||||
query = {
|
||||
item: window.location.pathname.substring(1).split('/')[0]
|
||||
item: window.location.pathname.slice(1).split('/')[0]
|
||||
},
|
||||
defaults = {
|
||||
view: 'video',
|
||||
|
@ -158,7 +158,7 @@ Ox.load('UI', {
|
|||
item: ''
|
||||
};
|
||||
vars.forEach(function(v) {
|
||||
v= v.split('=');
|
||||
v = v.split('=');
|
||||
query[v[0]] = decodeURIComponent(v[1]);
|
||||
});
|
||||
|
||||
|
|
|
@ -270,7 +270,7 @@ appPanel
|
|||
pandora.site.listSettings = {};
|
||||
Ox.forEach(pandora.site.user.ui, function(val, 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['mapFind'] = '';
|
||||
} else {
|
||||
//pandora.user.ui.mapFind = state.span.substr(1);
|
||||
set['mapFind'] = state.span.substr(1);
|
||||
//pandora.user.ui.mapFind = state.span.slice(1);
|
||||
set['mapFind'] = state.span.slice(1);
|
||||
set['mapSelection'] = '';
|
||||
}
|
||||
} else if (state.view == 'calendar') {
|
||||
|
@ -301,8 +301,8 @@ pandora.URL = (function() {
|
|||
|
||||
// on page load, this sets the state from the URL
|
||||
that.parse = function(callback) {
|
||||
if (document.location.pathname.substr(0, 4) == 'url=') {
|
||||
document.location.href = decodeURI(document.location.pathname.substr(4));
|
||||
if (document.location.pathname.slice(0, 4) == 'url=') {
|
||||
document.location.href = decodeURI(document.location.pathname.slice(4));
|
||||
} else {
|
||||
self.URL.parse(function(state) {
|
||||
setState(state, callback); // setState -> UI.set -> URL.update
|
||||
|
|
|
@ -5,14 +5,14 @@
|
|||
pandora.autovalidateCode = function(value, blur, callback) {
|
||||
value = value.toUpperCase().split('').map(function(v) {
|
||||
return /[A-Z]/.test(v) ? v : null;
|
||||
}).join('').substr(0, 16);
|
||||
}).join('').slice(0, 16);
|
||||
callback({valid: value.length == 16, value: value});
|
||||
};
|
||||
|
||||
pandora.autovalidateEmail = function(value, blur, callback) {
|
||||
value = value.toLowerCase().split('').map(function(v, i) {
|
||||
return /[0-9a-z\.\+\-_@]/.test(v) ? v : null;
|
||||
}).join('').substr(0, 255);
|
||||
}).join('').slice(0, 255);
|
||||
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) {
|
||||
return /\s/.test(v) && (i == 0 || (i == length - 1 && blur)) ? null : v;
|
||||
}).join('');
|
||||
value = value.replace(/\s+/g, ' ').substr(0, 255);
|
||||
value = value.replace(/\s+/g, ' ').slice(0, 255);
|
||||
callback({valid: !!value.length, value: value});
|
||||
};
|
||||
|
||||
|
@ -34,7 +34,7 @@ pandora.autovalidateUsername = function(value, blur, callback) {
|
|||
value = value.toLowerCase().split('').map(function(v, i) {
|
||||
return /\s/.test(v) && (i == 0 || (i == length - 1 && blur)) ? null : v;
|
||||
}).join('');
|
||||
value = value.replace(/\s+/g, ' ').substr(0, 255);
|
||||
value = value.replace(/\s+/g, ' ').slice(0, 255);
|
||||
callback({valid: !!value.length, value: value});
|
||||
};
|
||||
|
||||
|
@ -96,7 +96,7 @@ pandora.validateUser = function(key, existing) {
|
|||
callback({
|
||||
message: existing ?
|
||||
'Unknown ' + string :
|
||||
string[0].toUpperCase() + string.substr(1) + ' already exists',
|
||||
string[0].toUpperCase() + string.slice(1) + ' already exists',
|
||||
valid: valid
|
||||
});
|
||||
}) : callback({
|
||||
|
|
|
@ -127,7 +127,7 @@ pandora.ui.editor = function(data) {
|
|||
function callback(result) {
|
||||
Ox.Log('', 'editAnnotation result', result);
|
||||
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);
|
||||
};
|
||||
|
|
|
@ -20,7 +20,7 @@ pandora.ui.infoView = function(data) {
|
|||
iconHeight = iconRatio < 1 ? iconSize : Math.round(iconSize / iconRatio),
|
||||
iconLeft = iconSize == 256 ? Math.floor((iconSize - iconWidth) / 2) : 0,
|
||||
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,
|
||||
margin = 16,
|
||||
statisticsWidth = 128,
|
||||
|
|
|
@ -241,11 +241,11 @@ pandora.ui.mainMenu = function() {
|
|||
pandora.UI.set(set);
|
||||
} else if (data.id == 'viewicons') {
|
||||
pandora.UI.set({icons: value});
|
||||
} else if (data.id.substr(0, 8) == 'viewlist') {
|
||||
} else if (data.id.slice(0, 8) == 'viewlist') {
|
||||
pandora.UI.set({
|
||||
find: {
|
||||
conditions: data.checked ? [
|
||||
{key: 'list', value: data.id.substr(8), operator: '=='}
|
||||
{key: 'list', value: data.id.slice(8), operator: '=='}
|
||||
] : [],
|
||||
operator: '&'
|
||||
}
|
||||
|
|
|
@ -128,10 +128,10 @@ pandora.ui.statisticsDialog = function() {
|
|||
var city, continent, country, countryData, name = {}, region, split;
|
||||
if (mode == 'all' || item.level != 'guest') {
|
||||
['firstseen', 'lastseen'].forEach(function(key, i) {
|
||||
var year = item[key].substr(0, 4) + '-' + key,
|
||||
month = item[key].substr(0, 7) + '-' + key,
|
||||
var year = item[key].slice(0, 4) + '-' + key,
|
||||
month = item[key].slice(0, 7) + '-' + key,
|
||||
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][month] = (data[mode].year[year][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;
|
||||
keys = Object.keys(data[mode].month).map(function(key) {
|
||||
return key.substr(0, 7)
|
||||
return key.slice(0, 7);
|
||||
}).sort();
|
||||
firstKey = keys[0].split('-').map(function(str) {
|
||||
return parseInt(str, 10);
|
||||
|
|
|
@ -77,7 +77,7 @@ pandora.ui.toolbar = function() {
|
|||
return '<b>' + (
|
||||
listId == ''
|
||||
? 'All ' + pandora.site.itemName.plural
|
||||
: Ox.encodeHTMLEntities(listId.substr(listId.indexOf(':') + 1))
|
||||
: Ox.encodeHTMLEntities(listId.slice(listId.indexOf(':') + 1))
|
||||
) + '</b>';
|
||||
}
|
||||
function getListTitleLeft() {
|
||||
|
|
|
@ -33,7 +33,7 @@ pandora.ui.tv = function() {
|
|||
lists = [''];
|
||||
Ox.loop(3, function(f) {
|
||||
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],
|
||||
value = $input.value();
|
||||
$input.value(
|
||||
value.substr(0, textarea.selectionStart)
|
||||
value.slice(0, textarea.selectionStart)
|
||||
+ '{' + data.id + '}'
|
||||
+ value.substr(textarea.selectionEnd)
|
||||
+ value.slice(textarea.selectionEnd)
|
||||
)
|
||||
.focusInput(textarea.selectionStart + data.id.length + 2);
|
||||
}
|
||||
|
|
|
@ -675,7 +675,7 @@ pandora.getMetadataByIdOrName = function(item, view, str, callback) {
|
|||
) && item && !isName,
|
||||
canBeEvent = !view || view == 'calendar',
|
||||
canBePlace = !view || view == 'map';
|
||||
str = isName ? str.substr(1) : str;
|
||||
str = isName ? str.slice(1) : str;
|
||||
getId(canBeAnnotation ? 'annotation' : '', function(id) {
|
||||
if (id) {
|
||||
Ox.Log('URL', 'id?', id)
|
||||
|
@ -764,7 +764,7 @@ pandora.getPageTitle = function(stateOrURL) {
|
|||
].concat(pandora.site.sitePages),
|
||||
page = Ox.getObjectById(
|
||||
pages,
|
||||
Ox.isObject(stateOrURL) ? stateOrURL.page : stateOrURL.substr(1)
|
||||
Ox.isObject(stateOrURL) ? stateOrURL.page : stateOrURL.slice(1)
|
||||
);
|
||||
return page
|
||||
? pandora.site.site.name
|
||||
|
@ -840,7 +840,7 @@ pandora.getVideoOptions = function(data) {
|
|||
pandora.site.layers.forEach(function(layer, i) {
|
||||
options.annotations[i] = Ox.extend({}, layer, {
|
||||
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.editable = annotation.editable
|
||||
|| annotation.user == pandora.user.username
|
||||
|
|
Loading…
Reference in a new issue