use [].concat, not Ox.merge

This commit is contained in:
rolux 2012-05-24 10:22:56 +02:00
parent fd5f0c3c4c
commit ee160efa3d
24 changed files with 85 additions and 90 deletions

View file

@ -103,15 +103,17 @@ Ox.load('UI', {
options.censored = canPlayVideo ? []
: canPlayClips ? (
options.subtitles.length
? Ox.merge(
options.subtitles.map(function(subtitle, i) {
return {
'in': i == 0 ? 0 : options.subtitles[i - 1].out,
out: subtitle['in']
};
}),
? options.subtitles.map(function(subtitle, i) {
return {
'in': i == 0 ? 0 : options.subtitles[i - 1].out,
out: subtitle['in']
};
}).concat(
[{'in': Ox.last(options.subtitles).out, out: data.duration}]
)
).filter(function(censored) {
// don't include gaps shorter than one second
return censored.out - censored['in'] >= 1;
})
: Ox.range(0, data.duration - 5, 60).map(function(position) {
return {
'in': position + 5,

View file

@ -311,7 +311,7 @@ appPanel
function loadBrowserMessage() {
var isMSIE = $.browser.msie,
browsers = Ox.merge(
browsers = [].concat(
isMSIE ? [{name: 'Chrome Frame', url: 'http://google.com/chromeframe/'}] : [],
[
{name: 'Chrome', url: 'http://google.com/chrome/'},

View file

@ -39,7 +39,7 @@ pandora.URL = (function() {
// ...
} else if (['timeline', 'player', 'editor'].indexOf(state.view) > -1) {
var videoPoints = pandora.user.ui.videoPoints[state.item] || {};
state.span = videoPoints.annotation || Ox.merge(
state.span = videoPoints.annotation || [].concat(
videoPoints.position
? videoPoints.position
: [],
@ -173,19 +173,17 @@ pandora.URL = (function() {
findKeys, sortKeys = {}, spanType = {}, views = {};
views[itemsSection] = {
list: Ox.merge(
// listView is the default view
[pandora.user.ui.listView],
// listView is the default view
list: [pandora.user.ui.listView].concat(
pandora.site.listViews.filter(function(view) {
return view.id == pandora.user.ui.listView
}).map(function(view) {
return view.id;
})
),
item: Ox.merge(
// itemView is the default view,
// videoView is the default view if there is a duration
[pandora.user.ui.itemView, pandora.user.ui.videoView],
// itemView is the default view,
// videoView is the default view if there is a duration
item: [pandora.user.ui.itemView, pandora.user.ui.videoView].concat(
pandora.site.itemViews.filter(function(view) {
return [
pandora.user.ui.itemView, pandora.user.ui.videoView
@ -198,7 +196,7 @@ pandora.URL = (function() {
sortKeys[itemsSection] = {list: {}, item: {}};
views[itemsSection].list.forEach(function(view) {
sortKeys[itemsSection].list[view] = Ox.merge(
sortKeys[itemsSection].list[view] = [].concat(
// listSort[0].key is the default sort key
Ox.getObjectById(pandora.site.sortKeys, pandora.user.ui.listSort[0].key)
|| pandora.isClipView(view)
@ -214,9 +212,13 @@ pandora.URL = (function() {
});
views[itemsSection].item.forEach(function(view) {
if (pandora.isClipView(view, true)) {
sortKeys[itemsSection].item[view] = Ox.merge(
// itemSort[0].key is the default sort key
[Ox.getObjectById(pandora.site.clipKeys, pandora.user.ui.itemSort[0].key)],
// itemSort[0].key is the default sort key
sortKeys[itemsSection].item[view] = [
Ox.getObjectById(
pandora.site.clipKeys,
pandora.user.ui.itemSort[0].key
)
].concat(
pandora.site.clipKeys.filter(function(key) {
return key.id == pandora.user.ui.itemSort[0].key;
})
@ -238,13 +240,13 @@ pandora.URL = (function() {
}
};
findKeys = Ox.merge([{id: 'list', type: 'string'}], pandora.site.itemKeys);
findKeys = [{id: 'list', type: 'string'}].concat(pandora.site.itemKeys);
self.URL = Ox.URL({
findKeys: findKeys,
getItem: pandora.getItemByIdOrTitle,
getSpan: pandora.getMetadataByIdOrName,
pages: Ox.merge(
pages: [].concat(
['home', 'software', 'api', 'help', 'tv'],
pandora.site.sitePages.map(function(page) {
return page.id;

View file

@ -84,7 +84,7 @@ pandora.ui.accountDialogOptions = function(action, value) {
}
return {
buttons: Ox.merge(
buttons: [].concat(
buttons[action].map(function(type) {
return button(type);
}),

View file

@ -4,7 +4,7 @@
pandora.ui.annotationDialog = function(layer) {
var isEditor = pandora.user.ui.itemView == 'editor',
$dialog = Ox.Dialog({
buttons: Ox.merge(
buttons: [].concat(
isEditor ? [
Ox.Button({title: 'Sign Up...'}).bindEvent({
click: function() {

View file

@ -87,7 +87,7 @@ pandora.ui.browser = function() {
info = (
/^color/.test(format.type.toLowerCase()) ? Ox.Theme : Ox
)['format' + Ox.toTitleCase(format.type)].apply(
this, Ox.merge([data[sortKey]], format.args || [])
this, [data[sortKey]].concat(format.args || [])
);
} else {
info = data[sortKey];

View file

@ -46,7 +46,7 @@ pandora.ui.clipList = function(videoRatio) {
info = (
/^color/.test(format.type.toLowerCase()) ? Ox.Theme : Ox
)['format' + Ox.toTitleCase(format.type)].apply(
this, Ox.merge([data[sortKey]], format.args || [])
this, [data[sortKey]].concat(format.args || [])
);
} else {
info = data[sortKey];
@ -98,8 +98,7 @@ pandora.ui.clipList = function(videoRatio) {
query: query
}, data), callback);
},
keys: Ox.merge(
['annotations', 'id', 'in', 'out'],
keys = ['annotations', 'id', 'in', 'out'].concat(
!ui.item ? ['videoRatio'] : []
),
max: 1,

View file

@ -15,20 +15,20 @@ pandora.ui.filterForm = function(list) {
}, function(result) {
that.append(
that.$filter = Ox.Filter({
findKeys: Ox.merge(pandora.site.itemKeys.map(function(itemKey) {
findKeys: pandora.site.itemKeys.map(function(itemKey) {
var key = Ox.clone(itemKey);
key.type = key.type == 'layer'
? Ox.getObjectById(pandora.site.layers, key.id).type
: key.type;
return key;
}), {
}).concat([{
id: 'list',
title: 'List',
type: 'list',
values: result.data.items.map(function(item) {
return item.id;
})
}),
}]),
list: list ? null : {
sort: pandora.user.ui.listSort,
view: pandora.user.ui.listView

View file

@ -5,9 +5,9 @@ pandora.ui.findElement = function() {
findKey = pandora.user.ui._findState.key,
findValue = pandora.user.ui._findState.value,
hasPressedClear = false,
previousFindKey = findKey;
var that = Ox.FormElementGroup({
elements: Ox.merge(pandora.user.ui._list ? [
previousFindKey = findKey,
that = Ox.FormElementGroup({
elements: [].concat(pandora.user.ui._list ? [
pandora.$ui.findListSelect = Ox.Select({
items: [
{id: 'all', title: 'Find: All ' + pandora.site.itemName.plural},
@ -27,7 +27,7 @@ pandora.ui.findElement = function() {
] : [], [
pandora.$ui.findSelect = Ox.Select({
id: 'select',
items: Ox.merge(
items: [].concat(
pandora.site.findKeys.filter(function(key, i) {
return !key.capability
|| pandora.site.capabilities[key.capability][pandora.user.level];
@ -93,7 +93,7 @@ pandora.ui.findElement = function() {
var findInList = pandora.user.ui._list
&& pandora.$ui.findListSelect.value() == 'list',
key = pandora.$ui.findSelect.value(),
conditions = Ox.merge(
conditions = [].concat(
findInList ? [{
key: 'list',
value: pandora.user.ui._list,

View file

@ -37,7 +37,7 @@ pandora.ui.homePage = function() {
// fixme: duplicated
$select = Ox.Select({
id: 'select',
items: Ox.merge(pandora.site.findKeys.map(function(key) {
items: [].concat(pandora.site.findKeys.map(function(key) {
return {
id: key.id,
title: 'Find: ' + key.title

View file

@ -598,7 +598,7 @@ pandora.ui.infoView = function(data) {
}
function renderCapabilities(rightsLevel) {
var capabilities = Ox.merge(
var capabilities = [].concat(
canEdit ? [{name: 'canSeeItem', symbol: 'Find'}] : [],
[
{name: 'canPlayClips', symbol: 'PlayInToOut'},

View file

@ -571,7 +571,7 @@ pandora.ui.infoView = function(data) {
}
function renderCapabilities(rightsLevel) {
var capabilities = Ox.merge(
var capabilities = [].concat(
canEdit ? [{name: 'canSeeItem', symbol: 'Find'}] : [],
[
{name: 'canPlayClips', symbol: 'PlayInToOut'},

View file

@ -571,7 +571,7 @@ pandora.ui.infoView = function(data) {
}
function renderCapabilities(rightsLevel) {
var capabilities = Ox.merge(
var capabilities = [].concat(
canEdit ? [{name: 'canSeeItem', symbol: 'Find'}] : [],
[
{name: 'canPlayClips', symbol: 'PlayInToOut'},

View file

@ -8,7 +8,7 @@ pandora.ui.list = function() {
if (view == 'list') {
that = Ox.TextList({
columns: Ox.merge([{
columns: [].concat([{
align: 'center',
defaultWidth: 16,
format: function(value, data) {
@ -139,7 +139,7 @@ pandora.ui.list = function() {
info = (
/^color/.test(format.type.toLowerCase()) ? Ox.Theme : Ox
)['format' + Ox.toTitleCase(format.type)].apply(
this, Ox.merge([data[sortKey]], format.args || [])
this, [data[sortKey]].concat(format.args || [])
);
} else {
info = data[sortKey];
@ -192,7 +192,7 @@ pandora.ui.list = function() {
info = (
/^color/.test(format.type.toLowerCase()) ? Ox.Theme : Ox
)['format' + Ox.toTitleCase(format.type)].apply(
this, Ox.merge([data[sortKey]], format.args || [])
this, [data[sortKey]].concat(format.args || [])
);
} else {
info = data[sortKey];
@ -272,7 +272,7 @@ pandora.ui.list = function() {
info = (
/^color/.test(format.type.toLowerCase()) ? Ox.Theme : Ox
)['format' + Ox.toTitleCase(format.type)].apply(
this, Ox.merge([data[sortKey]], format.args || [])
this, [data[sortKey]].concat(format.args || [])
);
} else {
info = data[sortKey];
@ -525,15 +525,15 @@ pandora.ui.list = function() {
};
} else {
query = {
conditions: Ox.merge([
pandora.user.ui.find
], data.rest.map(function(id) {
return {
key: 'id',
value: id,
operator: '!='
};
})),
conditions: [pandora.user.ui.find].concat(
data.rest.map(function(id) {
return {
key: 'id',
value: id,
operator: '!='
};
})
),
operator: '&'
};
}

View file

@ -7,7 +7,7 @@ pandora.ui.listDialog = function(section) {
section = section || 'general';
var width = getWidth(section);
var listData = pandora.getListData(),
tabs = Ox.merge([
tabs = [].concat([
{id: 'general', title: 'General'},
{id: 'icon', title: 'Icon'}
], listData.type == 'smart'
@ -494,8 +494,7 @@ pandora.ui.listIconPanel = function(listData) {
items: function(data, callback) {
pandora.api.find(Ox.extend(data, {
query: {
conditions: Ox.merge(
[{key: 'list', value: listData.id, operator: '=='}],
conditions: [{key: 'list', value: listData.id, operator: '=='}].concat(
value !== '' ? [{key: key, value: value, operator: '='}] : []
),
operator: '&'

View file

@ -232,7 +232,7 @@ pandora.ui.logsDialog = function() {
function updateList(key, value) {
var query = {
conditions: Ox.merge(
conditions: [].concat(
key != 'url' ? [{key: 'user', value: value, operator: '='}] : [],
key != 'user' ? [{key: 'url', value: value, operator: '='}] : []
),

View file

@ -12,9 +12,9 @@ pandora.ui.mainMenu = function() {
})
],
id: 'mainMenu',
menus: Ox.merge(
menus: [].concat(
[
{ id: pandora.site.site.id + 'Menu', title: pandora.site.site.name, items: Ox.merge(
{ id: pandora.site.site.id + 'Menu', title: pandora.site.site.name, items: [].concat(
[
{ id: 'home', title: 'Home' },
{}
@ -58,7 +58,7 @@ pandora.ui.mainMenu = function() {
}, view);
}) },
]},
{ id: 'icons', title: 'Icons', items: Ox.merge([
{ id: 'icons', title: 'Icons', items: [].concat([
{ group: 'viewicons', min: 1, max: 1, items: ['posters', 'frames'].map(function(icons) {
return {id: icons, title: Ox.toTitleCase(icons), checked: ui.icons == icons};
}) }
@ -255,7 +255,7 @@ pandora.ui.mainMenu = function() {
}
},
click: function(data) {
if (Ox.merge(
if ([].concat(
['home', 'software'],
pandora.site.sitePages.map(function(page) {
return page.id;
@ -552,7 +552,7 @@ pandora.ui.mainMenu = function() {
}
function getListMenu(lists) {
return { id: 'listMenu', title: 'List', items: Ox.merge(
return { id: 'listMenu', title: 'List', items: [].concat(
{ id: 'allitems', title: 'All ' + pandora.site.itemName.plural, checked: !ui.item && !ui._list, keyboard: 'shift control w' },
['personal', 'favorite', 'featured'].map(function(folder) {
return {
@ -600,7 +600,7 @@ pandora.ui.mainMenu = function() {
}) : [];
return { id: 'sortMenu', title: 'Sort', items: [
{ id: 'sortitems', title: 'Sort ' + (isClipView || ui.item ? 'Clips' : pandora.site.itemName.plural) + ' by', items: [
{ group: 'listsort', min: 1, max: 1, items: Ox.merge(
{ group: 'listsort', min: 1, max: 1, items: [].concat(
items,
pandora.site.sortKeys.filter(function(key) {
return Ox.getIndexById(items, key.id) == -1 && (

View file

@ -7,10 +7,7 @@ pandora.ui.siteDialog = function(section) {
var dialogHeight = Math.round((window.innerHeight - 48) * 0.75),
dialogWidth = Math.round(window.innerWidth * 0.75),
isEditable = pandora.site.capabilities.canEditSitePages[pandora.user.level],
tabs = Ox.merge(
Ox.clone(pandora.site.sitePages, true),
[{id: 'software', title: 'Software'}]
);
tabs = pandora.site.sitePages.concat([{id: 'software', title: 'Software'}]);
Ox.getObjectById(tabs, section).selected = true;
var $tabPanel = Ox.TabPanel({
content: function(id) {
@ -70,7 +67,7 @@ pandora.ui.siteDialog = function(section) {
.css({width: '128px', height: '128px', marginBottom: '8px'})
.appendTo($right);
risk = ['Unknown', 'Severe', 'High', 'Significant', 'General', 'Low'];
Ox.merge(
[].concat(
['Unknown'],
pandora.site.rightsLevels.map(function(rightsLevel) {
return rightsLevel.name;

View file

@ -7,7 +7,7 @@ pandora.ui.sortMenu = function() {
// FIXME: unused
var that = Ox.MenuButton({
items: Ox.merge(
items: [].concat(
pandora.site.clipKeys.map(function(key) {
return Ox.extend(Ox.clone(key), {
checked: key.id == pandora.user.ui.itemSort[0].key,

View file

@ -13,7 +13,7 @@ pandora.ui.sortSelect = function(isNavigationView) {
sortKey = !pandora.user.ui.item ? 'listSort' : 'itemSort',
that;
if (!pandora.user.ui.item) {
items = Ox.merge(
items = [].concat(
items,
pandora.site.sortKeys.filter(function(key) {
return Ox.getIndexById(items, key.id) == -1 && (

View file

@ -26,7 +26,7 @@ pandora.ui.statisticsDialog = function() {
},
dialogHeight = Math.round((window.innerHeight - 48) * 0.9),
dialogWidth = Math.round(window.innerWidth * 0.9),
names = Ox.merge(Object.keys(colors.system), Object.keys(colors.browser)),
names = Object.keys(colors.system).concat(Object.keys(colors.browser)),
tabs = [
{id: 'seen', title: 'First Seen & Last Seen', selected: true},
{id: 'locations', title: 'Locations'},

View file

@ -16,12 +16,9 @@ pandora.ui.usersDialog = function() {
'Android', 'BSD', 'iOS', 'Linux',
'Mac OS X', 'Unix', 'Windows'
],
userLevels = Ox.merge(
pandora.site.userLevels.map(function(userLevel) {
return Ox.toTitleCase(userLevel);
}),
['Robot']
),
userLevels = pandora.site.userLevels.map(function(userLevel) {
return Ox.toTitleCase(userLevel);
}).concat(['Robot']),
$reloadButton = Ox.Button({
title: 'redo',
@ -968,11 +965,11 @@ pandora.ui.usersDialog = function() {
value = $findInput.value(),
query = {
conditions: value
? Ox.merge(
? [].concat(
key != 'email' ? [{key: 'username', value: value, operator: '='}] : [],
key != 'username' ? [{key: 'email', value: value, operator: '='}] : []
)
: Ox.merge(
: [].concat(
!guests ? [{key: 'level', value: 'guest', operator: '!='}] : [],
!robots ? [{key: 'level', value: 'robot', operator: '!='}] : []
),

View file

@ -770,7 +770,7 @@ pandora.getMetadataByIdOrName = function(item, view, str, callback) {
};
pandora.getPageTitle = function(stateOrURL) {
var pages = Ox.merge([
var pages = [
{id: '', title: ''},
{id: 'help', title: 'Help'},
{id: 'home', title: ''},
@ -780,7 +780,7 @@ pandora.getPageTitle = function(stateOrURL) {
{id: 'signup', title: 'Sign Up'},
{id: 'software', title: 'Software'},
{id: 'tv', title: 'TV'}
], pandora.site.sitePages),
].concat(pandora.site.sitePages),
page = Ox.getObjectById(
pages,
Ox.isObject(stateOrURL) ? stateOrURL.page : stateOrURL.substr(1)
@ -830,13 +830,12 @@ pandora.getVideoOptions = function(data) {
options.censored = canPlayVideo ? []
: canPlayClips ? (
options.subtitles.length
? Ox.merge(
options.subtitles.map(function(subtitle, i) {
return {
'in': i == 0 ? 0 : options.subtitles[i - 1].out,
out: subtitle['in']
};
}),
? options.subtitles.map(function(subtitle, i) {
return {
'in': i == 0 ? 0 : options.subtitles[i - 1].out,
out: subtitle['in']
};
}).concat(
[{'in': Ox.last(options.subtitles).out, out: data.duration}]
).filter(function(censored) {
// don't include gaps shorter than one second

View file

@ -16,7 +16,7 @@ pandora.ui.viewSelect = function() {
viewKey == 'itemView'
&& pandora.site.capabilities.canSeeExtraItemViews[pandora.user.level]
) {
Ox.merge(items, [
items = items.concat([
{},
{id: 'data', title: 'View Data'},
{id: 'files', title: 'View Files'}