/** * Local settings page * DDVTECH * for more information, see http://mistserver.org/index.php?title=Stand-alone_Configuration_Page */ /** * Store a local copy of the data send by the server. * server is the URL, credentials hold the username, password and authstring and settings is the local copy. */ var settings = { server: '', credentials: { username: "", password: "", authstring: "" }, settings: {} }; /** * Table for long/short limit names */ var ltypes = [ ['kb_total', 'Total bandwidth'], ['kbps_max', 'Current bandwidth'], ['users', 'Concurrent users'], ['streams', 'Cocurrent streams'], ['geo', 'Geolimited'], ['host', 'Hostlimited'], ['time', 'Timelimited'], ['duration', 'Duration'], ['str_kbps_min', 'Minimum bitrate'], ['str_kbps_max', 'Maximum bitrate'] ]; /** * When the page loads, fix the menu and show the correct tab */ $(document).ready(function() { $('#nav').children().each(function() { $(this).click(function() { // remove currently selected' class $('#nav').children().each(function() { $(this).attr('class', ''); }); // select this one $(this).attr('class', 'selected'); // show correct tab showTab($(this).text()); }); if (($(this).text() == "limits") && (settings.settings.LTS != 1)) { $(this).remove(); } }); // show login 'tab' and hide menu showTab('login'); $('#nav').css('visibility', 'hidden'); }); // used on the overview and streams page. cleared when switching to another 'tab'. var sinterval = null; // and this one is used on the protocols page. var pinterval = null; // what kind of streams should be displayed? Format is [recorded, live]; var streamsdisplay = [true, true]; // used on the overview page to decide then to ask the controller for an update check var updatelastchecked; /** * Display a certain page. It contains a (giant) switch-statement, that builds a page depending on the tab requested * @param name the name of the tab * @param streamname only used when editing streams or protocols, the name of the edited (or new) stream/protocol. Also used with the 'embed' tab */ function showTab(name, streamname) { // clear page and refresh interval $('#page').html(''); clearInterval(sinterval); clearInterval(pinterval); switch(name) { case 'login': var host = $('').attr('type', 'text').attr('placeholder', 'HTTP://' + (location.host == '' ? 'localhost:4242' : location.host) + '/api'); var user = $('').attr('type', 'text').attr('placeholder', 'USERNAME'); var pass = $('').attr('type', 'password').attr('placeholder', 'PASSWORD'); var conn = $('