$(function() {
Ox.initLoading();
var pandora = new Ox.App({
requestURL: "/api/"
}),
$dialog = new Ox.Dialog({
title: "Application Error",
buttons: [
{
value: "Change Title",
click: function() {
Ox.print("click to change title")
$dialog.options({
title: "New Title"
});
$dialog.$buttons[0].toggleDisabled();
}
},
{
value: "Close",
click: function() {
$dialog.close();
}
}
]
});
var user = {
username: "",
group: "guest", // guest / user / vip / admin
prefs: {
find: "all",
groupMovies: "country",
orderMovies: "ascending",
orderGroups: "descending",
showGroups: true,
showInfo: true,
showMovies: true,
showSidebar: true,
sortMovies: "director",
sortGroups: "items",
useOxdbPosters: false,
useGroups: true,
viewMovies: "list",
viewIcons: "poster",
}
}
Ox.Location.set("find", {
s: user.prefs.sortMovies,
o: user.prefs.orderMovies
})
var $body = $("body");
var aspectRatio = 4 / 3;
var foo = {
id: "foo",
title: ["Show Window", "Hide Window"],
disabled: true,
checked: false,
group: "foo",
shortcut: "ALT ESCAPE", // $(this).bind("OxKeyboardAltEscape", function() { $(this).trigger("click"); })
click: function() {
},
bind: [
["OxUserLogin", function(e) {
$(this).setTitle("User:" + e.user)
}],
["OxResizeWindow", function() {
$(this).toggleChecked();
$(this).toggleDisabled();
$(this).toggleTitle();
}]
],
trigger: true // $("*").trigger("OxMenuUserLogin") // or trigger({ "type: OxMenuGroupname", item: Item })
}
var m = [
["pandora", "Pandora", [
["about", "About Pandora", {
click: loadPage
}],
[],
["faq", "Frequently Asked Questions", {
click: loadPage
}],
["tos", "Terms of Service", {
click: loadPage
}],
["sas", "Security Advisory System", {
click: loadPage
}],
[],
["contact", "Contact", {
click: loadPage
}],
[],
["technology", "Technology", {
click: loadPage
}],
["source", "Source Code", {
click: loadPage
}],
["report", "Report a Bug...", {
click: loadPage
}]
]],
["user", "User", [
["user", "User: not logged in", {
disabled: true,
bind: [
["OxLogin", function() {
$(this).setTitle("User: " + e.username)
}],
["OxLogout", function() {
$(this).toggleTitle();
}]
]
}],
[],
["account", "Account", {
disabled: true,
click: loadPage
}],
["preferences", "Preferences", {
disabled: true,
shortcut: "CONTROL ,",
click: loadPage
}],
[],
["login", ["Login", "Logout"], {
click: loadDialog,
bind: [
["OxLogin", function() {
$(this).toggleTitle();
}],
["OxLogout", function() {
$(this).toggleTitle();
}]
]
}]
]],
["list", "List", [
["history", "History", [
["All Movies", "All Movies", {}]
]],
["viewFilter", "View Filter", [
["Most Viewed", "Most Viewed", {}],
["Recently Viewed", "Recently Viewed", {}]
]],
["viewList", "View List", [
["Favorites", "Favorites", {}]
]],
["viewFeature", "View Feature", [
["Situationist Film", "Situationist Film", {}],
["Timelines", "Timelines", {}],
]],
[],
["newList", "New List...", {
disabled: true,
shortcut: "CONTROL N",
click: loadDialog
}],
["newListFromSelection", "New List from Selection...", {
disabled: true,
shortcut: "SHIFT CONTROL N",
click: loadDialog
}],
["newFilter", "New Filter...", {
disabled: true,
shortcut: "ALT CONTROL N",
click: loadDialog
}],
[],
["add", "Add Selected Movie to List...", {
disabled: true
}],
[],
["set", "Set Poster Frame", {
disabled: true
}]
]],
["edit", "Edit", [
["undo", "Undo", {
disabled: true,
shortcut: "CONTROL Z"
}],
["redo", "Redo", {
disabled: true,
shortcut: "SHIFT CONTROL Z"
}],
[],
["cut", "Cut", {
disabled: true,
shortcut: "CONTROL X"
}],
["copy", "Copy", {
disabled: true,
shortcut: "CONTROL C"
}],
["paste", "Paste", {
disabled: true,
shortcut: "CONTROL V"
}],
["delete", "Delete", {
disabled: true,
shortcut: "DELETE"
}],
[],
["all", "Select All", {
disabled: true,
shortcut: "CONTROL A"
}],
["none", "Select None", {
disabled: true,
shortcut: "SHIFT CONTROL A"
}],
["invert", "Invert Selection", {
disabled: true,
shortcut: "ALT CONTROL A"
}],
]],
["view", "View", [
["movies", "View Movies", getMenuGroupItems("viewMovies", [
"as List",
"as Icons",
"with Clips",
"with Timelines",
"with Maps",
"",
"as Scenes",
"on Map",
"on Calendar"
])],
["icons", "Icons", getMenuGroupItems("viewIcons", [
"Poster",
"Still",
"Timeline"
])],
["info", "Info", getMenuGroupItems("viewInfo", [
"Poster",
"Video"
])],
[],
["open", "Open Movie", [
["info", "Info", {
shortcut: "CONTROL RETURN"
}],
["poster", "Statistics", {}],
["scenes", "Clips", {}],
["editor", "Timeline", {}],
["map", "Map", {}],
["calendar", "Calendar", {}],
[],
["files", "Files", {}]
]],
["preview", "Preview", { shortcut: "CONTROL SPACE" }],
[],
["toggleSidebar", ["Hide Sidebar", "Show Sidebar"], {
shortcut: "SHIFT S"
}],
["toggleInfo", ["Hide Info", "Show Info"], {
shortcut: "SHIFT I"
}],
["toggleGroups", ["Hide Groups", "Show Groups"], {
shortcut: "SHIFT G"
}],
["toggleMovies", ["Hide Movies", "show Movies"], {
disabled: true,
shortcut: "SHIFT M"
}],
]],
["sort", "Sort", [
["sortMovies", "Sort Movies by", getMenuGroupItems("sortMovies", [
"Title",
"Director",
"Country",
"Year",
"Runtime",
"Language",
"Writer",
"Producer",
"Cinematographer",
"Editor",
"Cast",
"Genre",
"Keywords",
"Release Date",
"Budget",
"Gross",
"Profit",
"Rating",
"Votes",
"Connections",
"Locations",
"ID",
"",
"Aspect Ratio",
"Duration",
"Color",
"Saturation",
"Brightness",
"Volume",
"Clips",
"Cuts",
"Cuts per Minute",
"Words",
"Words per Minute",
"",
"Resolution",
"Pixels",
"Size",
"Bitrate",
"Files",
"Filename",
"Date Published",
"Date Modified"
])],
["orderMovies", "Order Movies", getMenuGroupItems("orderMovies", [
"Ascending",
"Descending"
])],
[],
["groups", "Use Groups", {
checked: true
}],
["groupMovies", "Group Movies by", getMenuGroupItems("groupMovies", [
"Director",
"Country",
"Year",
"Language",
"Genre"
])],
["sortGroups", "Sort Groups by", getMenuGroupItems("sortGroups", [
"Name",
"Number of Movies"
])],
["orderGroups", "Order Groups", getMenuGroupItems("orderGroups", [
"Ascending",
"Descending"
])]
]],
["find", "Find", [
["find", "Find", getMenuGroupItems("find", [
"All",
"Title",
"Director",
"Country",
"Year",
"Language",
"Writer",
"Producer",
"Cinematographer",
"Editor",
"Cast",
"Name",
"Genre",
"Keyword",
"Summary",
"Trivia",
"Dialog"
])],
[],
["advanced", "Advanced Find...", {}]
]],
["help", "Help", [
["help", "Pandora Help", {
shortcut: "SHIFT ?"
}]
]]
];
function getMenuGroupItems(group, titles) {
var items = [];
$.each(titles, function(i, v) {
if (v) {
//v.replace(/(^[as|on] )/, "");
var id = v.replace("as ", "").replace("with ", "").replace(" of Movies", "").replace(" ", "").toLowerCase();
items.push([id, v, {
group: group,
checked: user.prefs[group] == id,
bind: [group, function(e) {
if (e.sort == id) {
Ox.topMenu.toggleChecked("sort/" + group + "/" + id);
}
}]
}]);
} else {
items.push([]);
}
});
if (group == "viewMovies") {
items.push([]),
items.push(["rss", "RSS", {}]);
items.push(["json", "JSON", {}]);
}
if (group == "viewIcons") {
items.push([]);
items.push(["pandora", "Always Use 0xdb Posters", {
group: "pandoraPosters",
checked: false
}]);
}
return items;
}
var menus = [
["list", "List", [
["foo", "Foo", { checked: true, shortcut: "ALT ESCAPE" }, function() {}],
["view", "View List", getMenuItemsC()],
["more", "View More", getMenuItemsL()],
[],
["createList", "New List...", { disabled: true, shortcut: "CONTROL N" }, function() { loadDialog("createList"); }],
["createListFromSelection", "New List from Selection...", { disabled: true, shortcut: "SHIFT CONTROL N" }, function() { loadDialog("createListFromSelection"); }],
["createSmartList", "New Filter...", { disabled: true, shortcut: "ALT CONTROL N"}, function() { loadDialog("createList"); }],
[],
["add", "Add Movie to List", { disabled: false }, function() {}],
["remove", "Remove Movie from List", { disabled: true }, function() {}]
]],
["edit", "Edit", [
["undo", "Undo", { shortcut: "CONTROL Z" }, function() {}],
["redo", "Redo", { shortcut: "SHIFT CONTROL Z" }, function() {}],
[],
["cut", "Cut", { shortcut: "CONTROL X" }, function() {}],
["copy", "Copy", { shortcut: "CONTROL C" }, function() {}],
["paste", "Paste", { shortcut: "CONTROL V" }, function() {}],
["delete", "Delete", { shortcut: "DELETE" }, function() {}],
[],
["all", "Select All", { shortcut: "CONTROL A" }, function() {}],
["none", "Select None", { shortcut: "SHIFT CONTROL A" }, function() {}],
["invert", "Invert Selection", { shortcut: "ALT CONTROL A" }, function() {}],
]],
["view", "View", [
["view", "View Movies", [
["viewList", "as List", function() { setPref("view", "list"); }],
["viewGrid", "as Grid", { checked: true }, function() { setPref("view", "grid"); }],
["viewScenes", "as Scenes", function() { setPref("view", "scenes"); }],
["viewTimelines", "as Timelines", function() { setPref("view", "timelines"); }],
["viewMaps", "as Maps", function() { setPref("view", "maps"); }],
[],
["map", "on Map", function() {}],
["calendar", "on Calendar", function() {}],
[],
["viewRSS", "RSS", function() { setPref("view", "maps"); }],
["viewJSON", "JSON", function() { setPref("view", "maps"); }],
[],
["foobar", "foobar", [
["foo", "foo", function() { setPref("view", "maps"); }],
["bar", "bar", function() { setPref("view", "maps"); }]
]]
]],
["icons", "Icons", [
["posters", "Posters", { checked: true }, function() {}],
["stills", "Stills", function() {}],
["timelines", "Timelines", function() {}],
[],
["pandora", "Always Use 0xdb Posters", function() {}],
]],
[],
["open", "Open Movie", [
["info", "Info", { shortcut: "CONTROL RETURN" }, function() {}],
["poster", "Poster", function() {}],
["scenes", "Scenes", function() {}],
["editor", "Editor", function() {}],
["map", "Map", function() {}],
["calendar", "Calendar", function() {}]
]],
["preview", "Preview Movie", { shortcut: "CONTROL SPACE" }, function() {}],
[],
["lists", "Hide Lists", { shortcut: "SHIFT L" }, function() { $("#sideView").parent().next().trigger("dblclick"); $topMenu.toggleTitle("view/lists", ["Hide Lists", "Show Lists"]) }],
["stills", "Hide Scenes", { shortcut: "SHIFT S" }, function() {} ],
["groups", "Hide Groups", { shortcut: "SHIFT G" }, function() {}],
["movies", "Hide Movies", { disabled: true, shortcut: "SHIFT M" }, function() {}],
]],
["sort", "Sort", [
["sort", "Sort Movies by", [
["id", "ID", { group: "sort", checked: true }, function() { setPref("sort", "id"); }],
["title", "Title", { group: "sort" }, function() { setPref("sort", "title"); }],
["director", "Director", { group: "sort" }, function() { setPref("sort", "director"); }],
["country", "Country", { group: "sort" }, function() { setPref("sort", "country"); }],
["year", "Year", { group: "sort" }, function() { setPref("sort", "year"); }],
["language", "Language", { group: "sort" }, function() { setPref("sort", "language"); }],
["runtime", "Runtime", { group: "sort" }, function() { setPref("sort", "runtime"); }],
["producer", "Producer", { group: "sort" }, function() { setPref("sort", "producer"); }],
["writer", "Writer", { group: "sort" }, function() { setPref("sort", "writer"); }],
["cinematographer", "Cinematographer", { group: "sort" }, function() { setPref("sort", "cinematographer"); }],
["editor", "Editor", { group: "sort" }, function() { setPref("sort", "editor"); }],
["genre", "Genre", { group: "sort" }, function() { setPref("sort", "genre"); }],
["releasedate", "Release Date", { group: "sort" }, function() { setPref("sort", "releasedate"); }],
["rating", "Rating", { group: "sort" }, function() { setPref("sort", "rating"); }],
["votes", "Votes", { group: "sort" }, function() { setPref("sort", "votes"); }]
]],
["order", "Order Movies", [
["ascending", "Ascending", { group: "order", checked: true }, function() { setPref("order", "ascending"); }],
["descending", "Descending", { group: "order" }, function() { setPref("order", "descending"); }]
]],
[],
["groups", "Use Groups", { checked: true }, function() {}],
["group", "Group Movies by", [
["title", "Title", function() { setPref("group", "title"); }],
["director", "Director", { checked: true }, function() { setPref("group", "director"); }],
["country", "Country", function() { setPref("group", "country"); }],
["year", "Year", function() { setPref("group", "year"); }]
]],
["sortGroups", "Sort Groups by", [
["name", "Name", { checked: true }, function() { setPref("sortGroups", "name"); }],
["movies", "Number of Movies", function() { setPref("sortGroups", "movies"); }]
]],
["orderGroups", "Order Groups", [
["ascending", "Ascending", { checked: true }, function() { setPref("orderGroups", "ascending"); }],
["descending", "Descending", function() { setPref("orderGroups", "descending"); }]
]]
]],
["find", "Find", [
["find", "Find", [
["all", "All", { checked: true }, function() {}],
["title", "Title", function() { setPref("find", "title"); }],
["director", "Director", function() { setPref("find", "director"); }],
["country", "Country", function() { setPref("find", "country"); }],
["year", "Year", function() { setPref("find", "year"); }],
["language", "Language", function() { setPref("find", "language"); }],
["producer", "Producer", function() { setPref("find", "producer"); }],
["writer", "Writer", function() { setPref("find", "writer"); }],
["cinematographer", "Cinematographer", function() { setPref("find", "cinematographer"); }],
["editor", "Editor", function() { setPref("find", "editor"); }],
["cast", "Cast", function() { setPref("find", "cast"); }],
["name", "Name", function() { setPref("find", "name"); }],
["genre", "Name", function() { setPref("find", "genre"); }],
["keywords", "Keywords", function() { setPref("find", "keywords"); }],
]],
[],
["advanced", "Advanced Find", function() {}]
]],
["help", "Help", [
["help", "Pandora Help", { shortcut: "SHIFT ?" }, function() {}]
]],
["test", "Test", [
["me", "Check Me", function() { $topMenu.toggleChecked("test/me"); }],
["disable", "Disable It", function() { $topMenu.toggleDisabled("test/me"); $topMenu.toggleTitle("test/disable", ["Disable It", "Enable It"]); }],
["them", "Check Them", [
["me", "Check Me", { checked: true, group: "them" }, function() { $topMenu.checkItem("test/them/me"); }],
["her", "Check Her", { group: "them" }, function() { $topMenu.checkItem("test/them/her"); }],
["him", "Check Him", { group: "them" }, function() { $topMenu.checkItem("test/them/him"); }],
[],
["disable", "Disable Them", function() { $topMenu.toggleDisabled("test/them/me"); $topMenu.toggleDisabled("test/them/her"); $topMenu.toggleDisabled("test/them/him"); $topMenu.toggleTitle("test/them/disable", ["Disable Them", "Enable Them"]); }]
]],
["1", "1"],
["2", "2"],
["3", "3"],
["4", "4"],
["5", "5"],
["6", "6"],
["7", "7"],
["8", "8"],
["9", "9"],
["10", "10"],
["11", "11"],
["12", "12"],
[],
["add", "Add Item", function() { $topMenu.insertItemAfter("test/12", ["13", "13"]); $topMenu.toggleDisabled("test/add"); $topMenu.toggleDisabled("test/remove"); }],
["remove", "Remove Item", { disabled: true }, function() { $topMenu.removeItem("test/13"); $topMenu.toggleDisabled("test/add"); $topMenu.toggleDisabled("test/remove"); }],
]]
];
function getMenuItemsC() {
var items = [];
var countries = Ox.getCountries();
$.each(countries, function(i, v) {
items.push([v.code, v.name, { icon: Ox.baseUrl + "png/flags/" + v.flag + ".png" }, function() {}]);
});
return items;
}
function getMenuItemsL() {
var items = [];
var languages = Ox.getLanguages();
$.each(languages, function(i, v) {
items.push([v.code, v.name, { icon: Ox.baseUrl + "png/flags/" + v.flag + ".png" }, function() {}]);
});
return items;
}
function getBrowserItems() {
var items = [];
var groups = [{"items": 3093, "title": "United States"}, {"items": 1142, "title": "France"}, {"items": 688, "title": "Germany"}, {"items": 548, "title": "United Kingdom"}, {"items": 296, "title": "Italy"}, {"items": 285, "title": "Japan"}, {"items": 253, "title": "Canada"}, {"items": 94, "title": "Austria"}, {"items": 88, "title": "Spain"}, {"items": 88, "title": "Switzerland"}, {"items": 79, "title": "Soviet Union"}, {"items": 75, "title": "Belgium"}, {"items": 72, "title": "Netherlands"}, {"items": 72, "title": "Sweden"}, {"items": 69, "title": "Unknown"}, {"items": 61, "title": "Poland"}, {"items": 52, "title": "Hong Kong"}, {"items": 50, "title": "Denmark"}, {"items": 46, "title": "Australia"}, {"items": 42, "title": "China"}, {"items": 42, "title": "India"}, {"items": 39, "title": "Finland"}, {"items": 38, "title": "South Korea"}, {"items": 36, "title": "Iran"}, {"items": 36, "title": "Russia"}, {"items": 34, "title": "Mexico"}, {"items": 34, "title": "Taiwan"}, {"items": 30, "title": "Ireland"}, {"items": 28, "title": "Portugal"}, {"items": 27, "title": "Cuba"}, {"items": 27, "title": "Yugoslavia"}, {"items": 26, "title": "Norway"}, {"items": 24, "title": "Argentina"}, {"items": 24, "title": "Brazil"}, {"items": 16, "title": "Czechoslovakia"}, {"items": 16, "title": "Luxembourg"}, {"items": 15, "title": "Thailand"}, {"items": 12, "title": "Chile"}, {"items": 12, "title": "Czech Republic"}, {"items": 11, "title": "Hungary"}, {"items": 10, "title": "Senegal"}, {"items": 9, "title": "Israel"}, {"items": 8, "title": "Greece"}, {"items": 7, "title": "Tunisia"}, {"items": 7, "title": "Turkey"}, {"items": 6, "title": "East Germany"}, {"items": 6, "title": "Egypt"}, {"items": 5, "title": "Algeria"}, {"items": 5, "title": "Burkina Faso"}, {"items": 4, "title": "Cameroon"}, {"items": 4, "title": "South Africa"}, {"items": 3, "title": "Bolivia"}, {"items": 3, "title": "Morocco"}, {"items": 3, "title": "Peru"}, {"items": 3, "title": "Philippines"}, {"items": 3, "title": "Romania"}, {"items": 3, "title": "Slovenia"}, {"items": 3, "title": "Ukraine"}, {"items": 3, "title": "Venezuela"}, {"items": 2, "title": "Armenia"}, {"items": 2, "title": "Bosnia and Herzegovina"}, {"items": 2, "title": "Croatia"}, {"items": 2, "title": "Estonia"}, {"items": 2, "title": "Iceland"}, {"items": 2, "title": "Jamaica"}, {"items": 2, "title": "Kazakhstan"}, {"items": 2, "title": "Lebanon"}, {"items": 2, "title": "Liechtenstein"}, {"items": 2, "title": "Lithuania"}, {"items": 2, "title": "Malaysia"}, {"items": 2, "title": "New Zealand"}, {"items": 2, "title": "Serbia"}, {"items": 2, "title": "Singapore"}, {"items": 2, "title": "Sri Lanka"}, {"items": 2, "title": "Vietnam"}, {"items": 1, "title": "Afghanistan"}, {"items": 1, "title": "Bangladesh"}, {"items": 1, "title": "Belarus"}, {"items": 1, "title": "Botswana"}, {"items": 1, "title": "Bulgaria"}, {"items": 1, "title": "Chad"}, {"items": 1, "title": "Colombia"}, {"items": 1, "title": "Congo"}, {"items": 1, "title": "Ecuador"}, {"items": 1, "title": "Indonesia"}, {"items": 1, "title": "Iraq"}, {"items": 1, "title": "Kenya"}, {"items": 1, "title": "Macau"}, {"items": 1, "title": "Madagascar"}, {"items": 1, "title": "Mali"}, {"items": 1, "title": "Niger"}, {"items": 1, "title": "Palestine"}, {"items": 1, "title": "Puerto Rico"}, {"items": 1, "title": "Serbia and Montenegro"}, {"items": 1, "title": "Slovakia"}, {"items": 1, "title": "Syria"}, {"items": 1, "title": "Tajikistan"}, {"items": 1, "title": "Uruguay"}, {"items": 1, "title": "Yemen"}];
$.each(groups, function(i, v) {
var code = Ox.getCountryCode(v.title.replace("Unknown", "Neutral Zone"));
var flag = Ox.getFlag(v.title.replace("Unknown", "Neutral Zone"));
var strings = v.title.split(" ");
items.push({
size: 64,
id: code,
icon: "http://localhost/pandorastatic/flags/" + flag + ".png",
title: strings[0] + (strings.length > 1 ? "
" + strings[1] : ""),
info: Ox.formatNumber(v.items) + " Movie" + (v.items > 1 ? "s" : "")
});
});
return items;
}
/*
$element = new Ox.Container().css({
width: "256px",
height: "256px",
background: "red"
}).click(function() {
Ox.print("click");
}).html("foo").appendTo($body);
$bar = new Ox.Bar({
orientation: "horizontal",
height: 16
}).appendTo($body);
*/
var $sideBrowserPlayer = $("