00001 var artStarted = false;
00002
00003 function manageButtons( artRunning ) {
00004 if(artRunning) {
00005 $("#shutdown").html("<span>Stop UDPDump</span>").attr("class","animated green visible");
00006 $("#started").html("<span>UDPDump Running</span>").attr("class","animated blue visible");
00007 } else {
00008 $("#shutdown").html("<span>UDPDump Not Running</span>").attr("class","animated blue visible");
00009 $("#started").html("<span>Start UDPDump</span>").attr("class","animated green visible");
00010 }
00011
00012 $( ".green.animated" ).hover( function () {
00013 $( this ).addClass( "active" );
00014 },function () { $( this ).removeClass( "active" ); } );
00015 }
00016
00017 function update( data ) {
00018
00019 manageButtons( data.running );
00020
00021
00022 var out = $("#out")[0];
00023 var err = $("#err")[0];
00024 var outAtBottom = out.scrollTop + out.clientHeight >= out.scrollHeight - 10;
00025 var errAtBottom = err.scrollTop + err.clientHeight >= err.scrollHeight - 10;
00026 $( "#out" ).val( data.out );
00027 $( "#err" ).val( data.err );
00028 if(outAtBottom) { out.scrollTop = out.scrollHeight };
00029 if(errAtBottom) { err.scrollTop = err.scrollHeight };
00030
00031 if(artStarted) {
00032 setTimeout(function() {Onmon("#wd0div",0,"udpdump");}, 1000);
00033 artStarted = false;
00034 }
00035
00036 if(data.running) { setTimeout(function() { AjaxGet( "/udpdump/Log", update); }, 1000); }
00037 }
00038
00039 function getFileNames() {
00040 $.get("/udpdump/FileNames", function(result) {
00041 $("#fileName").html(result);
00042 });
00043 }
00044
00045 function shutdownSystem() {
00046 if ( $( "#shutdown" ).is( ".green" ) ) {
00047 AjaxPost( "/udpdump/Kill",{ },update );
00048 }
00049 }
00050
00051 function startSystem() {
00052 if ( $( "#started" ).is( ".green" ) ) {
00053 artStarted = true;
00054 $("#wd0div").empty();
00055 AjaxPost( "/udpdump/Start",{ fileIndex: $( "#fileName" )[0].selectedIndex },update );
00056 }
00057 }
00058
00059 $( document ).ready( function() {
00060 $("#shutdown").click(function() {
00061 shutdownSystem();
00062 });
00063 $("#started").click(function() {
00064 startSystem();
00065 });
00066
00067 getFileNames();
00068 $("#reloadFileNames").click(function() {
00069 getFileNames();
00070 });
00071
00072 AjaxGet("/udpdump/Log", update);
00073 });