From c807e3f3618861c06aa7f5c43b595e0881775a26 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sat, 20 Sep 2014 04:04:00 +0000 Subject: refactoring diff --git a/index.html b/index.html index 8e75c5a..4f86282 100644 --- a/index.html +++ b/index.html @@ -53,24 +53,25 @@ + var shows_currentid; var shows_list = []; - var current_show; - var group_carts = []; - var log_carts = []; + var shows_current; + var shows_group_carts = []; + var shows_log_carts = []; - function updateShowListing() { + function shows_udpateCartListing() { $('#show-carts tbody').find('tr').remove(); $('#show-info-dumper').text( - 'Current Show:\n' + JSON.stringify(current_show, null, ' ') + - '\n\nGroup Carts:\n' + JSON.stringify(group_carts, null, ' ') + - '\n\nLog Carts:\n' + JSON.stringify(log_carts, null, ' ') + '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 updateGroupCartList(data, status, req) { - group_carts = []; + 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(); @@ -84,53 +85,53 @@ playcnt: new Date($(cut).find('playCounter').text()), lastplayed: new Date($(cut).find('lastPlayDatetime').text()), }; - group_carts.push(cart); + shows_group_carts.push(cart); } ); } - function updateLogCartList(data, status, req) { - log_carts = []; + 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 >= current_show.group.lowcart && number <= current_show.group.highcart) { - log_carts.push(number); + if(number >= shows_current.group.lowcart && number <= shows_current.group.highcart) { + shows_log_carts.push(number); } } ); } - function showSelectedShow() { + function shows_showSelected() { shows_currentid = $('#show-selector option:selected').attr('value'); sessionStorage.setItem("shows_currentid", shows_currentid); - current_show = $.grep(shows_list, function(elem) { return elem.id == shows_currentid; })[0]; - $('#show-title').text(current_show.title); - $('#show-dow').text(weekday[current_show.dow]); - $('#show-rhythm').text(current_show.rhythm); - $('#show-starttime').text(current_show.starttime); - $('#show-length').text(current_show.length + ' Min.'); + shows_current = $.grep(shows_list, function(elem) { return elem.id == shows_currentid; })[0]; + + $('#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.'); - log_carts = []; - data = { COMMAND: 22, LOGIN_NAME: username, PASSWORD: token, NAME: current_show.log }; - lcd = $.post("/rd-bin/rdxport.cgi", data, updateLogCartList, "xml"); + shows_log_carts = []; + data = { COMMAND: 22, LOGIN_NAME: username, PASSWORD: token, NAME: shows_current.log }; + lcd = $.post("/rd-bin/rdxport.cgi", data, shows_updateLogCartList, "xml"); - group_carts = []; - data = { COMMAND: 6, LOGIN_NAME: username, PASSWORD: token, GROUP_NAME: current_show.group.name, INCLUDE_CUTS: 1 }; - gcd = $.post("/rd-bin/rdxport.cgi", data, updateGroupCartList, "xml"); + shows_group_carts = []; + data = { COMMAND: 6, LOGIN_NAME: username, PASSWORD: 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') { - updateShowListing(); + shows_udpateCartListing(); } } ); } - - function updateShowsList(data, status, req) { + function shows_updateList(data, status, req) { shows_list = []; $('#show-selector').find('option').remove(); var dblist = $(data).find("dropboxList"); @@ -163,14 +164,14 @@ } ); $('#show-selector').val(shows_currentid); - showSelectedShow(); + shows_showSelected(); } function shows_init() { shows_currentid = sessionStorage.getItem("shows_currentid"); shows_list = []; data = { LOGIN_NAME: username, PASSWORD: token }; - $.post("/listdropboxes.cgi", data, updateShowsList, "xml") + $.post("/listdropboxes.cgi", data, shows_updateList, "xml") } function shows_cleanup() { @@ -179,8 +180,7 @@ } - - function selectApp(app) { + function apps_select(app) { switch(app) { case "musicpools": $('#app-shows').hide(); @@ -199,6 +199,9 @@ sessionStorage.setItem("app", app); } + + + function authSuccess(data) { if (data.status == 'OK') { username = data.username; @@ -207,7 +210,7 @@ token = data.token; sessionStorage.setItem("token", token); - selectApp('shows'); + apps_select('shows'); $('#username-field').html(username); $('#loginbox').slideUp(); @@ -300,8 +303,8 @@ Radio Helsinki - Import