diff --git a/server.html b/server.html index 315c2ea2..fb91ae12 100644 --- a/server.html +++ b/server.html @@ -164,6 +164,16 @@ margin: 10px 0 5px 15px; } + .errorlogin + { + color: #c33; + } + + .correctlogin + { + color: #393; + } + @@ -183,12 +193,12 @@ Username: - + Password: - + @@ -206,11 +216,11 @@ Config - Host: (save) + Host: save - Name: (save) + Name: save Status: DISABLE @@ -404,7 +414,22 @@ } }else{ //console.log('no challenge - we\'re logged in! = OK'); - settings.settings = d; + settings.settings = $.extend(true, { + "config": + { + "host": "", + "limits": [], + "name": "", + "protocols": {}, + "status": "", + "version": "" + }, + "streams": {}, + "log": {}, + "statistics": {} + }, d); + + console.log('new shinyness object:', settings.settings); } if(callback) @@ -433,20 +458,30 @@ settings.server = $('#server').val(); $('#status').text('logging in...'); + $('#status').attr('class', ''); loadSettings(function(errorstr) { if(errorstr == '') { $('#status').text('logged in'); + $('#status').attr('class', 'correctlogin'); $('div').show(); fillHTML(); - //console.log('logged in!'); +/* + setInterval(function() + { + loadSettings(fillLogs); + }, 5000); +*/ + console.log('logged in!'); }else{ $('#status').text('disconnected - ' + errorstr); - $('div').hide(); + $('#status').attr('class', 'errorlogin'); + $('div:not(#current-status):not(#connect)').hide(); + //$('div').hide(); //console.log('error logging in: ' + errorstr); } }); @@ -549,7 +584,7 @@ $(this).parent().remove(); loadSettings(fillLimits); - }).text('(delete)'); + }).html('delete'); cur.append($('').text(limitShortToLong(lim.name))); cur.append($('').text(lim.type)); @@ -574,7 +609,7 @@ li.text(protocol + ' on port ' + settings.settings.config.protocols[protocol].port); - li.append($('').click(function() + li.append($('').click(function() { var prot = $(this).parent().attr('id').replace('protocol-', ''); console.log(prot); @@ -584,7 +619,7 @@ $(this).parent().remove(); loadSettings(fillProtocols); - }).text('')); + }).text('remove')); $('#protocol-list').append(li); } @@ -599,7 +634,7 @@ for(stream in settings.settings.streams) { - var d = $('').text(' ').attr('id', 'stream-delete-' + stream).click(function() + var d = $('').text('delete').attr('id', 'stream-delete-' + stream).click(function() { var id = $(this).attr('id').replace('stream-delete-', ''); console.log('delete this stream', id); @@ -616,7 +651,7 @@ li.append( $('').text('Name: ').append( $('').attr('type', 'text').attr('id', 'stream-name-' + stream).attr('value', cur.name) ).append( - $('').text('').click(function(x) + $('').text('save').click(function(x) { return function() { @@ -635,7 +670,7 @@ li.append( $('').text('Group: ').append( $('').attr('type', 'text').attr('id', 'stream-group-' + stream).attr('value', cur.group) ).append( - $('').text('').click(function(x) + $('').text('save').click(function(x) { return function() { @@ -663,7 +698,7 @@ $('').attr('type', 'text').attr('id', 'stream-channel-account-' + stream).attr('value', cur.channel.account) ) ); - channel.append($('').attr('class', 'mleft25').text('(save)').click(function() + channel.append($('').attr('class', 'mleft25').text('save').click(function() { var cname = $(this).parent().attr('id').replace('stream-channel-', ''), url = $('#stream-channel-url-' + cname).val(), @@ -696,7 +731,9 @@ ) ).append(tbody); - for(var i = 0; i < cur.limits.length; i++) + var cll = cur.limits ? cur.limits.length : 0; + + for(var i = 0; i < cll; i++) { var climit = $('').attr('id', 'stream-limit-' + stream + '-' + i); @@ -711,7 +748,7 @@ loadSettings(fillStreams); - }).text('(delete)'); + }).html('delete'); climit.append($('').text(limitShortToLong(cur.limits[i].name))); climit.append($('').text(cur.limits[i].type)); @@ -786,7 +823,7 @@ spreset.append( $('').text('Command: ').append( $('').attr('id', 'stream-preset-cmd-' + stream).attr('type', 'text').val(settings.settings.streams[stream].preset.cmd) ).append( - $('').text('').click(function() + $('').text('save').click(function() { var stream = $(this).parent().parent().attr('id').replace('stream-preset-', ''); var cmd = $('#stream-preset-cmd-' + stream).val(); @@ -801,7 +838,7 @@ spreset.append( $('').text('Description: ').append( $('').attr('id', 'stream-preset-desc-' + stream).attr('type', 'text').val(settings.settings.streams[stream].preset.desc) ).append( - $('').text('').click(function() + $('').text('save').click(function() { var stream = $(this).parent().parent().attr('id').replace('stream-preset-', ''); var desc = $('#stream-preset-desc-' + stream).val(); @@ -816,7 +853,7 @@ spreset.append( $('').text('Name: ').append( $('').attr('id', 'stream-preset-name-' + stream).attr('type', 'text').val(settings.settings.streams[stream].preset.name) ).append( - $('').text('').click(function() + $('').text('save').click(function() { var stream = $(this).parent().parent().attr('id').replace('stream-preset-', ''); var name = $('#stream-preset-name-' + stream).val(); @@ -874,6 +911,8 @@ logs = settings.settings.log.reverse(), len = logs.length; + tbody.html(''); + for(i = 0; i < len; i++) { cur = settings.settings.log[i]; @@ -886,7 +925,6 @@ $('').text(cur[2]) ); - tbody.append(tr); } }