LSP: fixed missing wildcard streams on stream page
This commit is contained in:
parent
e309d0358c
commit
ac914b7b95
2 changed files with 94 additions and 89 deletions
157
lsp/minified.js
157
lsp/minified.js
|
@ -1,10 +1,10 @@
|
|||
var MD5=function(a){function b(a,b){var c,d,g,f,i;g=a&2147483648;f=b&2147483648;c=a&1073741824;d=b&1073741824;i=(a&1073741823)+(b&1073741823);return c&d?i^2147483648^g^f:c|d?i&1073741824?i^3221225472^g^f:i^1073741824^g^f:i^g^f}function c(a,c,d,g,f,i,j){a=b(a,b(b(c&d|~c&g,f),j));return b(a<<i|a>>>32-i,c)}function d(a,c,d,g,f,i,j){a=b(a,b(b(c&g|d&~g,f),j));return b(a<<i|a>>>32-i,c)}function e(a,c,d,g,f,i,j){a=b(a,b(b(c^d^g,f),j));return b(a<<i|a>>>32-i,c)}function l(a,c,d,g,f,i,j){a=b(a,b(b(d^(c|~g),
|
||||
f),j));return b(a<<i|a>>>32-i,c)}function n(a){var b="",c="",d;for(d=0;3>=d;d++)c=a>>>8*d&255,c="0"+c.toString(16),b+=c.substr(c.length-2,2);return b}var h=[],q,p,f,t,g,i,j,k,h=a.replace(/\r\n/g,"\n"),a="";for(q=0;q<h.length;q++)p=h.charCodeAt(q),128>p?a+=String.fromCharCode(p):(127<p&&2048>p?a+=String.fromCharCode(p>>6|192):(a+=String.fromCharCode(p>>12|224),a+=String.fromCharCode(p>>6&63|128)),a+=String.fromCharCode(p&63|128));h=a;a=h.length;q=a+8;p=16*((q-q%64)/64+1);f=Array(p-1);for(g=t=0;g<a;)q=
|
||||
(g-g%4)/4,t=8*(g%4),f[q]|=h.charCodeAt(g)<<t,g++;q=(g-g%4)/4;f[q]|=128<<8*(g%4);f[p-2]=a<<3;f[p-1]=a>>>29;h=f;g=1732584193;i=4023233417;j=2562383102;k=271733878;for(a=0;a<h.length;a+=16)q=g,p=i,f=j,t=k,g=c(g,i,j,k,h[a+0],7,3614090360),k=c(k,g,i,j,h[a+1],12,3905402710),j=c(j,k,g,i,h[a+2],17,606105819),i=c(i,j,k,g,h[a+3],22,3250441966),g=c(g,i,j,k,h[a+4],7,4118548399),k=c(k,g,i,j,h[a+5],12,1200080426),j=c(j,k,g,i,h[a+6],17,2821735955),i=c(i,j,k,g,h[a+7],22,4249261313),g=c(g,i,j,k,h[a+8],7,1770035416),
|
||||
f),j));return b(a<<i|a>>>32-i,c)}function n(a){var b="",c="",d;for(d=0;3>=d;d++)c=a>>>8*d&255,c="0"+c.toString(16),b+=c.substr(c.length-2,2);return b}var h=[],q,p,f,v,g,i,j,k,h=a.replace(/\r\n/g,"\n"),a="";for(q=0;q<h.length;q++)p=h.charCodeAt(q),128>p?a+=String.fromCharCode(p):(127<p&&2048>p?a+=String.fromCharCode(p>>6|192):(a+=String.fromCharCode(p>>12|224),a+=String.fromCharCode(p>>6&63|128)),a+=String.fromCharCode(p&63|128));h=a;a=h.length;q=a+8;p=16*((q-q%64)/64+1);f=Array(p-1);for(g=v=0;g<a;)q=
|
||||
(g-g%4)/4,v=8*(g%4),f[q]|=h.charCodeAt(g)<<v,g++;q=(g-g%4)/4;f[q]|=128<<8*(g%4);f[p-2]=a<<3;f[p-1]=a>>>29;h=f;g=1732584193;i=4023233417;j=2562383102;k=271733878;for(a=0;a<h.length;a+=16)q=g,p=i,f=j,v=k,g=c(g,i,j,k,h[a+0],7,3614090360),k=c(k,g,i,j,h[a+1],12,3905402710),j=c(j,k,g,i,h[a+2],17,606105819),i=c(i,j,k,g,h[a+3],22,3250441966),g=c(g,i,j,k,h[a+4],7,4118548399),k=c(k,g,i,j,h[a+5],12,1200080426),j=c(j,k,g,i,h[a+6],17,2821735955),i=c(i,j,k,g,h[a+7],22,4249261313),g=c(g,i,j,k,h[a+8],7,1770035416),
|
||||
k=c(k,g,i,j,h[a+9],12,2336552879),j=c(j,k,g,i,h[a+10],17,4294925233),i=c(i,j,k,g,h[a+11],22,2304563134),g=c(g,i,j,k,h[a+12],7,1804603682),k=c(k,g,i,j,h[a+13],12,4254626195),j=c(j,k,g,i,h[a+14],17,2792965006),i=c(i,j,k,g,h[a+15],22,1236535329),g=d(g,i,j,k,h[a+1],5,4129170786),k=d(k,g,i,j,h[a+6],9,3225465664),j=d(j,k,g,i,h[a+11],14,643717713),i=d(i,j,k,g,h[a+0],20,3921069994),g=d(g,i,j,k,h[a+5],5,3593408605),k=d(k,g,i,j,h[a+10],9,38016083),j=d(j,k,g,i,h[a+15],14,3634488961),i=d(i,j,k,g,h[a+4],20,3889429448),
|
||||
g=d(g,i,j,k,h[a+9],5,568446438),k=d(k,g,i,j,h[a+14],9,3275163606),j=d(j,k,g,i,h[a+3],14,4107603335),i=d(i,j,k,g,h[a+8],20,1163531501),g=d(g,i,j,k,h[a+13],5,2850285829),k=d(k,g,i,j,h[a+2],9,4243563512),j=d(j,k,g,i,h[a+7],14,1735328473),i=d(i,j,k,g,h[a+12],20,2368359562),g=e(g,i,j,k,h[a+5],4,4294588738),k=e(k,g,i,j,h[a+8],11,2272392833),j=e(j,k,g,i,h[a+11],16,1839030562),i=e(i,j,k,g,h[a+14],23,4259657740),g=e(g,i,j,k,h[a+1],4,2763975236),k=e(k,g,i,j,h[a+4],11,1272893353),j=e(j,k,g,i,h[a+7],16,4139469664),
|
||||
i=e(i,j,k,g,h[a+10],23,3200236656),g=e(g,i,j,k,h[a+13],4,681279174),k=e(k,g,i,j,h[a+0],11,3936430074),j=e(j,k,g,i,h[a+3],16,3572445317),i=e(i,j,k,g,h[a+6],23,76029189),g=e(g,i,j,k,h[a+9],4,3654602809),k=e(k,g,i,j,h[a+12],11,3873151461),j=e(j,k,g,i,h[a+15],16,530742520),i=e(i,j,k,g,h[a+2],23,3299628645),g=l(g,i,j,k,h[a+0],6,4096336452),k=l(k,g,i,j,h[a+7],10,1126891415),j=l(j,k,g,i,h[a+14],15,2878612391),i=l(i,j,k,g,h[a+5],21,4237533241),g=l(g,i,j,k,h[a+12],6,1700485571),k=l(k,g,i,j,h[a+3],10,2399980690),
|
||||
j=l(j,k,g,i,h[a+10],15,4293915773),i=l(i,j,k,g,h[a+1],21,2240044497),g=l(g,i,j,k,h[a+8],6,1873313359),k=l(k,g,i,j,h[a+15],10,4264355552),j=l(j,k,g,i,h[a+6],15,2734768916),i=l(i,j,k,g,h[a+13],21,1309151649),g=l(g,i,j,k,h[a+4],6,4149444226),k=l(k,g,i,j,h[a+11],10,3174756917),j=l(j,k,g,i,h[a+2],15,718787259),i=l(i,j,k,g,h[a+9],21,3951481745),g=b(g,q),i=b(i,p),j=b(j,f),k=b(k,t);return(n(g)+n(i)+n(j)+n(k)).toLowerCase()};(function(a){a.fn.stupidtable=function(){a(this).on("click","thead th",function(){a(this).stupidsort()})};a.fn.stupidsort=function(){function b(b){var c=0,d;a(b).children("td,th").each(function(){if(c==q)return d=a(this),!1;var b=a(this).attr("colspan");c+=b?Number(b):1});b="undefined"!=typeof d.data("sort-value")?d.data("sort-value"):"undefined"!=typeof d.attr("data-sort-value")?d.attr("data-sort-value"):d.text();switch(n){case "string":case "string-ins":b=String(b).toLowerCase();break;case "int":b=
|
||||
j=l(j,k,g,i,h[a+10],15,4293915773),i=l(i,j,k,g,h[a+1],21,2240044497),g=l(g,i,j,k,h[a+8],6,1873313359),k=l(k,g,i,j,h[a+15],10,4264355552),j=l(j,k,g,i,h[a+6],15,2734768916),i=l(i,j,k,g,h[a+13],21,1309151649),g=l(g,i,j,k,h[a+4],6,4149444226),k=l(k,g,i,j,h[a+11],10,3174756917),j=l(j,k,g,i,h[a+2],15,718787259),i=l(i,j,k,g,h[a+9],21,3951481745),g=b(g,q),i=b(i,p),j=b(j,f),k=b(k,v);return(n(g)+n(i)+n(j)+n(k)).toLowerCase()};(function(a){a.fn.stupidtable=function(){a(this).on("click","thead th",function(){a(this).stupidsort()})};a.fn.stupidsort=function(){function b(b){var c=0,d;a(b).children("td,th").each(function(){if(c==q)return d=a(this),!1;var b=a(this).attr("colspan");c+=b?Number(b):1});b="undefined"!=typeof d.data("sort-value")?d.data("sort-value"):"undefined"!=typeof d.attr("data-sort-value")?d.attr("data-sort-value"):d.text();switch(n){case "string":case "string-ins":b=String(b).toLowerCase();break;case "int":b=
|
||||
parseInt(Number(b));break;case "float":b=Number(b)}return b}var c=a(this),d=c.closest("table"),e=d.children("tbody"),l=e.children("tr"),n=c.attr("data-sort-type");if(n){var h=!0;c.hasClass("sorting-asc")&&(h=!1);var q=0;c.prevAll().each(function(){var b=a(this).attr("colspan");q+=b?Number(b):1});l.sort(function(a,c){var d=h?1:-1,a=b(a),c=b(c);return a>c?1*d:a<c?-1*d:0});e.append(l);d.find("thead th").removeClass("sorting-asc").removeClass("sorting-desc");c.addClass(h?"sorting-asc":"sorting-desc")}}})(jQuery);$(function(){UI.elements={menu:$("nav > .menu"),main:$("main"),header:$("header"),connection:{status:$("#connection"),user_and_host:$("#user_and_host"),msg:$("#message")}};UI.buildMenu();UI.stored.getOpts();try{if("mistLogin"in sessionStorage){var a=JSON.parse(sessionStorage.mistLogin);mist.user.name=a.name;mist.user.password=a.password;mist.user.host=a.host}}catch(b){}location.hash&&(a=decodeURIComponent(location.hash).substring(1).split("@")[0].split("&"),mist.user.name=a[0],a[1]&&(mist.user.host=
|
||||
a[1]));mist.send(function(){$(window).trigger("hashchange")},{},{timeout:5,hide:!0});var c=0;$("body > div.filler").on("scroll",function(){var a=$(this).scrollLeft();a!=c&&UI.elements.header.css("margin-right",-1*a+"px");c=a})});$(window).on("hashchange",function(){var a=decodeURIComponent(location.hash).substring(1).split("@");a[1]||(a[1]="");a=a[1].split("&");""==a[0]&&(a[0]="Overview");UI.showTab(a[0],a[1])});
|
||||
var otherhost=!1,UI={debug:!1,elements:{},stored:{getOpts:function(){var a=localStorage.stored;a&&(a=JSON.parse(a));$.extend(!0,this.vars,a);return this.vars},saveOpt:function(a,b){this.vars[a]=b;localStorage.stored=JSON.stringify(this.vars);return this.vars},vars:{helpme:!0}},interval:{clear:function(){"undefined"!=typeof this.opts&&(clearInterval(this.opts.id),delete this.opts)},set:function(a,b){this.opts&&log("[interval]","Set called on interval, but an interval is already active.");this.opts=
|
||||
|
@ -35,8 +35,8 @@ typeof d.checklist[c]&&(d.checklist[c]=[d.checklist[c],d.checklist[c]]),$checkli
|
|||
d&&e.attr("placeholder",d["default"]);"unit"in d&&h.append($("<span>").addClass("unit").html(d.unit));"readonly"in d&&(e.attr("readonly","readonly"),e.click(function(){$(this).select()}));"qrcode"in d&&h.append($("<span>").addClass("unit").html($("<button>").text("QR").on("keydown",function(a){a.stopPropagation()}).click(function(){var a=String($(this).closest(".field_container").find(".field").getval()),b=$("<div>").addClass("qrcode");UI.popup.show($("<span>").addClass("qr_container").append($("<p>").text(a)).append(b));
|
||||
b.qrcode({text:a,size:Math.min(b.width(),b.height())})})));"clipboard"in d&&document.queryCommandSupported("copy")&&h.append($("<span>").addClass("unit").html($("<button>").text("Copy").on("keydown",function(a){a.stopPropagation()}).click(function(){var a=String($(this).closest(".field_container").find(".field").getval()),b=document.createElement("textarea");b.value=a;document.body.appendChild(b);b.select();var c=false;try{c=document.execCommand("copy")}catch(d){}if(c){$(this).text("Copied to clipboard!");
|
||||
document.body.removeChild(b);var f=$(this);setTimeout(function(){f.text("Copy")},5E3)}else{document.body.removeChild(b);alert("Failed to copy:\n"+a)}})));"rows"in d&&e.attr("rows",d.rows);"LTSonly"in d&&!mist.data.LTS&&(h.addClass("LTSonly"),e.prop("disabled",!0));switch(d.type){case "browse":f=$("<div>").addClass("grouper").append(n);b.append(f);f=$("<button>").text("Browse").on("keydown",function(a){a.stopPropagation()});h.append(f);f.click(function(){function a(b){n.text("Loading..");mist.send(function(a){e.text(a.browse.path[0]);
|
||||
mist.data.LTS&&d.setval(a.browse.path[0]+"/");n.html(l.clone(true).text("..").attr("title","Folder up"));if(a.browse.subdirectories){a.browse.subdirectories.sort();for(var b in a.browse.subdirectories){var g=a.browse.subdirectories[b];n.append(l.clone(true).attr("title",e.text()+q+g).text(g))}}if(a.browse.files){a.browse.files.sort();for(b in a.browse.files){var g=a.browse.files[b],h=e.text()+q+g,g=$("<a>").text(g).addClass("file").attr("title",h);n.append(g);if(p){var t=true,E;for(E in p)if(typeof p[E]!=
|
||||
"undefined"&&mist.inputMatch(p[E],h)){t=false;break}t&&g.hide()}g.click(function(){var a=$(this).attr("title");d.setval(a).removeAttr("readonly").css("opacity",1);f.show();c.remove()})}}},{browse:b})}var b=$(this).closest(".grouper"),c=$("<div>").addClass("browse_container"),d=b.find(".field").attr("readonly","readonly").css("opacity",0.5),f=$(this),h=$("<button>").text("Stop browsing").click(function(){f.show();c.remove();d.removeAttr("readonly").css("opacity",1)}),e=$("<span>").addClass("field"),
|
||||
mist.data.LTS&&d.setval(a.browse.path[0]+"/");n.html(l.clone(true).text("..").attr("title","Folder up"));if(a.browse.subdirectories){a.browse.subdirectories.sort();for(var b in a.browse.subdirectories){var g=a.browse.subdirectories[b];n.append(l.clone(true).attr("title",e.text()+q+g).text(g))}}if(a.browse.files){a.browse.files.sort();for(b in a.browse.files){var g=a.browse.files[b],h=e.text()+q+g,g=$("<a>").text(g).addClass("file").attr("title",h);n.append(g);if(p){var v=true,r;for(r in p)if(typeof p[r]!=
|
||||
"undefined"&&mist.inputMatch(p[r],h)){v=false;break}v&&g.hide()}g.click(function(){var a=$(this).attr("title");d.setval(a).removeAttr("readonly").css("opacity",1);f.show();c.remove()})}}},{browse:b})}var b=$(this).closest(".grouper"),c=$("<div>").addClass("browse_container"),d=b.find(".field").attr("readonly","readonly").css("opacity",0.5),f=$(this),h=$("<button>").text("Stop browsing").click(function(){f.show();c.remove();d.removeAttr("readonly").css("opacity",1)}),e=$("<span>").addClass("field"),
|
||||
n=$("<div>").addClass("browse_contents"),l=$("<a>").addClass("folder"),p=d.data("filetypes");b.append(c);c.append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Current folder:")).append($("<span>").addClass("field_container").append(e).append(h))).append(n);var q="/";mist.data.config.version.indexOf("indows")>-1&&(q="\\");l.click(function(){var b=e.text()+q+$(this).text();a(b)});b=d.getval();h=b.split("://");h.length>1&&(b=h[0]=="file"?h[1]:"");b=b.split(q);b.pop();
|
||||
b=b.join(q);f.hide();a(b)});break;case "geolimited":case "hostlimited":f={field:e};f.blackwhite=$("<select>").append($("<option>").val("-").text("Blacklist")).append($("<option>").val("+").text("Whitelist"));f.values=$("<span>").addClass("limit_value_list");switch(d.type){case "geolimited":f.prototype=$("<select>").append($("<option>").val("").text("[Select a country]"));for(c in UI.countrylist)f.prototype.append($("<option>").val(c).html(UI.countrylist[c]));break;case "hostlimited":f.prototype=$("<input>").attr("type",
|
||||
"text").attr("placeholder","type a host")}f.prototype.on("change keyup",function(){$(this).closest(".field_container").data("subUI").blackwhite.trigger("change")});f.blackwhite.change(function(){var a=$(this).closest(".field_container").data("subUI"),b=[],c=false;a.values.children().each(function(){c=$(this).val();c!=""?b.push(c):$(this).remove()});a.values.append(a.prototype.clone(true));b.length>0?a.field.val($(this).val()+b.join(" ")):a.field.val("");a.field.trigger("change")});"LTSonly"in d&&
|
||||
|
@ -50,12 +50,12 @@ function(a){switch(a.which){case 13:$(this).find("button.save").first().trigger(
|
|||
b.append(c.elements.cont);return c},go:function(a){if(!(1>Object.keys(a).length)){var b={totals:[],clients:[]},c;for(c in a)for(var d in a[c].datasets){var e=a[c].datasets[d];switch(e.datatype){case "clients":case "upbps":case "downbps":switch(e.origin[0]){case "total":b.totals.push({fields:[e.datatype],end:-15});break;case "stream":b.totals.push({fields:[e.datatype],streams:[e.origin[1]],end:-15});break;case "protocol":b.totals.push({fields:[e.datatype],protocols:[e.origin[1]],end:-15})}break;case "cpuload":case "memload":b.capabilities=
|
||||
{}}}0==b.totals.length&&delete b.totals;0==b.clients.length&&delete b.clients;mist.send(function(){for(var b in a){var c=a[b];if(1>c.datasets.length){c.elements.plot.html("");c.elements.legend.html("");break}switch(c.xaxis){case "time":var d=[];c.yaxes={};var e=[],p;for(p in c.datasets){var f=c.datasets[p];f.display&&(f.getdata(),f.yaxistype in c.yaxes||(d.push(UI.plot.yaxes[f.yaxistype]),c.yaxes[f.yaxistype]=d.length),f.yaxis=c.yaxes[f.yaxistype],e.push(f))}d[0]&&(d[0].color=0);c.plot=$.plot(c.elements.plot,
|
||||
e,{legend:{show:!1},xaxis:UI.plot.xaxes[c.xaxis],yaxes:d,grid:{hoverable:!0,borderWidth:{top:0,right:0,bottom:1,left:1},color:"black",backgroundColor:{colors:["rgba(0,0,0,0)","rgba(0,0,0,0.025)"]}},crosshair:{mode:"x"}});d=$("<table>").addClass("legend-list").addClass("nolay").html($("<tr>").html($("<td>").html($("<h3>").text(c.id))).append($("<td>").css("padding-right","2em").css("text-align","right").html($("<span>").addClass("value")).append($("<button>").data("opts",c).text("X").addClass("close").click(function(){var b=
|
||||
$(this).data("opts");if(confirm("Are you sure you want to remove "+b.id+"?")){b.elements.cont.remove();var c=$(".graph_ids option:contains("+b.id+")"),d=c.parent();c.remove();UI.plot.del(b.id);delete a[b.id];d.trigger("change");UI.plot.go(a)}}))));c.elements.legend.html(d);var t=function(a){var b=c.elements.legend.find(".value"),d=1;if(typeof a=="undefined")b.eq(0).html("Latest:");else{var f=c.plot.getXAxes()[0],a=Math.min(f.max,a),a=Math.max(f.min,a);b.eq(0).html(UI.format.time(a/1E3))}for(var e in c.datasets){var g=
|
||||
$(this).data("opts");if(confirm("Are you sure you want to remove "+b.id+"?")){b.elements.cont.remove();var c=$(".graph_ids option:contains("+b.id+")"),d=c.parent();c.remove();UI.plot.del(b.id);delete a[b.id];d.trigger("change");UI.plot.go(a)}}))));c.elements.legend.html(d);var v=function(a){var b=c.elements.legend.find(".value"),d=1;if(typeof a=="undefined")b.eq(0).html("Latest:");else{var f=c.plot.getXAxes()[0],a=Math.min(f.max,a),a=Math.max(f.min,a);b.eq(0).html(UI.format.time(a/1E3))}for(var e in c.datasets){var g=
|
||||
" ";if(c.datasets[e].display){var f=UI.plot.yaxes[c.datasets[e].yaxistype].tickFormatter,h=c.datasets[e].data;if(a)for(var l in h){if(h[l][0]==a){g=f(h[l][1]);break}if(h[l][0]>a){if(l!=0){g=h[l];h=h[l-1];g=f(g[1]+(a-g[0])*(h[1]-g[1])/(h[0]-g[0]))}break}}else g=f(c.datasets[e].data[c.datasets[e].data.length-1][1])}b.eq(d).html(g);d++}};c.plot.getOptions();for(p in c.datasets)e=$("<input>").attr("type","checkbox").data("index",p).data("graph",c).click(function(){var a=$(this).data("graph");$(this).is(":checked")?
|
||||
a.datasets[$(this).data("index")].display=true:a.datasets[$(this).data("index")].display=false;var b={};b[a.id]=a;UI.plot.go(b)}),c.datasets[p].display&&e.attr("checked","checked"),d.append($("<tr>").html($("<td>").html($("<label>").html(e).append($("<div>").addClass("series-color").css("background-color",c.datasets[p].color)).append(c.datasets[p].label))).append($("<td>").css("padding-right","2em").css("text-align","right").html($("<span>").addClass("value")).append($("<button>").text("X").addClass("close").data("index",
|
||||
p).data("graph",c).click(function(){var b=$(this).data("index"),c=$(this).data("graph");if(confirm("Are you sure you want to remove "+c.datasets[b].label+" from "+c.id+"?")){c.datasets.splice(b,1);if(c.datasets.length==0){c.elements.cont.remove();var b=$(".graph_ids option:contains("+c.id+")"),d=b.parent();b.remove();d.trigger("change");UI.plot.del(c.id);delete a[c.id];UI.plot.go(a)}else{UI.plot.save(c);b={};b[c.id]=c;UI.plot.go(b)}}}))));t();var g=!1;c.elements.plot.on("plothover",function(a,b,c){if(b.x!=
|
||||
g){t(b.x);g=b.x}if(c){a=$("<span>").append($("<h3>").text(c.series.label).prepend($("<div>").addClass("series-color").css("background-color",c.series.color))).append($("<table>").addClass("nolay").html($("<tr>").html($("<td>").text("Time:")).append($("<td>").html(UI.format.dateTime(c.datapoint[0]/1E3,"long")))).append($("<tr>").html($("<td>").text("Value:")).append($("<td>").html(c.series.yaxis.tickFormatter(c.datapoint[1],c.series.yaxis)))));UI.tooltip.show(b,a.children())}else UI.tooltip.hide()}).on("mouseout",
|
||||
function(){t()})}}},b)}},save:function(a){var b={id:a.id,xaxis:a.xaxis,datasets:[]},c;for(c in a.datasets)b.datasets.push({origin:a.datasets[c].origin,datatype:a.datasets[c].datatype});a=mist.stored.get().graphs||{};a[b.id]=b;mist.stored.set("graphs",a)},del:function(a){var b=mist.stored.get().graphs||{};delete b[a];mist.stored.set("graphs",b)},datatype:{getOptions:function(a){var b=$.extend(!0,{},UI.plot.datatype.templates.general),c=$.extend(!0,{},UI.plot.datatype.templates[a.datatype]),a=$.extend(!0,
|
||||
p).data("graph",c).click(function(){var b=$(this).data("index"),c=$(this).data("graph");if(confirm("Are you sure you want to remove "+c.datasets[b].label+" from "+c.id+"?")){c.datasets.splice(b,1);if(c.datasets.length==0){c.elements.cont.remove();var b=$(".graph_ids option:contains("+c.id+")"),d=b.parent();b.remove();d.trigger("change");UI.plot.del(c.id);delete a[c.id];UI.plot.go(a)}else{UI.plot.save(c);b={};b[c.id]=c;UI.plot.go(b)}}}))));v();var g=!1;c.elements.plot.on("plothover",function(a,b,c){if(b.x!=
|
||||
g){v(b.x);g=b.x}if(c){a=$("<span>").append($("<h3>").text(c.series.label).prepend($("<div>").addClass("series-color").css("background-color",c.series.color))).append($("<table>").addClass("nolay").html($("<tr>").html($("<td>").text("Time:")).append($("<td>").html(UI.format.dateTime(c.datapoint[0]/1E3,"long")))).append($("<tr>").html($("<td>").text("Value:")).append($("<td>").html(c.series.yaxis.tickFormatter(c.datapoint[1],c.series.yaxis)))));UI.tooltip.show(b,a.children())}else UI.tooltip.hide()}).on("mouseout",
|
||||
function(){v()})}}},b)}},save:function(a){var b={id:a.id,xaxis:a.xaxis,datasets:[]},c;for(c in a.datasets)b.datasets.push({origin:a.datasets[c].origin,datatype:a.datasets[c].datatype});a=mist.stored.get().graphs||{};a[b.id]=b;mist.stored.set("graphs",a)},del:function(a){var b=mist.stored.get().graphs||{};delete b[a];mist.stored.set("graphs",b)},datatype:{getOptions:function(a){var b=$.extend(!0,{},UI.plot.datatype.templates.general),c=$.extend(!0,{},UI.plot.datatype.templates[a.datatype]),a=$.extend(!0,
|
||||
c,a),a=$.extend(!0,b,a);switch(a.origin[0]){case "total":switch(a.datatype){case "cpuload":case "memload":break;default:a.label+=" (total)"}break;case "stream":case "protocol":a.label+=" ("+a.origin[1]+")"}var b=[],d;for(d in a.basecolor)c=a.basecolor[d],c+=50*(0.5-Math.random()),c=Math.round(c),c=Math.min(255,Math.max(0,c)),b.push(c);a.color="rgb("+b.join(",")+")";return a},templates:{general:{display:!0,datatype:"general",label:"",yaxistype:"amount",data:[],lines:{show:!0},points:{show:!1},getdata:function(){var a=
|
||||
mist.data.totals["stream"==this.origin[0]?this.origin[1]:"all_streams"]["protocol"==this.origin[0]?this.origin[1]:"all_protocols"][this.datatype];return this.data=a}},cpuload:{label:"CPU use",yaxistype:"percentage",basecolor:[237,194,64],cores:1,getdata:function(){var a=!1,b;for(b in this.data)this.data[b][0]<1E3*(mist.data.config.time-600)&&(a=b);!1!==a&&this.data.splice(0,Number(a)+1);this.data.push([1E3*mist.data.config.time,mist.data.capabilities.cpu_use/10]);return this.data}},memload:{label:"Memory load",
|
||||
yaxistype:"percentage",basecolor:[175,216,248],getdata:function(){var a=!1,b;for(b in this.data)this.data[b][0]<1E3*(mist.data.config.time-600)&&(a=b);!1!==a&&this.data.splice(0,Number(a)+1);this.data.push([1E3*mist.data.config.time,mist.data.capabilities.load.memory]);return this.data}},clients:{label:"Connections",basecolor:[203,75,75]},upbps:{label:"Bandwidth up",yaxistype:"bytespersec",basecolor:[77,167,77]},downbps:{label:"Bandwidth down",yaxistype:"bytespersec",basecolor:[148,64,237]}}},yaxes:{percentage:{name:"percentage",
|
||||
|
@ -78,78 +78,79 @@ d+'".<br>')}c.append("Saving protocol settings..<br>");mist.send(function(){c.ap
|
|||
{type:"span",label:"Version",pointer:{main:mist.data.config,index:"version"}},{type:"span",label:"Version check",value:e,LTSonly:!0},{type:"span",label:"Server time",value:h},{type:"span",label:"Current streams",value:l},{type:"span",label:"Current connections",value:n},$("<br>"),{type:"str",label:"Human readable name",pointer:{main:mist.data.config,index:"name"},help:"You can name your MistServer here for personal use. You'll still need to set host name within your network yourself."},{type:"debug",
|
||||
label:"Debug level",pointer:{main:mist.data.config,index:"debug"},help:"You can set the amount of debug information MistServer saves in the log. A full reboot of MistServer is required before some components of MistServer can post debug information."},{type:"checkbox",label:"Force configurations save",pointer:{main:mist.data,index:"save"},help:"Tick the box in order to force an immediate save to the config.json MistServer uses to save your settings. Saving will otherwise happen upon closing MistServer. Don't forget to press save after ticking the box."},
|
||||
{type:"buttons",buttons:[{type:"save",label:"Save","function":function(){var a={config:mist.data.config};if(mist.data.save)a.save=mist.data.save;mist.send(function(){UI.navto("Overview")},a)}}]}]));if(mist.data.LTS){var q=function(){var a=mist.stored.get().update||{};"uptodate"in a?a.error?e.addClass("red").text(a.error):a.uptodate?e.text("Your version is up to date.").addClass("green"):e.addClass("red").text("Version outdated!").append($("<button>").text("Update").css({"font-size":"1em","margin-left":"1em"}).click(function(){if(confirm("Are you sure you want to execute a rolling update?")){e.addClass("orange").removeClass("red").text("Rolling update command sent..");
|
||||
mist.stored.del("update");mist.send(function(){UI.navto("Overview")},{autoupdate:true})}})):e.text("Unknown")};if(!mist.stored.get().update||36E5<(new Date).getTime()-mist.stored.get().update.lastchecked){var p=mist.stored.get().update||{};p.lastchecked=(new Date).getTime();mist.send(function(a){mist.stored.set("update",$.extend(true,p,a.update));q()},{checkupdate:!0})}else q()}else e.text("");var f=function(){mist.send(function(){t()},{totals:{fields:["clients"],start:-10},active_streams:true})},
|
||||
t=function(){l.text(("active_streams"in mist.data?mist.data.active_streams?mist.data.active_streams.length:0:"?")+" active, "+(mist.data.streams?Object.keys(mist.data.streams).length:0)+" configured");if("totals"in mist.data&&"all_streams"in mist.data.totals)var a=mist.data.totals.all_streams.all_protocols.clients,a=a.length?UI.format.number(a[a.length-1][1]):0;else a="Loading..";n.text(a);h.text(UI.format.dateTime(mist.data.config.time,"long"))};f();t();UI.interval.set(f,3E4);break;case "Protocols":if("undefined"==
|
||||
mist.stored.del("update");mist.send(function(){UI.navto("Overview")},{autoupdate:true})}})):e.text("Unknown")};if(!mist.stored.get().update||36E5<(new Date).getTime()-mist.stored.get().update.lastchecked){var p=mist.stored.get().update||{};p.lastchecked=(new Date).getTime();mist.send(function(a){mist.stored.set("update",$.extend(true,p,a.update));q()},{checkupdate:!0})}else q()}else e.text("");var f=function(){mist.send(function(){v()},{totals:{fields:["clients"],start:-10},active_streams:true})},
|
||||
v=function(){l.text(("active_streams"in mist.data?mist.data.active_streams?mist.data.active_streams.length:0:"?")+" active, "+(mist.data.streams?Object.keys(mist.data.streams).length:0)+" configured");if("totals"in mist.data&&"all_streams"in mist.data.totals)var a=mist.data.totals.all_streams.all_protocols.clients,a=a.length?UI.format.number(a[a.length-1][1]):0;else a="Loading..";n.text(a);h.text(UI.format.dateTime(mist.data.config.time,"long"))};f();v();UI.interval.set(f,3E4);break;case "Protocols":if("undefined"==
|
||||
typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});c.append("Loading..");break}var g=$("<tbody>");c.append(UI.buildUI([{type:"help",help:"You can find an overview of all the protocols and their relevant information here. You can add, edit or delete protocols."}])).append($("<button>").text("New protocol").click(function(){UI.navto("Edit Protocol")})).append($("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Protocol")).append($("<th>").text("Status")).append($("<th>").text("Settings")).append($("<th>")))).append(g));
|
||||
var i=function(){function a(b){var c=mist.data.capabilities.connectors[b.connector];if(!c)return"";var d=[],f=["required","optional"],g;for(g in f)for(var e in c[f[g]])b[e]&&b[e]!=""?d.push(e+": "+b[e]):c[f[g]][e]["default"]&&d.push(e+": "+c[f[g]][e]["default"]);return $("<span>").addClass("description").text(d.join(", "))}g.html("");for(var b in mist.data.config.protocols){var c=mist.data.config.protocols[b];g.append($("<tr>").data("index",b).append($("<td>").text(c.connector)).append($("<td>").html(UI.format.status(c))).append($("<td>").html(a(c))).append($("<td>").css("text-align",
|
||||
"right").html($("<button>").text("Edit").click(function(){UI.navto("Edit Protocol",$(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 protocol "'+mist.data.config.protocols[a].connector+'"?')){mist.data.config.protocols.splice(a,1);mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}}))))}};i();UI.interval.set(function(){mist.send(function(){i()})},
|
||||
3E4);break;case "Edit Protocol":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,b)},{capabilities:!0});c.append("Loading..");break}var j=!1;""!=b&&0<=b&&(j=!0);var k={};for(f in mist.data.config.protocols)k[mist.data.config.protocols[f].connector]=1;var E=function(a){var c=mist.data.capabilities.connectors[a],d=mist.convertBuildOptions(c,m);d.push({type:"hidden",pointer:{main:m,index:"connector"},value:a});d.push({type:"buttons",buttons:[{type:"save",label:"Save","function":function(){if(j)mist.data.config.protocols[b]=
|
||||
3E4);break;case "Edit Protocol":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,b)},{capabilities:!0});c.append("Loading..");break}var j=!1;""!=b&&0<=b&&(j=!0);var k={};for(f in mist.data.config.protocols)k[mist.data.config.protocols[f].connector]=1;var aa=function(a){var c=mist.data.capabilities.connectors[a],d=mist.convertBuildOptions(c,m);d.push({type:"hidden",pointer:{main:m,index:"connector"},value:a});d.push({type:"buttons",buttons:[{type:"save",label:"Save","function":function(){if(j)mist.data.config.protocols[b]=
|
||||
m;else{if(!mist.data.config.protocols)mist.data.config.protocols=[];mist.data.config.protocols.push(m)}mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}},{type:"cancel",label:"Cancel","function":function(){UI.navto("Protocols")}}]});if("deps"in c&&c.deps!=""){$t=$("<span>").text("Dependencies:");$ul=$("<ul>");$t.append($ul);if(typeof c.deps=="string")c.deps=c.deps.split(", ");for(var f in c.deps){a=$("<li>").text(c.deps[f]+" ");$ul.append(a);typeof k[c.deps[f]]!="undefined"||
|
||||
typeof k[c.deps[f]+".exe"]!="undefined"?a.append($("<span>").addClass("green").text("(Configured)")):a.append($("<span>").addClass("red").text("(Not yet configured)"))}d.unshift({type:"text",text:$t[0].innerHTML})}return UI.buildUI(d)},k={};for(f in mist.data.config.protocols)k[mist.data.config.protocols[f].connector]=1;if(j)m=d=mist.data.config.protocols[b],c.find("h2").append(' "'+d.connector+'"'),c.append(E(d.connector));else{c.html($("<h2>").text("New Protocol"));var m={},x=[];for(f in mist.data.capabilities.connectors)x.push([f,
|
||||
f]);var F=$("<span>");c.append(UI.buildUI([{label:"Protocol",type:"select",select:x,"function":function(){F.html(E($(this).getval()))}}])).append(F)}break;case "Streams":if(!("capabilities"in mist.data)){c.html("Loading..");mist.send(function(){UI.navto(a)},{capabilities:!0});break}var f=$("<button>"),B=$("<span>").text("Loading..");c.append(UI.buildUI([{type:"help",help:"Here you can create, edit or delete new and existing streams. Go to stream preview or embed a video player on your website."},
|
||||
$("<div>").css({width:"45.25em",display:"flex","justify-content":"flex-end"}).append(f).append($("<button>").text("Create a new stream").click(function(){UI.navto("Edit")}))])).append(B);if(""==b){var r=mist.stored.get();"viewmode"in r&&(b=r.viewmode)}f.text("Switch to "+("thumbnails"==b?"list":"thumbnail")+" view").click(function(){mist.stored.set("viewmode",b=="thumbnails"?"list":"thumbnails");UI.navto("Streams",b=="thumbnails"?"list":"thumbnails")});var Q=function(b,d,f){B.remove();switch(b){case "thumbnails":var e=
|
||||
$("<div>").addClass("preview_icons"),g;g=f||[];d.sort();d.unshift("");B.remove();c.append($("<h2>").text(a)).append(UI.buildUI([{label:"Filter the streams",type:"datalist",datalist:d,pointer:{main:{},index:"stream"},help:"If you type something here, the box below will only show streams with names that contain your text.","function":function(){var a=$(this).val();e.children().each(function(){$(this).hide();$(this).attr("data-stream").indexOf(a)>-1&&$(this).show()})}}]));d.shift();c.append($("<span>").addClass("description").text("Choose a stream below.")).append(e);
|
||||
for(var h in d){var b=d[h],i="",j=$("<button>").text("Delete").click(function(){var a=$(this).closest("div").attr("data-stream");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)}}),l=$("<button>").text("Settings").click(function(){UI.navto("Edit",$(this).closest("div").attr("data-stream"))}),f=$("<button>").text("Preview").click(function(){UI.navto("Preview",
|
||||
$(this).closest("div").attr("data-stream"))}),k=$("<button>").text("Embed").click(function(){UI.navto("Embed",$(this).closest("div").attr("data-stream"))}),n=$("<span>").addClass("image");if(b.indexOf("+")>-1){i=b.split("+");i=mist.data.streams[i[0]].source+i[1];l=j="";n.addClass("wildcard")}else{i=mist.data.streams[b].source;if(g.indexOf(b)>-1){k=f="";n.addClass("folder")}}e.append($("<div>").append($("<span>").addClass("streamname").text(b)).append(n).append($("<span>").addClass("description").text(i)).append($("<span>").addClass("button_container").append(l).append(j).append(f).append(k)).attr("title",
|
||||
b).attr("data-stream",b))}break;default:var m=$("<tbody>").append($("<tr>").append("<td>").attr("colspan",6).text("Loading.."));h=$("<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(m);
|
||||
c.append(h);h.stupidtable();var o=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,p,mist.data.streams);var a=0;m.html("");d.sort();for(var b in d){var c=d[b],f;f=c in mist.data.streams?mist.data.streams[c]:p[c];var g=$("<td>").css("text-align","right").html($("<span>").addClass("description").text("Loading..")),e=0;if(typeof mist.data.totals!="undefined"&&typeof mist.data.totals[c]!=
|
||||
"undefined"){var h=mist.data.totals[c].all_protocols.clients,e=0;if(h.length){for(a in h)e=e+h[a][1];e=Math.round(e/h.length)}}g.html(UI.format.number(e));if(e==0&&f.online==1)f.online=2;e=$("<td>").css("text-align","right").css("white-space","nowrap");(!("ischild"in f)||!f.ischild)&&e.html($("<button>").text("Settings").click(function(){UI.navto("Edit",$(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)}}));h=$("<span>").text(c);f.ischild&&h.css("padding-left","1em");var L=UI.format.status(f),i=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("tr").data("index"))}),j=$("<button>").text("Embed").click(function(){UI.navto("Embed",$(this).closest("tr").data("index"))});if("filesfound"in p[c]){L.html("");i="";g.html("");
|
||||
j=""}m.append($("<tr>").data("index",c).html($("<td>").html(h).attr("title",c).addClass("overflow_ellipsis")).append($("<td>").text(f.source).attr("title",f.source).addClass("description").addClass("overflow_ellipsis").css("max-width","20em")).append($("<td>").data("sort-value",f.online).html(L)).append(g).append($("<td>").css("white-space","nowrap").html(i).append(j)).append(e));a++}},{totals:a,active_streams:true})},p=$.extend(true,{},mist.data.streams);if(mist.data.LTS){var q=0,t=0;for(g in mist.data.streams){h=
|
||||
mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"];if(!h)break;if(mist.inputMatch(h.source_match,mist.data.streams[g].source)){p[g].source=p[g].source+"*";p[g].filesfound=null;mist.send(function(a,b){var c=b.stream,d;for(d in a.browse.files)for(var f in mist.data.capabilities.inputs)if(!(f.indexOf("Buffer")>=0||f.indexOf("Folder")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[f].source_match,"/"+a.browse.files[d])){var e=c+"+"+a.browse.files[d],g=p,h=e,L=e,i=$.extend({},
|
||||
mist.data.streams[c]);delete i.meta;delete i.error;i.online=2;i.name=L;i.ischild=true;g[h]=i;p[e].source=mist.data.streams[c].source+a.browse.files[d]}"files"in a.browse&&a.browse.files.length?p[c].filesfound=true:mist.data.streams[c].filesfound=false;t++;if(q==t){mist.send(function(){o()},{active_streams:true});UI.interval.set(function(){o()},5E3)}},{browse:mist.data.streams[g].source},{stream:g});q++}}if(q==0){mist.send(function(){o()},{active_streams:true});UI.interval.set(function(){o()},5E3)}}else{mist.send(function(){o()},
|
||||
{active_streams:true});UI.interval.set(function(){o()},5E3)}}};if(mist.data.LTS){var R=0,aa=0,x={},ba=[];for(r in mist.data.streams)if(mist.inputMatch((mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"]).source_match,mist.data.streams[r].source))ba.push(r),mist.send(function(a,c){var d=c.stream,f;for(f in a.browse.files)for(var e in mist.data.capabilities.inputs)e.indexOf("Buffer")>=0||e.indexOf("Folder")>=0||mist.inputMatch(mist.data.capabilities.inputs[e].source_match,
|
||||
"/"+a.browse.files[f])&&(x[d+"+"+a.browse.files[f]]=true);aa++;R==aa&&mist.send(function(){for(var a in mist.data.active_streams){var c=mist.data.active_streams[a].split("+");c.length>1&&c[0]in mist.data.streams&&(x[mist.data.active_streams[a]]=true)}x=Object.keys(x);x=x.concat(Object.keys(mist.data.streams));Q(b,x,ba)},{active_streams:true})},{browse:mist.data.streams[r].source},{stream:r}),R++;0==R&&mist.send(function(){var a=[],c;for(c in mist.data.active_streams){var d=mist.data.active_streams[c].split("+");
|
||||
d.length>1&&d[0]in mist.data.streams&&(a[mist.data.active_streams[c]]=true)}mist.data.streams&&(a=a.concat(Object.keys(mist.data.streams)));a.sort();Q(b,a)},{active_streams:!0})}else Q(b,Object.keys(mist.data.streams));break;case "Edit":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,b)},{capabilities:!0});c.append("Loading..");break}j=!1;""!=b&&(j=!0);if(j){var s=b,m=mist.data.streams[s];c.find("h2").append(' "'+s+'"')}else c.html($("<h2>").text("New Stream")),m={};
|
||||
s=[];for(f in mist.data.capabilities.inputs)s.push(mist.data.capabilities.inputs[f].source_match);var K=$("<div>"),ca=function(a){if(!mist.data.streams)mist.data.streams={};mist.data.streams[m.name]=m;b!=m.name&&delete mist.data.streams[b];var c={};if(mist.data.LTS){c.addstream={};c.addstream[m.name]=m;if(b!=m.name)c.deletestream=[b]}else c.streams=mist.data.streams;if(m.stop_sessions&&b!=""){c.stop_sessions=b;delete m.stop_sessions}mist.send(function(){delete mist.data.streams[m.name].online;delete mist.data.streams[m.name].error;
|
||||
UI.navto(a,a=="Preview"?m.name:"")},c)},da=$("<style>").text("button.saveandpreview { display: none; }");c.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",filetypes:s,pointer:{main:m,index:"source"},help:"<p>Below is the explanation of the input methods for MistServer. Anything between brackets () will go to default settings if not specified.</p><table><tr><td>Input</td><td>Syntax</td><td>Explanation</td></tr> <tr><th>File</th><td>Linux/MacOS: /PATH/FILE<br>Windows: /cygdrive/DRIVE/PATH/FILE</td><td>For file input please specify the proper path and file.<br>Supported inputs are: DTSC, FLV, MP3. MistServer Pro has TS, MP4, ISMV added as input.</td></tr><th>Folder<br>(Pro only)</th><td>Linux/MacOS: /PATH/<br>Windows: /cygdrive/DRIVE/PATH/</td><td>A folder stream makes all the recognised files in the selected folder available as a stream.</td></tr><tr><th>RTMP</th><td>push://(IP)(@PASSWORD)</td><td>IP is white listed IP for pushing towards MistServer, if left empty all are white listed.<br>Password is the application under which to push to MistServer, if it doesn't match the stream will be rejected. Password is MistServer Pro only. <tr><th>RTSP<br>(Pro only)</th><td>push://(IP)(@PASSWORD)</td><td>IP is white listed IP for pushing towards MistServer, if left empty all are white listed.</td></tr> <tr><th>TS<br>(Pro only)</th><td>tsudp://(IP):PORT(/INTERFACE)</td><td>IP is the IP address used to listen for this stream, multi-cast IP range is: 224.0.0.0 - 239.255.255.255. If IP is not set all addresses will listened to.<br>PORT is the port you reserve for this stream on the chosen IP.<br>INTERFACE is the interface used, if left all interfaces will be used.</td></tr></table>",
|
||||
"function":function(){var a=$(this).val();da.remove();if(a!=""){var b=null,d;for(d in mist.data.capabilities.inputs)if(typeof mist.data.capabilities.inputs[d].source_match!="undefined"&&mist.inputMatch(mist.data.capabilities.inputs[d].source_match,a)){b=d;break}if(b===null)K.html($("<h3>").text("Unrecognized input").addClass("red")).append($("<span>").text("Please edit the stream source.").addClass("red"));else{b=mist.data.capabilities.inputs[b];K.html($("<h3>").text(b.name+" Input options"));var f=
|
||||
mist.convertBuildOptions(b,m);"always_match"in mist.data.capabilities.inputs[d]&&mist.inputMatch(mist.data.capabilities.inputs[d].always_match,a)&&f.push({label:"Always on",type:"checkbox",help:"Keep this input available at all times, even when there are no active viewers.",pointer:{main:m,index:"always_on"}});K.append(UI.buildUI(f));b.name=="Folder"&&c.append(da)}}}},{label:"Stop sessions",type:"checkbox",help:"When saving these stream settings, kill this stream's current connections.",LTSonly:!0,
|
||||
typeof k[c.deps[f]+".exe"]!="undefined"?a.append($("<span>").addClass("green").text("(Configured)")):a.append($("<span>").addClass("red").text("(Not yet configured)"))}d.unshift({type:"text",text:$t[0].innerHTML})}return UI.buildUI(d)},k={};for(f in mist.data.config.protocols)k[mist.data.config.protocols[f].connector]=1;if(j)m=d=mist.data.config.protocols[b],c.find("h2").append(' "'+d.connector+'"'),c.append(aa(d.connector));else{c.html($("<h2>").text("New Protocol"));var m={},t=[];for(f in mist.data.capabilities.connectors)t.push([f,
|
||||
f]);var F=$("<span>");c.append(UI.buildUI([{label:"Protocol",type:"select",select:t,"function":function(){F.html(aa($(this).getval()))}}])).append(F)}break;case "Streams":if(!("capabilities"in mist.data)){c.html("Loading..");mist.send(function(){UI.navto(a)},{capabilities:!0});break}var f=$("<button>"),C=$("<span>").text("Loading..");c.append(UI.buildUI([{type:"help",help:"Here you can create, edit or delete new and existing streams. Go to stream preview or embed a video player on your website."},
|
||||
$("<div>").css({width:"45.25em",display:"flex","justify-content":"flex-end"}).append(f).append($("<button>").text("Create a new stream").click(function(){UI.navto("Edit")}))])).append(C);if(""==b){var s=mist.stored.get();"viewmode"in s&&(b=s.viewmode)}f.text("Switch to "+("thumbnails"==b?"list":"thumbnail")+" view").click(function(){mist.stored.set("viewmode",b=="thumbnails"?"list":"thumbnails");UI.navto("Streams",b=="thumbnails"?"list":"thumbnails")});var y=$.extend(!0,{},mist.data.streams),P=function(a,
|
||||
b){var c=$.extend({},b);delete c.meta;delete c.error;c.online=2;c.name=a;c.ischild=true;return c},Q=function(b,d,f){C.remove();switch(b){case "thumbnails":var e=$("<div>").addClass("preview_icons"),g;g=f||[];d.sort();d.unshift("");C.remove();c.append($("<h2>").text(a)).append(UI.buildUI([{label:"Filter the streams",type:"datalist",datalist:d,pointer:{main:{},index:"stream"},help:"If you type something here, the box below will only show streams with names that contain your text.","function":function(){var a=
|
||||
$(this).val();e.children().each(function(){$(this).hide();$(this).attr("data-stream").indexOf(a)>-1&&$(this).show()})}}]));d.shift();c.append($("<span>").addClass("description").text("Choose a stream below.")).append(e);for(var h in d){var b=d[h],i="",j=$("<button>").text("Delete").click(function(){var a=$(this).closest("div").attr("data-stream");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)}}),l=$("<button>").text("Settings").click(function(){UI.navto("Edit",$(this).closest("div").attr("data-stream"))}),f=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("div").attr("data-stream"))}),k=$("<button>").text("Embed").click(function(){UI.navto("Embed",$(this).closest("div").attr("data-stream"))}),n=$("<span>").addClass("image");if(b.indexOf("+")>-1){i=b.split("+");i=mist.data.streams[i[0]].source+i[1];l=j="";n.addClass("wildcard")}else{i=
|
||||
mist.data.streams[b].source;if(g.indexOf(b)>-1){k=f="";n.addClass("folder")}}e.append($("<div>").append($("<span>").addClass("streamname").text(b)).append(n).append($("<span>").addClass("description").text(i)).append($("<span>").addClass("button_container").append(l).append(j).append(f).append(k)).attr("title",b).attr("data-stream",b))}break;default:var m=$("<tbody>").append($("<tr>").append("<td>").attr("colspan",6).text("Loading.."));h=$("<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(m);c.append(h);h.stupidtable();var o=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,
|
||||
y,mist.data.streams);var a=0;m.html("");d.sort();for(var b in d){var c=d[b],f;f=c in mist.data.streams?mist.data.streams[c]:y[c];var g=$("<td>").css("text-align","right").html($("<span>").addClass("description").text("Loading..")),e=0;if(typeof mist.data.totals!="undefined"&&typeof mist.data.totals[c]!="undefined"){var h=mist.data.totals[c].all_protocols.clients,e=0;if(h.length){for(a in h)e=e+h[a][1];e=Math.round(e/h.length)}}g.html(UI.format.number(e));if(e==0&&f.online==1)f.online=2;e=$("<td>").css("text-align",
|
||||
"right").css("white-space","nowrap");(!("ischild"in f)||!f.ischild)&&e.html($("<button>").text("Settings").click(function(){UI.navto("Edit",$(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)}}));h=$("<span>").text(c);
|
||||
f.ischild&&h.css("padding-left","1em");var da=UI.format.status(f),i=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("tr").data("index"))}),j=$("<button>").text("Embed").click(function(){UI.navto("Embed",$(this).closest("tr").data("index"))});if("filesfound"in y[c]){da.html("");i="";g.html("");j=""}m.append($("<tr>").data("index",c).html($("<td>").html(h).attr("title",c).addClass("overflow_ellipsis")).append($("<td>").text(f.source).attr("title",f.source).addClass("description").addClass("overflow_ellipsis").css("max-width",
|
||||
"20em")).append($("<td>").data("sort-value",f.online).html(da)).append(g).append($("<td>").css("white-space","nowrap").html(i).append(j)).append(e));a++}},{totals:a,active_streams:true})};if(mist.data.LTS){var p=0,q=0;for(g in mist.data.streams){h=mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"];if(!h)break;if(mist.inputMatch(h.source_match,mist.data.streams[g].source)){y[g].source=y[g].source+"*";y[g].filesfound=null;mist.send(function(a,b){var c=b.stream,d;for(d in a.browse.files)for(var f in mist.data.capabilities.inputs)if(!(f.indexOf("Buffer")>=
|
||||
0||f.indexOf("Folder")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[f].source_match,"/"+a.browse.files[d])){var e=c+"+"+a.browse.files[d];y[e]=P(e,mist.data.streams[c]);y[e].source=mist.data.streams[c].source+a.browse.files[d]}"files"in a.browse&&a.browse.files.length?y[c].filesfound=true:mist.data.streams[c].filesfound=false;q++;if(p==q){mist.send(function(){o()},{active_streams:true});UI.interval.set(function(){o()},5E3)}},{browse:mist.data.streams[g].source},{stream:g});p++}}if(p==0){mist.send(function(){o()},
|
||||
{active_streams:true});UI.interval.set(function(){o()},5E3)}}else{mist.send(function(){o()},{active_streams:true});UI.interval.set(function(){o()},5E3)}}};if(mist.data.LTS){var R=0,ba=0,t={},ca=[];for(s in mist.data.streams)if(mist.inputMatch((mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"]).source_match,mist.data.streams[s].source))ca.push(s),mist.send(function(a,c){var d=c.stream,f;for(f in a.browse.files)for(var e in mist.data.capabilities.inputs)e.indexOf("Buffer")>=
|
||||
0||e.indexOf("Folder")>=0||mist.inputMatch(mist.data.capabilities.inputs[e].source_match,"/"+a.browse.files[f])&&(t[d+"+"+a.browse.files[f]]=true);ba++;R==ba&&mist.send(function(){for(var a in mist.data.active_streams){var c=mist.data.active_streams[a].split("+");if(c.length>1&&c[0]in mist.data.streams){t[mist.data.active_streams[a]]=true;y[mist.data.active_streams[a]]=P(mist.data.active_streams[a],mist.data.streams[c[0]])}}t=Object.keys(t);t=t.concat(Object.keys(mist.data.streams));t.sort();Q(b,
|
||||
t,ca)},{active_streams:true})},{browse:mist.data.streams[s].source},{stream:s}),R++;0==R&&mist.send(function(){for(var a in mist.data.active_streams){var c=mist.data.active_streams[a].split("+");if(c.length>1&&c[0]in mist.data.streams){t[mist.data.active_streams[a]]=true;y[mist.data.active_streams[a]]=P(mist.data.active_streams[a],mist.data.streams[c[0]])}}t=Object.keys(t);mist.data.streams&&(t=t.concat(Object.keys(mist.data.streams)));t.sort();Q(b,t)},{active_streams:!0})}else Q(b,Object.keys(mist.data.streams));
|
||||
break;case "Edit":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,b)},{capabilities:!0});c.append("Loading..");break}j=!1;""!=b&&(j=!0);if(j){var r=b,m=mist.data.streams[r];c.find("h2").append(' "'+r+'"')}else c.html($("<h2>").text("New Stream")),m={};r=[];for(f in mist.data.capabilities.inputs)r.push(mist.data.capabilities.inputs[f].source_match);var K=$("<div>"),ea=function(a){if(!mist.data.streams)mist.data.streams={};mist.data.streams[m.name]=m;b!=m.name&&delete mist.data.streams[b];
|
||||
var c={};if(mist.data.LTS){c.addstream={};c.addstream[m.name]=m;if(b!=m.name)c.deletestream=[b]}else c.streams=mist.data.streams;if(m.stop_sessions&&b!=""){c.stop_sessions=b;delete m.stop_sessions}mist.send(function(){delete mist.data.streams[m.name].online;delete mist.data.streams[m.name].error;UI.navto(a,a=="Preview"?m.name:"")},c)},fa=$("<style>").text("button.saveandpreview { display: none; }");c.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",filetypes:r,pointer:{main:m,index:"source"},help:"<p>Below is the explanation of the input methods for MistServer. Anything between brackets () will go to default settings if not specified.</p><table><tr><td>Input</td><td>Syntax</td><td>Explanation</td></tr> <tr><th>File</th><td>Linux/MacOS: /PATH/FILE<br>Windows: /cygdrive/DRIVE/PATH/FILE</td><td>For file input please specify the proper path and file.<br>Supported inputs are: DTSC, FLV, MP3. MistServer Pro has TS, MP4, ISMV added as input.</td></tr><th>Folder<br>(Pro only)</th><td>Linux/MacOS: /PATH/<br>Windows: /cygdrive/DRIVE/PATH/</td><td>A folder stream makes all the recognised files in the selected folder available as a stream.</td></tr><tr><th>RTMP</th><td>push://(IP)(@PASSWORD)</td><td>IP is white listed IP for pushing towards MistServer, if left empty all are white listed.<br>Password is the application under which to push to MistServer, if it doesn't match the stream will be rejected. Password is MistServer Pro only. <tr><th>RTSP<br>(Pro only)</th><td>push://(IP)(@PASSWORD)</td><td>IP is white listed IP for pushing towards MistServer, if left empty all are white listed.</td></tr> <tr><th>TS<br>(Pro only)</th><td>tsudp://(IP):PORT(/INTERFACE)</td><td>IP is the IP address used to listen for this stream, multi-cast IP range is: 224.0.0.0 - 239.255.255.255. If IP is not set all addresses will listened to.<br>PORT is the port you reserve for this stream on the chosen IP.<br>INTERFACE is the interface used, if left all interfaces will be used.</td></tr></table>",
|
||||
"function":function(){var a=$(this).val();fa.remove();if(a!=""){var b=null,d;for(d in mist.data.capabilities.inputs)if(typeof mist.data.capabilities.inputs[d].source_match!="undefined"&&mist.inputMatch(mist.data.capabilities.inputs[d].source_match,a)){b=d;break}if(b===null)K.html($("<h3>").text("Unrecognized input").addClass("red")).append($("<span>").text("Please edit the stream source.").addClass("red"));else{b=mist.data.capabilities.inputs[b];K.html($("<h3>").text(b.name+" Input options"));var f=
|
||||
mist.convertBuildOptions(b,m);"always_match"in mist.data.capabilities.inputs[d]&&mist.inputMatch(mist.data.capabilities.inputs[d].always_match,a)&&f.push({label:"Always on",type:"checkbox",help:"Keep this input available at all times, even when there are no active viewers.",pointer:{main:m,index:"always_on"}});K.append(UI.buildUI(f));b.name=="Folder"&&c.append(fa)}}}},{label:"Stop sessions",type:"checkbox",help:"When saving these stream settings, kill this stream's current connections.",LTSonly:!0,
|
||||
pointer:{main:m,index:"stop_sessions"}},$("<br>"),{type:"custom",custom:K},$("<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(){ca("Streams")}},{type:"save",label:"Save and Preview","function":function(){ca("Preview")},classes:["saveandpreview"]}]}]));break;case "Preview":""==
|
||||
b&&UI.navto("Streams");r=":8080";for(f in mist.data.config.protocols)if(d=mist.data.config.protocols[f],"HTTP"==d.connector||"HTTP.exe"==d.connector)r=d.port?":"+d.port:":8080";var s=parseURL(mist.user.host),M=s.protocol+s.host+r+"/",F=$("<div>").css({display:"flex","flex-flow":"row wrap"}),s="";-1==b.indexOf("+")&&(s=$("<button>").text("Settings").addClass("settings").click(function(){UI.navto("Edit",b)}));c.html($("<div>").addClass("bigbuttons").append(s).append($("<button>").text("Embed").addClass("embed").click(function(){UI.navto("Embed",
|
||||
b)})).append($("<button>").addClass("cancel").addClass("return").text("Return").click(function(){UI.navto("Streams")}))).append($("<h2>").text('Preview of "'+b+'"')).append(F);var C=encodeURIComponent(b),f=$("<div>");F.append(f);var S=$("<div>"),N=$("<select>").append($("<option>").text("Automatic").val("")).change(function(){T()}),I=$("<select>").append($("<option>").text("Automatic").val("")).change(function(){T()}),s=UI.buildUI([{label:"Use player",type:"DOMfield",DOMfield:N,help:"Choose a player to preview"},
|
||||
{label:"Use source",type:"DOMfield",DOMfield:I,help:"Choose an output type to preview"}]),G=$("<div>").addClass("mistvideo").text("Loading player..");f.append(G).append(S).append(s);var T=function(){G.html("");z.html("");var a={target:G[0],maxheight:window.innerHeight-$("header").height(),maxwidth:window.innerWidth-UI.elements.menu.width()-100,loop:true};if(N.val()!="")a.forcePlayer=N.val();if(I.val()!="")a.forceType=I.val();mistPlay(b,a)},z=$("<div>").addClass("player_log");f.append($("<div>").append($("<h3>").text("Player log:")).append(z));
|
||||
G.on("log error",function(a){var b=false;z.height()+z.scrollTop()==z[0].scrollHeight&&(b=true);z.append($("<div>").append($("<span>").text("["+UI.format.time((new Date).getTime()/1E3)+"]").css("margin-right","0.5em")).append($("<span>").text(a.originalEvent.message)).addClass(a.type=="error"?"red":""));b&&z.scrollTop(z[0].scrollHeight)});var ea=function(){S.text("");var a=document.createElement("script");c.append(a);a.src=M+"player.js";a.onerror=function(){G.html("Failed to load player.js").append($("<button>").text("Reload").css("display",
|
||||
"block").click(function(){ea()}))};a.onload=function(){for(var d in mistplayers)N.append($("<option>").text(mistplayers[d].name).val(d));T();G.on("initialized",function(){if(I.children().length<=1)for(var a in mistvideo[b].source){var c=UI.humanMime(mistvideo[b].source[a].type);I.append($("<option>").val(mistvideo[b].source[a].type).text(c?c+" ("+mistvideo[b].source[a].type+")":UI.format.capital(mistvideo[b].source[a].type)))}a=mistvideo[b].embedded[mistvideo[b].embedded.length-1];c=UI.humanMime(a.player.options.source.type);
|
||||
S.html("You're watching "+(c?c+" <span class=description>("+a.player.options.source.type+")</span>":UI.format.capital(a.player.options.source.type))+" through "+mistplayers[a.selectedPlayer].name+".")});c[0].removeChild(a)}};ea();var f=$("<div>").append($("<h3>").text("Meta information")),O=$("<span>").text("Loading..");f.append(O);F.append(f);$.ajax({type:"GET",url:M+"json_"+C+".js",success:function(a){var b=a.meta;if(b){a=[];a.push({label:"Type",type:"span",value:b.live?"Live":"Pre-recorded (VoD)"});
|
||||
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(){ea("Streams")}},{type:"save",label:"Save and Preview","function":function(){ea("Preview")},classes:["saveandpreview"]}]}]));break;case "Preview":""==
|
||||
b&&UI.navto("Streams");s=":8080";for(f in mist.data.config.protocols)if(d=mist.data.config.protocols[f],"HTTP"==d.connector||"HTTP.exe"==d.connector)s=d.port?":"+d.port:":8080";var r=parseURL(mist.user.host),L=r.protocol+r.host+s+"/",F=$("<div>").css({display:"flex","flex-flow":"row wrap"}),r="";-1==b.indexOf("+")&&(r=$("<button>").text("Settings").addClass("settings").click(function(){UI.navto("Edit",b)}));c.html($("<div>").addClass("bigbuttons").append(r).append($("<button>").text("Embed").addClass("embed").click(function(){UI.navto("Embed",
|
||||
b)})).append($("<button>").addClass("cancel").addClass("return").text("Return").click(function(){UI.navto("Streams")}))).append($("<h2>").text('Preview of "'+b+'"')).append(F);var D=encodeURIComponent(b),f=$("<div>");F.append(f);var S=$("<div>"),M=$("<select>").append($("<option>").text("Automatic").val("")).change(function(){T()}),I=$("<select>").append($("<option>").text("Automatic").val("")).change(function(){T()}),r=UI.buildUI([{label:"Use player",type:"DOMfield",DOMfield:M,help:"Choose a player to preview"},
|
||||
{label:"Use source",type:"DOMfield",DOMfield:I,help:"Choose an output type to preview"}]),G=$("<div>").addClass("mistvideo").text("Loading player..");f.append(G).append(S).append(r);var T=function(){G.html("");A.html("");var a={target:G[0],maxheight:window.innerHeight-$("header").height(),maxwidth:window.innerWidth-UI.elements.menu.width()-100,loop:true};if(M.val()!="")a.forcePlayer=M.val();if(I.val()!="")a.forceType=I.val();mistPlay(b,a)},A=$("<div>").addClass("player_log");f.append($("<div>").append($("<h3>").text("Player log:")).append(A));
|
||||
G.on("log error",function(a){var b=false;A.height()+A.scrollTop()==A[0].scrollHeight&&(b=true);A.append($("<div>").append($("<span>").text("["+UI.format.time((new Date).getTime()/1E3)+"]").css("margin-right","0.5em")).append($("<span>").text(a.originalEvent.message)).addClass(a.type=="error"?"red":""));b&&A.scrollTop(A[0].scrollHeight)});var ga=function(){S.text("");var a=document.createElement("script");c.append(a);a.src=L+"player.js";a.onerror=function(){G.html("Failed to load player.js").append($("<button>").text("Reload").css("display",
|
||||
"block").click(function(){ga()}))};a.onload=function(){for(var d in mistplayers)M.append($("<option>").text(mistplayers[d].name).val(d));T();G.on("initialized",function(){if(I.children().length<=1)for(var a in mistvideo[b].source){var c=UI.humanMime(mistvideo[b].source[a].type);I.append($("<option>").val(mistvideo[b].source[a].type).text(c?c+" ("+mistvideo[b].source[a].type+")":UI.format.capital(mistvideo[b].source[a].type)))}a=mistvideo[b].embedded[mistvideo[b].embedded.length-1];c=UI.humanMime(a.player.options.source.type);
|
||||
S.html("You're watching "+(c?c+" <span class=description>("+a.player.options.source.type+")</span>":UI.format.capital(a.player.options.source.type))+" through "+mistplayers[a.selectedPlayer].name+".")});c[0].removeChild(a)}};ga();var f=$("<div>").append($("<h3>").text("Meta information")),N=$("<span>").text("Loading..");f.append(N);F.append(f);$.ajax({type:"GET",url:L+"json_"+D+".js",success:function(a){var b=a.meta;if(b){a=[];a.push({label:"Type",type:"span",value:b.live?"Live":"Pre-recorded (VoD)"});
|
||||
"format"in b&&a.push({label:"Format",type:"span",value:b.format});b.live&&a.push({label:"Buffer window",type:"span",value:UI.format.addUnit(b.buffer_window,"ms")});var c={audio:{vheader:"Audio",labels:["Codec","Duration","Peak bitrate","Channels","Samplerate","Language"],content:[]},video:{vheader:"Video",labels:["Codec","Duration","Peak bitrate","Size","Framerate","Language"],content:[]},subtitle:{vheader:"Subtitles",labels:["Codec","Duration","Peak bitrate","Language"],content:[]}},d=Object.keys(b.tracks);
|
||||
d.sort(function(a,b){a=a.split("_").pop();b=b.split("_").pop();return a-b});for(var f in d){var e=d[f],g=b.tracks[e];switch(g.type){case "audio":c.audio.content.push({header:"Track "+e.split("_").pop(),body:[g.codec,UI.format.duration((g.lastms-g.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(g.firstms/1E3)+" to "+UI.format.duration(g.lastms/1E3)+"</span>",UI.format.bytes(g.bps,1),g.channels,UI.format.addUnit(UI.format.number(g.rate),"Hz"),"lang"in g?g.lang:"unknown"]});break;case "video":c.video.content.push({header:"Track "+
|
||||
e.split("_").pop(),body:[g.codec,UI.format.duration((g.lastms-g.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(g.firstms/1E3)+" to "+UI.format.duration(g.lastms/1E3)+"</span>",UI.format.bytes(g.bps,1),UI.format.addUnit(g.width,"x ")+UI.format.addUnit(g.height,"px"),UI.format.addUnit(UI.format.number(g.fpks/1E3),"fps"),"lang"in g?g.lang:"unknown"]});break;case "subtitle":c.subtitle.content.push({header:"Track "+e.split("_").pop(),body:[g.codec,UI.format.duration((g.lastms-g.firstms)/
|
||||
1E3)+"<br><span class=description>"+UI.format.duration(g.firstms/1E3)+" to "+UI.format.duration(g.lastms/1E3)+"</span>",UI.format.bytes(g.bps,1),"lang"in g?g.lang:"unknown"]})}}f=["audio","video","subtitle"];b=$("<div>").css({display:"flex","flex-flow":"row wrap","font-size":"0.9em"});for(e in f)c[f[e]].content.length&&b.append(UI.buildVheaderTable(c[f[e]]).css("width","auto"));a.push($("<span>").text("Tracks:"));a.push(b);O.html(UI.buildUI(a))}else O.html("No meta information available.")},error:function(){O.html("Error while retrieving stream info.")}});
|
||||
break;case "Embed":""==b&&UI.navTo("Streams");s="";-1==b.indexOf("+")&&(s=$("<button>").addClass("settings").text("Settings").click(function(){UI.navto("Edit",b)}));c.html($("<div>").addClass("bigbuttons").append(s).append($("<button>").text("Preview").addClass("preview").click(function(){UI.navto("Preview",b)})).append($("<button>").addClass("cancel").addClass("return").text("Return").click(function(){UI.navto("Streams")}))).append($("<h2>").text('Embed "'+b+'"'));var P=$("<span>");c.append(P);C=
|
||||
encodeURIComponent(b);s=parseURL(mist.user.host);r=":8080";for(f in mist.data.config.protocols)if(d=mist.data.config.protocols[f],"HTTP"==d.connector||"HTTP.exe"==d.connector)r=d.port?":"+d.port:":8080";var D=M=s.protocol+s.host+r+"/";otherhost&&(f=parseURL(otherhost),D=f.protocol+f.host+r+"/");var U={forcePlayer:"",forceType:"",controls:!0,autoplay:!0,loop:!1,width:"",height:"",maxwidth:"",maxheight:"",poster:"",urlappend:"",setTracks:{}},o=$.extend({},U),f=UI.stored.getOpts();"embedoptions"in f&&
|
||||
(o=$.extend(o,f.embedoptions,!0),"object"!=typeof o.setTracks&&(o.setTracks={}));f={};switch(o.controls){case "stock":f.controls="stock";break;case !0:f.controls=1;break;case !1:f.controls=0}var v=function(){function a(b){switch(typeof b){case "string":return $.isNumeric(b)?b:'"'+b+'"';case "object":return JSON.stringify(b);default:return b}}UI.stored.saveOpt("embedoptions",o);for(var c=b+"_",d=12,f="";d--;){var g;g=Math.floor(Math.random()*62);g=g<10?g:g<36?String.fromCharCode(g+55):String.fromCharCode(g+
|
||||
61);f=f+g}var c=c+f,d=['target: document.getElementById("'+c+'")'],e;for(e in o)o[e]!=U[e]&&(typeof o[e]!="object"||JSON.stringify(o[e])!=JSON.stringify(U[e]))&&d.push(e+": "+a(o[e]));e=[];e.push('<div class="mistvideo" id="'+c+'">');e.push(" <noscript>");e.push(' <a href="'+D+C+'.html" target="_blank">');e.push(" Click here to play this video");e.push(" </a>");e.push(" </noscript>");e.push(" <script>");e.push(" var a = function(){");e.push(' mistPlay("'+b+'",{');e.push(" "+
|
||||
d.join(",\n "));e.push(" });");e.push(" };");e.push(" if (!window.mistplayers) {");e.push(' var p = document.createElement("script");');e.push(' p.src = "'+D+'player.js"');e.push(" document.head.appendChild(p);");e.push(" p.onload = a;");e.push(" }");e.push(" else { a(); }");e.push(" <\/script>");e.push("</div>");return e.join("\n")},V=$("<span>").text("Loading.."),r=v(o),H=$("<div>").text("Loading..").css("display","flex");P.append($("<span>").addClass("input_container").append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Use a different host:")).append($("<span>").addClass("field_container").append($("<input>").attr("type",
|
||||
"text").addClass("field").val(otherhost?otherhost:s.protocol+s.host)).append($("<span>").addClass("unit").append($("<button>").text("Apply").click(function(){otherhost=$(this).closest("label").find("input").val();UI.navto("Embed",b)})))))).append(UI.buildUI([$("<h3>").text("Urls"),{label:"Stream info json",type:"str",value:D+"json_"+C+".js",readonly:!0,clipboard:!0,help:"Information about this stream as a json page."},{label:"Stream info script",type:"str",value:D+"info_"+C+".js",readonly:!0,clipboard:!0,
|
||||
help:"This script loads information about this stream into a mistvideo javascript object."},{label:"HTML page",type:"str",value:D+C+".html",readonly:!0,qrcode:!0,clipboard:!0,help:"A basic html containing the embedded stream."},$("<h3>").text("Embed code"),{label:"Embed code",type:"textarea",value:r,rows:r.split("\n").length+3,readonly:!0,classes:["embed_code"],clipboard:!0,help:"Include this code on your webpage to embed the stream. The options below can be used to configure how your content is displayed."},
|
||||
$("<h4>").text("Embed code options (optional)").css("margin-top",0),{type:"help",help:"Use these controls to customise what this embedded video will look like.<br>Not all players have all of these options."},{label:"Force player",type:"select",select:[["","Automatic"]],pointer:{main:o,index:"forcePlayer"},classes:["forcePlayer"],"function":function(){o.forcePlayer=$(this).getval();$(".embed_code").setval(v(o))},help:"Only use this particular player."},{label:"Force source",type:"select",select:[["",
|
||||
"Automatic"]],pointer:{main:o,index:"forceType"},classes:["forceType"],"function":function(){o.forceType=$(this).getval();$(".embed_code").setval(v(o))},help:"Only use this particular source."},{label:"Controls",type:"select",select:[["1","MistServer Controls"],["stock","Player controls"],["0","None"]],pointer:{main:f,index:"controls"},"function":function(){o.controls=$(this).getval()==1;switch($(this).getval()){case 0:o.controls=false;break;case 1:o.controls=true;break;case "stock":o.controls="stock"}$(".embed_code").setval(v(o))},
|
||||
help:"The type of controls that should be shown."},{label:"Autoplay",type:"checkbox",pointer:{main:o,index:"autoplay"},"function":function(){o.autoplay=$(this).getval();$(".embed_code").setval(v(o))},help:"Whether or not the video should play as the page is loaded."},{label:"Loop",type:"checkbox",pointer:{main:o,index:"loop"},"function":function(){o.loop=$(this).getval();$(".embed_code").setval(v(o))},help:"If the video should restart when the end is reached."},{label:"Force width",type:"int",min:0,
|
||||
unit:"px",pointer:{main:o,index:"width"},"function":function(){o.width=$(this).getval();$(".embed_code").setval(v(o))},help:"Enforce a fixed width."},{label:"Force height",type:"int",min:0,unit:"px",pointer:{main:o,index:"height"},"function":function(){o.height=$(this).getval();$(".embed_code").setval(v(o))},help:"Enforce a fixed height."},{label:"Maximum width",type:"int",min:0,unit:"px",pointer:{main:o,index:"maxwidth"},"function":function(){o.maxwidth=$(this).getval();$(".embed_code").setval(v(o))},
|
||||
help:"The maximum width this video can use."},{label:"Maximum height",type:"int",min:0,unit:"px",pointer:{main:o,index:"maxheight"},"function":function(){o.maxheight=$(this).getval();$(".embed_code").setval(v(o))},help:"The maximum height this video can use."},{label:"Poster",type:"str",pointer:{main:o,index:"poster"},"function":function(){o.poster=$(this).getval();$(".embed_code").setval(v(o))},help:"URL to an image that is displayed when the video is not playing."},{label:"Video URL addition",type:"str",
|
||||
pointer:{main:o,index:"urlappend"},help:"The embed script will append this string to the video url, useful for sending through params.",classes:["embed_code_forceprotocol"],"function":function(){o.urlappend=$(this).getval();$(".embed_code").setval(v(o))}},{label:"Preselect tracks",type:"DOMfield",DOMfield:H,help:"Pre-select these tracks."},$("<h3>").text("Protocol stream urls"),V]));$.ajax({type:"GET",url:D+"json_"+C+".js",success:function(a){var b=[],c=P.find(".forceType"),d;for(d in a.source){var e=
|
||||
a.source[d],g=UI.humanMime(e.type);b.push({label:g?g+" <span class=description>("+e.type+")</span>":UI.format.capital(e.type),type:"str",value:e.url,readonly:true,qrcode:true,clipboard:true});g=UI.humanMime(e.type);c.append($("<option>").text(g?g+" ("+e.type+")":UI.format.capital(e.type)).val(e.type))}V.html(UI.buildUI(b));H.html("");b={};for(d in a.meta.tracks){c=a.meta.tracks[d];c.type!="audio"&&c.type!="video"||(c.type in b?b[c.type].push([c.trackid,UI.format.capital(c.type)+" track "+(b[c.type].length+
|
||||
1)]):b[c.type]=[["",UI.format.capital(c.type)+" track 1"]])}if(Object.keys(b).length){H.closest("label").show();for(d in b){a=$("<select>").attr("data-type",d).css("flex-grow","1").change(function(){$(this).val()==""?delete o.setTracks[$(this).attr("data-type")]:o.setTracks[$(this).attr("data-type")]=$(this).val();$(".embed_code").setval(v(o))});H.append(a);b[d].push([-1,"No "+d]);for(var f in b[d])a.append($("<option>").val(b[d][f][0]).text(b[d][f][1]));if(d in o.setTracks){a.val(o.setTracks[d]);
|
||||
if(a.val()==null){a.val("");delete o.setTracks[d];$(".embed_code").setval(v(o))}}}}else H.closest("label").hide()},error:function(){V.html("Error while retrieving stream info.");H.closest("label").hide();o.setTracks={}}});f=document.createElement("script");f.src=M+"player.js";document.head.appendChild(f);f.onload=function(){var a=P.find(".forcePlayer"),b;for(b in mistplayers)a.append($("<option>").text(mistplayers[b].name).val(b));document.head.removeChild(this)};f.onerror=function(){document.head.removeChild(this)};
|
||||
break;case "Push":var y=$("<div>").text("Loading..");c.append(y);mist.send(function(a){function b(a){setTimeout(function(){mist.send(function(c){var d=false;if("push_list"in c&&c.push_list&&c.push_list.length){var d=true,f;for(f in c.push_list)if(a.indexOf(c.push_list[f][0])>-1){d=false;break}}else d=true;if(d)for(f in a)e.find("tr[data-pushid="+a[f]+"]").remove();else b()},{push_list:1})},1E3)}function c(d,f){var g=$("<span>");d.length>=4&&d[2]!=d[3]?g.append($("<span>").text(d[2])).append($("<span>").html("»").addClass("unit").css("margin",
|
||||
1E3)+"<br><span class=description>"+UI.format.duration(g.firstms/1E3)+" to "+UI.format.duration(g.lastms/1E3)+"</span>",UI.format.bytes(g.bps,1),"lang"in g?g.lang:"unknown"]})}}f=["audio","video","subtitle"];b=$("<div>").css({display:"flex","flex-flow":"row wrap","font-size":"0.9em"});for(e in f)c[f[e]].content.length&&b.append(UI.buildVheaderTable(c[f[e]]).css("width","auto"));a.push($("<span>").text("Tracks:"));a.push(b);N.html(UI.buildUI(a))}else N.html("No meta information available.")},error:function(){N.html("Error while retrieving stream info.")}});
|
||||
break;case "Embed":""==b&&UI.navTo("Streams");r="";-1==b.indexOf("+")&&(r=$("<button>").addClass("settings").text("Settings").click(function(){UI.navto("Edit",b)}));c.html($("<div>").addClass("bigbuttons").append(r).append($("<button>").text("Preview").addClass("preview").click(function(){UI.navto("Preview",b)})).append($("<button>").addClass("cancel").addClass("return").text("Return").click(function(){UI.navto("Streams")}))).append($("<h2>").text('Embed "'+b+'"'));var O=$("<span>");c.append(O);D=
|
||||
encodeURIComponent(b);r=parseURL(mist.user.host);s=":8080";for(f in mist.data.config.protocols)if(d=mist.data.config.protocols[f],"HTTP"==d.connector||"HTTP.exe"==d.connector)s=d.port?":"+d.port:":8080";var E=L=r.protocol+r.host+s+"/";otherhost&&(f=parseURL(otherhost),E=f.protocol+f.host+s+"/");var U={forcePlayer:"",forceType:"",controls:!0,autoplay:!0,loop:!1,width:"",height:"",maxwidth:"",maxheight:"",poster:"",urlappend:"",setTracks:{}},o=$.extend({},U),f=UI.stored.getOpts();"embedoptions"in f&&
|
||||
(o=$.extend(o,f.embedoptions,!0),"object"!=typeof o.setTracks&&(o.setTracks={}));f={};switch(o.controls){case "stock":f.controls="stock";break;case !0:f.controls=1;break;case !1:f.controls=0}var w=function(){function a(b){switch(typeof b){case "string":return $.isNumeric(b)?b:'"'+b+'"';case "object":return JSON.stringify(b);default:return b}}UI.stored.saveOpt("embedoptions",o);for(var c=b+"_",d=12,f="";d--;){var g;g=Math.floor(Math.random()*62);g=g<10?g:g<36?String.fromCharCode(g+55):String.fromCharCode(g+
|
||||
61);f=f+g}var c=c+f,d=['target: document.getElementById("'+c+'")'],e;for(e in o)o[e]!=U[e]&&(typeof o[e]!="object"||JSON.stringify(o[e])!=JSON.stringify(U[e]))&&d.push(e+": "+a(o[e]));e=[];e.push('<div class="mistvideo" id="'+c+'">');e.push(" <noscript>");e.push(' <a href="'+E+D+'.html" target="_blank">');e.push(" Click here to play this video");e.push(" </a>");e.push(" </noscript>");e.push(" <script>");e.push(" var a = function(){");e.push(' mistPlay("'+b+'",{');e.push(" "+
|
||||
d.join(",\n "));e.push(" });");e.push(" };");e.push(" if (!window.mistplayers) {");e.push(' var p = document.createElement("script");');e.push(' p.src = "'+E+'player.js"');e.push(" document.head.appendChild(p);");e.push(" p.onload = a;");e.push(" }");e.push(" else { a(); }");e.push(" <\/script>");e.push("</div>");return e.join("\n")},V=$("<span>").text("Loading.."),s=w(o),H=$("<div>").text("Loading..").css("display","flex");O.append($("<span>").addClass("input_container").append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Use a different host:")).append($("<span>").addClass("field_container").append($("<input>").attr("type",
|
||||
"text").addClass("field").val(otherhost?otherhost:r.protocol+r.host)).append($("<span>").addClass("unit").append($("<button>").text("Apply").click(function(){otherhost=$(this).closest("label").find("input").val();UI.navto("Embed",b)})))))).append(UI.buildUI([$("<h3>").text("Urls"),{label:"Stream info json",type:"str",value:E+"json_"+D+".js",readonly:!0,clipboard:!0,help:"Information about this stream as a json page."},{label:"Stream info script",type:"str",value:E+"info_"+D+".js",readonly:!0,clipboard:!0,
|
||||
help:"This script loads information about this stream into a mistvideo javascript object."},{label:"HTML page",type:"str",value:E+D+".html",readonly:!0,qrcode:!0,clipboard:!0,help:"A basic html containing the embedded stream."},$("<h3>").text("Embed code"),{label:"Embed code",type:"textarea",value:s,rows:s.split("\n").length+3,readonly:!0,classes:["embed_code"],clipboard:!0,help:"Include this code on your webpage to embed the stream. The options below can be used to configure how your content is displayed."},
|
||||
$("<h4>").text("Embed code options (optional)").css("margin-top",0),{type:"help",help:"Use these controls to customise what this embedded video will look like.<br>Not all players have all of these options."},{label:"Force player",type:"select",select:[["","Automatic"]],pointer:{main:o,index:"forcePlayer"},classes:["forcePlayer"],"function":function(){o.forcePlayer=$(this).getval();$(".embed_code").setval(w(o))},help:"Only use this particular player."},{label:"Force source",type:"select",select:[["",
|
||||
"Automatic"]],pointer:{main:o,index:"forceType"},classes:["forceType"],"function":function(){o.forceType=$(this).getval();$(".embed_code").setval(w(o))},help:"Only use this particular source."},{label:"Controls",type:"select",select:[["1","MistServer Controls"],["stock","Player controls"],["0","None"]],pointer:{main:f,index:"controls"},"function":function(){o.controls=$(this).getval()==1;switch($(this).getval()){case 0:o.controls=false;break;case 1:o.controls=true;break;case "stock":o.controls="stock"}$(".embed_code").setval(w(o))},
|
||||
help:"The type of controls that should be shown."},{label:"Autoplay",type:"checkbox",pointer:{main:o,index:"autoplay"},"function":function(){o.autoplay=$(this).getval();$(".embed_code").setval(w(o))},help:"Whether or not the video should play as the page is loaded."},{label:"Loop",type:"checkbox",pointer:{main:o,index:"loop"},"function":function(){o.loop=$(this).getval();$(".embed_code").setval(w(o))},help:"If the video should restart when the end is reached."},{label:"Force width",type:"int",min:0,
|
||||
unit:"px",pointer:{main:o,index:"width"},"function":function(){o.width=$(this).getval();$(".embed_code").setval(w(o))},help:"Enforce a fixed width."},{label:"Force height",type:"int",min:0,unit:"px",pointer:{main:o,index:"height"},"function":function(){o.height=$(this).getval();$(".embed_code").setval(w(o))},help:"Enforce a fixed height."},{label:"Maximum width",type:"int",min:0,unit:"px",pointer:{main:o,index:"maxwidth"},"function":function(){o.maxwidth=$(this).getval();$(".embed_code").setval(w(o))},
|
||||
help:"The maximum width this video can use."},{label:"Maximum height",type:"int",min:0,unit:"px",pointer:{main:o,index:"maxheight"},"function":function(){o.maxheight=$(this).getval();$(".embed_code").setval(w(o))},help:"The maximum height this video can use."},{label:"Poster",type:"str",pointer:{main:o,index:"poster"},"function":function(){o.poster=$(this).getval();$(".embed_code").setval(w(o))},help:"URL to an image that is displayed when the video is not playing."},{label:"Video URL addition",type:"str",
|
||||
pointer:{main:o,index:"urlappend"},help:"The embed script will append this string to the video url, useful for sending through params.",classes:["embed_code_forceprotocol"],"function":function(){o.urlappend=$(this).getval();$(".embed_code").setval(w(o))}},{label:"Preselect tracks",type:"DOMfield",DOMfield:H,help:"Pre-select these tracks."},$("<h3>").text("Protocol stream urls"),V]));$.ajax({type:"GET",url:E+"json_"+D+".js",success:function(a){var b=[],c=O.find(".forceType"),d;for(d in a.source){var e=
|
||||
a.source[d],f=UI.humanMime(e.type);b.push({label:f?f+" <span class=description>("+e.type+")</span>":UI.format.capital(e.type),type:"str",value:e.url,readonly:true,qrcode:true,clipboard:true});f=UI.humanMime(e.type);c.append($("<option>").text(f?f+" ("+e.type+")":UI.format.capital(e.type)).val(e.type))}V.html(UI.buildUI(b));H.html("");b={};for(d in a.meta.tracks){c=a.meta.tracks[d];c.type!="audio"&&c.type!="video"||(c.type in b?b[c.type].push([c.trackid,UI.format.capital(c.type)+" track "+(b[c.type].length+
|
||||
1)]):b[c.type]=[["",UI.format.capital(c.type)+" track 1"]])}if(Object.keys(b).length){H.closest("label").show();for(d in b){a=$("<select>").attr("data-type",d).css("flex-grow","1").change(function(){$(this).val()==""?delete o.setTracks[$(this).attr("data-type")]:o.setTracks[$(this).attr("data-type")]=$(this).val();$(".embed_code").setval(w(o))});H.append(a);b[d].push([-1,"No "+d]);for(var g in b[d])a.append($("<option>").val(b[d][g][0]).text(b[d][g][1]));if(d in o.setTracks){a.val(o.setTracks[d]);
|
||||
if(a.val()==null){a.val("");delete o.setTracks[d];$(".embed_code").setval(w(o))}}}}else H.closest("label").hide()},error:function(){V.html("Error while retrieving stream info.");H.closest("label").hide();o.setTracks={}}});f=document.createElement("script");f.src=L+"player.js";document.head.appendChild(f);f.onload=function(){var a=O.find(".forcePlayer"),b;for(b in mistplayers)a.append($("<option>").text(mistplayers[b].name).val(b));document.head.removeChild(this)};f.onerror=function(){document.head.removeChild(this)};
|
||||
break;case "Push":var z=$("<div>").text("Loading..");c.append(z);mist.send(function(a){function b(a){setTimeout(function(){mist.send(function(c){var d=false;if("push_list"in c&&c.push_list&&c.push_list.length){var d=true,f;for(f in c.push_list)if(a.indexOf(c.push_list[f][0])>-1){d=false;break}}else d=true;if(d)for(f in a)e.find("tr[data-pushid="+a[f]+"]").remove();else b()},{push_list:1})},1E3)}function c(d,f){var g=$("<span>");d.length>=4&&d[2]!=d[3]?g.append($("<span>").text(d[2])).append($("<span>").html("»").addClass("unit").css("margin",
|
||||
"0 0.5em")).append($("<span>").text(d[3])):g.append($("<span>").text(d[2]));var h=$("<td>").append($("<button>").text(f=="Automatic"?"Remove":"Stop").click(function(){if(confirm("Are you sure you want to "+$(this).text().toLowerCase()+" this push?\n"+d[1]+" to "+d[2])){var a=$(this).closest("tr");a.html($("<td colspan=99>").html($("<span>").addClass("red").text(f=="Automatic"?"Removing..":"Stopping..")));f=="Automatic"?mist.send(function(){a.remove()},{push_auto_remove:{stream:d[1],target:d[2]}}):
|
||||
mist.send(function(){b([d[0]])},{push_stop:[d[0]]})}}));f=="Automatic"&&h.append($("<button>").text("Remove and stop pushes").click(function(){if(confirm("Are you sure you want to remove this automatic push, and also stop all pushes matching it?\n"+d[1]+" to "+d[2])){var c=$(this).closest("tr");c.html($("<td colspan=99>").html($("<span>").addClass("red").text("Removing and stopping..")));var f=[],g;for(g in a.push_list)if(d[1]==a.push_list[g][1]&&d[2]==a.push_list[g][2]){f.push(a.push_list[g][0]);
|
||||
e.find("tr[data-pushid="+a.push_list[g][0]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}mist.send(function(){c.remove();b(f)},{push_auto_remove:{stream:d[1],target:d[2]},push_stop:f})}}));return $("<tr>").attr("data-pushid",d[0]).append($("<td>").text(d[1])).append($("<td>").append(g.children())).append(h)}y.html("");var d=a.push_settings;d||(d={});y.append(UI.buildUI([{type:"help",help:"You can push streams to files or other servers, allowing them to broadcast your stream as well."},
|
||||
e.find("tr[data-pushid="+a.push_list[g][0]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}mist.send(function(){c.remove();b(f)},{push_auto_remove:{stream:d[1],target:d[2]},push_stop:f})}}));return $("<tr>").attr("data-pushid",d[0]).append($("<td>").text(d[1])).append($("<td>").append(g.children())).append(h)}z.html("");var d=a.push_settings;d||(d={});z.append(UI.buildUI([{type:"help",help:"You can push streams to files or other servers, allowing them to broadcast your stream as well."},
|
||||
$("<h3>").text("Settings"),{label:"Delay before retry",unit:"s",type:"int",min:0,help:"How long the delay should be before MistServer retries an automatic push.<br>If set to 0, it does not retry.","default":0,pointer:{main:d,index:"wait"},LTSonly:1},{label:"Maximum retries",unit:"/s",type:"int",min:0,help:"The maximum amount of retries per second (for all automatic pushes).<br>If set to 0, there is no limit.","default":0,pointer:{main:d,index:"maxspeed"},LTSonly:1},{type:"buttons",buttons:[{type:"save",
|
||||
label:"Save","function":function(){mist.send(function(){UI.navto("Push")},{push_settings:d})}}]}]));var e=$("<table>").append($("<tr>").append($("<th>").text("Stream")).append($("<th>").text("Target")).append($("<th>"))),g=e.clone();if("push_list"in a)for(var f in a.push_list)e.append(c(a.push_list[f],"Manual"));if("push_auto_list"in a)for(f in a.push_auto_list)g.append(c([-1,a.push_auto_list[f][0],a.push_auto_list[f][1]],"Automatic"));y.append($("<h3>").text("Automatic pushes")).append($("<button>").text("Add an automatic push").click(function(){UI.navto("Start Push",
|
||||
"auto")}));g.find("tr").length==1?y.append($("<div>").text("No automatic pushes have been configured.").addClass("text").css("margin-top","0.5em")):y.append(g);y.append($("<h3>").text("Pushes")).append($("<button>").text("Start a push").click(function(){UI.navto("Start Push")}));if(e.find("tr").length==1)y.append($("<div>").text("No pushes are active.").addClass("text").css("margin-top","0.5em"));else{var g=[],h=[],i=$("<select>").css("margin-left","0.5em").append($("<option>").text("Any stream").val("")),
|
||||
j=$("<select>").css("margin-left","0.5em").append($("<option>").text("Any target").val(""));for(f in a.push_list){g.indexOf(a.push_list[f][1])==-1&&g.push(a.push_list[f][1]);h.indexOf(a.push_list[f][2])==-1&&h.push(a.push_list[f][2])}g.sort();h.sort();for(f in g)i.append($("<option>").text(g[f]));for(f in h)j.append($("<option>").text(h[f]));y.append($("<button>").text("Stop all pushes").click(function(){var c=[],d;for(d in a.push_list)c.push(a.push_list[d][0]);if(c.length!=0&&confirm("Are you sure you want to stop all pushes?")){mist.send(function(){b(c)},
|
||||
label:"Save","function":function(){mist.send(function(){UI.navto("Push")},{push_settings:d})}}]}]));var e=$("<table>").append($("<tr>").append($("<th>").text("Stream")).append($("<th>").text("Target")).append($("<th>"))),f=e.clone();if("push_list"in a)for(var g in a.push_list)e.append(c(a.push_list[g],"Manual"));if("push_auto_list"in a)for(g in a.push_auto_list)f.append(c([-1,a.push_auto_list[g][0],a.push_auto_list[g][1]],"Automatic"));z.append($("<h3>").text("Automatic pushes")).append($("<button>").text("Add an automatic push").click(function(){UI.navto("Start Push",
|
||||
"auto")}));f.find("tr").length==1?z.append($("<div>").text("No automatic pushes have been configured.").addClass("text").css("margin-top","0.5em")):z.append(f);z.append($("<h3>").text("Pushes")).append($("<button>").text("Start a push").click(function(){UI.navto("Start Push")}));if(e.find("tr").length==1)z.append($("<div>").text("No pushes are active.").addClass("text").css("margin-top","0.5em"));else{var f=[],h=[],i=$("<select>").css("margin-left","0.5em").append($("<option>").text("Any stream").val("")),
|
||||
j=$("<select>").css("margin-left","0.5em").append($("<option>").text("Any target").val(""));for(g in a.push_list){f.indexOf(a.push_list[g][1])==-1&&f.push(a.push_list[g][1]);h.indexOf(a.push_list[g][2])==-1&&h.push(a.push_list[g][2])}f.sort();h.sort();for(g in f)i.append($("<option>").text(f[g]));for(g in h)j.append($("<option>").text(h[g]));z.append($("<button>").text("Stop all pushes").click(function(){var c=[],d;for(d in a.push_list)c.push(a.push_list[d][0]);if(c.length!=0&&confirm("Are you sure you want to stop all pushes?")){mist.send(function(){b(c)},
|
||||
{push_stop:c});e.find("tr:not(:first-child)").html($("<td colspan=99>").append($("<span>").addClass("red").text("Stopping..")));$(this).remove()}})).append($("<label>").css("margin-left","1em").append($("<span>").text("Stop all pushes that match: ").css("font-size","0.9em")).append(i).append($("<span>").css("margin-left","0.5em").text("and").css("font-size","0.9em")).append(j).append($("<button>").css("margin-left","0.5em").text("Apply").click(function(){var c=i.val(),d=j.val();if(c==""&&d=="")return alert("Looks like you want to stop all pushes. Maybe you should use that button?");
|
||||
var f={},g;for(g in a.push_list)if((c==""||a.push_list[g][1]==c)&&(d==""||a.push_list[g][2]==d))f[a.push_list[g][0]]=a.push_list[g];if(Object.keys(f).length==0)return alert("No matching pushes.");c="Are you sure you want to stop these pushes?\n\n";for(g in f)c=c+(f[g][1]+" to "+f[g][2]+"\n");if(confirm(c)){f=Object.keys(f);mist.send(function(){b(f)},{push_stop:f});for(g in f)e.find("tr[data-pushid="+f[g]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}}))).append(e)}},
|
||||
{push_settings:1,push_list:1,push_auto_list:1});break;case "Start Push":if(!("capabilities"in mist.data)){c.append("Loading Mist capabilities..");mist.send(function(){UI.navto("Start Push",b)},{capabilities:1});break}var u,W=function(){var a=[],d;for(d in mist.data.capabilities.connectors){var f=mist.data.capabilities.connectors[d];"push_urls"in f&&(a=a.concat(f.push_urls))}b=="auto"&&c.find("h2").text("Add automatic push");var g={};c.append(UI.buildUI([{label:"Stream name",type:"str",help:"This may either be a full stream name, a partial wildcard stream name, or a full wildcard stream name.<br>For example, given the stream <i>a</i> you can use:<ul><li><i>a</i>: the stream configured as <i>a</i></li><li><i>a+</i>: all streams configured as <i>a</i> with a wildcard behind it, but not <i>a</i> itself</li><li><i>a+b</i>: only the version of stream <i>a</i> that has wildcard <i>b</i></li></ul>",
|
||||
pointer:{main:g,index:"stream"},validate:["required",function(a){a=a.split("+");a=a[0];return a in mist.data.streams?false:{msg:"'"+a+"' is not a stream name.",classes:["red"]}}],datalist:u,LTSonly:1},{label:"Target",type:"str",help:"Where the stream will be pushed to.<br>Valid formats:<ul><li>"+a.join("</li><li>")+"</li></ul> Valid text replacements:<ul><li>$stream - inserts the stream name used to push to MistServer</li><li>$day - inserts the current day number</li><li>$month - inserts the current month number</li><li>$year - inserts the current year number</li><li>$hour - inserts the hour timestamp when stream was received</li><li>$minute - inserts the minute timestamp the stream was received</li><li>$seconds - inserts the seconds timestamp when the stream was received</li><li>$datetime - inserts $year.$month.$day.$hour.$minute.$seconds timestamp when the stream was received</li>",
|
||||
pointer:{main:g,index:"target"},validate:["required",function(b){for(var c in a)if(mist.inputMatch(a[c],b))return false;return{msg:"Does not match a valid target.<br>Valid formats:<ul><li>"+a.join("</li><li>")+"</li></ul>",classes:["red"]}}],LTSonly:1},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Push")}},{type:"save",label:"Save","function":function(){var a={};a[b=="auto"?"push_auto_add":"push_start"]=g;mist.send(function(){UI.navto("Push")},a)}}]}]))};mist.data.LTS?
|
||||
mist.send(function(a){(u=a.active_streams)||(u=[]);var a=[],b;for(b in u)u[b].indexOf("+")!=-1&&a.push(u[b].replace(/\+.*/,"")+"+");u=u.concat(a);var c=0,d=0;for(b in mist.data.streams){u.push(b);if(mist.inputMatch(mist.data.capabilities.inputs.Folder.source_match,mist.data.streams[b].source)){u.push(b+"+");mist.send(function(a,b){var f=b.stream,g;for(g in a.browse.files)for(var e in mist.data.capabilities.inputs)e.indexOf("Buffer")>=0||e.indexOf("Folder")>=0||mist.inputMatch(mist.data.capabilities.inputs[e].source_match,
|
||||
"/"+a.browse.files[g])&&u.push(f+"+"+a.browse.files[g]);d++;if(c==d){u=u.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();W()}},{browse:mist.data.streams[b].source},{stream:b});c++}}if(c==d){u=u.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();W()}},{active_streams:1}):(u=Object.keys(mist.data.streams),W());break;case "Triggers":"triggers"in mist.data.config||(mist.data.config.triggers={});g=$("<tbody>");r=$("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Trigger on").attr("data-sort-type",
|
||||
"string").addClass("sorting-asc")).append($("<th>").text("Applies to").attr("data-sort-type","string")).append($("<th>").text("Handler").attr("data-sort-type","string")).append($("<th>")))).append(g);c.append(UI.buildUI([{type:"help",help:"Triggers are the system you can use to react to events that occur inside MistServer. These allow you to block specific users, redirect streams, keep tabs on what is being pushed where, etcetera. For full documentation, please refer to the developer documentation section on the MistServer website."}])).append($("<button>").text("New trigger").click(function(){UI.navto("Edit Trigger")})).append(r);
|
||||
r.stupidtable();r=mist.data.config.triggers;for(f in r)for(s in r[f])g.append($("<tr>").attr("data-index",f+","+s).append($("<td>").text(f)).append($("<td>").text(r[f][s][2].join(", "))).append($("<td>").text(r[f][s][0])).append($("<td>").html($("<button>").text("Edit").click(function(){UI.navto("Edit Trigger",$(this).closest("tr").attr("data-index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").attr("data-index").split(",");if(confirm("Are you sure you want to delete this "+
|
||||
"/"+a.browse.files[g])&&u.push(f+"+"+a.browse.files[g]);d++;if(c==d){u=u.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();W()}},{browse:mist.data.streams[b].source},{stream:b});c++}}if(c==d){u=u.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();W()}},{active_streams:1}):(u=Object.keys(mist.data.streams),W());break;case "Triggers":"triggers"in mist.data.config||(mist.data.config.triggers={});g=$("<tbody>");s=$("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Trigger on").attr("data-sort-type",
|
||||
"string").addClass("sorting-asc")).append($("<th>").text("Applies to").attr("data-sort-type","string")).append($("<th>").text("Handler").attr("data-sort-type","string")).append($("<th>")))).append(g);c.append(UI.buildUI([{type:"help",help:"Triggers are the system you can use to react to events that occur inside MistServer. These allow you to block specific users, redirect streams, keep tabs on what is being pushed where, etcetera. For full documentation, please refer to the developer documentation section on the MistServer website."}])).append($("<button>").text("New trigger").click(function(){UI.navto("Edit Trigger")})).append(s);
|
||||
s.stupidtable();s=mist.data.config.triggers;for(f in s)for(r in s[f])g.append($("<tr>").attr("data-index",f+","+r).append($("<td>").text(f)).append($("<td>").text(s[f][r][2].join(", "))).append($("<td>").text(s[f][r][0])).append($("<td>").html($("<button>").text("Edit").click(function(){UI.navto("Edit Trigger",$(this).closest("tr").attr("data-index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").attr("data-index").split(",");if(confirm("Are you sure you want to delete this "+
|
||||
a[0]+" trigger?")){mist.data.config.triggers[a[0]].splice(a[1],1);mist.data.config.triggers[a[0]].length==0&&delete mist.data.config.triggers[a[0]];mist.send(function(){UI.navto("Triggers")},{config:mist.data.config})}}))));break;case "Edit Trigger":"triggers"in mist.data.config||(mist.data.config.triggers={});b?(b=b.split(","),f=mist.data.config.triggers[b[0]][b[1]],m={triggeron:b[0],appliesto:f[2],url:f[0],async:f[1],"default":f[3]}):(c.html($("<h2>").text("New Trigger")),m={});c.append(UI.buildUI([{label:"Trigger on",
|
||||
pointer:{main:m,index:"triggeron"},help:"For what event this trigger should activate.",type:"select",select:[["SYSTEM_START","SYSTEM_START: after MistServer boot"],["SYSTEM_STOP","SYSTEM_STOP: right before MistServer shutdown"],["SYSTEM_CONFIG","SYSTEM_CONFIG: after MistServer configurations have changed"],["OUTPUT_START","OUTPUT_START: right after the start command has been send to a protocol"],["OUTPUT_STOP","OUTPUT_STOP: right after the close command has been send to a protocol "],["STREAM_ADD",
|
||||
"STREAM_ADD: right before new stream configured"],["STREAM_CONFIG","STREAM_CONFIG: right before a stream configuration has changed"],["STREAM_REMOVE","STREAM_REMOVE: right before a stream has been deleted"],["STREAM_SOURCE","STREAM_SOURCE: right before stream source is loaded"],["STREAM_LOAD","STREAM_LOAD: right before stream input is loaded in memory"],["STREAM_READY","STREAM_READY: when the stream input is loaded and ready for playback"],["STREAM_UNLOAD","STREAM_UNLOAD: right before the stream input is removed from memory"],
|
||||
|
@ -158,20 +159,20 @@ pointer:{main:m,index:"triggeron"},help:"For what event this trigger should acti
|
|||
break;default:$("[name=appliesto]").closest(".UIelement").show()}}},{label:"Applies to",pointer:{main:m,index:"appliesto"},help:"For triggers that can apply to specific streams, this value decides what streams they are triggered for. (none checked = always triggered)",type:"checklist",checklist:Object.keys(mist.data.streams),LTSonly:!0},$("<br>"),{label:"Handler (URL or executable)",help:"This can be either an HTTP URL or a full path to an executable.",pointer:{main:m,index:"url"},validate:["required"],
|
||||
type:"str",LTSonly:!0},{label:"Blocking",type:"checkbox",help:"If checked, pauses processing and uses the response of the handler. If the response does not start with 1, true, yes or cont, further processing is aborted. If unchecked, processing is never paused and the response is not checked.",pointer:{main:m,index:"async"},LTSonly:!0},{label:"Default response",type:"str",help:"For blocking requests, the default response in case the handler cannot be executed for any reason.",pointer:{main:m,index:"default"},
|
||||
LTSonly:!0},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Triggers")}},{type:"save",label:"Save","function":function(){b&&mist.data.config.triggers[b[0]].splice(b[1],1);var a=[m.url,m.async?true:false,typeof m.appliesto!="undefined"?m.appliesto:[]];typeof m["default"]!="undefined"&&a.push(m["default"]);m.triggeron in mist.data.config.triggers||(mist.data.config.triggers[m.triggeron]=[]);mist.data.config.triggers[m.triggeron].push(a);mist.send(function(){UI.navto("Triggers")},
|
||||
{config:mist.data.config})}}]}]));$("[name=triggeron]").trigger("change");break;case "Logs":var fa=$("<button>").text("Refresh now").click(function(){$(this).text("Loading..");mist.send(function(){X();fa.text("Refresh now")})}).css("padding","0.2em 0.5em").css("flex-grow",0);c.append(UI.buildUI([{type:"help",help:"Here you have an overview of all edited settings within MistServer and possible warnings or errors MistServer has encountered. MistServer stores up to 100 logs at a time."},{label:"Refresh every",
|
||||
type:"select",select:[[10,"10 seconds"],[30,"30 seconds"],[60,"minute"],[300,"5 minutes"]],value:30,"function":function(){UI.interval.clear();UI.interval.set(function(){mist.send(function(){X()})},$(this).val()*1E3)},help:"How often the table below should be updated."},{label:"..or",type:"DOMfield",DOMfield:fa,help:"Instantly refresh the table below."}]));c.append($("<button>").text("Purge logs").click(function(){mist.send(function(){mist.data.log=[];UI.navto("Logs")},{clearstatlogs:true})}));g=$("<tbody>").css("font-size",
|
||||
"0.9em");c.append($("<table>").append(g));var ha=function(a){var b=$("<span>").text(a);switch(a){case "WARN":b.addClass("orange");break;case "ERROR":case "FAIL":b.addClass("red")}return b},X=function(){var a=mist.data.log;if(a){a.length>=2&&a[0][0]<a[a.length-1][0]&&a.reverse();g.html("");for(var b in a)g.append($("<tr>").html($("<td>").text(UI.format.dateTime(a[b][0],"long")).css("white-space","nowrap")).append($("<td>").html(ha(a[b][1])).css("text-align","center")).append($("<td>").text(a[b][2]).css("text-align",
|
||||
"left")))}};X();break;case "Statistics":var A=$("<span>").text("Loading..");c.append(A);var m={},w=mist.stored.get().graphs?$.extend(!0,{},mist.stored.get().graphs):{},J={};for(f in mist.data.streams)J[f]=!0;for(f in mist.data.active_streams)J[mist.data.active_streams[f]]=!0;var J=Object.keys(J).sort(),Y=[];for(f in mist.data.config.protocols)Y.push(mist.data.config.protocols[f].connector);Y.sort();mist.send(function(){UI.plot.datatype.templates.cpuload.cores=0;for(var a in mist.data.capabilities.cpu)UI.plot.datatype.templates.cpuload.cores=
|
||||
UI.plot.datatype.templates.cpuload.cores+mist.data.capabilities.cpu[a].cores;A.html(UI.buildUI([{type:"help",help:"Here you will find the MistServer stream statistics, you can select various categories yourself. All statistics are live: up to five minutes are saved."},$("<h3>").text("Select the data to display"),{label:"Add to",type:"select",select:[["new","New graph"]],pointer:{main:m,index:"graph"},classes:["graph_ids"],"function":function(){if($(this).val()){var a=A.find(".graph_xaxis"),b=A.find(".graph_id");
|
||||
if($(this).val()=="new"){a.children("option").prop("disabled",false);b.setval("Graph "+(Object.keys(w).length+1)).closest("label").show()}else{var c=w[$(this).val()].xaxis;a.children("option").prop("disabled",true).filter('[value="'+c+'"]').prop("disabled",false);b.closest("label").hide()}a.children('option[value="'+a.val()+'"]:disabled').length&&a.val(a.children("option:enabled").first().val());a.trigger("change")}}},{label:"Graph id",type:"str",pointer:{main:m,index:"id"},classes:["graph_id"],validate:[function(a){return a in
|
||||
w?{msg:"This graph id has already been used. Please enter something else.",classes:["red"]}:false}]},{label:"Axis type",type:"select",select:[["time","Time line"]],pointer:{main:m,index:"xaxis"},value:"time",classes:["graph_xaxis"],"function":function(){$s=A.find(".graph_datatype");switch($(this).getval()){case "coords":$s.children("option").prop("disabled",true).filter('[value="coords"]').prop("disabled",false);break;case "time":$s.children("option").prop("disabled",false).filter('[value="coords"]').prop("disabled",
|
||||
true)}if(!$s.val()||$s.children('option[value="'+$s.val()+'"]:disabled').length){$s.val($s.children("option:enabled").first().val());$s.trigger("change")}}},{label:"Data type",type:"select",select:[["clients","Connections"],["upbps","Bandwidth (up)"],["downbps","Bandwidth (down)"],["cpuload","CPU use"],["memload","Memory load"],["coords","Client location"]],pointer:{main:m,index:"datatype"},classes:["graph_datatype"],"function":function(){$s=A.find(".graph_origin");switch($(this).getval()){case "cpuload":case "memload":$s.find("input[type=radio]").not('[value="total"]').prop("disabled",
|
||||
true);$s.find('input[type=radio][value="total"]').prop("checked",true);break;default:$s.find("input[type=radio]").prop("disabled",false)}}},{label:"Data origin",type:"radioselect",radioselect:[["total","All"],["stream","The stream:",J],["protocol","The protocol:",Y]],pointer:{main:m,index:"origin"},value:["total"],classes:["graph_origin"]},{type:"buttons",buttons:[{label:"Add data set",type:"save","function":function(){var a;if(m.graph=="new"){a=UI.plot.addGraph(m,b);w[a.id]=a;A.find("select.graph_ids").append($("<option>").text(a.id)).val(a.id).trigger("change")}else a=
|
||||
w[m.graph];var c=UI.plot.datatype.getOptions({datatype:m.datatype,origin:m.origin});a.datasets.push(c);UI.plot.save(a);UI.plot.go(w)}}]}]));var b=$("<div>").addClass("graph_container");c.append(b);var d=A.find("select.graph_ids");for(a in w){var f=UI.plot.addGraph(w[a],b);d.append($("<option>").text(f.id)).val(f.id);var g=[],e;for(e in w[a].datasets){var h=UI.plot.datatype.getOptions({datatype:w[a].datasets[e].datatype,origin:w[a].datasets[e].origin});g.push(h)}f.datasets=g;w[f.id]=f}d.trigger("change");
|
||||
UI.plot.go(w);UI.interval.set(function(){UI.plot.go(w)},1E4)},{active_streams:!0,capabilities:!0});break;case "Server Stats":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});c.append("Loading..");break}var Z=$("<table>"),B=$("<table>"),s={vheader:"CPUs",labels:["Model","Processor speed","Amount of cores","Amount of threads"],content:[]};for(f in mist.data.capabilities.cpu)r=mist.data.capabilities.cpu[f],s.content.push({header:"CPU #"+(Number(f)+1),
|
||||
body:[r.model,UI.format.addUnit(UI.format.number(r.mhz),"MHz"),r.cores,r.threads]});var f=UI.buildVheaderTable(s),ga=function(){var a=mist.data.capabilities.mem,b=mist.data.capabilities.load,a={vheader:"Memory",labels:["Used","Cached","Available","Total"],content:[{header:"Physical memory",body:[UI.format.bytes(a.used*1048576)+" ("+UI.format.addUnit(b.memory,"%")+")",UI.format.bytes(a.cached*1048576),UI.format.bytes(a.free*1048576),UI.format.bytes(a.total*1048576)]},{header:"Swap memory",body:[UI.format.bytes((a.swaptotal-
|
||||
a.swapfree)*1048576),UI.format.addUnit("","N/A"),UI.format.bytes(a.swapfree*1048576),UI.format.bytes(a.swaptotal*1048576)]}]},a=UI.buildVheaderTable(a);Z.replaceWith(a);Z=a;b={vheader:"Load average",labels:["CPU use","1 minute","5 minutes","15 minutes"],content:[{header:" ",body:[UI.format.addUnit(UI.format.number(mist.data.capabilities.cpu_use/10),"%"),UI.format.number(b.one/100),UI.format.number(b.five/100),UI.format.number(b.fifteen/100)]}]};b=UI.buildVheaderTable(b);B.replaceWith(b);B=b};
|
||||
ga();c.append(UI.buildUI([{type:"help",help:"You can find general server statistics here. Note that memory and CPU usage is for your entire machine, not just MistServer."}])).append($("<table>").css("width","auto").addClass("nolay").append($("<tr>").append($("<td>").append(Z)).append($("<td>").append(B))).append($("<tr>").append($("<td>").append(f).attr("colspan",2))));UI.interval.set(function(){mist.send(function(){ga()},{capabilities:true})},3E4);break;case "Email for Help":f=$.extend({},mist.data);
|
||||
{config:mist.data.config})}}]}]));$("[name=triggeron]").trigger("change");break;case "Logs":var ha=$("<button>").text("Refresh now").click(function(){$(this).text("Loading..");mist.send(function(){X();ha.text("Refresh now")})}).css("padding","0.2em 0.5em").css("flex-grow",0);c.append(UI.buildUI([{type:"help",help:"Here you have an overview of all edited settings within MistServer and possible warnings or errors MistServer has encountered. MistServer stores up to 100 logs at a time."},{label:"Refresh every",
|
||||
type:"select",select:[[10,"10 seconds"],[30,"30 seconds"],[60,"minute"],[300,"5 minutes"]],value:30,"function":function(){UI.interval.clear();UI.interval.set(function(){mist.send(function(){X()})},$(this).val()*1E3)},help:"How often the table below should be updated."},{label:"..or",type:"DOMfield",DOMfield:ha,help:"Instantly refresh the table below."}]));c.append($("<button>").text("Purge logs").click(function(){mist.send(function(){mist.data.log=[];UI.navto("Logs")},{clearstatlogs:true})}));g=$("<tbody>").css("font-size",
|
||||
"0.9em");c.append($("<table>").append(g));var ja=function(a){var b=$("<span>").text(a);switch(a){case "WARN":b.addClass("orange");break;case "ERROR":case "FAIL":b.addClass("red")}return b},X=function(){var a=mist.data.log;if(a){a.length>=2&&a[0][0]<a[a.length-1][0]&&a.reverse();g.html("");for(var b in a)g.append($("<tr>").html($("<td>").text(UI.format.dateTime(a[b][0],"long")).css("white-space","nowrap")).append($("<td>").html(ja(a[b][1])).css("text-align","center")).append($("<td>").text(a[b][2]).css("text-align",
|
||||
"left")))}};X();break;case "Statistics":var B=$("<span>").text("Loading..");c.append(B);var m={},x=mist.stored.get().graphs?$.extend(!0,{},mist.stored.get().graphs):{},J={};for(f in mist.data.streams)J[f]=!0;for(f in mist.data.active_streams)J[mist.data.active_streams[f]]=!0;var J=Object.keys(J).sort(),Y=[];for(f in mist.data.config.protocols)Y.push(mist.data.config.protocols[f].connector);Y.sort();mist.send(function(){UI.plot.datatype.templates.cpuload.cores=0;for(var a in mist.data.capabilities.cpu)UI.plot.datatype.templates.cpuload.cores=
|
||||
UI.plot.datatype.templates.cpuload.cores+mist.data.capabilities.cpu[a].cores;B.html(UI.buildUI([{type:"help",help:"Here you will find the MistServer stream statistics, you can select various categories yourself. All statistics are live: up to five minutes are saved."},$("<h3>").text("Select the data to display"),{label:"Add to",type:"select",select:[["new","New graph"]],pointer:{main:m,index:"graph"},classes:["graph_ids"],"function":function(){if($(this).val()){var a=B.find(".graph_xaxis"),b=B.find(".graph_id");
|
||||
if($(this).val()=="new"){a.children("option").prop("disabled",false);b.setval("Graph "+(Object.keys(x).length+1)).closest("label").show()}else{var c=x[$(this).val()].xaxis;a.children("option").prop("disabled",true).filter('[value="'+c+'"]').prop("disabled",false);b.closest("label").hide()}a.children('option[value="'+a.val()+'"]:disabled').length&&a.val(a.children("option:enabled").first().val());a.trigger("change")}}},{label:"Graph id",type:"str",pointer:{main:m,index:"id"},classes:["graph_id"],validate:[function(a){return a in
|
||||
x?{msg:"This graph id has already been used. Please enter something else.",classes:["red"]}:false}]},{label:"Axis type",type:"select",select:[["time","Time line"]],pointer:{main:m,index:"xaxis"},value:"time",classes:["graph_xaxis"],"function":function(){$s=B.find(".graph_datatype");switch($(this).getval()){case "coords":$s.children("option").prop("disabled",true).filter('[value="coords"]').prop("disabled",false);break;case "time":$s.children("option").prop("disabled",false).filter('[value="coords"]').prop("disabled",
|
||||
true)}if(!$s.val()||$s.children('option[value="'+$s.val()+'"]:disabled').length){$s.val($s.children("option:enabled").first().val());$s.trigger("change")}}},{label:"Data type",type:"select",select:[["clients","Connections"],["upbps","Bandwidth (up)"],["downbps","Bandwidth (down)"],["cpuload","CPU use"],["memload","Memory load"],["coords","Client location"]],pointer:{main:m,index:"datatype"},classes:["graph_datatype"],"function":function(){$s=B.find(".graph_origin");switch($(this).getval()){case "cpuload":case "memload":$s.find("input[type=radio]").not('[value="total"]').prop("disabled",
|
||||
true);$s.find('input[type=radio][value="total"]').prop("checked",true);break;default:$s.find("input[type=radio]").prop("disabled",false)}}},{label:"Data origin",type:"radioselect",radioselect:[["total","All"],["stream","The stream:",J],["protocol","The protocol:",Y]],pointer:{main:m,index:"origin"},value:["total"],classes:["graph_origin"]},{type:"buttons",buttons:[{label:"Add data set",type:"save","function":function(){var a;if(m.graph=="new"){a=UI.plot.addGraph(m,b);x[a.id]=a;B.find("select.graph_ids").append($("<option>").text(a.id)).val(a.id).trigger("change")}else a=
|
||||
x[m.graph];var c=UI.plot.datatype.getOptions({datatype:m.datatype,origin:m.origin});a.datasets.push(c);UI.plot.save(a);UI.plot.go(x)}}]}]));var b=$("<div>").addClass("graph_container");c.append(b);var d=B.find("select.graph_ids");for(a in x){var f=UI.plot.addGraph(x[a],b);d.append($("<option>").text(f.id)).val(f.id);var g=[],e;for(e in x[a].datasets){var h=UI.plot.datatype.getOptions({datatype:x[a].datasets[e].datatype,origin:x[a].datasets[e].origin});g.push(h)}f.datasets=g;x[f.id]=f}d.trigger("change");
|
||||
UI.plot.go(x);UI.interval.set(function(){UI.plot.go(x)},1E4)},{active_streams:!0,capabilities:!0});break;case "Server Stats":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});c.append("Loading..");break}var Z=$("<table>"),C=$("<table>"),r={vheader:"CPUs",labels:["Model","Processor speed","Amount of cores","Amount of threads"],content:[]};for(f in mist.data.capabilities.cpu)s=mist.data.capabilities.cpu[f],r.content.push({header:"CPU #"+(Number(f)+1),
|
||||
body:[s.model,UI.format.addUnit(UI.format.number(s.mhz),"MHz"),s.cores,s.threads]});var f=UI.buildVheaderTable(r),ia=function(){var a=mist.data.capabilities.mem,b=mist.data.capabilities.load,a={vheader:"Memory",labels:["Used","Cached","Available","Total"],content:[{header:"Physical memory",body:[UI.format.bytes(a.used*1048576)+" ("+UI.format.addUnit(b.memory,"%")+")",UI.format.bytes(a.cached*1048576),UI.format.bytes(a.free*1048576),UI.format.bytes(a.total*1048576)]},{header:"Swap memory",body:[UI.format.bytes((a.swaptotal-
|
||||
a.swapfree)*1048576),UI.format.addUnit("","N/A"),UI.format.bytes(a.swapfree*1048576),UI.format.bytes(a.swaptotal*1048576)]}]},a=UI.buildVheaderTable(a);Z.replaceWith(a);Z=a;b={vheader:"Load average",labels:["CPU use","1 minute","5 minutes","15 minutes"],content:[{header:" ",body:[UI.format.addUnit(UI.format.number(mist.data.capabilities.cpu_use/10),"%"),UI.format.number(b.one/100),UI.format.number(b.five/100),UI.format.number(b.fifteen/100)]}]};b=UI.buildVheaderTable(b);C.replaceWith(b);C=b};
|
||||
ia();c.append(UI.buildUI([{type:"help",help:"You can find general server statistics here. Note that memory and CPU usage is for your entire machine, not just MistServer."}])).append($("<table>").css("width","auto").addClass("nolay").append($("<tr>").append($("<td>").append(Z)).append($("<td>").append(C))).append($("<tr>").append($("<td>").append(f).attr("colspan",2))));UI.interval.set(function(){mist.send(function(){ia()},{capabilities:true})},3E4);break;case "Email for Help":f=$.extend({},mist.data);
|
||||
delete f.statistics;delete f.totals;delete f.clients;delete f.capabilities;f=JSON.stringify(f);f="Version: "+mist.data.config.version+"\n\nConfig:\n"+f;m={};c.append(UI.buildUI([{type:"help",help:"You can use this form to email MistServer support if you're having difficulties.<br>A copy of your server config file will automatically be included."},{type:"str",label:"Your name",validate:["required"],pointer:{main:m,index:"name"},value:mist.user.name},{type:"email",label:"Your email address",validate:["required"],
|
||||
pointer:{main:m,index:"email"}},{type:"hidden",value:"Integrated Help",pointer:{main:m,index:"subject"}},{type:"hidden",value:"-",pointer:{main:m,index:"company"}},{type:"textarea",rows:20,label:"Your message",validate:["required"],pointer:{main:m,index:"message"}},{type:"textarea",rows:20,label:"Your config file",readonly:!0,value:f,pointer:{main:m,index:"configfile"}},{type:"buttons",buttons:[{type:"save",label:"Send","function":function(a){$(a).text("Sending..");$.ajax({type:"POST",url:"http://mistserver.org/contact?skin=plain",
|
||||
data:m,success:function(a){a=$("<span>").html(a);a.find("script").remove();c.html(a[0].innerHTML)}})}}]}]));break;case "Disconnect":mist.user.password="";delete mist.user.authstring;delete mist.user.loggedin;sessionStorage.removeItem("mistLogin");UI.navto("Login");break;default:c.append($("<p>").text("This tab does not exist."))}}}};"origin"in location||(location.origin=location.protocol+"//"+location.hostname+(location.port?":"+location.port:""));
|
||||
|
|
26
lsp/mist.js
26
lsp/mist.js
|
@ -2410,6 +2410,16 @@ var UI = {
|
|||
UI.navto('Streams',(other == 'thumbnails' ? 'list' : 'thumbnails'));
|
||||
});
|
||||
|
||||
var allstreams = $.extend(true,{},mist.data.streams);
|
||||
function createWcStreamObject(streamname,parent) {
|
||||
var wcstream = $.extend({},parent);
|
||||
delete wcstream.meta;
|
||||
delete wcstream.error;
|
||||
wcstream.online = 2; //should either be available (2) or active (1)
|
||||
wcstream.name = streamname;
|
||||
wcstream.ischild = true;
|
||||
return wcstream;
|
||||
}
|
||||
|
||||
function createPage(type,streams,folders) {
|
||||
$loading.remove();
|
||||
|
@ -2669,16 +2679,6 @@ var UI = {
|
|||
});
|
||||
}
|
||||
|
||||
var allstreams = $.extend(true,{},mist.data.streams);
|
||||
function createWcStreamObject(streamname,parent) {
|
||||
var wcstream = $.extend({},parent);
|
||||
delete wcstream.meta;
|
||||
delete wcstream.error;
|
||||
wcstream.online = 2; //should either be available (2) or active (1)
|
||||
wcstream.name = streamname;
|
||||
wcstream.ischild = true;
|
||||
return wcstream;
|
||||
}
|
||||
|
||||
if (mist.data.LTS) {
|
||||
//insert folder streams
|
||||
|
@ -2773,10 +2773,12 @@ var UI = {
|
|||
var split = mist.data.active_streams[i].split('+');
|
||||
if ((split.length > 1) && (split[0] in mist.data.streams)) {
|
||||
select[mist.data.active_streams[i]] = true;
|
||||
allstreams[mist.data.active_streams[i]] = createWcStreamObject(mist.data.active_streams[i],mist.data.streams[split[0]]);
|
||||
}
|
||||
}
|
||||
select = Object.keys(select);
|
||||
select = select.concat(Object.keys(mist.data.streams));
|
||||
select.sort();
|
||||
createPage(other,select,folders);
|
||||
},{active_streams: true});
|
||||
}
|
||||
|
@ -2786,13 +2788,15 @@ var UI = {
|
|||
}
|
||||
if (browserequests == 0) {
|
||||
mist.send(function(){
|
||||
var select = [];
|
||||
//var select = [];
|
||||
for (var i in mist.data.active_streams) {
|
||||
var split = mist.data.active_streams[i].split('+');
|
||||
if ((split.length > 1) && (split[0] in mist.data.streams)) {
|
||||
select[mist.data.active_streams[i]] = true;
|
||||
allstreams[mist.data.active_streams[i]] = createWcStreamObject(mist.data.active_streams[i],mist.data.streams[split[0]]);
|
||||
}
|
||||
}
|
||||
select = Object.keys(select);
|
||||
if (mist.data.streams) { select = select.concat(Object.keys(mist.data.streams)); }
|
||||
select.sort();
|
||||
createPage(other,select);
|
||||
|
|
Loading…
Add table
Reference in a new issue