LSP: added info about stream processes to the stream info page

This commit is contained in:
Cat 2021-05-05 11:13:24 +02:00 committed by Thulinma
parent a8750ccd94
commit 099e2d1a58
2 changed files with 227 additions and 126 deletions

View file

@ -1,10 +1,10 @@
var MD5=function(a){function b(a,b){var c,d,g,h,e;g=a&2147483648;h=b&2147483648;c=a&1073741824;d=b&1073741824;e=(a&1073741823)+(b&1073741823);return c&d?e^2147483648^g^h:c|d?e&1073741824?e^3221225472^g^h:e^1073741824^g^h:e^g^h}function c(a,c,d,g,h,e,f){a=b(a,b(b(c&d|~c&g,h),f));return b(a<<e|a>>>32-e,c)}function d(a,c,d,g,h,e,f){a=b(a,b(b(c&g|d&~g,h),f));return b(a<<e|a>>>32-e,c)}function f(a,c,d,g,h,e,f){a=b(a,b(b(c^d^g,h),f));return b(a<<e|a>>>32-e,c)}function l(a,c,d,g,h,e,f){a=b(a,b(b(d^(c|~g), var MD5=function(a){function b(a,b){var c,d,g,h,e;g=a&2147483648;h=b&2147483648;c=a&1073741824;d=b&1073741824;e=(a&1073741823)+(b&1073741823);return c&d?e^2147483648^g^h:c|d?e&1073741824?e^3221225472^g^h:e^1073741824^g^h:e^g^h}function c(a,c,d,g,h,e,f){a=b(a,b(b(c&d|~c&g,h),f));return b(a<<e|a>>>32-e,c)}function d(a,c,d,g,h,e,f){a=b(a,b(b(c&g|d&~g,h),f));return b(a<<e|a>>>32-e,c)}function f(a,c,d,g,h,e,f){a=b(a,b(b(c^d^g,h),f));return b(a<<e|a>>>32-e,c)}function l(a,c,d,g,h,e,f){a=b(a,b(b(d^(c|~g),
h),f));return b(a<<e|a>>>32-e,c)}function m(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 e=[],q,n,i,v,g,h,j,k,e=a.replace(/\r\n/g,"\n"),a="";for(q=0;q<e.length;q++)n=e.charCodeAt(q),128>n?a+=String.fromCharCode(n):(127<n&&2048>n?a+=String.fromCharCode(n>>6|192):(a+=String.fromCharCode(n>>12|224),a+=String.fromCharCode(n>>6&63|128)),a+=String.fromCharCode(n&63|128));e=a;a=e.length;q=a+8;n=16*((q-q%64)/64+1);i=Array(n-1);for(g=v=0;g<a;)q= h),f));return b(a<<e|a>>>32-e,c)}function m(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 e=[],q,n,k,w,g,h,j,i,e=a.replace(/\r\n/g,"\n"),a="";for(q=0;q<e.length;q++)n=e.charCodeAt(q),128>n?a+=String.fromCharCode(n):(127<n&&2048>n?a+=String.fromCharCode(n>>6|192):(a+=String.fromCharCode(n>>12|224),a+=String.fromCharCode(n>>6&63|128)),a+=String.fromCharCode(n&63|128));e=a;a=e.length;q=a+8;n=16*((q-q%64)/64+1);k=Array(n-1);for(g=w=0;g<a;)q=
(g-g%4)/4,v=8*(g%4),i[q]|=e.charCodeAt(g)<<v,g++;q=(g-g%4)/4;i[q]|=128<<8*(g%4);i[n-2]=a<<3;i[n-1]=a>>>29;e=i;g=1732584193;h=4023233417;j=2562383102;k=271733878;for(a=0;a<e.length;a+=16)q=g,n=h,i=j,v=k,g=c(g,h,j,k,e[a+0],7,3614090360),k=c(k,g,h,j,e[a+1],12,3905402710),j=c(j,k,g,h,e[a+2],17,606105819),h=c(h,j,k,g,e[a+3],22,3250441966),g=c(g,h,j,k,e[a+4],7,4118548399),k=c(k,g,h,j,e[a+5],12,1200080426),j=c(j,k,g,h,e[a+6],17,2821735955),h=c(h,j,k,g,e[a+7],22,4249261313),g=c(g,h,j,k,e[a+8],7,1770035416), (g-g%4)/4,w=8*(g%4),k[q]|=e.charCodeAt(g)<<w,g++;q=(g-g%4)/4;k[q]|=128<<8*(g%4);k[n-2]=a<<3;k[n-1]=a>>>29;e=k;g=1732584193;h=4023233417;j=2562383102;i=271733878;for(a=0;a<e.length;a+=16)q=g,n=h,k=j,w=i,g=c(g,h,j,i,e[a+0],7,3614090360),i=c(i,g,h,j,e[a+1],12,3905402710),j=c(j,i,g,h,e[a+2],17,606105819),h=c(h,j,i,g,e[a+3],22,3250441966),g=c(g,h,j,i,e[a+4],7,4118548399),i=c(i,g,h,j,e[a+5],12,1200080426),j=c(j,i,g,h,e[a+6],17,2821735955),h=c(h,j,i,g,e[a+7],22,4249261313),g=c(g,h,j,i,e[a+8],7,1770035416),
k=c(k,g,h,j,e[a+9],12,2336552879),j=c(j,k,g,h,e[a+10],17,4294925233),h=c(h,j,k,g,e[a+11],22,2304563134),g=c(g,h,j,k,e[a+12],7,1804603682),k=c(k,g,h,j,e[a+13],12,4254626195),j=c(j,k,g,h,e[a+14],17,2792965006),h=c(h,j,k,g,e[a+15],22,1236535329),g=d(g,h,j,k,e[a+1],5,4129170786),k=d(k,g,h,j,e[a+6],9,3225465664),j=d(j,k,g,h,e[a+11],14,643717713),h=d(h,j,k,g,e[a+0],20,3921069994),g=d(g,h,j,k,e[a+5],5,3593408605),k=d(k,g,h,j,e[a+10],9,38016083),j=d(j,k,g,h,e[a+15],14,3634488961),h=d(h,j,k,g,e[a+4],20,3889429448), i=c(i,g,h,j,e[a+9],12,2336552879),j=c(j,i,g,h,e[a+10],17,4294925233),h=c(h,j,i,g,e[a+11],22,2304563134),g=c(g,h,j,i,e[a+12],7,1804603682),i=c(i,g,h,j,e[a+13],12,4254626195),j=c(j,i,g,h,e[a+14],17,2792965006),h=c(h,j,i,g,e[a+15],22,1236535329),g=d(g,h,j,i,e[a+1],5,4129170786),i=d(i,g,h,j,e[a+6],9,3225465664),j=d(j,i,g,h,e[a+11],14,643717713),h=d(h,j,i,g,e[a+0],20,3921069994),g=d(g,h,j,i,e[a+5],5,3593408605),i=d(i,g,h,j,e[a+10],9,38016083),j=d(j,i,g,h,e[a+15],14,3634488961),h=d(h,j,i,g,e[a+4],20,3889429448),
g=d(g,h,j,k,e[a+9],5,568446438),k=d(k,g,h,j,e[a+14],9,3275163606),j=d(j,k,g,h,e[a+3],14,4107603335),h=d(h,j,k,g,e[a+8],20,1163531501),g=d(g,h,j,k,e[a+13],5,2850285829),k=d(k,g,h,j,e[a+2],9,4243563512),j=d(j,k,g,h,e[a+7],14,1735328473),h=d(h,j,k,g,e[a+12],20,2368359562),g=f(g,h,j,k,e[a+5],4,4294588738),k=f(k,g,h,j,e[a+8],11,2272392833),j=f(j,k,g,h,e[a+11],16,1839030562),h=f(h,j,k,g,e[a+14],23,4259657740),g=f(g,h,j,k,e[a+1],4,2763975236),k=f(k,g,h,j,e[a+4],11,1272893353),j=f(j,k,g,h,e[a+7],16,4139469664), g=d(g,h,j,i,e[a+9],5,568446438),i=d(i,g,h,j,e[a+14],9,3275163606),j=d(j,i,g,h,e[a+3],14,4107603335),h=d(h,j,i,g,e[a+8],20,1163531501),g=d(g,h,j,i,e[a+13],5,2850285829),i=d(i,g,h,j,e[a+2],9,4243563512),j=d(j,i,g,h,e[a+7],14,1735328473),h=d(h,j,i,g,e[a+12],20,2368359562),g=f(g,h,j,i,e[a+5],4,4294588738),i=f(i,g,h,j,e[a+8],11,2272392833),j=f(j,i,g,h,e[a+11],16,1839030562),h=f(h,j,i,g,e[a+14],23,4259657740),g=f(g,h,j,i,e[a+1],4,2763975236),i=f(i,g,h,j,e[a+4],11,1272893353),j=f(j,i,g,h,e[a+7],16,4139469664),
h=f(h,j,k,g,e[a+10],23,3200236656),g=f(g,h,j,k,e[a+13],4,681279174),k=f(k,g,h,j,e[a+0],11,3936430074),j=f(j,k,g,h,e[a+3],16,3572445317),h=f(h,j,k,g,e[a+6],23,76029189),g=f(g,h,j,k,e[a+9],4,3654602809),k=f(k,g,h,j,e[a+12],11,3873151461),j=f(j,k,g,h,e[a+15],16,530742520),h=f(h,j,k,g,e[a+2],23,3299628645),g=l(g,h,j,k,e[a+0],6,4096336452),k=l(k,g,h,j,e[a+7],10,1126891415),j=l(j,k,g,h,e[a+14],15,2878612391),h=l(h,j,k,g,e[a+5],21,4237533241),g=l(g,h,j,k,e[a+12],6,1700485571),k=l(k,g,h,j,e[a+3],10,2399980690), h=f(h,j,i,g,e[a+10],23,3200236656),g=f(g,h,j,i,e[a+13],4,681279174),i=f(i,g,h,j,e[a+0],11,3936430074),j=f(j,i,g,h,e[a+3],16,3572445317),h=f(h,j,i,g,e[a+6],23,76029189),g=f(g,h,j,i,e[a+9],4,3654602809),i=f(i,g,h,j,e[a+12],11,3873151461),j=f(j,i,g,h,e[a+15],16,530742520),h=f(h,j,i,g,e[a+2],23,3299628645),g=l(g,h,j,i,e[a+0],6,4096336452),i=l(i,g,h,j,e[a+7],10,1126891415),j=l(j,i,g,h,e[a+14],15,2878612391),h=l(h,j,i,g,e[a+5],21,4237533241),g=l(g,h,j,i,e[a+12],6,1700485571),i=l(i,g,h,j,e[a+3],10,2399980690),
j=l(j,k,g,h,e[a+10],15,4293915773),h=l(h,j,k,g,e[a+1],21,2240044497),g=l(g,h,j,k,e[a+8],6,1873313359),k=l(k,g,h,j,e[a+15],10,4264355552),j=l(j,k,g,h,e[a+6],15,2734768916),h=l(h,j,k,g,e[a+13],21,1309151649),g=l(g,h,j,k,e[a+4],6,4149444226),k=l(k,g,h,j,e[a+11],10,3174756917),j=l(j,k,g,h,e[a+2],15,718787259),h=l(h,j,k,g,e[a+9],21,3951481745),g=b(g,q),h=b(h,n),j=b(j,i),k=b(k,v);return(m(g)+m(h)+m(j)+m(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(m){case "string":case "string-ins":b=String(b).toLowerCase();break;case "int":b= j=l(j,i,g,h,e[a+10],15,4293915773),h=l(h,j,i,g,e[a+1],21,2240044497),g=l(g,h,j,i,e[a+8],6,1873313359),i=l(i,g,h,j,e[a+15],10,4264355552),j=l(j,i,g,h,e[a+6],15,2734768916),h=l(h,j,i,g,e[a+13],21,1309151649),g=l(g,h,j,i,e[a+4],6,4149444226),i=l(i,g,h,j,e[a+11],10,3174756917),j=l(j,i,g,h,e[a+2],15,718787259),h=l(h,j,i,g,e[a+9],21,3951481745),g=b(g,q),h=b(h,n),j=b(j,k),i=b(i,w);return(m(g)+m(h)+m(j)+m(i)).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(m){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"),f=d.children("tbody"),l=f.children("tr"),m=c.attr("data-sort-type");if(m){var e=!0;c.hasClass("sorting-asc")&&(e=!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=e?1:-1,a=b(a),c=b(c);return a>c?1*d:a<c?-1*d:0});f.append(l);d.find("thead th").removeClass("sorting-asc").removeClass("sorting-desc");c.addClass(e?"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= parseInt(Number(b));break;case "float":b=Number(b)}return b}var c=a(this),d=c.closest("table"),f=d.children("tbody"),l=f.children("tr"),m=c.attr("data-sort-type");if(m){var e=!0;c.hasClass("sorting-asc")&&(e=!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=e?1:-1,a=b(a),c=b(c);return a>c?1*d:a<c?-1*d:0});f.append(l);d.find("thead th").removeClass("sorting-asc").removeClass("sorting-desc");c.addClass(e?"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])}); 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 MistVideoObject={},otherhost={host:!1,https:!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."); var MistVideoObject={},otherhost={host:!1,https:!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.");
@ -30,41 +30,41 @@ $(this).getval(),b=$(this).data("pointer");if(""===a)if("default"in $(this).data
m.append(e);switch(d.type){case "password":f=$("<input>").attr("type","password");break;case "int":f=$("<input>").attr("type","number");"min"in d&&f.attr("min",d.min);"max"in d&&f.attr("max",d.max);"validate"in d?d.validate.push("int"):d.validate=["int"];break;case "span":f=$("<span>");break;case "debug":d.select=[["","Default"],[0,"0 - All debugging messages disabled"],[1,"1 - Messages about failed operations"],[2,"2 - Previous level, and error messages"],[3,"3 - Previous level, and warning messages"], m.append(e);switch(d.type){case "password":f=$("<input>").attr("type","password");break;case "int":f=$("<input>").attr("type","number");"min"in d&&f.attr("min",d.min);"max"in d&&f.attr("max",d.max);"validate"in d?d.validate.push("int"):d.validate=["int"];break;case "span":f=$("<span>");break;case "debug":d.select=[["","Default"],[0,"0 - All debugging messages disabled"],[1,"1 - Messages about failed operations"],[2,"2 - Previous level, and error messages"],[3,"3 - Previous level, and warning messages"],
[4,"4 - Previous level, and status messages for development"],[5,"5 - Previous level, and more status messages for development"],[6,"6 - Previous level, and verbose debugging messages"],[7,"7 - Previous level, and very verbose debugging messages"],[8,"8 - Report everything in extreme detail"],[9,"9 - Report everything in insane detail"],[10,"10 - All messages enabled"]];case "select":f=$("<select>");for(l in d.select){var n=$("<option>");"string"==typeof d.select[l]?n.text(d.select[l]):n.val(d.select[l][0]).text(d.select[l][1]); [4,"4 - Previous level, and status messages for development"],[5,"5 - Previous level, and more status messages for development"],[6,"6 - Previous level, and verbose debugging messages"],[7,"7 - Previous level, and very verbose debugging messages"],[8,"8 - Report everything in extreme detail"],[9,"9 - Report everything in insane detail"],[10,"10 - All messages enabled"]];case "select":f=$("<select>");for(l in d.select){var n=$("<option>");"string"==typeof d.select[l]?n.text(d.select[l]):n.val(d.select[l][0]).text(d.select[l][1]);
f.append(n)}break;case "textarea":f=$("<textarea>").on("keydown",function(a){a.stopPropagation()});break;case "checkbox":f=$("<input>").attr("type","checkbox");break;case "hidden":f=$("<input>").attr("type","hidden");m.hide();break;case "email":f=$("<input>").attr("type","email").attr("autocomplete","on").attr("required","");break;case "browse":f=$("<input>").attr("type","text");"filetypes"in d&&f.data("filetypes",d.filetypes);break;case "geolimited":case "hostlimited":f=$("<input>").attr("type", f.append(n)}break;case "textarea":f=$("<textarea>").on("keydown",function(a){a.stopPropagation()});break;case "checkbox":f=$("<input>").attr("type","checkbox");break;case "hidden":f=$("<input>").attr("type","hidden");m.hide();break;case "email":f=$("<input>").attr("type","email").attr("autocomplete","on").attr("required","");break;case "browse":f=$("<input>").attr("type","text");"filetypes"in d&&f.data("filetypes",d.filetypes);break;case "geolimited":case "hostlimited":f=$("<input>").attr("type",
"hidden");break;case "radioselect":f=$("<div>").addClass("radioselect");for(c in d.radioselect){var i=$("<input>").attr("type","radio").val(d.radioselect[c][0]).attr("name",d.label);("LTSonly"in d&&!mist.data.LTS||d.readonly)&&i.prop("disabled",!0);n=$("<label>").append(i).append($("<span>").html(d.radioselect[c][1]));f.append(n);if(2<d.radioselect[c].length)for(l in i=$("<select>").change(function(){$(this).parent().find("input[type=radio]:enabled").prop("checked","true")}),n.append(i),("LTSonly"in "hidden");break;case "radioselect":f=$("<div>").addClass("radioselect");for(c in d.radioselect){var k=$("<input>").attr("type","radio").val(d.radioselect[c][0]).attr("name",d.label);("LTSonly"in d&&!mist.data.LTS||d.readonly)&&k.prop("disabled",!0);n=$("<label>").append(k).append($("<span>").html(d.radioselect[c][1]));f.append(n);if(2<d.radioselect[c].length)for(l in k=$("<select>").change(function(){$(this).parent().find("input[type=radio]:enabled").prop("checked","true")}),n.append(k),("LTSonly"in
d&&!mist.data.LTS||d.readonly)&&i.prop("disabled",!0),d.radioselect[c][2])n=$("<option>"),i.append(n),d.radioselect[c][2][l]instanceof Array?n.val(d.radioselect[c][2][l][0]).html(d.radioselect[c][2][l][1]):n.html(d.radioselect[c][2][l])}break;case "checklist":f=$("<div>").addClass("checkcontainer");$controls=$("<div>").addClass("controls");$checklist=$("<div>").addClass("checklist");f.append($checklist);for(c in d.checklist)"string"==typeof d.checklist[c]&&(d.checklist[c]=[d.checklist[c],d.checklist[c]]), d&&!mist.data.LTS||d.readonly)&&k.prop("disabled",!0),d.radioselect[c][2])n=$("<option>"),k.append(n),d.radioselect[c][2][l]instanceof Array?n.val(d.radioselect[c][2][l][0]).html(d.radioselect[c][2][l][1]):n.html(d.radioselect[c][2][l])}break;case "checklist":f=$("<div>").addClass("checkcontainer");$controls=$("<div>").addClass("controls");$checklist=$("<div>").addClass("checklist");f.append($checklist);for(c in d.checklist)"string"==typeof d.checklist[c]&&(d.checklist[c]=[d.checklist[c],d.checklist[c]]),
$checklist.append($("<label>").text(d.checklist[c][1]).prepend($("<input>").attr("type","checkbox").attr("name",d.checklist[c][0])));break;case "DOMfield":f=d.DOMfield;break;case "unix":f=$("<input>").attr("type","datetime-local").attr("step",1);d.unit=$("<button>").text("Now").click(function(){$(this).closest(".field_container").find(".field").setval((new Date).getTime()/1E3)});break;case "selectinput":f=$("<div>").addClass("selectinput");i=$("<select>");f.append(i);i.data("input",!1);"LTSonly"in $checklist.append($("<label>").text(d.checklist[c][1]).prepend($("<input>").attr("type","checkbox").attr("name",d.checklist[c][0])));break;case "DOMfield":f=d.DOMfield;break;case "unix":f=$("<input>").attr("type","datetime-local").attr("step",1);d.unit=$("<button>").text("Now").click(function(){$(this).closest(".field_container").find(".field").setval((new Date).getTime()/1E3)});break;case "selectinput":f=$("<div>").addClass("selectinput");k=$("<select>");f.append(k);k.data("input",!1);"LTSonly"in
d&&!mist.data.LTS&&i.prop("disabled",!0);for(c in d.selectinput)n=$("<option>"),i.append(n),"string"==typeof d.selectinput[c]?n.text(d.selectinput[c]):(n.text(d.selectinput[c][1]),"string"==typeof d.selectinput[c][0]?n.val(d.selectinput[c][0]):(n.val("CUSTOM"),i.data("input")||i.data("input",UI.buildUI([d.selectinput[c][0]]).children())));i.data("input")&&f.append(i.data("input"));i.change(function(){"CUSTOM"==$(this).val()?$(this).data("input").css("display","flex"):$(this).data("input").hide()}); d&&!mist.data.LTS&&k.prop("disabled",!0);for(c in d.selectinput)n=$("<option>"),k.append(n),"string"==typeof d.selectinput[c]?n.text(d.selectinput[c]):(n.text(d.selectinput[c][1]),"string"==typeof d.selectinput[c][0]?n.val(d.selectinput[c][0]):(n.val("CUSTOM"),k.data("input")||k.data("input",UI.buildUI([d.selectinput[c][0]]).children())));k.data("input")&&f.append(k.data("input"));k.change(function(){"CUSTOM"==$(this).val()?$(this).data("input").css("display","flex"):$(this).data("input").hide()});
i.trigger("change");break;case "inputlist":f=$("<div>").addClass("inputlist");f.data("newitem",function(){var a=$("<input>").attr("type","text").addClass("listitem");("LTSonly"in d&&!mist.data.LTS||d.readonly)&&a.prop("disabled",!0);var b=function(c){$(this).is(":last-child")?""!=$(this).val()?$(this).after(a.clone().keyup(b).val("")):8==c.which&&$(this).prev().focus():""==$(this).val()&&($(this).next().focus(),$(this).remove())};a.keyup(b);return a});f.append(f.data("newitem"));break;case "sublist":f= k.trigger("change");break;case "inputlist":f=$("<div>").addClass("inputlist");f.data("newitem",function(){var a=$("<input>").attr("type","text").addClass("listitem");("LTSonly"in d&&!mist.data.LTS||d.readonly)&&a.prop("disabled",!0);var b=function(c){$(this).is(":last-child")?""!=$(this).val()?$(this).after(a.clone().keyup(b).val("")):8==c.which&&$(this).prev().focus():""==$(this).val()&&($(this).next().focus(),$(this).remove())};a.keyup(b);return a});f.append(f.data("newitem"));break;case "sublist":f=
$("<div>").addClass("sublist");i=$("<div>").addClass("curvals");i.append($("<span>").text("None."));var v=$("<div>").addClass("itemsettings"),g=$("<button>").text("New "+d.itemLabel),h=d.sublist,j=d,k=f,P=m;f.data("build",function(a,b){for(var c in j.saveas)c in a||delete j.saveas[c];j.saveas=Object.assign(j.saveas,a);c="New";"undefined"!=typeof b&&(c="Edit");c=UI.buildUI([$("<h4>").text(c+" "+j.itemLabel)].concat(h).concat([{label:"Save first",type:"str",classes:["onlyshowhelp"],validate:[function(){return{msg:"Did you want to save this "+ $("<div>").addClass("sublist");k=$("<div>").addClass("curvals");k.append($("<span>").text("None."));var w=$("<div>").addClass("itemsettings"),g=$("<button>").text("New "+d.itemLabel),h=d.sublist,j=d,i=f,P=m;f.data("build",function(a,b){for(var c in j.saveas)c in a||delete j.saveas[c];j.saveas=Object.assign(j.saveas,a);c="New";"undefined"!=typeof b&&(c="Edit");c=UI.buildUI([$("<h4>").text(c+" "+j.itemLabel)].concat(h).concat([{label:"Save first",type:"str",classes:["onlyshowhelp"],validate:[function(){return{msg:"Did you want to save this "+
j.itemLabel+"?",classes:["red"]}}]},{type:"buttons",buttons:[{label:"Cancel",type:"cancel","function":function(){v.html("");g.show();P.show()}},{label:"Save "+j.itemLabel,type:"save",preSave:function(){$(this).closest(".input_container").find(".onlyshowhelp").closest("label").hide()},failedValidate:function(){$(this).closest(".input_container").find(".onlyshowhelp").closest("label").show()},"function":function(){var a=k.getval(),c=Object.assign({},j.saveas),d;for(d in c)null===c[d]&&delete c[d];"undefined"== j.itemLabel+"?",classes:["red"]}}]},{type:"buttons",buttons:[{label:"Cancel",type:"cancel","function":function(){w.html("");g.show();P.show()}},{label:"Save "+j.itemLabel,type:"save",preSave:function(){$(this).closest(".input_container").find(".onlyshowhelp").closest("label").hide()},failedValidate:function(){$(this).closest(".input_container").find(".onlyshowhelp").closest("label").show()},"function":function(){var a=i.getval(),c=Object.assign({},j.saveas),d;for(d in c)null===c[d]&&delete c[d];"undefined"==
typeof b?a.push(c):a[b]=c;k.setval(a);v.html("");g.show();P.show()}}]}]));v.html(c);g.hide();P.hide()});var F=f;g.click(function(){F.data("build")({})});h.unshift({type:"str",label:"Human readable name",placeholder:"none",help:"A convenient name to describe this "+d.itemLabel+". It won't be used by MistServer.",pointer:{main:d.saveas,index:"x-LSP-name"}});f.data("savelist",[]);f.append(i).append(g);b.append(v);break;default:f=$("<input>").attr("type","text")}f.addClass("field").data("opts",d);"pointer"in typeof b?a.push(c):a[b]=c;i.setval(a);w.html("");g.show();P.show()}}]}]));w.html(c);g.hide();P.hide()});var F=f;g.click(function(){F.data("build")({})});h.unshift({type:"str",label:"Human readable name",placeholder:"none",help:"A convenient name to describe this "+d.itemLabel+". It won't be used by MistServer.",pointer:{main:d.saveas,index:"x-LSP-name"}});f.data("savelist",[]);f.append(k).append(g);b.append(w);break;default:f=$("<input>").attr("type","text")}f.addClass("field").data("opts",d);"pointer"in
d&&f.attr("name",d.pointer.index);e.append(f);if("classes"in d)for(l in d.classes)f.addClass(d.classes[l]);"placeholder"in d&&f.attr("placeholder",d.placeholder);"default"in d&&f.attr("placeholder",d["default"]);"unit"in d&&e.append($("<span>").addClass("unit").html(d.unit));"readonly"in d&&(f.attr("readonly","readonly"),f.click(function(){$(this).select()}));"qrcode"in d&&e.append($("<span>").addClass("unit").html($("<button>").text("QR").on("keydown",function(a){a.stopPropagation()}).click(function(){var a= d&&f.attr("name",d.pointer.index);e.append(f);if("classes"in d)for(l in d.classes)f.addClass(d.classes[l]);"placeholder"in d&&f.attr("placeholder",d.placeholder);"default"in d&&f.attr("placeholder",d["default"]);"unit"in d&&e.append($("<span>").addClass("unit").html(d.unit));"readonly"in d&&(f.attr("readonly","readonly"),f.click(function(){$(this).select()}));"qrcode"in d&&e.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")&&e.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()), 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")&&e.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 g=$(this);setTimeout(function(){g.text("Copy")},5E3)}else{document.body.removeChild(b);alert("Failed to copy:\n"+a)}})));"rows"in d&&f.attr("rows",d.rows);"LTSonly"in d&&!mist.data.LTS&&(e.addClass("LTSonly"),f.prop("disabled",!0));if("dependent"in d)for(c in d.dependent)m.attr("data-dependent-"+ 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 g=$(this);setTimeout(function(){g.text("Copy")},5E3)}else{document.body.removeChild(b);alert("Failed to copy:\n"+a)}})));"rows"in d&&f.attr("rows",d.rows);"LTSonly"in d&&!mist.data.LTS&&(e.addClass("LTSonly"),f.prop("disabled",!0));if("dependent"in d)for(c in d.dependent)m.attr("data-dependent-"+
c,d.dependent[c]);switch(d.type){case "browse":i=$("<div>").addClass("grouper").append(m);b.append(i);i=$("<button>").text("Browse").on("keydown",function(a){a.stopPropagation()});e.append(i);i.click(function(){function a(b){f.text("Loading..");mist.send(function(a){e.text(a.browse.path[0]);mist.data.LTS&&d.setval(a.browse.path[0]+"/");f.html(j.clone(true).text("..").attr("title","Folder up"));if(a.browse.subdirectories){a.browse.subdirectories.sort();for(var b in a.browse.subdirectories){var h=a.browse.subdirectories[b]; c,d.dependent[c]);switch(d.type){case "browse":k=$("<div>").addClass("grouper").append(m);b.append(k);k=$("<button>").text("Browse").on("keydown",function(a){a.stopPropagation()});e.append(k);k.click(function(){function a(b){f.text("Loading..");mist.send(function(a){e.text(a.browse.path[0]);mist.data.LTS&&d.setval(a.browse.path[0]+"/");f.html(j.clone(true).text("..").attr("title","Folder up"));if(a.browse.subdirectories){a.browse.subdirectories.sort();for(var b in a.browse.subdirectories){var h=a.browse.subdirectories[b];
f.append(j.clone(true).attr("title",e.text()+k+h).text(h))}}if(a.browse.files){a.browse.files.sort();for(b in a.browse.files){var h=a.browse.files[b],r=e.text()+k+h,h=$("<a>").text(h).addClass("file").attr("title",r);f.append(h);if(m){var i=true,l;for(l in m)if(typeof m[l]!="undefined"&&mist.inputMatch(m[l],r)){i=false;break}i&&h.hide()}h.click(function(){var a=$(this).attr("title");d.setval(a).removeAttr("readonly").css("opacity",1);g.show();c.remove()})}}},{browse:b})}var b=$(this).closest(".grouper"), f.append(j.clone(true).attr("title",e.text()+i+h).text(h))}}if(a.browse.files){a.browse.files.sort();for(b in a.browse.files){var h=a.browse.files[b],s=e.text()+i+h,h=$("<a>").text(h).addClass("file").attr("title",s);f.append(h);if(m){var k=true,l;for(l in m)if(typeof m[l]!="undefined"&&mist.inputMatch(m[l],s)){k=false;break}k&&h.hide()}h.click(function(){var a=$(this).attr("title");d.setval(a).removeAttr("readonly").css("opacity",1);g.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),g=$(this),h=$("<button>").text("Stop browsing").click(function(){g.show();c.remove();d.removeAttr("readonly").css("opacity",1)}),e=$("<span>").addClass("field"),f=$("<div>").addClass("browse_contents"),j=$("<a>").addClass("folder"),m=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(f); c=$("<div>").addClass("browse_container"),d=b.find(".field").attr("readonly","readonly").css("opacity",0.5),g=$(this),h=$("<button>").text("Stop browsing").click(function(){g.show();c.remove();d.removeAttr("readonly").css("opacity",1)}),e=$("<span>").addClass("field"),f=$("<div>").addClass("browse_contents"),j=$("<a>").addClass("folder"),m=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(f);
var k="/";mist.data.config.version.indexOf("indows")>-1&&(k="\\");j.click(function(){var b=e.text()+k+$(this).text();a(b)});b=d.getval();h=b.split("://");h.length>1&&(b=h[0]=="file"?h[1]:"");b=b.split(k);b.pop();b=b.join(k);g.hide();a(b)});break;case "geolimited":case "hostlimited":i={field:f};i.blackwhite=$("<select>").append($("<option>").val("-").text("Blacklist")).append($("<option>").val("+").text("Whitelist"));i.values=$("<span>").addClass("limit_value_list");switch(d.type){case "geolimited":i.prototype= var i="/";mist.data.config.version.indexOf("indows")>-1&&(i="\\");j.click(function(){var b=e.text()+i+$(this).text();a(b)});b=d.getval();h=b.split("://");h.length>1&&(b=h[0]=="file"?h[1]:"");b=b.split(i);b.pop();b=b.join(i);g.hide();a(b)});break;case "geolimited":case "hostlimited":k={field:f};k.blackwhite=$("<select>").append($("<option>").val("-").text("Blacklist")).append($("<option>").val("+").text("Whitelist"));k.values=$("<span>").addClass("limit_value_list");switch(d.type){case "geolimited":k.prototype=
$("<select>").append($("<option>").val("").text("[Select a country]"));for(c in UI.countrylist)i.prototype.append($("<option>").val(c).html(UI.countrylist[c]));break;case "hostlimited":i.prototype=$("<input>").attr("type","text").attr("placeholder","type a host")}i.prototype.on("change keyup",function(){$(this).closest(".field_container").data("subUI").blackwhite.trigger("change")});i.blackwhite.change(function(){var a=$(this).closest(".field_container").data("subUI"),b=[],c=false;a.values.children().each(function(){c= $("<select>").append($("<option>").val("").text("[Select a country]"));for(c in UI.countrylist)k.prototype.append($("<option>").val(c).html(UI.countrylist[c]));break;case "hostlimited":k.prototype=$("<input>").attr("type","text").attr("placeholder","type a host")}k.prototype.on("change keyup",function(){$(this).closest(".field_container").data("subUI").blackwhite.trigger("change")});k.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&&!mist.data.LTS&&(i.blackwhite.prop("disabled",!0),i.prototype.prop("disabled",!0));i.values.append(i.prototype.clone(!0));e.data("subUI",i).addClass("limit_list").append(i.blackwhite).append(i.values)}"pointer"in d&&(f.data("pointer",d.pointer).addClass("isSetting"),d.pointer.main&&(i=d.pointer.main[d.pointer.index], $(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&&!mist.data.LTS&&(k.blackwhite.prop("disabled",!0),k.prototype.prop("disabled",!0));k.values.append(k.prototype.clone(!0));e.data("subUI",k).addClass("limit_list").append(k.blackwhite).append(k.values)}"pointer"in d&&(f.data("pointer",d.pointer).addClass("isSetting"),d.pointer.main&&(k=d.pointer.main[d.pointer.index],
"undefined"!=i&&f.setval(i)));(""==f.getval()||null==f.getval())&&"value"in d&&f.setval(d.value);if("datalist"in d)for(c in i="datalist_"+c+MD5(f[0].outerHTML),f.attr("list",i),i=$("<datalist>").attr("id",i),e.append(i),d.datalist)i.append($("<option>").val(d.datalist[c]));e=$("<span>").addClass("help_container");m.append(e);"help"in d&&(e.append($("<span>").addClass("ih_balloon").html(d.help)),f.on("focus mouseover",function(){$(this).closest("label").addClass("active")}).on("blur mouseout",function(){$(this).closest("label").removeClass("active")})); "undefined"!=k&&f.setval(k)));(""==f.getval()||null==f.getval())&&"value"in d&&f.setval(d.value);if("datalist"in d)for(c in k="datalist_"+c+MD5(f[0].outerHTML),f.attr("list",k),k=$("<datalist>").attr("id",k),e.append(k),d.datalist)k.append($("<option>").val(d.datalist[c]));e=$("<span>").addClass("help_container");m.append(e);"help"in d&&(e.append($("<span>").addClass("ih_balloon").html(d.help)),f.on("focus mouseover",function(){$(this).closest("label").addClass("active")}).on("blur mouseout",function(){$(this).closest("label").removeClass("active")}));
if("validate"in d){m=[];for(l in d.validate){i=d.validate[l];if("function"!=typeof i)switch(i){case "required":i=function(a){return a==""||a==null?{msg:"This is a required field.",classes:["red"]}:false};break;case "int":i=function(a,b){var c=$(b).data("opts");if(!$(b)[0].validity.valid){var d=[];"min"in c&&d.push(" greater than or equal to "+c.min);"max"in c&&d.push(" smaller than or equal to "+c.max);return{msg:"Please enter an integer"+d.join(" and")+".",classes:["red"]}}if(parseInt(Number(a))!= if("validate"in d){m=[];for(l in d.validate){k=d.validate[l];if("function"!=typeof k)switch(k){case "required":k=function(a){return a==""||a==null?{msg:"This is a required field.",classes:["red"]}:false};break;case "int":k=function(a,b){var c=$(b).data("opts");if(!$(b)[0].validity.valid){var d=[];"min"in c&&d.push(" greater than or equal to "+c.min);"max"in c&&d.push(" smaller than or equal to "+c.max);return{msg:"Please enter an integer"+d.join(" and")+".",classes:["red"]}}if(parseInt(Number(a))!=
a)return{msg:"Please enter an integer.",classes:["red"]}};break;case "streamname":i=function(a,b){if(a!=""){if(!isNaN(a.charAt(0)))return{msg:"The first character may not be a number.",classes:["red"]};if(a.toLowerCase()!=a)return{msg:"Uppercase letters are not allowed.",classes:["red"]};if(a.replace(/[^\da-z_]/g,"")!=a)return{msg:"Special characters (except for underscores) are not allowed.",classes:["red"]};if("streams"in mist.data&&a in mist.data.streams&&$(b).data("pointer").main.name!=a)return{msg:"This streamname already exists.<br>If you want to edit an existing stream, please click edit on the the streams tab.", a)return{msg:"Please enter an integer.",classes:["red"]}};break;case "streamname":k=function(a,b){if(a!=""){if(!isNaN(a.charAt(0)))return{msg:"The first character may not be a number.",classes:["red"]};if(a.toLowerCase()!=a)return{msg:"Uppercase letters are not allowed.",classes:["red"]};if(a.replace(/[^\da-z_]/g,"")!=a)return{msg:"Special characters (except for underscores) are not allowed.",classes:["red"]};if("streams"in mist.data&&a in mist.data.streams&&$(b).data("pointer").main.name!=a)return{msg:"This streamname already exists.<br>If you want to edit an existing stream, please click edit on the the streams tab.",
classes:["red"]}}};break;case "streamname_with_wildcard":i=function(a){if(a!=""){streampart=a.split("+");var b=streampart.slice(1).join("+");streampart=streampart[0];if(!isNaN(streampart.charAt(0)))return{msg:"The first character may not be a number.",classes:["red"]};if(streampart.toLowerCase()!=streampart)return{msg:"Uppercase letters are not allowed in a stream name.",classes:["red"]};if(streampart.replace(/[^\da-z_]/g,"")!=streampart)return{msg:"Special characters (except for underscores) are not allowed in a stream name.", classes:["red"]}}};break;case "streamname_with_wildcard":k=function(a){if(a!=""){streampart=a.split("+");var b=streampart.slice(1).join("+");streampart=streampart[0];if(!isNaN(streampart.charAt(0)))return{msg:"The first character may not be a number.",classes:["red"]};if(streampart.toLowerCase()!=streampart)return{msg:"Uppercase letters are not allowed in a stream name.",classes:["red"]};if(streampart.replace(/[^\da-z_]/g,"")!=streampart)return{msg:"Special characters (except for underscores) are not allowed in a stream name.",
classes:["red"]};if(streampart!=a&&b.replace(/[\00|\0|\/]/g,"")!=b)return{msg:"Slashes or null bytes are not allowed in wildcards.",classes:["red"]}}};break;case "streamname_with_wildcard_and_variables":i=function(a){if(a!=""){streampart=a.split("+");var b=streampart.slice(1).join("+");streampart=streampart[0];if(!isNaN(streampart.charAt(0)))return{msg:"The first character may not be a number.",classes:["red"]};if(streampart.toLowerCase()!=streampart)return{msg:"Uppercase letters are not allowed in a stream name.", classes:["red"]};if(streampart!=a&&b.replace(/[\00|\0|\/]/g,"")!=b)return{msg:"Slashes or null bytes are not allowed in wildcards.",classes:["red"]}}};break;case "streamname_with_wildcard_and_variables":k=function(a){if(a!=""){streampart=a.split("+");var b=streampart.slice(1).join("+");streampart=streampart[0];if(!isNaN(streampart.charAt(0)))return{msg:"The first character may not be a number.",classes:["red"]};if(streampart.toLowerCase()!=streampart)return{msg:"Uppercase letters are not allowed in a stream name.",
classes:["red"]};if(streampart.replace(/[^\da-z_$]/g,"")!=streampart)return{msg:"Special characters (except for underscores) are not allowed in a stream name.",classes:["red"]};if(streampart!=a&&b.replace(/[\00|\0|\/]/g,"")!=b)return{msg:"Slashes or null bytes are not allowed in wildcards.",classes:["red"]}}};break;default:i=function(){}}m.push(i)}f.data("validate_functions",m).data("help_container",e).data("validate",function(a,b){if($(a).is(":visible")||$(a).is('input[type="hidden"]')){var c=$(a).getval(), classes:["red"]};if(streampart.replace(/[^\da-z_$]/g,"")!=streampart)return{msg:"Special characters (except for underscores) are not allowed in a stream name.",classes:["red"]};if(streampart!=a&&b.replace(/[\00|\0|\/]/g,"")!=b)return{msg:"Slashes or null bytes are not allowed in wildcards.",classes:["red"]}}};break;default:k=function(){}}m.push(k)}f.data("validate_functions",m).data("help_container",e).data("validate",function(a,b){if($(a).is(":visible")||$(a).is('input[type="hidden"]')){var c=$(a).getval(),
d=$(a).data("validate_functions"),h=$(a).data("help_container");h.find(".err_balloon").remove();for(var g in d){var e=d[g](c,a);if(e){$err=$("<span>").addClass("err_balloon").html(e.msg);for(var f in e.classes)$err.addClass(e.classes[f]);h.prepend($err);b&&$(a).focus();return typeof e=="object"&&"break"in e?e["break"]:true}}return false}}).addClass("hasValidate").on("change keyup",function(){$(this).data("validate")($(this))});""!=f.getval()&&f.trigger("change")}"function"in d&&(f.on("change keyup", d=$(a).data("validate_functions"),h=$(a).data("help_container");h.find(".err_balloon").remove();for(var g in d){var e=d[g](c,a);if(e){$err=$("<span>").addClass("err_balloon").html(e.msg);for(var f in e.classes)$err.addClass(e.classes[f]);h.prepend($err);b&&$(a).focus();return typeof e=="object"&&"break"in e?e["break"]:true}}return false}}).addClass("hasValidate").on("change keyup",function(){$(this).data("validate")($(this))});""!=f.getval()&&f.trigger("change")}"function"in d&&(f.on("change keyup",
d["function"]),f.trigger("change"))}}b.on("keydown",function(a){var b=!1;switch(a.which){case 13:b=$(this).find("button.save").first();break;case 27:b=$(this).find("button.cancel").first()}b&&b.length&&(b.trigger("click"),a.stopPropagation())});return b},buildVheaderTable:function(a){var b=$("<table>").css("margin","0.2em"),c=$("<tr>").addClass("header").append($("<td>").addClass("vheader").attr("rowspan",a.labels.length+1).append($("<span>").text(a.vheader))),d=[];c.append($("<td>"));for(var f in a.labels)d.push($("<tr>").append($("<td>").html(""== d["function"]),f.trigger("change"))}}b.on("keydown",function(a){var b=!1;switch(a.which){case 13:b=$(this).find("button.save").first();break;case 27:b=$(this).find("button.cancel").first()}b&&b.length&&(b.trigger("click"),a.stopPropagation())});return b},buildVheaderTable:function(a){var b=$("<table>").css("margin","0.2em"),c=$("<tr>").addClass("header").append($("<td>").addClass("vheader").attr("rowspan",a.labels.length+1).append($("<span>").text(a.vheader))),d=[];c.append($("<td>"));for(var f in a.labels)d.push($("<tr>").append($("<td>").html(""==
a.labels[f]?"&nbsp;":a.labels[f]+":")));for(var l in a.content)for(f in c.append($("<td>").html(a.content[l].header)),a.content[l].body)d[f].append($("<td>").html(a.content[l].body[f]));b.append($("<tbody>").append(c).append(d));return b},plot:{addGraph:function(a,b){var c={id:a.id,xaxis:a.xaxis,datasets:[],elements:{cont:$("<div>").addClass("graph"),plot:$("<div>").addClass("plot"),legend:$("<div>").addClass("legend").attr("draggable","true")}};UI.draggable(c.elements.legend);c.elements.cont.append(c.elements.plot).append(c.elements.legend); a.labels[f]?"&nbsp;":a.labels[f]+":")));for(var l in a.content)for(f in c.append($("<td>").html(a.content[l].header)),a.content[l].body)d[f].append($("<td>").html(a.content[l].body[f]));b.append($("<tbody>").append(c).append(d));return b},plot:{addGraph:function(a,b){var c={id:a.id,xaxis:a.xaxis,datasets:[],elements:{cont:$("<div>").addClass("graph"),plot:$("<div>").addClass("plot"),legend:$("<div>").addClass("legend").attr("draggable","true")}};UI.draggable(c.elements.legend);c.elements.cont.append(c.elements.plot).append(c.elements.legend);
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 f=a[c].datasets[d];switch(f.datatype){case "clients":case "upbps":case "downbps":case "perc_lost":case "perc_retrans":switch(f.origin[0]){case "total":b.totals.push({fields:[f.datatype],end:-15});break;case "stream":b.totals.push({fields:[f.datatype],streams:[f.origin[1]],end:-15});break;case "protocol":b.totals.push({fields:[f.datatype],protocols:[f.origin[1]], 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 f=a[c].datasets[d];switch(f.datatype){case "clients":case "upbps":case "downbps":case "perc_lost":case "perc_retrans":switch(f.origin[0]){case "total":b.totals.push({fields:[f.datatype],end:-15});break;case "stream":b.totals.push({fields:[f.datatype],streams:[f.origin[1]],end:-15});break;case "protocol":b.totals.push({fields:[f.datatype],protocols:[f.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 f=[],n;for(n in c.datasets){var i=c.datasets[n];i.display&&(i.getdata(),i.yaxistype in c.yaxes||(d.push(UI.plot.yaxes[i.yaxistype]),c.yaxes[i.yaxistype]=d.length),i.yaxis=c.yaxes[i.yaxistype], 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 f=[],n;for(n in c.datasets){var k=c.datasets[n];k.display&&(k.getdata(),k.yaxistype in c.yaxes||(d.push(UI.plot.yaxes[k.yaxistype]),c.yaxes[k.yaxistype]=d.length),k.yaxis=c.yaxes[k.yaxistype],
f.push(i))}d[0]&&(d[0].color=0);c.plot=$.plot(c.elements.plot,f,{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", f.push(k))}d[0]&&(d[0].color=0);c.plot=$.plot(c.elements.plot,f,{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 v=function(a){var b=c.elements.legend.find(".value"),d=1;if(typeof a=="undefined")b.eq(0).html("Latest:");else{var g=c.plot.getXAxes()[0],a=Math.min(g.max,a),a=Math.max(g.min, 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 w=function(a){var b=c.elements.legend.find(".value"),d=1;if(typeof a=="undefined")b.eq(0).html("Latest:");else{var g=c.plot.getXAxes()[0],a=Math.min(g.max,a),a=Math.max(g.min,
a);b.eq(0).html(UI.format.time(a/1E3))}for(var e in c.datasets){var f="&nbsp;";if(c.datasets[e].display){var g=UI.plot.yaxes[c.datasets[e].yaxistype].tickFormatter,i=c.datasets[e].data;if(a)for(var l in i){if(i[l][0]==a){f=g(i[l][1]);break}if(i[l][0]>a){if(l!=0){f=i[l];i=i[l-1];f=g(f[1]+(a-f[0])*(i[1]-f[1])/(i[0]-f[0]))}break}}else f=g(c.datasets[e].data[c.datasets[e].data.length-1][1])}b.eq(d).html(f);d++}};c.plot.getOptions();for(n in c.datasets)f=$("<input>").attr("type","checkbox").data("index", a);b.eq(0).html(UI.format.time(a/1E3))}for(var e in c.datasets){var f="&nbsp;";if(c.datasets[e].display){var g=UI.plot.yaxes[c.datasets[e].yaxistype].tickFormatter,k=c.datasets[e].data;if(a)for(var l in k){if(k[l][0]==a){f=g(k[l][1]);break}if(k[l][0]>a){if(l!=0){f=k[l];k=k[l-1];f=g(f[1]+(a-f[0])*(k[1]-f[1])/(k[0]-f[0]))}break}}else f=g(c.datasets[e].data[c.datasets[e].data.length-1][1])}b.eq(d).html(f);d++}};c.plot.getOptions();for(n in c.datasets)f=$("<input>").attr("type","checkbox").data("index",
n).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[n].display&&f.attr("checked","checked"),d.append($("<tr>").html($("<td>").html($("<label>").html(f).append($("<div>").addClass("series-color").css("background-color",c.datasets[n].color)).append(c.datasets[n].label))).append($("<td>").css("padding-right","2em").css("text-align", n).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[n].display&&f.attr("checked","checked"),d.append($("<tr>").html($("<td>").html($("<label>").html(f).append($("<div>").addClass("series-color").css("background-color",c.datasets[n].color)).append(c.datasets[n].label))).append($("<td>").css("padding-right","2em").css("text-align",
"right").html($("<span>").addClass("value")).append($("<button>").text("X").addClass("close").data("index",n).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); "right").html($("<span>").addClass("value")).append($("<button>").text("X").addClass("close").data("index",n).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], b={};b[c.id]=c;UI.plot.go(b)}}}))));w();var g=!1;c.elements.plot.on("plothover",function(a,b,c){if(b.x!=g){w(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.series.yaxis)))));UI.tooltip.show(b,a.children())}else UI.tooltip.hide()}).on("mouseout",function(){w()})}}},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:"", 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, 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", 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",
@ -85,137 +85,141 @@ pointer:{main:mist.user,index:"name"}},{label:"Desired password",type:"password"
classes:["red"]}:false}],help:"Repeat your desired password.",classes:["match_password"]},{type:"buttons",buttons:[{type:"save",label:"Create new account","function":function(){mist.send(function(){UI.navto("Account created")},{authorize:{new_username:mist.user.name,new_password:mist.user.rawpassword}});mist.user.password=MD5(mist.user.rawpassword);delete mist.user.rawpassword}}]}]));break;case "Account created":UI.elements.menu.addClass("hide");c.append($("<p>").text("Your account has been created succesfully.")).append(UI.buildUI([{type:"text", classes:["red"]}:false}],help:"Repeat your desired password.",classes:["match_password"]},{type:"buttons",buttons:[{type:"save",label:"Create new account","function":function(){mist.send(function(){UI.navto("Account created")},{authorize:{new_username:mist.user.name,new_password:mist.user.rawpassword}});mist.user.password=MD5(mist.user.rawpassword);delete mist.user.rawpassword}}]}]));break;case "Account created":UI.elements.menu.addClass("hide");c.append($("<p>").text("Your account has been created succesfully.")).append(UI.buildUI([{type:"text",
text:"Would you like to enable all (currently) available protocols with their default settings?"},{type:"buttons",buttons:[{label:"Enable protocols",type:"save","function":function(){if(mist.data.config.protocols)c.append("Unable to enable all protocols as protocol settings already exist.<br>");else{c.append("Retrieving available protocols..<br>");mist.send(function(a){var b=[],d;for(d in a.capabilities.connectors)if(a.capabilities.connectors[d].required)c.append('Could not enable protocol "'+d+'" because it has required settings.<br>'); text:"Would you like to enable all (currently) available protocols with their default settings?"},{type:"buttons",buttons:[{label:"Enable protocols",type:"save","function":function(){if(mist.data.config.protocols)c.append("Unable to enable all protocols as protocol settings already exist.<br>");else{c.append("Retrieving available protocols..<br>");mist.send(function(a){var b=[],d;for(d in a.capabilities.connectors)if(a.capabilities.connectors[d].required)c.append('Could not enable protocol "'+d+'" because it has required settings.<br>');
else{b.push({connector:d});c.append('Enabled protocol "'+d+'".<br>')}c.append("Saving protocol settings..<br>");mist.send(function(){c.append("Protocols enabled. Redirecting..");setTimeout(function(){UI.navto("Overview")},5E3)},{config:{protocols:b}})},{capabilities:true})}}},{label:"Skip",type:"cancel","function":function(){UI.navto("Overview")}}]}]));break;case "Overview":if("undefined"==typeof mist.data.bandwidth){mist.send(function(){UI.navto(a)},{bandwidth:!0});c.append("Loading..");return}var f= else{b.push({connector:d});c.append('Enabled protocol "'+d+'".<br>')}c.append("Saving protocol settings..<br>");mist.send(function(){c.append("Protocols enabled. Redirecting..");setTimeout(function(){UI.navto("Overview")},5E3)},{config:{protocols:b}})},{capabilities:true})}}},{label:"Skip",type:"cancel","function":function(){UI.navto("Overview")}}]}]));break;case "Overview":if("undefined"==typeof mist.data.bandwidth){mist.send(function(){UI.navto(a)},{bandwidth:!0});c.append("Loading..");return}var f=
$("<span>").text("Loading.."),l=$("<span>"),m=$("<span>").addClass("logs"),e=$("<span>"),q=$("<span>"),n=$("<span>").text("Unknown"),i=$("<span>"),v=$("<span>"),g={serverid:mist.data.config.serverid,debug:mist.data.config.debug,accesslog:mist.data.config.accesslog,prometheus:mist.data.config.prometheus,defaultStream:mist.data.config.defaultStream,trustedproxy:mist.data.config.trustedproxy},h={};"bandwidth"in mist.data&&(h=mist.data.bandwidth,null==h&&(h={}),h.limit||(h.limit=""));var j=$("<select>").html($("<option>").val(1).text("bytes/s")).append($("<option>").val(1024).text("KiB/s")).append($("<option>").val(1048576).text("MiB/s")).append($("<option>").val(1073741824).text("GiB/s")), $("<span>").text("Loading.."),l=$("<span>"),m=$("<span>").addClass("logs"),e=$("<span>"),q=$("<span>"),n=$("<span>").text("Unknown"),k=$("<span>"),w=$("<span>"),g={serverid:mist.data.config.serverid,debug:mist.data.config.debug,accesslog:mist.data.config.accesslog,prometheus:mist.data.config.prometheus,defaultStream:mist.data.config.defaultStream,trustedproxy:mist.data.config.trustedproxy},h={};"bandwidth"in mist.data&&(h=mist.data.bandwidth,null==h&&(h={}),h.limit||(h.limit=""));var j=$("<select>").html($("<option>").val(1).text("bytes/s")).append($("<option>").val(1024).text("KiB/s")).append($("<option>").val(1048576).text("MiB/s")).append($("<option>").val(1073741824).text("GiB/s")),
k=parseURL(mist.user.host),k=k.protocol+k.host+k.port;c.append(UI.buildUI([{type:"help",help:"You can find most basic information about your MistServer here.<br>You can also set the debug level and force a save to the config.json file that MistServer uses to save your settings. "},{type:"span",label:"Version",pointer:{main:mist.data.config,index:"version"}},{type:"span",label:"Version check",value:f,LTSonly:!0},{type:"span",label:"Server time",value:q},{type:"span",label:"Licensed to",value:"license"in i=parseURL(mist.user.host),i=i.protocol+i.host+i.port;c.append(UI.buildUI([{type:"help",help:"You can find most basic information about your MistServer here.<br>You can also set the debug level and force a save to the config.json file that MistServer uses to save your settings. "},{type:"span",label:"Version",pointer:{main:mist.data.config,index:"version"}},{type:"span",label:"Version check",value:f,LTSonly:!0},{type:"span",label:"Server time",value:q},{type:"span",label:"Licensed to",value:"license"in
mist.data.config?mist.data.config.license.user:"",LTSonly:!0},{type:"span",label:"Active licenses",value:n,LTSonly:!0},{type:"span",label:"Configured streams",value:mist.data.streams?Object.keys(mist.data.streams).length:0},{type:"span",label:"Active streams",value:l},{type:"span",label:"Current connections",value:e},{type:"span",label:"Enabled protocols",value:i},{type:"span",label:"Disabled protocols",value:v},{type:"span",label:"Recent problems",value:m},$("<br>"),{type:"str",label:"Human readable name", mist.data.config?mist.data.config.license.user:"",LTSonly:!0},{type:"span",label:"Active licenses",value:n,LTSonly:!0},{type:"span",label:"Configured streams",value:mist.data.streams?Object.keys(mist.data.streams).length:0},{type:"span",label:"Active streams",value:l},{type:"span",label:"Current connections",value:e},{type:"span",label:"Enabled protocols",value:k},{type:"span",label:"Disabled protocols",value:w},{type:"span",label:"Recent problems",value:m},$("<br>"),{type:"str",label:"Human readable name",
pointer:{main:g,index:"serverid"},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:g,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:"selectinput",label:"Access log",selectinput:[["","Do not track"],["LOG","Log to MistServer log"], pointer:{main:g,index:"serverid"},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:g,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:"selectinput",label:"Access log",selectinput:[["","Do not track"],["LOG","Log to MistServer log"],
[{type:"str",label:"Path",LTSonly:!0},"Log to file"]],pointer:{main:g,index:"accesslog"},help:"Enable access logs.",LTSonly:!0},{type:"selectinput",label:"Prometheus stats output",selectinput:[["","Disabled"],[{type:"str",label:"Passphrase",LTSonly:!0},"Enabled"]],pointer:{main:g,index:"prometheus"},help:"Make stats available in Prometheus format. These can be accessed via "+k+"/PASSPHRASE or "+k+"/PASSPHRASE.json.",LTSonly:!0},{type:"inputlist",label:"Trusted proxies",help:"List of proxy server addresses that are allowed to override the viewer IP address to arbitrary values.<br>You may use a hostname or IP address.", [{type:"str",label:"Path",LTSonly:!0},"Log to file"]],pointer:{main:g,index:"accesslog"},help:"Enable access logs.",LTSonly:!0},{type:"selectinput",label:"Prometheus stats output",selectinput:[["","Disabled"],[{type:"str",label:"Passphrase",LTSonly:!0},"Enabled"]],pointer:{main:g,index:"prometheus"},help:"Make stats available in Prometheus format. These can be accessed via "+i+"/PASSPHRASE or "+i+"/PASSPHRASE.json.",LTSonly:!0},{type:"inputlist",label:"Trusted proxies",help:"List of proxy server addresses that are allowed to override the viewer IP address to arbitrary values.<br>You may use a hostname or IP address.",
LTSonly:!0,pointer:{main:g,index:"trustedproxy"}},{type:"selectinput",label:"Load balancer bandwidth limit",selectinput:[["","Default (1 gbps)"],[{label:"Custom",type:"int",min:0,unit:j},"Custom"]],pointer:{main:h,index:"limit"},help:"This setting only applies when MistServer is combined with a load balancer. This is the amount of traffic this server is willing to handle.",LTSonly:!0},{type:"inputlist",label:"Load balancer bandwidth exceptions",pointer:{main:h,index:"exceptions"},help:"This setting only applies when MistServer is combined with a load balancer. Data sent to the hosts and subnets listed here will not count towards reported bandwidth usage.<br>Examples:<ul><li>192.168.0.0/16</li><li>localhost</li><li>10.0.0.0/8</li><li>fe80::/16</li></ul>", LTSonly:!0,pointer:{main:g,index:"trustedproxy"}},{type:"selectinput",label:"Load balancer bandwidth limit",selectinput:[["","Default (1 gbps)"],[{label:"Custom",type:"int",min:0,unit:j},"Custom"]],pointer:{main:h,index:"limit"},help:"This setting only applies when MistServer is combined with a load balancer. This is the amount of traffic this server is willing to handle.",LTSonly:!0},{type:"inputlist",label:"Load balancer bandwidth exceptions",pointer:{main:h,index:"exceptions"},help:"This setting only applies when MistServer is combined with a load balancer. Data sent to the hosts and subnets listed here will not count towards reported bandwidth usage.<br>Examples:<ul><li>192.168.0.0/16</li><li>localhost</li><li>10.0.0.0/8</li><li>fe80::/16</li></ul>",
LTSonly:!0},{type:"str",validate:["streamname_with_wildcard_and_variables"],label:"Fallback stream",pointer:{main:g,index:"defaultStream"},help:"When this is set, if someone attempts to view a stream that does not exist, or is offline, they will be redirected to this stream instead. $stream may be used to refer to the original stream name.",LTSonly:!0},{type:"checkbox",label:"Force configurations save",pointer:{main:g,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."}, LTSonly:!0},{type:"str",validate:["streamname_with_wildcard_and_variables"],label:"Fallback stream",pointer:{main:g,index:"defaultStream"},help:"When this is set, if someone attempts to view a stream that does not exist, or is offline, they will be redirected to this stream instead. $stream may be used to refer to the original stream name.",LTSonly:!0},{type:"checkbox",label:"Force configurations save",pointer:{main:g,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:g},b={};b.limit=h.limit?j.val()*h.limit:0;b.exceptions=h.exceptions;if(b.exceptions===null)b.exceptions=[];a.bandwidth=b;if(g.save)a.save=g.save;delete g.save;mist.send(function(){UI.navto("Overview")},a)}}]}]));if(mist.data.LTS){var P=function(a){function b(a){if(a.update){var d="";"progress"in a.update&&(d=" ("+a.update.progress+"%)");f.text("Updating.."+d);c(a.log);setTimeout(function(){mist.send(function(a){b(a)}, {type:"buttons",buttons:[{type:"save",label:"Save","function":function(){var a={config:g},b={};b.limit=h.limit?j.val()*h.limit:0;b.exceptions=h.exceptions;if(b.exceptions===null)b.exceptions=[];a.bandwidth=b;if(g.save)a.save=g.save;delete g.save;mist.send(function(){UI.navto("Overview")},a)}}]}]));if(mist.data.LTS){var P=function(a){function b(a){if(a.update){var d="";"progress"in a.update&&(d=" ("+a.update.progress+"%)");f.text("Updating.."+d);c(a.log);setTimeout(function(){mist.send(function(a){b(a)},
{update:true})},1E3)}else UI.showTab("Overview")}function c(a){a=a.filter(function(a){return a[1]=="UPDR"});if(a.length){var b=$("<div>");f.append(b);for(var d in a)b.append($("<div>").text(a[d][2]))}}if(!a.update||!("uptodate"in a.update)){f.text("Unknown, checking..");setTimeout(function(){mist.send(function(a){"update"in a&&P(a)},{checkupdate:true})},5E3)}else if(a.update.error)f.addClass("red").text(a.update.error);else if(a.update.uptodate)f.text("Your version is up to date.").addClass("green"); {update:true})},1E3)}else UI.showTab("Overview")}function c(a){a=a.filter(function(a){return a[1]=="UPDR"});if(a.length){var b=$("<div>");f.append(b);for(var d in a)b.append($("<div>").text(a[d][2]))}}if(!a.update||!("uptodate"in a.update)){f.text("Unknown, checking..");setTimeout(function(){mist.send(function(a){"update"in a&&P(a)},{checkupdate:true})},5E3)}else if(a.update.error)f.addClass("red").text(a.update.error);else if(a.update.uptodate)f.text("Your version is up to date.").addClass("green");
else{if(a.update.progress){f.addClass("orange").removeClass("red").text("Updating..");b(a)}else{f.text("");f.append($("<span>").addClass("red").text("On "+(new Date(a.update.date)).toLocaleDateString()+" version "+a.update.version+" became available."));(!a.update.url||a.update.url.slice(-4)!=".zip")&&f.append($("<button>").text("Rolling update").css({"font-size":"1em","margin-left":"1em"}).click(function(){if(confirm("Are you sure you want to execute a rolling update?")){f.addClass("orange").removeClass("red").text("Rolling update command sent.."); else{if(a.update.progress){f.addClass("orange").removeClass("red").text("Updating..");b(a)}else{f.text("");f.append($("<span>").addClass("red").text("On "+(new Date(a.update.date)).toLocaleDateString()+" version "+a.update.version+" became available."));(!a.update.url||a.update.url.slice(-4)!=".zip")&&f.append($("<button>").text("Rolling update").css({"font-size":"1em","margin-left":"1em"}).click(function(){if(confirm("Are you sure you want to execute a rolling update?")){f.addClass("orange").removeClass("red").text("Rolling update command sent..");
mist.send(function(a){b(a)},{autoupdate:true})}}));var d=$("<a>").attr("href",a.update.url).attr("target","_blank").text("Manual download");d[0].protocol="https:";f.append($("<div>").append(d))}c(a.log)}};P(mist.data);if("license"in mist.data.config){if("active_products"in mist.data.config.license&&Object.keys(mist.data.config.license.active_products).length){var F=$("<table>").css("text-indent","0");n.html(F);F.append($("<tr>").append($("<th>").append("Product")).append($("<th>").append("Updates until")).append($("<th>").append("Use until")).append($("<th>").append("Max. simul. instances"))); mist.send(function(a){b(a)},{autoupdate:true})}}));var d=$("<a>").attr("href",a.update.url).attr("target","_blank").text("Manual download");d[0].protocol="https:";f.append($("<div>").append(d))}c(a.log)}};P(mist.data);if("license"in mist.data.config){if("active_products"in mist.data.config.license&&Object.keys(mist.data.config.license.active_products).length){var F=$("<table>").css("text-indent","0");n.html(F);F.append($("<tr>").append($("<th>").append("Product")).append($("<th>").append("Updates until")).append($("<th>").append("Use until")).append($("<th>").append("Max. simul. instances")));
for(var r in mist.data.config.license.active_products){var J=mist.data.config.license.active_products[r];F.append($("<tr>").append($("<td>").append(J.name)).append($("<td>").append(J.updates_final?J.updates_final:"&infin;")).append($("<td>").append(J.use_final?J.use_final:"&infin;")).append($("<td>").append(J.amount?J.amount:"&infin;")))}}else n.text("None. ");n.append($("<a>").text("More details").attr("href","https://shop.mistserver.org/myinvoices").attr("target","_blank"))}}else f.text("");var xa= for(var s in mist.data.config.license.active_products){var J=mist.data.config.license.active_products[s];F.append($("<tr>").append($("<td>").append(J.name)).append($("<td>").append(J.updates_final?J.updates_final:"&infin;")).append($("<td>").append(J.use_final?J.use_final:"&infin;")).append($("<td>").append(J.amount?J.amount:"&infin;")))}}else n.text("None. ");n.append($("<a>").text("More details").attr("href","https://shop.mistserver.org/myinvoices").attr("target","_blank"))}}else f.text("");var ya=
function(){var a={totals:{fields:["clients"],start:-10},active_streams:true};if(!("cabailities"in mist.data))a.capabilities=true;mist.send(function(){ya()},a)},ya=function(){l.text("active_streams"in mist.data?mist.data.active_streams?mist.data.active_streams.length:0:"?");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..";e.text(a);q.text(UI.format.dateTime(mist.data.config.time, function(){var a={totals:{fields:["clients"],start:-10},active_streams:true};if(!("cabailities"in mist.data))a.capabilities=true;mist.send(function(){za()},a)},za=function(){l.text("active_streams"in mist.data?mist.data.active_streams?mist.data.active_streams.length:0:"?");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..";e.text(a);q.text(UI.format.dateTime(mist.data.config.time,
"long"));m.html("");a=0;"license"in mist.data.config&&"user_msg"in mist.data.config.license&&mist.data.log.unshift([mist.data.config.license.time,"ERROR",mist.data.config.license.user_msg]);for(var b in mist.data.log){var c=mist.data.log[b];if(["FAIL","ERROR"].indexOf(c[1])>-1){a++;var d=$("<span>").addClass("content").addClass("red"),g=c[2].split("|");for(b in g)d.append($("<span>").text(g[b]));m.append($("<div>").append($("<span>").append(UI.format.time(c[0]))).append(d));if(a==5)break}}a==0&&m.html("None."); "long"));m.html("");a=0;"license"in mist.data.config&&"user_msg"in mist.data.config.license&&mist.data.log.unshift([mist.data.config.license.time,"ERROR",mist.data.config.license.user_msg]);for(var b in mist.data.log){var c=mist.data.log[b];if(["FAIL","ERROR"].indexOf(c[1])>-1){a++;var d=$("<span>").addClass("content").addClass("red"),g=c[2].split("|");for(b in g)d.append($("<span>").text(g[b]));m.append($("<div>").append($("<span>").append(UI.format.time(c[0]))).append(d));if(a==5)break}}a==0&&m.html("None.");
a=[];c=[];for(b in mist.data.config.protocols){d=mist.data.config.protocols[b];a.indexOf(d.connector)>-1||a.push(d.connector)}i.text(a.length?a.join(", "):"None.");if("capabilities"in mist.data){for(b in mist.data.capabilities.connectors)a.indexOf(b)==-1&&c.push(b);v.text(c.length?c.join(", "):"None.")}else v.text("Loading..")};xa();ya();UI.interval.set(xa,3E4);break;case "Protocols":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});c.append("Loading.."); a=[];c=[];for(b in mist.data.config.protocols){d=mist.data.config.protocols[b];a.indexOf(d.connector)>-1||a.push(d.connector)}k.text(a.length?a.join(", "):"None.");if("capabilities"in mist.data){for(b in mist.data.capabilities.connectors)a.indexOf(b)==-1&&c.push(b);w.text(c.length?c.join(", "):"None.")}else w.text("Loading..")};ya();za();UI.interval.set(ya,3E4);break;case "Protocols":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});c.append("Loading..");
return}var C=$("<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("Delete all protocols").click(function(){if(confirm("Are you sure you want to delete all currently configured protocols?")){mist.data.config.protocols=[];mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}})).append($("<button>").text("Enable default protocols").click(function(){var a= return}var C=$("<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("Delete all protocols").click(function(){if(confirm("Are you sure you want to delete all currently configured protocols?")){mist.data.config.protocols=[];mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}})).append($("<button>").text("Enable default protocols").click(function(){var a=
Object.keys(mist.data.capabilities.connectors),b;for(b in mist.data.config.protocols){var c=a.indexOf(mist.data.config.protocols[b].connector);c>-1&&a.splice(c,1)}var d=[];for(b in a)(!("required"in mist.data.capabilities.connectors[a[b]])||Object.keys(mist.data.capabilities.connectors[a[b]].required).length==0)&&d.push(a[b]);c="Click OK to enable disabled protocols with their default settings:\n ";c=d.length?c+d.join(", "):c+"None.";if(d.length!=a.length){a=a.filter(function(a){return d.indexOf(a)< Object.keys(mist.data.capabilities.connectors),b;for(b in mist.data.config.protocols){var c=a.indexOf(mist.data.config.protocols[b].connector);c>-1&&a.splice(c,1)}var d=[];for(b in a)(!("required"in mist.data.capabilities.connectors[a[b]])||Object.keys(mist.data.capabilities.connectors[a[b]].required).length==0)&&d.push(a[b]);c="Click OK to enable disabled protocols with their default settings:\n ";c=d.length?c+d.join(", "):c+"None.";if(d.length!=a.length){a=a.filter(function(a){return d.indexOf(a)<
0});c=c+("\n\nThe following protocols can only be set manually:\n "+a.join(", "))}if(confirm(c)&&d.length){if(mist.data.config.protocols===null)mist.data.config.protocols=[];for(b in d)mist.data.config.protocols.push({connector:d[b]});mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}})).append("<br>").append($("<button>").text("New protocol").click(function(){UI.navto("Edit Protocol")}).css("clear","both")).append($("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Protocol")).append($("<th>").text("Status")).append($("<th>").text("Settings")).append($("<th>")))).append(C)); 0});c=c+("\n\nThe following protocols can only be set manually:\n "+a.join(", "))}if(confirm(c)&&d.length){if(mist.data.config.protocols===null)mist.data.config.protocols=[];for(b in d)mist.data.config.protocols.push({connector:d[b]});mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}})).append("<br>").append($("<button>").text("New protocol").click(function(){UI.navto("Edit Protocol")}).css("clear","both")).append($("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Protocol")).append($("<th>").text("Status")).append($("<th>").text("Settings")).append($("<th>")))).append(C));
var za=function(){function a(b){var c=mist.data.capabilities.connectors[b.connector];if(!c)return"";var d=[],g=["required","optional"],e;for(e in g)for(var f in c[g[e]])b[f]&&b[f]!=""?d.push(f+": "+b[f]):c[g[e]][f]["default"]&&d.push(f+": "+c[g[e]][f]["default"]);return $("<span>").addClass("description").text(d.join(", "))}C.html("");for(var b in mist.data.config.protocols){var c=mist.data.config.protocols[b],d=mist.data.capabilities.connectors[c.connector];C.append($("<tr>").data("index",b).append($("<td>").text(d&& var Aa=function(){function a(b){var c=mist.data.capabilities.connectors[b.connector];if(!c)return"";var d=[],g=["required","optional"],e;for(e in g)for(var f in c[g[e]])b[f]&&b[f]!=""?d.push(f+": "+b[f]):c[g[e]][f]["default"]&&d.push(f+": "+c[g[e]][f]["default"]);return $("<span>").addClass("description").text(d.join(", "))}C.html("");for(var b in mist.data.config.protocols){var c=mist.data.config.protocols[b],d=mist.data.capabilities.connectors[c.connector];C.append($("<tr>").data("index",b).append($("<td>").text(d&&
d.friendly?d.friendly: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.send(function(){UI.navto("Protocols")}, d.friendly?d.friendly: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.send(function(){UI.navto("Protocols")},
{deleteprotocol:mist.data.config.protocols[a]});mist.data.config.protocols.splice(a,1)}}))))}};za();UI.interval.set(function(){mist.send(function(){za()})},1E4);break;case "Edit Protocol":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,b)},{capabilities:!0});c.append("Loading..");return}var K=!1;""!=b&&0<=b&&(K=!0);var T={};for(r in mist.data.config.protocols)T[mist.data.config.protocols[r].connector]=1;var Aa=function(a){var b=mist.data.capabilities.connectors[a],c= {deleteprotocol:mist.data.config.protocols[a]});mist.data.config.protocols.splice(a,1)}}))))}};Aa();UI.interval.set(function(){mist.send(function(){Aa()})},1E4);break;case "Edit Protocol":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,b)},{capabilities:!0});c.append("Loading..");return}var K=!1;""!=b&&0<=b&&(K=!0);var T={};for(s in mist.data.config.protocols)T[mist.data.config.protocols[s].connector]=1;var Ba=function(a){var b=mist.data.capabilities.connectors[a],c=
mist.convertBuildOptions(b,o);if(K)var d=$.extend({},o);c.push({type:"hidden",pointer:{main:o,index:"connector"},value:a});c.push({type:"buttons",buttons:[{type:"save",label:"Save","function":function(){var a={};K?a.updateprotocol=[d,o]:a.addprotocol=o;mist.send(function(){UI.navto("Protocols")},a)}},{type:"cancel",label:"Cancel","function":function(){UI.navto("Protocols")}}]});if("deps"in b&&b.deps!=""){F=$("<span>").text("Dependencies:");$ul=$("<ul>");F.append($ul);if(typeof b.deps=="string")b.deps= mist.convertBuildOptions(b,o);if(K)var d=$.extend({},o);c.push({type:"hidden",pointer:{main:o,index:"connector"},value:a});c.push({type:"buttons",buttons:[{type:"save",label:"Save","function":function(){var a={};K?a.updateprotocol=[d,o]:a.addprotocol=o;mist.send(function(){UI.navto("Protocols")},a)}},{type:"cancel",label:"Cancel","function":function(){UI.navto("Protocols")}}]});if("deps"in b&&b.deps!=""){F=$("<span>").text("Dependencies:");$ul=$("<ul>");F.append($ul);if(typeof b.deps=="string")b.deps=
b.deps.split(", ");for(var g in b.deps){a=$("<li>").text(b.deps[g]+" ");$ul.append(a);typeof T[b.deps[g]]!="undefined"||typeof T[b.deps[g]+".exe"]!="undefined"?a.append($("<span>").addClass("green").text("(Configured)")):a.append($("<span>").addClass("red").text("(Not yet configured)"))}c.unshift({type:"text",text:F[0].innerHTML})}return UI.buildUI(c)},T={};for(r in mist.data.config.protocols)T[mist.data.config.protocols[r].connector]=1;if(K){var s=mist.data.config.protocols[b],o=s;c.find("h2").append(' "'+ b.deps.split(", ");for(var g in b.deps){a=$("<li>").text(b.deps[g]+" ");$ul.append(a);typeof T[b.deps[g]]!="undefined"||typeof T[b.deps[g]+".exe"]!="undefined"?a.append($("<span>").addClass("green").text("(Configured)")):a.append($("<span>").addClass("red").text("(Not yet configured)"))}c.unshift({type:"text",text:F[0].innerHTML})}return UI.buildUI(c)},T={};for(s in mist.data.config.protocols)T[mist.data.config.protocols[s].connector]=1;if(K){var t=mist.data.config.protocols[b],o=t;c.find("h2").append(' "'+
s.connector+'"');c.append(Aa(s.connector))}else{c.html($("<h2>").text("New Protocol"));var o={},t=[["",""]];for(r in mist.data.capabilities.connectors)t.push([r,mist.data.capabilities.connectors[r].friendly?mist.data.capabilities.connectors[r].friendly:r]);var Q=$("<span>");c.append(UI.buildUI([{label:"Protocol",type:"select",select:t,"function":function(){$(this).getval()!=""&&Q.html(Aa($(this).getval()))}}])).append(Q)}break;case "Streams":if(!("capabilities"in mist.data)){c.html("Loading..");mist.send(function(){UI.navto(a)}, t.connector+'"');c.append(Ba(t.connector))}else{c.html($("<h2>").text("New Protocol"));var o={},u=[["",""]];for(s in mist.data.capabilities.connectors)u.push([s,mist.data.capabilities.connectors[s].friendly?mist.data.capabilities.connectors[s].friendly:s]);var Q=$("<span>");c.append(UI.buildUI([{label:"Protocol",type:"select",select:u,"function":function(){$(this).getval()!=""&&Q.html(Ba($(this).getval()))}}])).append(Q)}break;case "Streams":if(!("capabilities"in mist.data)){c.html("Loading..");mist.send(function(){UI.navto(a)},
{capabilities:!0});return}var Ba=$("<button>"),L=$("<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(Ba).append($("<button>").text("Create a new stream").click(function(){UI.navto("Edit")}))])).append(L);""==b&&(g=mist.stored.get(),"viewmode"in g&&(b=g.viewmode));Ba.text("Switch to "+ {capabilities:!0});return}var Ca=$("<button>"),L=$("<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(Ca).append($("<button>").text("Create a new stream").click(function(){UI.navto("Edit")}))])).append(L);""==b&&(g=mist.stored.get(),"viewmode"in g&&(b=g.viewmode));Ca.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 z=$.extend(!0,{},mist.data.streams),ja=function(a,b){var c=$.extend({},b);delete c.meta;delete c.error;c.online=2;c.name=a;c.ischild=true;return c},ka=function(b,d,g){L.remove();switch(b){case "thumbnails":var f=$("<div>").addClass("preview_icons"),e;e=g||[];d.sort();d.unshift("");L.remove();c.append($("<h2>").text(a)).append(UI.buildUI([{label:"Filter the streams", ("thumbnails"==b?"list":"thumbnail")+" view").click(function(){mist.stored.set("viewmode",b=="thumbnails"?"list":"thumbnails");UI.navto("Streams",b=="thumbnails"?"list":"thumbnails")});var A=$.extend(!0,{},mist.data.streams),ja=function(a,b){var c=$.extend({},b);delete c.meta;delete c.error;c.online=2;c.name=a;c.ischild=true;return c},ka=function(b,d,g){L.remove();switch(b){case "thumbnails":var f=$("<div>").addClass("preview_icons"),e;e=g||[];d.sort();d.unshift("");L.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();f.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(f);for(var h in d){var b=d[h],k="",j=$("<button>").text("Delete").click(function(){var a= 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();f.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(f);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={};b.deletestream=[a];mist.send(function(){UI.navto("Streams")},b)}}),i=$("<button>").text("Settings").click(function(){UI.navto("Edit",$(this).closest("div").attr("data-stream"))}),g=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("div").attr("data-stream"))}),m=$("<button>").text("Embed").click(function(){UI.navto("Embed", $(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={};b.deletestream=[a];mist.send(function(){UI.navto("Streams")},b)}}),k=$("<button>").text("Settings").click(function(){UI.navto("Edit",$(this).closest("div").attr("data-stream"))}),g=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("div").attr("data-stream"))}),m=$("<button>").text("Embed").click(function(){UI.navto("Embed",
$(this).closest("div").attr("data-stream"))}),B=$("<span>").addClass("image");if(b.indexOf("+")>-1){k=b.split("+");k=mist.data.streams[k[0]].source+k[1];i=j="";B.addClass("wildcard")}else{k=mist.data.streams[b].source;if(e.indexOf(b)>-1){m=g="";B.addClass("folder")}}f.append($("<div>").append($("<span>").addClass("streamname").text(b)).append(B).append($("<span>").addClass("description").text(k)).append($("<span>").addClass("button_container").append(i).append(j).append(g).append(m)).attr("title", $(this).closest("div").attr("data-stream"))}),r=$("<span>").addClass("image");if(b.indexOf("+")>-1){i=b.split("+");i=mist.data.streams[i[0]].source+i[1];k=j="";r.addClass("wildcard")}else{i=mist.data.streams[b].source;if(e.indexOf(b)>-1){m=g="";r.addClass("folder")}}f.append($("<div>").append($("<span>").addClass("streamname").text(b)).append(r).append($("<span>").addClass("description").text(i)).append($("<span>").addClass("button_container").append(k).append(j).append(g).append(m)).attr("title",
b).attr("data-stream",b))}break;default:var l=$("<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(l); b).attr("data-stream",b))}break;default:var l=$("<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(l);
c.append(h);h.stupidtable();var q=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,z,mist.data.streams);var a=0;l.html("");d.sort();for(var b in d){var c=d[b],g;g=c in mist.data.streams?mist.data.streams[c]:z[c];var e=$("<td>").css("text-align","right").html($("<span>").addClass("description").text("Loading..")),f=0;if(typeof mist.data.totals!="undefined"&&typeof mist.data.totals[c]!= c.append(h);h.stupidtable();var q=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,A,mist.data.streams);var a=0;l.html("");d.sort();for(var b in d){var c=d[b],g;g=c in mist.data.streams?mist.data.streams[c]:A[c];var e=$("<td>").css("text-align","right").html($("<span>").addClass("description").text("Loading..")),f=0;if(typeof mist.data.totals!="undefined"&&typeof mist.data.totals[c]!=
"undefined"){var h=mist.data.totals[c].all_protocols.clients,f=0;if(h.length){for(a in h)f=f+h[a][1];f=Math.round(f/h.length)}}e.html(UI.format.number(f));if(f==0&&g.online==1)g.online=2;f=$("<td>").css("text-align","right").css("white-space","nowrap");(!("ischild"in g)||!g.ischild)&&f.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 "'+ "undefined"){var h=mist.data.totals[c].all_protocols.clients,f=0;if(h.length){for(a in h)f=f+h[a][1];f=Math.round(f/h.length)}}e.html(UI.format.number(f));if(f==0&&g.online==1)g.online=2;f=$("<td>").css("text-align","right").css("white-space","nowrap");(!("ischild"in g)||!g.ischild)&&f.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(g.name);g.ischild&&h.css("padding-left","1em");var Ca=UI.format.status(g),k=$("<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 z[c]||g.online<0){Ca.html(""); 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(g.name);g.ischild&&h.css("padding-left","1em");var Da=UI.format.status(g),i=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("tr").data("index"))}),r=$("<button>").text("Embed").click(function(){UI.navto("Embed",$(this).closest("tr").data("index"))});if("filesfound"in A[c]||g.online<0){Da.html("");
k="";e.html("");j=""}l.append($("<tr>").data("index",c).html($("<td>").html(h).attr("title",g.name=="..."?"The results were truncated":g.name).addClass("overflow_ellipsis")).append($("<td>").text(g.source).attr("title",g.source).addClass("description").addClass("overflow_ellipsis").css("max-width","20em")).append($("<td>").data("sort-value",g.online).html(Ca)).append(e).append($("<td>").css("white-space","nowrap").html(k).append(j)).append(f));a++}},{totals:a,active_streams:true})};if(mist.data.LTS){var n= i="";e.html("");r=""}l.append($("<tr>").data("index",c).html($("<td>").html(h).attr("title",g.name=="..."?"The results were truncated":g.name).addClass("overflow_ellipsis")).append($("<td>").text(g.source).attr("title",g.source).addClass("description").addClass("overflow_ellipsis").css("max-width","20em")).append($("<td>").data("sort-value",g.online).html(Da)).append(e).append($("<td>").css("white-space","nowrap").html(i).append(r)).append(f));a++}},{totals:a,active_streams:true})};if(mist.data.LTS){var n=
0,o=0;for(e 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[e].source)){z[e].source=z[e].source+"*";z[e].filesfound=null;mist.send(function(a,b){var c=b.stream,d=0,g;a:for(g in a.browse.files){var f;for(f in mist.data.capabilities.inputs)if(!(f.indexOf("Buffer")>=0||f.indexOf("Buffer.exe")>=0||f.indexOf("Folder")>=0||f.indexOf("Folder.exe")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[f].source_match, 0,o=0;for(e 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[e].source)){A[e].source=A[e].source+"*";A[e].filesfound=null;mist.send(function(a,b){var c=b.stream,d=0,g;a:for(g in a.browse.files){var f;for(f in mist.data.capabilities.inputs)if(!(f.indexOf("Buffer")>=0||f.indexOf("Buffer.exe")>=0||f.indexOf("Folder")>=0||f.indexOf("Folder.exe")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[f].source_match,
"/"+a.browse.files[g])){var e=c+"+"+a.browse.files[g];z[e]=ja(e,mist.data.streams[c]);z[e].source=mist.data.streams[c].source+a.browse.files[g];d++;if(d>=500){z[c+"+zzzzzzzzz"]={ischild:true,name:"...",online:-1};break a}}}"files"in a.browse&&a.browse.files.length?z[c].filesfound=true:mist.data.streams[c].filesfound=false;o++;if(n==o){mist.send(function(){q()},{active_streams:true});UI.interval.set(function(){q()},5E3)}},{browse:mist.data.streams[e].source},{stream:e});n++}}if(n==0){mist.send(function(){q()}, "/"+a.browse.files[g])){var e=c+"+"+a.browse.files[g];A[e]=ja(e,mist.data.streams[c]);A[e].source=mist.data.streams[c].source+a.browse.files[g];d++;if(d>=500){A[c+"+zzzzzzzzz"]={ischild:true,name:"...",online:-1};break a}}}"files"in a.browse&&a.browse.files.length?A[c].filesfound=true:mist.data.streams[c].filesfound=false;o++;if(n==o){mist.send(function(){q()},{active_streams:true});UI.interval.set(function(){q()},5E3)}},{browse:mist.data.streams[e].source},{stream:e});n++}}if(n==0){mist.send(function(){q()},
{active_streams:true});UI.interval.set(function(){q()},5E3)}}else{mist.send(function(){q()},{active_streams:true});UI.interval.set(function(){q()},5E3)}}};if(mist.data.LTS){var la=0,Da=0,t={},Ea=[];for(g in mist.data.streams)if(mist.inputMatch((mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"]).source_match,mist.data.streams[g].source))Ea.push(g),mist.send(function(a,c){var d=c.stream,g=0,f;a:for(f in a.browse.files){var e;for(e in mist.data.capabilities.inputs)if(!(e.indexOf("Buffer")>= {active_streams:true});UI.interval.set(function(){q()},5E3)}}else{mist.send(function(){q()},{active_streams:true});UI.interval.set(function(){q()},5E3)}}};if(mist.data.LTS){var la=0,Ea=0,u={},Fa=[];for(g in mist.data.streams)if(mist.inputMatch((mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"]).source_match,mist.data.streams[g].source))Fa.push(g),mist.send(function(a,c){var d=c.stream,g=0,f;a:for(f in a.browse.files){var e;for(e in mist.data.capabilities.inputs)if(!(e.indexOf("Buffer")>=
0||e.indexOf("Folder")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[e].source_match,"/"+a.browse.files[f])){t[d+"+"+a.browse.files[f]]=true;g++;if(g>=500){t[d+"+zzzzzzzzz"]=true;break a}}}Da++;la==Da&&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;z[mist.data.active_streams[a]]=ja(mist.data.active_streams[a],mist.data.streams[c[0]])}}t=Object.keys(t);t=t.concat(Object.keys(mist.data.streams)); 0||e.indexOf("Folder")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[e].source_match,"/"+a.browse.files[f])){u[d+"+"+a.browse.files[f]]=true;g++;if(g>=500){u[d+"+zzzzzzzzz"]=true;break a}}}Ea++;la==Ea&&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){u[mist.data.active_streams[a]]=true;A[mist.data.active_streams[a]]=ja(mist.data.active_streams[a],mist.data.streams[c[0]])}}u=Object.keys(u);u=u.concat(Object.keys(mist.data.streams));
t.sort();ka(b,t,Ea)},{active_streams:true})},{browse:mist.data.streams[g].source},{stream:g}),la++;0==la&&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;z[mist.data.active_streams[a]]=ja(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();ka(b,t)},{active_streams:!0})}else ka(b, u.sort();ka(b,u,Fa)},{active_streams:true})},{browse:mist.data.streams[g].source},{stream:g}),la++;0==la&&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){u[mist.data.active_streams[a]]=true;A[mist.data.active_streams[a]]=ja(mist.data.active_streams[a],mist.data.streams[c[0]])}}u=Object.keys(u);mist.data.streams&&(u=u.concat(Object.keys(mist.data.streams)));u.sort();ka(b,u)},{active_streams:!0})}else ka(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..");return}K=!1;""!=b&&(K=!0);if(K){var Fa=b,o=mist.data.streams[Fa];c.find("h2").append(' "'+Fa+'"')}else c.html($("<h2>").text("New Stream")),o={};var Ga=[];for(r in mist.data.capabilities.inputs)Ga.push(mist.data.capabilities.inputs[r].source_match);var ca=$("<div>"),Ha=function(a){var c={};if(!mist.data.streams)mist.data.streams= 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..");return}K=!1;""!=b&&(K=!0);if(K){var Ga=b,o=mist.data.streams[Ga];c.find("h2").append(' "'+Ga+'"')}else c.html($("<h2>").text("New Stream")),o={};var Ha=[];for(s in mist.data.capabilities.inputs)Ha.push(mist.data.capabilities.inputs[s].source_match);var ca=$("<div>"),Ia=function(a){var c={};if(!mist.data.streams)mist.data.streams=
{};mist.data.streams[o.name]=o;b!=o.name&&delete mist.data.streams[b];c.addstream={};c.addstream[o.name]=o;if(b!=o.name)c.deletestream=[b];if(o.stop_sessions&&b!=""){c.stop_sessions=b;delete o.stop_sessions}mist.send(function(){delete mist.data.streams[o.name].online;delete mist.data.streams[o.name].error;UI.navto(a,a=="Preview"?o.name:"")},c)},Ia=$("<style>").text("button.saveandpreview { display: none; }"),M=$("<span>"),ma=function(){var a=c.find("[name=name]").val();if(a){var b=parseURL(mist.user.host), {};mist.data.streams[o.name]=o;b!=o.name&&delete mist.data.streams[b];c.addstream={};c.addstream[o.name]=o;if(b!=o.name)c.deletestream=[b];if(o.stop_sessions&&b!=""){c.stop_sessions=b;delete o.stop_sessions}mist.send(function(){delete mist.data.streams[o.name].online;delete mist.data.streams[o.name].error;UI.navto(a,a=="Preview"?o.name:"")},c)},Ja=$("<style>").text("button.saveandpreview { display: none; }"),M=$("<span>"),ma=function(){var a=c.find("[name=name]").val();if(a){var b=parseURL(mist.user.host),
d=c.find("[name=source]").val(),g=d.match(/@.*/);g&&(g=g[0].substring(1));var f=d.replace(/(?:.+?):\/\//,""),f=f.split("/"),f=f[0],f=f.split(":"),f=f[0];(d=d.match(/:\d+/))&&(d=d[0]);var e={},h=["RTMP","RTSP","RTMP.exe","RTSP.exe"],k;for(k in h)h[k]in mist.data.capabilities.connectors&&(e[h[k]]=mist.data.capabilities.connectors[h[k]].optional.port["default"]);var h={RTMP:1935,"RTMP.exe":1935,RTSP:554,"RTSP.exe":554,TS:-1,"TS.exe":-1},j;for(j in e){for(k in mist.data.config.protocols){var i=mist.data.config.protocols[k]; d=c.find("[name=source]").val(),g=d.match(/@.*/);g&&(g=g[0].substring(1));var f=d.replace(/(?:.+?):\/\//,""),f=f.split("/"),f=f[0],f=f.split(":"),f=f[0];(d=d.match(/:\d+/))&&(d=d[0]);var e={},h=["RTMP","RTSP","RTMP.exe","RTSP.exe"],i;for(i in h)h[i]in mist.data.capabilities.connectors&&(e[h[i]]=mist.data.capabilities.connectors[h[i]].optional.port["default"]);var h={RTMP:1935,"RTMP.exe":1935,RTSP:554,"RTSP.exe":554,TS:-1,"TS.exe":-1},j;for(j in e){for(i in mist.data.config.protocols){var k=mist.data.config.protocols[i];
if(i.connector==j){if("port"in i)e[j]=i.port;break}}e[j]=e[j]==h[j]?"":":"+e[j]}e.TS="";e["TS.exe"]="";M.find(".field").closest("label").hide();for(k in e){var B;j=d?d:e[k];switch(k){case "RTMP":case "RTMP.exe":B="rtmp://"+b.host+j+"/"+(g?g:"live")+"/";M.find(".field.RTMPurl").setval(B).closest("label").show();M.find(".field.RTMPkey").setval(a==""?"STREAMNAME":a).closest("label").show();B=B+(a==""?"STREAMNAME":a);break;case "RTSP":case "RTSP.exe":B="rtsp://"+b.host+j+"/"+(a==""?"STREAMNAME":a)+(g? if(k.connector==j){if("port"in k)e[j]=k.port;break}}e[j]=e[j]==h[j]?"":":"+e[j]}e.TS="";e["TS.exe"]="";M.find(".field").closest("label").hide();for(i in e){var r;j=d?d:e[i];switch(i){case "RTMP":case "RTMP.exe":r="rtmp://"+b.host+j+"/"+(g?g:"live")+"/";M.find(".field.RTMPurl").setval(r).closest("label").show();M.find(".field.RTMPkey").setval(a==""?"STREAMNAME":a).closest("label").show();r=r+(a==""?"STREAMNAME":a);break;case "RTSP":case "RTSP.exe":r="rtsp://"+b.host+j+"/"+(a==""?"STREAMNAME":a)+(g?
"?pass="+g:"");break;case "TS":case "TS.exe":B="udp://"+(f==""?b.host:f)+j+"/"}M.find(".field."+k.replace(".exe","")).setval(B).closest("label").show()}}},Ja=$("<div>"),na={},t=[],Ka=$("<div>");for(r in mist.data.capabilities.processes)t.push([r,mist.data.capabilities.processes[r].hrn?mist.data.capabilities.processes[r].hrn:mist.data.capabilities.processes[r].name]);if(t.length){var Za=[{label:"New process",type:"select",select:t,value:t[0][0],pointer:{main:na,index:"process"},"function":function(){var a= "?pass="+g:"");break;case "TS":case "TS.exe":r="udp://"+(f==""?b.host:f)+j+"/"}M.find(".field."+i.replace(".exe","")).setval(r).closest("label").show()}}},Ka=$("<div>"),na={},u=[],La=$("<div>");for(s in mist.data.capabilities.processes)u.push([s,mist.data.capabilities.processes[s].hrn?mist.data.capabilities.processes[s].hrn:mist.data.capabilities.processes[s].name]);if(u.length){var ab=[{label:"New process",type:"select",select:u,value:u[0][0],pointer:{main:na,index:"process"},"function":function(){var a=
$(this).getval();if(a!=null){var a=mist.data.capabilities.processes[a],b=[$("<h4>").text(a.name+" Process options")];Ka.html(UI.buildUI(b.concat(mist.convertBuildOptions(a,na))))}}},Ka];Ja.append(UI.buildUI([$("<br>"),$("<h3>").text("Stream processes"),{label:"Stream processes",itemLabel:"stream process",type:"sublist",sublist:Za,saveas:na,pointer:{main:o,index:"processes"}}]))}c.append(UI.buildUI([{label:"Stream name",type:"str",validate:["required","streamname"],pointer:{main:o,index:"name"},help:"Set the name this stream will be recognised by for players and/or stream pushing."}, $(this).getval();if(a!=null){var a=mist.data.capabilities.processes[a],b=[$("<h4>").text(a.name+" Process options")];La.html(UI.buildUI(b.concat(mist.convertBuildOptions(a,na))))}}},La];Ka.append(UI.buildUI([$("<br>"),$("<h3>").text("Stream processes"),{label:"Stream processes",itemLabel:"stream process",type:"sublist",sublist:ab,saveas:na,pointer:{main:o,index:"processes"}}]))}c.append(UI.buildUI([{label:"Stream name",type:"str",validate:["required","streamname"],pointer:{main:o,index:"name"},help:"Set the name this stream will be recognised by for players and/or stream pushing."},
{label:"Source",type:"browse",filetypes:Ga,pointer:{main:o,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 class=valigntop> <tr> <th colspan=3><b>File inputs</b></th> </tr> <tr> <th>File</th> <td> Linux/MacOS:&nbsp;/PATH/FILE<br> Windows:&nbsp;/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 </th> <td> Linux/MacOS:&nbsp;/PATH/<br> Windows:&nbsp;/cygdrive/DRIVE/PATH/ </td> <td class=LTSonly> A folder stream makes all the recognised files in the selected folder available as a stream. </td> </tr> <tr><td colspan=3>&nbsp;</td></tr> <tr> <th colspan=3><b>Push inputs</b></th> </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. </td> </tr> <tr> <th>RTSP</th> <td>push://(IP)(@PASSWORD)</td> <td class=LTSonly>IP is white listed IP for pushing towards MistServer, if left empty all are white listed.</td> </tr> <tr> <th>TS</th> <td>tsudp://(IP):PORT(/INTERFACE)</td> <td class=LTSonly> 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> <tr><td colspan=3>&nbsp;</td></tr> <tr> <th colspan=3><b>Pull inputs</b></th> </tr> <tr> <th>DTSC</th> <td>dtsc://MISTSERVER_IP:PORT/(STREAMNAME)</td> <td>MISTSERVER_IP is the IP of another MistServer to pull from.<br> PORT is the DTSC port of the other MistServer. (default is 4200)<br> STREAMNAME is the name of the target stream on the other MistServer. If left empty, the name of this stream will be used. </td> </tr> <tr> <th>HLS</th> <td>http://URL/TO/STREAM.m3u8</td> <td class=LTSonly>The URL where the HLS stream is available to MistServer.</td> </tr> <tr> <th>RTSP</th> <td>rtsp://(USER:PASSWORD@)IP(:PORT)(/path)</td> <td class=LTSonly> USER:PASSWORD is the account used if authorization is required.<br> IP is the IP address used to pull this stream from.<br> PORT is the port used to connect through.<br> PATH is the path to be used to identify the correct stream. </td> </tr> </table>".replace(/LTSonly/g, {label:"Source",type:"browse",filetypes:Ha,pointer:{main:o,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 class=valigntop> <tr> <th colspan=3><b>File inputs</b></th> </tr> <tr> <th>File</th> <td> Linux/MacOS:&nbsp;/PATH/FILE<br> Windows:&nbsp;/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 </th> <td> Linux/MacOS:&nbsp;/PATH/<br> Windows:&nbsp;/cygdrive/DRIVE/PATH/ </td> <td class=LTSonly> A folder stream makes all the recognised files in the selected folder available as a stream. </td> </tr> <tr><td colspan=3>&nbsp;</td></tr> <tr> <th colspan=3><b>Push inputs</b></th> </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. </td> </tr> <tr> <th>RTSP</th> <td>push://(IP)(@PASSWORD)</td> <td class=LTSonly>IP is white listed IP for pushing towards MistServer, if left empty all are white listed.</td> </tr> <tr> <th>TS</th> <td>tsudp://(IP):PORT(/INTERFACE)</td> <td class=LTSonly> 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> <tr><td colspan=3>&nbsp;</td></tr> <tr> <th colspan=3><b>Pull inputs</b></th> </tr> <tr> <th>DTSC</th> <td>dtsc://MISTSERVER_IP:PORT/(STREAMNAME)</td> <td>MISTSERVER_IP is the IP of another MistServer to pull from.<br> PORT is the DTSC port of the other MistServer. (default is 4200)<br> STREAMNAME is the name of the target stream on the other MistServer. If left empty, the name of this stream will be used. </td> </tr> <tr> <th>HLS</th> <td>http://URL/TO/STREAM.m3u8</td> <td class=LTSonly>The URL where the HLS stream is available to MistServer.</td> </tr> <tr> <th>RTSP</th> <td>rtsp://(USER:PASSWORD@)IP(:PORT)(/path)</td> <td class=LTSonly> USER:PASSWORD is the account used if authorization is required.<br> IP is the IP address used to pull this stream from.<br> PORT is the port used to connect through.<br> PATH is the path to be used to identify the correct stream. </td> </tr> </table>".replace(/LTSonly/g,
mist.data.LTS?'""':"LTSonly"),"function":function(){var a=$(this).val();Ia.remove();M.html("");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)ca.html($("<h3>").text("Unrecognized input").addClass("red")).append($("<span>").text("Please edit the stream source.").addClass("red"));else{b=mist.data.capabilities.inputs[b];ca.html($("<h3>").text(b.name+ mist.data.LTS?'""':"LTSonly"),"function":function(){var a=$(this).val();Ja.remove();M.html("");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)ca.html($("<h3>").text("Unrecognized input").addClass("red")).append($("<span>").text("Please edit the stream source.").addClass("red"));else{b=mist.data.capabilities.inputs[b];ca.html($("<h3>").text(b.name+
" Input options"));var g=mist.convertBuildOptions(b,o);"always_match"in mist.data.capabilities.inputs[d]&&mist.inputMatch(mist.data.capabilities.inputs[d].always_match,a)&&g.push({label:"Always on",type:"checkbox",help:"Keep this input available at all times, even when there are no active viewers.",pointer:{main:o,index:"always_on"}});ca.append(UI.buildUI(g));if(b.name=="Folder")c.append(Ia);else if(["Buffer","Buffer.exe","TS","TS.exe"].indexOf(b.name)>-1){d=[$("<br>"),$("<span>").text("Configure your source to push to:")]; " Input options"));var g=mist.convertBuildOptions(b,o);"always_match"in mist.data.capabilities.inputs[d]&&mist.inputMatch(mist.data.capabilities.inputs[d].always_match,a)&&g.push({label:"Always on",type:"checkbox",help:"Keep this input available at all times, even when there are no active viewers.",pointer:{main:o,index:"always_on"}});ca.append(UI.buildUI(g));if(b.name=="Folder")c.append(Ja);else if(["Buffer","Buffer.exe","TS","TS.exe"].indexOf(b.name)>-1){d=[$("<br>"),$("<span>").text("Configure your source to push to:")];
switch(b.name){case "Buffer":case "Buffer.exe":d.push({label:"RTMP full url",type:"span",clipboard:true,readonly:true,classes:["RTMP"],help:"Use this RTMP url if your client doesn't ask for a stream key"});d.push({label:"RTMP url",type:"span",clipboard:true,readonly:true,classes:["RTMPurl"],help:"Use this RTMP url if your client also asks for a stream key"});d.push({label:"RTMP stream key",type:"span",clipboard:true,readonly:true,classes:["RTMPkey"],help:"Use this key if your client asks for a stream key"}); switch(b.name){case "Buffer":case "Buffer.exe":d.push({label:"RTMP full url",type:"span",clipboard:true,readonly:true,classes:["RTMP"],help:"Use this RTMP url if your client doesn't ask for a stream key"});d.push({label:"RTMP url",type:"span",clipboard:true,readonly:true,classes:["RTMPurl"],help:"Use this RTMP url if your client also asks for a stream key"});d.push({label:"RTMP stream key",type:"span",clipboard:true,readonly:true,classes:["RTMPkey"],help:"Use this key if your client asks for a stream key"});
d.push({label:"RTSP",type:"span",clipboard:true,readonly:true,classes:["RTSP"]});break;case "TS":case "TS.exe":a.charAt(0)=="/"?d=[]:d.push({label:"TS",type:"span",clipboard:true,readonly:true,classes:["TS"]})}M.html(UI.buildUI(d));ma()}}}}},{label:"Stop sessions",type:"checkbox",help:"When saving these stream settings, kill this stream's current connections.",LTSonly:!0,pointer:{main:o,index:"stop_sessions"}},M,$("<br>"),{type:"custom",custom:ca},Ja,$("<br>"),$("<h3>").text("Encryption"),{type:"help", d.push({label:"RTSP",type:"span",clipboard:true,readonly:true,classes:["RTSP"]});break;case "TS":case "TS.exe":a.charAt(0)=="/"?d=[]:d.push({label:"TS",type:"span",clipboard:true,readonly:true,classes:["TS"]})}M.html(UI.buildUI(d));ma()}}}}},{label:"Stop sessions",type:"checkbox",help:"When saving these stream settings, kill this stream's current connections.",LTSonly:!0,pointer:{main:o,index:"stop_sessions"}},M,$("<br>"),{type:"custom",custom:ca},Ka,$("<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:o,index:"la_url"}},$("<br>"),{label:"Content key",type:"str",LTSonly:!0,pointer:{main:o,index:"contentkey"}},{type:"text",text:" - or - "},{label:"Key ID",type:"str",LTSonly:!0,pointer:{main:o, 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:o,index:"la_url"}},$("<br>"),{label:"Content key",type:"str",LTSonly:!0,pointer:{main:o,index:"contentkey"}},{type:"text",text:" - or - "},{label:"Key ID",type:"str",LTSonly:!0,pointer:{main:o,
index:"keyid"}},{label:"Key seed",type:"str",LTSonly:!0,pointer:{main:o,index:"keyseed"}},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Streams")}},{type:"save",label:"Save","function":function(){Ha("Streams")}},{type:"save",label:"Save and Preview","function":function(){Ha("Preview")},classes:["saveandpreview"]}]}]));c.find("[name=name]").keyup(function(){ma()});ma();break;case "Preview":""==b&&UI.navto("Streams");var N=parseURL(mist.user.host),U=N.protocol, index:"keyid"}},{label:"Key seed",type:"str",LTSonly:!0,pointer:{main:o,index:"keyseed"}},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Streams")}},{type:"save",label:"Save","function":function(){Ia("Streams")}},{type:"save",label:"Save and Preview","function":function(){Ia("Preview")},classes:["saveandpreview"]}]}]));c.find("[name=name]").keyup(function(){ma()});ma();break;case "Preview":""==b&&UI.navto("Streams");var N=parseURL(mist.user.host),U=N.protocol,
R=N.host,G=":8080",u=U+R+G+"/";for(r in mist.data.config.protocols)if(s=mist.data.config.protocols[r],"HTTP"==s.connector||"HTTP.exe"==s.connector){s.pubaddr&&s.pubaddr.length?"string"==typeof s.pubaddr?u=s.pubaddr.replace(/\/$/,"")+"/":s.pubaddr.length&&(u=s.pubaddr[0].replace(/\/$/,"")+"/"):(G=s.port?":"+s.port:":8080",u=U+R+G+"/");break}var Q=$("<div>").css({display:"flex","flex-flow":"row wrap","flex-shrink":1,"min-width":"auto"}),V="";-1==b.indexOf("+")&&(V=$("<button>").text("Settings").addClass("settings").click(function(){UI.navto("Edit", R=N.host,G=":8080",v=U+R+G+"/";for(s in mist.data.config.protocols)if(t=mist.data.config.protocols[s],"HTTP"==t.connector||"HTTP.exe"==t.connector){t.pubaddr&&t.pubaddr.length?"string"==typeof t.pubaddr?v=t.pubaddr.replace(/\/$/,"")+"/":t.pubaddr.length&&(v=t.pubaddr[0].replace(/\/$/,"")+"/"):(G=t.port?":"+t.port:":8080",v=U+R+G+"/");break}var Q=$("<div>").css({display:"flex","flex-flow":"row wrap","flex-shrink":1,"min-width":"auto"}),V="";-1==b.indexOf("+")&&(V=$("<button>").text("Settings").addClass("settings").click(function(){UI.navto("Edit",
b)}));c.html($("<div>").addClass("bigbuttons").append(V).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(Q);var H=encodeURIComponent(b),La=$("<div>").css("flex-shrink","1").css("min-width","auto").css("max-width","100%");Q.append(La);var Ma=$("<div>"),W=$("<div>").text("Loading player..").css("max-width", b)}));c.html($("<div>").addClass("bigbuttons").append(V).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(Q);var H=encodeURIComponent(b),Ma=$("<div>").css("flex-shrink","1").css("min-width","auto").css("max-width","100%");Q.append(Ma);var Na=$("<div>"),W=$("<div>").text("Loading player..").css("max-width",
"100%").css("flex-shrink","1").css("min-width","auto"),oa=$("<div>").addClass("controls");La.append(W).append(Ma).append(oa);$("link#devcss").length||c.append($("<link>").attr("rel","stylesheet").attr("type","text/css").attr("href",u+"skins/dev.css").attr("id","devcss"));var Na=function(){Ma.text("");var d=document.createElement("script");c.append(d);d.src=u+"player.js";d.onerror=function(){W.html($("<p>").append('Failed to load <a href="'+u+'player.js">'+u+"player.js</a>.")).append($("<p>").append("Please check if you've activated the HTTP protocol, if your http port is blocked, or if you're trying to load HTTPS on an HTTP page.")).append($("<button>").text("Reload").css("display", "100%").css("flex-shrink","1").css("min-width","auto"),oa=$("<div>").addClass("controls");Ma.append(W).append(Na).append(oa);$("link#devcss").length||c.append($("<link>").attr("rel","stylesheet").attr("type","text/css").attr("href",v+"skins/dev.css").attr("id","devcss"));var Oa=function(){Na.text("");var d=document.createElement("script");c.append(d);d.src=v+"player.js";d.onerror=function(){W.html($("<p>").append('Failed to load <a href="'+v+'player.js">'+v+"player.js</a>.")).append($("<p>").append("Please check if you've activated the HTTP protocol, if your http port is blocked, or if you're trying to load HTTPS on an HTTP page.")).append($("<button>").text("Reload").css("display",
"block").click(function(){Na()}))};d.onload=function(){var g=b,f=function(){var a=MistVideoObject.reference;oa.html("");oa.append(a.UI.buildStructure({type:"container",classes:["mistvideo-column"],style:{flexShrink:1},children:[{"if":function(){return this.playerName&&this.source},then:{type:"container",classes:["mistvideo-description"],style:{display:"block"},children:[{type:"playername",style:{display:"inline"}},{type:"text",text:"is playing",style:{margin:"0 0.2em"}},{type:"mimetype"}]}},{type:"decodingIssues", "block").click(function(){Oa()}))};d.onload=function(){var g=b,f=function(){var a=MistVideoObject.reference;oa.html("");oa.append(a.UI.buildStructure({type:"container",classes:["mistvideo-column"],style:{flexShrink:1},children:[{"if":function(){return this.playerName&&this.source},then:{type:"container",classes:["mistvideo-description"],style:{display:"block"},children:[{type:"playername",style:{display:"inline"}},{type:"text",text:"is playing",style:{margin:"0 0.2em"}},{type:"mimetype"}]}},{type:"decodingIssues",
style:{"max-width":"30em","flex-flow":"column nowrap"}},{type:"container",classes:["mistvideo-column","mistvideo-devcontrols"],children:[{type:"text",text:"Player control"},{type:"container",classes:["mistvideo-devbuttons"],style:{"flex-wrap":"wrap"},children:[{"if":function(){return!(!this.player||!this.player.api)},then:{type:"button",title:"Reload the video source",label:"Reload video",onclick:function(){this.player.api.load()}}},{type:"button",title:"Build MistVideo again",label:"Reload player", style:{"max-width":"30em","flex-flow":"column nowrap"}},{type:"container",classes:["mistvideo-column","mistvideo-devcontrols"],children:[{type:"text",text:"Player control"},{type:"container",classes:["mistvideo-devbuttons"],style:{"flex-wrap":"wrap"},children:[{"if":function(){return!(!this.player||!this.player.api)},then:{type:"button",title:"Reload the video source",label:"Reload video",onclick:function(){this.player.api.load()}}},{type:"button",title:"Build MistVideo again",label:"Reload player",
onclick:function(){this.reload()}},{type:"button",title:"Switch to the next available player and source combination",label:"Try next combination",onclick:function(){this.nextCombo()}}]},{type:"forcePlayer"},{type:"forceType"},{type:"forceSource"}]},{type:"log"}]}))};if(!(a!="Preview"||!b||b==""||g!=b)){W[0].addEventListener("initialized",f);W[0].addEventListener("initializeFailed",f);MistVideoObject.reference=mistPlay(g,{target:W[0],host:u,skin:"dev",loop:true,MistVideoObject:MistVideoObject})}c[0].removeChild(d)}; onclick:function(){this.reload()}},{type:"button",title:"Switch to the next available player and source combination",label:"Try next combination",onclick:function(){this.nextCombo()}}]},{type:"forcePlayer"},{type:"forceType"},{type:"forceSource"}]},{type:"log"}]}))};if(!(a!="Preview"||!b||b==""||g!=b)){W[0].addEventListener("initialized",f);W[0].addEventListener("initializeFailed",f);MistVideoObject.reference=mistPlay(g,{target:W[0],host:v,skin:"dev",loop:true,MistVideoObject:MistVideoObject})}c[0].removeChild(d)};
MistVideoObject.reference={unload:function(){d.onload=function(){this.parentElement&&this.parentElement.removeChild(this)}}}};Na();var Oa=$("<div>").append($("<h3>").text("Meta information")),da=$("<span>").text("Loading..");Oa.append(da);Q.append(Oa);""!=H&&$.ajax({type:"GET",url:u+"json_"+H+".js",success:function(a){var b=function(a,b){return"maxbps"in a?UI.format.bytes(a[b],1):b=="maxbps"?UI.format.bytes(a.bps,1):"unknown"},c=a.meta;if(!c||!c.tracks)da.html("No meta information available.");else{a= MistVideoObject.reference={unload:function(){d.onload=function(){this.parentElement&&this.parentElement.removeChild(this)}}}};Oa();var pa=$("<div>").append($("<h3>").text("Meta information")),da=$("<span>").text("Loading..");pa.append(da);var Pa=$("<div>").addClass("process_info");pa.append(Pa);Q.append(pa);if(""!=H){$.ajax({type:"GET",url:v+"json_"+H+".js",success:function(a){var b=function(a,b){return"maxbps"in a?UI.format.bytes(a[b],1):b=="maxbps"?UI.format.bytes(a.bps,1):"unknown"},c=a.meta;if(!c||
[];a.push({label:"Type",type:"span",value:c.live?"Live":"Pre-recorded (VoD)"});"format"in c&&a.push({label:"Format",type:"span",value:c.format});c.live&&a.push({label:"Buffer window",type:"span",value:UI.format.addUnit(c.buffer_window,"ms")});var d={audio:{vheader:"Audio",labels:["Codec","Duration","Avg bitrate","Peak bitrate","Channels","Samplerate","Language","Track index"],content:[]},video:{vheader:"Video",labels:["Codec","Duration","Avg bitrate","Peak bitrate","Size","Framerate","Language","Track index", !c.tracks)da.html("No meta information available.");else{a=[];a.push({label:"Type",type:"span",value:c.live?"Live":"Pre-recorded (VoD)"});"format"in c&&a.push({label:"Format",type:"span",value:c.format});c.live&&a.push({label:"Buffer window",type:"span",value:UI.format.addUnit(c.buffer_window,"ms")});var d={audio:{vheader:"Audio",labels:["Codec","Duration","Avg bitrate","Peak bitrate","Channels","Samplerate","Language","Track index"],content:[]},video:{vheader:"Video",labels:["Codec","Duration","Avg bitrate",
"Has B-Frames"],content:[]},subtitle:{vheader:"Subtitles",labels:["Codec","Duration","Avg bitrate","Peak bitrate","Language","Track index"],content:[]}},g=Object.keys(c.tracks);g.sort(function(a,b){a=a.split("_").pop();b=b.split("_").pop();return a-b});var f=1,e=1,h=1,k;for(k in g){var j=g[k],i=c.tracks[j];switch(i.type){case "audio":d.audio.content.push({header:"Track "+j.split("_").pop(),body:[i.codec,UI.format.duration((i.lastms-i.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(i.firstms/ "Peak bitrate","Size","Framerate","Language","Track index","Has B-Frames"],content:[]},subtitle:{vheader:"Subtitles",labels:["Codec","Duration","Avg bitrate","Peak bitrate","Language","Track index"],content:[]}},g=Object.keys(c.tracks);g.sort(function(a,b){a=a.split("_").pop();b=b.split("_").pop();return a-b});var f=1,e=1,h=1,i;for(i in g){var j=g[i],r=c.tracks[j];switch(r.type){case "audio":d.audio.content.push({header:"Track "+j.split("_").pop(),body:[r.codec,UI.format.duration((r.lastms-r.firstms)/
1E3)+" to "+UI.format.duration(i.lastms/1E3)+"</span>",b(i,"bps"),b(i,"maxbps"),i.channels,UI.format.addUnit(UI.format.number(i.rate),"Hz"),"language"in i?i.language:"unknown",f]});f++;break;case "video":d.video.content.push({header:"Track "+j.split("_").pop(),body:[i.codec,UI.format.duration((i.lastms-i.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(i.firstms/1E3)+" to "+UI.format.duration(i.lastms/1E3)+"</span>",b(i,"bps"),b(i,"maxbps"),UI.format.addUnit(i.width,"x ")+UI.format.addUnit(i.height, 1E3)+"<br><span class=description>"+UI.format.duration(r.firstms/1E3)+" to "+UI.format.duration(r.lastms/1E3)+"</span>",b(r,"bps"),b(r,"maxbps"),r.channels,UI.format.addUnit(UI.format.number(r.rate),"Hz"),"language"in r?r.language:"unknown",f]});f++;break;case "video":d.video.content.push({header:"Track "+j.split("_").pop(),body:[r.codec,UI.format.duration((r.lastms-r.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(r.firstms/1E3)+" to "+UI.format.duration(r.lastms/1E3)+"</span>",b(r,
"px"),UI.format.addUnit(UI.format.number(i.fpks/1E3),"fps"),"language"in i?i.language:"unknown",e,"bframes"in i?"yes":"no"]});e++;break;case "meta":case "subtitle":if(i.codec=="subtitle"||i.type=="subtitle"){d.subtitle.content.push({header:"Track "+j.split("_").pop(),body:[i.codec,UI.format.duration((i.lastms-i.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(i.firstms/1E3)+" to "+UI.format.duration(i.lastms/1E3)+"</span>",b(i,"bps"),b(i,"maxbps"),"language"in i?i.language:"unknown", "bps"),b(r,"maxbps"),UI.format.addUnit(r.width,"x ")+UI.format.addUnit(r.height,"px"),UI.format.addUnit(UI.format.number(r.fpks/1E3),"fps"),"language"in r?r.language:"unknown",e,"bframes"in r?"yes":"no"]});e++;break;case "meta":case "subtitle":if(r.codec=="subtitle"||r.type=="subtitle"){d.subtitle.content.push({header:"Track "+j.split("_").pop(),body:[r.codec,UI.format.duration((r.lastms-r.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(r.firstms/1E3)+" to "+UI.format.duration(r.lastms/
h]});h++}}}b=["audio","video","subtitle"];k=$("<div>").css({display:"flex","flex-flow":"row wrap","font-size":"0.9em"});for(j in b)d[b[j]].content.length&&k.append(UI.buildVheaderTable(d[b[j]]).css("width","auto"));a.push($("<span>").text("Tracks:"));a.push(k);da.html(UI.buildUI(a))}},error:function(){da.html("Error while retrieving stream info.")}});break;case "Embed":""==b&&UI.navTo("Streams");V="";-1==b.indexOf("+")&&(V=$("<button>").addClass("settings").text("Settings").click(function(){UI.navto("Edit", 1E3)+"</span>",b(r,"bps"),b(r,"maxbps"),"language"in r?r.language:"unknown",h]});h++}}}b=["audio","video","subtitle"];i=$("<div>").css({display:"flex","flex-flow":"row wrap","font-size":"0.9em"});for(j in b)d[b[j]].content.length&&i.append(UI.buildVheaderTable(d[b[j]]).css("width","auto"));a.push($("<span>").text("Tracks:"));a.push(i);da.html(UI.buildUI(a))}},error:function(){da.html("Error while retrieving stream info.")}});var Qa=function(){var a={proc_list:b};if(!mist.data.capabilities)a.capabilities=
b)}));c.html($("<div>").addClass("bigbuttons").append(V).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 X=$("<span>");c.append(X);var H=encodeURIComponent(b),N=parseURL(mist.user.host),U=N.protocol,R=N.host,G=":8080",Y,ea={},u={http:U+R+G+"/"};for(r in mist.data.config.protocols)if(s=mist.data.config.protocols[r], true;mist.send(function(a){if(a.proc_list){var b=$("<table>").css("width","auto"),c={"Process type:":function(a){return $("<b>").text(a.process)},"Source:":function(a){var b=$("<span>").text(a.source);a.source_tracks&&a.source_tracks.length&&b.append($("<span>").addClass("description").text(" track "+a.source_tracks.slice(0,-2).concat(a.source_tracks.slice(-2).join(" and ")).join(", ")));return b},"Sink:":function(a){var b=$("<span>").text(a.sink);a.sink_tracks&&a.sink_tracks.length&&b.append($("<span>").addClass("description").text(" track "+
"HTTP"==s.connector||"HTTP.exe"==s.connector)s.pubaddr?("string"==typeof s.pubaddr?u.http=s.pubaddr.replace(/\/$/,"")+"/":s.pubaddr.length&&(u.http=s.pubaddr[0].replace(/\/$/,"")+"/"),ea.http=s.pubaddr):(G=s.port?":"+s.port:":8080",u.http=U+R+G+"/");else if("HTTPS"==s.connector||"HTTPS.exe"==s.connector)s.pubaddr&&s.pubaddr.length?("string"==typeof s.pubaddr?u.https=s.pubaddr.replace(/\/$/,"")+"/":s.pubaddr.length&&(u.https=s.pubaddr[0].replace(/\/$/,"")+"/"),ea.https=s.pubaddr):(Y=s.port?":"+s.port: a.sink_tracks.slice(0,-2).concat(a.sink_tracks.slice(-2).join(" and ")).join(", ")));return b},"Active for:":function(a){var b=(new Date).setSeconds((new Date).getSeconds()-a.active_seconds);return $("<span>").append($("<span>").text(UI.format.duration(a.active_seconds))).append($("<span>").addClass("description").text(" since "+UI.format.time(b/1E3)))},"Pid:":function(a,b){return b},"Logs:":function(a){var b=$("<div>").text("None.");if(a.logs&&a.logs.length){b.html("").addClass("description").css({overflow:"auto",
":4433",u.https="https://"+R+Y+"/");var O=u.http,A={http:u.http};"https"in u&&(A.https=u.https);if(otherhost.host||otherhost.https){O=(otherhost.https&&Y?"https://":"http://")+(otherhost.host?otherhost.host:N.host)+(otherhost.https&&Y?Y:G)+"/";if(otherhost.host&&("http"in ea||(A.http=parseURL(A.http,{hostname:otherhost.host}).full),"https"in A&&!("https"in ea)))A.https=parseURL(A.https,{hostname:otherhost.host}).full;O=otherhost.https?A.https:A.http}var Z=!1,pa={forcePlayer:"",forceType:"",controls:!0, maxHeight:"6em",display:"flex",flexFlow:"column-reverse nowrap"});for(var c in a.logs){var d=a.logs[c];b.prepend($("<div>").append(UI.format.time(d[0])+" ["+d[1]+"] "+d[2]))}}return b},"Additional info:":function(a){var b;if(a.ainfo&&Object.keys(a.ainfo).length){b=$("<table>");for(var c in a.ainfo){var d=mist.data.capabilities.processes[a.process].ainfo[c];d||(d={name:c});b.append($("<tr>").append($("<th>").text(d.name+":")).append($("<td>").html(a.ainfo[c]).append(d.unit?$("<span>").addClass("unit").text(d.unit):
autoplay:!0,loop:!1,muted:!1,fillSpace:!1,poster:"",urlappend:"",setTracks:{}},p=$.extend({},pa),Pa=UI.stored.getOpts();"embedoptions"in Pa&&(p=$.extend(p,Pa.embedoptions,!0),"object"!=typeof p.setTracks&&(p.setTracks={}));var fa={};switch(p.controls){case "stock":fa.controls="stock";break;case !0:fa.controls=1;break;case !1:fa.controls=0}var x=function(){function a(b){switch(typeof b){case "string":return $.isNumeric(b)?b:'"'+b+'"';case "object":return JSON.stringify(b);default:return b}}Z&&UI.stored.saveOpt("embedoptions", "")))}}else b=$("<span>").addClass("description").text("N/A");return b}};Pa.html($("<h4>").text("Stream processes")).append(b);for(var d in c){var g=$("<tr>");b.append(g);g.append($("<th>").text(d).css("vertical-align","top"));for(var f in a.proc_list){$out=c[d](a.proc_list[f],f);g.append($("<td>").html($out).css("vertical-align","top"))}}}},a)};UI.interval.set(function(){Qa()},5E3);Qa()}break;case "Embed":""==b&&UI.navTo("Streams");V="";-1==b.indexOf("+")&&(V=$("<button>").addClass("settings").text("Settings").click(function(){UI.navto("Edit",
b)}));c.html($("<div>").addClass("bigbuttons").append(V).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 X=$("<span>");c.append(X);var H=encodeURIComponent(b),N=parseURL(mist.user.host),U=N.protocol,R=N.host,G=":8080",Y,ea={},v={http:U+R+G+"/"};for(s in mist.data.config.protocols)if(t=mist.data.config.protocols[s],
"HTTP"==t.connector||"HTTP.exe"==t.connector)t.pubaddr?("string"==typeof t.pubaddr?v.http=t.pubaddr.replace(/\/$/,"")+"/":t.pubaddr.length&&(v.http=t.pubaddr[0].replace(/\/$/,"")+"/"),ea.http=t.pubaddr):(G=t.port?":"+t.port:":8080",v.http=U+R+G+"/");else if("HTTPS"==t.connector||"HTTPS.exe"==t.connector)t.pubaddr&&t.pubaddr.length?("string"==typeof t.pubaddr?v.https=t.pubaddr.replace(/\/$/,"")+"/":t.pubaddr.length&&(v.https=t.pubaddr[0].replace(/\/$/,"")+"/"),ea.https=t.pubaddr):(Y=t.port?":"+t.port:
":4433",v.https="https://"+R+Y+"/");var O=v.http,B={http:v.http};"https"in v&&(B.https=v.https);if(otherhost.host||otherhost.https){O=(otherhost.https&&Y?"https://":"http://")+(otherhost.host?otherhost.host:N.host)+(otherhost.https&&Y?Y:G)+"/";if(otherhost.host&&("http"in ea||(B.http=parseURL(B.http,{hostname:otherhost.host}).full),"https"in B&&!("https"in ea)))B.https=parseURL(B.https,{hostname:otherhost.host}).full;O=otherhost.https?B.https:B.http}var Z=!1,qa={forcePlayer:"",forceType:"",controls:!0,
autoplay:!0,loop:!1,muted:!1,fillSpace:!1,poster:"",urlappend:"",setTracks:{}},p=$.extend({},qa),Ra=UI.stored.getOpts();"embedoptions"in Ra&&(p=$.extend(p,Ra.embedoptions,!0),"object"!=typeof p.setTracks&&(p.setTracks={}));var fa={};switch(p.controls){case "stock":fa.controls="stock";break;case !0:fa.controls=1;break;case !1:fa.controls=0}var y=function(){function a(b){switch(typeof b){case "string":return $.isNumeric(b)?b:'"'+b+'"';case "object":return JSON.stringify(b);default:return b}}Z&&UI.stored.saveOpt("embedoptions",
p);for(var c=b+"_",d=12,g="";d--;){var f;f=Math.floor(Math.random()*62);f=f<10?f:f<36?String.fromCharCode(f+55):String.fromCharCode(f+61);g=g+f}var c=c+g,d=['target: document.getElementById("'+c+'")'],e;for(e in p)e=="prioritize_type"?p[e]&&p[e]!=""&&d.push("forcePriority: "+JSON.stringify({source:[["type",[p[e]]]]})):e=="monitor_action"?p[e]&&p[e]!=""&&p[e]=="nextCombo"&&d.push('monitor: {\n action: function(){\n this.MistVideo.log("Switching to nextCombo because of poor playback in "+this.MistVideo.source.type+" ("+Math.round(this.vars.score*1000)/10+"%)");\n this.MistVideo.nextCombo();\n }\n }'): p);for(var c=b+"_",d=12,g="";d--;){var f;f=Math.floor(Math.random()*62);f=f<10?f:f<36?String.fromCharCode(f+55):String.fromCharCode(f+61);g=g+f}var c=c+g,d=['target: document.getElementById("'+c+'")'],e;for(e in p)e=="prioritize_type"?p[e]&&p[e]!=""&&d.push("forcePriority: "+JSON.stringify({source:[["type",[p[e]]]]})):e=="monitor_action"?p[e]&&p[e]!=""&&p[e]=="nextCombo"&&d.push('monitor: {\n action: function(){\n this.MistVideo.log("Switching to nextCombo because of poor playback in "+this.MistVideo.source.type+" ("+Math.round(this.vars.score*1000)/10+"%)");\n this.MistVideo.nextCombo();\n }\n }'):
p[e]!=pa[e]&&(p[e]!=null&&(typeof p[e]!="object"||JSON.stringify(p[e])!=JSON.stringify(pa[e])))&&d.push(e+": "+a(p[e]));e=[];e.push('<div class="mistvideo" id="'+c+'">');e.push(" <noscript>");e.push(' <a href="'+(otherhost.https?A.https:A.http)+H+'.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(" });"); p[e]!=qa[e]&&(p[e]!=null&&(typeof p[e]!="object"||JSON.stringify(p[e])!=JSON.stringify(qa[e])))&&d.push(e+": "+a(p[e]));e=[];e.push('<div class="mistvideo" id="'+c+'">');e.push(" <noscript>");e.push(' <a href="'+(otherhost.https?B.https:B.http)+H+'.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");');if("https"in u&&parseURL(u.http).protocol!="https://"){e.push(' if (location.protocol == "https:") { p.src = "'+A.https+'player.js" } ');e.push(' else { p.src = "'+A.http+'player.js" } ')}else e.push(' p.src = "'+O+'player.js"');e.push(" document.head.appendChild(p);");e.push(" p.onload = a;");e.push(" }");e.push(" else { a(); }");e.push(" <\/script>"); e.push(" };");e.push(" if (!window.mistplayers) {");e.push(' var p = document.createElement("script");');if("https"in v&&parseURL(v.http).protocol!="https://"){e.push(' if (location.protocol == "https:") { p.src = "'+B.https+'player.js" } ');e.push(' else { p.src = "'+B.http+'player.js" } ')}else e.push(' p.src = "'+O+'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")},qa=$("<span>").text("Loading.."),Qa=x(p),S=$("<div>").text("Loading..").css("display","flex").css("flex-flow","column nowrap"),Ra="";"https"in u&&(Ra=UI.buildUI([{label:"Use HTTPS",type:"checkbox","function":function(){if($(this).getval()!=otherhost.https){otherhost.https=$(this).getval();UI.navto("Embed",b)}},value:otherhost.https}]).find("label"));X.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", e.push("</div>");return e.join("\n")},ra=$("<span>").text("Loading.."),Sa=y(p),S=$("<div>").text("Loading..").css("display","flex").css("flex-flow","column nowrap"),Ta="";"https"in v&&(Ta=UI.buildUI([{label:"Use HTTPS",type:"checkbox","function":function(){if($(this).getval()!=otherhost.https){otherhost.https=$(this).getval();UI.navto("Embed",b)}},value:otherhost.https}]).find("label"));X.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.host?otherhost.host:N.host)).append($("<span>").addClass("unit").append($("<button>").text("Apply").click(function(){otherhost.host=$(this).closest("label").find("input").val();UI.navto("Embed",b)}))))).append(Ra)).append(UI.buildUI([$("<h3>").text("Urls"),{label:"Stream info json",type:"str",value:O+"json_"+H+".js",readonly:!0,clipboard:!0,help:"Information about this stream as a json page."},{label:"Stream info script",type:"str",value:O+"info_"+H+".js",readonly:!0, "text").addClass("field").val(otherhost.host?otherhost.host:N.host)).append($("<span>").addClass("unit").append($("<button>").text("Apply").click(function(){otherhost.host=$(this).closest("label").find("input").val();UI.navto("Embed",b)}))))).append(Ta)).append(UI.buildUI([$("<h3>").text("Urls"),{label:"Stream info json",type:"str",value:O+"json_"+H+".js",readonly:!0,clipboard:!0,help:"Information about this stream as a json page."},{label:"Stream info script",type:"str",value:O+"info_"+H+".js",readonly:!0,
clipboard:!0,help:"This script loads information about this stream into a mistvideo javascript object."},{label:"HTML page",type:"str",value:O+H+".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:Qa,rows:Qa.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."}, clipboard:!0,help:"This script loads information about this stream into a mistvideo javascript object."},{label:"HTML page",type:"str",value:O+H+".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:Sa,rows:Sa.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:"Prioritize type",type:"select",select:[["","Automatic"]],pointer:{main:p,index:"prioritize_type"},classes:["prioritize_type"],"function":function(){if(Z){p.prioritize_type=$(this).getval();$(".embed_code").setval(x(p))}},help:"Try to use this source type first, but full back to something else if it is not available."}, $("<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:"Prioritize type",type:"select",select:[["","Automatic"]],pointer:{main:p,index:"prioritize_type"},classes:["prioritize_type"],"function":function(){if(Z){p.prioritize_type=$(this).getval();$(".embed_code").setval(y(p))}},help:"Try to use this source type first, but full back to something else if it is not available."},
{label:"Force type",type:"select",select:[["","Automatic"]],pointer:{main:p,index:"forceType"},classes:["forceType"],"function":function(){if(Z){p.forceType=$(this).getval();$(".embed_code").setval(x(p))}},help:"Only use this particular source."},{label:"Force player",type:"select",select:[["","Automatic"]],pointer:{main:p,index:"forcePlayer"},classes:["forcePlayer"],"function":function(){if(Z){p.forcePlayer=$(this).getval();$(".embed_code").setval(x(p))}},help:"Only use this particular player."}, {label:"Force type",type:"select",select:[["","Automatic"]],pointer:{main:p,index:"forceType"},classes:["forceType"],"function":function(){if(Z){p.forceType=$(this).getval();$(".embed_code").setval(y(p))}},help:"Only use this particular source."},{label:"Force player",type:"select",select:[["","Automatic"]],pointer:{main:p,index:"forcePlayer"},classes:["forcePlayer"],"function":function(){if(Z){p.forcePlayer=$(this).getval();$(".embed_code").setval(y(p))}},help:"Only use this particular player."},
{label:"Controls",type:"select",select:[["1","MistServer Controls"],["stock","Player controls"],["0","None"]],pointer:{main:fa,index:"controls"},"function":function(){p.controls=$(this).getval()==1;switch($(this).getval()){case 0:p.controls=false;break;case 1:p.controls=true;break;case "stock":p.controls="stock"}$(".embed_code").setval(x(p))},help:"The type of controls that should be shown."},{label:"Autoplay",type:"checkbox",pointer:{main:p,index:"autoplay"},"function":function(){p.autoplay=$(this).getval(); {label:"Controls",type:"select",select:[["1","MistServer Controls"],["stock","Player controls"],["0","None"]],pointer:{main:fa,index:"controls"},"function":function(){p.controls=$(this).getval()==1;switch($(this).getval()){case 0:p.controls=false;break;case 1:p.controls=true;break;case "stock":p.controls="stock"}$(".embed_code").setval(y(p))},help:"The type of controls that should be shown."},{label:"Autoplay",type:"checkbox",pointer:{main:p,index:"autoplay"},"function":function(){p.autoplay=$(this).getval();
$(".embed_code").setval(x(p))},help:"Whether or not the video should play as the page is loaded."},{label:"Loop",type:"checkbox",pointer:{main:p,index:"loop"},"function":function(){p.loop=$(this).getval();$(".embed_code").setval(x(p))},help:"If the video should restart when the end is reached."},{label:"Start muted",type:"checkbox",pointer:{main:p,index:"muted"},"function":function(){p.muted=$(this).getval();$(".embed_code").setval(x(p))},help:"If the video should restart when the end is reached."}, $(".embed_code").setval(y(p))},help:"Whether or not the video should play as the page is loaded."},{label:"Loop",type:"checkbox",pointer:{main:p,index:"loop"},"function":function(){p.loop=$(this).getval();$(".embed_code").setval(y(p))},help:"If the video should restart when the end is reached."},{label:"Start muted",type:"checkbox",pointer:{main:p,index:"muted"},"function":function(){p.muted=$(this).getval();$(".embed_code").setval(y(p))},help:"If the video should restart when the end is reached."},
{label:"Fill available space",type:"checkbox",pointer:{main:p,index:"fillSpace"},"function":function(){p.fillSpace=$(this).getval();$(".embed_code").setval(x(p))},help:"The video will fit the available space in its container, even if the video stream has a smaller resolution."},{label:"Poster",type:"str",pointer:{main:p,index:"poster"},"function":function(){p.poster=$(this).getval();$(".embed_code").setval(x(p))},help:"URL to an image that is displayed when the video is not playing."},{label:"Video URL addition", {label:"Fill available space",type:"checkbox",pointer:{main:p,index:"fillSpace"},"function":function(){p.fillSpace=$(this).getval();$(".embed_code").setval(y(p))},help:"The video will fit the available space in its container, even if the video stream has a smaller resolution."},{label:"Poster",type:"str",pointer:{main:p,index:"poster"},"function":function(){p.poster=$(this).getval();$(".embed_code").setval(y(p))},help:"URL to an image that is displayed when the video is not playing."},{label:"Video URL addition",
type:"str",pointer:{main:p,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(){p.urlappend=$(this).getval();$(".embed_code").setval(x(p))}},{label:"Preselect tracks",type:"DOMfield",DOMfield:S,help:"Pre-select these tracks."},{label:"Monitoring action",type:"select",select:[["","Ask the viewer what to do"],["nextCombo","Try the next source / player combination"]],pointer:{main:p, type:"str",pointer:{main:p,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(){p.urlappend=$(this).getval();$(".embed_code").setval(y(p))}},{label:"Preselect tracks",type:"DOMfield",DOMfield:S,help:"Pre-select these tracks."},{label:"Monitoring action",type:"select",select:[["","Ask the viewer what to do"],["nextCombo","Try the next source / player combination"]],pointer:{main:p,
index:"monitor_action"},"function":function(){p.monitor_action=$(this).getval();$(".embed_code").setval(x(p))},help:"What the player should do when playback is poor."},$("<h3>").text("Protocol stream urls"),qa]));$.ajax({type:"GET",url:O+"json_"+H+".js",success:function(a){var b=[],c=X.find(".field.forceType"),d=X.find(".field.prioritize_type"),e;for(e in a.source){var g=a.source[e],f=UI.humanMime(g.type);b.push({label:f?f+" <span class=description>("+g.type+")</span>":UI.format.capital(g.type),type:"str", index:"monitor_action"},"function":function(){p.monitor_action=$(this).getval();$(".embed_code").setval(y(p))},help:"What the player should do when playback is poor."},$("<h3>").text("Protocol stream urls"),ra]));$.ajax({type:"GET",url:O+"json_"+H+".js",success:function(a){var b=[],c=X.find(".field.forceType"),d=X.find(".field.prioritize_type"),e;for(e in a.source){var g=a.source[e],f=UI.humanMime(g.type);b.push({label:f?f+" <span class=description>("+g.type+")</span>":UI.format.capital(g.type),type:"str",
value:g.url,readonly:true,qrcode:true,clipboard:true});f=UI.humanMime(g.type);if(c.children('option[value="'+g.type+'"]').length==0){c.append($("<option>").text(f?f+" ("+g.type+")":UI.format.capital(g.type)).val(g.type));d.append($("<option>").text(f?f+" ("+g.type+")":UI.format.capital(g.type)).val(g.type))}}c.val(p.forceType);d.val(p.prioritize_type);qa.html(UI.buildUI(b));S.html("");b={};for(e in a.meta.tracks){c=a.meta.tracks[e];if(c.codec=="subtitle")c.type="subtitle";if(!(c.type!="audio"&&c.type!= value:g.url,readonly:true,qrcode:true,clipboard:true});f=UI.humanMime(g.type);if(c.children('option[value="'+g.type+'"]').length==0){c.append($("<option>").text(f?f+" ("+g.type+")":UI.format.capital(g.type)).val(g.type));d.append($("<option>").text(f?f+" ("+g.type+")":UI.format.capital(g.type)).val(g.type))}}c.val(p.forceType);d.val(p.prioritize_type);ra.html(UI.buildUI(b));S.html("");b={};for(e in a.meta.tracks){c=a.meta.tracks[e];if(c.codec=="subtitle")c.type="subtitle";if(!(c.type!="audio"&&c.type!=
"video"&&c.type!="subtitle")){c.type in b||(b[c.type]=c.type=="subtitle"?[]:[["","Autoselect "+c.type]]);b[c.type].push([c.trackid,UI.format.capital(c.type)+" track "+(b[c.type].length+(c.type=="subtitle"?1:0))])}}if(Object.keys(b).length){S.closest("label").show();var a=["audio","video","subtitle"],h;for(h in a){e=a[h];if(b[e]&&b[e].length){c=$("<select>").attr("data-type",e).css("flex-grow","1").change(function(){$(this).val()==""?delete p.setTracks[$(this).attr("data-type")]:p.setTracks[$(this).attr("data-type")]= "video"&&c.type!="subtitle")){c.type in b||(b[c.type]=c.type=="subtitle"?[]:[["","Autoselect "+c.type]]);b[c.type].push([c.trackid,UI.format.capital(c.type)+" track "+(b[c.type].length+(c.type=="subtitle"?1:0))])}}if(Object.keys(b).length){S.closest("label").show();var a=["audio","video","subtitle"],h;for(h in a){e=a[h];if(b[e]&&b[e].length){c=$("<select>").attr("data-type",e).css("flex-grow","1").change(function(){$(this).val()==""?delete p.setTracks[$(this).attr("data-type")]:p.setTracks[$(this).attr("data-type")]=
$(this).val();$(".embed_code").setval(x(p))});S.append(c);e=="subtitle"?b[e].unshift(["","No "+e]):b[e].push([-1,"No "+e]);for(var i in b[e])c.append($("<option>").val(b[e][i][0]).text(b[e][i][1]));if(e in p.setTracks){c.val(p.setTracks[e]);if(c.val()==null){c.val("");delete p.setTracks[e];$(".embed_code").setval(x(p))}}}}}else S.closest("label").hide();Z=true},error:function(){qa.html("Error while retrieving stream info.");S.closest("label").hide();p.setTracks={}}});var ga=document.createElement("script"); $(this).val();$(".embed_code").setval(y(p))});S.append(c);e=="subtitle"?b[e].unshift(["","No "+e]):b[e].push([-1,"No "+e]);for(var i in b[e])c.append($("<option>").val(b[e][i][0]).text(b[e][i][1]));if(e in p.setTracks){c.val(p.setTracks[e]);if(c.val()==null){c.val("");delete p.setTracks[e];$(".embed_code").setval(y(p))}}}}}else S.closest("label").hide();Z=true},error:function(){ra.html("Error while retrieving stream info.");S.closest("label").hide();p.setTracks={}}});var ga=document.createElement("script");
ga.src=u.http+"player.js";document.head.appendChild(ga);ga.onload=function(){var a=X.find(".field.forcePlayer"),b;for(b in mistplayers)a.append($("<option>").text(mistplayers[b].name).val(b));document.head.removeChild(this)};ga.onerror=function(){document.head.removeChild(this)};break;case "Push":var I=$("<div>").text("Loading..");c.append(I);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, ga.src=v.http+"player.js";document.head.appendChild(ga);ga.onload=function(){var a=X.find(".field.forcePlayer"),b;for(b in mistplayers)a.append($("<option>").text(mistplayers[b].name).val(b));document.head.removeChild(this)};ga.onerror=function(){document.head.removeChild(this)};break;case "Push":var I=$("<div>").text("Loading..");c.append(I);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,
g;for(g in c.push_list)if(a.indexOf(c.push_list[g][0])>-1){d=false;break}}else d=true;if(d)for(g in a)e.find("tr[data-pushid="+a[g]+"]").remove();else b()},{push_list:1})},1E3)}function c(g,f){var h=$("<span>"),i=$("<span>");if(f=="Automatic"&&g.length>=4){h.append($("<span>").text(g[2]));g[3]&&h.append($("<span>").text(", schedule on "+(new Date(g[3]*1E3)).toLocaleString()));g.length>=5&&g[4]&&h.append($("<span>").text(", complete on "+(new Date(g[4]*1E3)).toLocaleString()))}else g.length>=4&&g[2]!= g;for(g in c.push_list)if(a.indexOf(c.push_list[g][0])>-1){d=false;break}}else d=true;if(d)for(g in a)e.find("tr[data-pushid="+a[g]+"]").remove();else b()},{push_list:1})},1E3)}function c(g,f){var h=$("<span>"),i=$("<span>");if(f=="Automatic"&&g.length>=4){h.append($("<span>").text(g[2]));g[3]&&h.append($("<span>").text(", schedule on "+(new Date(g[3]*1E3)).toLocaleString()));g.length>=5&&g[4]&&h.append($("<span>").text(", complete on "+(new Date(g[4]*1E3)).toLocaleString()))}else g.length>=4&&g[2]!=
g[3]?h.append($("<span>").text(g[2])).append($("<span>").html("&#187").addClass("unit").css("margin","0 0.5em")).append($("<span>").text(g[3])):h.append($("<span>").text(g[2]));var k=$("<td>").append($("<button>").text(f=="Automatic"?"Remove":"Stop").click(function(){if(confirm("Are you sure you want to "+$(this).text().toLowerCase()+" this push?\n"+g[1]+" to "+g[2])){var a=$(this).closest("tr");a.html($("<td colspan=99>").html($("<span>").addClass("red").text(f=="Automatic"?"Removing..":"Stopping.."))); g[3]?h.append($("<span>").text(g[2])).append($("<span>").html("&#187").addClass("unit").css("margin","0 0.5em")).append($("<span>").text(g[3])):h.append($("<span>").text(g[2]));var j=$("<td>").append($("<button>").text(f=="Automatic"?"Remove":"Stop").click(function(){if(confirm("Are you sure you want to "+$(this).text().toLowerCase()+" this push?\n"+g[1]+" to "+g[2])){var a=$(this).closest("tr");a.html($("<td colspan=99>").html($("<span>").addClass("red").text(f=="Automatic"?"Removing..":"Stopping..")));
if(f=="Automatic"){var c=g.slice(1);mist.send(function(){a.remove()},{push_auto_remove:[c]})}else mist.send(function(){b([g[0]])},{push_stop:[g[0]]})}}));if(f=="Automatic"){k.prepend($("<button>").text("Edit").click(function(){UI.navto("Start Push","auto_"+($(this).closest("tr").index()-1))}));k.append($("<button>").text("Stop pushes").click(function(){if(confirm('Are you sure you want to stop all pushes matching \n"'+g[1]+" to "+g[2]+'"?'+(d.wait!=0?"\n\nRetrying is enabled. You'll probably want to set that to 0.": if(f=="Automatic"){var c=g.slice(1);mist.send(function(){a.remove()},{push_auto_remove:[c]})}else mist.send(function(){b([g[0]])},{push_stop:[g[0]]})}}));if(f=="Automatic"){j.prepend($("<button>").text("Edit").click(function(){UI.navto("Start Push","auto_"+($(this).closest("tr").index()-1))}));j.append($("<button>").text("Stop pushes").click(function(){if(confirm('Are you sure you want to stop all pushes matching \n"'+g[1]+" to "+g[2]+'"?'+(d.wait!=0?"\n\nRetrying is enabled. You'll probably want to set that to 0.":
""))){var c=$(this);c.text("Stopping pushes..");var f=[],h;for(h in a.push_list)if(g[1]==a.push_list[h][1]&&g[2]==a.push_list[h][2]){f.push(a.push_list[h][0]);e.find("tr[data-pushid="+a.push_list[h][0]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}mist.send(function(){c.text("Stop pushes");b(f)},{push_stop:f,push_settings:{wait:0}})}}))}else{if(g.length>=6){var j=g[5];i.append($("<div>").append("Active for: "+UI.format.duration(j.active_seconds))).append($("<div>").append("Data transfered: "+ ""))){var c=$(this);c.text("Stopping pushes..");var f=[],h;for(h in a.push_list)if(g[1]==a.push_list[h][1]&&g[2]==a.push_list[h][2]){f.push(a.push_list[h][0]);e.find("tr[data-pushid="+a.push_list[h][0]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}mist.send(function(){c.text("Stop pushes");b(f)},{push_stop:f,push_settings:{wait:0}})}}))}else{if(g.length>=6){var k=g[5];i.append($("<div>").append("Active for: "+UI.format.duration(k.active_seconds))).append($("<div>").append("Data transfered: "+
UI.format.bytes(j.bytes))).append($("<div>").append("Media time transfered: "+UI.format.duration(j.mediatime*0.001)));"pkt_retrans_count"in j&&i.append($("<div>").append("Packets retransmitted: "+UI.format.number(j.pkt_retrans_count||0)));"pkt_loss_count"in j&&i.append($("<div>").append("Packets lost: "+UI.format.number(j.pkt_loss_count||0)+" ("+UI.format.addUnit(UI.format.number(j.pkt_loss_perc||0),"%")+" over the last "+UI.format.addUnit(5,"s")+")"))}if(g.length>=5)for(var m in g[4]){j=g[4][m]; UI.format.bytes(k.bytes))).append($("<div>").append("Media time transfered: "+UI.format.duration(k.mediatime*0.001)));"pkt_retrans_count"in k&&i.append($("<div>").append("Packets retransmitted: "+UI.format.number(k.pkt_retrans_count||0)));"pkt_loss_count"in k&&i.append($("<div>").append("Packets lost: "+UI.format.number(k.pkt_loss_count||0)+" ("+UI.format.addUnit(UI.format.number(k.pkt_loss_perc||0),"%")+" over the last "+UI.format.addUnit(5,"s")+")"))}if(g.length>=5)for(var m in g[4]){k=g[4][m];
i.append($("<div>").append(UI.format.time(j[0])+" ["+j[1]+"] "+j[2]))}}return $("<tr>").css("vertical-align","top").attr("data-pushid",g[0]).append($("<td>").text(g[1])).append($("<td>").append(h.children())).append($("<td>").addClass("logs").append(i.children())).append(k)}I.html(UI.buildUI([{type:"help",help:"You can push streams to files or other servers, allowing them to broadcast your stream as well."}]));var d=a.push_settings;d||(d={});var e=$("<table>").append($("<tr>").append($("<th>").text("Stream")).append($("<th>").text("Target")).append($("<th>")).append($("<th>"))), i.append($("<div>").append(UI.format.time(k[0])+" ["+k[1]+"] "+k[2]))}}return $("<tr>").css("vertical-align","top").attr("data-pushid",g[0]).append($("<td>").text(g[1])).append($("<td>").append(h.children())).append($("<td>").addClass("logs").append(i.children())).append(j)}I.html(UI.buildUI([{type:"help",help:"You can push streams to files or other servers, allowing them to broadcast your stream as well."}]));var d=a.push_settings;d||(d={});var e=$("<table>").append($("<tr>").append($("<th>").text("Stream")).append($("<th>").text("Target")).append($("<th>")).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){var h=a.push_auto_list[f].slice();h.unshift(-1);g.append(c(h,"Automatic"))}I.append($("<h3>").text("Automatic pushes")).append(UI.buildUI([{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}, 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){var h=a.push_auto_list[f].slice();h.unshift(-1);g.append(c(h,"Automatic"))}I.append($("<h3>").text("Automatic pushes")).append(UI.buildUI([{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})}}]}])).append($("<button>").text("Add an automatic push").click(function(){UI.navto("Start Push","auto")}));g.find("tr").length==1?I.append($("<div>").text("No automatic pushes have been configured.").addClass("text").css("margin-top", {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})}}]}])).append($("<button>").text("Add an automatic push").click(function(){UI.navto("Start Push","auto")}));g.find("tr").length==1?I.append($("<div>").text("No automatic pushes have been configured.").addClass("text").css("margin-top",
"0.5em")):I.append(g);I.append($("<h3>").text("Pushes")).append($("<button>").text("Start a push").click(function(){UI.navto("Start Push")}));if(e.find("tr").length==1)I.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("")),k=$("<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])== "0.5em")):I.append(g);I.append($("<h3>").text("Pushes")).append($("<button>").text("Start a push").click(function(){UI.navto("Start Push")}));if(e.find("tr").length==1)I.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)k.append($("<option>").text(h[f]));I.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.."))); -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]));I.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(k).append($("<button>").css("margin-left","0.5em").text("Apply").click(function(){var c=i.val(),d=k.val();if(c==""&&d=="")return alert("Looks like you want to stop all pushes. Maybe you should use that button?");var g={},f;for(f in a.push_list)if((c==""|| $(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 g={},f;for(f in a.push_list)if((c==""||
a.push_list[f][1]==c)&&(d==""||a.push_list[f][2]==d))g[a.push_list[f][0]]=a.push_list[f];if(Object.keys(g).length==0)return alert("No matching pushes.");c="Are you sure you want to stop these pushes?\n\n";for(f in g)c=c+(g[f][1]+" to "+g[f][2]+"\n");if(confirm(c)){g=Object.keys(g);mist.send(function(){b(g)},{push_stop:g});for(f in g)e.find("tr[data-pushid="+g[f]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}}))).append(e)}UI.interval.set(function(){mist.send(function(a){var b= a.push_list[f][1]==c)&&(d==""||a.push_list[f][2]==d))g[a.push_list[f][0]]=a.push_list[f];if(Object.keys(g).length==0)return alert("No matching pushes.");c="Are you sure you want to stop these pushes?\n\n";for(f in g)c=c+(g[f][1]+" to "+g[f][2]+"\n");if(confirm(c)){g=Object.keys(g);mist.send(function(){b(g)},{push_stop:g});for(f in g)e.find("tr[data-pushid="+g[f]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}}))).append(e)}UI.interval.set(function(){mist.send(function(a){var b=
e.find("tr").first();e.empty();e.append(b);for(var d in a.push_list)e.append(c(a.push_list[d]))},{push_list:1})},5E3)},{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});return}var w,ha=function(a){var d=false,g=b.split("_");b=g[0];g.length==2&&(d=g[1]);if(d!==false&&typeof a=="undefined")mist.send(function(a){ha(a.push_auto_list[d])},{push_auto_list:1}); e.find("tr").first();e.empty();e.append(b);for(var d in a.push_list)e.append(c(a.push_list[d]))},{push_list:1})},5E3)},{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});return}var x,ha=function(a){var d=false,g=b.split("_");b=g[0];g.length==2&&(d=g[1]);if(d!==false&&typeof a=="undefined")mist.send(function(a){ha(a.push_auto_list[d])},{push_auto_list:1});
else{var e=[],f={},h;for(h in mist.data.capabilities.connectors){g=mist.data.capabilities.connectors[h];if("push_urls"in g){e=e.concat(g.push_urls);f[h]=g.push_urls}}b=="auto"&&c.find("h2").text("Add automatic push");var i={params:{}};if(b=="auto"&&typeof a!="undefined"){i={stream:a[0],target:a[1],params:{}};g=i.target.split("?");if(g.length>1){params=g.pop();i.target=g.join("?");params=params.split("&");for(h in params){g=params[h].split("=");i.params[g.shift()]=g.join("=")}}}var j=$("<div>").css("margin", else{var e=[],f={},h;for(h in mist.data.capabilities.connectors){g=mist.data.capabilities.connectors[h];if("push_urls"in g){e=e.concat(g.push_urls);f[h]=g.push_urls}}b=="auto"&&c.find("h2").text("Add automatic push");var i={params:{}};if(b=="auto"&&typeof a!="undefined"){i={stream:a[0],target:a[1],params:{}};g=i.target.split("?");if(g.length>1){params=g.pop();i.target=g.join("?");params=params.split("&");for(h in params){g=params[h].split("=");i.params[g.shift()]=g.join("=")}}}var j=$("<div>").css("margin",
"1em 0");h=[{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>", "1em 0");h=[{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:i,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:["orange"],"break":false}}],datalist:w,LTSonly:1},{label:"Target",type:"str",help:"Where the stream will be pushed to.<br> Valid formats: <ul> <li>"+e.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> </ul> Valid URL parameters: <ul> <li>recstart=123 - media timestamp in milisseconds where the push should start</li> <li>recstop=456 - media timestamp in miliseconds where the push should stop</li> <li>recstartunix=150000000 - unix time in seconds where the push should start. This will override the recstart parameter.</li> <li>recstopunix=150000000 - unix time in seconds where the push should stop. This will override the recstop parameter.</li> </ul>", pointer:{main:i,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:["orange"],"break":false}}],datalist:x,LTSonly:1},{label:"Target",type:"str",help:"Where the stream will be pushed to.<br> Valid formats: <ul> <li>"+e.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> </ul> Valid URL parameters: <ul> <li>recstart=123 - media timestamp in milisseconds where the push should start</li> <li>recstop=456 - media timestamp in miliseconds where the push should stop</li> <li>recstartunix=150000000 - unix time in seconds where the push should start. This will override the recstart parameter.</li> <li>recstopunix=150000000 - unix time in seconds where the push should stop. This will override the recstop parameter.</li> </ul>",
pointer:{main:i,index:"target"},validate:["required",function(a){for(var b in e)if(mist.inputMatch(e[b],a))return false;return{msg:"Does not match a valid target.<br>Valid formats:<ul><li>"+e.join("</li><li>")+"</li></ul>",classes:["red"]}}],"function":function(){var a=false;for(connector in f)for(var b in f[connector])if(mist.inputMatch(f[connector][b],$(this).getval())){a=connector;break}if(a){j.html($("<h3>").text(mist.data.capabilities.connectors[a].friendly));j.append(UI.buildUI(mist.convertBuildOptions({desc:mist.data.capabilities.connectors[a].desc, pointer:{main:i,index:"target"},validate:["required",function(a){for(var b in e)if(mist.inputMatch(e[b],a))return false;return{msg:"Does not match a valid target.<br>Valid formats:<ul><li>"+e.join("</li><li>")+"</li></ul>",classes:["red"]}}],"function":function(){var a=false;for(connector in f)for(var b in f[connector])if(mist.inputMatch(f[connector][b],$(this).getval())){a=connector;break}if(a){j.html($("<h3>").text(mist.data.capabilities.connectors[a].friendly));j.append(UI.buildUI(mist.convertBuildOptions({desc:mist.data.capabilities.connectors[a].desc,
optional:mist.data.capabilities.connectors[a].push_parameters},i.params)))}else j.html($("<h4>").addClass("red").text("Unrecognized target.")).append($("<span>").text("Please edit the push target."))},LTSonly:1},j];h.push({type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Push")}},{type:"save",label:"Save","function":function(){var c=i.params,d;for(d in c)c[d]===null&&delete c[d];if(Object.keys(c).length){var g="?",e=i.target.split("?");if(e.length>1){g="&";e=e[e.length- optional:mist.data.capabilities.connectors[a].push_parameters},i.params)))}else j.html($("<h4>").addClass("red").text("Unrecognized target.")).append($("<span>").text("Please edit the push target."))},LTSonly:1},j];h.push({type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Push")}},{type:"save",label:"Save","function":function(){var c=i.params,d;for(d in c)c[d]===null&&delete c[d];if(Object.keys(c).length){var g="?",e=i.target.split("?");if(e.length>1){g="&";e=e[e.length-
1];e=e.split("&");for(d in e){var f=e[d].split("=")[0];f in c&&delete c[f]}}if(Object.keys(c).length){e=[];for(d in c)e.push(d+"="+c[d]);g=g+e.join("&");i.target=i.target+g}}c={};c[b=="auto"?"push_auto_add":"push_start"]=i;if(typeof a!="undefined"&&(a[0]!=i.stream||a[1]!=i.target))c.push_auto_remove=[a];mist.send(function(){UI.navto("Push")},c)}}]});c.append(UI.buildUI(h))}};mist.data.LTS?mist.send(function(a){(w=a.active_streams)||(w=[]);var a=[],b;for(b in w)w[b].indexOf("+")!=-1&&a.push(w[b].replace(/\+.*/, 1];e=e.split("&");for(d in e){var f=e[d].split("=")[0];f in c&&delete c[f]}}if(Object.keys(c).length){e=[];for(d in c)e.push(d+"="+c[d]);g=g+e.join("&");i.target=i.target+g}}c={};c[b=="auto"?"push_auto_add":"push_start"]=i;if(typeof a!="undefined"&&(a[0]!=i.stream||a[1]!=i.target))c.push_auto_remove=[a];mist.send(function(){UI.navto("Push")},c)}}]});c.append(UI.buildUI(h))}};mist.data.LTS?mist.send(function(a){(x=a.active_streams)||(x=[]);var a=[],b;for(b in x)x[b].indexOf("+")!=-1&&a.push(x[b].replace(/\+.*/,
"")+"+");w=w.concat(a);var c=0,d=0;for(b in mist.data.streams){w.push(b);if(mist.inputMatch(UI.findInput("Folder").source_match,mist.data.streams[b].source)){w.push(b+"+");mist.send(function(a,b){var g=b.stream,e;for(e in a.browse.files)for(var f in mist.data.capabilities.inputs)f.indexOf("Buffer")>=0||(f.indexOf("Folder")>=0||f.indexOf("Buffer.exe")>=0||f.indexOf("Folder.exe")>=0)||mist.inputMatch(mist.data.capabilities.inputs[f].source_match,"/"+a.browse.files[e])&&w.push(g+"+"+a.browse.files[e]); "")+"+");x=x.concat(a);var c=0,d=0;for(b in mist.data.streams){x.push(b);if(mist.inputMatch(UI.findInput("Folder").source_match,mist.data.streams[b].source)){x.push(b+"+");mist.send(function(a,b){var g=b.stream,e;for(e in a.browse.files)for(var f in mist.data.capabilities.inputs)f.indexOf("Buffer")>=0||(f.indexOf("Folder")>=0||f.indexOf("Buffer.exe")>=0||f.indexOf("Folder.exe")>=0)||mist.inputMatch(mist.data.capabilities.inputs[f].source_match,"/"+a.browse.files[e])&&x.push(g+"+"+a.browse.files[e]);
d++;if(c==d){w=w.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();ha()}},{browse:mist.data.streams[b].source},{stream:b});c++}}if(c==d){w=w.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();ha()}},{active_streams:1}):(w=Object.keys(mist.data.streams),ha());break;case "Triggers":if(!("triggers"in mist.data.config)||!mist.data.config.triggers)mist.data.config.triggers={};var C=$("<tbody>"),Sa=$("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Trigger on").attr("data-sort-type", d++;if(c==d){x=x.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();ha()}},{browse:mist.data.streams[b].source},{stream:b});c++}}if(c==d){x=x.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();ha()}},{active_streams:1}):(x=Object.keys(mist.data.streams),ha());break;case "Triggers":if(!("triggers"in mist.data.config)||!mist.data.config.triggers)mist.data.config.triggers={};var C=$("<tbody>"),Ua=$("<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(C);c.append(UI.buildUI([{type:"help",help:"Triggers are a way 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(Sa); "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(C);c.append(UI.buildUI([{type:"help",help:"Triggers are a way 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(Ua);
Sa.stupidtable();var ra=mist.data.config.triggers;for(r in ra)for(var Ta in ra[r]){var sa=triggerRewrite(ra[r][Ta]);C.append($("<tr>").attr("data-index",r+","+Ta).append($("<td>").text(r)).append($("<td>").text("streams"in sa?sa.streams.join(", "):"")).append($("<td>").text(sa.handler)).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(","); Ua.stupidtable();var sa=mist.data.config.triggers;for(s in sa)for(var Va in sa[s]){var ta=triggerRewrite(sa[s][Va]);C.append($("<tr>").attr("data-index",s+","+Va).append($("<td>").text(s)).append($("<td>").text("streams"in ta?ta.streams.join(", "):"")).append($("<td>").text(ta.handler)).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":if(!("triggers"in mist.data.config)||!mist.data.config.triggers)mist.data.config.triggers={};if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});c.append("Loading.."); 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":if(!("triggers"in mist.data.config)||!mist.data.config.triggers)mist.data.config.triggers={};if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});c.append("Loading..");
return}if(b)var b=b.split(","),aa=triggerRewrite(mist.data.config.triggers[b[0]][b[1]]),o={triggeron:b[0],appliesto:aa.streams,url:aa.handler,async:aa.sync,"default":aa["default"],params:aa.params};else c.html($("<h2>").text("New Trigger")),o={};var Ua=[];for(r in mist.data.capabilities.triggers)Ua.push([r,r+": "+mist.data.capabilities.triggers[r].when]);var ta=$("<div>").addClass("desc"),Va=$("<div>");c.append(UI.buildUI([{label:"Trigger on",pointer:{main:o,index:"triggeron"},help:"For what event this trigger should activate.", return}if(b)var b=b.split(","),aa=triggerRewrite(mist.data.config.triggers[b[0]][b[1]]),o={triggeron:b[0],appliesto:aa.streams,url:aa.handler,async:aa.sync,"default":aa["default"],params:aa.params};else c.html($("<h2>").text("New Trigger")),o={};var Wa=[];for(s in mist.data.capabilities.triggers)Wa.push([s,s+": "+mist.data.capabilities.triggers[s].when]);var ua=$("<div>").addClass("desc"),Xa=$("<div>");c.append(UI.buildUI([{label:"Trigger on",pointer:{main:o,index:"triggeron"},help:"For what event this trigger should activate.",
type:"select",select:Ua,LTSonly:!0,validate:["required"],"function":function(){var a=$(this).getval(),b=mist.data.capabilities.triggers[a];ta.html("");if(b){a=[$("<h4>").text("Trigger properties"),{type:"help",help:'The trigger "<i>'+a+'</i>" has the following properties:'},{type:"span",label:"Triggers",value:b.when,help:"When this trigger is activated"}];b.payload!=""&&a.push({label:"Payload",type:"textarea",value:b.payload,rows:b.payload.split("\n").length,readonly:true,clipboard:true,help:"The information this trigger sends to the handler."}); type:"select",select:Wa,LTSonly:!0,validate:["required"],"function":function(){var a=$(this).getval(),b=mist.data.capabilities.triggers[a];ua.html("");if(b){a=[$("<h4>").text("Trigger properties"),{type:"help",help:'The trigger "<i>'+a+'</i>" has the following properties:'},{type:"span",label:"Triggers",value:b.when,help:"When this trigger is activated"}];b.payload!=""&&a.push({label:"Payload",type:"textarea",value:b.payload,rows:b.payload.split("\n").length,readonly:true,clipboard:true,help:"The information this trigger sends to the handler."});
a.push({type:"span",label:"Requires response",value:function(a){switch(a){case "ignored":return"No. The trigger will ignore the response of the handler.";case "always":return"Yes. The trigger needs a response to proceed.";case "when-blocking":return"The trigger needs a response to proceed if it is configured to be blocking.";default:return a}}(b.response),help:"Whether this trigger requires a response from the trigger handler"});a.push({type:"span",label:"Response action",value:b.response_action, a.push({type:"span",label:"Requires response",value:function(a){switch(a){case "ignored":return"No. The trigger will ignore the response of the handler.";case "always":return"Yes. The trigger needs a response to proceed.";case "when-blocking":return"The trigger needs a response to proceed if it is configured to be blocking.";default:return a}}(b.response),help:"Whether this trigger requires a response from the trigger handler"});a.push({type:"span",label:"Response action",value:b.response_action,
help:"What this trigger will do with its handler's response"});ta.append(UI.buildUI(a));b.stream_specific?$("[name=appliesto]").closest(".UIelement").show():$("[name=appliesto]").setval([]).closest(".UIelement").hide();if(b.argument){$("[name=params]").closest(".UIelement").show();Va.text(b.argument)}else $("[name=params]").setval("").closest(".UIelement").hide()}}},ta,$("<h4>").text("Trigger settings"),{label:"Applies to",pointer:{main:o,index:"appliesto"},help:"For triggers that can apply to specific streams, this value decides what streams they are triggered for. (none checked = always triggered)", help:"What this trigger will do with its handler's response"});ua.append(UI.buildUI(a));b.stream_specific?$("[name=appliesto]").closest(".UIelement").show():$("[name=appliesto]").setval([]).closest(".UIelement").hide();if(b.argument){$("[name=params]").closest(".UIelement").show();Xa.text(b.argument)}else $("[name=params]").setval("").closest(".UIelement").hide()}}},ua,$("<h4>").text("Trigger settings"),{label:"Applies to",pointer:{main:o,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:o,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.", 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:o,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:o,index:"async"},LTSonly:!0},{label:"Parameters",type:"str",help:$("<div>").text("The extra data you want this trigger to use.").append(Va),pointer:{main:o,index:"params"},LTSonly:!0},{label:"Default response",type:"str",help:"The default response in case the handler fails or is set to non-blocking.",placeholder:"true",pointer:{main:o,index:"default"},LTSonly:!0},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Triggers")}},{type:"save",label:"Save", pointer:{main:o,index:"async"},LTSonly:!0},{label:"Parameters",type:"str",help:$("<div>").text("The extra data you want this trigger to use.").append(Xa),pointer:{main:o,index:"params"},LTSonly:!0},{label:"Default response",type:"str",help:"The default response in case the handler fails or is set to non-blocking.",placeholder:"true",pointer:{main:o,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={handler:o.url,sync:o.async?true:false,streams:typeof o.appliesto=="undefined"?[]:o.appliesto,params:o.params,"default":o["default"]};if(!("triggers"in mist.data.config))mist.data.config.triggers={};o.triggeron in mist.data.config.triggers||(mist.data.config.triggers[o.triggeron]=[]);mist.data.config.triggers[o.triggeron].push(a);mist.send(function(){UI.navto("Triggers")},{config:mist.data.config})}}]}]));$("[name=triggeron]").trigger("change"); "function":function(){b&&mist.data.config.triggers[b[0]].splice(b[1],1);var a={handler:o.url,sync:o.async?true:false,streams:typeof o.appliesto=="undefined"?[]:o.appliesto,params:o.params,"default":o["default"]};if(!("triggers"in mist.data.config))mist.data.config.triggers={};o.triggeron in mist.data.config.triggers||(mist.data.config.triggers[o.triggeron]=[]);mist.data.config.triggers[o.triggeron].push(a);mist.send(function(){UI.navto("Triggers")},{config:mist.data.config})}}]}]));$("[name=triggeron]").trigger("change");
break;case "Logs":var Wa=$("<button>").text("Refresh now").click(function(){$(this).text("Loading..");mist.send(function(){ua();Wa.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, break;case "Logs":var Ya=$("<button>").text("Refresh now").click(function(){$(this).text("Loading..");mist.send(function(){va();Ya.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(){ua()})},$(this).val()*1E3)},help:"How often the table below should be updated."},{label:"..or",type:"DOMfield",DOMfield:Wa,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})}));C=$("<tbody>").css("font-size","0.9em");c.append($("<table>").addClass("logs").append(C)); "minute"],[300,"5 minutes"]],value:30,"function":function(){UI.interval.clear();UI.interval.set(function(){mist.send(function(){va()})},$(this).val()*1E3)},help:"How often the table below should be updated."},{label:"..or",type:"DOMfield",DOMfield:Ya,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})}));C=$("<tbody>").css("font-size","0.9em");c.append($("<table>").addClass("logs").append(C));
var $a=function(a){var b=$("<span>").text(a);switch(a){case "WARN":b.addClass("orange");break;case "ERROR":case "FAIL":b.addClass("red")}return b},ua=function(){var a=mist.data.log;if(a){a.length>=2&&a[0][0]<a[a.length-1][0]&&a.reverse();C.html("");for(var b in a){var c=$("<span>").addClass("content"),d=a[b][2].split("|"),g;for(g in d)c.append($("<span>").text(d[g]));C.append($("<tr>").html($("<td>").text(UI.format.dateTime(a[b][0],"long")).css("white-space","nowrap")).append($("<td>").html($a(a[b][1])).css("text-align", var bb=function(a){var b=$("<span>").text(a);switch(a){case "WARN":b.addClass("orange");break;case "ERROR":case "FAIL":b.addClass("red")}return b},va=function(){var a=mist.data.log;if(a){a.length>=2&&a[0][0]<a[a.length-1][0]&&a.reverse();C.html("");for(var b in a){var c=$("<span>").addClass("content"),d=a[b][2].split("|"),g;for(g in d)c.append($("<span>").text(d[g]));C.append($("<tr>").html($("<td>").text(UI.format.dateTime(a[b][0],"long")).css("white-space","nowrap")).append($("<td>").html(bb(a[b][1])).css("text-align",
"center")).append($("<td>").html(c).css("text-align","left")))}}};ua();break;case "Statistics":var D=$("<span>").text("Loading..");c.append(D);var o={graph:"new"},y=mist.stored.get().graphs?$.extend(!0,{},mist.stored.get().graphs):{},ba={};for(r in mist.data.streams)ba[r]=!0;for(r in mist.data.active_streams)ba[mist.data.active_streams[r]]=!0;var ba=Object.keys(ba).sort(),va=[];for(r in mist.data.config.protocols)va.push(mist.data.config.protocols[r].connector);va.sort();mist.send(function(){UI.plot.datatype.templates.cpuload.cores= "center")).append($("<td>").html(c).css("text-align","left")))}}};va();break;case "Statistics":var D=$("<span>").text("Loading..");c.append(D);var o={graph:"new"},z=mist.stored.get().graphs?$.extend(!0,{},mist.stored.get().graphs):{},ba={};for(s in mist.data.streams)ba[s]=!0;for(s in mist.data.active_streams)ba[mist.data.active_streams[s]]=!0;var ba=Object.keys(ba).sort(),wa=[];for(s in mist.data.config.protocols)wa.push(mist.data.config.protocols[s].connector);wa.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;D.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:o,index:"graph"},classes:["graph_ids"], 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;D.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:o,index:"graph"},classes:["graph_ids"],
"function":function(){if($(this).val()){var a=D.find(".graph_xaxis"),b=D.find(".graph_id");if($(this).val()=="new"){a.children("option").prop("disabled",false);b.setval("Graph "+(Object.keys(y).length+1)).closest("label").show()}else{var c=y[$(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")}}}, "function":function(){if($(this).val()){var a=D.find(".graph_xaxis"),b=D.find(".graph_id");if($(this).val()=="new"){a.children("option").prop("disabled",false);b.setval("Graph "+(Object.keys(z).length+1)).closest("label").show()}else{var c=z[$(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:o,index:"id"},classes:["graph_id"],validate:[function(a){return a in y?{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:o,index:"xaxis"},value:"time",classes:["graph_xaxis"],"function":function(){$s=D.find(".graph_datatype");switch($(this).getval()){case "coords":$s.children("option").prop("disabled",true).filter('[value="coords"]').prop("disabled", {label:"Graph id",type:"str",pointer:{main:o,index:"id"},classes:["graph_id"],validate:[function(a){return a in z?{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:o,index:"xaxis"},value:"time",classes:["graph_xaxis"],"function":function(){$s=D.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"],["perc_lost","Lost packages"], 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"],["perc_lost","Lost packages"],
["perc_retrans","Re-transmitted packages"]],pointer:{main:o,index:"datatype"},classes:["graph_datatype"],"function":function(){$s=D.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:", ["perc_retrans","Re-transmitted packages"]],pointer:{main:o,index:"datatype"},classes:["graph_datatype"],"function":function(){$s=D.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:",
ba],["protocol","The protocol:",va]],pointer:{main:o,index:"origin"},value:["total"],classes:["graph_origin"]},{type:"buttons",buttons:[{label:"Add data set",type:"save","function":function(){var a;if(o.graph=="new"){a=UI.plot.addGraph(o,b);y[a.id]=a;D.find("input.graph_id").val("");D.find("select.graph_ids").append($("<option>").text(a.id)).val(a.id).trigger("change")}else a=y[o.graph];var c=UI.plot.datatype.getOptions({datatype:o.datatype,origin:o.origin});a.datasets.push(c);UI.plot.save(a);UI.plot.go(y)}}]}])); ba],["protocol","The protocol:",wa]],pointer:{main:o,index:"origin"},value:["total"],classes:["graph_origin"]},{type:"buttons",buttons:[{label:"Add data set",type:"save","function":function(){var a;if(o.graph=="new"){a=UI.plot.addGraph(o,b);z[a.id]=a;D.find("input.graph_id").val("");D.find("select.graph_ids").append($("<option>").text(a.id)).val(a.id).trigger("change")}else a=z[o.graph];var c=UI.plot.datatype.getOptions({datatype:o.datatype,origin:o.origin});a.datasets.push(c);UI.plot.save(a);UI.plot.go(z)}}]}]));
var b=$("<div>").addClass("graph_container");c.append(b);var d=D.find("select.graph_ids");for(a in y){var g=UI.plot.addGraph(y[a],b);d.append($("<option>").text(g.id)).val(g.id);var e=[],f;for(f in y[a].datasets){var h=UI.plot.datatype.getOptions({datatype:y[a].datasets[f].datatype,origin:y[a].datasets[f].origin});e.push(h)}g.datasets=e;y[g.id]=g}d.trigger("change");UI.plot.go(y);UI.interval.set(function(){UI.plot.go(y)},1E4)},{active_streams:!0,capabilities:!0});break;case "Server Stats":if("undefined"== var b=$("<div>").addClass("graph_container");c.append(b);var d=D.find("select.graph_ids");for(a in z){var g=UI.plot.addGraph(z[a],b);d.append($("<option>").text(g.id)).val(g.id);var e=[],f;for(f in z[a].datasets){var h=UI.plot.datatype.getOptions({datatype:z[a].datasets[f].datatype,origin:z[a].datasets[f].origin});e.push(h)}g.datasets=e;z[g.id]=g}d.trigger("change");UI.plot.go(z);UI.interval.set(function(){UI.plot.go(z)},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..");return}var wa=$("<table>"),L=$("<table>"),Xa={vheader:"CPUs",labels:["Model","Processor speed","Amount of cores","Amount of threads"],content:[]};for(r in mist.data.capabilities.cpu){var ia=mist.data.capabilities.cpu[r];Xa.content.push({header:"CPU #"+(Number(r)+1),body:[ia.model,UI.format.addUnit(UI.format.number(ia.mhz),"MHz"),ia.cores,ia.threads]})}var ab=UI.buildVheaderTable(Xa),Ya=function(){var a= typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});c.append("Loading..");return}var xa=$("<table>"),L=$("<table>"),Za={vheader:"CPUs",labels:["Model","Processor speed","Amount of cores","Amount of threads"],content:[]};for(s in mist.data.capabilities.cpu){var ia=mist.data.capabilities.cpu[s];Za.content.push({header:"CPU #"+(Number(s)+1),body:[ia.model,UI.format.addUnit(UI.format.number(ia.mhz),"MHz"),ia.cores,ia.threads]})}var cb=UI.buildVheaderTable(Za),$a=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* 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);wa.replaceWith(a);wa=a;b={vheader:"Load average",labels:["CPU use","1 minute","5 minutes","15 minutes"],content:[{header:"&nbsp;",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);L.replaceWith(b);L=b};Ya();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", 1048576)]}]},a=UI.buildVheaderTable(a);xa.replaceWith(a);xa=a;b={vheader:"Load average",labels:["CPU use","1 minute","5 minutes","15 minutes"],content:[{header:"&nbsp;",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);L.replaceWith(b);L=b};$a();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(wa)).append($("<td>").append(L))).append($("<tr>").append($("<td>").append(ab).attr("colspan",2))));UI.interval.set(function(){mist.send(function(){Ya()},{capabilities:true})},3E4);break;case "Email for Help":var E=$.extend({},mist.data);delete E.statistics;delete E.totals;delete E.clients;delete E.capabilities;E=JSON.stringify(E);E="Version: "+mist.data.config.version+"\n\nConfig:\n"+E;o={};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."}, "auto").addClass("nolay").append($("<tr>").append($("<td>").append(xa)).append($("<td>").append(L))).append($("<tr>").append($("<td>").append(cb).attr("colspan",2))));UI.interval.set(function(){mist.send(function(){$a()},{capabilities:true})},3E4);break;case "Email for Help":var E=$.extend({},mist.data);delete E.statistics;delete E.totals;delete E.clients;delete E.capabilities;E=JSON.stringify(E);E="Version: "+mist.data.config.version+"\n\nConfig:\n"+E;o={};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:o,index:"name"},value:mist.user.name},{type:"email",label:"Your email address",validate:["required"],pointer:{main:o,index:"email"}},{type:"hidden",value:"Integrated Help",pointer:{main:o,index:"subject"}},{type:"hidden",value:"-",pointer:{main:o,index:"company"}},{type:"textarea",rows:20,label:"Your message",validate:["required"],pointer:{main:o,index:"message"}},{type:"textarea",rows:20,label:"Your config file",readonly:!0,value:E, {type:"str",label:"Your name",validate:["required"],pointer:{main:o,index:"name"},value:mist.user.name},{type:"email",label:"Your email address",validate:["required"],pointer:{main:o,index:"email"}},{type:"hidden",value:"Integrated Help",pointer:{main:o,index:"subject"}},{type:"hidden",value:"-",pointer:{main:o,index:"company"}},{type:"textarea",rows:20,label:"Your message",validate:["required"],pointer:{main:o,index:"message"}},{type:"textarea",rows:20,label:"Your config file",readonly:!0,value:E,
pointer:{main:o,index:"configfile"}},{type:"buttons",buttons:[{type:"save",label:"Send","function":function(a){$(a).text("Sending..");$.ajax({type:"POST",url:"https://mistserver.org/contact?skin=plain",data:o,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."))}c.find(".field").filter(function(){var a= pointer:{main:o,index:"configfile"}},{type:"buttons",buttons:[{type:"save",label:"Send","function":function(a){$(a).text("Sending..");$.ajax({type:"POST",url:"https://mistserver.org/contact?skin=plain",data:o,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."))}c.find(".field").filter(function(){var a=
$(this).getval();return a==""||a==null?true:false}).each(function(){var a=[];$(this).is("input, select, textarea")?a.push($(this)):a=$(this).find("input, select, textarea");if(a.length){$(a[0]).focus();return false}})}};"origin"in location||(location.origin=location.protocol+"//");var host;host="file://"==location.origin?"http://localhost:4242/api":location.origin+location.pathname.replace(/\/+$/,"")+"/api"; $(this).getval();return a==""||a==null?true:false}).each(function(){var a=[];$(this).is("input, select, textarea")?a.push($(this)):a=$(this).find("input, select, textarea");if(a.length){$(a[0]).focus();return false}})}};"origin"in location||(location.origin=location.protocol+"//");var host;host="file://"==location.origin?"http://localhost:4242/api":location.origin+location.pathname.replace(/\/+$/,"")+"/api";

