/* * rhwebimport * * Copyright (C) 2014-2015 Christian Pointner * * This file is part of rhwebimport. * * rhwebimport is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * rhwebimport is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with rhwebimport. If not, see . */ var jingles_group_list = []; var jingles_group_carts = {}; function jingles_newCartEntry(cut) { return $('').append($('').text(cut.name)) .append($('').text(cut.title)) .append($(''))//.text(msToTimeString(cart.length))) .append($(''))//.text(cart.imported)) .append($(''))//.text(cart.playcnt)) .append($(''))//.text(cart.lastplayed)) .append($(''));//.css('text-align', 'center').append(buttons)) //.attr("id", "show-cart-" + elem); } function jingles_updateCartListing() { $('#jingles-jingAllgem table tbody').find('tr').remove(); $('#jingles-jingAnlass table tbody').find('tr').remove(); $.each(jingles_group_carts, function(key, cart) { console.log(cart); if (cart.group.name === 'jingAllgem') { $.each(cart.cutList, function(key, cut) { $('#jingles-jingAllgem table > tbody:last').append(jingles_newCartEntry(cut)); }); } else if (cart.group.name === 'jingAnlass') { $.each(cart.cutList, function(key, cut) { $('#jingles-jingAnlass table > tbody:last').append(jingles_newCartEntry(cut)); }); } }); } function jingles_updateGroupCartList(data, status, req) { var cartlist = $(data).find("cartList"); var carts = cartlist.children(); carts.each(function() { var number = $(this).find('number').text(); var cart = { title: $(this).find('title').text(), group: { name: $(this).find('groupName').text(), }, cutList: [], //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()), }; var cutList = $(this).find("cutList"); cutList.each(function() { cart.cutList.push({ name: $(this).find('cutName').text(), title: $(this).find('description').text(), }); }); //cart.imported = isNaN(cart.imported) ? '-' : cart.imported; //cart.lastplayed = isNaN(cart.lastplayed) ? '-' : cart.lastplayed; jingles_group_carts[number] = cart; } ); console.log(jingles_group_carts); 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) { $('#jingles-jingAllgem h2').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) { $('#jingles-jingAnlass h2').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) { jingles_group_list = []; $('#jingle-selector').find('option').remove(); var dblist = $(data).find("dropboxList"); var dbs = dblist.children(); dbs.each(function() { type = $(this).find('type').text(); if (type == 'jingle') { var jingle_group = { title: $(this).find('jingle-title').text(), group: { name: $(this).find('group').text(), description: $(this).find('group-description').text(), lowcart: $(this).find('group-low-cart').text(), highcart: $(this).find('group-high-cart').text(), }, normlevel: $(this).find('normalization-level').text(), trimlevel: $(this).find('autotrim-level').text(), }; var name = jingle_group.title; $('#jingle-selector').append($('