LSP bugfixes by Carina van der Meer
This commit is contained in:
parent
11cb4c1c76
commit
7905bb2bda
6 changed files with 298 additions and 30 deletions
|
@ -1,4 +0,0 @@
|
|||
[Dolphin]
|
||||
Timestamp=2015,4,10,12,58,21
|
||||
Version=3
|
||||
ViewMode=1
|
25
lsp/main.css
25
lsp/main.css
File diff suppressed because one or more lines are too long
|
@ -63,8 +63,8 @@ d?5:10;e=e*n*Math.pow(1024,b);null!=a.minTickSize&&e<a.minTickSize&&(e=a.minTick
|
|||
b.getSeconds()).slice(-2));return d.join(":")},date:function(a,c){var b=new Date(1E3*a),d="Sun Mon Tue Wed Thu Fri Sat".split(" "),g=[];"long"==c&&g.push(d[b.getDay()]);g.push(("0"+b.getDate()).slice(-2));g.push("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" ")[b.getMonth()]);"short"!=c&&g.push(b.getFullYear());return g.join(" ")},dateTime:function(a,c){return UI.format.date(a,c)+", "+UI.format.time(a,c)},duration:function(a){var c=[0.001,1E3,60,60,24,7,1E9],b="ms sec min hr day week".split(" "),
|
||||
d={},g;for(g in b){var a=a/c[g],j=Math.round(a%c[Number(g)+1]);d[b[g]]=j;a-=j}var n;for(g=b.length-1;0<=g;g--)if(0<d[b[g]]){n=b[g];break}c=$("<span>");switch(n){case "week":c.append(UI.format.addUnit(d.week,"wks, ")).append(UI.format.addUnit(d.day,"days"));break;case "day":c.append(UI.format.addUnit(d.day,"days, ")).append(UI.format.addUnit(d.hr,"hrs"));break;default:c.append([("0"+d.hr).slice(-2),("0"+d.min).slice(-2),("0"+d.sec).slice(-2)+(d.ms?"."+d.ms:"")].join(":"))}return c[0].innerHTML},number:function(a){if(isNaN(Number(a))||
|
||||
0==a)return a;var c=Math.pow(10,3-Math.floor(Math.log(a)/Math.LN10)-1),a=Math.round(a*c)/c;if(1E4<a){number=a.toString().split(".");for(a=/(\d+)(\d{3})/;a.test(number[0]);)number[0]=number[0].replace(a,"$1 $2");a=number.join(".")}return a},status:function(a){var c=$("<span>");if("undefined"==typeof a.online)return c.text("Unknown, checking.."),"undefined"!=typeof a.error&&c.text(a.error),c;switch(a.online){case -1:c.text("Enabling");break;case 0:c.text("Unavailable").addClass("red");break;case 1:c.text("Active").addClass("green");
|
||||
break;case 2:c.text("Standby").addClass("orange");break;default:c.text(a.online)}"undefined"!=typeof a.error&&c.text(a.error);return c},capital:function(a){return a.charAt(0).toUpperCase()+a.substring(1)},addUnit:function(a,c){var b=$("<span>").html(a);b.append($("<span>").addClass("unit").html(c));return b[0].innerHTML},bytes:function(a,c){var b="bytes KiB MiB GiB TiB PiB".split(" ");if(0==a)unit=b[0];else{var d=Math.floor(Math.log(Math.abs(a))/Math.log(1024));0>d?unit=b[0]:(a/=Math.pow(1024,d),
|
||||
unit=b[d])}return UI.format.addUnit(UI.format.number(a),unit+(c?"/s":""))}},navto:function(a,c){var b=location.hash,d=b.split("@");d[0]=[mist.user.name,mist.user.host].join("&");d[1]=[a,c].join("&");location.hash=d.join("@");location.hash==b&&$(window).trigger("hashchange")},showTab:function(a,c){var b=UI.elements.main;if(mist.user.loggedin&&!("ui_settings"in mist.data))b.html("Loading.."),mist.send(function(){UI.showTab(a,c)},{ui_settings:!0});else{var d=UI.elements.menu.css("visibility","visible").find(".button").filter(function(){if($(this).find(".plain").text()==
|
||||
break;case 2:c.text("Standby").addClass("orange");break;default:c.text(a.online)}"error"in a&&c.text(a.error);return c},capital:function(a){return a.charAt(0).toUpperCase()+a.substring(1)},addUnit:function(a,c){var b=$("<span>").html(a);b.append($("<span>").addClass("unit").html(c));return b[0].innerHTML},bytes:function(a,c){var b="bytes KiB MiB GiB TiB PiB".split(" ");if(0==a)unit=b[0];else{var d=Math.floor(Math.log(Math.abs(a))/Math.log(1024));0>d?unit=b[0]:(a/=Math.pow(1024,d),unit=b[d])}return UI.format.addUnit(UI.format.number(a),
|
||||
unit+(c?"/s":""))}},navto:function(a,c){var b=location.hash,d=b.split("@");d[0]=[mist.user.name,mist.user.host].join("&");d[1]=[a,c].join("&");location.hash=d.join("@");location.hash==b&&$(window).trigger("hashchange")},showTab:function(a,c){var b=UI.elements.main;if(mist.user.loggedin&&!("ui_settings"in mist.data))b.html("Loading.."),mist.send(function(){UI.showTab(a,c)},{ui_settings:!0});else{var d=UI.elements.menu.css("visibility","visible").find(".button").filter(function(){if($(this).find(".plain").text()==
|
||||
a)return!0});0<d.length&&(UI.elements.menu.find(".button.active").removeClass("active"),d.addClass("active"));UI.elements.secondary_menu.html("");UI.interval.clear();b.html($("<h2>").text(a));switch(a){case "Login":if(mist.user.loggedin){UI.navto("Overview");break}UI.elements.menu.css("visibility","hidden");UI.elements.connection.status.text("Disconnected").removeClass("green").addClass("red");b.append(UI.buildUI([{type:"help",help:"Please provide your account details.<br>You were asked to set these when MistController was started for the first time. If you did not yet set any account details, log in with your desired credentials to create a new account."},
|
||||
{label:"Host",help:"Url location of the MistServer API. Generally located at http://MistServerIP:4242/api","default":"http://localhost:4242/api",pointer:{main:mist.user,index:"host"}},{label:"Username",help:"Please enter your username here.",validate:["required"],pointer:{main:mist.user,index:"name"}},{label:"Password",type:"password",help:"Please enter your password here.",validate:["required"],pointer:{main:mist.user,index:"password"}},{type:"buttons",buttons:[{label:"Login",type:"save","function":function(){mist.send(function(){UI.navto("Overview")})}}]}]));
|
||||
break;case "Create a new account":UI.elements.menu.css("visibility","hidden");b.append($("<p>").text("No account has been created yet in the MistServer at ").append($("<i>").text(mist.user.host)).append("."));b.append(UI.buildUI([{type:"buttons",buttons:[{label:"Select other host",type:"cancel",css:{"float":"left"},"function":function(){UI.navto("Login")}}]},{type:"custom",custom:$("<br>")},{label:"Desired username",type:"str",validate:["required"],help:"Enter your desired username. In the future, you will need this to access the Management Interface.",
|
||||
|
@ -86,13 +86,13 @@ var l=function(){function a(b){var c=mist.data.capabilities.connectors[b.connect
|
|||
var m={},t=[];for(q in mist.data.capabilities.connectors)t.push([q,q]);var Q=$("<span>");b.append(UI.buildUI([{label:"Protocol",type:"select",select:t,"function":function(){Q.html(P($(this).getval()))}}])).append(Q)}break;case "Streams":if(!("capabilities"in mist.data)){b.html("Loading..");mist.send(function(){UI.navto(a)},{capabilities:!0});break}h=$("<tbody>").append($("<tr>").append("<td>").attr("colspan",6).text("Loading.."));p=$("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Stream name").attr("data-sort-type",
|
||||
"string").addClass("sorting-asc")).append($("<th>").text("Source").attr("data-sort-type","string")).append($("<th>").text("Status").attr("data-sort-type","int")).append($("<th>").css("text-align","right").text("Connections").attr("data-sort-type","int")).append($("<th>")).append($("<th>")))).append(h);b.append(UI.buildUI([{type:"help",help:"Here you can create, edit or delete new and existing streams. Immidiately go to the stream preview or view the information available about the stream with the info button."}])).append($("<button>").text("New stream").click(function(){UI.navto("Edit Stream")})).append(p);
|
||||
p.stupidtable();var D=function(){var a=[],b;for(b in mist.data.active_streams)a.push({streams:[mist.data.active_streams[b]],fields:["clients"],start:-2});mist.send(function(){$.extend(true,x,mist.data.streams);var a=0;h.html("");if(mist.data.LTS)for(a in mist.data.active_streams){var b=mist.data.active_streams[a].split("+");if(!(b.length<2)&&b[0]in mist.data.streams){b=R(mist.data.active_streams[a],mist.data.streams[b[0]]);b.online=1;x[mist.data.active_streams[a]]=b}}b=Object.keys(x);b.sort();for(var c in b){var d=
|
||||
b[c],e=x[d],g=$("<td>").css("text-align","right").html($("<span>").addClass("description").text("Loading..")),f=0;if(typeof mist.data.totals!="undefined"&&typeof mist.data.totals[d]!="undefined"){f=mist.data.totals[d].all_protocols.clients;f=f.length?f[f.length-1][1]:0}g.html(UI.format.number(f));if(f==0&&e.online==1)e.online=2;f=$("<td>").css("text-align","right").css("white-space","nowrap");e.ischild||f.html($("<button>").text("Edit").click(function(){UI.navto("Edit Stream",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a=
|
||||
$(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the stream "'+a+'"?')){delete mist.data.streams[a];var b={};mist.data.LTS?b.deletestream=[a]:b.streams=mist.data.streams;mist.send(function(){UI.navto("Streams")},b)}}));var i=$("<span>").text(d);e.ischild&&i.css("padding-left","1em");var j=UI.format.status(e),k=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("tr").data("index"))});if(e.filesfound){j.html("");k="";g.html("")}h.append($("<tr>").data("index",
|
||||
d).html($("<td>").html(i).attr("title",d).addClass("overflow_ellipsis")).append($("<td>").text(e.source).attr("title",e.source).addClass("description").addClass("overflow_ellipsis").css("max-width","20em")).append($("<td>").data("sort-value",e.online).html(j)).append(g).append($("<td>").html(k)).append(f));a++}},{totals:a,active_streams:true})},x=$.extend(!0,{},mist.data.streams),R=function(a,b){var c=$.extend({},b);delete c.meta;delete c.error;c.online=2;c.name=a;c.ischild=true;return c};if(mist.data.LTS){var A=
|
||||
0,E=0;for(i in mist.data.streams)p=mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"],mist.inputMatch(p.source_match,mist.data.streams[i].source)&&(x[i].source+="*",mist.send(function(a,b){var c=b.stream,d;for(d in a.browse.files)for(var e in mist.data.capabilities.inputs)if(!(e.indexOf("Buffer")>=0||e.indexOf("Folder")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[e].source_match,"/"+a.browse.files[d])){var g=c+"+"+a.browse.files[d];x[g]=R(g,mist.data.streams[c]);
|
||||
x[g].source=mist.data.streams[c].source+a.browse.files[d]}a.browse.files.length?x[c].filesfound=true:mist.data.streams[c].filesfound=false;E++;if(A==E){mist.send(function(){D()},{active_streams:true});UI.interval.set(function(){D()},3E4)}},{browse:mist.data.streams[i].source},{stream:i}),A++);0==A&&(mist.send(function(){D()},{active_streams:!0}),UI.interval.set(function(){D()},3E4))}else mist.send(function(){D()},{active_streams:!0}),UI.interval.set(function(){D()},1E4);break;case "Edit Stream":if("undefined"==
|
||||
typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});b.append("Loading..");break}k=!1;""!=c&&(k=!0);k?(p=c,m=mist.data.streams[p],b.find("h2").append(' "'+p+'"')):(b.html($("<h2>").text("New Stream")),m={});i=[];for(q in mist.data.capabilities.inputs)i.push(mist.data.capabilities.inputs[q].source_match);var F=$("<div>");b.append(UI.buildUI([{label:"Stream name",type:"str",validate:["required","streamname"],pointer:{main:m,index:"name"},help:"Set the name this stream will be recognised by for players and/or stream pushing."},
|
||||
{label:"Source",type:"browse",validate:["required"],filetypes:i,pointer:{main:m,index:"source"},help:'Set the stream source.<table><tr><td>VoD:</td><td>You can browse to the file or folder as a source or simply enter the path to the file.</td></tr><tr><td>Live:</td><td>You\'ll need to enter "push://IP" with the IP of the machine pushing towards MistServer.<br>You can use "push://" to accept any source.</td></tr><tr><td>(Pro only)</td><td>Use "push://(IP)@password" to set a password protection for pushes.</td></tr></table>If you\'re unsure how to set the source properly, please view our Live pushing guide at the tools section.',
|
||||
b[c],e;e=d in mist.data.streams?mist.data.streams[d]:x[d];var g=$("<td>").css("text-align","right").html($("<span>").addClass("description").text("Loading..")),f=0;if(typeof mist.data.totals!="undefined"&&typeof mist.data.totals[d]!="undefined"){var i=mist.data.totals[d].all_protocols.clients,f=0;if(i.length){for(a in i)f=f+i[a][1];f=Math.round(f/i.length)}}g.html(UI.format.number(f));if(f==0&&e.online==1)e.online=2;f=$("<td>").css("text-align","right").css("white-space","nowrap");(!("ischild"in e)||
|
||||
!e.ischild)&&f.html($("<button>").text("Edit").click(function(){UI.navto("Edit Stream",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the stream "'+a+'"?')){delete mist.data.streams[a];var b={};mist.data.LTS?b.deletestream=[a]:b.streams=mist.data.streams;mist.send(function(){UI.navto("Streams")},b)}}));i=$("<span>").text(d);e.ischild&&i.css("padding-left","1em");var j=
|
||||
UI.format.status(e),k=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("tr").data("index"))});if(e.filesfound){j.html("");k="";g.html("")}h.append($("<tr>").data("index",d).html($("<td>").html(i).attr("title",d).addClass("overflow_ellipsis")).append($("<td>").text(e.source).attr("title",e.source).addClass("description").addClass("overflow_ellipsis").css("max-width","20em")).append($("<td>").data("sort-value",e.online).html(j)).append(g).append($("<td>").html(k)).append(f));
|
||||
a++}},{totals:a,active_streams:true})},x=$.extend(!0,{},mist.data.streams),R=function(a,b){var c=$.extend({},b);delete c.meta;delete c.error;c.online=2;c.name=a;c.ischild=true;return c};if(mist.data.LTS){var A=0,E=0;for(i in mist.data.streams)p=mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"],mist.inputMatch(p.source_match,mist.data.streams[i].source)&&(x[i].source+="*",mist.send(function(a,b){var c=b.stream,d;for(d in a.browse.files)for(var e in mist.data.capabilities.inputs)if(!(e.indexOf("Buffer")>=
|
||||
0||e.indexOf("Folder")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[e].source_match,"/"+a.browse.files[d])){var g=c+"+"+a.browse.files[d];x[g]=R(g,mist.data.streams[c]);x[g].source=mist.data.streams[c].source+a.browse.files[d]}a.browse.files.length?x[c].filesfound=true:mist.data.streams[c].filesfound=false;E++;if(A==E){mist.send(function(){D()},{active_streams:true});UI.interval.set(function(){D()},1E4)}},{browse:mist.data.streams[i].source},{stream:i}),A++);0==A&&(mist.send(function(){D()},
|
||||
{active_streams:!0}),UI.interval.set(function(){D()},3E4))}else mist.send(function(){D()},{active_streams:!0}),UI.interval.set(function(){D()},1E4);break;case "Edit Stream":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});b.append("Loading..");break}k=!1;""!=c&&(k=!0);k?(p=c,m=mist.data.streams[p],b.find("h2").append(' "'+p+'"')):(b.html($("<h2>").text("New Stream")),m={});i=[];for(q in mist.data.capabilities.inputs)i.push(mist.data.capabilities.inputs[q].source_match);
|
||||
var F=$("<div>");b.append(UI.buildUI([{label:"Stream name",type:"str",validate:["required","streamname"],pointer:{main:m,index:"name"},help:"Set the name this stream will be recognised by for players and/or stream pushing."},{label:"Source",type:"browse",validate:["required"],filetypes:i,pointer:{main:m,index:"source"},help:'Set the stream source.<table><tr><td>VoD:</td><td>You can browse to the file or folder as a source or simply enter the path to the file.</td></tr><tr><td>Live:</td><td>You\'ll need to enter "push://IP" with the IP of the machine pushing towards MistServer.<br>You can use "push://" to accept any source.</td></tr><tr><td>(Pro only)</td><td>Use "push://(IP)@password" to set a password protection for pushes.</td></tr></table>If you\'re unsure how to set the source properly, please view our Live pushing guide at the tools section.',
|
||||
"function":function(){var a=$(this).val();if(a!=""){var b=null,c;for(c in mist.data.capabilities.inputs)if(typeof mist.data.capabilities.inputs[c].source_match!="undefined"&&mist.inputMatch(mist.data.capabilities.inputs[c].source_match,a)){b=c;break}if(b===null)F.html($("<h3>").text("Unrecognized input").addClass("red")).append($("<span>").text("Please edit the stream source.").addClass("red"));else{a=mist.data.capabilities.inputs[b];F.html($("<h3>").text(a.name+" Input options"));a=mist.convertBuildOptions(a,
|
||||
m);F.append(UI.buildUI(a))}}}},$("<br>"),{type:"custom",custom:F},$("<br>"),$("<h3>").text("Encryption"),{type:"help",help:"To enable encryption, the licence acquisition url must be entered, as well as either the content key or the key ID and seed.<br>Unsure how you should fill in your encryption or missing your preferred encryption? Please contact us."},{label:"License acquisition url",type:"str",LTSonly:!0,pointer:{main:m,index:"la_url"}},$("<br>"),{label:"Content key",type:"str",LTSonly:!0,pointer:{main:m,
|
||||
index:"contentkey"}},{type:"text",text:" - or - "},{label:"Key ID",type:"str",LTSonly:!0,pointer:{main:m,index:"keyid"}},{label:"Key seed",type:"str",LTSonly:!0,pointer:{main:m,index:"keyseed"}},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Streams")}},{type:"save",label:"Save","function":function(){if(!mist.data.streams)mist.data.streams={};mist.data.streams[m.name]=m;c!=m.name&&delete mist.data.streams[c];var a={};if(mist.data.LTS){a.addstream={};a.addstream[m.name]=
|
||||
|
@ -146,10 +146,10 @@ validate:["required"],pointer:{main:m,index:"name"},value:mist.user.name},{type:
|
|||
{type:"buttons",buttons:[{type:"save",label:"Send","function":function(a){$(a).text("Sending..");$.ajax({type:"POST",url:"http://mistserver.org/contact_us?skin=plain",data:m,success:function(a){a=$("<span>").html(a);a.find("script").remove();b.html(a[0].innerHTML)}})}}]}]));break;case "Disconnect":mist.user.password="";delete mist.user.authstring;delete mist.user.loggedin;UI.navto("Login");break;default:b.append($("<p>").text("This tab does not exist."))}}}},mist={data:{},user:{name:"",password:"",
|
||||
host:"http://"+(location.hostname?location.hostname:"localhost")+":4242/api"},send:function(a,c,b){var c=c||{},b=b||{},b=$.extend(!0,{timeout:30,sendData:c},b),d={authorize:{password:mist.user.authstring?MD5(MD5(mist.user.password)+mist.user.authstring):"",username:mist.user.name}};$.extend(!0,d,c);log("Send",$.extend(!0,{},c));d={url:mist.user.host,type:"POST",data:{command:JSON.stringify(d)},dataType:"jsonp",crossDomain:!0,timeout:1E3*b.timeout,async:!0,error:function(d,g){delete mist.user.loggedin;
|
||||
if(!b.hide){switch(g){case "timeout":g=$("<i>").text("The connection timed out. ");break;case "abort":g=$("<i>").text("The connection was aborted. ");break;default:g=$("<i>").text(g+". ").css("text-transform","capitalize")}$("#message").addClass("red").text("An error occurred while attempting to communicate with MistServer:").append($("<br>")).append(g).append($("<a>").text("Send server request again").click(function(){mist.send(a,c,b)}))}UI.navto("Login")},success:function(d){log("Receive",$.extend(!0,
|
||||
{},d),"as reply to",b.sendData);delete mist.user.loggedin;switch(d.authorize.status){case "OK":d.config&&(mist.data.config=d.config);d.capabilities&&(mist.data.capabilities=d.capabilities);d.ui_settings&&(mist.data.ui_settings=d.ui_settings);d.LTS&&(mist.data.LTS=d.LTS);d.active_streams&&(mist.data.active_streams=d.active_streams);d.browse&&(mist.data.browse=d.browse);d.log&&(mist.data.log=d.log);d.streams&&!d.streams["incomplete list"]&&(mist.data.streams=d.streams);d.totals&&(mist.data.totals=d.totals);
|
||||
mist.user.loggedin=!0;UI.elements.connection.status.text("Connected").removeClass("red").addClass("green");UI.elements.connection.user_and_host.text(mist.user.name+" @ "+mist.user.host);UI.elements.connection.msg.removeClass("red").text("Last communication with the server at "+UI.format.time((new Date).getTime()/1E3));d.LTS&&UI.elements.menu.find(".LTSonly").removeClass("LTSonly");if(d.log){var g=d.log[d.log.length-1];UI.elements.connection.msg.append($("<br>")).append("Last log entry: "+UI.format.time(g[0])+
|
||||
" ["+g[1]+"] "+g[2])}if("totals"in d)if(g=function(a,b,c){var d;d=function(){for(var a in c.fields)e[c.fields[a]].push([f,0])};var e={},g;for(g in c.fields)e[c.fields[g]]=[];var k=0,f;if(c.data){if(c.end-c.start<600){f=(c.end-600)*1E3;d();f=c.start*1E3;d()}else f=c.start*1E3;for(g in c.data){if(g==0){f=c.start*1E3;var j=0}else{f=f+c.interval[j][1]*1E3;c.interval[j][0]--;if(c.interval[j][0]<=0){j++;j<c.interval.length-1&&(k=2)}}if(k==1){d();k--}for(var n in c.data[g])e[c.fields[n]].push([f,c.data[g][n]]);
|
||||
if(k){d();k--}}if(mist.data.config.time-c.end>5){d();f=mist.data.config.time*1E3;d()}}else{f=(mist.data.config.time-600)*1E3;d();f=mist.data.config.time*1E3;d()}d=e;stream=a?a.join(" "):"all_streams";protocol=b?b.join("_"):"all_protocols";stream in mist.data.totals||(mist.data.totals[stream]={});protocol in mist.data.totals[stream]||(mist.data.totals[stream][protocol]={});$.extend(mist.data.totals[stream][protocol],d)},mist.data.totals={},"fields"in d.totals)g(c.totals.streams,c.totals.protocols,
|
||||
{},d),"as reply to",b.sendData);delete mist.user.loggedin;switch(d.authorize.status){case "OK":"config"in d&&(mist.data.config=d.config);"capabilities"in d&&(mist.data.capabilities=d.capabilities);"ui_settings"in d&&(mist.data.ui_settings=d.ui_settings);"LTS"in d&&(mist.data.LTS=d.LTS);"active_streams"in d&&(mist.data.active_streams=d.active_streams);"browse"in d&&(mist.data.browse=d.browse);"log"in d&&(mist.data.log=d.log);"streams"in d&&(d.streams&&"incomplete_list"in d.streams&&delete d.streams.incomplete_list,
|
||||
mist.data.streams=d.streams);d.totals&&(mist.data.totals=d.totals);mist.user.loggedin=!0;UI.elements.connection.status.text("Connected").removeClass("red").addClass("green");UI.elements.connection.user_and_host.text(mist.user.name+" @ "+mist.user.host);UI.elements.connection.msg.removeClass("red").text("Last communication with the server at "+UI.format.time((new Date).getTime()/1E3));d.LTS&&UI.elements.menu.find(".LTSonly").removeClass("LTSonly");if(d.log){var g=d.log[d.log.length-1];UI.elements.connection.msg.append($("<br>")).append("Last log entry: "+
|
||||
UI.format.time(g[0])+" ["+g[1]+"] "+g[2])}if("totals"in d)if(g=function(a,b,c){var d;d=function(){for(var a in c.fields)e[c.fields[a]].push([f,0])};var e={},g;for(g in c.fields)e[c.fields[g]]=[];var k=0,f;if(c.data){if(c.end-c.start<600){f=(c.end-600)*1E3;d();f=c.start*1E3;d()}else f=c.start*1E3;for(g in c.data){if(g==0){f=c.start*1E3;var j=0}else{f=f+c.interval[j][1]*1E3;c.interval[j][0]--;if(c.interval[j][0]<=0){j++;j<c.interval.length-1&&(k=2)}}if(k==1){d();k--}for(var n in c.data[g])e[c.fields[n]].push([f,
|
||||
c.data[g][n]]);if(k){d();k--}}if(mist.data.config.time-c.end>5){d();f=mist.data.config.time*1E3;d()}}else{f=(mist.data.config.time-600)*1E3;d();f=mist.data.config.time*1E3;d()}d=e;stream=a?a.join(" "):"all_streams";protocol=b?b.join("_"):"all_protocols";stream in mist.data.totals||(mist.data.totals[stream]={});protocol in mist.data.totals[stream]||(mist.data.totals[stream][protocol]={});$.extend(mist.data.totals[stream][protocol],d)},mist.data.totals={},"fields"in d.totals)g(c.totals.streams,c.totals.protocols,
|
||||
d.totals);else for(var e in d.totals)g(c.totals[e].streams,c.totals[e].protocols,d.totals[e]);a&&a(d,b);break;case "CHALL":d.authorize.challenge==mist.user.authstring?(""!=mist.user.password&&UI.elements.connection.msg.text("The credentials you provided are incorrect.").addClass("red"),UI.navto("Login")):""==mist.user.password?UI.navto("Login"):(mist.user.authstring=d.authorize.challenge,mist.send(a,c,b));break;case "NOACC":UI.navto("Create a new account");break;case "ACC_MADE":delete c.authorize;
|
||||
mist.send(a,c,b);break;default:UI.navto("Login")}}};b.hide||UI.elements.connection.msg.removeClass("red").text("Data sent, waiting for a reply..").append($("<br>")).append($("<a>").text("Cancel request").click(function(){g.abort()}));var g=$.ajax(d)},inputMatch:function(a,c){if("undefined"==typeof a)return!1;var b=a.replace(/[^\w\s]/g,"\\$&"),b=b.replace(/\\\?/g,".").replace(/\\\*/g,"(?:.)*");return RegExp("^"+b+"$","i").test(c)},convertBuildOptions:function(a,c){var b=[],d=["required","optional"];
|
||||
"desc"in a&&b.push({type:"help",help:a.desc});for(var g in d)if(a[d[g]]){b.push($("<h4>").text(UI.format.capital(d[g])+" parameters"));for(var j in a[d[g]]){var n=a[d[g]][j],e={label:UI.format.capital(n.name),pointer:{main:c,index:j},validate:[]};"required"==d[g]&&!("default"in n)&&e.validate.push("required");"default"in n&&(e.placeholder=n["default"]);"help"in n&&(e.help=n.help);"unit"in n&&(e.unit=n.unit);switch(n.type){case "int":e.type="int";break;case "uint":e.type="int";e.min=0;break;case "debug":e.type=
|
||||
|
|
40
lsp/mist.js
40
lsp/mist.js
|
@ -1661,7 +1661,7 @@ var UI = {
|
|||
case 2: $s.text('Standby').addClass('orange'); break;
|
||||
default: $s.text(item.online);
|
||||
}
|
||||
if (typeof item.error != 'undefined') {
|
||||
if ('error' in item) {
|
||||
$s.text(item.error);
|
||||
}
|
||||
return $s;
|
||||
|
@ -2340,20 +2340,29 @@ var UI = {
|
|||
streams.sort();
|
||||
for (var s in streams) {
|
||||
var streamname = streams[s];
|
||||
var stream = allstreams[streamname];
|
||||
var stream;
|
||||
if (streamname in mist.data.streams) { stream = mist.data.streams[streamname]; }
|
||||
else { stream = allstreams[streamname]; }
|
||||
|
||||
var $viewers = $('<td>').css('text-align','right').html($('<span>').addClass('description').text('Loading..'));
|
||||
var v = 0;
|
||||
if ((typeof mist.data.totals != 'undefined') && (typeof mist.data.totals[streamname] != 'undefined')) {
|
||||
var data = mist.data.totals[streamname].all_protocols.clients;
|
||||
var v = (data.length ? data[data.length-1][1] : 0);
|
||||
var v = 0;
|
||||
//get the average value
|
||||
if (data.length) {
|
||||
for (var i in data) {
|
||||
v += data[i][1];
|
||||
}
|
||||
v = Math.round(v / data.length);
|
||||
}
|
||||
}
|
||||
$viewers.html(UI.format.number(v));
|
||||
if ((v == 0) && (stream.online == 1)) {
|
||||
stream.online = 2;
|
||||
}
|
||||
var $buttons = $('<td>').css('text-align','right').css('white-space','nowrap');
|
||||
if (!stream.ischild) {
|
||||
if ((!('ischild' in stream)) || (!stream.ischild)) {
|
||||
$buttons.html(
|
||||
$('<button>').text('Edit').click(function(){
|
||||
UI.navto('Edit Stream',$(this).closest('tr').data('index'));
|
||||
|
@ -2476,7 +2485,7 @@ var UI = {
|
|||
|
||||
UI.interval.set(function(){
|
||||
updateStreams();
|
||||
},30e3);
|
||||
},10e3);
|
||||
}
|
||||
},{browse:mist.data.streams[s].source},{stream: s});
|
||||
browserequests++;
|
||||
|
@ -4169,14 +4178,19 @@ var mist = {
|
|||
switch (d.authorize.status) {
|
||||
case 'OK':
|
||||
//communication succesful, copy everything we care about, if it exists
|
||||
if (d.config){mist.data.config = d.config;}
|
||||
if (d.capabilities){mist.data.capabilities = d.capabilities;}
|
||||
if (d.ui_settings){mist.data.ui_settings = d.ui_settings;}
|
||||
if (d.LTS){mist.data.LTS = d.LTS;}
|
||||
if (d.active_streams){mist.data.active_streams = d.active_streams;}
|
||||
if (d.browse){mist.data.browse = d.browse;}
|
||||
if (d.log){mist.data.log = d.log;}
|
||||
if (d.streams && !d.streams["incomplete list"]){mist.data.streams = d.streams;}
|
||||
if ('config' in d) { mist.data.config = d.config; }
|
||||
if ('capabilities' in d) { mist.data.capabilities = d.capabilities; }
|
||||
if ('ui_settings' in d) { mist.data.ui_settings = d.ui_settings; }
|
||||
if ('LTS' in d) { mist.data.LTS = d.LTS; }
|
||||
if ('active_streams' in d) { mist.data.active_streams = d.active_streams; }
|
||||
if ('browse' in d) { mist.data.browse = d.browse; }
|
||||
if ('log' in d) { mist.data.log = d.log; }
|
||||
if ('streams' in d) {
|
||||
if ((d.streams) && ('incomplete_list' in d.streams)) {
|
||||
delete d.streams.incomplete_list;
|
||||
}
|
||||
mist.data.streams = d.streams;
|
||||
}
|
||||
|
||||
//does this really belong globally stored here?
|
||||
if (d.totals){mist.data.totals = d.totals;}
|
||||
|
|
232
lsp/plugins/screenlog.js
Normal file
232
lsp/plugins/screenlog.js
Normal file
|
@ -0,0 +1,232 @@
|
|||
|
||||
var screenlog = {
|
||||
master: function(){
|
||||
function gettab() {
|
||||
return location.hash.substring(1).split('@')[1];
|
||||
}
|
||||
|
||||
//which field has focus
|
||||
$(document).on('focus','.field',function(){
|
||||
screenlog.log.mine.push({
|
||||
type: 'focus',
|
||||
time: (new Date()).getTime(),
|
||||
tab: gettab(),
|
||||
element: $(this).attr('name')
|
||||
});
|
||||
});
|
||||
|
||||
//what is the value of this field on blur
|
||||
$(document).on('blur','.field',function(){
|
||||
screenlog.log.mine.push({
|
||||
type: 'blur',
|
||||
time: (new Date()).getTime(),
|
||||
tab: gettab(),
|
||||
element: $(this).attr('name'),
|
||||
val: $(this).getval()
|
||||
});
|
||||
});
|
||||
|
||||
//where is the cursor
|
||||
var mouse = {
|
||||
x: 0,
|
||||
y: 0
|
||||
};
|
||||
var lastmouse = mouse;
|
||||
$(document).on('mousemove',function(e){
|
||||
mouse = {
|
||||
x: e.pageX,
|
||||
y: e.pageY
|
||||
};
|
||||
});
|
||||
setInterval(function(){
|
||||
if ((mouse.x != lastmouse.x) || (mouse.y != lastmouse.y)) {
|
||||
lastmouse = mouse;
|
||||
screenlog.log.mine.push({
|
||||
type: 'mousepos',
|
||||
time: (new Date()).getTime(),
|
||||
tab: gettab(),
|
||||
pos: mouse
|
||||
});
|
||||
}
|
||||
},1e3);
|
||||
|
||||
//which tab are we on
|
||||
$(window).on('hashchange', function(e) {
|
||||
screenlog.log.mine.push({
|
||||
type: 'tab',
|
||||
time: (new Date()).getTime(),
|
||||
tab: gettab()
|
||||
});
|
||||
});
|
||||
|
||||
var lastsend;
|
||||
function sendlog(){
|
||||
var l = [];
|
||||
for (var i = screenlog.log.mine.length-1; i >= 0; i--) {
|
||||
var entry = screenlog.mine.log[i];
|
||||
if (entry.time <= lastsend) {
|
||||
break;
|
||||
}
|
||||
l.unshift(entry);
|
||||
}
|
||||
if (l.length == 0) {
|
||||
return;
|
||||
}
|
||||
var obj = {
|
||||
url: 'http://shop.mistserver.org/demo?store',
|
||||
data: {
|
||||
serverurl: mist.user.host,
|
||||
data: JSON.stringify(l)
|
||||
},
|
||||
method: 'POST',
|
||||
error: function(){
|
||||
|
||||
},
|
||||
success: function(d){
|
||||
lastsend = d;
|
||||
}
|
||||
};
|
||||
log('[screenlog]','Send:',l);
|
||||
var http = $.ajax(obj);
|
||||
}
|
||||
setInterval(sendlog,2e3)
|
||||
|
||||
},
|
||||
slave: function(sid,token){
|
||||
|
||||
var lastgotten = 0;
|
||||
function getlog() {
|
||||
var obj = {
|
||||
url: 'http://shop.mistserver.org/demo',
|
||||
data: {
|
||||
read: sid,
|
||||
token: token,
|
||||
from: lastgotten
|
||||
},
|
||||
method: 'POST',
|
||||
error: function(){
|
||||
|
||||
},
|
||||
success: function(d){
|
||||
var newlog = JSON.parse(d);
|
||||
|
||||
if ('error' in newlog) {
|
||||
log('[screenlog]','error',newlog);
|
||||
return;
|
||||
}
|
||||
|
||||
if (newlog.length == 0) { return; }
|
||||
|
||||
log('[screenlog]','Receive:',newlog);
|
||||
|
||||
if (lastgotten == 0) {
|
||||
var d = {blur:[]};
|
||||
var done = false;
|
||||
for (var i = newlog.length-1; i>=0; i--) {
|
||||
var entry = newlog[i];
|
||||
switch (entry.type) {
|
||||
case 'mousepos':
|
||||
case 'focus':
|
||||
if (entry.type in d) {
|
||||
break;
|
||||
}
|
||||
d[entry.type] = entry;
|
||||
break;
|
||||
case 'blur':
|
||||
d.blur.unshift(entry);
|
||||
break;
|
||||
case 'tab':
|
||||
d[entry.type] = entry;
|
||||
done = true;
|
||||
break;
|
||||
}
|
||||
if (done) { break; }
|
||||
}
|
||||
for (var i in d) {
|
||||
if (i == 'blur') {
|
||||
for (var j in d[i]) {
|
||||
playentry(d[i][j]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
playentry(d[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
playlog(newlog);
|
||||
}
|
||||
screenlog.log.theirs = screenlog.log.theirs.concat(newlog);
|
||||
|
||||
var amount = 50; //how many entries should be shown in the onscreen log
|
||||
var show = newlog.slice(-1*amount);
|
||||
for (var i in show) {
|
||||
var entry = show[i];
|
||||
var d = $.extend({},entry);
|
||||
delete d.time; delete d.type; delete d.tab;
|
||||
UI.elements.screenlog.append(
|
||||
$('<div>').addClass('entry').text(
|
||||
'['+UI.format.time(entry.time/1e3)+'] '+entry.type+' '+JSON.stringify(d)+' @ '+entry.tab
|
||||
)
|
||||
);
|
||||
}
|
||||
$entries = UI.elements.screenlog.children('.entry');
|
||||
if ($entries.length > amount) {
|
||||
$entries.slice(0,$entries.length-amount).remove();
|
||||
}
|
||||
UI.elements.screenlog.scrollTop(UI.elements.screenlog[0].scrollHeight);
|
||||
|
||||
lastgotten = newlog[newlog.length-1].time;
|
||||
}
|
||||
};
|
||||
var http = $.ajax(obj);
|
||||
}
|
||||
|
||||
this.elements.cursor = $('<div>').attr('id','cursor');
|
||||
$('body').append(this.elements.cursor);
|
||||
UI.elements.screenlog = $('<div>').attr('id','screenlog');
|
||||
UI.elements.menu.before(UI.elements.screenlog);
|
||||
|
||||
|
||||
getlog();
|
||||
setInterval(getlog,2e3);
|
||||
|
||||
|
||||
function playlog(l) {
|
||||
var delay = 0;
|
||||
for (var i in l) {
|
||||
if (i != 0) {
|
||||
delay = l[i].time - l[i-1].time;
|
||||
}
|
||||
setTimeout(playentry(l[i]),delay);
|
||||
}
|
||||
}
|
||||
function playentry(entry){
|
||||
switch (entry.type) {
|
||||
case 'mousepos':
|
||||
screenlog.elements.cursor.animate({
|
||||
'left': entry.pos.x+'px',
|
||||
'top': entry.pos.y+'px'
|
||||
},0.5e3);
|
||||
break;
|
||||
case 'focus':
|
||||
$('.field.hasFocus').removeClass('hasFocus');
|
||||
$('.field[name="'+entry.element+'"]').addClass('hasFocus');
|
||||
break;
|
||||
case 'blur':
|
||||
$('.field.hasChanged').removeClass('hasChanged');
|
||||
$('.field[name="'+entry.element+'"]').setval(entry.val).addClass('hasChanged').removeClass('hasFocus');
|
||||
break;
|
||||
case 'tab':
|
||||
location.hash = location.hash.split('@')[0] + '@' + entry.tab;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
log: {
|
||||
mine: [],
|
||||
theirs: []
|
||||
},
|
||||
elements: {}
|
||||
};
|
|
@ -12,6 +12,7 @@
|
|||
<script src='plugins/jquery.flot.min.js'></script>
|
||||
<script src='plugins/jquery.flot.time.min.js'></script>
|
||||
<script src='plugins/jquery.qrcode.min.js'></script>
|
||||
<script src='plugins/screenlog.js'></script>
|
||||
<script src='mist.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
|
|
Loading…
Add table
Reference in a new issue