summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2014-09-20 23:26:44 (GMT)
committerChristian Pointner <equinox@helsinki.at>2014-09-20 23:26:44 (GMT)
commit73ec6bc12e9c0200055578a6e74ddd2bdcb7fe98 (patch)
tree60129ab5d95b52c34f5ba887b5cad5ddc12ecc4c
parentc11a050167845523696d09fa1fb7c138fed489d8 (diff)
cart listing for shows work now
-rw-r--r--index.html22
-rw-r--r--js/shows.js60
-rw-r--r--js/utils.js34
3 files changed, 88 insertions, 28 deletions
diff --git a/index.html b/index.html
index f615b38..98a9043 100644
--- a/index.html
+++ b/index.html
@@ -26,27 +26,7 @@
<script src="/javascript/jquery/jquery.min.js"></script>
<script src="/javascript/twitter-bootstrap/js/bootstrap.min.js"></script>
<script src="/javascript/twitter-bootstrap/js/bootstrap-alert.min.js"></script>
- <script type="text/javascript">
- alertbox = function() {}
- alertbox.warning = function (heading, message) {
- $('#alertbox').html('<div class="alert"><a class="close" data-dismiss="alert" href="#">&times;</a><h4 class="alert-heading">' + heading + '</h4>' + message + '</div>');
- }
- alertbox.error = function (heading, message) {
- $('#alertbox').html('<div class="alert alert-error"><a class="close" data-dismiss="alert" href="#">&times;</a><h4 class="alert-heading">' + heading + '</h4>' + message + '</div>');
- }
- alertbox.info = function (heading, message) {
- $('#alertbox').html('<div class="alert alert-info"><a class="close" data-dismiss="alert" href="#">&times;</a><h4 class="alert-heading">' + heading + '</h4>' + message + '</div>');
- }
-
- 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";
- </script>
+ <script src="/js/utils.js"></script>
<script src="/js/auth.js"></script>
<script src="/js/apps.js"></script>
<script src="/js/shows.js"></script>
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);
+}
+
+// <td>
+// <button class="btn btn-info btn-mini disabled"><i class="icon-arrow-up icon-white"></i></button>
+// <button class="btn btn-info btn-mini disabled"><i class="icon-arrow-down icon-white"></i></button>
+// <button class="btn btn-danger btn-mini"><i class="icon-trash icon-white"></i> Löschen</button>
+// </td>
+// <td>
+// <button class="btn btn-info btn-mini"><i class="icon-arrow-up icon-white"></i></button>
+// <button class="btn btn-info btn-mini disabled"><i class="icon-arrow-down icon-white"></i></button>
+// <button class="btn btn-success btn-mini"><i class="icon-upload icon-white"></i> Importieren</button>
+// </td>
+
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 ?
+ '<button class="btn btn-danger btn-mini" onclick="shows_deleteCart(' + elem + ');">' +
+ '<i class="icon-trash icon-white"></i> Löschen</button>' :
+ '<button class="btn btn-success btn-mini" onclick="shows_importCart(' + elem + ');">' +
+ '<i class="icon-upload icon-white"></i> Importieren</button>';
+
+ $('#show-carts > tbody:last').append(
+ $('<tr>').append($('<td>').text(elem))
+ .append($('<td>').text(cart.title))
+ .append($('<td>').text(cart.length))
+ .append($('<td>').text(cart.imported))
+ .append($('<td>').text(cart.playcnt))
+ .append($('<td>').text(cart.lastplayed))
+ .append($('<td>').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('<div class="alert"><a class="close" data-dismiss="alert" href="#">&times;</a><h4 class="alert-heading">' + heading + '</h4>' + message + '</div>');
+}
+alertbox.error = function (heading, message) {
+ $('#alertbox').html('<div class="alert alert-error"><a class="close" data-dismiss="alert" href="#">&times;</a><h4 class="alert-heading">' + heading + '</h4>' + message + '</div>');
+}
+alertbox.info = function (heading, message) {
+ $('#alertbox').html('<div class="alert alert-info"><a class="close" data-dismiss="alert" href="#">&times;</a><h4 class="alert-heading">' + heading + '</h4>' + message + '</div>');
+}
+
+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;
+}