Splitted filler functions, added protocol settings (#17, 1h, +1h)
This commit is contained in:
parent
5afb962165
commit
050152b7b9
1 changed files with 123 additions and 35 deletions
142
server.html
142
server.html
|
@ -94,18 +94,18 @@
|
|||
|
||||
</div>
|
||||
|
||||
<p>
|
||||
new limit: <select id='new-limit-name'>
|
||||
<option value='kb_total'>kb_total</option>
|
||||
<option value='kbps_max'>kbps_max</option>
|
||||
<option value='users'>users</option>
|
||||
<option value='streams'>streams</option>
|
||||
<option value='geo'>geo</option>
|
||||
<option value='host'>host</option>
|
||||
<option value='time'>time</option>
|
||||
<option value='duration'>duration</option>
|
||||
<option value='str_kbps_min'>str_kbps_min</option>
|
||||
<option value='str_kbps_max'>str_kbps_max</option>
|
||||
|
||||
<option value='kb_total'>Total bandwidth</option>
|
||||
<option value='kbps_max'>Current bandwidth</option>
|
||||
<option value='users'>Concurrent users</option>
|
||||
<option value='streams'>Concurrent streams</option>
|
||||
<option value='geo'>Geolimited</option>
|
||||
<option value='host'>Hostlimited</option>
|
||||
<option value='time'>Time limited</option>
|
||||
<option value='duration'>Duration</option>
|
||||
<option value='str_kbps_min'>Minimum bitrate</option>
|
||||
<option value='str_kbps_max'>Maximum bitrate</option>
|
||||
</select>
|
||||
|
||||
<select id='new-limit-type'>
|
||||
|
@ -116,6 +116,8 @@
|
|||
<input type='text' id='new-limit-val' />
|
||||
|
||||
<button id='new-limit-build'>add</button>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -123,8 +125,19 @@
|
|||
|
||||
<h2>Protocols</h2>
|
||||
|
||||
<ul id='protocol-list'>
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
Not in wiki?
|
||||
new protocol: <select id='new-protocol-name'>
|
||||
<option value='HTTP'>HTTP</option>
|
||||
<option value='RTMP'>RTMP</option>
|
||||
</select>
|
||||
|
||||
port: <input type='text' id='new-protocol-port' />
|
||||
|
||||
<button id='new-protocol-build'>add</button>
|
||||
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
@ -134,9 +147,8 @@
|
|||
|
||||
<h2>Streams</h2>
|
||||
|
||||
<p>
|
||||
TODO: streams (or not?)
|
||||
</p>
|
||||
<ul id='streams-list'>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
|
@ -251,19 +263,19 @@
|
|||
$('#save-config-host').click(function()
|
||||
{
|
||||
settings.settings.config.host = $('#config-host').val();
|
||||
loadSettings(fillHTML);
|
||||
loadSettings(fillConfig);
|
||||
});
|
||||
|
||||
$('#save-config-name').click(function()
|
||||
{
|
||||
settings.settings.config.name = $('#config-name').val();
|
||||
loadSettings(fillHTML);
|
||||
loadSettings(fillConfig);
|
||||
});
|
||||
|
||||
$('#config-status-disable').click(function()
|
||||
{
|
||||
settings.settings.config.status = 'DISABLED';
|
||||
loadSettings(fillHTML);
|
||||
loadSettings(fillConfig);
|
||||
});
|
||||
|
||||
$('#new-limit-build').click(function()
|
||||
|
@ -274,7 +286,22 @@
|
|||
type: $('#new-limit-type option:selected').val(),
|
||||
val: $('#new-limit-val').val()
|
||||
});
|
||||
loadSettings(fillHTML);
|
||||
|
||||
$('#new-limit-val').val('');
|
||||
|
||||
loadSettings(fillLimits);
|
||||
});
|
||||
|
||||
$('#new-protocol-build').click(function()
|
||||
{
|
||||
var prot = $('#new-protocol-name option:selected').val(),
|
||||
port = $('#new-protocol-port').val();
|
||||
|
||||
settings.settings.config.protocols[prot] = {"port": port};
|
||||
|
||||
$('#new-protocol-port').val('');
|
||||
|
||||
loadSettings(fillProtocols);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -282,6 +309,22 @@
|
|||
|
||||
|
||||
function fillHTML()
|
||||
{
|
||||
//fill config
|
||||
fillConfig();
|
||||
|
||||
// limits
|
||||
fillLimits();
|
||||
|
||||
// protocols
|
||||
fillProtocols();
|
||||
|
||||
// streams
|
||||
fillStreams();
|
||||
}
|
||||
|
||||
|
||||
function fillConfig()
|
||||
{
|
||||
$('#config-host').val(settings.settings.config.host);
|
||||
$('#config-name').val(settings.settings.config.name);
|
||||
|
@ -290,10 +333,14 @@
|
|||
$('#config-time').text('time: ' + new Date(settings.settings.config.time).toUTCString() || '');
|
||||
|
||||
$('#config-status').text('status: ' + (settings.settings.config.status || ''));
|
||||
}
|
||||
|
||||
var i, cur, lim, del, sfrom, len = settings.settings.config.limits.length;
|
||||
|
||||
// delete prev items
|
||||
function fillLimits()
|
||||
{
|
||||
var i, cur, lim, del,
|
||||
len = settings.settings.config.limits.length;
|
||||
|
||||
$('#limits-list').html('');
|
||||
|
||||
for(i = 0; i < len; i++)
|
||||
|
@ -302,15 +349,11 @@
|
|||
lim = settings.settings.config.limits[i];
|
||||
del = $('<span>').click(function()
|
||||
{
|
||||
//console.log(settings.settings.config.limits);
|
||||
//console.log('slice(', $(this).parent().attr('id').replace('limits-', ''), ',1)', settings.settings.config.limits);
|
||||
sfrom = $(this).parent().attr('id').replace('limits-', '');
|
||||
var sfrom = $(this).parent().attr('id').replace('limits-', '');
|
||||
settings.settings.config.limits.splice(sfrom, 1);
|
||||
$(this).parent().remove();
|
||||
|
||||
loadSettings(fillHTML);
|
||||
|
||||
//console.log('y', settings.settings.config.limits);
|
||||
loadSettings(fillLimits);
|
||||
}).text(' <delete> ');
|
||||
|
||||
cur.append($('<span>').text(lim.name + ' | ' + lim.type + ' | ' + lim.val));
|
||||
|
@ -321,6 +364,51 @@
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
function fillProtocols()
|
||||
{
|
||||
var protocol, li;
|
||||
|
||||
$('#protocol-list').html('');
|
||||
|
||||
for(protocol in settings.settings.config.protocols)
|
||||
{
|
||||
li = $('<li>').attr('id', 'protocol-' + protocol);
|
||||
|
||||
li.text(protocol + ' on port ' + settings.settings.config.protocols[protocol].port);
|
||||
|
||||
li.append($('<span>').click(function()
|
||||
{
|
||||
var prot = $(this).parent().attr('id').replace('protocol-', '');
|
||||
console.log(prot);
|
||||
|
||||
delete settings.settings.config.protocols[prot];
|
||||
|
||||
$(this).parent().remove();
|
||||
|
||||
loadSettings(fillProtocols);
|
||||
}).text('<remove>'));
|
||||
|
||||
$('#protocol-list').append(li);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function fillStreams()
|
||||
{
|
||||
var stream, li;
|
||||
|
||||
$('#streams-list').html('');
|
||||
|
||||
for(stream in settings.settings.streams)
|
||||
{
|
||||
li = $('<li>').text(stream);
|
||||
|
||||
|
||||
$('#streams-list').append(li);
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
|
Loading…
Add table
Reference in a new issue