LSP: unix inputtype, validation warning mode, interface for push scheduling, automatic push edit button

This commit is contained in:
Cat 2017-10-30 13:17:10 +01:00 committed by Thulinma
parent ef8d305f37
commit e8b403400d
2 changed files with 372 additions and 240 deletions

View file

@ -1,11 +1,11 @@
var MD5=function(a){function c(a,c){var b,d,h,g,i;h=a&2147483648;g=c&2147483648;b=a&1073741824;d=c&1073741824;i=(a&1073741823)+(c&1073741823);return b&d?i^2147483648^h^g:b|d?i&1073741824?i^3221225472^h^g:i^1073741824^h^g:i^h^g}function d(a,b,d,h,g,i,f){a=c(a,c(c(b&d|~b&h,g),f));return c(a<<i|a>>>32-i,b)}function b(a,b,d,h,g,i,f){a=c(a,c(c(b&h|d&~h,g),f));return c(a<<i|a>>>32-i,b)}function e(a,b,d,h,g,i,f){a=c(a,c(c(b^d^h,g),f));return c(a<<i|a>>>32-i,b)}function g(a,b,d,h,g,i,f){a=c(a,c(c(d^(b|~h), var MD5=function(a){function c(a,c){var b,d,e,h,i;e=a&2147483648;h=c&2147483648;b=a&1073741824;d=c&1073741824;i=(a&1073741823)+(c&1073741823);return b&d?i^2147483648^e^h:b|d?i&1073741824?i^3221225472^e^h:i^1073741824^e^h:i^e^h}function d(a,b,d,e,h,i,f){a=c(a,c(c(b&d|~b&e,h),f));return c(a<<i|a>>>32-i,b)}function b(a,b,d,e,h,i,f){a=c(a,c(c(b&e|d&~e,h),f));return c(a<<i|a>>>32-i,b)}function g(a,b,d,e,h,i,f){a=c(a,c(c(b^d^e,h),f));return c(a<<i|a>>>32-i,b)}function h(a,b,d,e,h,i,f){a=c(a,c(c(d^(b|~e),
g),f));return c(a<<i|a>>>32-i,b)}function l(a){var c="",b="",d;for(d=0;3>=d;d++)b=a>>>8*d&255,b="0"+b.toString(16),c+=b.substr(b.length-2,2);return c}var f=[],q,p,m,u,h,i,j,k,f=a.replace(/\r\n/g,"\n"),a="";for(q=0;q<f.length;q++)p=f.charCodeAt(q),128>p?a+=String.fromCharCode(p):(127<p&&2048>p?a+=String.fromCharCode(p>>6|192):(a+=String.fromCharCode(p>>12|224),a+=String.fromCharCode(p>>6&63|128)),a+=String.fromCharCode(p&63|128));f=a;a=f.length;q=a+8;p=16*((q-q%64)/64+1);m=Array(p-1);for(h=u=0;h<a;)q= h),f));return c(a<<i|a>>>32-i,b)}function l(a){var c="",b="",d;for(d=0;3>=d;d++)b=a>>>8*d&255,b="0"+b.toString(16),c+=b.substr(b.length-2,2);return c}var f=[],q,p,m,u,e,i,j,k,f=a.replace(/\r\n/g,"\n"),a="";for(q=0;q<f.length;q++)p=f.charCodeAt(q),128>p?a+=String.fromCharCode(p):(127<p&&2048>p?a+=String.fromCharCode(p>>6|192):(a+=String.fromCharCode(p>>12|224),a+=String.fromCharCode(p>>6&63|128)),a+=String.fromCharCode(p&63|128));f=a;a=f.length;q=a+8;p=16*((q-q%64)/64+1);m=Array(p-1);for(e=u=0;e<a;)q=
(h-h%4)/4,u=8*(h%4),m[q]|=f.charCodeAt(h)<<u,h++;q=(h-h%4)/4;m[q]|=128<<8*(h%4);m[p-2]=a<<3;m[p-1]=a>>>29;f=m;h=1732584193;i=4023233417;j=2562383102;k=271733878;for(a=0;a<f.length;a+=16)q=h,p=i,m=j,u=k,h=d(h,i,j,k,f[a+0],7,3614090360),k=d(k,h,i,j,f[a+1],12,3905402710),j=d(j,k,h,i,f[a+2],17,606105819),i=d(i,j,k,h,f[a+3],22,3250441966),h=d(h,i,j,k,f[a+4],7,4118548399),k=d(k,h,i,j,f[a+5],12,1200080426),j=d(j,k,h,i,f[a+6],17,2821735955),i=d(i,j,k,h,f[a+7],22,4249261313),h=d(h,i,j,k,f[a+8],7,1770035416), (e-e%4)/4,u=8*(e%4),m[q]|=f.charCodeAt(e)<<u,e++;q=(e-e%4)/4;m[q]|=128<<8*(e%4);m[p-2]=a<<3;m[p-1]=a>>>29;f=m;e=1732584193;i=4023233417;j=2562383102;k=271733878;for(a=0;a<f.length;a+=16)q=e,p=i,m=j,u=k,e=d(e,i,j,k,f[a+0],7,3614090360),k=d(k,e,i,j,f[a+1],12,3905402710),j=d(j,k,e,i,f[a+2],17,606105819),i=d(i,j,k,e,f[a+3],22,3250441966),e=d(e,i,j,k,f[a+4],7,4118548399),k=d(k,e,i,j,f[a+5],12,1200080426),j=d(j,k,e,i,f[a+6],17,2821735955),i=d(i,j,k,e,f[a+7],22,4249261313),e=d(e,i,j,k,f[a+8],7,1770035416),
k=d(k,h,i,j,f[a+9],12,2336552879),j=d(j,k,h,i,f[a+10],17,4294925233),i=d(i,j,k,h,f[a+11],22,2304563134),h=d(h,i,j,k,f[a+12],7,1804603682),k=d(k,h,i,j,f[a+13],12,4254626195),j=d(j,k,h,i,f[a+14],17,2792965006),i=d(i,j,k,h,f[a+15],22,1236535329),h=b(h,i,j,k,f[a+1],5,4129170786),k=b(k,h,i,j,f[a+6],9,3225465664),j=b(j,k,h,i,f[a+11],14,643717713),i=b(i,j,k,h,f[a+0],20,3921069994),h=b(h,i,j,k,f[a+5],5,3593408605),k=b(k,h,i,j,f[a+10],9,38016083),j=b(j,k,h,i,f[a+15],14,3634488961),i=b(i,j,k,h,f[a+4],20,3889429448), k=d(k,e,i,j,f[a+9],12,2336552879),j=d(j,k,e,i,f[a+10],17,4294925233),i=d(i,j,k,e,f[a+11],22,2304563134),e=d(e,i,j,k,f[a+12],7,1804603682),k=d(k,e,i,j,f[a+13],12,4254626195),j=d(j,k,e,i,f[a+14],17,2792965006),i=d(i,j,k,e,f[a+15],22,1236535329),e=b(e,i,j,k,f[a+1],5,4129170786),k=b(k,e,i,j,f[a+6],9,3225465664),j=b(j,k,e,i,f[a+11],14,643717713),i=b(i,j,k,e,f[a+0],20,3921069994),e=b(e,i,j,k,f[a+5],5,3593408605),k=b(k,e,i,j,f[a+10],9,38016083),j=b(j,k,e,i,f[a+15],14,3634488961),i=b(i,j,k,e,f[a+4],20,3889429448),
h=b(h,i,j,k,f[a+9],5,568446438),k=b(k,h,i,j,f[a+14],9,3275163606),j=b(j,k,h,i,f[a+3],14,4107603335),i=b(i,j,k,h,f[a+8],20,1163531501),h=b(h,i,j,k,f[a+13],5,2850285829),k=b(k,h,i,j,f[a+2],9,4243563512),j=b(j,k,h,i,f[a+7],14,1735328473),i=b(i,j,k,h,f[a+12],20,2368359562),h=e(h,i,j,k,f[a+5],4,4294588738),k=e(k,h,i,j,f[a+8],11,2272392833),j=e(j,k,h,i,f[a+11],16,1839030562),i=e(i,j,k,h,f[a+14],23,4259657740),h=e(h,i,j,k,f[a+1],4,2763975236),k=e(k,h,i,j,f[a+4],11,1272893353),j=e(j,k,h,i,f[a+7],16,4139469664), e=b(e,i,j,k,f[a+9],5,568446438),k=b(k,e,i,j,f[a+14],9,3275163606),j=b(j,k,e,i,f[a+3],14,4107603335),i=b(i,j,k,e,f[a+8],20,1163531501),e=b(e,i,j,k,f[a+13],5,2850285829),k=b(k,e,i,j,f[a+2],9,4243563512),j=b(j,k,e,i,f[a+7],14,1735328473),i=b(i,j,k,e,f[a+12],20,2368359562),e=g(e,i,j,k,f[a+5],4,4294588738),k=g(k,e,i,j,f[a+8],11,2272392833),j=g(j,k,e,i,f[a+11],16,1839030562),i=g(i,j,k,e,f[a+14],23,4259657740),e=g(e,i,j,k,f[a+1],4,2763975236),k=g(k,e,i,j,f[a+4],11,1272893353),j=g(j,k,e,i,f[a+7],16,4139469664),
i=e(i,j,k,h,f[a+10],23,3200236656),h=e(h,i,j,k,f[a+13],4,681279174),k=e(k,h,i,j,f[a+0],11,3936430074),j=e(j,k,h,i,f[a+3],16,3572445317),i=e(i,j,k,h,f[a+6],23,76029189),h=e(h,i,j,k,f[a+9],4,3654602809),k=e(k,h,i,j,f[a+12],11,3873151461),j=e(j,k,h,i,f[a+15],16,530742520),i=e(i,j,k,h,f[a+2],23,3299628645),h=g(h,i,j,k,f[a+0],6,4096336452),k=g(k,h,i,j,f[a+7],10,1126891415),j=g(j,k,h,i,f[a+14],15,2878612391),i=g(i,j,k,h,f[a+5],21,4237533241),h=g(h,i,j,k,f[a+12],6,1700485571),k=g(k,h,i,j,f[a+3],10,2399980690), i=g(i,j,k,e,f[a+10],23,3200236656),e=g(e,i,j,k,f[a+13],4,681279174),k=g(k,e,i,j,f[a+0],11,3936430074),j=g(j,k,e,i,f[a+3],16,3572445317),i=g(i,j,k,e,f[a+6],23,76029189),e=g(e,i,j,k,f[a+9],4,3654602809),k=g(k,e,i,j,f[a+12],11,3873151461),j=g(j,k,e,i,f[a+15],16,530742520),i=g(i,j,k,e,f[a+2],23,3299628645),e=h(e,i,j,k,f[a+0],6,4096336452),k=h(k,e,i,j,f[a+7],10,1126891415),j=h(j,k,e,i,f[a+14],15,2878612391),i=h(i,j,k,e,f[a+5],21,4237533241),e=h(e,i,j,k,f[a+12],6,1700485571),k=h(k,e,i,j,f[a+3],10,2399980690),
j=g(j,k,h,i,f[a+10],15,4293915773),i=g(i,j,k,h,f[a+1],21,2240044497),h=g(h,i,j,k,f[a+8],6,1873313359),k=g(k,h,i,j,f[a+15],10,4264355552),j=g(j,k,h,i,f[a+6],15,2734768916),i=g(i,j,k,h,f[a+13],21,1309151649),h=g(h,i,j,k,f[a+4],6,4149444226),k=g(k,h,i,j,f[a+11],10,3174756917),j=g(j,k,h,i,f[a+2],15,718787259),i=g(i,j,k,h,f[a+9],21,3951481745),h=c(h,q),i=c(i,p),j=c(j,m),k=c(k,u);return(l(h)+l(i)+l(j)+l(k)).toLowerCase()};(function(a){a.fn.stupidtable=function(){a(this).on("click","thead th",function(){a(this).stupidsort()})};a.fn.stupidsort=function(){function c(c){var b=0,d;a(c).children("td,th").each(function(){if(b==q)return d=a(this),!1;var c=a(this).attr("colspan");b+=c?Number(c):1});c="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(l){case "string":case "string-ins":c=String(c).toLowerCase();break;case "int":c= j=h(j,k,e,i,f[a+10],15,4293915773),i=h(i,j,k,e,f[a+1],21,2240044497),e=h(e,i,j,k,f[a+8],6,1873313359),k=h(k,e,i,j,f[a+15],10,4264355552),j=h(j,k,e,i,f[a+6],15,2734768916),i=h(i,j,k,e,f[a+13],21,1309151649),e=h(e,i,j,k,f[a+4],6,4149444226),k=h(k,e,i,j,f[a+11],10,3174756917),j=h(j,k,e,i,f[a+2],15,718787259),i=h(i,j,k,e,f[a+9],21,3951481745),e=c(e,q),i=c(i,p),j=c(j,m),k=c(k,u);return(l(e)+l(i)+l(j)+l(k)).toLowerCase()};(function(a){a.fn.stupidtable=function(){a(this).on("click","thead th",function(){a(this).stupidsort()})};a.fn.stupidsort=function(){function c(c){var b=0,d;a(c).children("td,th").each(function(){if(b==q)return d=a(this),!1;var c=a(this).attr("colspan");b+=c?Number(c):1});c="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(l){case "string":case "string-ins":c=String(c).toLowerCase();break;case "int":c=
parseInt(Number(c));break;case "float":c=Number(c)}return c}var d=a(this),b=d.closest("table"),e=b.children("tbody"),g=e.children("tr"),l=d.attr("data-sort-type");if(l){var f=!0;d.hasClass("sorting-asc")&&(f=!1);var q=0;d.prevAll().each(function(){var c=a(this).attr("colspan");q+=c?Number(c):1});g.sort(function(a,b){var d=f?1:-1,a=c(a),b=c(b);return a>b?1*d:a<b?-1*d:0});e.append(g);b.find("thead th").removeClass("sorting-asc").removeClass("sorting-desc");d.addClass(f?"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(c){}location.hash&&(a=decodeURIComponent(location.hash).substring(1).split("@")[0].split("&"),mist.user.name=a[0],a[1]&&(mist.user.host= parseInt(Number(c));break;case "float":c=Number(c)}return c}var d=a(this),b=d.closest("table"),g=b.children("tbody"),h=g.children("tr"),l=d.attr("data-sort-type");if(l){var f=!0;d.hasClass("sorting-asc")&&(f=!1);var q=0;d.prevAll().each(function(){var c=a(this).attr("colspan");q+=c?Number(c):1});h.sort(function(a,b){var d=f?1:-1,a=c(a),b=c(b);return a>b?1*d:a<b?-1*d:0});g.append(h);b.find("thead th").removeClass("sorting-asc").removeClass("sorting-desc");d.addClass(f?"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(c){}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 d=0;$("body > div.filler").on("scroll",function(){var a=$(this).scrollLeft();a!=d&&UI.elements.header.css("margin-right",-1*a+"px");d=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 d=0;$("body > div.filler").on("scroll",function(){var a=$(this).scrollLeft();a!=d&&UI.elements.header.css("margin-right",-1*a+"px");d=a})});$(window).on("hashchange",function(){var a=decodeURIComponent(location.hash).substring(1).split("@");a[1]||(a[1]="");a=a[1].split("&");""==a[0]&&(a[0]="Overview");UI.showTab(a[0],a[1])});
var otherhost={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,c){this.vars[a]=c;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,c){this.opts&&log("[interval]","Set called on interval, but an interval is already active."); var 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,c){this.vars[a]=c;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,c){this.opts&&log("[interval]","Set called on interval, but an interval is already active.");
this.opts={delay:c,callback:a};this.opts.id=setInterval(a,c)}},returnTab:["Overview"],countrylist:{AF:"Afghanistan",AX:"&Aring;land Islands",AL:"Albania",DZ:"Algeria",AS:"American Samoa",AD:"Andorra",AO:"Angola",AI:"Anguilla",AQ:"Antarctica",AG:"Antigua and Barbuda",AR:"Argentina",AM:"Armenia",AW:"Aruba",AU:"Australia",AT:"Austria",AZ:"Azerbaijan",BS:"Bahamas",BH:"Bahrain",BD:"Bangladesh",BB:"Barbados",BY:"Belarus",BE:"Belgium",BZ:"Belize",BJ:"Benin",BM:"Bermuda",BT:"Bhutan",BO:"Bolivia, Plurinational State of", this.opts={delay:c,callback:a};this.opts.id=setInterval(a,c)}},returnTab:["Overview"],countrylist:{AF:"Afghanistan",AX:"&Aring;land Islands",AL:"Albania",DZ:"Algeria",AS:"American Samoa",AD:"Andorra",AO:"Angola",AI:"Anguilla",AQ:"Antarctica",AG:"Antigua and Barbuda",AR:"Argentina",AM:"Armenia",AW:"Aruba",AU:"Australia",AT:"Austria",AZ:"Azerbaijan",BS:"Bahamas",BH:"Bahrain",BD:"Bangladesh",BB:"Barbados",BY:"Belarus",BE:"Belgium",BZ:"Belize",BJ:"Benin",BM:"Bermuda",BT:"Bhutan",BO:"Bolivia, Plurinational State of",
@ -21,190 +21,195 @@ clearTimeout(this.hiding);delete this.hiding;var d=$(document).height()-$tooltip
"HLS";break;case "html5/video/mp4":c="MP4";break;case "dash/video/mp4":c="DASH";break;case "flash/11":c="HDS";break;case "flash/10":c="RTMP";break;case "flash/7":c="Progressive";break;case "html5/audio/mp3":c="MP3";break;case "html5/video/mp2t":c="TS";break;case "html5/application/vnd.ms-ss":c="Smooth";break;case "html5/text/vtt":c="VTT Subtitles";break;case "html5/text/plain":c="SRT Subtitles";break;case "html5/text/javascript":c="JSON Subtitles"}return c},popup:{element:null,show:function(a){this.element= "HLS";break;case "html5/video/mp4":c="MP4";break;case "dash/video/mp4":c="DASH";break;case "flash/11":c="HDS";break;case "flash/10":c="RTMP";break;case "flash/7":c="Progressive";break;case "html5/audio/mp3":c="MP3";break;case "html5/video/mp2t":c="TS";break;case "html5/application/vnd.ms-ss":c="Smooth";break;case "html5/text/vtt":c="VTT Subtitles";break;case "html5/text/plain":c="SRT Subtitles";break;case "html5/text/javascript":c="JSON Subtitles"}return c},popup:{element:null,show:function(a){this.element=
$("<div>").attr("id","popup").append($("<button>").text("Close").addClass("close").click(function(){UI.popup.element.fadeOut("fast",function(){UI.popup.element.remove();UI.popup.element=null})})).append(a);$("body").append(this.element)}},menu:[{Overview:{},Protocols:{},Streams:{hiddenmenu:{Edit:{},Preview:{},Embed:{}}},Push:{LTSonly:!0},Triggers:{LTSonly:!1},Logs:{},Statistics:{},"Server Stats":{}},{Disconnect:{classes:["red"]}},{Guides:{link:"http://mistserver.org/documentation#Userdocs"},Tools:{submenu:{"Release notes":{link:"http://mistserver.org/documentation#Devdocs"}, $("<div>").attr("id","popup").append($("<button>").text("Close").addClass("close").click(function(){UI.popup.element.fadeOut("fast",function(){UI.popup.element.remove();UI.popup.element=null})})).append(a);$("body").append(this.element)}},menu:[{Overview:{},Protocols:{},Streams:{hiddenmenu:{Edit:{},Preview:{},Embed:{}}},Push:{LTSonly:!0},Triggers:{LTSonly:!1},Logs:{},Statistics:{},"Server Stats":{}},{Disconnect:{classes:["red"]}},{Guides:{link:"http://mistserver.org/documentation#Userdocs"},Tools:{submenu:{"Release notes":{link:"http://mistserver.org/documentation#Devdocs"},
"Mist Shop":{link:"http://mistserver.org/products"},"Email for Help":{}}}}],buildMenu:function(){function a(a,c){var b=$("<a>").addClass("button");b.html($("<span>").addClass("plain").text(a)).append($("<span>").addClass("highlighted").text(a));for(var d in c.classes)b.addClass(c.classes[d]);"LTSonly"in c&&b.addClass("LTSonly");"link"in c?b.attr("href",c.link).attr("target","_blank"):"submenu"in c||b.click(function(c){$(this).closest(".menu").hasClass("hide")||(UI.navto(a),c.stopPropagation())}); "Mist Shop":{link:"http://mistserver.org/products"},"Email for Help":{}}}}],buildMenu:function(){function a(a,c){var b=$("<a>").addClass("button");b.html($("<span>").addClass("plain").text(a)).append($("<span>").addClass("highlighted").text(a));for(var d in c.classes)b.addClass(c.classes[d]);"LTSonly"in c&&b.addClass("LTSonly");"link"in c?b.attr("href",c.link).attr("target","_blank"):"submenu"in c||b.click(function(c){$(this).closest(".menu").hasClass("hide")||(UI.navto(a),c.stopPropagation())});
return b}var c=UI.elements.menu,d;for(d in UI.menu){0<d&&c.append($("<br>"));for(var b in UI.menu[d]){var e=UI.menu[d][b],g=a(b,e);c.append(g);if("submenu"in e){var l=$("<span>").addClass("submenu");g.addClass("arrowdown").append(l);for(var f in e.submenu)l.append(a(f,e.submenu[f]))}else if("hiddenmenu"in e)for(f in l=$("<span>").addClass("hiddenmenu"),g.append(l),e.hiddenmenu)l.append(a(f,e.hiddenmenu[f]))}}d=$("<div>").attr("id","ih_button").text("?").click(function(){$("body").toggleClass("helpme"); return b}var c=UI.elements.menu,d;for(d in UI.menu){0<d&&c.append($("<br>"));for(var b in UI.menu[d]){var g=UI.menu[d][b],h=a(b,g);c.append(h);if("submenu"in g){var l=$("<span>").addClass("submenu");h.addClass("arrowdown").append(l);for(var f in g.submenu)l.append(a(f,g.submenu[f]))}else if("hiddenmenu"in g)for(f in l=$("<span>").addClass("hiddenmenu"),h.append(l),g.hiddenmenu)l.append(a(f,g.hiddenmenu[f]))}}d=$("<div>").attr("id","ih_button").text("?").click(function(){$("body").toggleClass("helpme");
UI.stored.saveOpt("helpme",$("body").hasClass("helpme"))}).attr("title","Click to toggle the display of integrated help");UI.stored.getOpts().helpme&&$("body").addClass("helpme");c.after(d).after($("<div>").addClass("separator"))},findInput:function(a){return this.findInOutput("inputs",a)},findOutput:function(a){return this.findInOutput("connectors",a)},findInOutput:function(a,c){if("capabilities"in mist.data){var d=!1,b=mist.data.capabilities[a];c in b&&(d=b[c]);c+".exe"in b&&(d=b[c+".exe"]);return d}throw"Request capabilities first"; UI.stored.saveOpt("helpme",$("body").hasClass("helpme"))}).attr("title","Click to toggle the display of integrated help");UI.stored.getOpts().helpme&&$("body").addClass("helpme");c.after(d).after($("<div>").addClass("separator"))},findInput:function(a){return this.findInOutput("inputs",a)},findOutput:function(a){return this.findInOutput("connectors",a)},findInOutput:function(a,c){if("capabilities"in mist.data){var d=!1,b=mist.data.capabilities[a];c in b&&(d=b[c]);c+".exe"in b&&(d=b[c+".exe"]);return d}throw"Request capabilities first";
},buildUI:function(a){var c=$("<div>").addClass("input_container"),d;for(d in a){var b=a[d];if(b instanceof jQuery)c.append(b);else if("help"==b.type){var e=$("<span>").addClass("text_container").append($("<span>").addClass("description").append(b.help));c.append(e);if("classes"in b)for(var g in b.classes)e.addClass(b.classes[g])}else if("text"==b.type)c.append($("<span>").addClass("text_container").append($("<span>").addClass("text").append(b.text)));else if("custom"==b.type)c.append(b.custom);else if("buttons"== },buildUI:function(a){var c=$("<div>").addClass("input_container"),d;for(d in a){var b=a[d];if(b instanceof jQuery)c.append(b);else if("help"==b.type){var g=$("<span>").addClass("text_container").append($("<span>").addClass("description").append(b.help));c.append(g);if("classes"in b)for(var h in b.classes)g.addClass(b.classes[h])}else if("text"==b.type)c.append($("<span>").addClass("text_container").append($("<span>").addClass("text").append(b.text)));else if("custom"==b.type)c.append(b.custom);else if("buttons"==
b.type)for(g in e=$("<span>").addClass("button_container").on("keydown",function(a){a.stopPropagation()}),"css"in b&&e.css(b.css),c.append(e),b.buttons){var l=b.buttons[g],f=$("<button>").text(l.label).data("opts",l);"css"in l&&f.css(l.css);if("classes"in l)for(var q in l.classes)f.addClass(l.classes[q]);e.append(f);switch(l.type){case "cancel":f.addClass("cancel").click(l["function"]);break;case "save":f.addClass("save").click(function(){var a=$(this).closest(".input_container"),c=!1;a.find(".hasValidate").each(function(){if(c= b.type)for(h in g=$("<span>").addClass("button_container").on("keydown",function(a){a.stopPropagation()}),"css"in b&&g.css(b.css),c.append(g),b.buttons){var l=b.buttons[h],f=$("<button>").text(l.label).data("opts",l);"css"in l&&f.css(l.css);if("classes"in l)for(var q in l.classes)f.addClass(l.classes[q]);g.append(f);switch(l.type){case "cancel":f.addClass("cancel").click(l["function"]);break;case "save":f.addClass("save").click(function(){var a=$(this).closest(".input_container"),c=!1;a.find(".hasValidate").each(function(){if(c=
$(this).data("validate")(this,!0))return!1});c||(a.find(".isSetting").each(function(){var a=$(this).getval(),c=$(this).data("pointer");if(""==a)if("default"in $(this).data("opts"))a=$(this).data("opts")["default"];else return c.main[c.index]=null,!0;c.main[c.index]=a}),(a=$(this).data("opts")["function"])&&a(this))});break;default:f.click(l["function"])}}else{l=$("<label>").addClass("UIelement");c.append(l);"css"in b&&l.css(b.css);l.append($("<span>").addClass("label").html("label"in b?b.label+":": $(this).data("validate")(this,!0))return!1});c||(a.find(".isSetting").each(function(){var a=$(this).getval(),c=$(this).data("pointer");if(""==a)if("default"in $(this).data("opts"))a=$(this).data("opts")["default"];else return c.main[c.index]=null,!0;c.main[c.index]=a}),(a=$(this).data("opts")["function"])&&a(this))});break;default:f.click(l["function"])}}else{l=$("<label>").addClass("UIelement");c.append(l);"css"in b&&l.css(b.css);l.append($("<span>").addClass("label").html("label"in b?b.label+":":
""));f=$("<span>").addClass("field_container");l.append(f);switch(b.type){case "password":e=$("<input>").attr("type","password");break;case "int":e=$("<input>").attr("type","number");"min"in b&&e.attr("min",b.min);"max"in b&&e.attr("max",b.min);"validate"in b?b.validate.push("int"):b.validate=["int"];break;case "span":e=$("<span>");break;case "debug":b.select=[["","Default"],[0,"0 - All debugging messages disabled"],[1,"1 - Messages about failed operations"],[2,"2 - Previous level, and error messages"], ""));f=$("<span>").addClass("field_container");l.append(f);switch(b.type){case "password":g=$("<input>").attr("type","password");break;case "int":g=$("<input>").attr("type","number");"min"in b&&g.attr("min",b.min);"max"in b&&g.attr("max",b.min);"validate"in b?b.validate.push("int"):b.validate=["int"];break;case "span":g=$("<span>");break;case "debug":b.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":e=$("<select>");for(g in b.select){var p=$("<option>");"string"==typeof b.select[g]? [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":g=$("<select>");for(h in b.select){var p=$("<option>");"string"==typeof b.select[h]?
p.text(b.select[g]):p.val(b.select[g][0]).text(b.select[g][1]);e.append(p)}break;case "textarea":e=$("<textarea>").on("keydown",function(a){a.stopPropagation()});break;case "checkbox":e=$("<input>").attr("type","checkbox");break;case "hidden":e=$("<input>").attr("type","hidden");l.hide();break;case "email":e=$("<input>").attr("type","email").attr("autocomplete","on").attr("required","");break;case "browse":e=$("<input>").attr("type","text");"filetypes"in b&&e.data("filetypes",b.filetypes);break;case "geolimited":case "hostlimited":e= p.text(b.select[h]):p.val(b.select[h][0]).text(b.select[h][1]);g.append(p)}break;case "textarea":g=$("<textarea>").on("keydown",function(a){a.stopPropagation()});break;case "checkbox":g=$("<input>").attr("type","checkbox");break;case "hidden":g=$("<input>").attr("type","hidden");l.hide();break;case "email":g=$("<input>").attr("type","email").attr("autocomplete","on").attr("required","");break;case "browse":g=$("<input>").attr("type","text");"filetypes"in b&&g.data("filetypes",b.filetypes);break;case "geolimited":case "hostlimited":g=
$("<input>").attr("type","hidden");break;case "radioselect":e=$("<div>").addClass("radioselect");for(d in b.radioselect){var m=$("<input>").attr("type","radio").val(b.radioselect[d][0]).attr("name",b.label);("LTSonly"in b&&!mist.data.LTS||b.readonly)&&m.prop("disabled",!0);p=$("<label>").append(m).append($("<span>").html(b.radioselect[d][1]));e.append(p);if(2<b.radioselect[d].length)for(g in m=$("<select>").change(function(){$(this).parent().find("input[type=radio]:enabled").prop("checked","true")}), $("<input>").attr("type","hidden");break;case "radioselect":g=$("<div>").addClass("radioselect");for(d in b.radioselect){var m=$("<input>").attr("type","radio").val(b.radioselect[d][0]).attr("name",b.label);("LTSonly"in b&&!mist.data.LTS||b.readonly)&&m.prop("disabled",!0);p=$("<label>").append(m).append($("<span>").html(b.radioselect[d][1]));g.append(p);if(2<b.radioselect[d].length)for(h in m=$("<select>").change(function(){$(this).parent().find("input[type=radio]:enabled").prop("checked","true")}),
p.append(m),("LTSonly"in b&&!mist.data.LTS||b.readonly)&&m.prop("disabled",!0),b.radioselect[d][2])p=$("<option>"),m.append(p),b.radioselect[d][2][g]instanceof Array?p.val(b.radioselect[d][2][g][0]).html(b.radioselect[d][2][g][1]):p.html(b.radioselect[d][2][g])}break;case "checklist":e=$("<div>").addClass("checkcontainer");$controls=$("<div>").addClass("controls");$checklist=$("<div>").addClass("checklist");e.append($checklist);for(d in b.checklist)"string"==typeof b.checklist[d]&&(b.checklist[d]= p.append(m),("LTSonly"in b&&!mist.data.LTS||b.readonly)&&m.prop("disabled",!0),b.radioselect[d][2])p=$("<option>"),m.append(p),b.radioselect[d][2][h]instanceof Array?p.val(b.radioselect[d][2][h][0]).html(b.radioselect[d][2][h][1]):p.html(b.radioselect[d][2][h])}break;case "checklist":g=$("<div>").addClass("checkcontainer");$controls=$("<div>").addClass("controls");$checklist=$("<div>").addClass("checklist");g.append($checklist);for(d in b.checklist)"string"==typeof b.checklist[d]&&(b.checklist[d]=
[b.checklist[d],b.checklist[d]]),$checklist.append($("<label>").text(b.checklist[d][1]).prepend($("<input>").attr("type","checkbox").attr("name",b.checklist[d][0])));break;case "DOMfield":e=b.DOMfield;break;default:e=$("<input>").attr("type","text")}e.addClass("field").data("opts",b);"pointer"in b&&e.attr("name",b.pointer.index);f.append(e);if("classes"in b)for(g in b.classes)e.addClass(b.classes[g]);"placeholder"in b&&e.attr("placeholder",b.placeholder);"default"in b&&e.attr("placeholder",b["default"]); [b.checklist[d],b.checklist[d]]),$checklist.append($("<label>").text(b.checklist[d][1]).prepend($("<input>").attr("type","checkbox").attr("name",b.checklist[d][0])));break;case "DOMfield":g=b.DOMfield;break;case "unix":g=$("<input>").attr("type","datetime-local").attr("step",1);b.unit=$("<button>").text("Now").click(function(){$(this).closest(".field_container").find(".field").setval((new Date).getTime()/1E3)});break;default:g=$("<input>").attr("type","text")}g.addClass("field").data("opts",b);"pointer"in
"unit"in b&&f.append($("<span>").addClass("unit").html(b.unit));"readonly"in b&&(e.attr("readonly","readonly"),e.click(function(){$(this).select()}));"qrcode"in b&&f.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()),c=$("<div>").addClass("qrcode");UI.popup.show($("<span>").addClass("qr_container").append($("<p>").text(a)).append(c));c.qrcode({text:a, b&&g.attr("name",b.pointer.index);f.append(g);if("classes"in b)for(h in b.classes)g.addClass(b.classes[h]);"placeholder"in b&&g.attr("placeholder",b.placeholder);"default"in b&&g.attr("placeholder",b["default"]);"unit"in b&&f.append($("<span>").addClass("unit").html(b.unit));"readonly"in b&&(g.attr("readonly","readonly"),g.click(function(){$(this).select()}));"qrcode"in b&&f.append($("<span>").addClass("unit").html($("<button>").text("QR").on("keydown",function(a){a.stopPropagation()}).click(function(){var a=
size:Math.min(c.width(),c.height())})})));"clipboard"in b&&document.queryCommandSupported("copy")&&f.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()),c=document.createElement("textarea");c.value=a;document.body.appendChild(c);c.select();var b=false;try{b=document.execCommand("copy")}catch(d){}if(b){$(this).text("Copied to clipboard!");document.body.removeChild(c); String($(this).closest(".field_container").find(".field").getval()),c=$("<div>").addClass("qrcode");UI.popup.show($("<span>").addClass("qr_container").append($("<p>").text(a)).append(c));c.qrcode({text:a,size:Math.min(c.width(),c.height())})})));"clipboard"in b&&document.queryCommandSupported("copy")&&f.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()),
var g=$(this);setTimeout(function(){g.text("Copy")},5E3)}else{document.body.removeChild(c);alert("Failed to copy:\n"+a)}})));"rows"in b&&e.attr("rows",b.rows);"LTSonly"in b&&!mist.data.LTS&&(f.addClass("LTSonly"),e.prop("disabled",!0));switch(b.type){case "browse":m=$("<div>").addClass("grouper").append(l);c.append(m);m=$("<button>").text("Browse").on("keydown",function(a){a.stopPropagation()});f.append(m);m.click(function(){function a(c){l.text("Loading..");mist.send(function(a){e.text(a.browse.path[0]); c=document.createElement("textarea");c.value=a;document.body.appendChild(c);c.select();var b=false;try{b=document.execCommand("copy")}catch(d){}if(b){$(this).text("Copied to clipboard!");document.body.removeChild(c);var h=$(this);setTimeout(function(){h.text("Copy")},5E3)}else{document.body.removeChild(c);alert("Failed to copy:\n"+a)}})));"rows"in b&&g.attr("rows",b.rows);"LTSonly"in b&&!mist.data.LTS&&(f.addClass("LTSonly"),g.prop("disabled",!0));switch(b.type){case "browse":m=$("<div>").addClass("grouper").append(l);
mist.data.LTS&&d.setval(a.browse.path[0]+"/");l.html(m.clone(true).text("..").attr("title","Folder up"));if(a.browse.subdirectories){a.browse.subdirectories.sort();for(var c in a.browse.subdirectories){var h=a.browse.subdirectories[c];l.append(m.clone(true).attr("title",e.text()+q+h).text(h))}}if(a.browse.files){a.browse.files.sort();for(c in a.browse.files){var h=a.browse.files[c],f=e.text()+q+h,h=$("<a>").text(h).addClass("file").attr("title",f);l.append(h);if(p){var u=true,z;for(z in p)if(typeof p[z]!= c.append(m);m=$("<button>").text("Browse").on("keydown",function(a){a.stopPropagation()});f.append(m);m.click(function(){function a(c){l.text("Loading..");mist.send(function(a){g.text(a.browse.path[0]);mist.data.LTS&&d.setval(a.browse.path[0]+"/");l.html(m.clone(true).text("..").attr("title","Folder up"));if(a.browse.subdirectories){a.browse.subdirectories.sort();for(var c in a.browse.subdirectories){var e=a.browse.subdirectories[c];l.append(m.clone(true).attr("title",g.text()+q+e).text(e))}}if(a.browse.files){a.browse.files.sort();
"undefined"&&mist.inputMatch(p[z],f)){u=false;break}u&&h.hide()}h.click(function(){var a=$(this).attr("title");d.setval(a).removeAttr("readonly").css("opacity",1);g.show();b.remove()})}}},{browse:c})}var c=$(this).closest(".grouper"),b=$("<div>").addClass("browse_container"),d=c.find(".field").attr("readonly","readonly").css("opacity",0.5),g=$(this),f=$("<button>").text("Stop browsing").click(function(){g.show();b.remove();d.removeAttr("readonly").css("opacity",1)}),e=$("<span>").addClass("field"), for(c in a.browse.files){var e=a.browse.files[c],f=g.text()+q+e,e=$("<a>").text(e).addClass("file").attr("title",f);l.append(e);if(p){var u=true,z;for(z in p)if(typeof p[z]!="undefined"&&mist.inputMatch(p[z],f)){u=false;break}u&&e.hide()}e.click(function(){var a=$(this).attr("title");d.setval(a).removeAttr("readonly").css("opacity",1);h.show();b.remove()})}}},{browse:c})}var c=$(this).closest(".grouper"),b=$("<div>").addClass("browse_container"),d=c.find(".field").attr("readonly","readonly").css("opacity",
l=$("<div>").addClass("browse_contents"),m=$("<a>").addClass("folder"),p=d.data("filetypes");c.append(b);b.append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Current folder:")).append($("<span>").addClass("field_container").append(e).append(f))).append(l);var q="/";mist.data.config.version.indexOf("indows")>-1&&(q="\\");m.click(function(){var c=e.text()+q+$(this).text();a(c)});c=d.getval();f=c.split("://");f.length>1&&(c=f[0]=="file"?f[1]:"");c=c.split(q);c.pop(); 0.5),h=$(this),f=$("<button>").text("Stop browsing").click(function(){h.show();b.remove();d.removeAttr("readonly").css("opacity",1)}),g=$("<span>").addClass("field"),l=$("<div>").addClass("browse_contents"),m=$("<a>").addClass("folder"),p=d.data("filetypes");c.append(b);b.append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Current folder:")).append($("<span>").addClass("field_container").append(g).append(f))).append(l);var q="/";mist.data.config.version.indexOf("indows")>
c=c.join(q);g.hide();a(c)});break;case "geolimited":case "hostlimited":m={field:e};m.blackwhite=$("<select>").append($("<option>").val("-").text("Blacklist")).append($("<option>").val("+").text("Whitelist"));m.values=$("<span>").addClass("limit_value_list");switch(b.type){case "geolimited":m.prototype=$("<select>").append($("<option>").val("").text("[Select a country]"));for(d in UI.countrylist)m.prototype.append($("<option>").val(d).html(UI.countrylist[d]));break;case "hostlimited":m.prototype=$("<input>").attr("type", -1&&(q="\\");m.click(function(){var c=g.text()+q+$(this).text();a(c)});c=d.getval();f=c.split("://");f.length>1&&(c=f[0]=="file"?f[1]:"");c=c.split(q);c.pop();c=c.join(q);h.hide();a(c)});break;case "geolimited":case "hostlimited":m={field:g};m.blackwhite=$("<select>").append($("<option>").val("-").text("Blacklist")).append($("<option>").val("+").text("Whitelist"));m.values=$("<span>").addClass("limit_value_list");switch(b.type){case "geolimited":m.prototype=$("<select>").append($("<option>").val("").text("[Select a country]"));
"text").attr("placeholder","type a host")}m.prototype.on("change keyup",function(){$(this).closest(".field_container").data("subUI").blackwhite.trigger("change")});m.blackwhite.change(function(){var a=$(this).closest(".field_container").data("subUI"),c=[],b=false;a.values.children().each(function(){b=$(this).val();b!=""?c.push(b):$(this).remove()});a.values.append(a.prototype.clone(true));c.length>0?a.field.val($(this).val()+c.join(" ")):a.field.val("");a.field.trigger("change")});"LTSonly"in b&& for(d in UI.countrylist)m.prototype.append($("<option>").val(d).html(UI.countrylist[d]));break;case "hostlimited":m.prototype=$("<input>").attr("type","text").attr("placeholder","type a host")}m.prototype.on("change keyup",function(){$(this).closest(".field_container").data("subUI").blackwhite.trigger("change")});m.blackwhite.change(function(){var a=$(this).closest(".field_container").data("subUI"),c=[],b=false;a.values.children().each(function(){b=$(this).val();b!=""?c.push(b):$(this).remove()});
!mist.data.LTS&&(m.blackwhite.prop("disabled",!0),m.prototype.prop("disabled",!0));m.values.append(m.prototype.clone(!0));f.data("subUI",m).addClass("limit_list").append(m.blackwhite).append(m.values)}"pointer"in b&&(e.data("pointer",b.pointer).addClass("isSetting"),b.pointer.main&&(m=b.pointer.main[b.pointer.index],"undefined"!=m&&e.setval(m)));"value"in b&&e.setval(b.value);if("datalist"in b)for(d in m="datalist_"+d+MD5(e[0].outerHTML),e.attr("list",m),m=$("<datalist>").attr("id",m),f.append(m), a.values.append(a.prototype.clone(true));c.length>0?a.field.val($(this).val()+c.join(" ")):a.field.val("");a.field.trigger("change")});"LTSonly"in b&&!mist.data.LTS&&(m.blackwhite.prop("disabled",!0),m.prototype.prop("disabled",!0));m.values.append(m.prototype.clone(!0));f.data("subUI",m).addClass("limit_list").append(m.blackwhite).append(m.values)}"pointer"in b&&(g.data("pointer",b.pointer).addClass("isSetting"),b.pointer.main&&(m=b.pointer.main[b.pointer.index],"undefined"!=m&&g.setval(m)));"value"in
b.datalist)m.append($("<option>").val(b.datalist[d]));f=$("<span>").addClass("help_container");l.append(f);"help"in b&&(f.append($("<span>").addClass("ih_balloon").html(b.help)),e.on("focus mouseover",function(){$(this).closest("label").addClass("active")}).on("blur mouseout",function(){$(this).closest("label").removeClass("active")}));if("validate"in b){l=[];for(g in b.validate){m=b.validate[g];if("function"!=typeof m)switch(m){case "required":m=function(a){return a==""||a==null?{msg:"This is a required field.", b&&g.setval(b.value);if("datalist"in b)for(d in m="datalist_"+d+MD5(g[0].outerHTML),g.attr("list",m),m=$("<datalist>").attr("id",m),f.append(m),b.datalist)m.append($("<option>").val(b.datalist[d]));f=$("<span>").addClass("help_container");l.append(f);"help"in b&&(f.append($("<span>").addClass("ih_balloon").html(b.help)),g.on("focus mouseover",function(){$(this).closest("label").addClass("active")}).on("blur mouseout",function(){$(this).closest("label").removeClass("active")}));if("validate"in b){l=
classes:["red"]}:false};break;case "int":m=function(a,c){var b=$(c).data("opts");if(!$(c)[0].validity.valid){var d=[];"min"in b&&d.push(" greater than or equal to "+b.min);"max"in b&&d.push(" smaller than or equal to "+b.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":m=function(a,c){if(!isNaN(a.charAt(0)))return{msg:"The first character may not be a number.",classes:["red"]}; [];for(h in b.validate){m=b.validate[h];if("function"!=typeof m)switch(m){case "required":m=function(a){return a==""||a==null?{msg:"This is a required field.",classes:["red"]}:false};break;case "int":m=function(a,c){var b=$(c).data("opts");if(!$(c)[0].validity.valid){var d=[];"min"in b&&d.push(" greater than or equal to "+b.min);"max"in b&&d.push(" smaller than or equal to "+b.max);return{msg:"Please enter an integer"+d.join(" and")+".",classes:["red"]}}if(parseInt(Number(a))!=a)return{msg:"Please enter an integer.",
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&&$(c).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;default:m=function(){}}l.push(m)}e.data("validate_functions", classes:["red"]}};break;case "streamname":m=function(a,c){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&&$(c).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.",
l).data("help_container",f).data("validate",function(a,c){var b=$(a).getval(),d=$(a).data("validate_functions"),g=$(a).data("help_container");g.find(".err_balloon").remove();for(var f in d){var e=d[f](b,a);if(e){$err=$("<span>").addClass("err_balloon").html(e.msg);for(var l in e.classes)$err.addClass(e.classes[l]);g.prepend($err);c&&$(a).focus();return true}}return false}).addClass("hasValidate").on("change keyup",function(){$(this).data("validate")($(this))});""!=e.getval()&&e.trigger("change")}"function"in classes:["red"]}};break;default:m=function(){}}l.push(m)}g.data("validate_functions",l).data("help_container",f).data("validate",function(a,c){var b=$(a).getval(),d=$(a).data("validate_functions"),h=$(a).data("help_container");h.find(".err_balloon").remove();for(var f in d){var g=d[f](b,a);if(g){$err=$("<span>").addClass("err_balloon").html(g.msg);for(var l in g.classes)$err.addClass(g.classes[l]);h.prepend($err);c&&$(a).focus();return typeof g=="object"&&"break"in g?g["break"]:true}}return false}).addClass("hasValidate").on("change keyup",
b&&(e.on("change keyup",b["function"]),e.trigger("change"))}}c.on("keydown",function(a){switch(a.which){case 13:$(this).find("button.save").first().trigger("click");break;case 27:$(this).find("button.cancel").first().trigger("click")}});return c},buildVheaderTable:function(a){var c=$("<table>").css("margin","0.2em"),d=$("<tr>").addClass("header").append($("<td>").addClass("vheader").attr("rowspan",a.labels.length+1).append($("<span>").text(a.vheader))),b=[];d.append($("<td>"));for(var e in a.labels)b.push($("<tr>").append($("<td>").html(""== function(){$(this).data("validate")($(this))});""!=g.getval()&&g.trigger("change")}"function"in b&&(g.on("change keyup",b["function"]),g.trigger("change"))}}c.on("keydown",function(a){switch(a.which){case 13:$(this).find("button.save").first().trigger("click");break;case 27:$(this).find("button.cancel").first().trigger("click")}});return c},buildVheaderTable:function(a){var c=$("<table>").css("margin","0.2em"),d=$("<tr>").addClass("header").append($("<td>").addClass("vheader").attr("rowspan",a.labels.length+
a.labels[e]?"&nbsp;":a.labels[e]+":")));for(var g in a.content)for(e in d.append($("<td>").html(a.content[g].header)),a.content[g].body)b[e].append($("<td>").html(a.content[g].body[e]));c.append($("<tbody>").append(d).append(b));return c},plot:{addGraph:function(a,c){var d={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(d.elements.legend);d.elements.cont.append(d.elements.plot).append(d.elements.legend); 1).append($("<span>").text(a.vheader))),b=[];d.append($("<td>"));for(var g in a.labels)b.push($("<tr>").append($("<td>").html(""==a.labels[g]?"&nbsp;":a.labels[g]+":")));for(var h in a.content)for(g in d.append($("<td>").html(a.content[h].header)),a.content[h].body)b[g].append($("<td>").html(a.content[h].body[g]));c.append($("<tbody>").append(d).append(b));return c},plot:{addGraph:function(a,c){var d={id:a.id,xaxis:a.xaxis,datasets:[],elements:{cont:$("<div>").addClass("graph"),plot:$("<div>").addClass("plot"),
c.append(d.elements.cont);return d},go:function(a){if(!(1>Object.keys(a).length)){var c={totals:[],clients:[]},d;for(d in a)for(var b in a[d].datasets){var e=a[d].datasets[b];switch(e.datatype){case "clients":case "upbps":case "downbps":switch(e.origin[0]){case "total":c.totals.push({fields:[e.datatype],end:-15});break;case "stream":c.totals.push({fields:[e.datatype],streams:[e.origin[1]],end:-15});break;case "protocol":c.totals.push({fields:[e.datatype],protocols:[e.origin[1]],end:-15})}break;case "cpuload":case "memload":c.capabilities= legend:$("<div>").addClass("legend").attr("draggable","true")}};UI.draggable(d.elements.legend);d.elements.cont.append(d.elements.plot).append(d.elements.legend);c.append(d.elements.cont);return d},go:function(a){if(!(1>Object.keys(a).length)){var c={totals:[],clients:[]},d;for(d in a)for(var b in a[d].datasets){var g=a[d].datasets[b];switch(g.datatype){case "clients":case "upbps":case "downbps":switch(g.origin[0]){case "total":c.totals.push({fields:[g.datatype],end:-15});break;case "stream":c.totals.push({fields:[g.datatype],
{}}}0==c.totals.length&&delete c.totals;0==c.clients.length&&delete c.clients;mist.send(function(){for(var c in a){var b=a[c];if(1>b.datasets.length){b.elements.plot.html("");b.elements.legend.html("");break}switch(b.xaxis){case "time":var d=[];b.yaxes={};var e=[],p;for(p in b.datasets){var m=b.datasets[p];m.display&&(m.getdata(),m.yaxistype in b.yaxes||(d.push(UI.plot.yaxes[m.yaxistype]),b.yaxes[m.yaxistype]=d.length),m.yaxis=b.yaxes[m.yaxistype],e.push(m))}d[0]&&(d[0].color=0);b.plot=$.plot(b.elements.plot, streams:[g.origin[1]],end:-15});break;case "protocol":c.totals.push({fields:[g.datatype],protocols:[g.origin[1]],end:-15})}break;case "cpuload":case "memload":c.capabilities={}}}0==c.totals.length&&delete c.totals;0==c.clients.length&&delete c.clients;mist.send(function(){for(var c in a){var b=a[c];if(1>b.datasets.length){b.elements.plot.html("");b.elements.legend.html("");break}switch(b.xaxis){case "time":var d=[];b.yaxes={};var g=[],p;for(p in b.datasets){var m=b.datasets[p];m.display&&(m.getdata(),
e,{legend:{show:!1},xaxis:UI.plot.xaxes[b.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(b.id))).append($("<td>").css("padding-right","2em").css("text-align","right").html($("<span>").addClass("value")).append($("<button>").data("opts",b).text("X").addClass("close").click(function(){var c= m.yaxistype in b.yaxes||(d.push(UI.plot.yaxes[m.yaxistype]),b.yaxes[m.yaxistype]=d.length),m.yaxis=b.yaxes[m.yaxistype],g.push(m))}d[0]&&(d[0].color=0);b.plot=$.plot(b.elements.plot,g,{legend:{show:!1},xaxis:UI.plot.xaxes[b.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(b.id))).append($("<td>").css("padding-right",
$(this).data("opts");if(confirm("Are you sure you want to remove "+c.id+"?")){c.elements.cont.remove();var b=$(".graph_ids option:contains("+c.id+")"),d=b.parent();b.remove();UI.plot.del(c.id);delete a[c.id];d.trigger("change");UI.plot.go(a)}}))));b.elements.legend.html(d);var u=function(a){var c=b.elements.legend.find(".value"),d=1;if(typeof a=="undefined")c.eq(0).html("Latest:");else{var g=b.plot.getXAxes()[0],a=Math.min(g.max,a),a=Math.max(g.min,a);c.eq(0).html(UI.format.time(a/1E3))}for(var h in b.datasets){var e= "2em").css("text-align","right").html($("<span>").addClass("value")).append($("<button>").data("opts",b).text("X").addClass("close").click(function(){var c=$(this).data("opts");if(confirm("Are you sure you want to remove "+c.id+"?")){c.elements.cont.remove();var b=$(".graph_ids option:contains("+c.id+")"),d=b.parent();b.remove();UI.plot.del(c.id);delete a[c.id];d.trigger("change");UI.plot.go(a)}}))));b.elements.legend.html(d);var u=function(a){var c=b.elements.legend.find(".value"),d=1;if(typeof a==
"&nbsp;";if(b.datasets[h].display){var g=UI.plot.yaxes[b.datasets[h].yaxistype].tickFormatter,f=b.datasets[h].data;if(a)for(var m in f){if(f[m][0]==a){e=g(f[m][1]);break}if(f[m][0]>a){if(m!=0){e=f[m];f=f[m-1];e=g(e[1]+(a-e[0])*(f[1]-e[1])/(f[0]-e[0]))}break}}else e=g(b.datasets[h].data[b.datasets[h].data.length-1][1])}c.eq(d).html(e);d++}};b.plot.getOptions();for(p in b.datasets)e=$("<input>").attr("type","checkbox").data("index",p).data("graph",b).click(function(){var a=$(this).data("graph");$(this).is(":checked")? "undefined")c.eq(0).html("Latest:");else{var h=b.plot.getXAxes()[0],a=Math.min(h.max,a),a=Math.max(h.min,a);c.eq(0).html(UI.format.time(a/1E3))}for(var e in b.datasets){var g="&nbsp;";if(b.datasets[e].display){var h=UI.plot.yaxes[b.datasets[e].yaxistype].tickFormatter,f=b.datasets[e].data;if(a)for(var m in f){if(f[m][0]==a){g=h(f[m][1]);break}if(f[m][0]>a){if(m!=0){g=f[m];f=f[m-1];g=h(g[1]+(a-g[0])*(f[1]-g[1])/(f[0]-g[0]))}break}}else g=h(b.datasets[e].data[b.datasets[e].data.length-1][1])}c.eq(d).html(g);
a.datasets[$(this).data("index")].display=true:a.datasets[$(this).data("index")].display=false;var c={};c[a.id]=a;UI.plot.go(c)}),b.datasets[p].display&&e.attr("checked","checked"),d.append($("<tr>").html($("<td>").html($("<label>").html(e).append($("<div>").addClass("series-color").css("background-color",b.datasets[p].color)).append(b.datasets[p].label))).append($("<td>").css("padding-right","2em").css("text-align","right").html($("<span>").addClass("value")).append($("<button>").text("X").addClass("close").data("index", d++}};b.plot.getOptions();for(p in b.datasets)g=$("<input>").attr("type","checkbox").data("index",p).data("graph",b).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 c={};c[a.id]=a;UI.plot.go(c)}),b.datasets[p].display&&g.attr("checked","checked"),d.append($("<tr>").html($("<td>").html($("<label>").html(g).append($("<div>").addClass("series-color").css("background-color",b.datasets[p].color)).append(b.datasets[p].label))).append($("<td>").css("padding-right",
p).data("graph",b).click(function(){var c=$(this).data("index"),b=$(this).data("graph");if(confirm("Are you sure you want to remove "+b.datasets[c].label+" from "+b.id+"?")){b.datasets.splice(c,1);if(b.datasets.length==0){b.elements.cont.remove();var c=$(".graph_ids option:contains("+b.id+")"),d=c.parent();c.remove();d.trigger("change");UI.plot.del(b.id);delete a[b.id];UI.plot.go(a)}else{UI.plot.save(b);c={};c[b.id]=b;UI.plot.go(c)}}}))));u();var h=!1;b.elements.plot.on("plothover",function(a,c,b){if(c.x!= "2em").css("text-align","right").html($("<span>").addClass("value")).append($("<button>").text("X").addClass("close").data("index",p).data("graph",b).click(function(){var c=$(this).data("index"),b=$(this).data("graph");if(confirm("Are you sure you want to remove "+b.datasets[c].label+" from "+b.id+"?")){b.datasets.splice(c,1);if(b.datasets.length==0){b.elements.cont.remove();var c=$(".graph_ids option:contains("+b.id+")"),d=c.parent();c.remove();d.trigger("change");UI.plot.del(b.id);delete a[b.id];
h){u(c.x);h=c.x}if(b){a=$("<span>").append($("<h3>").text(b.series.label).prepend($("<div>").addClass("series-color").css("background-color",b.series.color))).append($("<table>").addClass("nolay").html($("<tr>").html($("<td>").text("Time:")).append($("<td>").html(UI.format.dateTime(b.datapoint[0]/1E3,"long")))).append($("<tr>").html($("<td>").text("Value:")).append($("<td>").html(b.series.yaxis.tickFormatter(b.datapoint[1],b.series.yaxis)))));UI.tooltip.show(c,a.children())}else UI.tooltip.hide()}).on("mouseout", UI.plot.go(a)}else{UI.plot.save(b);c={};c[b.id]=b;UI.plot.go(c)}}}))));u();var e=!1;b.elements.plot.on("plothover",function(a,c,b){if(c.x!=e){u(c.x);e=c.x}if(b){a=$("<span>").append($("<h3>").text(b.series.label).prepend($("<div>").addClass("series-color").css("background-color",b.series.color))).append($("<table>").addClass("nolay").html($("<tr>").html($("<td>").text("Time:")).append($("<td>").html(UI.format.dateTime(b.datapoint[0]/1E3,"long")))).append($("<tr>").html($("<td>").text("Value:")).append($("<td>").html(b.series.yaxis.tickFormatter(b.datapoint[1],
function(){u()})}}},c)}},save:function(a){var c={id:a.id,xaxis:a.xaxis,datasets:[]},d;for(d in a.datasets)c.datasets.push({origin:a.datasets[d].origin,datatype:a.datasets[d].datatype});a=mist.stored.get().graphs||{};a[c.id]=c;mist.stored.set("graphs",a)},del:function(a){var c=mist.stored.get().graphs||{};delete c[a];mist.stored.set("graphs",c)},datatype:{getOptions:function(a){var c=$.extend(!0,{},UI.plot.datatype.templates.general),d=$.extend(!0,{},UI.plot.datatype.templates[a.datatype]),a=$.extend(!0, b.series.yaxis)))));UI.tooltip.show(c,a.children())}else UI.tooltip.hide()}).on("mouseout",function(){u()})}}},c)}},save:function(a){var c={id:a.id,xaxis:a.xaxis,datasets:[]},d;for(d in a.datasets)c.datasets.push({origin:a.datasets[d].origin,datatype:a.datasets[d].datatype});a=mist.stored.get().graphs||{};a[c.id]=c;mist.stored.set("graphs",a)},del:function(a){var c=mist.stored.get().graphs||{};delete c[a];mist.stored.set("graphs",c)},datatype:{getOptions:function(a){var c=$.extend(!0,{},UI.plot.datatype.templates.general),
d,a),a=$.extend(!0,c,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 c=[],b;for(b in a.basecolor)d=a.basecolor[b],d+=50*(0.5-Math.random()),d=Math.round(d),d=Math.min(255,Math.max(0,d)),c.push(d);a.color="rgb("+c.join(",")+")";return a},templates:{general:{display:!0,datatype:"general",label:"",yaxistype:"amount",data:[],lines:{show:!0},points:{show:!1},getdata:function(){var a= d=$.extend(!0,{},UI.plot.datatype.templates[a.datatype]),a=$.extend(!0,d,a),a=$.extend(!0,c,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 c=[],b;for(b in a.basecolor)d=a.basecolor[b],d+=50*(0.5-Math.random()),d=Math.round(d),d=Math.min(255,Math.max(0,d)),c.push(d);a.color="rgb("+c.join(",")+")";return a},templates:{general:{display:!0,datatype:"general",label:"",
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,c;for(c in this.data)this.data[c][0]<1E3*(mist.data.config.time-600)&&(a=c);!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:"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,c;for(c in this.data)this.data[c][0]<1E3*(mist.data.config.time-600)&&(a=c);!1!==a&&this.data.splice(0,Number(a)+1);this.data.push([1E3*mist.data.config.time,
yaxistype:"percentage",basecolor:[175,216,248],getdata:function(){var a=!1,c;for(c in this.data)this.data[c][0]<1E3*(mist.data.config.time-600)&&(a=c);!1!==a&&this.data.splice(0,Number(a)+1);this.data.push([1E3*mist.data.config.time,mist.data.capabilities.load.memory]);return this.data}},clients:{label:"Connections",basecolor:[203,75,75]},upbps:{label:"Bandwidth up",yaxistype:"bytespersec",basecolor:[77,167,77]},downbps:{label:"Bandwidth down",yaxistype:"bytespersec",basecolor:[148,64,237]}}},yaxes:{percentage:{name:"percentage", mist.data.capabilities.cpu_use/10]);return this.data}},memload:{label:"Memory load",yaxistype:"percentage",basecolor:[175,216,248],getdata:function(){var a=!1,c;for(c in this.data)this.data[c][0]<1E3*(mist.data.config.time-600)&&(a=c);!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",
color:"black",tickColor:0,tickDecimals:0,tickFormatter:function(a){return UI.format.addUnit(UI.format.number(a),"%")},tickLength:0,min:0,max:100},amount:{name:"amount",color:"black",tickColor:0,tickDecimals:0,tickFormatter:function(a){return UI.format.number(a)},tickLength:0,min:0},bytespersec:{name:"bytespersec",color:"black",tickColor:0,tickDecimals:1,tickFormatter:function(a){return UI.format.bytes(a,!0)},tickLength:0,ticks:function(a){var c=0.3*Math.sqrt($(".graph").first().height()),c=(a.max- yaxistype:"bytespersec",basecolor:[148,64,237]}}},yaxes:{percentage:{name:"percentage",color:"black",tickColor:0,tickDecimals:0,tickFormatter:function(a){return UI.format.addUnit(UI.format.number(a),"%")},tickLength:0,min:0,max:100},amount:{name:"amount",color:"black",tickColor:0,tickDecimals:0,tickFormatter:function(a){return UI.format.number(a)},tickLength:0,min:0},bytespersec:{name:"bytespersec",color:"black",tickColor:0,tickDecimals:1,tickFormatter:function(a){return UI.format.bytes(a,!0)},tickLength:0,
a.min)/c,d=Math.floor(Math.log(Math.abs(c))/Math.log(1024)),b=c/Math.pow(1024,d),e=-Math.floor(Math.log(b)/Math.LN10),g=a.tickDecimals;null!=g&&e>g&&(e=g);var l=Math.pow(10,-e),b=b/l,f;if(1.5>b)f=1;else if(3>b){if(f=2,2.25<b&&(null==g||e+1<=g))f=2.5,++e}else f=7.5>b?5:10;f=f*l*Math.pow(1024,d);null!=a.minTickSize&&f<a.minTickSize&&(f=a.minTickSize);a.delta=c;a.tickDecimals=Math.max(0,null!=g?g:e);a.tickSize=f;c=[];d=a.tickSize*Math.floor(a.min/a.tickSize);e=0;g=Number.NaN;do l=g,g=d+e*a.tickSize, ticks:function(a){var c=0.3*Math.sqrt($(".graph").first().height()),c=(a.max-a.min)/c,d=Math.floor(Math.log(Math.abs(c))/Math.log(1024)),b=c/Math.pow(1024,d),g=-Math.floor(Math.log(b)/Math.LN10),h=a.tickDecimals;null!=h&&g>h&&(g=h);var l=Math.pow(10,-g),b=b/l,f;if(1.5>b)f=1;else if(3>b){if(f=2,2.25<b&&(null==h||g+1<=h))f=2.5,++g}else f=7.5>b?5:10;f=f*l*Math.pow(1024,d);null!=a.minTickSize&&f<a.minTickSize&&(f=a.minTickSize);a.delta=c;a.tickDecimals=Math.max(0,null!=h?h:g);a.tickSize=f;c=[];d=a.tickSize*
c.push(g),++e;while(g<a.max&&g!=l);return c},min:0}},xaxes:{time:{name:"time",mode:"time",timezone:"browser",ticks:5}}},draggable:function(a){a.attr("draggable",!0);a.on("dragstart",function(a){$(this).css("opacity",0.4).data("dragstart",{click:{x:a.originalEvent.pageX,y:a.originalEvent.pageY},ele:{x:this.offsetLeft,y:this.offsetTop}})}).on("dragend",function(a){var d=$(this).data("dragstart"),b=d.ele.x-d.click.x+a.originalEvent.pageX,a=d.ele.y-d.click.y+a.originalEvent.pageY;$(this).css({opacity:1, Math.floor(a.min/a.tickSize);g=0;h=Number.NaN;do l=h,h=d+g*a.tickSize,c.push(h),++g;while(h<a.max&&h!=l);return c},min:0}},xaxes:{time:{name:"time",mode:"time",timezone:"browser",ticks:5}}},draggable:function(a){a.attr("draggable",!0);a.on("dragstart",function(a){$(this).css("opacity",0.4).data("dragstart",{click:{x:a.originalEvent.pageX,y:a.originalEvent.pageY},ele:{x:this.offsetLeft,y:this.offsetTop}})}).on("dragend",function(a){var d=$(this).data("dragstart"),b=d.ele.x-d.click.x+a.originalEvent.pageX,
top:a,left:b,right:"auto",bottom:"auto"})});a.parent().on("dragleave",function(){})},format:{time:function(a,c){var d=new Date(1E3*a),b=[];b.push(("0"+d.getHours()).slice(-2));b.push(("0"+d.getMinutes()).slice(-2));"short"!=c&&b.push(("0"+d.getSeconds()).slice(-2));return b.join(":")},date:function(a,c){var d=new Date(1E3*a),b="Sun Mon Tue Wed Thu Fri Sat".split(" "),e=[];"long"==c&&e.push(b[d.getDay()]);e.push(("0"+d.getDate()).slice(-2));e.push("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" ")[d.getMonth()]); a=d.ele.y-d.click.y+a.originalEvent.pageY;$(this).css({opacity:1,top:a,left:b,right:"auto",bottom:"auto"})});a.parent().on("dragleave",function(){})},format:{time:function(a,c){var d=new Date(1E3*a),b=[];b.push(("0"+d.getHours()).slice(-2));b.push(("0"+d.getMinutes()).slice(-2));"short"!=c&&b.push(("0"+d.getSeconds()).slice(-2));return b.join(":")},date:function(a,c){var d=new Date(1E3*a),b="Sun Mon Tue Wed Thu Fri Sat".split(" "),g=[];"long"==c&&g.push(b[d.getDay()]);g.push(("0"+d.getDate()).slice(-2));
"short"!=c&&e.push(d.getFullYear());return e.join(" ")},dateTime:function(a,c){return UI.format.date(a,c)+", "+UI.format.time(a,c)},duration:function(a){var c=[0.001,1E3,60,60,24,7,1E9],d="ms sec min hr day week".split(" "),b={},e;for(e in d){var a=a/c[e],g=Math.round(a%c[Number(e)+1]);b[d[e]]=g;a-=g}var l;for(e=d.length-1;0<=e;e--)if(0<b[d[e]]){l=d[e];break}c=$("<span>");switch(l){case "week":c.append(UI.format.addUnit(b.week,"wks, ")).append(UI.format.addUnit(b.day,"days"));break;case "day":c.append(UI.format.addUnit(b.day, g.push("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" ")[d.getMonth()]);"short"!=c&&g.push(d.getFullYear());return g.join(" ")},dateTime:function(a,c){return UI.format.date(a,c)+", "+UI.format.time(a,c)},duration:function(a){var c=[0.001,1E3,60,60,24,7,1E9],d="ms sec min hr day week".split(" "),b={},g;for(g in d){var a=a/c[g],h=Math.round(a%c[Number(g)+1]);b[d[g]]=h;a-=h}var l;for(g=d.length-1;0<=g;g--)if(0<b[d[g]]){l=d[g];break}c=$("<span>");switch(l){case "week":c.append(UI.format.addUnit(b.week,
"days, ")).append(UI.format.addUnit(b.hr,"hrs"));break;default:c.append([("0"+b.hr).slice(-2),("0"+b.min).slice(-2),("0"+b.sec).slice(-2)+(b.ms?"."+b.ms:"")].join(":"))}return c[0].innerHTML},number:function(a){if(isNaN(Number(a))||0==a)return a;var c=Math.pow(10,3-Math.floor(Math.log(a)/Math.LN10)-1),a=Math.round(a*c)/c;if(1E4<a){number=a.toString().split(".");for(a=/(\d+)(\d{3})/;a.test(number[0]);)number[0]=number[0].replace(a,"$1 $2");a=number.join(".")}return a},status:function(a){var c=$("<span>"); "wks, ")).append(UI.format.addUnit(b.day,"days"));break;case "day":c.append(UI.format.addUnit(b.day,"days, ")).append(UI.format.addUnit(b.hr,"hrs"));break;default:c.append([("0"+b.hr).slice(-2),("0"+b.min).slice(-2),("0"+b.sec).slice(-2)+(b.ms?"."+b.ms:"")].join(":"))}return c[0].innerHTML},number:function(a){if(isNaN(Number(a))||0==a)return a;var c=Math.pow(10,3-Math.floor(Math.log(a)/Math.LN10)-1),a=Math.round(a*c)/c;if(1E4<a){number=a.toString().split(".");for(a=/(\d+)(\d{3})/;a.test(number[0]);)number[0]=
if("undefined"==typeof a.online)return c.text("Unknown, checking.."),"undefined"!=typeof a.error&&c.text(a.error),c;switch(a.online){case -1:c.text("Enabling");break;case 0:c.text("Unavailable").addClass("red");break;case 1:c.text("Active").addClass("green");break;case 2:c.text("Standby").addClass("orange");break;default:c.text(a.online)}"error"in a&&c.text(a.error);return c},capital:function(a){return a.charAt(0).toUpperCase()+a.substring(1)},addUnit:function(a,c){var d=$("<span>").html(a);d.append($("<span>").addClass("unit").html(c)); number[0].replace(a,"$1 $2");a=number.join(".")}return a},status:function(a){var c=$("<span>");if("undefined"==typeof a.online)return c.text("Unknown, checking.."),"undefined"!=typeof a.error&&c.text(a.error),c;switch(a.online){case -1:c.text("Enabling");break;case 0:c.text("Unavailable").addClass("red");break;case 1:c.text("Active").addClass("green");break;case 2:c.text("Standby").addClass("orange");break;default:c.text(a.online)}"error"in a&&c.text(a.error);return c},capital:function(a){return a.charAt(0).toUpperCase()+
return d[0].innerHTML},bytes:function(a,c){var d="bytes KiB MiB GiB TiB PiB".split(" ");if(0==a)unit=d[0];else{var b=Math.floor(Math.log(Math.abs(a))/Math.log(1024));0>b?unit=d[0]:(a/=Math.pow(1024,b),unit=d[b])}return UI.format.addUnit(UI.format.number(a),unit+(c?"/s":""))}},navto:function(a,c){var d=location.hash,b=d.split("@");b[0]=[mist.user.name,mist.user.host].join("&");b[1]=[a,c].join("&");"undefined"!=typeof screenlog&&screenlog.navto(b[1]);location.hash=b.join("@");location.hash==d&&$(window).trigger("hashchange")}, a.substring(1)},addUnit:function(a,c){var d=$("<span>").html(a);d.append($("<span>").addClass("unit").html(c));return d[0].innerHTML},bytes:function(a,c){var d="bytes KiB MiB GiB TiB PiB".split(" ");if(0==a)unit=d[0];else{var b=Math.floor(Math.log(Math.abs(a))/Math.log(1024));0>b?unit=d[0]:(a/=Math.pow(1024,b),unit=d[b])}return UI.format.addUnit(UI.format.number(a),unit+(c?"/s":""))}},navto:function(a,c){var d=location.hash,b=d.split("@");b[0]=[mist.user.name,mist.user.host].join("&");b[1]=[a,c].join("&");
showTab:function(a,c){var d=UI.elements.main;if(mist.user.loggedin&&!("ui_settings"in mist.data))d.html("Loading.."),mist.send(function(){UI.showTab(a,c)},{ui_settings:!0});else{var b=UI.elements.menu.removeClass("hide").find('.plain:contains("'+a+'")').closest(".button");0<b.length&&(UI.elements.menu.find(".button.active").removeClass("active"),b.addClass("active"));if("undefined"!=typeof mistvideo)for(var e in mistvideo)if("embedded"in mistvideo[e])for(var g in mistvideo[e].embedded)try{mistvideo[e].embedded[g].player.unload(), "undefined"!=typeof screenlog&&screenlog.navto(b[1]);location.hash=b.join("@");location.hash==d&&$(window).trigger("hashchange")},showTab:function(a,c){var d=UI.elements.main;if(mist.user.loggedin&&!("ui_settings"in mist.data))d.html("Loading.."),mist.send(function(){UI.showTab(a,c)},{ui_settings:!0});else{var b=UI.elements.menu.removeClass("hide").find('.plain:contains("'+a+'")').closest(".button");0<b.length&&(UI.elements.menu.find(".button.active").removeClass("active"),b.addClass("active"));if("undefined"!=
delete mistvideo[e].embedded[g]}catch(l){}UI.interval.clear();d.html($("<h2>").text(a));switch(a){case "Login":if(mist.user.loggedin){UI.navto("Overview");return}UI.elements.menu.addClass("hide");UI.elements.connection.status.text("Disconnected").removeClass("green").addClass("red");d.append(UI.buildUI([{type:"help",help:"Please provide your account details.<br>You were asked to set these when MistController was started for the first time. If you did not yet set any account details, log in with your desired credentials to create a new account."}, typeof mistvideo)for(var g in mistvideo)if("embedded"in mistvideo[g])for(var h in mistvideo[g].embedded)try{mistvideo[g].embedded[h].player.unload(),delete mistvideo[g].embedded[h]}catch(l){}UI.interval.clear();d.html($("<h2>").text(a));switch(a){case "Login":if(mist.user.loggedin){UI.navto("Overview");return}UI.elements.menu.addClass("hide");UI.elements.connection.status.text("Disconnected").removeClass("green").addClass("red");d.append(UI.buildUI([{type:"help",help:"Please provide your account details.<br>You were asked to set these when MistController was started for the first time. If you did not yet set any account details, log in with your desired credentials to create a new account."},
{label:"Host",help:"Url location of the MistServer API. Generally located at http://MistServerIP:4242/api","default":"http://localhost:4242/api",pointer:{main:mist.user,index:"host"}},{label:"Username",help:"Please enter your username here.",validate:["required"],pointer:{main:mist.user,index:"name"}},{label:"Password",type:"password",help:"Please enter your password here.",validate:["required"],pointer:{main:mist.user,index:"rawpassword"}},{type:"buttons",buttons:[{label:"Login",type:"save","function":function(){mist.user.password= {label:"Host",help:"Url location of the MistServer API. Generally located at http://MistServerIP:4242/api","default":"http://localhost:4242/api",pointer:{main:mist.user,index:"host"}},{label:"Username",help:"Please enter your username here.",validate:["required"],pointer:{main:mist.user,index:"name"}},{label:"Password",type:"password",help:"Please enter your password here.",validate:["required"],pointer:{main:mist.user,index:"rawpassword"}},{type:"buttons",buttons:[{label:"Login",type:"save","function":function(){mist.user.password=
MD5(mist.user.rawpassword);delete mist.user.rawpassword;mist.send(function(){UI.navto("Overview")})}}]}]));break;case "Create a new account":UI.elements.menu.addClass("hide");d.append($("<p>").text("No account has been created yet in the MistServer at ").append($("<i>").text(mist.user.host)).append("."));d.append(UI.buildUI([{type:"buttons",buttons:[{label:"Select other host",type:"cancel",css:{"float":"left"},"function":function(){UI.navto("Login")}}]},{type:"custom",custom:$("<br>")},{label:"Desired username", MD5(mist.user.rawpassword);delete mist.user.rawpassword;mist.send(function(){UI.navto("Overview")})}}]}]));break;case "Create a new account":UI.elements.menu.addClass("hide");d.append($("<p>").text("No account has been created yet in the MistServer at ").append($("<i>").text(mist.user.host)).append("."));d.append(UI.buildUI([{type:"buttons",buttons:[{label:"Select other host",type:"cancel",css:{"float":"left"},"function":function(){UI.navto("Login")}}]},{type:"custom",custom:$("<br>")},{label:"Desired username",
type:"str",validate:["required"],help:"Enter your desired username. In the future, you will need this to access the Management Interface.",pointer:{main:mist.user,index:"name"}},{label:"Desired password",type:"password",validate:["required",function(a,c){$(".match_password").not($(c)).trigger("change");return false}],help:"Enter your desired password. In the future, you will need this to access the Management Interface.",pointer:{main:mist.user,index:"rawpassword"},classes:["match_password"]},{label:"Repeat password", type:"str",validate:["required"],help:"Enter your desired username. In the future, you will need this to access the Management Interface.",pointer:{main:mist.user,index:"name"}},{label:"Desired password",type:"password",validate:["required",function(a,c){$(".match_password").not($(c)).trigger("change");return false}],help:"Enter your desired password. In the future, you will need this to access the Management Interface.",pointer:{main:mist.user,index:"rawpassword"},classes:["match_password"]},{label:"Repeat password",
type:"password",validate:["required",function(a,c){return a!=$(".match_password").not($(c)).val()?{msg:'The fields "Desired password" and "Repeat password" do not match.',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); type:"password",validate:["required",function(a,c){return a!=$(".match_password").not($(c)).val()?{msg:'The fields "Desired password" and "Repeat password" do not match.',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");d.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)d.append("Unable to enable all protocols as protocol settings already exist.<br>");else{d.append("Retrieving available protocols..<br>"); delete mist.user.rawpassword}}]}]));break;case "Account created":UI.elements.menu.addClass("hide");d.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)d.append("Unable to enable all protocols as protocol settings already exist.<br>");else{d.append("Retrieving available protocols..<br>");
mist.send(function(a){var c=[],b;for(b in a.capabilities.connectors)if(a.capabilities.connectors[b].required)d.append('Could not enable protocol "'+b+'" because it has required settings.<br>');else{c.push({connector:b});d.append('Enabled protocol "'+b+'".<br>')}d.append("Saving protocol settings..<br>");mist.send(function(){d.append("Protocols enabled. Redirecting..");setTimeout(function(){UI.navto("Overview")},5E3)},{config:{protocols:c}})},{capabilities:true})}}},{label:"Skip",type:"cancel","function":function(){UI.navto("Overview")}}]}])); mist.send(function(a){var c=[],b;for(b in a.capabilities.connectors)if(a.capabilities.connectors[b].required)d.append('Could not enable protocol "'+b+'" because it has required settings.<br>');else{c.push({connector:b});d.append('Enabled protocol "'+b+'".<br>')}d.append("Saving protocol settings..<br>");mist.send(function(){d.append("Protocols enabled. Redirecting..");setTimeout(function(){UI.navto("Overview")},5E3)},{config:{protocols:c}})},{capabilities:true})}}},{label:"Skip",type:"cancel","function":function(){UI.navto("Overview")}}]}]));
break;case "Overview":var f=$("<span>").text("Loading.."),q=$("<span>"),p=$("<span>").addClass("logs"),m=$("<span>"),u=$("<span>"),h=$("<span>").text("Unknown"),i=$("<span>"),j=$("<span>");e={serverid:mist.data.config.serverid,debug:mist.data.config.debug};d.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", break;case "Overview":var f=$("<span>").text("Loading.."),q=$("<span>"),p=$("<span>").addClass("logs"),m=$("<span>"),u=$("<span>"),e=$("<span>").text("Unknown"),i=$("<span>"),j=$("<span>");g={serverid:mist.data.config.serverid,debug:mist.data.config.debug};d.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:u},{type:"span",label:"Licensed to",value:"license"in mist.data.config?mist.data.config.license.user:"",LTSonly:!0},{type:"span",label:"Active products",value:h,LTSonly:!0},{type:"span",label:"Configured streams",value:mist.data.streams?Object.keys(mist.data.streams).length:0},{type:"span",label:"Active streams",value:q},{type:"span",label:"Current connections", pointer:{main:mist.data.config,index:"version"}},{type:"span",label:"Version check",value:f,LTSonly:!0},{type:"span",label:"Server time",value:u},{type:"span",label:"Licensed to",value:"license"in mist.data.config?mist.data.config.license.user:"",LTSonly:!0},{type:"span",label:"Active products",value:e,LTSonly:!0},{type:"span",label:"Configured streams",value:mist.data.streams?Object.keys(mist.data.streams).length:0},{type:"span",label:"Active streams",value:q},{type:"span",label:"Current connections",
value:m},{type:"span",label:"Enabled protocols",value:i},{type:"span",label:"Disabled protocols",value:j},{type:"span",label:"Recent problems",value:p},$("<br>"),{type:"str",label:"Human readable name",pointer:{main:e,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:e,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."}, value:m},{type:"span",label:"Enabled protocols",value:i},{type:"span",label:"Disabled protocols",value:j},{type:"span",label:"Recent problems",value:p},$("<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:"checkbox",label:"Force configurations save",pointer:{main:e,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:e};if(e.save)a.save=e.save;delete e.save;mist.send(function(){UI.navto("Overview")},a)}}]}]));if(mist.data.LTS){var k= {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};if(g.save)a.save=g.save;delete g.save;mist.send(function(){UI.navto("Overview")},a)}}]}]));if(mist.data.LTS){var k=
function(a){function c(a){if(a.update){var b="";"progress"in a.update&&(b=" ("+a.update.progress+"%)");f.text("Updating.."+b);setTimeout(function(){mist.send(function(a){c(a)},{update:true})},5E3)}else UI.showTab("Overview")}if(!a.update||!("uptodate"in a.update)){f.text("Unknown, checking..");setTimeout(function(){mist.send(function(a){"update"in a&&k(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"); function(a){function c(a){if(a.update){var b="";"progress"in a.update&&(b=" ("+a.update.progress+"%)");f.text("Updating.."+b);setTimeout(function(){mist.send(function(a){c(a)},{update:true})},5E3)}else UI.showTab("Overview")}if(!a.update||!("uptodate"in a.update)){f.text("Unknown, checking..");setTimeout(function(){mist.send(function(a){"update"in a&&k(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..");c(a)}else f.addClass("red").text("Version outdated!").append($("<button>").text("Update").css({"font-size":"1em","margin-left":"1em"}).click(function(){if(confirm("Are you sure you want to execute a rolling update?")){f.addClass("orange").removeClass("red").text("Rolling update command sent..");mist.send(function(a){c(a)},{autoupdate:true})}}))};k(mist.data);if("license"in mist.data.config){if("active_products"in else if(a.update.progress){f.addClass("orange").removeClass("red").text("Updating..");c(a)}else f.addClass("red").text("Version outdated!").append($("<button>").text("Update").css({"font-size":"1em","margin-left":"1em"}).click(function(){if(confirm("Are you sure you want to execute a rolling update?")){f.addClass("orange").removeClass("red").text("Rolling update command sent..");mist.send(function(a){c(a)},{autoupdate:true})}}))};k(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 z=$("<table>").css("text-indent","0");h.html(z);z.append($("<tr>").append($("<th>").append("Product")).append($("<th>").append("Updates until")).append($("<th>").append("Use until")).append($("<th>").append("Max. simul. instances")));for(g in mist.data.config.license.active_products)b=mist.data.config.license.active_products[g],z.append($("<tr>").append($("<td>").append(b.name)).append($("<td>").append(b.updates_final? mist.data.config.license&&Object.keys(mist.data.config.license.active_products).length){var z=$("<table>").css("text-indent","0");e.html(z);z.append($("<tr>").append($("<th>").append("Product")).append($("<th>").append("Updates until")).append($("<th>").append("Use until")).append($("<th>").append("Max. simul. instances")));for(h in mist.data.config.license.active_products)b=mist.data.config.license.active_products[h],z.append($("<tr>").append($("<td>").append(b.name)).append($("<td>").append(b.updates_final?
b.updates_final:"&infin;")).append($("<td>").append(b.use_final?b.use_final:"&infin;")).append($("<td>").append(b.amount?b.amount:"&infin;")))}else h.text("None. ");h.append($("<a>").text("More details").attr("href","https://shop.mistserver.org/myinvoices").attr("target","_blank"))}}else f.text("");g=function(){var a={totals:{fields:["clients"],start:-10},active_streams:true};if(!("cabailities"in mist.data))a.capabilities=true;mist.send(function(){ga()},a)};var ga=function(){q.text("active_streams"in b.updates_final:"&infin;")).append($("<td>").append(b.use_final?b.use_final:"&infin;")).append($("<td>").append(b.amount?b.amount:"&infin;")))}else e.text("None. ");e.append($("<a>").text("More details").attr("href","https://shop.mistserver.org/myinvoices").attr("target","_blank"))}}else f.text("");h=function(){var a={totals:{fields:["clients"],start:-10},active_streams:true};if(!("cabailities"in mist.data))a.capabilities=true;mist.send(function(){ga()},a)};var ga=function(){q.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..";m.text(a);u.text(UI.format.dateTime(mist.data.config.time,"long"));p.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]); 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..";m.text(a);u.text(UI.format.dateTime(mist.data.config.time,"long"));p.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 c in mist.data.log){var b=mist.data.log[c];if(["FAIL","ERROR"].indexOf(b[1])>-1){a++;var d=$("<span>").addClass("content").addClass("red"),g=b[2].split("|");for(c in g)d.append($("<span>").text(g[c]));p.append($("<div>").append($("<span>").append(UI.format.time(b[0]))).append(d));if(a==5)break}}a==0&&p.html("None.");a=[];b=[];for(c in mist.data.config.protocols){d=mist.data.config.protocols[c];a.indexOf(d.connector)>-1||a.push(d.connector)}i.text(a.length?a.join(", "):"None.");if("capabilities"in for(var c in mist.data.log){var b=mist.data.log[c];if(["FAIL","ERROR"].indexOf(b[1])>-1){a++;var d=$("<span>").addClass("content").addClass("red"),h=b[2].split("|");for(c in h)d.append($("<span>").text(h[c]));p.append($("<div>").append($("<span>").append(UI.format.time(b[0]))).append(d));if(a==5)break}}a==0&&p.html("None.");a=[];b=[];for(c in mist.data.config.protocols){d=mist.data.config.protocols[c];a.indexOf(d.connector)>-1||a.push(d.connector)}i.text(a.length?a.join(", "):"None.");if("capabilities"in
mist.data){for(c in mist.data.capabilities.connectors)a.indexOf(c)==-1&&b.push(c);j.text(b.length?b.join(", "):"None.")}else j.text("Loading..")};g();ga();UI.interval.set(g,3E4);break;case "Protocols":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});d.append("Loading..");return}var x=$("<tbody>");d.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.data){for(c in mist.data.capabilities.connectors)a.indexOf(c)==-1&&b.push(c);j.text(b.length?b.join(", "):"None.")}else j.text("Loading..")};h();ga();UI.interval.set(h,3E4);break;case "Protocols":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});d.append("Loading..");return}var x=$("<tbody>");d.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),c;for(c in mist.data.config.protocols){var b=a.indexOf(mist.data.config.protocols[c].connector);b>-1&&a.splice(b,1)}var d=[];for(c in a)(!("required"in mist.data.capabilities.connectors[a[c]])||Object.keys(mist.data.capabilities.connectors[a[c]].required).length==0)&&d.push(a[c]);b="Click OK to enable disabled protocols with their default settings:\n "; [];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),c;for(c in mist.data.config.protocols){var b=a.indexOf(mist.data.config.protocols[c].connector);b>-1&&a.splice(b,1)}var d=[];for(c in a)(!("required"in mist.data.capabilities.connectors[a[c]])||Object.keys(mist.data.capabilities.connectors[a[c]].required).length==0)&&d.push(a[c]);b="Click OK to enable disabled protocols with their default settings:\n ";
b=d.length?b+d.join(", "):b+"None.";if(d.length!=a.length){a=a.filter(function(a){return d.indexOf(a)<0});b=b+("\n\nThe following protocols can only be set manually:\n "+a.join(", "))}if(confirm(b)&&d.length){for(c in d)mist.data.config.protocols.push({connector:d[c]});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(x)); b=d.length?b+d.join(", "):b+"None.";if(d.length!=a.length){a=a.filter(function(a){return d.indexOf(a)<0});b=b+("\n\nThe following protocols can only be set manually:\n "+a.join(", "))}if(confirm(b)&&d.length){for(c in d)mist.data.config.protocols.push({connector:d[c]});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(x));
var ha=function(){function a(c){var b=mist.data.capabilities.connectors[c.connector];if(!b)return"";var d=[],g=["required","optional"],F;for(F in g)for(var h in b[g[F]])c[h]&&c[h]!=""?d.push(h+": "+c[h]):b[g[F]][h]["default"]&&d.push(h+": "+b[g[F]][h]["default"]);return $("<span>").addClass("description").text(d.join(", "))}x.html("");for(var c in mist.data.config.protocols){var b=mist.data.config.protocols[c];x.append($("<tr>").data("index",c).append($("<td>").text(b.connector)).append($("<td>").html(UI.format.status(b))).append($("<td>").html(a(b))).append($("<td>").css("text-align", var ha=function(){function a(c){var b=mist.data.capabilities.connectors[c.connector];if(!b)return"";var d=[],h=["required","optional"],F;for(F in h)for(var g in b[h[F]])c[g]&&c[g]!=""?d.push(g+": "+c[g]):b[h[F]][g]["default"]&&d.push(g+": "+b[h[F]][g]["default"]);return $("<span>").addClass("description").text(d.join(", "))}x.html("");for(var c in mist.data.config.protocols){var b=mist.data.config.protocols[c];x.append($("<tr>").data("index",c).append($("<td>").text(b.connector)).append($("<td>").html(UI.format.status(b))).append($("<td>").html(a(b))).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)}}))))}};ha();UI.interval.set(function(){mist.send(function(){ha()})}, "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)}}))))}};ha();UI.interval.set(function(){mist.send(function(){ha()})},
1E4);break;case "Edit Protocol":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});d.append("Loading..");return}var D=!1;""!=c&&0<=c&&(D=!0);var L={};for(g in mist.data.config.protocols)L[mist.data.config.protocols[g].connector]=1;var ia=function(a){var c=mist.data.capabilities.connectors[a],b=mist.convertBuildOptions(c,n);if(D)var d=$.extend({},n);b.push({type:"hidden",pointer:{main:n,index:"connector"},value:a});b.push({type:"buttons",buttons:[{type:"save", 1E4);break;case "Edit Protocol":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});d.append("Loading..");return}var D=!1;""!=c&&0<=c&&(D=!0);var L={};for(h in mist.data.config.protocols)L[mist.data.config.protocols[h].connector]=1;var ia=function(a){var c=mist.data.capabilities.connectors[a],b=mist.convertBuildOptions(c,n);if(D)var d=$.extend({},n);b.push({type:"hidden",pointer:{main:n,index:"connector"},value:a});b.push({type:"buttons",buttons:[{type:"save",
label:"Save","function":function(){var a={};D?a.updateprotocol=[d,n]:a.addprotocol=n;mist.send(function(){UI.navto("Protocols")},a)}},{type:"cancel",label:"Cancel","function":function(){UI.navto("Protocols")}}]});if("deps"in c&&c.deps!=""){z=$("<span>").text("Dependencies:");$ul=$("<ul>");z.append($ul);if(typeof c.deps=="string")c.deps=c.deps.split(", ");for(var g in c.deps){a=$("<li>").text(c.deps[g]+" ");$ul.append(a);typeof L[c.deps[g]]!="undefined"||typeof L[c.deps[g]+".exe"]!="undefined"?a.append($("<span>").addClass("green").text("(Configured)")): label:"Save","function":function(){var a={};D?a.updateprotocol=[d,n]:a.addprotocol=n;mist.send(function(){UI.navto("Protocols")},a)}},{type:"cancel",label:"Cancel","function":function(){UI.navto("Protocols")}}]});if("deps"in c&&c.deps!=""){z=$("<span>").text("Dependencies:");$ul=$("<ul>");z.append($ul);if(typeof c.deps=="string")c.deps=c.deps.split(", ");for(var h in c.deps){a=$("<li>").text(c.deps[h]+" ");$ul.append(a);typeof L[c.deps[h]]!="undefined"||typeof L[c.deps[h]+".exe"]!="undefined"?a.append($("<span>").addClass("green").text("(Configured)")):
a.append($("<span>").addClass("red").text("(Not yet configured)"))}b.unshift({type:"text",text:z[0].innerHTML})}return UI.buildUI(b)},L={};for(g in mist.data.config.protocols)L[mist.data.config.protocols[g].connector]=1;if(D){var r=mist.data.config.protocols[c],n=r;d.find("h2").append(' "'+r.connector+'"');d.append(ia(r.connector))}else{d.html($("<h2>").text("New Protocol"));var n={},s=[["",""]];for(g in mist.data.capabilities.connectors)s.push([g,g]);var J=$("<span>");d.append(UI.buildUI([{label:"Protocol", a.append($("<span>").addClass("red").text("(Not yet configured)"))}b.unshift({type:"text",text:z[0].innerHTML})}return UI.buildUI(b)},L={};for(h in mist.data.config.protocols)L[mist.data.config.protocols[h].connector]=1;if(D){var r=mist.data.config.protocols[c],n=r;d.find("h2").append(' "'+r.connector+'"');d.append(ia(r.connector))}else{d.html($("<h2>").text("New Protocol"));var n={},s=[["",""]];for(h in mist.data.capabilities.connectors)s.push([h,h]);var J=$("<span>");d.append(UI.buildUI([{label:"Protocol",
type:"select",select:s,"function":function(){$(this).getval()!=""&&J.html(ia($(this).getval()))}}])).append(J)}break;case "Streams":if(!("capabilities"in mist.data)){d.html("Loading..");mist.send(function(){UI.navto(a)},{capabilities:!0});return}g=$("<button>");var E=$("<span>").text("Loading..");d.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", type:"select",select:s,"function":function(){$(this).getval()!=""&&J.html(ia($(this).getval()))}}])).append(J)}break;case "Streams":if(!("capabilities"in mist.data)){d.html("Loading..");mist.send(function(){UI.navto(a)},{capabilities:!0});return}h=$("<button>");var E=$("<span>").text("Loading..");d.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(g).append($("<button>").text("Create a new stream").click(function(){UI.navto("Edit")}))])).append(E);""==c&&(e=mist.stored.get(),"viewmode"in e&&(c=e.viewmode));g.text("Switch to "+("thumbnails"==c?"list":"thumbnail")+" view").click(function(){mist.stored.set("viewmode",c=="thumbnails"?"list":"thumbnails");UI.navto("Streams",c=="thumbnails"?"list":"thumbnails")});var y=$.extend(!0,{},mist.data.streams),U=function(a,c){var b=$.extend({},c);delete b.meta;delete b.error; "justify-content":"flex-end"}).append(h).append($("<button>").text("Create a new stream").click(function(){UI.navto("Edit")}))])).append(E);""==c&&(g=mist.stored.get(),"viewmode"in g&&(c=g.viewmode));h.text("Switch to "+("thumbnails"==c?"list":"thumbnail")+" view").click(function(){mist.stored.set("viewmode",c=="thumbnails"?"list":"thumbnails");UI.navto("Streams",c=="thumbnails"?"list":"thumbnails")});var y=$.extend(!0,{},mist.data.streams),V=function(a,c){var b=$.extend({},c);delete b.meta;delete b.error;
b.online=2;b.name=a;b.ischild=true;return b},V=function(c,b,g){E.remove();switch(c){case "thumbnails":var h=$("<div>").addClass("preview_icons"),e;e=g||[];b.sort();b.unshift("");E.remove();d.append($("<h2>").text(a)).append(UI.buildUI([{label:"Filter the streams",type:"datalist",datalist:b,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();h.children().each(function(){$(this).hide(); b.online=2;b.name=a;b.ischild=true;return b},W=function(c,b,h){E.remove();switch(c){case "thumbnails":var g=$("<div>").addClass("preview_icons"),e;e=h||[];b.sort();b.unshift("");E.remove();d.append($("<h2>").text(a)).append(UI.buildUI([{label:"Filter the streams",type:"datalist",datalist:b,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();g.children().each(function(){$(this).hide();
$(this).attr("data-stream").indexOf(a)>-1&&$(this).show()})}}]));b.shift();d.append($("<span>").addClass("description").text("Choose a stream below.")).append(h);for(var f in b){var c=b[f],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 c={};c.deletestream=[a];mist.send(function(){UI.navto("Streams")},c)}}),k=$("<button>").text("Settings").click(function(){UI.navto("Edit", $(this).attr("data-stream").indexOf(a)>-1&&$(this).show()})}}]));b.shift();d.append($("<span>").addClass("description").text("Choose a stream below.")).append(g);for(var f in b){var c=b[f],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 c={};c.deletestream=[a];mist.send(function(){UI.navto("Streams")},c)}}),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"))}),l=$("<button>").text("Embed").click(function(){UI.navto("Embed",$(this).closest("div").attr("data-stream"))}),m=$("<span>").addClass("image");if(c.indexOf("+")>-1){i=c.split("+");i=mist.data.streams[i[0]].source+i[1];k=j="";m.addClass("wildcard")}else{i=mist.data.streams[c].source;if(e.indexOf(c)>-1){l=g="";m.addClass("folder")}}h.append($("<div>").append($("<span>").addClass("streamname").text(c)).append(m).append($("<span>").addClass("description").text(i)).append($("<span>").addClass("button_container").append(k).append(j).append(g).append(l)).attr("title", $(this).closest("div").attr("data-stream"))}),h=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("div").attr("data-stream"))}),l=$("<button>").text("Embed").click(function(){UI.navto("Embed",$(this).closest("div").attr("data-stream"))}),m=$("<span>").addClass("image");if(c.indexOf("+")>-1){i=c.split("+");i=mist.data.streams[i[0]].source+i[1];k=j="";m.addClass("wildcard")}else{i=mist.data.streams[c].source;if(e.indexOf(c)>-1){l=h="";m.addClass("folder")}}g.append($("<div>").append($("<span>").addClass("streamname").text(c)).append(m).append($("<span>").addClass("description").text(i)).append($("<span>").addClass("button_container").append(k).append(j).append(h).append(l)).attr("title",
c).attr("data-stream",c))}break;default:var n=$("<tbody>").append($("<tr>").append("<td>").attr("colspan",6).text("Loading.."));f=$("<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(n); c).attr("data-stream",c))}break;default:var n=$("<tbody>").append($("<tr>").append("<td>").attr("colspan",6).text("Loading.."));f=$("<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(n);
d.append(f);f.stupidtable();var o=function(){var a=[],c;for(c in mist.data.active_streams)a.push({streams:[mist.data.active_streams[c]],fields:["clients"],start:-2});mist.send(function(){$.extend(true,y,mist.data.streams);var a=0;n.html("");b.sort();for(var c in b){var d=b[c],g;g=d in mist.data.streams?mist.data.streams[d]:y[d];var h=$("<td>").css("text-align","right").html($("<span>").addClass("description").text("Loading..")),e=0;if(typeof mist.data.totals!="undefined"&&typeof mist.data.totals[d]!= d.append(f);f.stupidtable();var o=function(){var a=[],c;for(c in mist.data.active_streams)a.push({streams:[mist.data.active_streams[c]],fields:["clients"],start:-2});mist.send(function(){$.extend(true,y,mist.data.streams);var a=0;n.html("");b.sort();for(var c in b){var d=b[c],h;h=d in mist.data.streams?mist.data.streams[d]:y[d];var g=$("<td>").css("text-align","right").html($("<span>").addClass("description").text("Loading..")),e=0;if(typeof mist.data.totals!="undefined"&&typeof mist.data.totals[d]!=
"undefined"){var f=mist.data.totals[d].all_protocols.clients,e=0;if(f.length){for(a in f)e=e+f[a][1];e=Math.round(e/f.length)}}h.html(UI.format.number(e));if(e==0&&g.online==1)g.online=2;e=$("<td>").css("text-align","right").css("white-space","nowrap");(!("ischild"in g)||!g.ischild)&&e.html($("<button>").text("Settings").click(function(){UI.navto("Edit",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the stream "'+ "undefined"){var f=mist.data.totals[d].all_protocols.clients,e=0;if(f.length){for(a in f)e=e+f[a][1];e=Math.round(e/f.length)}}g.html(UI.format.number(e));if(e==0&&h.online==1)h.online=2;e=$("<td>").css("text-align","right").css("white-space","nowrap");(!("ischild"in h)||!h.ischild)&&e.html($("<button>").text("Settings").click(function(){UI.navto("Edit",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the stream "'+
a+'"?')){delete mist.data.streams[a];var c={};mist.data.LTS?c.deletestream=[a]:c.streams=mist.data.streams;mist.send(function(){UI.navto("Streams")},c)}}));f=$("<span>").text(d);g.ischild&&f.css("padding-left","1em");var F=UI.format.status(g),i=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("tr").data("index"))}),j=$("<button>").text("Embed").click(function(){UI.navto("Embed",$(this).closest("tr").data("index"))});if("filesfound"in y[d]){F.html("");i="";h.html(""); a+'"?')){delete mist.data.streams[a];var c={};mist.data.LTS?c.deletestream=[a]:c.streams=mist.data.streams;mist.send(function(){UI.navto("Streams")},c)}}));f=$("<span>").text(d);h.ischild&&f.css("padding-left","1em");var F=UI.format.status(h),i=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("tr").data("index"))}),ja=$("<button>").text("Embed").click(function(){UI.navto("Embed",$(this).closest("tr").data("index"))});if("filesfound"in y[d]){F.html("");i="";g.html("");
j=""}n.append($("<tr>").data("index",d).html($("<td>").html(f).attr("title",d).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(F)).append(h).append($("<td>").css("white-space","nowrap").html(i).append(j)).append(e));a++}},{totals:a,active_streams:true})};if(mist.data.LTS){var p=0,q=0;for(e in mist.data.streams){f=mist.data.capabilities.inputs.Folder|| ja=""}n.append($("<tr>").data("index",d).html($("<td>").html(f).attr("title",d).addClass("overflow_ellipsis")).append($("<td>").text(h.source).attr("title",h.source).addClass("description").addClass("overflow_ellipsis").css("max-width","20em")).append($("<td>").data("sort-value",h.online).html(F)).append(g).append($("<td>").css("white-space","nowrap").html(i).append(ja)).append(e));a++}},{totals:a,active_streams:true})};if(mist.data.LTS){var p=0,q=0;for(e in mist.data.streams){f=mist.data.capabilities.inputs.Folder||
mist.data.capabilities.inputs["Folder.exe"];if(!f)break;if(mist.inputMatch(f.source_match,mist.data.streams[e].source)){y[e].source=y[e].source+"*";y[e].filesfound=null;mist.send(function(a,c){var b=c.stream,d;for(d in a.browse.files)for(var g in mist.data.capabilities.inputs)if(!(g.indexOf("Buffer")>=0||g.indexOf("Buffer.exe")>=0||g.indexOf("Folder")>=0||g.indexOf("Folder.exe")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[g].source_match,"/"+a.browse.files[d])){var e=b+"+"+a.browse.files[d]; mist.data.capabilities.inputs["Folder.exe"];if(!f)break;if(mist.inputMatch(f.source_match,mist.data.streams[e].source)){y[e].source=y[e].source+"*";y[e].filesfound=null;mist.send(function(a,c){var b=c.stream,d;for(d in a.browse.files)for(var h in mist.data.capabilities.inputs)if(!(h.indexOf("Buffer")>=0||h.indexOf("Buffer.exe")>=0||h.indexOf("Folder")>=0||h.indexOf("Folder.exe")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[h].source_match,"/"+a.browse.files[d])){var e=b+"+"+a.browse.files[d];
y[e]=U(e,mist.data.streams[b]);y[e].source=mist.data.streams[b].source+a.browse.files[d]}"files"in a.browse&&a.browse.files.length?y[b].filesfound=true:mist.data.streams[b].filesfound=false;q++;if(p==q){mist.send(function(){o()},{active_streams:true});UI.interval.set(function(){o()},5E3)}},{browse:mist.data.streams[e].source},{stream:e});p++}}if(p==0){mist.send(function(){o()},{active_streams:true});UI.interval.set(function(){o()},5E3)}}else{mist.send(function(){o()},{active_streams:true});UI.interval.set(function(){o()}, y[e]=V(e,mist.data.streams[b]);y[e].source=mist.data.streams[b].source+a.browse.files[d]}"files"in a.browse&&a.browse.files.length?y[b].filesfound=true:mist.data.streams[b].filesfound=false;q++;if(p==q){mist.send(function(){o()},{active_streams:true});UI.interval.set(function(){o()},5E3)}},{browse:mist.data.streams[e].source},{stream:e});p++}}if(p==0){mist.send(function(){o()},{active_streams:true});UI.interval.set(function(){o()},5E3)}}else{mist.send(function(){o()},{active_streams:true});UI.interval.set(function(){o()},
5E3)}}};if(mist.data.LTS){var W=0,ja=0,s={},ka=[];for(e in mist.data.streams)if(mist.inputMatch((mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"]).source_match,mist.data.streams[e].source))ka.push(e),mist.send(function(a,b){var d=b.stream,g;for(g in a.browse.files)for(var e in mist.data.capabilities.inputs)e.indexOf("Buffer")>=0||e.indexOf("Folder")>=0||mist.inputMatch(mist.data.capabilities.inputs[e].source_match,"/"+a.browse.files[g])&&(s[d+"+"+a.browse.files[g]]= 5E3)}}};if(mist.data.LTS){var X=0,ka=0,s={},la=[];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))la.push(g),mist.send(function(a,b){var d=b.stream,h;for(h in a.browse.files)for(var e in mist.data.capabilities.inputs)e.indexOf("Buffer")>=0||e.indexOf("Folder")>=0||mist.inputMatch(mist.data.capabilities.inputs[e].source_match,"/"+a.browse.files[h])&&(s[d+"+"+a.browse.files[h]]=
true);ja++;W==ja&&mist.send(function(){for(var a in mist.data.active_streams){var b=mist.data.active_streams[a].split("+");if(b.length>1&&b[0]in mist.data.streams){s[mist.data.active_streams[a]]=true;y[mist.data.active_streams[a]]=U(mist.data.active_streams[a],mist.data.streams[b[0]])}}s=Object.keys(s);s=s.concat(Object.keys(mist.data.streams));s.sort();V(c,s,ka)},{active_streams:true})},{browse:mist.data.streams[e].source},{stream:e}),W++;0==W&&mist.send(function(){for(var a in mist.data.active_streams){var b= true);ka++;X==ka&&mist.send(function(){for(var a in mist.data.active_streams){var b=mist.data.active_streams[a].split("+");if(b.length>1&&b[0]in mist.data.streams){s[mist.data.active_streams[a]]=true;y[mist.data.active_streams[a]]=V(mist.data.active_streams[a],mist.data.streams[b[0]])}}s=Object.keys(s);s=s.concat(Object.keys(mist.data.streams));s.sort();W(c,s,la)},{active_streams:true})},{browse:mist.data.streams[g].source},{stream:g}),X++;0==X&&mist.send(function(){for(var a in mist.data.active_streams){var b=
mist.data.active_streams[a].split("+");if(b.length>1&&b[0]in mist.data.streams){s[mist.data.active_streams[a]]=true;y[mist.data.active_streams[a]]=U(mist.data.active_streams[a],mist.data.streams[b[0]])}}s=Object.keys(s);mist.data.streams&&(s=s.concat(Object.keys(mist.data.streams)));s.sort();V(c,s)},{active_streams:!0})}else V(c,Object.keys(mist.data.streams));break;case "Edit":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});d.append("Loading.."); mist.data.active_streams[a].split("+");if(b.length>1&&b[0]in mist.data.streams){s[mist.data.active_streams[a]]=true;y[mist.data.active_streams[a]]=V(mist.data.active_streams[a],mist.data.streams[b[0]])}}s=Object.keys(s);mist.data.streams&&(s=s.concat(Object.keys(mist.data.streams)));s.sort();W(c,s)},{active_streams:!0})}else W(c,Object.keys(mist.data.streams));break;case "Edit":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});d.append("Loading..");
return}D=!1;""!=c&&(D=!0);D?(h=c,n=mist.data.streams[h],d.find("h2").append(' "'+h+'"')):(d.html($("<h2>").text("New Stream")),n={});h=[];for(g in mist.data.capabilities.inputs)h.push(mist.data.capabilities.inputs[g].source_match);var Q=$("<div>"),la=function(a){var b={};if(!mist.data.streams)mist.data.streams={};mist.data.streams[n.name]=n;c!=n.name&&delete mist.data.streams[c];b.addstream={};b.addstream[n.name]=n;if(c!=n.name)b.deletestream=[c];if(n.stop_sessions&&c!=""){b.stop_sessions=c;delete n.stop_sessions}mist.send(function(){delete mist.data.streams[n.name].online; return}D=!1;""!=c&&(D=!0);D?(e=c,n=mist.data.streams[e],d.find("h2").append(' "'+e+'"')):(d.html($("<h2>").text("New Stream")),n={});e=[];for(h in mist.data.capabilities.inputs)e.push(mist.data.capabilities.inputs[h].source_match);var Q=$("<div>"),ma=function(a){var b={};if(!mist.data.streams)mist.data.streams={};mist.data.streams[n.name]=n;c!=n.name&&delete mist.data.streams[c];b.addstream={};b.addstream[n.name]=n;if(c!=n.name)b.deletestream=[c];if(n.stop_sessions&&c!=""){b.stop_sessions=c;delete n.stop_sessions}mist.send(function(){delete mist.data.streams[n.name].online;
delete mist.data.streams[n.name].error;UI.navto(a,a=="Preview"?n.name:"")},b)},ma=$("<style>").text("button.saveandpreview { display: none; }"),G=$("<span>"),X=function(){var a=d.find("[name=name]").val();if(a){var c=parseURL(mist.user.host),b=d.find("[name=source]").val(),g=b.match(/@.*/);g&&(g=g[0].substring(1));var e=b.replace(/(?:.+?):\/\//,""),e=e.split("/"),e=e[0],e=e.split(":"),e=e[0];(b=b.match(/:\d+/))&&(b=b[0]);var h={},f=["RTMP","RTSP","TS","RTMP.exe","RTSP.exe","TS.exe"],i;for(i in f)f[i]in delete mist.data.streams[n.name].error;UI.navto(a,a=="Preview"?n.name:"")},b)},na=$("<style>").text("button.saveandpreview { display: none; }"),G=$("<span>"),Y=function(){var a=d.find("[name=name]").val();if(a){var c=parseURL(mist.user.host),b=d.find("[name=source]").val(),h=b.match(/@.*/);h&&(h=h[0].substring(1));var e=b.replace(/(?:.+?):\/\//,""),e=e.split("/"),e=e[0],e=e.split(":"),e=e[0];(b=b.match(/:\d+/))&&(b=b[0]);var g={},f=["RTMP","RTSP","TS","RTMP.exe","RTSP.exe","TS.exe"],i;for(i in f)f[i]in
mist.data.capabilities.connectors&&(h[f[i]]=mist.data.capabilities.connectors[f[i]].optional.port["default"]);var f={RTMP:1935,"RTMP.exe":1935,RTSP:554,"RTSP.exe":554,TS:-1,"TS.exe":-1},j;for(j in h){for(i in mist.data.config.protocols){var k=mist.data.config.protocols[i];if(k.connector==j){if("port"in k)h[j]=k.port;break}}h[j]=h[j]==f[j]?"":":"+h[j]}G.find(".field").closest("label").hide();for(i in h){var l;j=b?b:h[i];switch(i){case "RTMP":case "RTMP.exe":l="rtmp://"+c.host+j+"/"+(g?g:"live")+"/"; mist.data.capabilities.connectors&&(g[f[i]]=mist.data.capabilities.connectors[f[i]].optional.port["default"]);var f={RTMP:1935,"RTMP.exe":1935,RTSP:554,"RTSP.exe":554,TS:-1,"TS.exe":-1},j;for(j in g){for(i in mist.data.config.protocols){var k=mist.data.config.protocols[i];if(k.connector==j){if("port"in k)g[j]=k.port;break}}g[j]=g[j]==f[j]?"":":"+g[j]}G.find(".field").closest("label").hide();for(i in g){var l;j=b?b:g[i];switch(i){case "RTMP":case "RTMP.exe":l="rtmp://"+c.host+j+"/"+(h?h:"live")+"/";
G.find(".field.RTMPurl").setval(l).closest("label").show();G.find(".field.RTMPkey").setval(a==""?"STREAMNAME":a).closest("label").show();l=l+(a==""?"STREAMNAME":a);break;case "RTSP":case "RTSP.exe":l="rtsp://"+c.host+j+"/"+(a==""?"STREAMNAME":a)+(g?"?pass="+g:"");break;case "TS":case "TS.exe":l="udp://"+(e==""?c.host:e)+j+"/"}G.find(".field."+i.replace(".exe","")).setval(l).closest("label").show()}}};d.append(UI.buildUI([{label:"Stream name",type:"str",validate:["required","streamname"],pointer:{main:n, G.find(".field.RTMPurl").setval(l).closest("label").show();G.find(".field.RTMPkey").setval(a==""?"STREAMNAME":a).closest("label").show();l=l+(a==""?"STREAMNAME":a);break;case "RTSP":case "RTSP.exe":l="rtsp://"+c.host+j+"/"+(a==""?"STREAMNAME":a)+(h?"?pass="+h:"");break;case "TS":case "TS.exe":l="udp://"+(e==""?c.host:e)+j+"/"}G.find(".field."+i.replace(".exe","")).setval(l).closest("label").show()}}};d.append(UI.buildUI([{label:"Stream name",type:"str",validate:["required","streamname"],pointer:{main:n,
index:"name"},help:"Set the name this stream will be recognised by for players and/or stream pushing."},{label:"Source",type:"browse",filetypes:h,pointer:{main:n,index:"source"},help:"<p>Below is the explanation of the input methods for MistServer. Anything between brackets () will go to default settings if not specified.</p><table><tr><td>File input</td><td>Syntax</td><td>Explanation</td></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<br>(Pro&nbsp;only)</th><td>Linux/MacOS:&nbsp;/PATH/<br>Windows:&nbsp;/cygdrive/DRIVE/PATH/</td><td>A folder stream makes all the recognised files in the selected folder available as a stream.</td></tr><tr><td>Push input</td><td>Syntax</td><td>Explanation</td></tr><tr><th>RTMP</th><td>push://(IP)(@PASSWORD)</td><td>IP is white listed IP for pushing towards MistServer, if left empty all are white listed.<br>PASSWORD is the application under which to push to MistServer, if it doesn't match the stream will be rejected. PASSWORD is MistServer Pro only. <tr><th>RTSP<br>(Pro&nbsp;only)</th><td>push://(IP)(@PASSWORD)</td><td>IP is white listed IP for pushing towards MistServer, if left empty all are white listed.</td></tr> <tr><th>TS<br>(Pro&nbsp;only)</th><td>tsudp://(IP):PORT(/INTERFACE)</td><td>IP is the IP address used to listen for this stream, multi-cast IP range is: 224.0.0.0 - 239.255.255.255. If IP is not set all addresses will listened to.<br>PORT is the port you reserve for this stream on the chosen IP.<br>INTERFACE is the interface used, if left all interfaces will be used.</td></tr><tr><td>Pull input</td><td>Syntax</td><td>Explanation</td></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<br>(Pro&nbsp;only)</th><td>http://URL/TO/STREAM.m3u8</td><td>The URL where the HLS stream is available to MistServer.</td></tr></table>", index:"name"},help:"Set the name this stream will be recognised by for players and/or stream pushing."},{label:"Source",type:"browse",filetypes:e,pointer:{main:n,index:"source"},help:"<p>Below is the explanation of the input methods for MistServer. Anything between brackets () will go to default settings if not specified.</p><table><tr><td>File input</td><td>Syntax</td><td>Explanation</td></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<br>(Pro&nbsp;only)</th><td>Linux/MacOS:&nbsp;/PATH/<br>Windows:&nbsp;/cygdrive/DRIVE/PATH/</td><td>A folder stream makes all the recognised files in the selected folder available as a stream.</td></tr><tr><td>Push input</td><td>Syntax</td><td>Explanation</td></tr><tr><th>RTMP</th><td>push://(IP)(@PASSWORD)</td><td>IP is white listed IP for pushing towards MistServer, if left empty all are white listed.<br>PASSWORD is the application under which to push to MistServer, if it doesn't match the stream will be rejected. PASSWORD is MistServer Pro only. <tr><th>RTSP<br>(Pro&nbsp;only)</th><td>push://(IP)(@PASSWORD)</td><td>IP is white listed IP for pushing towards MistServer, if left empty all are white listed.</td></tr> <tr><th>TS<br>(Pro&nbsp;only)</th><td>tsudp://(IP):PORT(/INTERFACE)</td><td>IP is the IP address used to listen for this stream, multi-cast IP range is: 224.0.0.0 - 239.255.255.255. If IP is not set all addresses will listened to.<br>PORT is the port you reserve for this stream on the chosen IP.<br>INTERFACE is the interface used, if left all interfaces will be used.</td></tr><tr><td>Pull input</td><td>Syntax</td><td>Explanation</td></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<br>(Pro&nbsp;only)</th><td>http://URL/TO/STREAM.m3u8</td><td>The URL where the HLS stream is available to MistServer.</td></tr></table>",
"function":function(){var a=$(this).val();ma.remove();G.html("");if(a!=""){var c=null,b;for(b in mist.data.capabilities.inputs)if(typeof mist.data.capabilities.inputs[b].source_match!="undefined"&&mist.inputMatch(mist.data.capabilities.inputs[b].source_match,a)){c=b;break}if(c===null)Q.html($("<h3>").text("Unrecognized input").addClass("red")).append($("<span>").text("Please edit the stream source.").addClass("red"));else{c=mist.data.capabilities.inputs[c];Q.html($("<h3>").text(c.name+" Input options")); "function":function(){var a=$(this).val();na.remove();G.html("");if(a!=""){var c=null,b;for(b in mist.data.capabilities.inputs)if(typeof mist.data.capabilities.inputs[b].source_match!="undefined"&&mist.inputMatch(mist.data.capabilities.inputs[b].source_match,a)){c=b;break}if(c===null)Q.html($("<h3>").text("Unrecognized input").addClass("red")).append($("<span>").text("Please edit the stream source.").addClass("red"));else{c=mist.data.capabilities.inputs[c];Q.html($("<h3>").text(c.name+" Input options"));
var g=mist.convertBuildOptions(c,n);"always_match"in mist.data.capabilities.inputs[b]&&mist.inputMatch(mist.data.capabilities.inputs[b].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:n,index:"always_on"}});Q.append(UI.buildUI(g));if(c.name=="Folder")d.append(ma);else if(["Buffer","Buffer.exe","TS","TS.exe"].indexOf(c.name)>-1){a=[$("<span>").text("Configure your source to push to:")];switch(c.name){case "Buffer":case "Buffer.exe":a.push({label:"RTMP full url", var h=mist.convertBuildOptions(c,n);"always_match"in mist.data.capabilities.inputs[b]&&mist.inputMatch(mist.data.capabilities.inputs[b].always_match,a)&&h.push({label:"Always on",type:"checkbox",help:"Keep this input available at all times, even when there are no active viewers.",pointer:{main:n,index:"always_on"}});Q.append(UI.buildUI(h));if(c.name=="Folder")d.append(na);else if(["Buffer","Buffer.exe","TS","TS.exe"].indexOf(c.name)>-1){a=[$("<span>").text("Configure your source to push to:")];switch(c.name){case "Buffer":case "Buffer.exe":a.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"});a.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"});a.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"});a.push({label:"RTSP",type:"span",clipboard:true,readonly:true,classes:["RTSP"]}); type:"span",clipboard:true,readonly:true,classes:["RTMP"],help:"Use this RTMP url if your client doesn't ask for a stream key"});a.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"});a.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"});a.push({label:"RTSP",type:"span",clipboard:true,readonly:true,classes:["RTSP"]});
break;case "TS":case "TS.exe":a.push({label:"TS",type:"span",clipboard:true,readonly:true,classes:["TS"]})}G.html("<br>").append(UI.buildUI(a));X()}}}}},{label:"Stop sessions",type:"checkbox",help:"When saving these stream settings, kill this stream's current connections.",LTSonly:!0,pointer:{main:n,index:"stop_sessions"}},G,$("<br>"),{type:"custom",custom:Q},$("<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."}, break;case "TS":case "TS.exe":a.push({label:"TS",type:"span",clipboard:true,readonly:true,classes:["TS"]})}G.html("<br>").append(UI.buildUI(a));Y()}}}}},{label:"Stop sessions",type:"checkbox",help:"When saving these stream settings, kill this stream's current connections.",LTSonly:!0,pointer:{main:n,index:"stop_sessions"}},G,$("<br>"),{type:"custom",custom:Q},$("<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:n,index:"la_url"}},$("<br>"),{label:"Content key",type:"str",LTSonly:!0,pointer:{main:n,index:"contentkey"}},{type:"text",text:" - or - "},{label:"Key ID",type:"str",LTSonly:!0,pointer:{main:n,index:"keyid"}},{label:"Key seed",type:"str",LTSonly:!0,pointer:{main:n,index:"keyseed"}},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Streams")}},{type:"save",label:"Save","function":function(){la("Streams")}}, {label:"License acquisition url",type:"str",LTSonly:!0,pointer:{main:n,index:"la_url"}},$("<br>"),{label:"Content key",type:"str",LTSonly:!0,pointer:{main:n,index:"contentkey"}},{type:"text",text:" - or - "},{label:"Key ID",type:"str",LTSonly:!0,pointer:{main:n,index:"keyid"}},{label:"Key seed",type:"str",LTSonly:!0,pointer:{main:n,index:"keyseed"}},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Streams")}},{type:"save",label:"Save","function":function(){ma("Streams")}},
{type:"save",label:"Save and Preview","function":function(){la("Preview")},classes:["saveandpreview"]}]}]));d.find("[name=name]").keyup(function(){X()});X();break;case "Preview":""==c&&UI.navto("Streams");b=":8080";for(g in mist.data.config.protocols)if(r=mist.data.config.protocols[g],"HTTP"==r.connector||"HTTP.exe"==r.connector)b=r.port?":"+r.port:":8080";var h=parseURL(mist.user.host),M=h.protocol+h.host+b+"/",J=$("<div>").css({display:"flex","flex-flow":"row wrap"}),h="";-1==c.indexOf("+")&&(h= {type:"save",label:"Save and Preview","function":function(){ma("Preview")},classes:["saveandpreview"]}]}]));d.find("[name=name]").keyup(function(){Y()});Y();break;case "Preview":""==c&&UI.navto("Streams");b=":8080";for(h in mist.data.config.protocols)if(r=mist.data.config.protocols[h],"HTTP"==r.connector||"HTTP.exe"==r.connector)b=r.port?":"+r.port:":8080";var e=parseURL(mist.user.host),M=e.protocol+e.host+b+"/",J=$("<div>").css({display:"flex","flex-flow":"row wrap"}),e="";-1==c.indexOf("+")&&(e=
$("<button>").text("Settings").addClass("settings").click(function(){UI.navto("Edit",c)}));d.html($("<div>").addClass("bigbuttons").append(h).append($("<button>").text("Embed").addClass("embed").click(function(){UI.navto("Embed",c)})).append($("<button>").addClass("cancel").addClass("return").text("Return").click(function(){UI.navto("Streams")}))).append($("<h2>").text('Preview of "'+c+'"')).append(J);var H=encodeURIComponent(c);g=$("<div>");J.append(g);var Y=$("<div>"),R=$("<select>").append($("<option>").text("Automatic").val("")).change(function(){Z()}), $("<button>").text("Settings").addClass("settings").click(function(){UI.navto("Edit",c)}));d.html($("<div>").addClass("bigbuttons").append(e).append($("<button>").text("Embed").addClass("embed").click(function(){UI.navto("Embed",c)})).append($("<button>").addClass("cancel").addClass("return").text("Return").click(function(){UI.navto("Streams")}))).append($("<h2>").text('Preview of "'+c+'"')).append(J);var H=encodeURIComponent(c);h=$("<div>");J.append(h);var Z=$("<div>"),R=$("<select>").append($("<option>").text("Automatic").val("")).change(function(){aa()}),
N=$("<select>").append($("<option>").text("Automatic").val("")).change(function(){Z()}),h=UI.buildUI([{label:"Use player",type:"DOMfield",DOMfield:R,help:"Choose a player to preview"},{label:"Use source",type:"DOMfield",DOMfield:N,help:"Choose an output type to preview"}]),O=$("<div>").addClass("mistvideo").text("Loading player..");g.append(O).append(Y).append(h);var Z=function(){A.html("");if(typeof mistvideo!="undefined")for(var a in mistvideo)if("embedded"in mistvideo[a])for(var b in mistvideo[a].embedded)try{mistvideo[a].embedded[b].player.unload()}catch(d){}a= N=$("<select>").append($("<option>").text("Automatic").val("")).change(function(){aa()}),e=UI.buildUI([{label:"Use player",type:"DOMfield",DOMfield:R,help:"Choose a player to preview"},{label:"Use source",type:"DOMfield",DOMfield:N,help:"Choose an output type to preview"}]),O=$("<div>").addClass("mistvideo").text("Loading player..");h.append(O).append(Z).append(e);var aa=function(){A.html("");if(typeof mistvideo!="undefined")for(var a in mistvideo)if("embedded"in mistvideo[a])for(var b in mistvideo[a].embedded)try{mistvideo[a].embedded[b].player.unload()}catch(d){}a=
{target:O[0],maxheight:window.innerHeight-$("header").height(),maxwidth:window.innerWidth-UI.elements.menu.width()-100,host:M.replace(/\/$/,""),loop:true};if(R.val()!="")a.forcePlayer=R.val();if(N.val()!="")a.forceSource=N.val();mistPlay(c,a)},A=$("<div>").addClass("player_log");g.append($("<div>").append($("<h3>").text("Player log:")).append(A));var na="";O.on("log error",function(a){var c=false;A.height()+A.scrollTop()==A[0].scrollHeight&&(c=true);var b=a.type+a.originalEvent.message,d="["+UI.format.time((new Date).getTime()/ {target:O[0],maxheight:window.innerHeight-$("header").height(),maxwidth:window.innerWidth-UI.elements.menu.width()-100,host:M.replace(/\/$/,""),loop:true};if(R.val()!="")a.forcePlayer=R.val();if(N.val()!="")a.forceSource=N.val();mistPlay(c,a)},A=$("<div>").addClass("player_log");h.append($("<div>").append($("<h3>").text("Player log:")).append(A));var oa="";O.on("log error",function(a){var c=false;A.height()+A.scrollTop()==A[0].scrollHeight&&(c=true);var b=a.type+a.originalEvent.message,d="["+UI.format.time((new Date).getTime()/
1E3)+"]";if(na==b){var a=A.children().last(),c=a.children("[data-amount]"),g=c.attr("data-amount");g++;c.text("("+g+"x)").attr("data-amount",g);a.children(".timestamp").text(d)}else{A.append($("<div>").append($("<span>").addClass("timestamp").text(d).css("margin-right","0.5em")).append($("<span>").text(a.originalEvent.message)).append($("<span>").attr("data-amount",1).css("margin-left","0.5em")).addClass(a.type=="error"?"red":""));c&&A.scrollTop(A[0].scrollHeight)}na=b});var oa=function(){Y.text(""); 1E3)+"]";if(oa==b){var a=A.children().last(),c=a.children("[data-amount]"),h=c.attr("data-amount");h++;c.text("("+h+"x)").attr("data-amount",h);a.children(".timestamp").text(d)}else{A.append($("<div>").append($("<span>").addClass("timestamp").text(d).css("margin-right","0.5em")).append($("<span>").text(a.originalEvent.message)).append($("<span>").attr("data-amount",1).css("margin-left","0.5em")).addClass(a.type=="error"?"red":""));c&&A.scrollTop(A[0].scrollHeight)}oa=b});var pa=function(){Z.text("");
var a=document.createElement("script");d.append(a);a.src=M+"player.js";a.onerror=function(){O.html("Failed to load player.js").append($("<button>").text("Reload").css("display","block").click(function(){oa()}))};a.onload=function(){for(var b in mistplayers)R.append($("<option>").text(mistplayers[b].name).val(b));Z();O.on("initialized",function(){if(N.children().length<=1)for(var a in mistvideo[c].source){var b=mistvideo[c].source[a],d=UI.humanMime(b.type);N.append($("<option>").val(a).text(d?d+" @ "+ var a=document.createElement("script");d.append(a);a.src=M+"player.js";a.onerror=function(){O.html("Failed to load player.js").append($("<button>").text("Reload").css("display","block").click(function(){pa()}))};a.onload=function(){for(var b in mistplayers)R.append($("<option>").text(mistplayers[b].name).val(b));aa();O.on("initialized",function(){if(N.children().length<=1)for(var a in mistvideo[c].source){var b=mistvideo[c].source[a],d=UI.humanMime(b.type);N.append($("<option>").val(a).text(d?d+" @ "+
b.url.substring(b.url.length-b.relurl.length,0):UI.format.capital(b.type)+" @ "+b.url.substring(b.url.length-b.relurl.length,0)))}a=mistvideo[c].embedded[mistvideo[c].embedded.length-1];d=UI.humanMime(a.player.options.source.type);Y.html("You're watching "+(d?d+" <span class=description>("+a.player.options.source.type+")</span>":UI.format.capital(a.player.options.source.type))+" through "+mistplayers[a.selectedPlayer].name+".")});d[0].removeChild(a)}};oa();g=$("<div>").append($("<h3>").text("Meta information")); b.url.substring(b.url.length-b.relurl.length,0):UI.format.capital(b.type)+" @ "+b.url.substring(b.url.length-b.relurl.length,0)))}a=mistvideo[c].embedded[mistvideo[c].embedded.length-1];d=UI.humanMime(a.player.options.source.type);Z.html("You're watching "+(d?d+" <span class=description>("+a.player.options.source.type+")</span>":UI.format.capital(a.player.options.source.type))+" through "+mistplayers[a.selectedPlayer].name+".")});d[0].removeChild(a)}};pa();h=$("<div>").append($("<h3>").text("Meta information"));
var S=$("<span>").text("Loading..");g.append(S);J.append(g);$.ajax({type:"GET",url:M+"json_"+H+".js",success:function(a){var c=function(a,c){return"maxbps"in a?UI.format.bytes(a[c],1):c=="maxbps"?UI.format.bytes(a.bps,1):"unknown"},b=a.meta;if(!b||!b.tracks)S.html("No meta information available.");else{a=[];a.push({label:"Type",type:"span",value:b.live?"Live":"Pre-recorded (VoD)"});"format"in b&&a.push({label:"Format",type:"span",value:b.format});b.live&&a.push({label:"Buffer window",type:"span", var S=$("<span>").text("Loading..");h.append(S);J.append(h);$.ajax({type:"GET",url:M+"json_"+H+".js",success:function(a){var c=function(a,c){return"maxbps"in a?UI.format.bytes(a[c],1):c=="maxbps"?UI.format.bytes(a.bps,1):"unknown"},b=a.meta;if(!b||!b.tracks)S.html("No meta information available.");else{a=[];a.push({label:"Type",type:"span",value:b.live?"Live":"Pre-recorded (VoD)"});"format"in b&&a.push({label:"Format",type:"span",value:b.format});b.live&&a.push({label:"Buffer window",type:"span",
value:UI.format.addUnit(b.buffer_window,"ms")});var d={audio:{vheader:"Audio",labels:["Codec","Duration","Avg bitrate","Peak bitrate","Channels","Samplerate","Language"],content:[]},video:{vheader:"Video",labels:["Codec","Duration","Avg bitrate","Peak bitrate","Size","Framerate","Language"],content:[]},subtitle:{vheader:"Subtitles",labels:["Codec","Duration","Avg bitrate","Peak bitrate","Language"],content:[]}},g=Object.keys(b.tracks);g.sort(function(a,c){a=a.split("_").pop();c=c.split("_").pop(); value:UI.format.addUnit(b.buffer_window,"ms")});var d={audio:{vheader:"Audio",labels:["Codec","Duration","Avg bitrate","Peak bitrate","Channels","Samplerate","Language"],content:[]},video:{vheader:"Video",labels:["Codec","Duration","Avg bitrate","Peak bitrate","Size","Framerate","Language"],content:[]},subtitle:{vheader:"Subtitles",labels:["Codec","Duration","Avg bitrate","Peak bitrate","Language"],content:[]}},h=Object.keys(b.tracks);h.sort(function(a,c){a=a.split("_").pop();c=c.split("_").pop();
return a-c});for(var e in g){var h=g[e],f=b.tracks[h];switch(f.type){case "audio":d.audio.content.push({header:"Track "+h.split("_").pop(),body:[f.codec,UI.format.duration((f.lastms-f.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(f.firstms/1E3)+" to "+UI.format.duration(f.lastms/1E3)+"</span>",c(f,"bps"),c(f,"maxbps"),f.channels,UI.format.addUnit(UI.format.number(f.rate),"Hz"),"language"in f?f.language:"unknown"]});break;case "video":d.video.content.push({header:"Track "+h.split("_").pop(), return a-c});for(var e in h){var g=h[e],f=b.tracks[g];switch(f.type){case "audio":d.audio.content.push({header:"Track "+g.split("_").pop(),body:[f.codec,UI.format.duration((f.lastms-f.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(f.firstms/1E3)+" to "+UI.format.duration(f.lastms/1E3)+"</span>",c(f,"bps"),c(f,"maxbps"),f.channels,UI.format.addUnit(UI.format.number(f.rate),"Hz"),"language"in f?f.language:"unknown"]});break;case "video":d.video.content.push({header:"Track "+g.split("_").pop(),
body:[f.codec,UI.format.duration((f.lastms-f.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(f.firstms/1E3)+" to "+UI.format.duration(f.lastms/1E3)+"</span>",c(f,"bps"),c(f,"maxbps"),UI.format.addUnit(f.width,"x ")+UI.format.addUnit(f.height,"px"),UI.format.addUnit(UI.format.number(f.fpks/1E3),"fps"),"language"in f?f.language:"unknown"]});break;case "meta":case "subtitle":if(f.codec=="subtitle"||f.type=="subtitle")d.subtitle.content.push({header:"Track "+h.split("_").pop(),body:[f.codec, body:[f.codec,UI.format.duration((f.lastms-f.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(f.firstms/1E3)+" to "+UI.format.duration(f.lastms/1E3)+"</span>",c(f,"bps"),c(f,"maxbps"),UI.format.addUnit(f.width,"x ")+UI.format.addUnit(f.height,"px"),UI.format.addUnit(UI.format.number(f.fpks/1E3),"fps"),"language"in f?f.language:"unknown"]});break;case "meta":case "subtitle":if(f.codec=="subtitle"||f.type=="subtitle")d.subtitle.content.push({header:"Track "+g.split("_").pop(),body:[f.codec,
UI.format.duration((f.lastms-f.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(f.firstms/1E3)+" to "+UI.format.duration(f.lastms/1E3)+"</span>",c(f,"bps"),c(f,"maxbps"),"language"in f?f.language:"unknown"]})}}c=["audio","video","subtitle"];e=$("<div>").css({display:"flex","flex-flow":"row wrap","font-size":"0.9em"});for(h in c)d[c[h]].content.length&&e.append(UI.buildVheaderTable(d[c[h]]).css("width","auto"));a.push($("<span>").text("Tracks:"));a.push(e);S.html(UI.buildUI(a))}},error:function(){S.html("Error while retrieving stream info.")}}); UI.format.duration((f.lastms-f.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(f.firstms/1E3)+" to "+UI.format.duration(f.lastms/1E3)+"</span>",c(f,"bps"),c(f,"maxbps"),"language"in f?f.language:"unknown"]})}}c=["audio","video","subtitle"];e=$("<div>").css({display:"flex","flex-flow":"row wrap","font-size":"0.9em"});for(g in c)d[c[g]].content.length&&e.append(UI.buildVheaderTable(d[c[g]]).css("width","auto"));a.push($("<span>").text("Tracks:"));a.push(e);S.html(UI.buildUI(a))}},error:function(){S.html("Error while retrieving stream info.")}});
break;case "Embed":""==c&&UI.navTo("Streams");h="";-1==c.indexOf("+")&&(h=$("<button>").addClass("settings").text("Settings").click(function(){UI.navto("Edit",c)}));d.html($("<div>").addClass("bigbuttons").append(h).append($("<button>").text("Preview").addClass("preview").click(function(){UI.navto("Preview",c)})).append($("<button>").addClass("cancel").addClass("return").text("Return").click(function(){UI.navto("Streams")}))).append($("<h2>").text('Embed "'+c+'"'));var T=$("<span>");d.append(T);H= break;case "Embed":""==c&&UI.navTo("Streams");e="";-1==c.indexOf("+")&&(e=$("<button>").addClass("settings").text("Settings").click(function(){UI.navto("Edit",c)}));d.html($("<div>").addClass("bigbuttons").append(e).append($("<button>").text("Preview").addClass("preview").click(function(){UI.navto("Preview",c)})).append($("<button>").addClass("cancel").addClass("return").text("Return").click(function(){UI.navto("Streams")}))).append($("<h2>").text('Embed "'+c+'"'));var T=$("<span>");d.append(T);H=
encodeURIComponent(c);h=parseURL(mist.user.host);b={"":{port:":8080"}};for(g in mist.data.config.protocols){r=mist.data.config.protocols[g];if("HTTP"==r.connector||"HTTP.exe"==r.connector)b[""].port=r.port?":"+r.port:":8080";if("HTTPS"==r.connector||"HTTPS.exe"==r.connector)b.s={},b.s.port=r.port?":"+r.port:":4433"}var I=M="http://"+h.host+b[""].port+"/";if(otherhost.host||otherhost.https)I=(otherhost.https&&"s"in b?"https://":"http://")+(otherhost.host?otherhost.host:h.host)+(otherhost.https&&"s"in encodeURIComponent(c);e=parseURL(mist.user.host);b={"":{port:":8080"}};for(h in mist.data.config.protocols){r=mist.data.config.protocols[h];if("HTTP"==r.connector||"HTTP.exe"==r.connector)b[""].port=r.port?":"+r.port:":8080";if("HTTPS"==r.connector||"HTTPS.exe"==r.connector)b.s={},b.s.port=r.port?":"+r.port:":4433"}var I=M="http://"+e.host+b[""].port+"/";if(otherhost.host||otherhost.https)I=(otherhost.https&&"s"in b?"https://":"http://")+(otherhost.host?otherhost.host:e.host)+(otherhost.https&&"s"in
b?b.s.port:b[""].port)+"/";var aa={forcePlayer:"",forceType:"",controls:!0,autoplay:!0,loop:!1,width:"",height:"",maxwidth:"",maxheight:"",poster:"",urlappend:"",setTracks:{}},o=$.extend({},aa);g=UI.stored.getOpts();"embedoptions"in g&&(o=$.extend(o,g.embedoptions,!0),"object"!=typeof o.setTracks&&(o.setTracks={}));g={};switch(o.controls){case "stock":g.controls="stock";break;case !0:g.controls=1;break;case !1:g.controls=0}var v=function(){function a(c){switch(typeof c){case "string":return $.isNumeric(c)? b?b.s.port:b[""].port)+"/";var ba={forcePlayer:"",forceType:"",controls:!0,autoplay:!0,loop:!1,width:"",height:"",maxwidth:"",maxheight:"",poster:"",urlappend:"",setTracks:{}},o=$.extend({},ba);h=UI.stored.getOpts();"embedoptions"in h&&(o=$.extend(o,h.embedoptions,!0),"object"!=typeof o.setTracks&&(o.setTracks={}));h={};switch(o.controls){case "stock":h.controls="stock";break;case !0:h.controls=1;break;case !1:h.controls=0}var v=function(){function a(c){switch(typeof c){case "string":return $.isNumeric(c)?
c:'"'+c+'"';case "object":return JSON.stringify(c);default:return c}}UI.stored.saveOpt("embedoptions",o);for(var b=c+"_",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 b=b+g,d=['target: document.getElementById("'+b+'")'],e;for(e in o)o[e]!=aa[e]&&(typeof o[e]!="object"||JSON.stringify(o[e])!=JSON.stringify(aa[e]))&&d.push(e+": "+a(o[e]));e=[];e.push('<div class="mistvideo" id="'+b+'">');e.push(" <noscript>");e.push(' <a href="'+ c:'"'+c+'"';case "object":return JSON.stringify(c);default:return c}}UI.stored.saveOpt("embedoptions",o);for(var b=c+"_",d=12,h="";d--;){var f;f=Math.floor(Math.random()*62);f=f<10?f:f<36?String.fromCharCode(f+55):String.fromCharCode(f+61);h=h+f}var b=b+h,d=['target: document.getElementById("'+b+'")'],e;for(e in o)o[e]!=ba[e]&&(typeof o[e]!="object"||JSON.stringify(o[e])!=JSON.stringify(ba[e]))&&d.push(e+": "+a(o[e]));e=[];e.push('<div class="mistvideo" id="'+b+'">');e.push(" <noscript>");e.push(' <a href="'+
I+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("'+c+'",{');e.push(" "+d.join(",\n "));e.push(" });");e.push(" };");e.push(" if (!window.mistplayers) {");e.push(' var p = document.createElement("script");');e.push(' p.src = "'+I+'player.js"');e.push(" document.head.appendChild(p);");e.push(" p.onload = a;"); I+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("'+c+'",{');e.push(" "+d.join(",\n "));e.push(" });");e.push(" };");e.push(" if (!window.mistplayers) {");e.push(' var p = document.createElement("script");');e.push(' p.src = "'+I+'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")},ba=$("<span>").text("Loading.."),r=v(o),K=$("<div>").text("Loading..").css("display","flex"),pa="";"s"in b&&(pa=UI.buildUI([{label:"Use HTTPS",type:"checkbox","function":function(){if($(this).getval()!=otherhost.https){otherhost.https=$(this).getval();UI.navto("Embed",c)}},value:otherhost.https}]).find("label"));T.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(" }");e.push(" else { a(); }");e.push(" <\/script>");e.push("</div>");return e.join("\n")},ca=$("<span>").text("Loading.."),r=v(o),K=$("<div>").text("Loading..").css("display","flex"),qa="";"s"in b&&(qa=UI.buildUI([{label:"Use HTTPS",type:"checkbox","function":function(){if($(this).getval()!=otherhost.https){otherhost.https=$(this).getval();UI.navto("Embed",c)}},value:otherhost.https}]).find("label"));T.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:h.host)).append($("<span>").addClass("unit").append($("<button>").text("Apply").click(function(){otherhost.host=$(this).closest("label").find("input").val();UI.navto("Embed",c)}))))).append(pa)).append(UI.buildUI([$("<h3>").text("Urls"),{label:"Stream info json",type:"str",value:I+"json_"+H+".js",readonly:!0,clipboard:!0,help:"Information about this stream as a json page."},{label:"Stream info script",type:"str",value:I+"info_"+H+".js",readonly:!0, "text").addClass("field").val(otherhost.host?otherhost.host:e.host)).append($("<span>").addClass("unit").append($("<button>").text("Apply").click(function(){otherhost.host=$(this).closest("label").find("input").val();UI.navto("Embed",c)}))))).append(qa)).append(UI.buildUI([$("<h3>").text("Urls"),{label:"Stream info json",type:"str",value:I+"json_"+H+".js",readonly:!0,clipboard:!0,help:"Information about this stream as a json page."},{label:"Stream info script",type:"str",value:I+"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:I+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:r,rows:r.split("\n").length+3,readonly:!0,classes:["embed_code"],clipboard:!0,help:"Include this code on your webpage to embed the stream. The options below can be used to configure how your content is displayed."}, clipboard:!0,help:"This script loads information about this stream into a mistvideo javascript object."},{label:"HTML page",type:"str",value:I+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:r,rows:r.split("\n").length+3,readonly:!0,classes:["embed_code"],clipboard:!0,help:"Include this code on your webpage to embed the stream. The options below can be used to configure how your content is displayed."},
$("<h4>").text("Embed code options (optional)").css("margin-top",0),{type:"help",help:"Use these controls to customise what this embedded video will look like.<br>Not all players have all of these options."},{label:"Force player",type:"select",select:[["","Automatic"]],pointer:{main:o,index:"forcePlayer"},classes:["forcePlayer"],"function":function(){o.forcePlayer=$(this).getval();$(".embed_code").setval(v(o))},help:"Only use this particular player."},{label:"Force source",type:"select",select:[["", $("<h4>").text("Embed code options (optional)").css("margin-top",0),{type:"help",help:"Use these controls to customise what this embedded video will look like.<br>Not all players have all of these options."},{label:"Force player",type:"select",select:[["","Automatic"]],pointer:{main:o,index:"forcePlayer"},classes:["forcePlayer"],"function":function(){o.forcePlayer=$(this).getval();$(".embed_code").setval(v(o))},help:"Only use this particular player."},{label:"Force source",type:"select",select:[["",
"Automatic"]],pointer:{main:o,index:"forceType"},classes:["forceType"],"function":function(){o.forceType=$(this).getval();$(".embed_code").setval(v(o))},help:"Only use this particular source."},{label:"Controls",type:"select",select:[["1","MistServer Controls"],["stock","Player controls"],["0","None"]],pointer:{main:g,index:"controls"},"function":function(){o.controls=$(this).getval()==1;switch($(this).getval()){case 0:o.controls=false;break;case 1:o.controls=true;break;case "stock":o.controls="stock"}$(".embed_code").setval(v(o))}, "Automatic"]],pointer:{main:o,index:"forceType"},classes:["forceType"],"function":function(){o.forceType=$(this).getval();$(".embed_code").setval(v(o))},help:"Only use this particular source."},{label:"Controls",type:"select",select:[["1","MistServer Controls"],["stock","Player controls"],["0","None"]],pointer:{main:h,index:"controls"},"function":function(){o.controls=$(this).getval()==1;switch($(this).getval()){case 0:o.controls=false;break;case 1:o.controls=true;break;case "stock":o.controls="stock"}$(".embed_code").setval(v(o))},
help:"The type of controls that should be shown."},{label:"Autoplay",type:"checkbox",pointer:{main:o,index:"autoplay"},"function":function(){o.autoplay=$(this).getval();$(".embed_code").setval(v(o))},help:"Whether or not the video should play as the page is loaded."},{label:"Loop",type:"checkbox",pointer:{main:o,index:"loop"},"function":function(){o.loop=$(this).getval();$(".embed_code").setval(v(o))},help:"If the video should restart when the end is reached."},{label:"Force width",type:"int",min:0, help:"The type of controls that should be shown."},{label:"Autoplay",type:"checkbox",pointer:{main:o,index:"autoplay"},"function":function(){o.autoplay=$(this).getval();$(".embed_code").setval(v(o))},help:"Whether or not the video should play as the page is loaded."},{label:"Loop",type:"checkbox",pointer:{main:o,index:"loop"},"function":function(){o.loop=$(this).getval();$(".embed_code").setval(v(o))},help:"If the video should restart when the end is reached."},{label:"Force width",type:"int",min:0,
unit:"px",pointer:{main:o,index:"width"},"function":function(){o.width=$(this).getval();$(".embed_code").setval(v(o))},help:"Enforce a fixed width."},{label:"Force height",type:"int",min:0,unit:"px",pointer:{main:o,index:"height"},"function":function(){o.height=$(this).getval();$(".embed_code").setval(v(o))},help:"Enforce a fixed height."},{label:"Maximum width",type:"int",min:0,unit:"px",pointer:{main:o,index:"maxwidth"},"function":function(){o.maxwidth=$(this).getval();$(".embed_code").setval(v(o))}, unit:"px",pointer:{main:o,index:"width"},"function":function(){o.width=$(this).getval();$(".embed_code").setval(v(o))},help:"Enforce a fixed width."},{label:"Force height",type:"int",min:0,unit:"px",pointer:{main:o,index:"height"},"function":function(){o.height=$(this).getval();$(".embed_code").setval(v(o))},help:"Enforce a fixed height."},{label:"Maximum width",type:"int",min:0,unit:"px",pointer:{main:o,index:"maxwidth"},"function":function(){o.maxwidth=$(this).getval();$(".embed_code").setval(v(o))},
help:"The maximum width this video can use."},{label:"Maximum height",type:"int",min:0,unit:"px",pointer:{main:o,index:"maxheight"},"function":function(){o.maxheight=$(this).getval();$(".embed_code").setval(v(o))},help:"The maximum height this video can use."},{label:"Poster",type:"str",pointer:{main:o,index:"poster"},"function":function(){o.poster=$(this).getval();$(".embed_code").setval(v(o))},help:"URL to an image that is displayed when the video is not playing."},{label:"Video URL addition",type:"str", help:"The maximum width this video can use."},{label:"Maximum height",type:"int",min:0,unit:"px",pointer:{main:o,index:"maxheight"},"function":function(){o.maxheight=$(this).getval();$(".embed_code").setval(v(o))},help:"The maximum height this video can use."},{label:"Poster",type:"str",pointer:{main:o,index:"poster"},"function":function(){o.poster=$(this).getval();$(".embed_code").setval(v(o))},help:"URL to an image that is displayed when the video is not playing."},{label:"Video URL addition",type:"str",
pointer:{main:o,index:"urlappend"},help:"The embed script will append this string to the video url, useful for sending through params.",classes:["embed_code_forceprotocol"],"function":function(){o.urlappend=$(this).getval();$(".embed_code").setval(v(o))}},{label:"Preselect tracks",type:"DOMfield",DOMfield:K,help:"Pre-select these tracks."},$("<h3>").text("Protocol stream urls"),ba]));$.ajax({type:"GET",url:I+"json_"+H+".js",success:function(a){var c=[],b=T.find(".forceType"),d;for(d in a.source){var g= pointer:{main:o,index:"urlappend"},help:"The embed script will append this string to the video url, useful for sending through params.",classes:["embed_code_forceprotocol"],"function":function(){o.urlappend=$(this).getval();$(".embed_code").setval(v(o))}},{label:"Preselect tracks",type:"DOMfield",DOMfield:K,help:"Pre-select these tracks."},$("<h3>").text("Protocol stream urls"),ca]));$.ajax({type:"GET",url:I+"json_"+H+".js",success:function(a){var c=[],b=T.find(".forceType"),d;for(d in a.source){var h=
a.source[d],e=UI.humanMime(g.type);c.push({label:e?e+" <span class=description>("+g.type+")</span>":UI.format.capital(g.type),type:"str",value:g.url,readonly:true,qrcode:true,clipboard:true});e=UI.humanMime(g.type);b.append($("<option>").text(e?e+" ("+g.type+")":UI.format.capital(g.type)).val(g.type))}ba.html(UI.buildUI(c));K.html("");c={};for(d in a.meta.tracks){b=a.meta.tracks[d];b.type!="audio"&&b.type!="video"||(b.type in c?c[b.type].push([b.trackid,UI.format.capital(b.type)+" track "+(c[b.type].length+ a.source[d],e=UI.humanMime(h.type);c.push({label:e?e+" <span class=description>("+h.type+")</span>":UI.format.capital(h.type),type:"str",value:h.url,readonly:true,qrcode:true,clipboard:true});e=UI.humanMime(h.type);b.append($("<option>").text(e?e+" ("+h.type+")":UI.format.capital(h.type)).val(h.type))}ca.html(UI.buildUI(c));K.html("");c={};for(d in a.meta.tracks){b=a.meta.tracks[d];b.type!="audio"&&b.type!="video"||(b.type in c?c[b.type].push([b.trackid,UI.format.capital(b.type)+" track "+(c[b.type].length+
1)]):c[b.type]=[["",UI.format.capital(b.type)+" track 1"]])}if(Object.keys(c).length){K.closest("label").show();for(d in c){a=$("<select>").attr("data-type",d).css("flex-grow","1").change(function(){$(this).val()==""?delete o.setTracks[$(this).attr("data-type")]:o.setTracks[$(this).attr("data-type")]=$(this).val();$(".embed_code").setval(v(o))});K.append(a);c[d].push([-1,"No "+d]);for(var f in c[d])a.append($("<option>").val(c[d][f][0]).text(c[d][f][1]));if(d in o.setTracks){a.val(o.setTracks[d]); 1)]):c[b.type]=[["",UI.format.capital(b.type)+" track 1"]])}if(Object.keys(c).length){K.closest("label").show();for(d in c){a=$("<select>").attr("data-type",d).css("flex-grow","1").change(function(){$(this).val()==""?delete o.setTracks[$(this).attr("data-type")]:o.setTracks[$(this).attr("data-type")]=$(this).val();$(".embed_code").setval(v(o))});K.append(a);c[d].push([-1,"No "+d]);for(var f in c[d])a.append($("<option>").val(c[d][f][0]).text(c[d][f][1]));if(d in o.setTracks){a.val(o.setTracks[d]);
if(a.val()==null){a.val("");delete o.setTracks[d];$(".embed_code").setval(v(o))}}}}else K.closest("label").hide()},error:function(){ba.html("Error while retrieving stream info.");K.closest("label").hide();o.setTracks={}}});g=document.createElement("script");g.src=M+"player.js";document.head.appendChild(g);g.onload=function(){var a=T.find(".forcePlayer"),c;for(c in mistplayers)a.append($("<option>").text(mistplayers[c].name).val(c));document.head.removeChild(this)};g.onerror=function(){document.head.removeChild(this)}; if(a.val()==null){a.val("");delete o.setTracks[d];$(".embed_code").setval(v(o))}}}}else K.closest("label").hide()},error:function(){ca.html("Error while retrieving stream info.");K.closest("label").hide();o.setTracks={}}});h=document.createElement("script");h.src=M+"player.js";document.head.appendChild(h);h.onload=function(){var a=T.find(".forcePlayer"),c;for(c in mistplayers)a.append($("<option>").text(mistplayers[c].name).val(c));document.head.removeChild(this)};h.onerror=function(){document.head.removeChild(this)};
break;case "Push":var B=$("<div>").text("Loading..");d.append(B);mist.send(function(a){function c(a){setTimeout(function(){mist.send(function(b){var d=false;if("push_list"in b&&b.push_list&&b.push_list.length){var d=true,e;for(e in b.push_list)if(a.indexOf(b.push_list[e][0])>-1){d=false;break}}else d=true;if(d)for(e in a)g.find("tr[data-pushid="+a[e]+"]").remove();else c()},{push_list:1})},1E3)}function b(e,f){var h=$("<span>");e.length>=4&&e[2]!=e[3]?h.append($("<span>").text(e[2])).append($("<span>").html("&#187").addClass("unit").css("margin", break;case "Push":var B=$("<div>").text("Loading..");d.append(B);mist.send(function(a){function c(a){setTimeout(function(){mist.send(function(b){var d=false;if("push_list"in b&&b.push_list&&b.push_list.length){var d=true,e;for(e in b.push_list)if(a.indexOf(b.push_list[e][0])>-1){d=false;break}}else d=true;if(d)for(e in a)h.find("tr[data-pushid="+a[e]+"]").remove();else c()},{push_list:1})},1E3)}function b(e,f){var g=$("<span>");f=="Automatic"&&e.length>=4?g.append($("<span>").text(e[2])).append($("<span>").text(", schedule on "+
"0 0.5em")).append($("<span>").text(e[3])):h.append($("<span>").text(e[2]));var i=$("<td>").append($("<button>").text(f=="Automatic"?"Remove":"Stop").click(function(){if(confirm("Are you sure you want to "+$(this).text().toLowerCase()+" this push?\n"+e[1]+" to "+e[2])){var a=$(this).closest("tr");a.html($("<td colspan=99>").html($("<span>").addClass("red").text(f=="Automatic"?"Removing..":"Stopping..")));f=="Automatic"?mist.send(function(){a.remove()},{push_auto_remove:{stream:e[1],target:e[2]}}): (new Date(e[3]*1E3)).toLocaleString())).append($("<span>").text(", complete on "+(new Date(e[4]*1E3)).toLocaleString())):e.length>=4&&e[2]!=e[3]?g.append($("<span>").text(e[2])).append($("<span>").html("&#187").addClass("unit").css("margin","0 0.5em")).append($("<span>").text(e[3])):g.append($("<span>").text(e[2]));var i=$("<td>").append($("<button>").text(f=="Automatic"?"Remove":"Stop").click(function(){if(confirm("Are you sure you want to "+$(this).text().toLowerCase()+" this push?\n"+e[1]+" to "+
mist.send(function(){c([e[0]])},{push_stop:[e[0]]})}}));f=="Automatic"&&i.append($("<button>").text("Stop pushes").click(function(){if(confirm('Are you sure you want to stop all pushes matching \n"'+e[1]+" to "+e[2]+'"?'+(d.wait!=0?"\n\nRetrying is enabled. You'll probably want to set that to 0.":""))){var b=$(this);b.text("Stopping pushes..");var f=[],h;for(h in a.push_list)if(e[1]==a.push_list[h][1]&&e[2]==a.push_list[h][2]){f.push(a.push_list[h][0]);g.find("tr[data-pushid="+a.push_list[h][0]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}mist.send(function(){b.text("Stop pushes"); e[2])){var a=$(this).closest("tr");a.html($("<td colspan=99>").html($("<span>").addClass("red").text(f=="Automatic"?"Removing..":"Stopping..")));if(f=="Automatic"){var b=e.slice(1);mist.send(function(){a.remove()},{push_auto_remove:[b]})}else mist.send(function(){c([e[0]])},{push_stop:[e[0]]})}}));if(f=="Automatic"){i.prepend($("<button>").text("Edit").click(function(){UI.navto("Start Push","auto_"+($(this).closest("tr").index()-1))}));i.append($("<button>").text("Stop pushes").click(function(){if(confirm('Are you sure you want to stop all pushes matching \n"'+
c(f)},{push_stop:f,push_settings:{wait:0}})}}));return $("<tr>").attr("data-pushid",e[0]).append($("<td>").text(e[1])).append($("<td>").append(h.children())).append(i)}B.html("");var d=a.push_settings;d||(d={});B.append(UI.buildUI([{type:"help",help:"You can push streams to files or other servers, allowing them to broadcast your stream as well."},$("<h3>").text("Settings"),{label:"Delay before retry",unit:"s",type:"int",min:0,help:"How long the delay should be before MistServer retries an automatic push.<br>If set to 0, it does not retry.", e[1]+" to "+e[2]+'"?'+(d.wait!=0?"\n\nRetrying is enabled. You'll probably want to set that to 0.":""))){var b=$(this);b.text("Stopping pushes..");var f=[],g;for(g in a.push_list)if(e[1]==a.push_list[g][1]&&e[2]==a.push_list[g][2]){f.push(a.push_list[g][0]);h.find("tr[data-pushid="+a.push_list[g][0]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}mist.send(function(){b.text("Stop pushes");c(f)},{push_stop:f,push_settings:{wait:0}})}}))}return $("<tr>").attr("data-pushid",
"default":0,pointer:{main:d,index:"wait"},LTSonly:1},{label:"Maximum retries",unit:"/s",type:"int",min:0,help:"The maximum amount of retries per second (for all automatic pushes).<br>If set to 0, there is no limit.","default":0,pointer:{main:d,index:"maxspeed"},LTSonly:1},{type:"buttons",buttons:[{type:"save",label:"Save","function":function(){mist.send(function(){UI.navto("Push")},{push_settings:d})}}]}]));var g=$("<table>").append($("<tr>").append($("<th>").text("Stream")).append($("<th>").text("Target")).append($("<th>"))), e[0]).append($("<td>").text(e[1])).append($("<td>").append(g.children())).append(i)}B.html("");var d=a.push_settings;d||(d={});B.append(UI.buildUI([{type:"help",help:"You can push streams to files or other servers, allowing them to broadcast your stream as well."},$("<h3>").text("Settings"),{label:"Delay before retry",unit:"s",type:"int",min:0,help:"How long the delay should be before MistServer retries an automatic push.<br>If set to 0, it does not retry.","default":0,pointer:{main:d,index:"wait"},
e=g.clone();if("push_list"in a)for(var f in a.push_list)g.append(b(a.push_list[f],"Manual"));if("push_auto_list"in a)for(f in a.push_auto_list)e.append(b([-1,a.push_auto_list[f][0],a.push_auto_list[f][1]],"Automatic"));B.append($("<h3>").text("Automatic pushes")).append($("<button>").text("Add an automatic push").click(function(){UI.navto("Start Push","auto")}));e.find("tr").length==1?B.append($("<div>").text("No automatic pushes have been configured.").addClass("text").css("margin-top","0.5em")): LTSonly:1},{label:"Maximum retries",unit:"/s",type:"int",min:0,help:"The maximum amount of retries per second (for all automatic pushes).<br>If set to 0, there is no limit.","default":0,pointer:{main:d,index:"maxspeed"},LTSonly:1},{type:"buttons",buttons:[{type:"save",label:"Save","function":function(){mist.send(function(){UI.navto("Push")},{push_settings:d})}}]}]));var h=$("<table>").append($("<tr>").append($("<th>").text("Stream")).append($("<th>").text("Target")).append($("<th>"))),e=h.clone();
B.append(e);B.append($("<h3>").text("Pushes")).append($("<button>").text("Start a push").click(function(){UI.navto("Start Push")}));if(g.find("tr").length==1)B.append($("<div>").text("No pushes are active.").addClass("text").css("margin-top","0.5em"));else{var e=[],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){e.indexOf(a.push_list[f][1])== if("push_list"in a)for(var f in a.push_list)h.append(b(a.push_list[f],"Manual"));if("push_auto_list"in a)for(f in a.push_auto_list){var g=a.push_auto_list[f].slice();g.unshift(-1);e.append(b(g,"Automatic"))}B.append($("<h3>").text("Automatic pushes")).append($("<button>").text("Add an automatic push").click(function(){UI.navto("Start Push","auto")}));e.find("tr").length==1?B.append($("<div>").text("No automatic pushes have been configured.").addClass("text").css("margin-top","0.5em")):B.append(e);
-1&&e.push(a.push_list[f][1]);h.indexOf(a.push_list[f][2])==-1&&h.push(a.push_list[f][2])}e.sort();h.sort();for(f in e)i.append($("<option>").text(e[f]));for(f in h)j.append($("<option>").text(h[f]));B.append($("<button>").text("Stop all pushes").click(function(){var b=[],d;for(d in a.push_list)b.push(a.push_list[d][0]);if(b.length!=0&&confirm("Are you sure you want to stop all pushes?")){mist.send(function(){c(b)},{push_stop:b});g.find("tr:not(:first-child)").html($("<td colspan=99>").append($("<span>").addClass("red").text("Stopping.."))); B.append($("<h3>").text("Pushes")).append($("<button>").text("Start a push").click(function(){UI.navto("Start Push")}));if(h.find("tr").length==1)B.append($("<div>").text("No pushes are active.").addClass("text").css("margin-top","0.5em"));else{var e=[],g=[],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){e.indexOf(a.push_list[f][1])==-1&&e.push(a.push_list[f][1]);
g.indexOf(a.push_list[f][2])==-1&&g.push(a.push_list[f][2])}e.sort();g.sort();for(f in e)i.append($("<option>").text(e[f]));for(f in g)j.append($("<option>").text(g[f]));B.append($("<button>").text("Stop all pushes").click(function(){var b=[],d;for(d in a.push_list)b.push(a.push_list[d][0]);if(b.length!=0&&confirm("Are you sure you want to stop all pushes?")){mist.send(function(){c(b)},{push_stop:b});h.find("tr:not(:first-child)").html($("<td colspan=99>").append($("<span>").addClass("red").text("Stopping..")));
$(this).remove()}})).append($("<label>").css("margin-left","1em").append($("<span>").text("Stop all pushes that match: ").css("font-size","0.9em")).append(i).append($("<span>").css("margin-left","0.5em").text("and").css("font-size","0.9em")).append(j).append($("<button>").css("margin-left","0.5em").text("Apply").click(function(){var b=i.val(),d=j.val();if(b==""&&d=="")return alert("Looks like you want to stop all pushes. Maybe you should use that button?");var e={},f;for(f in a.push_list)if((b==""|| $(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 b=i.val(),d=j.val();if(b==""&&d=="")return alert("Looks like you want to stop all pushes. Maybe you should use that button?");var e={},f;for(f in a.push_list)if((b==""||
a.push_list[f][1]==b)&&(d==""||a.push_list[f][2]==d))e[a.push_list[f][0]]=a.push_list[f];if(Object.keys(e).length==0)return alert("No matching pushes.");b="Are you sure you want to stop these pushes?\n\n";for(f in e)b=b+(e[f][1]+" to "+e[f][2]+"\n");if(confirm(b)){e=Object.keys(e);mist.send(function(){c(e)},{push_stop:e});for(f in e)g.find("tr[data-pushid="+e[f]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}}))).append(g)}},{push_settings:1,push_list:1,push_auto_list:1}); a.push_list[f][1]==b)&&(d==""||a.push_list[f][2]==d))e[a.push_list[f][0]]=a.push_list[f];if(Object.keys(e).length==0)return alert("No matching pushes.");b="Are you sure you want to stop these pushes?\n\n";for(f in e)b=b+(e[f][1]+" to "+e[f][2]+"\n");if(confirm(b)){e=Object.keys(e);mist.send(function(){c(e)},{push_stop:e});for(f in e)h.find("tr[data-pushid="+e[f]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}}))).append(h)}},{push_settings:1,push_list:1,push_auto_list:1});
break;case "Start Push":if(!("capabilities"in mist.data)){d.append("Loading Mist capabilities..");mist.send(function(){UI.navto("Start Push",c)},{capabilities:1});return}var t,ca=function(){var a=[],b;for(b in mist.data.capabilities.connectors){var e=mist.data.capabilities.connectors[b];"push_urls"in e&&(a=a.concat(e.push_urls))}c=="auto"&&d.find("h2").text("Add automatic push");var g={};d.append(UI.buildUI([{label:"Stream name",type:"str",help:"This may either be a full stream name, a partial wildcard stream name, or a full wildcard stream name.<br>For example, given the stream <i>a</i> you can use:<ul><li><i>a</i>: the stream configured as <i>a</i></li><li><i>a+</i>: all streams configured as <i>a</i> with a wildcard behind it, but not <i>a</i> itself</li><li><i>a+b</i>: only the version of stream <i>a</i> that has wildcard <i>b</i></li></ul>", break;case "Start Push":if(!("capabilities"in mist.data)){d.append("Loading Mist capabilities..");mist.send(function(){UI.navto("Start Push",c)},{capabilities:1});return}var t,U=function(a){var b=false,e=c.split("_");c=e[0];e.length==2&&(b=e[1]);if(b!==false&&typeof a=="undefined")mist.send(function(a){U(a.push_auto_list[b])},{push_auto_list:1});else{var h=[],f;for(f in mist.data.capabilities.connectors){e=mist.data.capabilities.connectors[f];"push_urls"in e&&(h=h.concat(e.push_urls))}c=="auto"&&
pointer:{main:g,index:"stream"},validate:["required",function(a){a=a.split("+");a=a[0];return a in mist.data.streams?false:{msg:"'"+a+"' is not a stream name.",classes:["red"]}}],datalist:t,LTSonly:1},{label:"Target",type:"str",help:"Where the stream will be pushed to.<br>Valid formats:<ul><li>"+a.join("</li><li>")+"</li></ul> Valid text replacements:<ul><li>$stream - inserts the stream name used to push to MistServer</li><li>$day - inserts the current day number</li><li>$month - inserts the current month number</li><li>$year - inserts the current year number</li><li>$hour - inserts the hour timestamp when stream was received</li><li>$minute - inserts the minute timestamp the stream was received</li><li>$seconds - inserts the seconds timestamp when the stream was received</li><li>$datetime - inserts $year.$month.$day.$hour.$minute.$seconds timestamp when the stream was received</li>", d.find("h2").text("Add automatic push");var g={};if(c=="auto"&&typeof a!="undefined"){g={stream:a[0],target:a[1]};if(a.length>=3)g.scheduletime=a[2];if(a.length>=4)g.completetime=a[3];if(g.target.indexOf("recstartunix=")>-1){f=g.target.split("recstartunix=")[1];g.recstartunix=f.split("&")[0];g.target=g.target.replace("recstartunix="+g.recstartunix,"").replace("?&","?").replace("&&","&");if(g.target[g.target.length-1]=="?")g.target=g.target.slice(0,-1)}}f=[{label:"Stream name",type:"str",help:"This may either be a full stream name, a partial wildcard stream name, or a full wildcard stream name.<br>For example, given the stream <i>a</i> you can use:<ul><li><i>a</i>: the stream configured as <i>a</i></li><li><i>a+</i>: all streams configured as <i>a</i> with a wildcard behind it, but not <i>a</i> itself</li><li><i>a+b</i>: only the version of stream <i>a</i> that has wildcard <i>b</i></li></ul>",
pointer:{main:g,index:"target"},validate:["required",function(b){for(var c in a)if(mist.inputMatch(a[c],b))return false;return{msg:"Does not match a valid target.<br>Valid formats:<ul><li>"+a.join("</li><li>")+"</li></ul>",classes:["red"]}}],LTSonly:1},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Push")}},{type:"save",label:"Save","function":function(){var a={};a[c=="auto"?"push_auto_add":"push_start"]=g;mist.send(function(){UI.navto("Push")},a)}}]}]))};mist.data.LTS? pointer:{main:g,index:"stream"},validate:["required",function(a){a=a.split("+");a=a[0];return a in mist.data.streams?false:{msg:"'"+a+"' is not a stream name.",classes:["orange"],"break":false}}],datalist:t,LTSonly:1},{label:"Target",type:"str",help:"Where the stream will be pushed to.<br>Valid formats:<ul><li>"+h.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>",
mist.send(function(a){(t=a.active_streams)||(t=[]);var a=[],b;for(b in t)t[b].indexOf("+")!=-1&&a.push(t[b].replace(/\+.*/,"")+"+");t=t.concat(a);var c=0,d=0;for(b in mist.data.streams){t.push(b);if(mist.inputMatch(UI.findInput("Folder").source_match,mist.data.streams[b].source)){t.push(b+"+");mist.send(function(a,b){var e=b.stream,g;for(g 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")>= pointer:{main:g,index:"target"},validate:["required",function(a){for(var b in h)if(mist.inputMatch(h[b],a))return false;return{msg:"Does not match a valid target.<br>Valid formats:<ul><li>"+h.join("</li><li>")+"</li></ul>",classes:["red"]}}],LTSonly:1}];c=="auto"&&f.push({type:"unix",label:"Schedule time",min:0,help:"TODO",pointer:{main:g,index:"scheduletime"}},{type:"unix",label:"Recording start time",min:0,help:"TODO",pointer:{main:g,index:"recstartunix"}},{type:"unix",label:"Complete time",min:0,
0)||mist.inputMatch(mist.data.capabilities.inputs[f].source_match,"/"+a.browse.files[g])&&t.push(e+"+"+a.browse.files[g]);d++;if(c==d){t=t.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();ca()}},{browse:mist.data.streams[b].source},{stream:b});c++}}if(c==d){t=t.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();ca()}},{active_streams:1}):(t=Object.keys(mist.data.streams),ca());break;case "Triggers":"triggers"in mist.data.config||(mist.data.config.triggers={});x=$("<tbody>");b= help:"TODO",pointer:{main:g,index:"completetime"}});f.push({type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Push")}},{type:"save",label:"Save","function":function(){var b={};g.recstartunix?b.recstartunix="recstartunix="+g.recstartunix:g.scheduletime&&(b.recstartunix="recstartunix="+g.scheduletime);delete g.recstartunix;if(Object.keys(b).length){var d="?",e=g.target.split("?");if(e.length>1){var d="&",e=e[e.length-1],e=e.split("&"),f;for(f in e){var h=e[f].split("=")[0];
$("<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(x);d.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(b); h in b&&delete b[h]}}if(Object.keys(b).length){d=d+Object.values(b).join("&");g.target=g.target+d}}b={};b[c=="auto"?"push_auto_add":"push_start"]=g;if(typeof a!="undefined")b.push_auto_remove=[a];mist.send(function(){UI.navto("Push")},b)}}]});d.append(UI.buildUI(f))}};mist.data.LTS?mist.send(function(a){(t=a.active_streams)||(t=[]);var a=[],b;for(b in t)t[b].indexOf("+")!=-1&&a.push(t[b].replace(/\+.*/,"")+"+");t=t.concat(a);var c=0,d=0;for(b in mist.data.streams){t.push(b);if(mist.inputMatch(UI.findInput("Folder").source_match,
b.stupidtable();b=mist.data.config.triggers;for(g in b)for(h in b[g])r=triggerRewrite(b[g][h]),x.append($("<tr>").attr("data-index",g+","+h).append($("<td>").text(g)).append($("<td>").text("streams"in r?r.streams.join(", "):"")).append($("<td>").text(r.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(","); mist.data.streams[b].source)){t.push(b+"+");mist.send(function(a,b){var e=b.stream,f;for(f in a.browse.files)for(var h in mist.data.capabilities.inputs)h.indexOf("Buffer")>=0||(h.indexOf("Folder")>=0||h.indexOf("Buffer.exe")>=0||h.indexOf("Folder.exe")>=0)||mist.inputMatch(mist.data.capabilities.inputs[h].source_match,"/"+a.browse.files[f])&&t.push(e+"+"+a.browse.files[f]);d++;if(c==d){t=t.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();U()}},{browse:mist.data.streams[b].source},{stream:b});
if(confirm("Are you sure you want to delete this "+a[0]+" trigger?")){mist.data.config.triggers[a[0]].splice(a[1],1);mist.data.config.triggers[a[0]].length==0&&delete mist.data.config.triggers[a[0]];mist.send(function(){UI.navto("Triggers")},{config:mist.data.config})}}))));break;case "Edit Trigger":"triggers"in mist.data.config||(mist.data.config.triggers={});c?(c=c.split(","),g=triggerRewrite(mist.data.config.triggers[c[0]][c[1]]),n={triggeron:c[0],appliesto:g.streams,url:g.handler,async:g.sync, c++}}if(c==d){t=t.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();U()}},{active_streams:1}):(t=Object.keys(mist.data.streams),U());break;case "Triggers":"triggers"in mist.data.config||(mist.data.config.triggers={});x=$("<tbody>");b=$("<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",
"default":g["default"],params:g.params}):(d.html($("<h2>").text("New Trigger")),n={});d.append(UI.buildUI([{label:"Trigger on",pointer:{main:n,index:"triggeron"},help:"For what event this trigger should activate.",type:"select",select:[["SYSTEM_START","SYSTEM_START: after MistServer boot"],["SYSTEM_STOP","SYSTEM_STOP: right before MistServer shutdown"],["SYSTEM_CONFIG","SYSTEM_CONFIG: after MistServer configurations have changed"],["OUTPUT_START","OUTPUT_START: right after the start command has been send to a protocol"], "string")).append($("<th>")))).append(x);d.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(b);b.stupidtable();b=mist.data.config.triggers;
["OUTPUT_STOP","OUTPUT_STOP: right after the close command has been send to a protocol "],["STREAM_ADD","STREAM_ADD: right before new stream configured"],["STREAM_CONFIG","STREAM_CONFIG: right before a stream configuration has changed"],["STREAM_REMOVE","STREAM_REMOVE: right before a stream has been deleted"],["STREAM_SOURCE","STREAM_SOURCE: right before stream source is loaded"],["STREAM_LOAD","STREAM_LOAD: right before stream input is loaded in memory"],["STREAM_READY","STREAM_READY: when the stream input is loaded and ready for playback"], for(h in b)for(e in b[h])r=triggerRewrite(b[h][e]),x.append($("<tr>").attr("data-index",h+","+e).append($("<td>").text(h)).append($("<td>").text("streams"in r?r.streams.join(", "):"")).append($("<td>").text(r.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 "+
["STREAM_UNLOAD","STREAM_UNLOAD: right before the stream input is removed from memory"],["STREAM_PUSH","STREAM_PUSH: right before an incoming push is accepted"],["STREAM_TRACK_ADD","STREAM_TRACK_ADD: right before a track will be added to a stream; e.g.: additional push received"],["STREAM_TRACK_REMOVE","STREAM_TRACK_REMOVE: right before a track will be removed track from a stream; e.g.: push timeout"],["STREAM_BUFFER","STREAM_BUFFER: when a buffer changes between mostly full or mostly empty"],["RTMP_PUSH_REWRITE", a[0]+" trigger?")){mist.data.config.triggers[a[0]].splice(a[1],1);mist.data.config.triggers[a[0]].length==0&&delete mist.data.config.triggers[a[0]];mist.send(function(){UI.navto("Triggers")},{config:mist.data.config})}}))));break;case "Edit Trigger":"triggers"in mist.data.config||(mist.data.config.triggers={});c?(c=c.split(","),h=triggerRewrite(mist.data.config.triggers[c[0]][c[1]]),n={triggeron:c[0],appliesto:h.streams,url:h.handler,async:h.sync,"default":h["default"],params:h.params}):(d.html($("<h2>").text("New Trigger")),
"RTMP_PUSH_REWRITE: allows rewriting of RTMP push URLs from external to internal representation before further parsing"],["PUSH_OUT_START","PUSH_OUT_START: before recording/pushing, allow target changes."],["RECORDING_END","RECORDING_END: after a recording finishes."],["CONN_OPEN","CONN_OPEN: right after a new incoming connection has been received"],["CONN_CLOSE","CONN_CLOSE: right after a connection has been closed"],["CONN_PLAY","CONN_PLAY: right before a stream playback of a connection"],["USER_NEW", n={});d.append(UI.buildUI([{label:"Trigger on",pointer:{main:n,index:"triggeron"},help:"For what event this trigger should activate.",type:"select",select:[["SYSTEM_START","SYSTEM_START: after MistServer boot"],["SYSTEM_STOP","SYSTEM_STOP: right before MistServer shutdown"],["SYSTEM_CONFIG","SYSTEM_CONFIG: after MistServer configurations have changed"],["OUTPUT_START","OUTPUT_START: right after the start command has been send to a protocol"],["OUTPUT_STOP","OUTPUT_STOP: right after the close command has been send to a protocol "],
"USER_NEW: a new user connects that hasn't been allowed or denied access before"],["LIVE_BANDWIDTH","LIVE_BANDWIDTH: when the value specified as param is surpassed"]],LTSonly:!0,validate:["required"],"function":function(){switch($(this).getval()){case "SYSTEM_START":case "SYSTEM_STOP":case "SYSTEM_CONFIG":case "OUTPUT_START":case "OUTPUT_STOP":case "RTMP_PUSH_REWRITE":$("[name=appliesto]").setval([]).closest(".UIelement").hide();$("[name=params]").setval("").closest(".UIelement").hide();break;case "LIVE_BANDWIDTH":$("[name=appliesto]").closest(".UIelement").show(); ["STREAM_ADD","STREAM_ADD: right before new stream configured"],["STREAM_CONFIG","STREAM_CONFIG: right before a stream configuration has changed"],["STREAM_REMOVE","STREAM_REMOVE: right before a stream has been deleted"],["STREAM_SOURCE","STREAM_SOURCE: right before stream source is loaded"],["STREAM_LOAD","STREAM_LOAD: right before stream input is loaded in memory"],["STREAM_READY","STREAM_READY: when the stream input is loaded and ready for playback"],["STREAM_UNLOAD","STREAM_UNLOAD: right before the stream input is removed from memory"],
$("[name=params]").closest(".UIelement").show();break;default:$("[name=appliesto]").closest(".UIelement").show();$("[name=params]").setval("").closest(".UIelement").hide()}}},{label:"Applies to",pointer:{main:n,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.", ["STREAM_PUSH","STREAM_PUSH: right before an incoming push is accepted"],["STREAM_TRACK_ADD","STREAM_TRACK_ADD: right before a track will be added to a stream; e.g.: additional push received"],["STREAM_TRACK_REMOVE","STREAM_TRACK_REMOVE: right before a track will be removed track from a stream; e.g.: push timeout"],["STREAM_BUFFER","STREAM_BUFFER: when a buffer changes between mostly full or mostly empty"],["RTMP_PUSH_REWRITE","RTMP_PUSH_REWRITE: allows rewriting of RTMP push URLs from external to internal representation before further parsing"],
pointer:{main:n,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:n,index:"async"},LTSonly:!0},{label:"Parameters",type:"str",help:"The extra data you want this trigger to use.",pointer:{main:n,index:"params"}, ["PUSH_OUT_START","PUSH_OUT_START: before recording/pushing, allow target changes."],["RECORDING_END","RECORDING_END: after a recording finishes."],["CONN_OPEN","CONN_OPEN: right after a new incoming connection has been received"],["CONN_CLOSE","CONN_CLOSE: right after a connection has been closed"],["CONN_PLAY","CONN_PLAY: right before a stream playback of a connection"],["USER_NEW","USER_NEW: a new user connects that hasn't been allowed or denied access before"],["LIVE_BANDWIDTH","LIVE_BANDWIDTH: when the value specified as param is surpassed"]],
LTSonly:!0},{label:"Default response",type:"str",help:"For blocking requests, the default response in case the handler cannot be executed for any reason.",pointer:{main:n,index:"default"},LTSonly:!0},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Triggers")}},{type:"save",label:"Save","function":function(){c&&mist.data.config.triggers[c[0]].splice(c[1],1);var a={handler:n.url,sync:n.async?true:false,streams:typeof n.appliesto=="undefined"?[]:n.appliesto,params:n.params, LTSonly:!0,validate:["required"],"function":function(){switch($(this).getval()){case "SYSTEM_START":case "SYSTEM_STOP":case "SYSTEM_CONFIG":case "OUTPUT_START":case "OUTPUT_STOP":case "RTMP_PUSH_REWRITE":$("[name=appliesto]").setval([]).closest(".UIelement").hide();$("[name=params]").setval("").closest(".UIelement").hide();break;case "LIVE_BANDWIDTH":$("[name=appliesto]").closest(".UIelement").show();$("[name=params]").closest(".UIelement").show();break;default:$("[name=appliesto]").closest(".UIelement").show();
"default":n["default"]};if(!("triggers"in mist.data.config))mist.data.config.triggers={};n.triggeron in mist.data.config.triggers||(mist.data.config.triggers[n.triggeron]=[]);mist.data.config.triggers[n.triggeron].push(a);mist.send(function(){UI.navto("Triggers")},{config:mist.data.config})}}]}]));$("[name=triggeron]").trigger("change");break;case "Logs":var qa=$("<button>").text("Refresh now").click(function(){$(this).text("Loading..");mist.send(function(){da();qa.text("Refresh now")})}).css("padding", $("[name=params]").setval("").closest(".UIelement").hide()}}},{label:"Applies to",pointer:{main:n,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:n,index:"url"},validate:["required"],
"0.2em 0.5em").css("flex-grow",0);d.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(){da()})},$(this).val()*1E3)},help:"How often the table below should be updated."}, 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:n,index:"async"},LTSonly:!0},{label:"Parameters",type:"str",help:"The extra data you want this trigger to use.",pointer:{main:n,index:"params"},LTSonly:!0},{label:"Default response",type:"str",
{label:"..or",type:"DOMfield",DOMfield:qa,help:"Instantly refresh the table below."}]));d.append($("<button>").text("Purge logs").click(function(){mist.send(function(){mist.data.log=[];UI.navto("Logs")},{clearstatlogs:true})}));x=$("<tbody>").css("font-size","0.9em");d.append($("<table>").addClass("logs").append(x));var sa=function(a){var b=$("<span>").text(a);switch(a){case "WARN":b.addClass("orange");break;case "ERROR":case "FAIL":b.addClass("red")}return b},da=function(){var a=mist.data.log;if(a){a.length>= help:"For blocking requests, the default response in case the handler cannot be executed for any reason.",pointer:{main:n,index:"default"},LTSonly:!0},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Triggers")}},{type:"save",label:"Save","function":function(){c&&mist.data.config.triggers[c[0]].splice(c[1],1);var a={handler:n.url,sync:n.async?true:false,streams:typeof n.appliesto=="undefined"?[]:n.appliesto,params:n.params,"default":n["default"]};if(!("triggers"in
2&&a[0][0]<a[a.length-1][0]&&a.reverse();x.html("");for(var b in a){var c=$("<span>").addClass("content"),d=a[b][2].split("|"),e;for(e in d)c.append($("<span>").text(d[e]));x.append($("<tr>").html($("<td>").text(UI.format.dateTime(a[b][0],"long")).css("white-space","nowrap")).append($("<td>").html(sa(a[b][1])).css("text-align","center")).append($("<td>").html(c).css("text-align","left")))}}};da();break;case "Statistics":var C=$("<span>").text("Loading..");d.append(C);var n={graph:"new"},w=mist.stored.get().graphs? mist.data.config))mist.data.config.triggers={};n.triggeron in mist.data.config.triggers||(mist.data.config.triggers[n.triggeron]=[]);mist.data.config.triggers[n.triggeron].push(a);mist.send(function(){UI.navto("Triggers")},{config:mist.data.config})}}]}]));$("[name=triggeron]").trigger("change");break;case "Logs":var ra=$("<button>").text("Refresh now").click(function(){$(this).text("Loading..");mist.send(function(){da();ra.text("Refresh now")})}).css("padding","0.2em 0.5em").css("flex-grow",0);d.append(UI.buildUI([{type:"help",
$.extend(!0,{},mist.stored.get().graphs):{},P={};for(g in mist.data.streams)P[g]=!0;for(g in mist.data.active_streams)P[mist.data.active_streams[g]]=!0;var P=Object.keys(P).sort(),ea=[];for(g in mist.data.config.protocols)ea.push(mist.data.config.protocols[g].connector);ea.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; 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(){da()})},$(this).val()*1E3)},help:"How often the table below should be updated."},{label:"..or",type:"DOMfield",
C.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:n,index:"graph"},classes:["graph_ids"],"function":function(){if($(this).val()){var a=C.find(".graph_xaxis"),b=C.find(".graph_id");if($(this).val()=="new"){a.children("option").prop("disabled", DOMfield:ra,help:"Instantly refresh the table below."}]));d.append($("<button>").text("Purge logs").click(function(){mist.send(function(){mist.data.log=[];UI.navto("Logs")},{clearstatlogs:true})}));x=$("<tbody>").css("font-size","0.9em");d.append($("<table>").addClass("logs").append(x));var ta=function(a){var b=$("<span>").text(a);switch(a){case "WARN":b.addClass("orange");break;case "ERROR":case "FAIL":b.addClass("red")}return b},da=function(){var a=mist.data.log;if(a){a.length>=2&&a[0][0]<a[a.length-
false);b.setval("Graph "+(Object.keys(w).length+1)).closest("label").show()}else{var c=w[$(this).val()].xaxis;a.children("option").prop("disabled",true).filter('[value="'+c+'"]').prop("disabled",false);b.closest("label").hide()}a.children('option[value="'+a.val()+'"]:disabled').length&&a.val(a.children("option:enabled").first().val());a.trigger("change")}}},{label:"Graph id",type:"str",pointer:{main:n,index:"id"},classes:["graph_id"],validate:[function(a){return a in w?{msg:"This graph id has already been used. Please enter something else.", 1][0]&&a.reverse();x.html("");for(var b in a){var c=$("<span>").addClass("content"),d=a[b][2].split("|"),e;for(e in d)c.append($("<span>").text(d[e]));x.append($("<tr>").html($("<td>").text(UI.format.dateTime(a[b][0],"long")).css("white-space","nowrap")).append($("<td>").html(ta(a[b][1])).css("text-align","center")).append($("<td>").html(c).css("text-align","left")))}}};da();break;case "Statistics":var C=$("<span>").text("Loading..");d.append(C);var n={graph:"new"},w=mist.stored.get().graphs?$.extend(!0,
classes:["red"]}:false}]},{label:"Axis type",type:"select",select:[["time","Time line"]],pointer:{main:n,index:"xaxis"},value:"time",classes:["graph_xaxis"],"function":function(){$s=C.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()+ {},mist.stored.get().graphs):{},P={};for(h in mist.data.streams)P[h]=!0;for(h in mist.data.active_streams)P[mist.data.active_streams[h]]=!0;var P=Object.keys(P).sort(),ea=[];for(h in mist.data.config.protocols)ea.push(mist.data.config.protocols[h].connector);ea.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;C.html(UI.buildUI([{type:"help",
'"]:disabled').length){$s.val($s.children("option:enabled").first().val());$s.trigger("change")}}},{label:"Data type",type:"select",select:[["clients","Connections"],["upbps","Bandwidth (up)"],["downbps","Bandwidth (down)"],["cpuload","CPU use"],["memload","Memory load"],["coords","Client location"]],pointer:{main:n,index:"datatype"},classes:["graph_datatype"],"function":function(){$s=C.find(".graph_origin");switch($(this).getval()){case "cpuload":case "memload":$s.find("input[type=radio]").not('[value="total"]').prop("disabled", 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:n,index:"graph"},classes:["graph_ids"],"function":function(){if($(this).val()){var a=C.find(".graph_xaxis"),b=C.find(".graph_id");if($(this).val()=="new"){a.children("option").prop("disabled",false);b.setval("Graph "+(Object.keys(w).length+
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:",P],["protocol","The protocol:",ea]],pointer:{main:n,index:"origin"},value:["total"],classes:["graph_origin"]},{type:"buttons",buttons:[{label:"Add data set",type:"save","function":function(){var a;if(n.graph=="new"){a=UI.plot.addGraph(n,b);w[a.id]=a;C.find("input.graph_id").val(""); 1)).closest("label").show()}else{var c=w[$(this).val()].xaxis;a.children("option").prop("disabled",true).filter('[value="'+c+'"]').prop("disabled",false);b.closest("label").hide()}a.children('option[value="'+a.val()+'"]:disabled').length&&a.val(a.children("option:enabled").first().val());a.trigger("change")}}},{label:"Graph id",type:"str",pointer:{main:n,index:"id"},classes:["graph_id"],validate:[function(a){return a in w?{msg:"This graph id has already been used. Please enter something else.",classes:["red"]}:
C.find("select.graph_ids").append($("<option>").text(a.id)).val(a.id).trigger("change")}else a=w[n.graph];var c=UI.plot.datatype.getOptions({datatype:n.datatype,origin:n.origin});a.datasets.push(c);UI.plot.save(a);UI.plot.go(w)}}]}]));var b=$("<div>").addClass("graph_container");d.append(b);var c=C.find("select.graph_ids");for(a in w){var e=UI.plot.addGraph(w[a],b);c.append($("<option>").text(e.id)).val(e.id);var g=[],f;for(f in w[a].datasets){var h=UI.plot.datatype.getOptions({datatype:w[a].datasets[f].datatype, false}]},{label:"Axis type",type:"select",select:[["time","Time line"]],pointer:{main:n,index:"xaxis"},value:"time",classes:["graph_xaxis"],"function":function(){$s=C.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());
origin:w[a].datasets[f].origin});g.push(h)}e.datasets=g;w[e.id]=e}c.trigger("change");UI.plot.go(w);UI.interval.set(function(){UI.plot.go(w)},1E4)},{active_streams:!0,capabilities:!0});break;case "Server Stats":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});d.append("Loading..");return}var fa=$("<table>"),E=$("<table>"),h={vheader:"CPUs",labels:["Model","Processor speed","Amount of cores","Amount of threads"],content:[]};for(g in mist.data.capabilities.cpu)b= $s.trigger("change")}}},{label:"Data type",type:"select",select:[["clients","Connections"],["upbps","Bandwidth (up)"],["downbps","Bandwidth (down)"],["cpuload","CPU use"],["memload","Memory load"],["coords","Client location"]],pointer:{main:n,index:"datatype"},classes:["graph_datatype"],"function":function(){$s=C.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",
mist.data.capabilities.cpu[g],h.content.push({header:"CPU #"+(Number(g)+1),body:[b.model,UI.format.addUnit(UI.format.number(b.mhz),"MHz"),b.cores,b.threads]});g=UI.buildVheaderTable(h);var ra=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* true);break;default:$s.find("input[type=radio]").prop("disabled",false)}}},{label:"Data origin",type:"radioselect",radioselect:[["total","All"],["stream","The stream:",P],["protocol","The protocol:",ea]],pointer:{main:n,index:"origin"},value:["total"],classes:["graph_origin"]},{type:"buttons",buttons:[{label:"Add data set",type:"save","function":function(){var a;if(n.graph=="new"){a=UI.plot.addGraph(n,b);w[a.id]=a;C.find("input.graph_id").val("");C.find("select.graph_ids").append($("<option>").text(a.id)).val(a.id).trigger("change")}else a=
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);fa.replaceWith(a);fa=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/ w[n.graph];var c=UI.plot.datatype.getOptions({datatype:n.datatype,origin:n.origin});a.datasets.push(c);UI.plot.save(a);UI.plot.go(w)}}]}]));var b=$("<div>").addClass("graph_container");d.append(b);var c=C.find("select.graph_ids");for(a in w){var e=UI.plot.addGraph(w[a],b);c.append($("<option>").text(e.id)).val(e.id);var h=[],f;for(f in w[a].datasets){var g=UI.plot.datatype.getOptions({datatype:w[a].datasets[f].datatype,origin:w[a].datasets[f].origin});h.push(g)}e.datasets=h;w[e.id]=e}c.trigger("change");
100),UI.format.number(b.fifteen/100)]}]};b=UI.buildVheaderTable(b);E.replaceWith(b);E=b};ra();d.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(fa)).append($("<td>").append(E))).append($("<tr>").append($("<td>").append(g).attr("colspan",2))));UI.interval.set(function(){mist.send(function(){ra()}, UI.plot.go(w);UI.interval.set(function(){UI.plot.go(w)},1E4)},{active_streams:!0,capabilities:!0});break;case "Server Stats":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});d.append("Loading..");return}var fa=$("<table>"),E=$("<table>"),e={vheader:"CPUs",labels:["Model","Processor speed","Amount of cores","Amount of threads"],content:[]};for(h in mist.data.capabilities.cpu)b=mist.data.capabilities.cpu[h],e.content.push({header:"CPU #"+(Number(h)+
{capabilities:true})},3E4);break;case "Email for Help":g=$.extend({},mist.data);delete g.statistics;delete g.totals;delete g.clients;delete g.capabilities;g=JSON.stringify(g);g="Version: "+mist.data.config.version+"\n\nConfig:\n"+g;n={};d.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:n,index:"name"}, 1),body:[b.model,UI.format.addUnit(UI.format.number(b.mhz),"MHz"),b.cores,b.threads]});h=UI.buildVheaderTable(e);var sa=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-
value:mist.user.name},{type:"email",label:"Your email address",validate:["required"],pointer:{main:n,index:"email"}},{type:"hidden",value:"Integrated Help",pointer:{main:n,index:"subject"}},{type:"hidden",value:"-",pointer:{main:n,index:"company"}},{type:"textarea",rows:20,label:"Your message",validate:["required"],pointer:{main:n,index:"message"}},{type:"textarea",rows:20,label:"Your config file",readonly:!0,value:g,pointer:{main:n,index:"configfile"}},{type:"buttons",buttons:[{type:"save",label:"Send", a.swapfree)*1048576),UI.format.addUnit("","N/A"),UI.format.bytes(a.swapfree*1048576),UI.format.bytes(a.swaptotal*1048576)]}]},a=UI.buildVheaderTable(a);fa.replaceWith(a);fa=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);E.replaceWith(b);E=
"function":function(a){$(a).text("Sending..");$.ajax({type:"POST",url:"https://mistserver.org/contact?skin=plain",data:n,success:function(a){a=$("<span>").html(a);a.find("script").remove();d.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:d.append($("<p>").text("This tab does not exist."))}d.find(".field").filter(function(){var a=$(this).getval(); b};sa();d.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(fa)).append($("<td>").append(E))).append($("<tr>").append($("<td>").append(h).attr("colspan",2))));UI.interval.set(function(){mist.send(function(){sa()},{capabilities:true})},3E4);break;case "Email for Help":h=$.extend({},mist.data);
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}});!navigator.doNotTrack&&mist.user.loggedin&&d.append($("<img>").attr("src","https://www.google-analytics.com/collect?v=1&tid=UA-32426932-1&cid="+mist.data.config.iid+"&t=pageview&dp="+encodeURIComponent("/MI/"+a)+"&dh=MI."+(mist.data.LTS?"Pro":"OS")).css({width:"1px",height:"1px","min-width":"1px",opacity:0.1, delete h.statistics;delete h.totals;delete h.clients;delete h.capabilities;h=JSON.stringify(h);h="Version: "+mist.data.config.version+"\n\nConfig:\n"+h;n={};d.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:n,index:"name"},value:mist.user.name},{type:"email",label:"Your email address",validate:["required"],
position:"absolute",left:"-1000px"}))}}};"origin"in location||(location.origin=location.protocol+"//");var host;host="file://"==location.origin?"http://localhost:4242/api":location.origin+location.pathname.replace(/\/+$/,"")+"/api"; pointer:{main:n,index:"email"}},{type:"hidden",value:"Integrated Help",pointer:{main:n,index:"subject"}},{type:"hidden",value:"-",pointer:{main:n,index:"company"}},{type:"textarea",rows:20,label:"Your message",validate:["required"],pointer:{main:n,index:"message"}},{type:"textarea",rows:20,label:"Your config file",readonly:!0,value:h,pointer:{main:n,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",
var mist={data:{},user:{name:"",password:"",host:host},send:function(a,c,d){var c=c||{},d=d||{},d=$.extend(true,{timeOut:3E4,sendData:c},d),b={authorize:{password:mist.user.authstring?MD5(mist.user.password+mist.user.authstring):"",username:mist.user.name}};$.extend(true,b,c);log("Send",$.extend(true,{},c));b={url:mist.user.host,type:"POST",data:{command:JSON.stringify(b)},dataType:"jsonp",crossDomain:true,timeout:d.timeout*1E3,async:true,error:function(b,e){delete mist.user.loggedin;if(!d.hide){switch(e){case "timeout":e= data:n,success:function(a){a=$("<span>").html(a);a.find("script").remove();d.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:d.append($("<p>").text("This tab does not exist."))}d.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)):
$("<i>").text("The connection timed out. ");break;case "abort":e=$("<i>").text("The connection was aborted. ");break;default:e=$("<i>").text(e+". ").css("text-transform","capitalize")}$("#message").addClass("red").text("An error occurred while attempting to communicate with MistServer:").append($("<br>")).append(e).append($("<a>").text("Send server request again").click(function(){mist.send(a,c,d)}))}UI.navto("Login")},success:function(b){log("Receive",$.extend(true,{},b),"as reply to",d.sendData); a=$(this).find("input, select, textarea");if(a.length){$(a[0]).focus();return false}});!navigator.doNotTrack&&mist.user.loggedin&&d.append($("<img>").attr("src","https://www.google-analytics.com/collect?v=1&tid=UA-32426932-1&cid="+mist.data.config.iid+"&t=pageview&dp="+encodeURIComponent("/MI/"+a)+"&dh=MI."+(mist.data.LTS?"Pro":"OS")).css({width:"1px",height:"1px","min-width":"1px",opacity:0.1,position:"absolute",left:"-1000px"}))}}};"origin"in location||(location.origin=location.protocol+"//");var host;
delete mist.user.loggedin;switch(b.authorize.status){case "OK":if("streams"in b)if(b.streams)if("incomplete list"in b.streams){delete b.streams["incomplete list"];$.extend(mist.data.streams,b.streams)}else mist.data.streams=b.streams;else mist.data.streams={};var e=$.extend({},b),f=["config","capabilities","ui_settings","LTS","active_streams","browse","log","totals"],q;for(q in e)f.indexOf(q)==-1&&delete e[q];$.extend(mist.data,e);mist.user.loggedin=true;UI.elements.connection.status.text("Connected").removeClass("red").addClass("green"); host="file://"==location.origin?"http://localhost:4242/api":location.origin+location.pathname.replace(/\/+$/,"")+"/api";
UI.elements.connection.user_and_host.text(mist.user.name+" @ "+mist.user.host);UI.elements.connection.msg.removeClass("red").text("Last communication with the server at "+UI.format.time((new Date).getTime()/1E3));b.LTS&&UI.elements.menu.find(".LTSonly").removeClass("LTSonly");if(b.log){e=b.log[b.log.length-1];UI.elements.connection.msg.append($("<br>")).append("Last log entry: "+UI.format.time(e[0])+" ["+e[1]+"] "+e[2])}if("totals"in b){e=function(a,b,c){var d;d=function(){for(var a in c.fields)e[c.fields[a]].push([l, var mist={data:{},user:{name:"",password:"",host:host},send:function(a,c,d){var c=c||{},d=d||{},d=$.extend(true,{timeOut:3E4,sendData:c},d),b={authorize:{password:mist.user.authstring?MD5(mist.user.password+mist.user.authstring):"",username:mist.user.name}};$.extend(true,b,c);log("Send",$.extend(true,{},c));b={url:mist.user.host,type:"POST",data:{command:JSON.stringify(b)},dataType:"jsonp",crossDomain:true,timeout:d.timeout*1E3,async:true,error:function(b,g){delete mist.user.loggedin;if(!d.hide){switch(g){case "timeout":g=
0])};var e={},f;for(f in c.fields)e[c.fields[f]]=[];var g=0,l;if(c.data){if(c.start>mist.data.config.time-600){l=(mist.data.config.time-600)*1E3;d();l=c.start*1E3;d()}else l=c.start*1E3;for(f in c.data){if(f==0){l=c.start*1E3;var q=0}else{l=l+c.interval[q][1]*1E3;c.interval[q][0]--;if(c.interval[q][0]<=0){q++;q<c.interval.length-1&&(g=g+2)}}if(g%2==1){d();g--}for(var x in c.data[f])e[c.fields[x]].push([l,c.data[f][x]]);if(g){d();g--}}if(mist.data.config.time-c.end>20){d();l=(mist.data.config.time- $("<i>").text("The connection timed out. ");break;case "abort":g=$("<i>").text("The connection was aborted. ");break;default:g=$("<i>").text(g+". ").css("text-transform","capitalize")}$("#message").addClass("red").text("An error occurred while attempting to communicate with MistServer:").append($("<br>")).append(g).append($("<a>").text("Send server request again").click(function(){mist.send(a,c,d)}))}UI.navto("Login")},success:function(b){log("Receive",$.extend(true,{},b),"as reply to",d.sendData);
15)*1E3;d()}}else{l=(mist.data.config.time-600)*1E3;d();l=(mist.data.config.time-15)*1E3;d()}d=e;stream=a?a.join(" "):"all_streams";protocol=b?b.join("_"):"all_protocols";stream in mist.data.totals||(mist.data.totals[stream]={});protocol in mist.data.totals[stream]||(mist.data.totals[stream][protocol]={});$.extend(mist.data.totals[stream][protocol],d)};mist.data.totals={};if("fields"in b.totals)e(c.totals.streams,c.totals.protocols,b.totals);else for(q in b.totals)e(c.totals[q].streams,c.totals[q].protocols, delete mist.user.loggedin;switch(b.authorize.status){case "OK":if("streams"in b)if(b.streams)if("incomplete list"in b.streams){delete b.streams["incomplete list"];$.extend(mist.data.streams,b.streams)}else mist.data.streams=b.streams;else mist.data.streams={};var g=$.extend({},b),f=["config","capabilities","ui_settings","LTS","active_streams","browse","log","totals"],q;for(q in g)f.indexOf(q)==-1&&delete g[q];$.extend(mist.data,g);mist.user.loggedin=true;UI.elements.connection.status.text("Connected").removeClass("red").addClass("green");
UI.elements.connection.user_and_host.text(mist.user.name+" @ "+mist.user.host);UI.elements.connection.msg.removeClass("red").text("Last communication with the server at "+UI.format.time((new Date).getTime()/1E3));b.LTS&&UI.elements.menu.find(".LTSonly").removeClass("LTSonly");if(b.log){g=b.log[b.log.length-1];UI.elements.connection.msg.append($("<br>")).append("Last log entry: "+UI.format.time(g[0])+" ["+g[1]+"] "+g[2])}if("totals"in b){g=function(a,b,c){var d;d=function(){for(var a in c.fields)f[c.fields[a]].push([l,
0])};var f={},g;for(g in c.fields)f[c.fields[g]]=[];var h=0,l;if(c.data){if(c.start>mist.data.config.time-600){l=(mist.data.config.time-600)*1E3;d();l=c.start*1E3;d()}else l=c.start*1E3;for(g in c.data){if(g==0){l=c.start*1E3;var q=0}else{l=l+c.interval[q][1]*1E3;c.interval[q][0]--;if(c.interval[q][0]<=0){q++;q<c.interval.length-1&&(h=h+2)}}if(h%2==1){d();h--}for(var x in c.data[g])f[c.fields[x]].push([l,c.data[g][x]]);if(h){d();h--}}if(mist.data.config.time-c.end>20){d();l=(mist.data.config.time-
15)*1E3;d()}}else{l=(mist.data.config.time-600)*1E3;d();l=(mist.data.config.time-15)*1E3;d()}d=f;stream=a?a.join(" "):"all_streams";protocol=b?b.join("_"):"all_protocols";stream in mist.data.totals||(mist.data.totals[stream]={});protocol in mist.data.totals[stream]||(mist.data.totals[stream][protocol]={});$.extend(mist.data.totals[stream][protocol],d)};mist.data.totals={};if("fields"in b.totals)g(c.totals.streams,c.totals.protocols,b.totals);else for(q in b.totals)g(c.totals[q].streams,c.totals[q].protocols,
b.totals[q])}a&&a(b,d);break;case "CHALL":if(b.authorize.challenge==mist.user.authstring){mist.user.password!=""&&UI.elements.connection.msg.text("The credentials you provided are incorrect.").addClass("red");UI.navto("Login")}else if(mist.user.password=="")UI.navto("Login");else{mist.user.authstring=b.authorize.challenge;mist.send(a,c,d);sessionStorage.setItem("mistLogin",JSON.stringify({host:mist.user.host,name:mist.user.name,password:mist.user.password}))}break;case "NOACC":UI.navto("Create a new account"); b.totals[q])}a&&a(b,d);break;case "CHALL":if(b.authorize.challenge==mist.user.authstring){mist.user.password!=""&&UI.elements.connection.msg.text("The credentials you provided are incorrect.").addClass("red");UI.navto("Login")}else if(mist.user.password=="")UI.navto("Login");else{mist.user.authstring=b.authorize.challenge;mist.send(a,c,d);sessionStorage.setItem("mistLogin",JSON.stringify({host:mist.user.host,name:mist.user.name,password:mist.user.password}))}break;case "NOACC":UI.navto("Create a new account");
break;case "ACC_MADE":delete c.authorize;mist.send(a,c,d);break;default:UI.navto("Login")}}};d.hide||UI.elements.connection.msg.removeClass("red").text("Data sent, waiting for a reply..").append($("<br>")).append($("<a>").text("Cancel request").click(function(){e.abort()}));var e=$.ajax(b)},inputMatch:function(a,c){if(typeof a=="undefined")return false;typeof a=="string"&&(a=[a]);for(var d in a){var b=a[d].replace(/[^\w\s]/g,"\\$&"),b=b.replace(/\\\*/g,".*");if(RegExp("^(?:[a-zA-Z]:)?"+b+"(?:\\?[^\\?]*)?$", break;case "ACC_MADE":delete c.authorize;mist.send(a,c,d);break;default:UI.navto("Login")}}};d.hide||UI.elements.connection.msg.removeClass("red").text("Data sent, waiting for a reply..").append($("<br>")).append($("<a>").text("Cancel request").click(function(){g.abort()}));var g=$.ajax(b)},inputMatch:function(a,c){if(typeof a=="undefined")return false;typeof a=="string"&&(a=[a]);for(var d in a){var b=a[d].replace(/[^\w\s]/g,"\\$&"),b=b.replace(/\\\*/g,".*");if(RegExp("^(?:[a-zA-Z]:)?"+b+"(?:\\?[^\\?]*)?$",
"i").test(c))return true}return false},convertBuildOptions:function(a,c){var d=[],b=["required","optional"];"desc"in a&&d.push({type:"help",help:a.desc});for(var e in b)if(a[b[e]]){d.push($("<h4>").text(UI.format.capital(b[e])+" parameters"));for(var g in a[b[e]]){var l=a[b[e]][g],f={label:UI.format.capital(l.name),pointer:{main:c,index:g},validate:[]};b[e]=="required"&&(!("default"in l)||l["default"]=="")&&f.validate.push("required");if("default"in l)f.placeholder=l["default"];if("help"in l)f.help= "i").test(c))return true}return false},convertBuildOptions:function(a,c){var d=[],b=["required","optional"];"desc"in a&&d.push({type:"help",help:a.desc});for(var g in b)if(a[b[g]]){d.push($("<h4>").text(UI.format.capital(b[g])+" parameters"));for(var h in a[b[g]]){var l=a[b[g]][h],f={label:UI.format.capital(l.name),pointer:{main:c,index:h},validate:[]};b[g]=="required"&&(!("default"in l)||l["default"]=="")&&f.validate.push("required");if("default"in l)f.placeholder=l["default"];if("help"in l)f.help=
l.help;if("unit"in l)f.unit=l.unit;switch(l.type){case "int":f.type="int";break;case "uint":f.type="int";f.min=0;break;case "debug":f.type="debug";break;case "select":f.type="select";f.select=l.select;break;default:f.type="str"}d.push(f)}}return d},stored:{get:function(){return mist.data.ui_settings||{}},set:function(a,c){var d=this.get();d[a]=c;mist.send(function(){},{ui_settings:d})},del:function(a){delete mist.data.ui_settings[a];mist.send(function(){},{ui_settings:mist.data.ui_settings})}}}; l.help;if("unit"in l)f.unit=l.unit;switch(l.type){case "int":f.type="int";break;case "uint":f.type="int";f.min=0;break;case "debug":f.type="debug";break;case "select":f.type="select";f.select=l.select;break;default:f.type="str"}d.push(f)}}return d},stored:{get:function(){return mist.data.ui_settings||{}},set:function(a,c){var d=this.get();d[a]=c;mist.send(function(){},{ui_settings:d})},del:function(a){delete mist.data.ui_settings[a];mist.send(function(){},{ui_settings:mist.data.ui_settings})}}};
function log(){try{UI.debug&&[].push.call(arguments,Error().stack);[].unshift.call(arguments,"["+UI.format.time((new Date).getTime()/1E3)+"]");console.log.apply(console,arguments)}catch(a){}} function log(){try{UI.debug&&[].push.call(arguments,Error().stack);[].unshift.call(arguments,"["+UI.format.time((new Date).getTime()/1E3)+"]");console.log.apply(console,arguments)}catch(a){}}
$.fn.getval=function(){var a=$(this).data("opts"),c=$(this).val();if(a&&"type"in a)switch(a.type){case "span":c=$(this).html();break;case "checkbox":c=$(this).prop("checked");break;case "radioselect":a=$(this).find("label > input[type=radio]:checked").parent();if(a.length){c=[];c.push(a.children("input[type=radio]").val());a=a.children("select");a.length&&c.push(a.val())}else c="";break;case "checklist":c=[];$(this).find(".checklist input[type=checkbox]:checked").each(function(){c.push($(this).attr("name"))})}return c}; $.fn.getval=function(){var a=$(this).data("opts"),c=$(this).val();if(a&&"type"in a)switch(a.type){case "span":c=$(this).html();break;case "checkbox":c=$(this).prop("checked");break;case "radioselect":a=$(this).find("label > input[type=radio]:checked").parent();if(a.length){c=[];c.push(a.children("input[type=radio]").val());a=a.children("select");a.length&&c.push(a.val())}else c="";break;case "checklist":c=[];$(this).find(".checklist input[type=checkbox]:checked").each(function(){c.push($(this).attr("name"))});
break;case "unix":c!=""&&(c=Math.round(new Date($(this).val())/1E3))}return c};
$.fn.setval=function(a){var c=$(this).data("opts");$(this).val(a);if(c&&"type"in c)switch(c.type){case "span":$(this).html(a);break;case "checkbox":$(this).prop("checked",a);break;case "geolimited":case "hostlimited":c=$(this).closest(".field_container").data("subUI");if(typeof a=="undefined"||a.length==0)a="-";c.blackwhite.val(a.charAt(0));var a=a.substr(1).split(" "),d;for(d in a)c.values.append(c.prototype.clone(true).val(a[d]));c.blackwhite.trigger("change");break;case "radioselect":if(typeof a== $.fn.setval=function(a){var c=$(this).data("opts");$(this).val(a);if(c&&"type"in c)switch(c.type){case "span":$(this).html(a);break;case "checkbox":$(this).prop("checked",a);break;case "geolimited":case "hostlimited":c=$(this).closest(".field_container").data("subUI");if(typeof a=="undefined"||a.length==0)a="-";c.blackwhite.val(a.charAt(0));var a=a.substr(1).split(" "),d;for(d in a)c.values.append(c.prototype.clone(true).val(a[d]));c.blackwhite.trigger("change");break;case "radioselect":if(typeof a==
"undefined")return $(this);d=$(this).find('label > input[type=radio][value="'+a[0]+'"]').prop("checked",true).parent();a.length>1&&d.children("select").val(a[1]);break;case "checklist":c=$(this).find(".checklist input[type=checkbox]").prop("checked",false);for(d in a)c.filter('[name="'+a[d]+'"]').prop("checked",true)}$(this).trigger("change");return $(this)};function parseURL(a){var c=document.createElement("a");c.href=a;return{protocol:c.protocol+"//",host:c.hostname,port:c.port?":"+c.port:""}} "undefined")return $(this);d=$(this).find('label > input[type=radio][value="'+a[0]+'"]').prop("checked",true).parent();a.length>1&&d.children("select").val(a[1]);break;case "checklist":c=$(this).find(".checklist input[type=checkbox]").prop("checked",false);for(d in a)c.filter('[name="'+a[d]+'"]').prop("checked",true);break;case "unix":if(typeof a!="undefined"){a=new Date(Math.round(a)*1E3);a.setMinutes(a.getMinutes()-a.getTimezoneOffset());a=a.toISOString();$(this).val(a.split("Z")[0])}}$(this).trigger("change");
function triggerRewrite(a){return typeof a=="object"&&typeof a.length=="undefined"?a:obj={handler:a[0],sync:a[1],streams:a[2],"default":a[3]}}; return $(this)};function parseURL(a){var c=document.createElement("a");c.href=a;return{protocol:c.protocol+"//",host:c.hostname,port:c.port?":"+c.port:""}}function triggerRewrite(a){return typeof a=="object"&&typeof a.length=="undefined"?a:obj={handler:a[0],sync:a[1],streams:a[2],"default":a[3]}};

