From d20729fb64ef3ee163e7a347f049ffbb673fa30d Mon Sep 17 00:00:00 2001 From: That-Guy Date: Sat, 21 Apr 2012 11:25:25 +0200 Subject: [PATCH] several fixes for lsp, login save on error, enter button login and refresh viewer stats (#17, 1h) --- server.html | 243 ++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 177 insertions(+), 66 deletions(-) diff --git a/server.html b/server.html index d37a5be2..caf5792f 100644 --- a/server.html +++ b/server.html @@ -460,7 +460,7 @@ td if(protocol === null || (protocol[1] && protocol[1] === 'file')) { - return 'VoD'; + return 'Recorded'; }else{ return 'Live'; } @@ -486,6 +486,96 @@ td } + function getData(callback) + { + // this beast returns the server settings, but doesn't authorize first, + // nor does it save the retrieved data. + var data = + { + 'authorize': + { + 'username': settings.credentials.username, + 'password': MD5(MD5(settings.credentials.password) + settings.credentials.authstring) + } + }; + + $.ajax( + { + 'url': settings.server, + 'data': + { + "command": JSON.stringify(data) + }, + 'dataType': 'jsonp', + 'timeout': 2500, + 'error': function() + { + console.log('ERROR ERROR ERROR @514'); + }, + 'success': function(d) + { + var ret = $.extend(true, + { + "config": + { + "host": "", + "limits": [], + "name": "", + "protocols": {}, + "status": "", + "version": "" + }, + "streams": {}, + "log": {}, + "statistics": {} + }, d); + + if(callback) + { + callback(ret); + } + } + }); + } + + + function getStatData(callback) + { + getData(function(data) + { + console.log('getStatData: real data retrieved: ', data); + var svr, viewer, ret, + numstr = 0, + numvwr = 0, + numtotstr = 0; + + for(svr in data.statistics) + { + if(data.statistics[svr].curr) + { + for(viewer in data.statistics[svr].curr) + { + numvwr++; + } + } + } + + for(svr in data.streams) + { + numtotstr++; + + if(data.streams[svr].online && data.streams[svr].online == 1) + { + numstr++; + } + } + + ret = {streams: [numtotstr, numstr], viewers: numvwr}; + callback(ret); + }); + } + + // connect to server and set/get settings function loadSettings(callback) { @@ -579,6 +669,9 @@ td + // used on the overview page. clear when not on that page in showTab() + var sinterval = null; + // show tab @@ -586,6 +679,7 @@ td { // clear page $('#page').html(''); + clearInterval(sinterval); switch(name) { @@ -601,6 +695,9 @@ td settings.credentials.password = pass.val(); settings.server = host.val() || host.attr('placeholder'); + // save username, URL in address + location.hash = user.val() + '@' + host.val(); + // try to login setHeaderState('logingin'); @@ -637,6 +734,35 @@ td $('#page').append( $('
').attr('id', 'login').append(host).append(user).append(pass).append(conn) ); + + // btw: if we 'enter' in host, user or pass we should try to login. + function hand(e) + { + if(e.keyCode == 13) + { + conn.trigger('click'); // conn = login button :) + } + } + + host.keypress(hand); + user.keypress(hand); + pass.keypress(hand); + + + + // retrieve address hash stuff + var adr = location.hash.replace('#', '').split('@'); + + if(adr.length == 2) + { + console.log(adr[0], adr[1]); + } + + // put it in the page + host.val(adr[1]); + user.val(adr[0]); + + break; @@ -644,31 +770,6 @@ td case 'overview': - var svr, viewer, - numstr = 0, - numvwr = 0, - numtotstr = 0; - - for(svr in settings.settings.statistics) - { - if(settings.settings.statistics[svr].curr) - { - for(viewer in settings.settings.statistics[svr].curr) - { - numvwr++; - } - } - } - - for(svr in settings.settings.streams) - { - numtotstr++; - - if(settings.settings.streams[svr].online && settings.settings.streams[svr].online == 1) - { - numstr++; - } - } $('#page').append( $('
').attr('id', 'editserver').append( @@ -689,15 +790,32 @@ td ) ).append( $('