diff --git a/static/js/pandora.api.js b/static/js/pandora.api.js index 0e8d6e57..70ed9cda 100755 --- a/static/js/pandora.api.js +++ b/static/js/pandora.api.js @@ -90,10 +90,12 @@ function constructList() { return 0; return -1; } - if(!data.keys) { + if (!data.keys) { app.api.api(function(results) { var items = []; - $.each(results.data.actions, function(i, k) {items.push({'name': i})}); + Ox.forEach(results.data.actions, function(v, k) { + items.push({'name': v}) + }); items.sort(_sort); var result = {'data': {'items': items.length}}; callback(result); @@ -101,7 +103,9 @@ function constructList() { } else { app.api.api(function(results) { var items = []; - $.each(results.data.actions, function(i, k) {items.push({'name': i})}); + Ox.forEach(results.data.actions, function(v, k) { + items.push({'name': v}) + }); items.sort(_sort); var result = {'data': {'items': items}}; callback(result); @@ -120,13 +124,13 @@ function constructList() { var info = $('
') - .html(app.actions[k].doc.replace('/\n/
\n/g')) + .html(app.actions[id].doc.replace('/\n/
\n/g')) .appendTo(info); - var $code = $('') - .html(app.actions[k].code[1].replace('/\n/
\n/g')) + var $code = $('') + .html(app.actions[id].code[1].replace('/\n/
\n/g')) .hide(); var $button = new Ox.Button({ title: [ @@ -143,7 +147,7 @@ function constructList() { $('').append($code).appendTo(info) hljs.highlightBlock($code[0], ' '); - hash += k + ',' + hash += id + ',' }); else info.html(app.site.default_info); diff --git a/static/js/pandora.embed.js b/static/js/pandora.embed.js index 5b0f53ab..60f896ec 100755 --- a/static/js/pandora.embed.js +++ b/static/js/pandora.embed.js @@ -11,7 +11,7 @@ Ox.load('UI', { window.pandora = new Ox.App({url: '/api/'}).bindEvent({ apiURL: '/api/', }).bindEvent('load', function(data) { - $.extend(pandora, { + Ox.extend(pandora, { ui: {}, info: function(item) { var that = Ox.Element() @@ -116,7 +116,7 @@ window.pandora = new Ox.App({url: '/api/'}).bindEvent({ 'value': value } }); - $.each(args, function(i, a) { + args.forEach(function(a, i) { Ox.print(i, a); if (a.key == key) { result = a.value; diff --git a/static/js/pandora.js b/static/js/pandora.js index 3dc45815..0d574bf5 100644 --- a/static/js/pandora.js +++ b/static/js/pandora.js @@ -52,7 +52,7 @@ Ox.load({ user: data.user.level == 'guest' ? Ox.extend({}, data.site.user) : data.user }); Ox.extend(pandora.site, { - findKeys: $.map(data.site.itemKeys, function(key, i) { + findKeys: data.site.itemKeys.map(function(key) { return key.find ? key : null; }), sectionFolders: { @@ -73,7 +73,7 @@ Ox.load({ {id: 'featured', title: 'Featured Texts', showBrowser: false} ] }, - sortKeys: $.map(data.site.itemKeys, function(key, i) { + sortKeys: data.site.itemKeys.map(function(key) { return key.columnWidth ? key : null; }) }); diff --git a/static/js/pandora.local.js b/static/js/pandora.local.js index 66d97b2b..feadaca2 100644 --- a/static/js/pandora.local.js +++ b/static/js/pandora.local.js @@ -96,7 +96,7 @@ pandora.afterLaunch.push(function() { pandora.local.volumes(function(data) { Ox.print("got volumes", data); var volumes = 0; - $.each(data, function(name, info) { + Ox.forEach(data, function(info, name) { volumes ++; Ox.print("add volume", name, info); var status = info.available?"online":"offline"; @@ -269,10 +269,10 @@ pandora.afterLaunch.push(function() { var videos = {}; function parseResult(result) { //extract and upload requested videos - $.each(result.data.data, function(i, oshash) { - $.each(folder_ids, function(i, ids) { - if($.inArray(oshash, ids) > -1) { - if(!videos[i]) { + result.data.data.forEach(function(oshash) { + folder_ids.forEach(function(ids, i) { + if (ids.indexOf(oshash) > -1) { + if (!videos[i]) { videos[i] = []; var button = new Ox.Button({ id: 'upload_' + oshash, @@ -285,7 +285,7 @@ pandora.afterLaunch.push(function() { title: 'Cancel', width: 48 }).bindEvent('click', function(data) { - $.each(videos[fid], function(i, oshash) { + videos[fid].forEach(function(oshash) { _this.cancel(oshash); }); }); @@ -312,13 +312,13 @@ pandora.afterLaunch.push(function() { }); }); //upload requested files - $.each(result.data.file, function(i, oshash) { + result.data.file.forEach(function(oshash) { pandora.local.uploadFile(oshash); }); }; if (result.data.info.length>0) { var post = {'info': {}}; - $.each(result.data.info, function(i, oshash) { + result.data.info.forEach(function(oshash) { if(fileInfo[oshash]) { post.info[oshash] = fileInfo[oshash]; } @@ -336,7 +336,7 @@ pandora.afterLaunch.push(function() { } var folder_ids = {}; var folders = {}; - $.each(result.files, function(i, file) { + result.files.forEach(function(file) { var f = pandora.local.parsePath(file.path); if(!folders[f.folder]) { folders[f.folder] = { @@ -352,7 +352,7 @@ pandora.afterLaunch.push(function() { folder_ids[folders[f.folder].id].push(file.oshash); }); var j = 1; - $.each(folders, function(i, folder) { + folders.forEach(function(folder) { data.items.push(folder); }); r = { diff --git a/static/js/pandora/URL.js b/static/js/pandora/URL.js index 4c6361d1..e811b179 100644 --- a/static/js/pandora/URL.js +++ b/static/js/pandora/URL.js @@ -62,7 +62,7 @@ pandora.URL = (function() { ? /[\d\.:,-]+/.exec(split[split.length - 1]) : null, view = new RegExp( - '^(' + $.map(pandora.site.itemViews, function(v) { + '^(' + pandora.site.itemViews.map(function(v) { return v.id; }).join('|') + ')$' ).exec(split[1]); diff --git a/static/js/pandora/autovalidate.js b/static/js/pandora/autovalidate.js index 19e98887..a56718e2 100644 --- a/static/js/pandora/autovalidate.js +++ b/static/js/pandora/autovalidate.js @@ -1,13 +1,13 @@ // vim: et:ts=4:sw=4:sts=4:ft=javascript pandora.autovalidateCode = function(value, blur, callback) { - value = $.map(value.toUpperCase().split(''), function(v) { + value = value.toUpperCase().split('').map(function(v) { return /[0-9A-Z]/(v) ? v : null; }).join(''); callback(value); }; pandora.autovalidateEmail = function(value, blur, callback) { - value = $.map(value.toLowerCase().split(''), function(v, i) { + value = value.toLowerCase().split('').map(function(v, i) { return /[0-9a-z\.\+\-_@]/(v) ? v : null; }).join(''); callback(value); @@ -15,14 +15,14 @@ pandora.autovalidateEmail = function(value, blur, callback) { pandora.autovalidateListname = function(value, blur, callback) { var length = value.length; - value = $.map(value.split(''), function(v, i) { + value = value.split('').map(function(v, i) { if (new RegExp('[0-9' + Ox.regexp.letters + '\\(\\)' + ((i == 0 || (i == length - 1 && blur)) ? '' : ' \-') + ']', 'i').test(v)) { return v; } else { return null; } }).join(''); - $.each([' ', ' -', '- ', '--', '\\(\\(', '\\)\\(', '\\)\\)'], function(i, v) { + [' ', ' -', '- ', '--', '\\(\\(', '\\)\\(', '\\)\\)'].forEach(function(v) { //Ox.print(v, v[0], v[0] == '\\') while (value.indexOf(v) > -1) { value = value.replace(new RegExp(v, 'g'), v[0] + (v[0] == '\\' ? v[1] : '')); @@ -33,14 +33,14 @@ pandora.autovalidateListname = function(value, blur, callback) { pandora.autovalidateUsername = function(value, blur, callback) { var length = value.length; - value = $.map(value.toLowerCase().split(''), function(v, i) { + value = value.toLowerCase().split('').map(function(v, i) { if (new RegExp('[0-9a-z' + ((i == 0 || (i == length - 1 && blur)) ? '' : '\-_') + ']').test(v)) { return v; } else { return null; } }).join(''); - $.each(['--', '-_', '_-', '__'], function(i, v) { + ['--', '-_', '_-', '__'].forEach(function(v) { while (value.indexOf(v) > -1) { value = value.replace(new RegExp(v, 'g'), v[0]); } diff --git a/static/js/pandora/pandora.js b/static/js/pandora/pandora.js index 6a25b57f..55bea5af 100644 --- a/static/js/pandora/pandora.js +++ b/static/js/pandora/pandora.js @@ -276,24 +276,13 @@ pandora.getFoldersHeight = function() { height += 16 + pandora.user.ui.showFolder[pandora.user.ui.section][folder.id] * ( !!folder.showBrowser * 40 + folder.items * 16 ); - // // // Ox.print('h', height); }); - /* - $.each(pandora.user.ui.showFolder[pandora.user.ui.section], function(id, show) { - var i = Ox.getPositionById(pandora.site.sectionFolders[pandora.user.ui.section], id); - height += show * ( - pandora.site.sectionFolders[pandora.user.ui.section][i].showBrowser * 40 + - pandora.site.sectionFolders[pandora.user.ui.section][i].items * 16 - ); - }); - */ return height; }; pandora.getFoldersWidth = function() { var width = pandora.user.ui.sidebarSize; // fixme: don't use height(), look up in splitpanels - // // // Ox.print(pandora.getFoldersHeight(), '>', pandora.$ui.leftPanel.height() - 24 - 1 - pandora.$ui.info.height()); if (pandora.getFoldersHeight() > pandora.$ui.leftPanel.height() - 24 - 1 - pandora.$ui.info.height()) { width -= Ox.UI.SCROLLBAR_SIZE; } @@ -413,7 +402,7 @@ pandora.reloadGroups = function(i) { } }); } - $.each(pandora.user.ui.groups, function(i_, id) { + Ox.forEach(pandora.user.ui.groups, function(id, i_) { if (i_ != i) { //Ox.print('setting groups request', i, i_) pandora.$ui.groups[i_].options({ diff --git a/static/js/pandora/ui/Ox.FilesView.js b/static/js/pandora/ui/Ox.FilesView.js index b4107240..ea7d154d 100644 --- a/static/js/pandora/ui/Ox.FilesView.js +++ b/static/js/pandora/ui/Ox.FilesView.js @@ -136,7 +136,7 @@ Ox.FilesView = function(options, self) { columnsVisible: true, id: 'files', items: function(data, callback) { - pandora.api.findFiles($.extend(data, { + pandora.api.findFiles(Ox.extend(data, { query: { conditions: [{ key: 'id', diff --git a/static/js/pandora/ui/account.js b/static/js/pandora/ui/account.js index 4f4464bf..4d3f3a18 100644 --- a/static/js/pandora/ui/account.js +++ b/static/js/pandora/ui/account.js @@ -1,7 +1,7 @@ // vim: et:ts=4:sw=4:sts=4:ft=javascript pandora.ui.accountDialog = function(action) { - var that = Ox.Dialog($.extend({ + var that = Ox.Dialog(Ox.extend({ fixedSize: true, height: 192, id: 'accountDialog', @@ -72,7 +72,7 @@ pandora.ui.accountDialogOptions = function(action, value) { } } return { - buttons: Ox.merge($.map(buttons[action], function(type) { + buttons: Ox.merge(buttons[action].map(function(type) { return button(type); }), [{}, button('cancel'), button('submit')]), content: Ox.Element() @@ -120,7 +120,7 @@ pandora.ui.accountForm = function(action, value) { 'reset': ['usernameOrEmail'], 'resetAndSignin': ['oldUsername', 'newPassword', 'code'] }, - $items = $.map(items[action], function(v) { + $items = items[action].map(function(v) { return item(v, value); }), that = Ox.Form({ diff --git a/static/js/pandora/ui/editor.js b/static/js/pandora/ui/editor.js index 6642a2b9..7db0515a 100644 --- a/static/js/pandora/ui/editor.js +++ b/static/js/pandora/ui/editor.js @@ -18,7 +18,7 @@ pandora.ui.annotations = function() { } }), $bins = []; - $.each(pandora.site.layers, function(i, layer) { + pandora.site.layers.forEach(function(layer) { var $bin = Ox.CollapsePanel({ id: layer.id, size: 16, @@ -37,7 +37,7 @@ pandora.ui.annotations = function() { ) ); }); - $.each($bins, function(i, bin) { + $bins.forEach(function(bin) { that.append(bin); }); return that; diff --git a/static/js/pandora/ui/folderBrowserList.js b/static/js/pandora/ui/folderBrowserList.js index 69f0fe59..4b0e5c39 100644 --- a/static/js/pandora/ui/folderBrowserList.js +++ b/static/js/pandora/ui/folderBrowserList.js @@ -178,7 +178,7 @@ pandora.ui.folderBrowserList = function(id) { select: function(data) { // fixme: duplicated if (data.ids.length) { - $.each(pandora.$ui.folderList, function(id_, $list) { + Ox.forEach(pandora.$ui.folderList, function($list, id_) { id != id_ && $list.options('selected', []); }); pandora.UI.set({list: data.ids[0]}); diff --git a/static/js/pandora/ui/group.js b/static/js/pandora/ui/group.js index 3ccf8b7b..8f3d5970 100644 --- a/static/js/pandora/ui/group.js +++ b/static/js/pandora/ui/group.js @@ -127,11 +127,11 @@ pandora.ui.group = function(id) { } }); Ox.Select({ - items: $.map(pandora.site.groups, function(v) { + items: pandora.site.groups.map(function(group) { return { - checked: v.id == id, - id: v.id, - title: v.title + checked: group.id == id, + id: group.id, + title: group.title } }), max: 1, diff --git a/static/js/pandora/ui/item.js b/static/js/pandora/ui/item.js index 38dfdc13..aed7c62b 100644 --- a/static/js/pandora/ui/item.js +++ b/static/js/pandora/ui/item.js @@ -203,7 +203,7 @@ pandora.ui.item = function() { operator: '=' }]}, query = {conditions:[]}; - return pandora.api.findPlaces($.extend(data, { + return pandora.api.findPlaces(Ox.extend(data, { itemQuery: itemQuery, query: query }), callback); @@ -216,7 +216,7 @@ pandora.ui.item = function() { if(place) { pandora.$ui.clips.options({ items: function(data, callback) { - return pandora.api.findAnnotations($.extend(data, { + return pandora.api.findAnnotations(Ox.extend(data, { query: { conditions:[{key: 'place', value: place.id, operator:'='}] }, @@ -296,8 +296,8 @@ pandora.ui.item = function() { // fixme: duplicated var layers = [], video = {}; - $.each(pandora.site.layers, function(i, layer) { - layers[i] = $.extend({}, layer, {items: result.data.layers[layer.id]}); + pandora.site.layers.forEach(function(layer, i) { + layers[i] = Ox.extend({}, layer, {items: result.data.layers[layer.id]}); }); pandora.site.video.resolutions.forEach(function(resolution) { video[resolution] = Ox.range(result.data.parts).map(function(i) { diff --git a/static/js/pandora/ui/leftPanel.js b/static/js/pandora/ui/leftPanel.js index b13741b8..7b3fa47e 100644 --- a/static/js/pandora/ui/leftPanel.js +++ b/static/js/pandora/ui/leftPanel.js @@ -48,7 +48,7 @@ pandora.ui.leftPanel = function() { toggle: function(data) { pandora.UI.set({showSidebar: !data.collapsed}); if (data.collapsed) { - $.each(pandora.$ui.folderList, function(k, $list) { + Ox.forEach(pandora.$ui.folderList, function($list) { $list.loseFocus(); }); } diff --git a/static/js/pandora/ui/list.js b/static/js/pandora/ui/list.js index a3cc0760..0f603649 100644 --- a/static/js/pandora/ui/list.js +++ b/static/js/pandora/ui/list.js @@ -554,7 +554,7 @@ pandora.ui.list = function() { // fixme: remove view argument init: function(data) { pandora.$ui.total.html(pandora.ui.status('total', data)); data = []; - $.each(pandora.site.totals, function(i, v) { + pandora.site.totals.forEach(function(v) { data[v.id] = 0; }); pandora.$ui.selected.html(pandora.ui.status('selected', data)); @@ -569,7 +569,7 @@ pandora.ui.list = function() { // fixme: remove view argument pandora.requests.preview = pandora.api.find({ keys: ['director', 'id', 'posterRatio', 'title'], query: { - conditions: $.map(data.ids, function(id, i) { + conditions: data.ids.map(function(id) { return { key: 'id', value: id, @@ -658,7 +658,7 @@ pandora.ui.list = function() { // fixme: remove view argument pandora.$ui.leftPanel.replaceElement(2, pandora.$ui.info = pandora.ui.info(data.ids[0])); pandora.api.find({ query: { - conditions: $.map(data.ids, function(id, i) { + conditions: data.ids.map(function(id) { return { key: 'id', value: id, diff --git a/static/js/pandora/ui/menu.js b/static/js/pandora/ui/menu.js index 3e93bcf0..d150d4d5 100644 --- a/static/js/pandora/ui/menu.js +++ b/static/js/pandora/ui/menu.js @@ -67,7 +67,7 @@ pandora.ui.mainMenu = function() { ] }, { id: 'viewMenu', title: 'View', items: [ { id: 'movies', title: 'View ' + pandora.site.itemName.plural, items: [ - { group: 'viewmovies', min: 1, max: 1, items: $.map(pandora.site.listViews, function(view, i) { + { group: 'viewmovies', min: 1, max: 1, items: pandora.site.listViews.map(function(view) { return Ox.extend({ checked: pandora.user.ui.lists[pandora.user.ui.list].listView == view.id, }, view); @@ -88,7 +88,7 @@ pandora.ui.mainMenu = function() { ]}, {}, { id: 'openmovie', title: ['Open ' + pandora.site.itemName.singular, 'Open ' + pandora.site.itemName.plural], items: [ - { group: 'movieview', min: 1, max: 1, items: $.map(pandora.site.itemViews, function(view, i) { + { group: 'movieview', min: 1, max: 1, items: pandora.site.itemViews.map(function(view) { return Ox.extend({ checked: pandora.user.ui.itemView == view.id, }, view); @@ -114,7 +114,7 @@ pandora.ui.mainMenu = function() { ]}, { id: 'sortMenu', title: 'Sort', items: [ { id: 'sortmovies', title: 'Sort ' + pandora.site.itemName.plural + ' by', items: [ - { group: 'sortmovies', min: 1, max: 1, items: $.map(pandora.site.sortKeys, function(key, i) { + { group: 'sortmovies', min: 1, max: 1, items: pandora.site.sortKeys.map(function(key) { return Ox.extend({ checked: pandora.user.ui.lists[pandora.user.ui.list].sort[0].key == key.id }, key); diff --git a/static/js/pandora/ui/placesDialog.js b/static/js/pandora/ui/placesDialog.js index b01ed1ba..4d5a5673 100644 --- a/static/js/pandora/ui/placesDialog.js +++ b/static/js/pandora/ui/placesDialog.js @@ -17,7 +17,7 @@ pandora.ui.placesDialog = function() { content: pandora.$ui.placesElement = Ox.ListMap({ height: height - 48, places: function(data, callback) { - return pandora.api.findPlaces($.extend({ + return pandora.api.findPlaces(Ox.extend({ query: {conditions: [], operator: ''} }, data), callback); }, diff --git a/static/js/pandora/ui/sortSelect.js b/static/js/pandora/ui/sortSelect.js index 86db3363..3faf3f28 100644 --- a/static/js/pandora/ui/sortSelect.js +++ b/static/js/pandora/ui/sortSelect.js @@ -2,9 +2,9 @@ pandora.ui.sortSelect = function() { var that = Ox.Select({ id: 'sortSelect', - items: $.map(pandora.site.sortKeys, function(key) { + items: pandora.site.sortKeys.map(function(key) { //Ox.print('????', pandora.user.ui.lists[pandora.user.ui.list].sort.key, key.id) - return $.extend($.extend({}, key), { + return Ox.extend(Ox.extend({}, key), { checked: pandora.user.ui.lists[pandora.user.ui.list].sort[0].key == key.id, title: 'Sort by ' + key.title }); diff --git a/static/js/pandora/ui/viewSelect.js b/static/js/pandora/ui/viewSelect.js index e150bfec..041b55eb 100644 --- a/static/js/pandora/ui/viewSelect.js +++ b/static/js/pandora/ui/viewSelect.js @@ -3,12 +3,12 @@ pandora.ui.viewSelect = function() { var that = Ox.Select({ id: 'viewSelect', items: !pandora.user.ui.item ? pandora.site.listViews.map(function(view) { - return $.extend($.extend({}, view), { + return Ox.extend(Ox.extend({}, view), { checked: pandora.user.ui.lists[pandora.user.ui.list].listView == view.id, title: 'View ' + view.title }); }) : pandora.site.itemViews.map(function(view) { - return $.extend($.extend({}, view), { + return Ox.extend(Ox.extend({}, view), { checked: pandora.user.ui.itemView == view.id, title: 'View: ' + view.title });