From 33b554b18a52991dff6d095158002aee8290e1b0 Mon Sep 17 00:00:00 2001 From: Alib Date: Thu, 25 Mar 2010 15:53:12 +0100 Subject: epg works --- js/istreamdev.js | 115 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 71 insertions(+), 44 deletions(-) (limited to 'js/istreamdev.js') diff --git a/js/istreamdev.js b/js/istreamdev.js index 565ae69..5307b28 100644 --- a/js/istreamdev.js +++ b/js/istreamdev.js @@ -966,7 +966,7 @@ function showStatus( timeout, message ) { // [/TIMER SECTION] // [EPG SECTION] -//buttons +//buttons & events $('.submit_epg').tap(function(event) { event.preventDefault(); json_start(this); @@ -992,6 +992,7 @@ get_epg("all","now","0","2"); }); + //functions function gen_epgmenu() { gen_epgchanlist(); @@ -1032,59 +1033,85 @@ var dayname = new Array( "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ); } function get_epg(channel,time,day,programs) { -$('#epglist #ul_epglist').html(''); var dataString = 'action=getEpg&channel=' + channel + '&time=' + time + '&day=' + day + '&programs=' + programs; $.getJSON("bin/backend.php", dataString, function(data) { $('#jqt').data("epg",data); - $('#epglist #epg_selector').html(''); - if ( data.category.length > 1 ) - { - $('#epglist #epg_selector').append(''); - $.each(data.category, function(i,category){ - $('#epglist #epg_selector #epglist_cat').append(''); - }); + if ( data.category.length > 1 ) { + type = 'cat'; + } else { + type = 'chan'; } - else { - $('#epglist #epg_selector').append(''); - data = $('#jqt').data('channellist'); - $.each(data.category, function(i,category){ - $('#epglist #epg_selector #epglist_chan').append(''); - var catname = category.name; - $.each(category.channel, function(j, channel){ - $('#epglist #epg_selector #epglist_chan optgroup[label="' + catname +'"]').append(''); - }); - $('#epg_chan').append(''); + parse_epg(data,0,type); + $('#epglist li[rel="toggle"]').hide(); + json_complete('#epglist','cube'); + }); +} + +function parse_epg(data,selectedvalue,type){ + $('#epglist #epg_selector').html(''); + $('#epglist #ul_epglist').html(''); + if ( data.category.length > 1 ) + { + $('#epglist #epg_selector').append(''); + $.each(data.category, function(i,category){ + $('#epglist #epg_selector #epglist_cat').append(''); }); - } - var k=1; - $.each(data.category[0].channel, function(i,channel){ - if ( k > 10 ) { - togglestatus = 'toggle'; - } - else - { - togglestatus = ''; - } + $('#epglist #epg_selector select option[value=' + selectedvalue + ']').attr("selected", "selected"); + } + else { + $('#epglist #epg_selector').append(''); + data = $('#jqt').data('channellist'); + $.each(data.category, function(i,category){ + $('#epglist #epg_selector #epglist_chan').append(''); + var catname = category.name; + $.each(category.channel, function(j, channel){ + $('#epglist #epg_selector #epglist_chan optgroup[label="' + catname +'"]').append(''); + }); + $('#epg_chan').append(''); + }); + $('#epglist #epg_selector select option[value=' + selectedvalue + ']').attr("selected", "selected"); + } + var k=1; + if ( type == "cat" ) { + arrayvalue = selectedvalue; + } else { + arrayvalue = 0; + } + $.each(data.category[arrayvalue].channel, function(i,channel){ + if ( k > 10 ) { + togglestatus = 'toggle'; + } + else + { + togglestatus = ''; + } + k++; + $('#epglist #ul_epglist').append('
  • ' + channel.name + '
  • '); + $.each(channel.epg, function(j,epg){ + if ( k > 10 ) { + togglestatus = 'toggle'; + } + else + { + togglestatus = ''; + } + $('#epglist #ul_epglist').append('
  • ' + epg.time + '' + epg.title + '
  • '); + k++; - $('#epglist #ul_epglist').append('
  • ' + channel.name + '
  • '); - $.each(channel.epg, function(j,epg){ - if ( k > 10 ) { - togglestatus = 'toggle'; - } - else - { - togglestatus = ''; - } - $('#epglist #ul_epglist').append('
  • ' + epg.time + '' + epg.title + '
  • '); - - k++; - }); }); - $('#epglist li[rel="toggle"]').hide(); - json_complete('#epglist','cube'); }); +$("#epglist #epg_selector select").change(function () { +epgdata = $('#jqt').data("epg"); +selectedvalue = $("#epglist #epg_selector select option:selected").val(); +if ($("#epglist #epg_selector select").attr("id") == 'epglist_cat') { +type = 'cat'; +} else { +type = 'chan'; +} +parse_epg(epgdata,selectedvalue,type); +}); } // [/EPG SECTION] -- cgit v1.2.3