diff --git a/pandora/static/js/pandora.js b/pandora/static/js/pandora.js index a4d46c5b3..7b8a4c281 100755 --- a/pandora/static/js/pandora.js +++ b/pandora/static/js/pandora.js @@ -3,133 +3,133 @@ $(function() { //Ox.debug = Ox.print; //Ox.print = function() {}; - var $body = $("body"), + var $body = $('body'), $document = $(document), $window = $(window), config = { - appId: "oxdb", - appName: "0xDB", + appId: 'oxdb', + appName: '0xDB', findKeys: [ - { id: "all", title: "All" }, - { id: "title", title: "Title", autocomplete: true }, - { id: "director", title: "Director", autocomplete: true }, - { id: "country", title: "Country", autocomplete: true }, - { id: "year", title: "Year", autocomplete: true }, - { id: "language", title: "Language", autocomplete: true }, - { id: "writer", title: "Writer", autocomplete: true }, - { id: "producer", title: "Producer", autocomplete: true }, - { id: "cinematographer", title: "Cinematographer", autocomplete: true }, - { id: "editor", title: "Editor", autocomplete: true }, - { id: "actor", title: "Actor", autocomplete: true }, - { id: "character", title: "Character", autocomplete: true }, - { id: "name", title: "Name", autocomplete: true }, - { id: "genre", title: "Genre", autocomplete: true }, - { id: "keyword", title: "Keyword", autocomplete: true }, - { id: "summary", title: "Summary" }, - { id: "dialog", title: "Dialog" } + { id: 'all', title: 'All' }, + { id: 'title', title: 'Title', autocomplete: true }, + { id: 'director', title: 'Director', autocomplete: true }, + { id: 'country', title: 'Country', autocomplete: true }, + { id: 'year', title: 'Year', autocomplete: true }, + { id: 'language', title: 'Language', autocomplete: true }, + { id: 'writer', title: 'Writer', autocomplete: true }, + { id: 'producer', title: 'Producer', autocomplete: true }, + { id: 'cinematographer', title: 'Cinematographer', autocomplete: true }, + { id: 'editor', title: 'Editor', autocomplete: true }, + { id: 'actor', title: 'Actor', autocomplete: true }, + { id: 'character', title: 'Character', autocomplete: true }, + { id: 'name', title: 'Name', autocomplete: true }, + { id: 'genre', title: 'Genre', autocomplete: true }, + { id: 'keyword', title: 'Keyword', autocomplete: true }, + { id: 'summary', title: 'Summary' }, + { id: 'dialog', title: 'Dialog' } ], - groups: ["director", "country", "year", "language", "genre"], + groups: ['director', 'country', 'year', 'language', 'genre'], itemViews: [ - { id: "info", title: "Info" }, - { id: "statistics", title: "Statistics" }, - { id: "clips", title: "Clips" }, - { id: "timeline", title: "Timeline" }, - { id: "map", title: "Map" }, - { id: "calendar", title: "Calendar" }, - { id: "files", title: "Files", admin: true } + { id: 'info', title: 'Info' }, + { id: 'statistics', title: 'Statistics' }, + { id: 'clips', title: 'Clips' }, + { id: 'timeline', title: 'Timeline' }, + { id: 'map', title: 'Map' }, + { id: 'calendar', title: 'Calendar' }, + { id: 'files', title: 'Files', admin: true } ], listViews: [ - { id: "list", title: "as List" }, - { id: "icons", title: "as Icons" }, - { id: "info", title: "with Info" }, - { id: "clips", title: "with Clips" }, - { id: "timelines", title: "with Timelines" }, - { id: "maps", title: "with Maps" }, - { id: "calendars", title: "with Calendars" }, - { id: "clip", title: "as Clips" }, - { id: "map", title: "on Map" }, - { id: "calendar", title: "on Calendar" }, + { id: 'list', title: 'as List' }, + { id: 'icons', title: 'as Icons' }, + { id: 'info', title: 'with Info' }, + { id: 'clips', title: 'with Clips' }, + { id: 'timelines', title: 'with Timelines' }, + { id: 'maps', title: 'with Maps' }, + { id: 'calendars', title: 'with Calendars' }, + { id: 'clip', title: 'as Clips' }, + { id: 'map', title: 'on Map' }, + { id: 'calendar', title: 'on Calendar' }, ], sections: [ - { id: "history", title: "History" }, - { id: "lists", title: "My Lists" }, - { id: "public", title: "Public Lists" }, - { id: "featured", title: "Featured Lists" } + { id: 'history', title: 'History' }, + { id: 'lists', title: 'My Lists' }, + { id: 'public', title: 'Public Lists' }, + { id: 'featured', title: 'Featured Lists' } ], sortKeys: [ - { id: "title", title: "Title", operator: "", align: "left", width: 180, removable: false }, - { id: "director", title: "Director", operator: "", align: "left", width: 180, removable: false }, - { id: "country", title: "Country", operator: "", align: "left", width: 120 }, - { id: "year", title: "Year", operator: "-", align: "right", width: 60 }, - { id: "language", title: "Language", operator: "", align: "left", width: 120 }, - { id: "runtime", title: "Runtime", operator: "", align: "right", width: 60 }, - { id: "writer", title: "Writer", operator: "", align: "left", width: 180 }, - { id: "producer", title: "Producer", operator: "", align: "left", width: 180 }, - { id: "cinematographer", title: "Cinematographer", operator: "", align: "left", width: 180 }, - { id: "editor", title: "Editor", operator: "", align: "left", width: 180 }, - { id: "actors", title: "Number of Actors", operator: "-", align: "right", width: 60 }, - { id: "genre", title: "Genre", operator: "", align: "left", width: 120 }, - { id: "keywords", title: "Number of Keywords", operator: "-", align: "right", width: 60 }, - { id: "summary", title: "Words in Summary", operator: "-", align: "right", width: 60 }, - { id: "trivia", title: "Words in Trivia", operator: "-", align: "right", width: 60 }, - { id: "releasedate", title: "Release Date", operator: "-", align: "left", width: 90 }, - { id: "budget", title: "Budget", operator: "-", align: "right", width: 90 }, - { id: "gross", title: "Gross", operator: "-", align: "right", width: 90 }, - { id: "profit", title: "Profit", operator: "-", align: "right", width: 90 }, - { id: "rating", title: "Rating", operator: "-", align: "right", width: 60 }, - { id: "votes", title: "Votes", operator: "-", align: "right", width: 90 }, - { id: "id", title: "ID", operator: "", align: "left", width: 90 }, - { id: "aspectratio", title: "Aspect Ratio", operator: "-", align: "left", width: 90 }, - { id: "duration", title: "Duration", operator: "-", align: "right", width: 90 }, - { id: "color", title: "Color", operator: "", align: "left", width: 90 }, - { id: "saturation", title: "Saturation", operator: "-", align: "right", width: 60 }, - { id: "brightness", title: "Brightness", operator: "-", align: "right", width: 60 }, - { id: "volume", title: "Volume", operator: "-", align: "right", width: 60 }, - { id: "clips", title: "Clips", operator: "-", align: "right", width: 60 }, - { id: "cuts", title: "Cuts", operator: "-", align: "right", width: 60 }, - { id: "cutsperminute", title: "Cuts per Minute", operator: "-", align: "right", width: 60 }, - { id: "words", title: "Words", operator: "-", align: "right", width: 60 }, - { id: "wordsperminute", title: "Words per Minute", operator: "-", align: "right", width: 60 }, - { id: "resolution", title: "Resolution", operator: "-", align: "left", width: 90 }, - { id: "pixels", title: "Pixels", operator: "-", align: "right", width: 90 }, - { id: "size", title: "Size", operator: "-", align: "right", width: 90 }, - { id: "bitrate", title: "Bitrate", operator: "-", align: "right", width: 90 }, - { id: "files", title: "Files", operator: "-", align: "right", width: 60 }, - { id: "filename", title: "Filename", operator: "", align: "left", width: 180 }, - { id: "published", title: "Date Published", operator: "-", align: "left", width: 90 }, - { id: "modified", title: "Date Modified", operator: "-", align: "left", width: 90 } + { id: 'title', title: 'Title', operator: '', align: 'left', width: 180, removable: false }, + { id: 'director', title: 'Director', operator: '', align: 'left', width: 180, removable: false }, + { id: 'country', title: 'Country', operator: '', align: 'left', width: 120 }, + { id: 'year', title: 'Year', operator: '-', align: 'right', width: 60 }, + { id: 'language', title: 'Language', operator: '', align: 'left', width: 120 }, + { id: 'runtime', title: 'Runtime', operator: '', align: 'right', width: 60 }, + { id: 'writer', title: 'Writer', operator: '', align: 'left', width: 180 }, + { id: 'producer', title: 'Producer', operator: '', align: 'left', width: 180 }, + { id: 'cinematographer', title: 'Cinematographer', operator: '', align: 'left', width: 180 }, + { id: 'editor', title: 'Editor', operator: '', align: 'left', width: 180 }, + { id: 'actors', title: 'Number of Actors', operator: '-', align: 'right', width: 60 }, + { id: 'genre', title: 'Genre', operator: '', align: 'left', width: 120 }, + { id: 'keywords', title: 'Number of Keywords', operator: '-', align: 'right', width: 60 }, + { id: 'summary', title: 'Words in Summary', operator: '-', align: 'right', width: 60 }, + { id: 'trivia', title: 'Words in Trivia', operator: '-', align: 'right', width: 60 }, + { id: 'releasedate', title: 'Release Date', operator: '-', align: 'left', width: 90 }, + { id: 'budget', title: 'Budget', operator: '-', align: 'right', width: 90 }, + { id: 'gross', title: 'Gross', operator: '-', align: 'right', width: 90 }, + { id: 'profit', title: 'Profit', operator: '-', align: 'right', width: 90 }, + { id: 'rating', title: 'Rating', operator: '-', align: 'right', width: 60 }, + { id: 'votes', title: 'Votes', operator: '-', align: 'right', width: 90 }, + { id: 'id', title: 'ID', operator: '', align: 'left', width: 90 }, + { id: 'aspectratio', title: 'Aspect Ratio', operator: '-', align: 'left', width: 90 }, + { id: 'duration', title: 'Duration', operator: '-', align: 'right', width: 90 }, + { id: 'color', title: 'Color', operator: '', align: 'left', width: 90 }, + { id: 'saturation', title: 'Saturation', operator: '-', align: 'right', width: 60 }, + { id: 'brightness', title: 'Brightness', operator: '-', align: 'right', width: 60 }, + { id: 'volume', title: 'Volume', operator: '-', align: 'right', width: 60 }, + { id: 'clips', title: 'Clips', operator: '-', align: 'right', width: 60 }, + { id: 'cuts', title: 'Cuts', operator: '-', align: 'right', width: 60 }, + { id: 'cutsperminute', title: 'Cuts per Minute', operator: '-', align: 'right', width: 60 }, + { id: 'words', title: 'Words', operator: '-', align: 'right', width: 60 }, + { id: 'wordsperminute', title: 'Words per Minute', operator: '-', align: 'right', width: 60 }, + { id: 'resolution', title: 'Resolution', operator: '-', align: 'left', width: 90 }, + { id: 'pixels', title: 'Pixels', operator: '-', align: 'right', width: 90 }, + { id: 'size', title: 'Size', operator: '-', align: 'right', width: 90 }, + { id: 'bitrate', title: 'Bitrate', operator: '-', align: 'right', width: 90 }, + { id: 'files', title: 'Files', operator: '-', align: 'right', width: 60 }, + { id: 'filename', title: 'Filename', operator: '', align: 'left', width: 180 }, + { id: 'published', title: 'Date Published', operator: '-', align: 'left', width: 90 }, + { id: 'modified', title: 'Date Modified', operator: '-', align: 'left', width: 90 } ], totals: [ - { id: "items" }, - { id: "runtime" }, - { id: "files", admin: true }, - { id: "duration", admin: true }, - { id: "size", admin: true }, - { id: "pixels" } + { id: 'items' }, + { id: 'runtime' }, + { id: 'files', admin: true }, + { id: 'duration', admin: true }, + { id: 'size', admin: true }, + { id: 'pixels' } ], user: { - group: "guest", + group: 'guest', ui: { - columns: ["id", "title", "director", "country", "year", "language", "runtime", "genre", "releasedate"], - // find: { conditions: [{ key: "", value: "", operator: "" }], operator: "" }, - findQuery: { conditions: [], operator: "" }, - groupsQuery: { conditions: [], operator: "|" }, + columns: ['id', 'title', 'director', 'country', 'year', 'language', 'runtime', 'genre', 'releasedate'], + // find: { conditions: [{ key: '', value: '', operator: '' }], operator: '' }, + findQuery: { conditions: [{key: '', value: '', operator: ''}], operator: '' }, + groupsQuery: { conditions: [], operator: '|' }, groupsSize: 128, - itemView: "info", - listQuery: { conditions: [], operator: "" }, + itemView: 'info', + listQuery: { conditions: [], operator: '' }, listsSize: 192, - listView: "list", - sections: ["history", "lists", "public", "featured"], + listView: 'list', + sections: ['history', 'lists', 'public', 'featured'], showGroups: true, showInfo: true, showLists: true, showMovies: true, sort: [ - { key: "director", operator: "" } + { key: 'director', operator: '' } ], - theme: $.browser.mozilla ? "classic" : "modern" + theme: $.browser.mozilla ? 'classic' : 'modern' }, - username: "" + username: '' } }, user = config.user, @@ -146,20 +146,20 @@ $(function() { Query = (function() { function constructFind(query) { - Ox.print("cF", query) + Ox.print('cF', query) return /*encodeURI(*/$.map(query.conditions, function(v, i) { if (!Ox.isUndefined(v.conditions)) { - return "[" + constructFind(v) + "]"; + return '[' + constructFind(v) + ']'; } else { - return v.value !== "" ? v.key + (v.key ? ":" : "") + constructValue(v.value, v.operator) : null; + return v.value !== '' ? v.key + (v.key ? ':' : '') + constructValue(v.value, v.operator) : null; } }).join(query.operator)/*)*/; } function constructValue(value, operator) { - operator = operator.replace("=", "^$"); - if (operator.indexOf("$") > -1) { - value = operator.substr(0, operator.length - 1) + value + "$" + operator = operator.replace('=', '^$'); + if (operator.indexOf('$') > -1) { + value = operator.substr(0, operator.length - 1) + value + '$' } else { value = operator + value; } @@ -172,27 +172,27 @@ $(function() { function parseFind(str) { var find = { conditions: [], - operator: "" + operator: '' }, subconditions = str.match(/\[.*?\]/g) || []; $.each(subconditions, function(i, v) { subconditions[i] = v.substr(1, v.length - 2); - str = str.replace(v, "[" + i + "]"); + str = str.replace(v, '[' + i + ']'); }); - if (str.indexOf(",") > -1) { - find.operator = "&"; - } else if (str.indexOf("|") > -1) { - find.operator = "|"; + if (str.indexOf(',') > -1) { + find.operator = '&'; + } else if (str.indexOf('|') > -1) { + find.operator = '|'; } - Ox.print("pF", str, find.operator) - find.conditions = $.map(find.operator === "" ? [str] : str.split(find.operator == "&" ? "," : "|"), function(v, i) { - Ox.print("v", v) + Ox.print('pF', str, find.operator) + find.conditions = $.map(find.operator === '' ? [str] : str.split(find.operator == '&' ? ',' : '|'), function(v, i) { + Ox.print('v', v) var ret, kv; - if (v[0] == "[") { - Ox.print("recursion", subconditions) + if (v[0] == '[') { + Ox.print('recursion', subconditions) ret = parseFind(subconditions[parseInt(v.substr(1, v.length - 2))]); } else { - kv = ((v.indexOf(":") > - 1 ? "" : ":") + v).split(":"); + kv = ((v.indexOf(':') > - 1 ? '' : ':') + v).split(':'); ret = $.extend({ key: kv[0] }, parseValue(kv[1])); @@ -205,21 +205,21 @@ $(function() { function parseValue(str) { var value = { value: decodeURI(str), - operator: "" + operator: '' }; - if (value.value[0] == "!") { - value.operator = "!" + if (value.value[0] == '!') { + value.operator = '!' value.value = value.value.substr(1); } - if ("^<>".indexOf(value.value[0]) > -1) { + if ('^<>'.indexOf(value.value[0]) > -1) { value.operator += value.value[0]; value.value = value.value.substr(1); } - if (value.value.substr(-1) == "$") { - value.operator += "$"; + if (value.value.substr(-1) == '$') { + value.operator += '$'; value.value = value.value.substr(0, value.value.length - 1); } - value.operator = value.operator.replace("^$", "="); + value.operator = value.operator.replace('^$', '='); return value; } @@ -228,29 +228,29 @@ $(function() { fromString: function(str) { var query = Ox.unserialize(str), sort = []; - if ("find" in query) { + if ('find' in query) { user.ui.findQuery = parseFind(query.find); - Ox.print("user.ui.findQuery", user.ui.findQuery) + Ox.print('user.ui.findQuery', user.ui.findQuery) } - if ("sort" in query) { - sort = query.sort.split(",") - user.ui.sort = $.map(query.sort.split(","), function(v, i) { - var hasOperator = "+-".indexOf(v[0]) > -1, + if ('sort' in query) { + sort = query.sort.split(',') + user.ui.sort = $.map(query.sort.split(','), function(v, i) { + var hasOperator = '+-'.indexOf(v[0]) > -1, key = hasOperator ? query.sort.substr(1) : query.sort, - operator = hasOperator ? v[0].replace("+", "") : Ox.getObjectById(config.sortKeys, key).operator; + operator = hasOperator ? v[0].replace('+', '') : Ox.getObjectById(config.sortKeys, key).operator; return { key: key, operator: operator }; }); } - if ("view" in query) { + if ('view' in query) { user.ui.listView = query.view; } }, toObject: function(groupId) { - Ox.print("tO", user.ui.findQuery.conditions) + Ox.print('tO', user.ui.findQuery.conditions) // the inner $.merge() creates a clone var conditions = $.merge($.merge([], user.ui.listQuery.conditions), user.ui.findQuery.conditions); $.merge(conditions, groups ? $.map(groups, function(v, i) { @@ -259,7 +259,7 @@ $(function() { v.query.conditions : v.query; } }) : []), - operator = conditions.length < 2 ? "" : ","; // fixme: should be & + operator = conditions.length < 2 ? '' : ','; // fixme: should be & Ox.print(groupId, user.ui.find, conditions); return { conditions: conditions, @@ -268,7 +268,7 @@ $(function() { }, toString: function() { - Ox.print("tS", user.ui.find) + Ox.print('tS', user.ui.find) return Ox.serialize({ find: constructFind(Query.toObject()), sort: user.ui.sort[0].operator + user.ui.sort[0].key, @@ -283,18 +283,18 @@ $(function() { // App Query.fromString(location.hash.substr(1)); - Ox.print("user.ui", user.ui) + Ox.print('user.ui', user.ui) document.title = config.appName; Ox.theme(user.ui.theme); app = new Ox.App({ name: config.appName, - requestURL: "/api/" + requestURL: '/api/' }); - $("