View file

@ -4224,6 +4224,8 @@ var UI = {
); );
var $tracktable = $('<span>').text('Loading..'); var $tracktable = $('<span>').text('Loading..');
$trackinfo.append($tracktable); $trackinfo.append($tracktable);
var $processinfo = $("<div>").addClass("process_info");
$trackinfo.append($processinfo);
$cont.append($trackinfo); $cont.append($trackinfo);
function buildTrackinfo(info) { function buildTrackinfo(info) {
var meta = info.meta; var meta = info.meta;
@ -4372,6 +4374,101 @@ var UI = {
$tracktable.html('Error while retrieving stream info.'); $tracktable.html('Error while retrieving stream info.');
} }
}); });
function updateProcessInfo() {
var req = {proc_list: other};
if (!mist.data.capabilities) { req.capabilities = true; }
mist.send(function(data){
if (data.proc_list) {
var $processes = $("<table>").css("width","auto");
var layout = {
"Process type:": function(d){ return $("<b>").text(d.process); },
"Source:": function(d){
var $s = $("<span>").text(d.source);
if (d.source_tracks && d.source_tracks.length) {
$s.append(
$("<span>").addClass("description").text(" track "+(d.source_tracks.slice(0,-2).concat(d.source_tracks.slice(-2).join(" and "))).join(", "))
);
}
return $s;
},
"Sink:": function(d){
var $s = $("<span>").text(d.sink);
if (d.sink_tracks && d.sink_tracks.length) {
$s.append(
$("<span>").addClass("description").text(" track "+(d.sink_tracks.slice(0,-2).concat(d.sink_tracks.slice(-2).join(" and "))).join(", "))
);
}
return $s;
},
"Active for:": function(d){
var since = new Date().setSeconds(new Date().getSeconds() - d.active_seconds);
return $("<span>").append(
$("<span>").text(UI.format.duration(d.active_seconds))
).append(
$("<span>").addClass("description").text(" since "+UI.format.time(since/1e3))
);
},
"Pid:": function(d,i){ return i; },
"Logs:": function(d){
var $logs = $("<div>").text("None.");
if (d.logs && d.logs.length) {
$logs.html("").addClass("description").css({overflow: "auto", maxHeight: "6em", display: "flex", flexFlow: "column-reverse nowrap"});
for (var i in d.logs) {
var item = d.logs[i];
$logs.prepend(
$("<div>").append(
UI.format.time(item[0])+' ['+item[1]+'] '+item[2]
)
);
}
}
return $logs;
},
"Additional info:": function(d){
var $t;
if (d.ainfo && Object.keys(d.ainfo).length) {
$t = $("<table>");
for (var i in d.ainfo) {
var legend = mist.data.capabilities.processes[d.process].ainfo[i];
if (!legend) {
legend = {
name: i
};
}
$t.append(
$("<tr>").append(
$("<th>").text(legend.name+":")
).append(
$("<td>").html(d.ainfo[i]).append(legend.unit ? $("<span>").addClass("unit").text(legend.unit) : "")
)
);
}
}
else { $t = $("<span>").addClass("description").text("N/A"); }
return $t;
}
};
$processinfo.html(
$("<h4>").text("Stream processes")
).append($processes);
for (var i in layout) {
var $tr = $("<tr>");
$processes.append($tr);
$tr.append(
$("<th>").text(i).css("vertical-align","top")
);
for (var j in data.proc_list) {
$out = layout[i](data.proc_list[j],j);
$tr.append($("<td>").html($out).css("vertical-align","top"));
}
}
}
},req);
}
UI.interval.set(function(){
updateProcessInfo();
},5e3);
updateProcessInfo();
} }
break; break;