several fixes for lsp, login save on error, enter button login and refresh viewer stats (#17, 1h)
This commit is contained in:
parent
2325d3be5a
commit
d20729fb64
1 changed files with 177 additions and 66 deletions
243
server.html
243
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(
|
||||
$('<div>').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(
|
||||
$('<div>').attr('id', 'editserver').append(
|
||||
|
@ -689,15 +790,32 @@ td
|
|||
)
|
||||
).append(
|
||||
$('<label>').text('Streams').append(
|
||||
$('<span>').text( numstr + ' of ' + numtotstr + ' online')
|
||||
$('<span>').attr('id', 'cur_streams_online').text('retrieving data...')
|
||||
)
|
||||
).append(
|
||||
$('<label>').text('Viewers').append(
|
||||
$('<span>').text( numvwr )
|
||||
$('<span>').attr('id', 'cur_num_viewers').text('retrieving data...')
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
function showStats()
|
||||
{
|
||||
getStatData(function(data)
|
||||
{
|
||||
console.log('getting live data... @' + new Date().getTime());
|
||||
$('#cur_streams_online').html('').text(data.streams[0] + ' of ' + data.streams[1] + ' online');
|
||||
$('#cur_num_viewers').html('').text(data.viewers);
|
||||
});
|
||||
}
|
||||
|
||||
sinterval = setInterval(function()
|
||||
{
|
||||
showStats();
|
||||
}, 30000);
|
||||
|
||||
// instantly call it the first time
|
||||
showStats();
|
||||
|
||||
|
||||
$('#editserver').append(
|
||||
|
@ -742,13 +860,13 @@ td
|
|||
|
||||
tr.append( $('<td>').attr('class', 'center').append( $('<button>').click(function()
|
||||
{
|
||||
if(confirmDelete('Are you sure you want to delete this protocol?') == true)
|
||||
{
|
||||
var id = $(this).parent().parent().attr('id').replace('protocol-', '');
|
||||
delete settings.settings.config.protocols[protocol];
|
||||
$(this).parent().parent().remove();
|
||||
loadSettings();
|
||||
}
|
||||
if(confirmDelete('Are you sure you want to delete this protocol?') == true)
|
||||
{
|
||||
var id = $(this).parent().parent().attr('id').replace('protocol-', '');
|
||||
delete settings.settings.config.protocols[protocol];
|
||||
$(this).parent().parent().remove();
|
||||
loadSettings();
|
||||
}
|
||||
}).text('delete') ) );
|
||||
|
||||
$tbody.append(tr);
|
||||
|
@ -982,19 +1100,14 @@ if(confirmDelete('Are you sure you want to delete this protocol?') == true)
|
|||
|
||||
|
||||
|
||||
case 'embed':
|
||||
|
||||
case 'embed':
|
||||
// FIXME use server URLs from stream_links.js
|
||||
|
||||
var url = settings.settings.streams[streamname].channel.URL;
|
||||
|
||||
$('#page').append( $('<p>').text('This feature is not yet implemented.') );
|
||||
$('#page').append( $('<p>').text('The URL for this stream is ').append( $('<span>').attr('class', 'nocapitals').text(url) ) );
|
||||
|
||||
|
||||
break;
|
||||
var url = settings.settings.streams[streamname].channel.URL;
|
||||
|
||||
$('#page').append( $('<p>').text('This feature is not yet implemented.') );
|
||||
$('#page').append( $('<p>').text('The URL for this stream is ').append( $('<span>').attr('class', 'nocapitals').text(url) ) );
|
||||
|
||||
break;
|
||||
|
||||
|
||||
|
||||
|
@ -1049,26 +1162,26 @@ case 'embed':
|
|||
|
||||
tr.append( $('<td>').attr('class', 'center').append( $('<button>').click(function()
|
||||
{
|
||||
if(confirmDelete('Are you sure you want to delete this limit?') == true)
|
||||
{
|
||||
var id = $(this).parent().parent().attr('id').replace('limits-', '');
|
||||
var at = $($(this).parent().parent().children()[3]).attr('id');
|
||||
if(confirmDelete('Are you sure you want to delete this limit?') == true)
|
||||
{
|
||||
var id = $(this).parent().parent().attr('id').replace('limits-', '');
|
||||
var at = $($(this).parent().parent().children()[3]).attr('id');
|
||||
|
||||
if(at == undefined)
|
||||
{
|
||||
settings.settings.config.limits.splice(id, 1);
|
||||
}else{
|
||||
var data = at.replace('limit-at-', '').split('-');
|
||||
var loc = data.pop();
|
||||
data = data.join('-');
|
||||
if(at == undefined)
|
||||
{
|
||||
settings.settings.config.limits.splice(id, 1);
|
||||
}else{
|
||||
var data = at.replace('limit-at-', '').split('-');
|
||||
var loc = data.pop();
|
||||
data = data.join('-');
|
||||
|
||||
settings.settings.streams[data].limits.splice(loc, 1);
|
||||
}
|
||||
settings.settings.streams[data].limits.splice(loc, 1);
|
||||
}
|
||||
|
||||
$(this).parent().parent().remove();
|
||||
$(this).parent().parent().remove();
|
||||
|
||||
loadSettings();
|
||||
}
|
||||
loadSettings();
|
||||
}
|
||||
}).text('delete') ) );
|
||||
|
||||
$tbody.append(tr);
|
||||
|
@ -1188,8 +1301,6 @@ if(confirmDelete('Are you sure you want to delete this limit?') == true)
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
case 'disconnect':
|
||||
showTab('login');
|
||||
setHeaderState('disconnected');
|
||||
|
@ -1207,11 +1318,11 @@ if(confirmDelete('Are you sure you want to delete this limit?') == true)
|
|||
settings: {}
|
||||
};
|
||||
break;
|
||||
} // end switch
|
||||
} // end switch :D
|
||||
|
||||
|
||||
//placeholder for older browsers T_T
|
||||
$('input[placeholder]').placeholder();
|
||||
//placeholder for older browsers
|
||||
$('input[placeholder]').placeholder();
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue