summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2014-09-20 22:07:33 (GMT)
committerChristian Pointner <equinox@helsinki.at>2014-09-20 22:07:33 (GMT)
commit07cdbb3c6b86a783f23f70a92f90ddf97e597b2c (patch)
treef63480075a3d2e6bb97dcbd22501184e7c4900c8
parentd54ed61ac57c905ed10235ed49ddc4e2c080970d (diff)
moved javascript code to external files
-rw-r--r--index.html268
-rw-r--r--js/apps.js34
-rw-r--r--js/auth.js78
-rw-r--r--js/musicpools.js5
-rw-r--r--js/shows.js129
5 files changed, 250 insertions, 264 deletions
diff --git a/index.html b/index.html
index d8c74c9..5442dd1 100644
--- a/index.html
+++ b/index.html
@@ -46,271 +46,11 @@
weekday[4] = "Donnerstag";
weekday[5] = "Freitag";
weekday[6] = "Samstag";
-
-
-
-
-
- var shows_currentid;
- var shows_list = [];
- var shows_current;
- var shows_group_carts = [];
- var shows_log_carts = [];
-
- function shows_udpateCartListing() {
- $('#show-carts tbody').find('tr').remove();
- $('#show-info-dumper').text(
- 'Current Show:\n' + JSON.stringify(shows_current, null, ' ') +
- '\n\nGroup Carts:\n' + JSON.stringify(shows_group_carts, null, ' ') +
- '\n\nLog Carts:\n' + JSON.stringify(shows_log_carts, null, ' ')
- );
-
- }
-
- function shows_updateGroupCartList(data, status, req) {
- shows_group_carts = [];
- $('#show-carts').find('tr:gt(0)').remove();
- var cartlist = $(data).find("cartList");
- var carts = cartlist.children();
- carts.each(function() {
- var cut = $(this).find("cutList").get(0);
- cart = {
- number: $(this).find('number').text(),
- title: $(this).find('title').text(),
- length: $(cut).find('length').text(),
- imported: new Date($(cut).find('originDatetime').text()),
- playcnt: new Date($(cut).find('playCounter').text()),
- lastplayed: new Date($(cut).find('lastPlayDatetime').text()),
- };
- shows_group_carts.push(cart);
- }
- );
- }
-
- function shows_updateLogCartList(data, status, req) {
- shows_log_carts = [];
- var loglist = $(data).find("logList");
- var loglines = loglist.children();
- loglines.each(function() {
- var number = $(this).find('cartNumber').text();
- if(number >= shows_current.group.lowcart && number <= shows_current.group.highcart) {
- shows_log_carts.push(number);
- }
- }
- );
- }
-
- function shows_showSelected() {
- shows_currentid = $('#show-selector option:selected').attr('value');
- sessionStorage.setItem("shows_currentid", shows_currentid);
- shows_current = $.grep(shows_list, function(elem) { return elem.id == shows_currentid; })[0];
-
- if(shows_current) {
- $('#show-title').text(shows_current.title);
- $('#show-dow').text(weekday[shows_current.dow]);
- $('#show-rhythm').text(shows_current.rhythm);
- $('#show-starttime').text(shows_current.starttime);
- $('#show-length').text(shows_current.length + ' Min.');
-
- shows_log_carts = [];
- data = { COMMAND: 22, LOGIN_NAME: auth_username, PASSWORD: auth_token, NAME: shows_current.log };
- lcd = $.post("/rd-bin/rdxport.cgi", data, shows_updateLogCartList, "xml");
-
- shows_group_carts = [];
- data = { COMMAND: 6, LOGIN_NAME: auth_username, PASSWORD: auth_token, GROUP_NAME: shows_current.group.name, INCLUDE_CUTS: 1 };
- gcd = $.post("/rd-bin/rdxport.cgi", data, shows_updateGroupCartList, "xml");
-
- $.when(lcd, gcd).done(
- function(lcres, gcres) {
- if(lcres[1] == 'success' && gcres[1] == 'success') {
- shows_udpateCartListing();
- }
- }
- );
- }
- }
-
- function shows_updateList(data, status, req) {
- shows_list = [];
- $('#show-selector').find('option').remove();
- var dblist = $(data).find("dropboxList");
- var dbs = dblist.children();
- dbs.each(function() {
- type = $(this).find('type').text();
- if(type == 'show') {
- var show = {
- id: $(this).find('showid').text(),
- title: $(this).find('show-title').text(),
- dow: $(this).find('show-dayofweek').text(),
- rhythm: $(this).find('show-rhythm').text(),
- starttime: $(this).find('show-starttime').text(),
- length: $(this).find('show-length').text(),
- group: {
- name: $(this).find('group').text(),
- lowcart: $(this).find('group-low-cart').text(),
- highcart: $(this).find('group-high-cart').text(),
- },
- log: $(this).find('log').text(),
- normlevel: $(this).find('normalization-level').text(),
- trimlevel: $(this).find('autotrim-level').text(),
- }
-
- var name = show.title + ' (' + show.rhythm + ', ' + weekday[show.dow] + ', ' + show.starttime + ', ' + show.length + ' Min.)';
- $('#show-selector').append($('<option>').attr('value',show.id).text(name));
-
- shows_list.push(show);
- }
- }
- );
- $('#show-selector').val(shows_currentid);
- shows_showSelected();
- }
-
- function shows_init() {
- shows_currentid = sessionStorage.getItem("shows_currentid");
- shows_list = [];
- data = { LOGIN_NAME: auth_username, PASSWORD: auth_token };
- $.post("/listdropboxes.cgi", data, shows_updateList, "xml")
- }
-
- function shows_cleanup() {
- sessionStorage.removeItem("shows_currentid");
- delete shows_currentid;
- shows_list = [];
- shows_group_carts = [];
- shows_log_carts = [];
- }
-
-
-
-
- function musicpools_init() {
- }
-
- function musicpools_cleanup() {
- }
-
-
-
-
- var apps_current;
-
- function apps_select(app) {
- switch(app) {
- case "musicpools":
- $('#app-shows').hide();
- $('#nav-btn-shows').removeClass('active');
- $('#app-musicpools').show();
- $('#nav-btn-musicpools').addClass('active');
- musicpools_init();
- break;
- default:
- $('#app-shows').show();
- $('#nav-btn-shows').addClass('active');
- $('#app-musicpools').hide();
- $('#nav-btn-musicpools').removeClass('active');
- apps_current = 'shows';
- shows_init();
- }
- sessionStorage.setItem("apps_current", apps_current);
- }
-
- function apps_init() {
- apps_current = sessionStorage.getItem("apps_current");
- apps_select(apps_current);
- }
-
- function apps_cleanup() {
- shows_cleanup();
- musicpools_cleanup();
-
- sessionStorage.removeItem("apps_current");
- delete apps_current;
- }
-
-
-
-
-
- var auth_username;
- var auth_token;
-
- function auth_loginSuccess(data) {
- if (data.status == 'OK') {
- auth_username = data.username;
- sessionStorage.setItem("auth_username", auth_username);
-
- auth_token = data.token;
- sessionStorage.setItem("auth_token", auth_token);
-
- apps_select('shows');
-
- $('#username-field').html(auth_username);
- $('#loginbox').slideUp();
- $('#mainwindow').fadeIn();
- } else {
- alertbox.error("Fehler beim Login", data.errorstring);
- auth_cleanup();
- }
- }
-
- function auth_loginError(req, status, error) {
- message = req.status + ': ' + error;
- if(req.status == 401) {
- message = "Benutzer und/oder Passwort sind falsch!";
- }
- alertbox.error("Fehler beim Login", message);
- $("#password").val('');
- }
-
- function auth_login()
- {
- $.ajax("/authtoken.json",
- { cache: false,
- username: $("#username").val(),
- password: $("#password").val(),
- dataType: "json",
- error: auth_loginError,
- success: auth_loginSuccess
- });
- }
-
- function auth_logout()
- {
- auth_cleanup();
- apps_cleanup();
-
- $(".alert").alert('close');
- $("#username").val('');
- $("#password").val('');
- $("#mainwindow").fadeOut();
- $('#username-field').html('');
- $('#loginbox').slideDown();
- }
-
- function auth_init() {
- auth_username = sessionStorage.getItem("auth_username");
- auth_token = sessionStorage.getItem("auth_token");
-
- if(auth_token && auth_username) {
- $("#loginbox").hide();
- $('#username-field').html(auth_username);
- } else {
- $("#mainwindow").hide();
- }
- $("#loginform").submit(function(event) { auth_login(); event.preventDefault(); });
- }
-
- function auth_cleanup() {
- sessionStorage.removeItem("auth_username");
- delete auth_username;
- $("#username").val('').focus();
-
- sessionStorage.removeItem("auth_token");
- delete auth_token;
- $("#password").val('');
- }
</script>
+ <script src="/js/auth.js"></script>
+ <script src="/js/apps.js"></script>
+ <script src="/js/shows.js"></script>
+ <script src="/js/musicpools.js"></script>
</head>
<body>
diff --git a/js/apps.js b/js/apps.js
new file mode 100644
index 0000000..c852cd4
--- /dev/null
+++ b/js/apps.js
@@ -0,0 +1,34 @@
+ var apps_current;
+
+ function apps_select(app) {
+ switch(app) {
+ case "musicpools":
+ $('#app-shows').hide();
+ $('#nav-btn-shows').removeClass('active');
+ $('#app-musicpools').show();
+ $('#nav-btn-musicpools').addClass('active');
+ musicpools_init();
+ break;
+ default:
+ $('#app-shows').show();
+ $('#nav-btn-shows').addClass('active');
+ $('#app-musicpools').hide();
+ $('#nav-btn-musicpools').removeClass('active');
+ apps_current = 'shows';
+ shows_init();
+ }
+ sessionStorage.setItem("apps_current", apps_current);
+ }
+
+ function apps_init() {
+ apps_current = sessionStorage.getItem("apps_current");
+ apps_select(apps_current);
+ }
+
+ function apps_cleanup() {
+ shows_cleanup();
+ musicpools_cleanup();
+
+ sessionStorage.removeItem("apps_current");
+ delete apps_current;
+ }
diff --git a/js/auth.js b/js/auth.js
new file mode 100644
index 0000000..30eefb8
--- /dev/null
+++ b/js/auth.js
@@ -0,0 +1,78 @@
+ var auth_username;
+ var auth_token;
+
+ function auth_loginSuccess(data) {
+ if (data.status == 'OK') {
+ auth_username = data.username;
+ sessionStorage.setItem("auth_username", auth_username);
+
+ auth_token = data.token;
+ sessionStorage.setItem("auth_token", auth_token);
+
+ apps_select('shows');
+
+ $('#username-field').html(auth_username);
+ $('#loginbox').slideUp();
+ $('#mainwindow').fadeIn();
+ } else {
+ alertbox.error("Fehler beim Login", data.errorstring);
+ auth_cleanup();
+ }
+ }
+
+ function auth_loginError(req, status, error) {
+ message = req.status + ': ' + error;
+ if(req.status == 401) {
+ message = "Benutzer und/oder Passwort sind falsch!";
+ }
+ alertbox.error("Fehler beim Login", message);
+ $("#password").val('');
+ }
+
+ function auth_login()
+ {
+ $.ajax("/authtoken.json",
+ { cache: false,
+ username: $("#username").val(),
+ password: $("#password").val(),
+ dataType: "json",
+ error: auth_loginError,
+ success: auth_loginSuccess
+ });
+ }
+
+ function auth_logout()
+ {
+ auth_cleanup();
+ apps_cleanup();
+
+ $(".alert").alert('close');
+ $("#username").val('');
+ $("#password").val('');
+ $("#mainwindow").fadeOut();
+ $('#username-field').html('');
+ $('#loginbox').slideDown();
+ }
+
+ function auth_init() {
+ auth_username = sessionStorage.getItem("auth_username");
+ auth_token = sessionStorage.getItem("auth_token");
+
+ if(auth_token && auth_username) {
+ $("#loginbox").hide();
+ $('#username-field').html(auth_username);
+ } else {
+ $("#mainwindow").hide();
+ }
+ $("#loginform").submit(function(event) { auth_login(); event.preventDefault(); });
+ }
+
+ function auth_cleanup() {
+ sessionStorage.removeItem("auth_username");
+ delete auth_username;
+ $("#username").val('').focus();
+
+ sessionStorage.removeItem("auth_token");
+ delete auth_token;
+ $("#password").val('');
+ }
diff --git a/js/musicpools.js b/js/musicpools.js
new file mode 100644
index 0000000..9e9008a
--- /dev/null
+++ b/js/musicpools.js
@@ -0,0 +1,5 @@
+ function musicpools_init() {
+ }
+
+ function musicpools_cleanup() {
+ }
diff --git a/js/shows.js b/js/shows.js
new file mode 100644
index 0000000..47d6d5c
--- /dev/null
+++ b/js/shows.js
@@ -0,0 +1,129 @@
+ var shows_currentid;
+ var shows_list = [];
+ var shows_current;
+ var shows_group_carts = [];
+ var shows_log_carts = [];
+
+ function shows_udpateCartListing() {
+ $('#show-carts tbody').find('tr').remove();
+ $('#show-info-dumper').text(
+ 'Current Show:\n' + JSON.stringify(shows_current, null, ' ') +
+ '\n\nGroup Carts:\n' + JSON.stringify(shows_group_carts, null, ' ') +
+ '\n\nLog Carts:\n' + JSON.stringify(shows_log_carts, null, ' ')
+ );
+
+ }
+
+ function shows_updateGroupCartList(data, status, req) {
+ shows_group_carts = [];
+ $('#show-carts').find('tr:gt(0)').remove();
+ var cartlist = $(data).find("cartList");
+ var carts = cartlist.children();
+ carts.each(function() {
+ var cut = $(this).find("cutList").get(0);
+ cart = {
+ number: $(this).find('number').text(),
+ title: $(this).find('title').text(),
+ length: $(cut).find('length').text(),
+ imported: new Date($(cut).find('originDatetime').text()),
+ playcnt: new Date($(cut).find('playCounter').text()),
+ lastplayed: new Date($(cut).find('lastPlayDatetime').text()),
+ };
+ shows_group_carts.push(cart);
+ }
+ );
+ }
+
+ function shows_updateLogCartList(data, status, req) {
+ shows_log_carts = [];
+ var loglist = $(data).find("logList");
+ var loglines = loglist.children();
+ loglines.each(function() {
+ var number = $(this).find('cartNumber').text();
+ if(number >= shows_current.group.lowcart && number <= shows_current.group.highcart) {
+ shows_log_carts.push(number);
+ }
+ }
+ );
+ }
+
+ function shows_showSelected() {
+ shows_currentid = $('#show-selector option:selected').attr('value');
+ sessionStorage.setItem("shows_currentid", shows_currentid);
+ shows_current = $.grep(shows_list, function(elem) { return elem.id == shows_currentid; })[0];
+
+ if(shows_current) {
+ $('#show-title').text(shows_current.title);
+ $('#show-dow').text(weekday[shows_current.dow]);
+ $('#show-rhythm').text(shows_current.rhythm);
+ $('#show-starttime').text(shows_current.starttime);
+ $('#show-length').text(shows_current.length + ' Min.');
+
+ shows_log_carts = [];
+ data = { COMMAND: 22, LOGIN_NAME: auth_username, PASSWORD: auth_token, NAME: shows_current.log };
+ lcd = $.post("/rd-bin/rdxport.cgi", data, shows_updateLogCartList, "xml");
+
+ shows_group_carts = [];
+ data = { COMMAND: 6, LOGIN_NAME: auth_username, PASSWORD: auth_token, GROUP_NAME: shows_current.group.name, INCLUDE_CUTS: 1 };
+ gcd = $.post("/rd-bin/rdxport.cgi", data, shows_updateGroupCartList, "xml");
+
+ $.when(lcd, gcd).done(
+ function(lcres, gcres) {
+ if(lcres[1] == 'success' && gcres[1] == 'success') {
+ shows_udpateCartListing();
+ }
+ }
+ );
+ }
+ }
+
+ function shows_updateList(data, status, req) {
+ shows_list = [];
+ $('#show-selector').find('option').remove();
+ var dblist = $(data).find("dropboxList");
+ var dbs = dblist.children();
+ dbs.each(function() {
+ type = $(this).find('type').text();
+ if(type == 'show') {
+ var show = {
+ id: $(this).find('showid').text(),
+ title: $(this).find('show-title').text(),
+ dow: $(this).find('show-dayofweek').text(),
+ rhythm: $(this).find('show-rhythm').text(),
+ starttime: $(this).find('show-starttime').text(),
+ length: $(this).find('show-length').text(),
+ group: {
+ name: $(this).find('group').text(),
+ lowcart: $(this).find('group-low-cart').text(),
+ highcart: $(this).find('group-high-cart').text(),
+ },
+ log: $(this).find('log').text(),
+ normlevel: $(this).find('normalization-level').text(),
+ trimlevel: $(this).find('autotrim-level').text(),
+ }
+
+ var name = show.title + ' (' + show.rhythm + ', ' + weekday[show.dow] + ', ' + show.starttime + ', ' + show.length + ' Min.)';
+ $('#show-selector').append($('<option>').attr('value',show.id).text(name));
+
+ shows_list.push(show);
+ }
+ }
+ );
+ $('#show-selector').val(shows_currentid);
+ shows_showSelected();
+ }
+
+ function shows_init() {
+ shows_currentid = sessionStorage.getItem("shows_currentid");
+ shows_list = [];
+ data = { LOGIN_NAME: auth_username, PASSWORD: auth_token };
+ $.post("/listdropboxes.cgi", data, shows_updateList, "xml")
+ }
+
+ function shows_cleanup() {
+ sessionStorage.removeItem("shows_currentid");
+ delete shows_currentid;
+ shows_list = [];
+ shows_group_carts = [];
+ shows_log_carts = [];
+ }