summaryrefslogtreecommitdiff
path: root/www/js
diff options
context:
space:
mode:
authorPeter Grassberger <petertheone@gmail.com>2015-08-09 16:39:55 (GMT)
committerPeter Grassberger <petertheone@gmail.com>2015-08-09 16:39:55 (GMT)
commite1dc9d23da796d5a83d32c94a8320167a15eb8ec (patch)
treeb73a2be0e55445168ebe97415c4e8d4e9adf71b1 /www/js
parent8e34dfc158906ad1ddf5810b8d0a88be6b7ffb1f (diff)
add basic jingles listing
Diffstat (limited to 'www/js')
-rw-r--r--www/js/jingles.js89
-rw-r--r--www/js/shows.js8
2 files changed, 80 insertions, 17 deletions
diff --git a/www/js/jingles.js b/www/js/jingles.js
index c936c36..5037382 100644
--- a/www/js/jingles.js
+++ b/www/js/jingles.js
@@ -19,10 +19,78 @@
* along with rhwebimport. If not, see <http://www.gnu.org/licenses/>.
*/
-jingle_groups_list = [];
+var jingles_group_list = [];
+var jingles_group_carts = {};
+
+function jingles_newCartEntry(cart) {
+
+ return $('<tr>').append($('<td>').text(cart.number))
+ .append($('<td>').text(cart.title))
+ .append($('<td>'))//.text(msToTimeString(cart.length)))
+ .append($('<td>'))//.text(cart.imported))
+ .append($('<td>'))//.text(cart.playcnt))
+ .append($('<td>'))//.text(cart.lastplayed))
+ .append($('<td>'));//.css('text-align', 'center').append(buttons))
+ //.attr("id", "show-cart-" + elem);
+}
+
+function jingles_updateCartListing() {
+ $('#jingle-carts-left tbody').find('tr').remove();
+ $.each(jingles_group_carts, function(cart) {
+ $('#jingle-carts-left > tbody:last').append(jingles_newCartEntry(cart));
+ });
+}
+
+function jingles_updateGroupCartList(data, status, req) {
+ var cartlist = $(data).find("cartList");
+ var carts = cartlist.children();
+ carts.each(function() {
+ var cut = $(this).find("cutList").get(0);
+ var number = $(this).find('number').text();
+ var cart = {
+ title: $(this).find('title').text(),
+ //length: Number($(cut).find('length').text()),
+ //imported: new Date($(cut).find('originDatetime').text()),
+ //playcnt: $(cut).find('playCounter').text(),
+ //lastplayed: new Date($(cut).find('lastPlayDatetime').text()),
+ };
+ //cart.imported = isNaN(cart.imported) ? '-' : cart.imported;
+ //cart.lastplayed = isNaN(cart.lastplayed) ? '-' : cart.lastplayed;
+ jingles_group_carts[number] = cart;
+ }
+ );
+ jingles_updateCartListing();
+}
+
+function jingles_show() {
+ jingAllgem = $.grep(jingles_group_list, function(elem) {
+ return elem.group.name == 'jingAllgem';
+ })[0];
+ jingAnlass = $.grep(jingles_group_list, function(elem) {
+ return elem.group.name == 'jingAnlass';
+ })[0];
+
+ if(jingAllgem) {
+ $('#jingle-title-left').text(jingAllgem.title);
+
+ jingles_group_carts = {};
+ data = { COMMAND: 7, LOGIN_NAME: auth_username, PASSWORD: auth_token, CART_NUMBER: jingAllgem.group.lowcart, INCLUDE_CUTS: 1 };
+ gcd = $.post("/rd-bin/rdxport.cgi", data, jingles_updateGroupCartList, "xml");
+ }
+
+ if(jingAnlass) {
+ $('#jingle-title-right').text(jingAnlass.title);
+
+ jingles_group_carts = {};
+ data = { COMMAND: 7, LOGIN_NAME: auth_username, PASSWORD: auth_token, CART_NUMBER: jingAnlass.group.lowcart, INCLUDE_CUTS: 1 };
+ gcd = $.post("/rd-bin/rdxport.cgi", data, jingles_updateGroupCartList, "xml");
+ }
+
+
+}
function jingle_groups_updateList(data, status, req) {
- jingle_groups_list = [];
+ jingles_group_list = [];
$('#jingle-selector').find('option').remove();
var dblist = $(data).find("dropboxList");
var dbs = dblist.children();
@@ -44,27 +112,22 @@ function jingle_groups_updateList(data, status, req) {
var name = jingle_group.title;
$('#jingle-selector').append($('<option>').attr('value', jingle_group.id).text(name));
- jingle_groups_list.push(jingle_group);
+ jingles_group_list.push(jingle_group);
}
});
- console.log(jingle_groups_list);
- //$('#jingle-selector').val(jingles_currentid);
- //shows_showSelected();
+ jingles_show();
}
function jingles_init() {
- //jingles_currentid = sessionStorage.getItem("jingles_currentid");
- jingle_groups_list = [];
+ jingles_group_list = [];
+ jingles_group_carts = {};
data = { LOGIN_NAME: auth_username, PASSWORD: auth_token };
$.post("/rh-bin/listdropboxes.cgi", data, jingle_groups_updateList, "xml");
- drawClock('Do, 1.1.1970', '00:00:00', 0);
- clock_add_callback(drawClock);
}
function jingles_cleanup() {
sessionStorage.removeItem("jingles_currentid");
delete jingles_currentid;
- jingle_groups_list = [];
- //jingles_group_carts = {};
- //jingles_log_carts = [];
+ jingles_group_list = [];
+ jingles_group_carts = {};
}
diff --git a/www/js/shows.js b/www/js/shows.js
index 5fd306c..f3e6105 100644
--- a/www/js/shows.js
+++ b/www/js/shows.js
@@ -216,7 +216,7 @@ function shows_redrawCartEntry(cart) {
$('#show-cart-' + cart).replaceWith(shows_newCartEntry(cart));
}
-function shows_udpateCartListing() {
+function shows_updateCartListing() {
$('#show-carts tbody').find('tr').remove();
shows_log_carts.forEach(function(elem) {
$('#show-carts > tbody:last').append(shows_newCartEntry(elem));
@@ -228,8 +228,8 @@ function shows_updateGroupCartList(data, status, req) {
var carts = cartlist.children();
carts.each(function() {
var cut = $(this).find("cutList").get(0);
- number = $(this).find('number').text(),
- cart = {
+ var number = $(this).find('number').text();
+ var cart = {
title: $(this).find('title').text(),
length: Number($(cut).find('length').text()),
imported: new Date($(cut).find('originDatetime').text()),
@@ -278,7 +278,7 @@ function shows_showSelected() {
$.when(lcd, gcd).done(
function(lcres, gcres) {
if(lcres[1] == 'success' && gcres[1] == 'success') {
- shows_udpateCartListing();
+ shows_updateCartListing();
}
}
);