From 73ec6bc12e9c0200055578a6e74ddd2bdcb7fe98 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sat, 20 Sep 2014 23:26:44 +0000 Subject: cart listing for shows work now diff --git a/index.html b/index.html index f615b38..98a9043 100644 --- a/index.html +++ b/index.html @@ -26,27 +26,7 @@ - + diff --git a/js/shows.js b/js/shows.js index 0917197..b0cb55b 100644 --- a/js/shows.js +++ b/js/shows.js @@ -1,9 +1,28 @@ var shows_currentid; var shows_list = []; var shows_current; -var shows_group_carts = []; +var shows_group_carts = {}; var shows_log_carts = []; +function shows_deleteCart(cart) { + alert('removing cart: ' + cart); +} + +function shows_importCart(cart) { + alert('removing cart: ' + cart); +} + +// +// +// +// +// +// +// +// +// +// + function shows_udpateCartListing() { $('#show-carts tbody').find('tr').remove(); $('#show-info-dumper').text( @@ -12,23 +31,50 @@ function shows_udpateCartListing() { '\n\nLog Carts:\n' + JSON.stringify(shows_log_carts, null, ' ') ); + shows_log_carts.forEach(function(elem) { + var cart_exists = shows_group_carts[elem] ? 1 : 0; + var cart = {}; + cart.title = cart_exists ? shows_group_carts[elem].title : '-'; + cart.length = cart_exists ? shows_group_carts[elem].length : '-'; + cart.imported = cart_exists ? format_datetime(shows_group_carts[elem].imported) : '-'; + cart.playcnt = cart_exists ? shows_group_carts[elem].playcnt : '-'; + cart.lastplayed = cart_exists ? format_datetime(shows_group_carts[elem].lastplayed) : '-'; + + var buttons = cart_exists ? + '' : + ''; + + $('#show-carts > tbody:last').append( + $('').append($('').text(elem)) + .append($('').text(cart.title)) + .append($('').text(cart.length)) + .append($('').text(cart.imported)) + .append($('').text(cart.playcnt)) + .append($('').text(cart.lastplayed)) + .append($('').append(buttons)) + ); + }); } function shows_updateGroupCartList(data, status, req) { - shows_group_carts = []; + shows_group_carts = {}; var cartlist = $(data).find("cartList"); var carts = cartlist.children(); carts.each(function() { var cut = $(this).find("cutList").get(0); + number = $(this).find('number').text(), 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()), + playcnt: $(cut).find('playCounter').text(), lastplayed: new Date($(cut).find('lastPlayDatetime').text()), }; - shows_group_carts.push(cart); + cart.imported = isNaN(cart.imported) ? '-' : cart.imported; + cart.lastplayed = isNaN(cart.lastplayed) ? '-' : cart.lastplayed; + shows_group_carts[number] = cart; } ); } @@ -62,7 +108,7 @@ function shows_showSelected() { 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 = []; + 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"); @@ -123,6 +169,6 @@ function shows_cleanup() { sessionStorage.removeItem("shows_currentid"); delete shows_currentid; shows_list = []; - shows_group_carts = []; + shows_group_carts = {}; shows_log_carts = []; } diff --git a/js/utils.js b/js/utils.js new file mode 100644 index 0000000..4d7d0d6 --- /dev/null +++ b/js/utils.js @@ -0,0 +1,34 @@ +alertbox = function() {} +alertbox.warning = function (heading, message) { + $('#alertbox').html('
×

' + heading + '

' + message + '
'); +} +alertbox.error = function (heading, message) { + $('#alertbox').html('
×

' + heading + '

' + message + '
'); +} +alertbox.info = function (heading, message) { + $('#alertbox').html('
×

' + heading + '

' + message + '
'); +} + +var weekday = new Array(7); +weekday[0] = "Sonntag"; +weekday[1] = "Montag"; +weekday[2] = "Dienstag"; +weekday[3] = "Mittwoch"; +weekday[4] = "Donnerstag"; +weekday[5] = "Freitag"; +weekday[6] = "Samstag"; + +function format_datetime(d) { + if(Object.prototype.toString.call(d) === "[object Date]") { + var daynames = new Array('So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'); + var datetimestr = daynames[d.getDay()]; + datetimestr += ' ' + d.getDate(); + datetimestr += '.' + (d.getMonth() + 1); + datetimestr += '.' + d.getFullYear(); + datetimestr += (d.getHours() > 9 ? ' ' : ' 0') + d.getHours(); + datetimestr += (d.getMinutes() > 9 ? ':' : ':0') + d.getMinutes(); + datetimestr += (d.getSeconds() > 9 ? ':' : ':0') + d.getSeconds(); + return datetimestr; + } + return d; +} -- cgit v0.10.2