From 7b66bd1c2f7b9c9f06e211a67b16cf935fbb64d2 Mon Sep 17 00:00:00 2001 From: Alib Date: Thu, 18 Mar 2010 23:00:15 +0100 Subject: various optimisation for animation with lot of elements on page. Removed Show All button, useless now. --- js/istreamdev.js | 109 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 68 insertions(+), 41 deletions(-) (limited to 'js') diff --git a/js/istreamdev.js b/js/istreamdev.js index cffc610..b57816a 100644 --- a/js/istreamdev.js +++ b/js/istreamdev.js @@ -89,6 +89,45 @@ function reinitDivs() { } +// Binds +$(document).ready(function(e){ +$('div').bind('pageAnimationEnd', function(event, info){ + if (info.direction == 'in') { + $('li[rel="toggle"]').show(); + } + }) +}); + +// show active sessions +$(document).ready(function(e){ +getRunningSessions(); +}); + +//reinit RunningSessions when going to Home: +$(document).ready(function(e){ +$('#home').bind('pageAnimationStart', function(event, info){ + if (info.direction == 'in') { + getRunningSessions() + } + }) +}); + +//trick to prevent animation bug with object. +$(document).ready(function(e){ +$('#streaming').bind('pageAnimationEnd', function(event, info){ + if (info.direction == 'in') { + var session = $("#streaming").find('span[rel="session"]').text(); + var name = $("#streaming").find('span[rel="name"]').text(); + playvideo(session,name); + } +}) +$('#streaming').bind('pageAnimationStart', function(event, info){ + var session = $("#streaming").find('span[rel="session"]').text(); + if (info.direction == 'out') { + $('#player').html(''); + } + }) +}); // [/GENERIC STUFF] @@ -152,20 +191,8 @@ $('#runningsessions li a').tap(function(event) { return false; }); -// show active sessions -$(document).ready(function(e){ -getRunningSessions(); -}); - -//reinit RunningSessions when going to Home: -$(document).ready(function(e){ -$('#home').bind('pageAnimationStart', function(event, info){ - if (info.direction == 'in') { - getRunningSessions() - } - }) -}); +// Get Active broadcast & encoding sessions function getRunningSessions() { var dataString = "action=getRunningSessions"; $('#home #runningsessions').html(''); @@ -229,7 +256,13 @@ function gen_categories() { dataString, function(data){ $.each(data.categories, function(i,categories){ - $("#cat_menu").append('
  • ' + categories.name + '' + categories.channels + '
  • '); + if ( i > 10 ) { + togglestatus = "toggle"; + } + else { + togglestatus = ""; + } + $("#cat_menu").append('
  • ' + categories.name + '' + categories.channels + '
  • '); }); json_complete('#categories','cube'); }) @@ -244,6 +277,7 @@ function gen_channels(category) { dataString, function(data){ $.each(data.channel,function(i,channel){ + //trick to lower cpu while animating. When the page have too much elements, it flickers. if ( i <= 10 ) { $("#chan_menu").append('
  • ' + channel.number + '' + channel.name + '' + channel.now_title + '
  • '); } @@ -252,9 +286,6 @@ function gen_channels(category) { } }); $('li[rel="toggle"]').hide(); - if ( data.channel.length > 10 ) { - $("#chan_menu").append('
  • Show all
  • '); - } json_complete('#channels','cube'); }) } @@ -429,23 +460,6 @@ function stop_broadcast(session) { }); } -//trick to prevent animation bug with object. -$(document).ready(function(e){ -$('#streaming').bind('pageAnimationEnd', function(event, info){ - if (info.direction == 'in') { - var session = $("#streaming").find('span[rel="session"]').text(); - var name = $("#streaming").find('span[rel="name"]').text(); - playvideo(session,name); - } -}) - -$('#streaming').bind('pageAnimationStart', function(event, info){ - var session = $("#streaming").find('span[rel="session"]').text(); - if (info.direction == 'out') { - $('#player').html(''); - } - }) -}); //Get server status & Play video function playvideo(session,name) { @@ -574,21 +588,28 @@ function gen_browser(path,browser,name,foldertype) { $("#browser" + browser).find('span[rel="path"]').html(path); $("#browser" + browser).find('span[rel="currentbrowser"]').html(browser); $.each(data.list, function(i,list){ + if ( i > 10 ) { + hidetoggle = 'toggle'; + } + else + { + hidetoggle = ''; + } if (list.type == "folder") { - $("#browser" + browser).find('ul').append('
  • ' + list.name + '
  • '); + $("#browser" + browser).find('ul').append('
  • ' + list.name + '
  • '); } else if (list.type == "rec") { - $("#browser" + browser).find('ul').append('
  • ' + list.name + '
  • '); + $("#browser" + browser).find('ul').append('
  • ' + list.name + '
  • '); } else if ( list.type == "video" ) { - $("#browser" + browser).find('ul').append('
  • ' + list.name + '
  • '); + $("#browser" + browser).find('ul').append('
  • ' + list.name + '
  • '); } else if ( list.type == "audio" ) { if ( list.trackname != "" ) { name = list.trackname; } else { name = list.name; } - $("#browser" + browser).find('ul').append('
  • ' + list.number + '
    ' + name + '
    ' + list.length +'
  • '); + $("#browser" + browser).find('ul').append('
  • ' + list.number + '
    ' + name + '
    ' + list.length +'
  • '); } }); json_complete('#browser' + browser,'cube'); @@ -681,15 +702,21 @@ function gen_timers(edit) { function(data) { $('#timers ul[rel="timers"]').append('
  • Current timers
  • '); $.each(data.timer, function(i,timer){ + if ( i > 10 ) { + togglestatus = "toggle"; + } + else { + togglestatus = ""; + } if ( timer.running == "1" ) { - timerli = '
  • ' + timer.date + ' ' + timer.name + '
  • '; + timerli = '
  • ' + timer.date + ' ' + timer.name + '
  • '; } else { if ( timer.active == "1" ) { - timerli = '
  • ' + timer.date + ' ' + timer.name + '
  • '; + timerli = '
  • ' + timer.date + ' ' + timer.name + '
  • '; } else { - timerli = '
  • ' + timer.date + ' ' + timer.name + '
  • '; + timerli = '
  • ' + timer.date + ' ' + timer.name + '
  • '; } } $('#timers ul[rel="timers"]').append(timerli); -- cgit v1.2.3