View file

@ -629,6 +629,12 @@ var UI = {
case 'DOMfield': case 'DOMfield':
$field = e.DOMfield; $field = e.DOMfield;
break; break;
case "unix":
$field = $("<input>").attr("type","datetime-local").attr("step",1);
e.unit = $("<button>").text("Now").click(function(){
$(this).closest(".field_container").find(".field").setval((new Date()).getTime()/1e3);
});
break;
default: default:
$field = $('<input>').attr('type','text'); $field = $('<input>').attr('type','text');
} }
@ -1045,7 +1051,7 @@ var UI = {
} }
$ihc.prepend($err); $ihc.prepend($err);
if (focusonerror) { $(me).focus(); } if (focusonerror) { $(me).focus(); }
return true; return ((typeof error == "object") && ("break" in error) ? error["break"] : true);
} }
} }
return false; return false;
@ -4306,7 +4312,16 @@ var UI = {
} }
function buildTr(push,type) { function buildTr(push,type) {
var $target = $('<span>'); var $target = $('<span>');
if ((push.length >= 4) && (push[2] != push[3])) { if ((type == "Automatic") && (push.length >= 4)) {
$target.append(
$('<span>').text(push[2])
).append(
$('<span>').text(', schedule on '+(new Date(push[3]*1e3)).toLocaleString())
).append(
$('<span>').text(", complete on "+(new Date(push[4]*1e3)).toLocaleString())
);
}
else if ((push.length >= 4) && (push[2] != push[3])) {
$target.append( $target.append(
$('<span>').text(push[2]) $('<span>').text(push[2])
).append( ).append(
@ -4330,12 +4345,10 @@ var UI = {
) )
); );
if (type == 'Automatic') { if (type == 'Automatic') {
var a = push.slice(1);
mist.send(function(){ mist.send(function(){
$tr.remove(); $tr.remove();
},{'push_auto_remove':{ },{'push_auto_remove':[a]});
stream: push[1],
target: push[2]
}});
} }
else { else {
mist.send(function(d){ mist.send(function(d){
@ -4346,6 +4359,11 @@ var UI = {
}) })
); );
if (type == 'Automatic') { if (type == 'Automatic') {
$buttons.prepend(
$("<button>").text("Edit").click(function(){
UI.navto("Start Push","auto_"+($(this).closest("tr").index()-1));
})
);
$buttons.append( $buttons.append(
$('<button>').text('Stop pushes').click(function(){ $('<button>').text('Stop pushes').click(function(){
if (confirm("Are you sure you want to stop all pushes matching \n\""+push[1]+' to '+push[2]+"\"?"+(push_settings.wait != 0 ? "\n\nRetrying is enabled. You'll probably want to set that to 0." : ''))) { if (confirm("Are you sure you want to stop all pushes matching \n\""+push[1]+' to '+push[2]+"\"?"+(push_settings.wait != 0 ? "\n\nRetrying is enabled. You'll probably want to set that to 0." : ''))) {
@ -4392,7 +4410,9 @@ var UI = {
} }
if ('push_auto_list' in d) { if ('push_auto_list' in d) {
for (var i in d.push_auto_list) { for (var i in d.push_auto_list) {
$autopush.append(buildTr([-1,d.push_auto_list[i][0],d.push_auto_list[i][1]],'Automatic')); var a = d.push_auto_list[i].slice();
a.unshift(-1);
$autopush.append(buildTr(a,'Automatic'));
} }
} }
@ -4537,7 +4557,19 @@ var UI = {
} }
var allthestreams; var allthestreams;
function buildTheThings() { function buildTheThings(edit) {
var editid = false;
var o = other.split("_");
other = o[0];
if (o.length == 2) { editid = o[1]; }
if ((editid !== false) && (typeof edit == "undefined")) {
mist.send(function(d){
buildTheThings(d.push_auto_list[editid]);
},{push_auto_list: 1});
return;
}
//retrieve a list of valid targets //retrieve a list of valid targets
var target_match = []; var target_match = [];
for (var i in mist.data.capabilities.connectors) { for (var i in mist.data.capabilities.connectors) {
@ -4552,72 +4584,153 @@ var UI = {
} }
var saveas = {}; var saveas = {};
$main.append( if ((other == "auto") && (typeof edit != "undefined")) {
UI.buildUI([{ saveas = {
label: 'Stream name', "stream": edit[0],
type: 'str', "target": edit[1]
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: { if (edit.length >= 3) { saveas.scheduletime = edit[2]; }
main: saveas, if (edit.length >= 4) { saveas.completetime = edit[3]; }
index: 'stream' if (saveas.target.indexOf("recstartunix=") > -1) {
},
validate: ['required',function(val,me){ //retrieve recstartunix param value
var shouldbestream = val.split('+'); var t = saveas.target.split("recstartunix=")[1];
shouldbestream = shouldbestream[0]; saveas.recstartunix = t.split("&")[0];
if (shouldbestream in mist.data.streams) {
return false; //remove param from target
} saveas.target = saveas.target.replace("recstartunix="+saveas.recstartunix,"").replace("?&","?").replace("&&","&");
return { if (saveas.target[saveas.target.length-1] == "?") { saveas.target = saveas.target.slice(0,-1); }
msg: "'"+shouldbestream+"' is not a stream name.",
classes: ['red'] }
}; }
}], var build = [{
datalist: allthestreams, label: 'Stream name',
LTSonly: 1 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>',
label: 'Target', pointer: {
type: 'str', main: saveas,
help: 'Where the stream will be pushed to.<br>Valid formats:<ul><li>'+target_match.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>', index: 'stream'
pointer: { },
main: saveas, validate: ['required',function(val,me){
index: 'target' var shouldbestream = val.split('+');
}, shouldbestream = shouldbestream[0];
validate: ['required',function(val,me){ if (shouldbestream in mist.data.streams) {
for (var i in target_match) { return false;
if (mist.inputMatch(target_match[i],val)) {
return false;
}
}
return {
msg: 'Does not match a valid target.<br>Valid formats:<ul><li>'+target_match.join('</li><li>')+'</li></ul>',
classes: ['red']
}
}],
LTSonly: 1
},{
type: 'buttons',
buttons: [
{
type: 'cancel',
label: 'Cancel',
'function': function(){
UI.navto('Push');
}
},{
type: 'save',
label: 'Save',
'function': function(){
var obj = {};
obj[(other == 'auto' ? 'push_auto_add' : 'push_start')] = saveas;
mist.send(function(){
UI.navto('Push');
},obj);
}
}
]
} }
]) return {
); msg: "'"+shouldbestream+"' is not a stream name.",
classes: ['orange'],
"break": false
};
}],
datalist: allthestreams,
LTSonly: 1
},{
label: 'Target',
type: 'str',
help: 'Where the stream will be pushed to.<br>Valid formats:<ul><li>'+target_match.join('</li><li>')+'</li></ul> Valid text replacements:<ul><li>$stream - inserts the stream name used to push to MistServer</li><li>$day - inserts the current day number</li><li>$month - inserts the current month number</li><li>$year - inserts the current year number</li><li>$hour - inserts the hour timestamp when stream was received</li><li>$minute - inserts the minute timestamp the stream was received</li><li>$seconds - inserts the seconds timestamp when the stream was received</li><li>$datetime - inserts $year.$month.$day.$hour.$minute.$seconds timestamp when the stream was received</li>',
pointer: {
main: saveas,
index: 'target'
},
validate: ['required',function(val,me){
for (var i in target_match) {
if (mist.inputMatch(target_match[i],val)) {
return false;
}
}
return {
msg: 'Does not match a valid target.<br>Valid formats:<ul><li>'+target_match.join('</li><li>')+'</li></ul>',
classes: ['red']
}
}],
LTSonly: 1
}];
if (other == "auto") { //options only for automatic pushes
build.push({
type: "unix",
label: "Schedule time",
min: 0,
help: "TODO",
pointer: {
main: saveas,
index: "scheduletime"
}
},{
type: "unix",
label: "Recording start time",
min: 0,
help: "TODO",
pointer: {
main: saveas,
index: "recstartunix"
}
},{
type: "unix",
label: "Complete time",
min: 0,
help: "TODO",
pointer: {
main: saveas,
index: "completetime"
}
});
}
build.push({
type: 'buttons',
buttons: [{
type: 'cancel',
label: 'Cancel',
'function': function(){
UI.navto('Push');
}
},{
type: 'save',
label: 'Save',
'function': function(){
var params = {};
if (saveas.recstartunix) {
//append recstartunix to target
params["recstartunix"] = "recstartunix="+saveas.recstartunix;
}
else if (saveas.scheduletime) {
params["recstartunix"] = "recstartunix="+saveas.scheduletime;
}
delete saveas.recstartunix;
if (Object.keys(params).length) {
var append = "?";
var curparams = saveas.target.split("?");
if (curparams.length > 1) {
append = "&";
curparams = curparams[curparams.length-1];
curparams = curparams.split("&");
for (var i in curparams) {
var key = curparams[i].split("=")[0];
if (key in params) { delete params[key]; }
}
}
if (Object.keys(params).length) {
append += Object.values(params).join("&");
saveas.target += append;
}
}
var obj = {};
obj[(other == 'auto' ? 'push_auto_add' : 'push_start')] = saveas;
if (typeof edit != "undefined") { obj.push_auto_remove = [edit]; }
mist.send(function(){
UI.navto('Push');
},obj);
}
}]
});
$main.append(UI.buildUI(build));
} }
if (mist.data.LTS) { if (mist.data.LTS) {
@ -5899,6 +6012,11 @@ $.fn.getval = function(){
val = []; val = [];
}*/ }*/
break; break;
case "unix":
if (val != "") {
val = Math.round(new Date($(this).val()) / 1e3);
}
break;
} }
} }
return val; return val;
@ -5942,6 +6060,15 @@ $.fn.setval = function(val){
for (i in val) { for (i in val) {
$inputs.filter('[name="'+val[i]+'"]').prop('checked',true); $inputs.filter('[name="'+val[i]+'"]').prop('checked',true);
} }
break;
case "unix":
if (typeof val != "undefined") {
var datetime = new Date(Math.round(val) * 1e3);
datetime.setMinutes(datetime.getMinutes() - datetime.getTimezoneOffset()); //correct for the browser being a pain and converting to UTC
datetime = datetime.toISOString();
$(this).val(datetime.split("Z")[0]);
}
break; break;
} }
} }