LSP: fix sublist field which is not last in field list

This commit is contained in:
Cat 2019-09-05 09:49:14 +02:00
parent d9c3b636c8
commit 0f7ea57ea1
2 changed files with 176 additions and 172 deletions

View file

@ -1,11 +1,11 @@
var MD5=function(a){function c(a,c){var b,d,k,g,e;k=a&2147483648;g=c&2147483648;b=a&1073741824;d=c&1073741824;e=(a&1073741823)+(c&1073741823);return b&d?e^2147483648^k^g:b|d?e&1073741824?e^3221225472^k^g:e^1073741824^k^g:e^k^g}function d(a,b,d,k,g,e,f){a=c(a,c(c(b&d|~b&k,g),f));return c(a<<e|a>>>32-e,b)}function b(a,b,d,k,g,e,f){a=c(a,c(c(b&k|d&~k,g),f));return c(a<<e|a>>>32-e,b)}function h(a,b,d,k,g,e,f){a=c(a,c(c(b^d^k,g),f));return c(a<<e|a>>>32-e,b)}function m(a,b,d,k,e,g,f){a=c(a,c(c(d^(b|~k), var MD5=function(a){function c(a,c){var b,d,g,h,e;g=a&2147483648;h=c&2147483648;b=a&1073741824;d=c&1073741824;e=(a&1073741823)+(c&1073741823);return b&d?e^2147483648^g^h:b|d?e&1073741824?e^3221225472^g^h:e^1073741824^g^h:e^g^h}function d(a,b,d,g,h,e,f){a=c(a,c(c(b&d|~b&g,h),f));return c(a<<e|a>>>32-e,b)}function b(a,b,d,g,h,e,f){a=c(a,c(c(b&g|d&~g,h),f));return c(a<<e|a>>>32-e,b)}function f(a,b,d,g,h,e,f){a=c(a,c(c(b^d^g,h),f));return c(a<<e|a>>>32-e,b)}function n(a,b,d,g,h,e,f){a=c(a,c(c(d^(b|~g),
e),f));return c(a<<g|a>>>32-g,b)}function i(a){var b="",c="",d;for(d=0;3>=d;d++)c=a>>>8*d&255,c="0"+c.toString(16),b+=c.substr(c.length-2,2);return b}var f=[],r,j,l,u,g,e,k,n,f=a.replace(/\r\n/g,"\n"),a="";for(r=0;r<f.length;r++)j=f.charCodeAt(r),128>j?a+=String.fromCharCode(j):(127<j&&2048>j?a+=String.fromCharCode(j>>6|192):(a+=String.fromCharCode(j>>12|224),a+=String.fromCharCode(j>>6&63|128)),a+=String.fromCharCode(j&63|128));f=a;a=f.length;r=a+8;j=16*((r-r%64)/64+1);l=Array(j-1);for(g=u=0;g<a;)r= h),f));return c(a<<e|a>>>32-e,b)}function o(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 e=[],r,j,l,u,g,h,k,i,e=a.replace(/\r\n/g,"\n"),a="";for(r=0;r<e.length;r++)j=e.charCodeAt(r),128>j?a+=String.fromCharCode(j):(127<j&&2048>j?a+=String.fromCharCode(j>>6|192):(a+=String.fromCharCode(j>>12|224),a+=String.fromCharCode(j>>6&63|128)),a+=String.fromCharCode(j&63|128));e=a;a=e.length;r=a+8;j=16*((r-r%64)/64+1);l=Array(j-1);for(g=u=0;g<a;)r=
(g-g%4)/4,u=8*(g%4),l[r]|=f.charCodeAt(g)<<u,g++;r=(g-g%4)/4;l[r]|=128<<8*(g%4);l[j-2]=a<<3;l[j-1]=a>>>29;f=l;g=1732584193;e=4023233417;k=2562383102;n=271733878;for(a=0;a<f.length;a+=16)r=g,j=e,l=k,u=n,g=d(g,e,k,n,f[a+0],7,3614090360),n=d(n,g,e,k,f[a+1],12,3905402710),k=d(k,n,g,e,f[a+2],17,606105819),e=d(e,k,n,g,f[a+3],22,3250441966),g=d(g,e,k,n,f[a+4],7,4118548399),n=d(n,g,e,k,f[a+5],12,1200080426),k=d(k,n,g,e,f[a+6],17,2821735955),e=d(e,k,n,g,f[a+7],22,4249261313),g=d(g,e,k,n,f[a+8],7,1770035416), (g-g%4)/4,u=8*(g%4),l[r]|=e.charCodeAt(g)<<u,g++;r=(g-g%4)/4;l[r]|=128<<8*(g%4);l[j-2]=a<<3;l[j-1]=a>>>29;e=l;g=1732584193;h=4023233417;k=2562383102;i=271733878;for(a=0;a<e.length;a+=16)r=g,j=h,l=k,u=i,g=d(g,h,k,i,e[a+0],7,3614090360),i=d(i,g,h,k,e[a+1],12,3905402710),k=d(k,i,g,h,e[a+2],17,606105819),h=d(h,k,i,g,e[a+3],22,3250441966),g=d(g,h,k,i,e[a+4],7,4118548399),i=d(i,g,h,k,e[a+5],12,1200080426),k=d(k,i,g,h,e[a+6],17,2821735955),h=d(h,k,i,g,e[a+7],22,4249261313),g=d(g,h,k,i,e[a+8],7,1770035416),
n=d(n,g,e,k,f[a+9],12,2336552879),k=d(k,n,g,e,f[a+10],17,4294925233),e=d(e,k,n,g,f[a+11],22,2304563134),g=d(g,e,k,n,f[a+12],7,1804603682),n=d(n,g,e,k,f[a+13],12,4254626195),k=d(k,n,g,e,f[a+14],17,2792965006),e=d(e,k,n,g,f[a+15],22,1236535329),g=b(g,e,k,n,f[a+1],5,4129170786),n=b(n,g,e,k,f[a+6],9,3225465664),k=b(k,n,g,e,f[a+11],14,643717713),e=b(e,k,n,g,f[a+0],20,3921069994),g=b(g,e,k,n,f[a+5],5,3593408605),n=b(n,g,e,k,f[a+10],9,38016083),k=b(k,n,g,e,f[a+15],14,3634488961),e=b(e,k,n,g,f[a+4],20,3889429448), i=d(i,g,h,k,e[a+9],12,2336552879),k=d(k,i,g,h,e[a+10],17,4294925233),h=d(h,k,i,g,e[a+11],22,2304563134),g=d(g,h,k,i,e[a+12],7,1804603682),i=d(i,g,h,k,e[a+13],12,4254626195),k=d(k,i,g,h,e[a+14],17,2792965006),h=d(h,k,i,g,e[a+15],22,1236535329),g=b(g,h,k,i,e[a+1],5,4129170786),i=b(i,g,h,k,e[a+6],9,3225465664),k=b(k,i,g,h,e[a+11],14,643717713),h=b(h,k,i,g,e[a+0],20,3921069994),g=b(g,h,k,i,e[a+5],5,3593408605),i=b(i,g,h,k,e[a+10],9,38016083),k=b(k,i,g,h,e[a+15],14,3634488961),h=b(h,k,i,g,e[a+4],20,3889429448),
g=b(g,e,k,n,f[a+9],5,568446438),n=b(n,g,e,k,f[a+14],9,3275163606),k=b(k,n,g,e,f[a+3],14,4107603335),e=b(e,k,n,g,f[a+8],20,1163531501),g=b(g,e,k,n,f[a+13],5,2850285829),n=b(n,g,e,k,f[a+2],9,4243563512),k=b(k,n,g,e,f[a+7],14,1735328473),e=b(e,k,n,g,f[a+12],20,2368359562),g=h(g,e,k,n,f[a+5],4,4294588738),n=h(n,g,e,k,f[a+8],11,2272392833),k=h(k,n,g,e,f[a+11],16,1839030562),e=h(e,k,n,g,f[a+14],23,4259657740),g=h(g,e,k,n,f[a+1],4,2763975236),n=h(n,g,e,k,f[a+4],11,1272893353),k=h(k,n,g,e,f[a+7],16,4139469664), g=b(g,h,k,i,e[a+9],5,568446438),i=b(i,g,h,k,e[a+14],9,3275163606),k=b(k,i,g,h,e[a+3],14,4107603335),h=b(h,k,i,g,e[a+8],20,1163531501),g=b(g,h,k,i,e[a+13],5,2850285829),i=b(i,g,h,k,e[a+2],9,4243563512),k=b(k,i,g,h,e[a+7],14,1735328473),h=b(h,k,i,g,e[a+12],20,2368359562),g=f(g,h,k,i,e[a+5],4,4294588738),i=f(i,g,h,k,e[a+8],11,2272392833),k=f(k,i,g,h,e[a+11],16,1839030562),h=f(h,k,i,g,e[a+14],23,4259657740),g=f(g,h,k,i,e[a+1],4,2763975236),i=f(i,g,h,k,e[a+4],11,1272893353),k=f(k,i,g,h,e[a+7],16,4139469664),
e=h(e,k,n,g,f[a+10],23,3200236656),g=h(g,e,k,n,f[a+13],4,681279174),n=h(n,g,e,k,f[a+0],11,3936430074),k=h(k,n,g,e,f[a+3],16,3572445317),e=h(e,k,n,g,f[a+6],23,76029189),g=h(g,e,k,n,f[a+9],4,3654602809),n=h(n,g,e,k,f[a+12],11,3873151461),k=h(k,n,g,e,f[a+15],16,530742520),e=h(e,k,n,g,f[a+2],23,3299628645),g=m(g,e,k,n,f[a+0],6,4096336452),n=m(n,g,e,k,f[a+7],10,1126891415),k=m(k,n,g,e,f[a+14],15,2878612391),e=m(e,k,n,g,f[a+5],21,4237533241),g=m(g,e,k,n,f[a+12],6,1700485571),n=m(n,g,e,k,f[a+3],10,2399980690), h=f(h,k,i,g,e[a+10],23,3200236656),g=f(g,h,k,i,e[a+13],4,681279174),i=f(i,g,h,k,e[a+0],11,3936430074),k=f(k,i,g,h,e[a+3],16,3572445317),h=f(h,k,i,g,e[a+6],23,76029189),g=f(g,h,k,i,e[a+9],4,3654602809),i=f(i,g,h,k,e[a+12],11,3873151461),k=f(k,i,g,h,e[a+15],16,530742520),h=f(h,k,i,g,e[a+2],23,3299628645),g=n(g,h,k,i,e[a+0],6,4096336452),i=n(i,g,h,k,e[a+7],10,1126891415),k=n(k,i,g,h,e[a+14],15,2878612391),h=n(h,k,i,g,e[a+5],21,4237533241),g=n(g,h,k,i,e[a+12],6,1700485571),i=n(i,g,h,k,e[a+3],10,2399980690),
k=m(k,n,g,e,f[a+10],15,4293915773),e=m(e,k,n,g,f[a+1],21,2240044497),g=m(g,e,k,n,f[a+8],6,1873313359),n=m(n,g,e,k,f[a+15],10,4264355552),k=m(k,n,g,e,f[a+6],15,2734768916),e=m(e,k,n,g,f[a+13],21,1309151649),g=m(g,e,k,n,f[a+4],6,4149444226),n=m(n,g,e,k,f[a+11],10,3174756917),k=m(k,n,g,e,f[a+2],15,718787259),e=m(e,k,n,g,f[a+9],21,3951481745),g=c(g,r),e=c(e,j),k=c(k,l),n=c(n,u);return(i(g)+i(e)+i(k)+i(n)).toLowerCase()};(function(a){a.fn.stupidtable=function(){a(this).on("click","thead th",function(){a(this).stupidsort()})};a.fn.stupidsort=function(){function c(b){var c=0,d;a(b).children("td,th").each(function(){if(c==r)return d=a(this),!1;var b=a(this).attr("colspan");c+=b?Number(b):1});b="undefined"!=typeof d.data("sort-value")?d.data("sort-value"):"undefined"!=typeof d.attr("data-sort-value")?d.attr("data-sort-value"):d.text();switch(i){case "string":case "string-ins":b=String(b).toLowerCase();break;case "int":b= k=n(k,i,g,h,e[a+10],15,4293915773),h=n(h,k,i,g,e[a+1],21,2240044497),g=n(g,h,k,i,e[a+8],6,1873313359),i=n(i,g,h,k,e[a+15],10,4264355552),k=n(k,i,g,h,e[a+6],15,2734768916),h=n(h,k,i,g,e[a+13],21,1309151649),g=n(g,h,k,i,e[a+4],6,4149444226),i=n(i,g,h,k,e[a+11],10,3174756917),k=n(k,i,g,h,e[a+2],15,718787259),h=n(h,k,i,g,e[a+9],21,3951481745),g=c(g,r),h=c(h,j),k=c(k,l),i=c(i,u);return(o(g)+o(h)+o(k)+o(i)).toLowerCase()};(function(a){a.fn.stupidtable=function(){a(this).on("click","thead th",function(){a(this).stupidsort()})};a.fn.stupidsort=function(){function c(b){var c=0,d;a(b).children("td,th").each(function(){if(c==r)return d=a(this),!1;var b=a(this).attr("colspan");c+=b?Number(b):1});b="undefined"!=typeof d.data("sort-value")?d.data("sort-value"):"undefined"!=typeof d.attr("data-sort-value")?d.attr("data-sort-value"):d.text();switch(o){case "string":case "string-ins":b=String(b).toLowerCase();break;case "int":b=
parseInt(Number(b));break;case "float":b=Number(b)}return b}var d=a(this),b=d.closest("table"),h=b.children("tbody"),m=h.children("tr"),i=d.attr("data-sort-type");if(i){var f=!0;d.hasClass("sorting-asc")&&(f=!1);var r=0;d.prevAll().each(function(){var b=a(this).attr("colspan");r+=b?Number(b):1});m.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});h.append(m);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(b));break;case "float":b=Number(b)}return b}var d=a(this),b=d.closest("table"),f=b.children("tbody"),n=f.children("tr"),o=d.attr("data-sort-type");if(o){var e=!0;d.hasClass("sorting-asc")&&(e=!1);var r=0;d.prevAll().each(function(){var b=a(this).attr("colspan");r+=b?Number(b):1});n.sort(function(a,b){var d=e?1:-1,a=c(a),b=c(b);return a>b?1*d:a<b?-1*d:0});f.append(n);b.find("thead th").removeClass("sorting-asc").removeClass("sorting-desc");d.addClass(e?"sorting-asc":"sorting-desc")}}})(jQuery);$(function(){UI.elements={menu:$("nav > .menu"),main:$("main"),header:$("header"),connection:{status:$("#connection"),user_and_host:$("#user_and_host"),msg:$("#message")}};UI.buildMenu();UI.stored.getOpts();try{if("mistLogin"in sessionStorage){var a=JSON.parse(sessionStorage.mistLogin);mist.user.name=a.name;mist.user.password=a.password;mist.user.host=a.host}}catch(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 MistVideoObject={},otherhost={host:!1,https:!1},UI={debug:!1,elements:{},stored:{getOpts:function(){var a=localStorage.stored;a&&(a=JSON.parse(a));$.extend(!0,this.vars,a);return this.vars},saveOpt:function(a,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 MistVideoObject={},otherhost={host:!1,https:!1},UI={debug:!1,elements:{},stored:{getOpts:function(){var a=localStorage.stored;a&&(a=JSON.parse(a));$.extend(!0,this.vars,a);return this.vars},saveOpt:function(a,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,47 +21,47 @@ clearTimeout(this.hiding);delete this.hiding;var d=$(document).height()-$tooltip
"HLS (TS)";break;case "html5/application/vnd.apple.mpegurl;version=7":c="HLS (CMAF)";break;case "html5/video/webm":c="WebM";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/audio/wav":c="WAV";break;case "html5/video/mp2t":case "html5/video/mpeg":c="TS";break;case "html5/application/vnd.ms-sstr+xml":case "html5/application/vnd.ms-ss":c= "HLS (TS)";break;case "html5/application/vnd.apple.mpegurl;version=7":c="HLS (CMAF)";break;case "html5/video/webm":c="WebM";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/audio/wav":c="WAV";break;case "html5/video/mp2t":case "html5/video/mpeg":c="TS";break;case "html5/application/vnd.ms-sstr+xml":case "html5/application/vnd.ms-ss":c=
"Smooth Streaming";break;case "html5/text/vtt":c="VTT Subtitles";break;case "html5/text/plain":c="SRT Subtitles";break;case "html5/text/javascript":c="JSON Subtitles";break;case "rtsp":c="RTSP";break;case "webrtc":c="WebRTC"}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)}}, "Smooth Streaming";break;case "html5/text/vtt":c="VTT Subtitles";break;case "html5/text/plain":c="SRT Subtitles";break;case "html5/text/javascript":c="JSON Subtitles";break;case "rtsp":c="RTSP";break;case "webrtc":c="WebRTC"}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"},"Mist Shop":{link:"http://mistserver.org/products"},"Email for Help":{}}}}],buildMenu:function(){function a(a,b){var c=$("<a>").addClass("button");c.html($("<span>").addClass("plain").text(a)).append($("<span>").addClass("highlighted").text(a)); 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,b){var c=$("<a>").addClass("button");c.html($("<span>").addClass("plain").text(a)).append($("<span>").addClass("highlighted").text(a));
for(var d in b.classes)c.addClass(b.classes[d]);"LTSonly"in b&&c.addClass("LTSonly");"link"in b?c.attr("href",b.link).attr("target","_blank"):"submenu"in b||c.click(function(b){$(this).closest(".menu").hasClass("hide")||(UI.navto(a),b.stopPropagation())});return c}var c=UI.elements.menu,d;for(d in UI.menu){0<d&&c.append($("<br>"));for(var b in UI.menu[d]){var h=UI.menu[d][b],m=a(b,h);c.append(m);if("submenu"in h){var i=$("<span>").addClass("submenu");m.addClass("arrowdown").append(i);for(var f in h.submenu)i.append(a(f, for(var d in b.classes)c.addClass(b.classes[d]);"LTSonly"in b&&c.addClass("LTSonly");"link"in b?c.attr("href",b.link).attr("target","_blank"):"submenu"in b||c.click(function(b){$(this).closest(".menu").hasClass("hide")||(UI.navto(a),b.stopPropagation())});return c}var c=UI.elements.menu,d;for(d in UI.menu){0<d&&c.append($("<br>"));for(var b in UI.menu[d]){var f=UI.menu[d][b],n=a(b,f);c.append(n);if("submenu"in f){var o=$("<span>").addClass("submenu");n.addClass("arrowdown").append(o);for(var e in f.submenu)o.append(a(e,
h.submenu[f]))}else if("hiddenmenu"in h)for(f in i=$("<span>").addClass("hiddenmenu"),m.append(i),h.hiddenmenu)i.append(a(f,h.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", f.submenu[e]))}else if("hiddenmenu"in f)for(e in o=$("<span>").addClass("hiddenmenu"),n.append(o),f.hiddenmenu)o.append(a(e,f.hiddenmenu[e]))}}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";},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 h=$("<span>").addClass("text_container").append($("<span>").addClass("description").append(b.help)); 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 f=$("<span>").addClass("text_container").append($("<span>").addClass("description").append(b.help));
c.append(h);if("classes"in b)for(var m in b.classes)h.addClass(b.classes[m])}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(m in h=$("<span>").addClass("button_container").on("keydown",function(a){a.stopPropagation()}),"css"in b&&h.css(b.css),c.append(h),b.buttons){var i=b.buttons[m],f=$("<button>").text(i.label).data("opts",i);"css"in i&&f.css(i.css); c.append(f);if("classes"in b)for(var n in b.classes)f.addClass(b.classes[n])}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(n in f=$("<span>").addClass("button_container").on("keydown",function(a){a.stopPropagation()}),"css"in b&&f.css(b.css),c.append(f),b.buttons){var o=b.buttons[n],e=$("<button>").text(o.label).data("opts",o);"css"in o&&e.css(o.css);
if("classes"in i)for(var r in i.classes)f.addClass(i.classes[r]);h.append(f);switch(i.type){case "cancel":f.addClass("cancel").click(i["function"]);break;case "save":f.addClass("save").click(function(){var a=$(this).data("opts").preSave;a&&a.call(this);var b=$(this).closest(".input_container"),c=!1;b.find('.hasValidate:visible, input[type="hidden"].hasValidate').each(function(){if(c=$(this).data("validate")(this,!0))return!1});(a=$(this).data("opts").failedValidate)&&a.call(this);c||(b.find('.isSetting:visible, input[type="hidden"].isSetting').each(function(){var a= if("classes"in o)for(var r in o.classes)e.addClass(o.classes[r]);f.append(e);switch(o.type){case "cancel":e.addClass("cancel").click(o["function"]);break;case "save":e.addClass("save").click(function(){var a=$(this).data("opts").preSave;a&&a.call(this);var b=$(this).closest(".input_container"),c=!1;b.find('.hasValidate:visible, input[type="hidden"].hasValidate').each(function(){if(c=$(this).data("validate")(this,!0))return!1});(a=$(this).data("opts").failedValidate)&&a.call(this);c||(b.find('.isSetting:visible, input[type="hidden"].isSetting').each(function(){var a=
$(this).getval(),b=$(this).data("pointer");if(""==a)if("default"in $(this).data("opts"))a=$(this).data("opts")["default"];else return b.main[b.index]=null,!0;b.main[b.index]=a}),(a=$(this).data("opts")["function"])&&a(this))});break;default:f.click(i["function"])}}else{var j=$("<label>").addClass("UIelement");c.append(j);"css"in b&&j.css(b.css);j.append($("<span>").addClass("label").html("label"in b?b.label+":":""));if("classes"in b)for(r in b.classes)j.addClass(b.classes[r]);h=$("<span>").addClass("field_container"); $(this).getval(),b=$(this).data("pointer");if(""==a)if("default"in $(this).data("opts"))a=$(this).data("opts")["default"];else return b.main[b.index]=null,!0;b.main[b.index]=a}),(a=$(this).data("opts")["function"])&&a(this))});break;default:e.click(o["function"])}}else{o=$("<label>").addClass("UIelement");c.append(o);"css"in b&&o.css(b.css);o.append($("<span>").addClass("label").html("label"in b?b.label+":":""));if("classes"in b)for(r in b.classes)o.addClass(b.classes[r]);e=$("<span>").addClass("field_container");
j.append(h);var l;switch(b.type){case "password":l=$("<input>").attr("type","password");break;case "int":l=$("<input>").attr("type","number");"min"in b&&l.attr("min",b.min);"max"in b&&l.attr("max",b.max);"validate"in b?b.validate.push("int"):b.validate=["int"];break;case "span":l=$("<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"], o.append(e);switch(b.type){case "password":f=$("<input>").attr("type","password");break;case "int":f=$("<input>").attr("type","number");"min"in b&&f.attr("min",b.min);"max"in b&&f.attr("max",b.max);"validate"in b?b.validate.push("int"):b.validate=["int"];break;case "span":f=$("<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":l=$("<select>");for(m in b.select)f=$("<option>"),"string"==typeof b.select[m]?f.text(b.select[m]):f.val(b.select[m][0]).text(b.select[m][1]), [4,"4 - Previous level, and status messages for development"],[5,"5 - Previous level, and more status messages for development"],[6,"6 - Previous level, and verbose debugging messages"],[7,"7 - Previous level, and very verbose debugging messages"],[8,"8 - Report everything in extreme detail"],[9,"9 - Report everything in insane detail"],[10,"10 - All messages enabled"]];case "select":f=$("<select>");for(n in b.select){var j=$("<option>");"string"==typeof b.select[n]?j.text(b.select[n]):j.val(b.select[n][0]).text(b.select[n][1]);
l.append(f);break;case "textarea":l=$("<textarea>").on("keydown",function(a){a.stopPropagation()});break;case "checkbox":l=$("<input>").attr("type","checkbox");break;case "hidden":l=$("<input>").attr("type","hidden");j.hide();break;case "email":l=$("<input>").attr("type","email").attr("autocomplete","on").attr("required","");break;case "browse":l=$("<input>").attr("type","text");"filetypes"in b&&l.data("filetypes",b.filetypes);break;case "geolimited":case "hostlimited":l=$("<input>").attr("type", f.append(j)}break;case "textarea":f=$("<textarea>").on("keydown",function(a){a.stopPropagation()});break;case "checkbox":f=$("<input>").attr("type","checkbox");break;case "hidden":f=$("<input>").attr("type","hidden");o.hide();break;case "email":f=$("<input>").attr("type","email").attr("autocomplete","on").attr("required","");break;case "browse":f=$("<input>").attr("type","text");"filetypes"in b&&f.data("filetypes",b.filetypes);break;case "geolimited":case "hostlimited":f=$("<input>").attr("type",
"hidden");break;case "radioselect":l=$("<div>").addClass("radioselect");for(d in b.radioselect)if(i=$("<input>").attr("type","radio").val(b.radioselect[d][0]).attr("name",b.label),("LTSonly"in b&&!mist.data.LTS||b.readonly)&&i.prop("disabled",!0),f=$("<label>").append(i).append($("<span>").html(b.radioselect[d][1])),l.append(f),2<b.radioselect[d].length)for(m in i=$("<select>").change(function(){$(this).parent().find("input[type=radio]:enabled").prop("checked","true")}),f.append(i),("LTSonly"in b&& "hidden");break;case "radioselect":f=$("<div>").addClass("radioselect");for(d in b.radioselect){var l=$("<input>").attr("type","radio").val(b.radioselect[d][0]).attr("name",b.label);("LTSonly"in b&&!mist.data.LTS||b.readonly)&&l.prop("disabled",!0);j=$("<label>").append(l).append($("<span>").html(b.radioselect[d][1]));f.append(j);if(2<b.radioselect[d].length)for(n in l=$("<select>").change(function(){$(this).parent().find("input[type=radio]:enabled").prop("checked","true")}),j.append(l),("LTSonly"in
!mist.data.LTS||b.readonly)&&i.prop("disabled",!0),b.radioselect[d][2])f=$("<option>"),i.append(f),b.radioselect[d][2][m]instanceof Array?f.val(b.radioselect[d][2][m][0]).html(b.radioselect[d][2][m][1]):f.html(b.radioselect[d][2][m]);break;case "checklist":l=$("<div>").addClass("checkcontainer");$controls=$("<div>").addClass("controls");$checklist=$("<div>").addClass("checklist");l.append($checklist);for(d in b.checklist)"string"==typeof b.checklist[d]&&(b.checklist[d]=[b.checklist[d],b.checklist[d]]), b&&!mist.data.LTS||b.readonly)&&l.prop("disabled",!0),b.radioselect[d][2])j=$("<option>"),l.append(j),b.radioselect[d][2][n]instanceof Array?j.val(b.radioselect[d][2][n][0]).html(b.radioselect[d][2][n][1]):j.html(b.radioselect[d][2][n])}break;case "checklist":f=$("<div>").addClass("checkcontainer");$controls=$("<div>").addClass("controls");$checklist=$("<div>").addClass("checklist");f.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":l=b.DOMfield;break;case "unix":l=$("<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;case "selectinput":l=$("<div>").addClass("selectinput");i=$("<select>");l.append(i);i.data("input",!1);"LTSonly"in $checklist.append($("<label>").text(b.checklist[d][1]).prepend($("<input>").attr("type","checkbox").attr("name",b.checklist[d][0])));break;case "DOMfield":f=b.DOMfield;break;case "unix":f=$("<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;case "selectinput":f=$("<div>").addClass("selectinput");l=$("<select>");f.append(l);l.data("input",!1);"LTSonly"in
b&&!mist.data.LTS&&i.prop("disabled",!0);for(d in b.selectinput)f=$("<option>"),i.append(f),"string"==typeof b.selectinput[d]?f.text(b.selectinput[d]):(f.text(b.selectinput[d][1]),"string"==typeof b.selectinput[d][0]?f.val(b.selectinput[d][0]):(f.val("CUSTOM"),i.data("input")||i.data("input",UI.buildUI([b.selectinput[d][0]]).children())));i.data("input")&&l.append(i.data("input"));i.change(function(){"CUSTOM"==$(this).val()?$(this).data("input").css("display","flex"):$(this).data("input").hide()}); b&&!mist.data.LTS&&l.prop("disabled",!0);for(d in b.selectinput)j=$("<option>"),l.append(j),"string"==typeof b.selectinput[d]?j.text(b.selectinput[d]):(j.text(b.selectinput[d][1]),"string"==typeof b.selectinput[d][0]?j.val(b.selectinput[d][0]):(j.val("CUSTOM"),l.data("input")||l.data("input",UI.buildUI([b.selectinput[d][0]]).children())));l.data("input")&&f.append(l.data("input"));l.change(function(){"CUSTOM"==$(this).val()?$(this).data("input").css("display","flex"):$(this).data("input").hide()});
i.trigger("change");break;case "inputlist":l=$("<div>").addClass("inputlist");l.data("newitem",function(){var a=$("<input>").attr("type","text").addClass("listitem");("LTSonly"in b&&!mist.data.LTS||b.readonly)&&a.prop("disabled",!0);var c=function(b){$(this).is(":last-child")?""!=$(this).val()?$(this).after(a.clone().keyup(c).val("")):8==b.which&&$(this).prev().focus():""==$(this).val()&&($(this).next().focus(),$(this).remove())};a.keyup(c);return a});l.append(l.data("newitem"));break;case "sublist":l= l.trigger("change");break;case "inputlist":f=$("<div>").addClass("inputlist");f.data("newitem",function(){var a=$("<input>").attr("type","text").addClass("listitem");("LTSonly"in b&&!mist.data.LTS||b.readonly)&&a.prop("disabled",!0);var c=function(b){$(this).is(":last-child")?""!=$(this).val()?$(this).after(a.clone().keyup(c).val("")):8==b.which&&$(this).prev().focus():""==$(this).val()&&($(this).next().focus(),$(this).remove())};a.keyup(c);return a});f.append(f.data("newitem"));break;case "sublist":f=
$("<div>").addClass("sublist");i=$("<div>").addClass("curvals");i.append($("<span>").text("None."));var u=$("<div>").addClass("itemsettings"),g=$("<button>").text("New "+b.itemLabel),e=b.sublist;l.data("build",function(a,c){for(var d in b.saveas)d in a||delete b.saveas[d];b.saveas=Object.assign(b.saveas,a);d="New";"undefined"!=typeof c&&(d="Edit");d=UI.buildUI([$("<h4>").text(d+" "+b.itemLabel)].concat(e).concat([{label:"Save first",type:"str",classes:["onlyshowhelp"],validate:[function(){return{msg:"Did you want to save this "+ $("<div>").addClass("sublist");l=$("<div>").addClass("curvals");l.append($("<span>").text("None."));var u=$("<div>").addClass("itemsettings"),g=$("<button>").text("New "+b.itemLabel),h=b.sublist,k=b,i=f,z=o;f.data("build",function(a,b){for(var c in k.saveas)c in a||delete k.saveas[c];k.saveas=Object.assign(k.saveas,a);c="New";"undefined"!=typeof b&&(c="Edit");c=UI.buildUI([$("<h4>").text(c+" "+k.itemLabel)].concat(h).concat([{label:"Save first",type:"str",classes:["onlyshowhelp"],validate:[function(){return{msg:"Did you want to save this "+
b.itemLabel+"?",classes:["red"]}}]},{type:"buttons",buttons:[{label:"Cancel",type:"cancel","function":function(){u.html("");g.show();j.show()}},{label:"Save "+b.itemLabel,type:"save",preSave:function(){$(this).closest(".input_container").find(".onlyshowhelp").closest("label").hide()},failedValidate:function(){$(this).closest(".input_container").find(".onlyshowhelp").closest("label").show()},"function":function(){var a=l.getval(),d=Object.assign({},b.saveas),e;for(e in d)null===d[e]&&delete d[e];"undefined"== k.itemLabel+"?",classes:["red"]}}]},{type:"buttons",buttons:[{label:"Cancel",type:"cancel","function":function(){u.html("");g.show();z.show()}},{label:"Save "+k.itemLabel,type:"save",preSave:function(){$(this).closest(".input_container").find(".onlyshowhelp").closest("label").hide()},failedValidate:function(){$(this).closest(".input_container").find(".onlyshowhelp").closest("label").show()},"function":function(){var a=i.getval(),c=Object.assign({},k.saveas),d;for(d in c)null===c[d]&&delete c[d];"undefined"==
typeof c?a.push(d):a[c]=d;l.setval(a);u.html("");g.show();j.show()}}]}]));u.html(d);g.hide();j.hide()});g.click(function(){l.data("build")({})});e.unshift({type:"str",label:"Human readable name",placeholder:"none",help:"A convenient name to describe this "+b.itemLabel+". It won't be used by MistServer.",pointer:{main:b.saveas,index:"x-LSP-name"}});l.data("savelist",[]);l.append(i).append(g);c.append(u);break;default:l=$("<input>").attr("type","text")}l.addClass("field").data("opts",b);"pointer"in typeof b?a.push(c):a[b]=c;i.setval(a);u.html("");g.show();z.show()}}]}]));u.html(c);g.hide();z.hide()});var m=f;g.click(function(){m.data("build")({})});h.unshift({type:"str",label:"Human readable name",placeholder:"none",help:"A convenient name to describe this "+b.itemLabel+". It won't be used by MistServer.",pointer:{main:b.saveas,index:"x-LSP-name"}});f.data("savelist",[]);f.append(l).append(g);c.append(u);break;default:f=$("<input>").attr("type","text")}f.addClass("field").data("opts",b);"pointer"in
b&&l.attr("name",b.pointer.index);h.append(l);if("classes"in b)for(m in b.classes)l.addClass(b.classes[m]);"placeholder"in b&&l.attr("placeholder",b.placeholder);"default"in b&&l.attr("placeholder",b["default"]);"unit"in b&&h.append($("<span>").addClass("unit").html(b.unit));"readonly"in b&&(l.attr("readonly","readonly"),l.click(function(){$(this).select()}));"qrcode"in b&&h.append($("<span>").addClass("unit").html($("<button>").text("QR").on("keydown",function(a){a.stopPropagation()}).click(function(){var a= b&&f.attr("name",b.pointer.index);e.append(f);if("classes"in b)for(n in b.classes)f.addClass(b.classes[n]);"placeholder"in b&&f.attr("placeholder",b.placeholder);"default"in b&&f.attr("placeholder",b["default"]);"unit"in b&&e.append($("<span>").addClass("unit").html(b.unit));"readonly"in b&&(f.attr("readonly","readonly"),f.click(function(){$(this).select()}));"qrcode"in b&&e.append($("<span>").addClass("unit").html($("<button>").text("QR").on("keydown",function(a){a.stopPropagation()}).click(function(){var a=
String($(this).closest(".field_container").find(".field").getval()),b=$("<div>").addClass("qrcode");UI.popup.show($("<span>").addClass("qr_container").append($("<p>").text(a)).append(b));b.qrcode({text:a,size:Math.min(b.width(),b.height())})})));"clipboard"in b&&document.queryCommandSupported("copy")&&h.append($("<span>").addClass("unit").html($("<button>").text("Copy").on("keydown",function(a){a.stopPropagation()}).click(function(){var a=String($(this).closest(".field_container").find(".field").getval()), String($(this).closest(".field_container").find(".field").getval()),b=$("<div>").addClass("qrcode");UI.popup.show($("<span>").addClass("qr_container").append($("<p>").text(a)).append(b));b.qrcode({text:a,size:Math.min(b.width(),b.height())})})));"clipboard"in b&&document.queryCommandSupported("copy")&&e.append($("<span>").addClass("unit").html($("<button>").text("Copy").on("keydown",function(a){a.stopPropagation()}).click(function(){var a=String($(this).closest(".field_container").find(".field").getval()),
b=document.createElement("textarea");b.value=a;document.body.appendChild(b);b.select();var c=false;try{c=document.execCommand("copy")}catch(d){}if(c){$(this).text("Copied to clipboard!");document.body.removeChild(b);var e=$(this);setTimeout(function(){e.text("Copy")},5E3)}else{document.body.removeChild(b);alert("Failed to copy:\n"+a)}})));"rows"in b&&l.attr("rows",b.rows);"LTSonly"in b&&!mist.data.LTS&&(h.addClass("LTSonly"),l.prop("disabled",!0));if("dependent"in b)for(d in b.dependent)j.attr("data-dependent-"+ b=document.createElement("textarea");b.value=a;document.body.appendChild(b);b.select();var c=false;try{c=document.execCommand("copy")}catch(d){}if(c){$(this).text("Copied to clipboard!");document.body.removeChild(b);var h=$(this);setTimeout(function(){h.text("Copy")},5E3)}else{document.body.removeChild(b);alert("Failed to copy:\n"+a)}})));"rows"in b&&f.attr("rows",b.rows);"LTSonly"in b&&!mist.data.LTS&&(e.addClass("LTSonly"),f.prop("disabled",!0));if("dependent"in b)for(d in b.dependent)o.attr("data-dependent-"+
d,b.dependent[d]);switch(b.type){case "browse":i=$("<div>").addClass("grouper").append(j);c.append(i);i=$("<button>").text("Browse").on("keydown",function(a){a.stopPropagation()});h.append(i);i.click(function(){function a(b){i.text("Loading..");mist.send(function(a){f.text(a.browse.path[0]);mist.data.LTS&&d.setval(a.browse.path[0]+"/");i.html(h.clone(true).text("..").attr("title","Folder up"));if(a.browse.subdirectories){a.browse.subdirectories.sort();for(var b in a.browse.subdirectories){var g=a.browse.subdirectories[b]; d,b.dependent[d]);switch(b.type){case "browse":l=$("<div>").addClass("grouper").append(o);c.append(l);l=$("<button>").text("Browse").on("keydown",function(a){a.stopPropagation()});e.append(l);l.click(function(){function a(b){f.text("Loading..");mist.send(function(a){e.text(a.browse.path[0]);mist.data.LTS&&d.setval(a.browse.path[0]+"/");f.html(k.clone(true).text("..").attr("title","Folder up"));if(a.browse.subdirectories){a.browse.subdirectories.sort();for(var b in a.browse.subdirectories){var g=a.browse.subdirectories[b];
i.append(h.clone(true).attr("title",f.text()+l+g).text(g))}}if(a.browse.files){a.browse.files.sort();for(b in a.browse.files){var g=a.browse.files[b],k=f.text()+l+g,g=$("<a>").text(g).addClass("file").attr("title",k);i.append(g);if(j){var n=true,m;for(m in j)if(typeof j[m]!="undefined"&&mist.inputMatch(j[m],k)){n=false;break}n&&g.hide()}g.click(function(){var a=$(this).attr("title");d.setval(a).removeAttr("readonly").css("opacity",1);e.show();c.remove()})}}},{browse:b})}var b=$(this).closest(".grouper"), f.append(k.clone(true).attr("title",e.text()+i+g).text(g))}}if(a.browse.files){a.browse.files.sort();for(b in a.browse.files){var g=a.browse.files[b],j=e.text()+i+g,g=$("<a>").text(g).addClass("file").attr("title",j);f.append(g);if(o){var m=true,l;for(l in o)if(typeof o[l]!="undefined"&&mist.inputMatch(o[l],j)){m=false;break}m&&g.hide()}g.click(function(){var a=$(this).attr("title");d.setval(a).removeAttr("readonly").css("opacity",1);h.show();c.remove()})}}},{browse:b})}var b=$(this).closest(".grouper"),
c=$("<div>").addClass("browse_container"),d=b.find(".field").attr("readonly","readonly").css("opacity",0.5),e=$(this),g=$("<button>").text("Stop browsing").click(function(){e.show();c.remove();d.removeAttr("readonly").css("opacity",1)}),f=$("<span>").addClass("field"),i=$("<div>").addClass("browse_contents"),h=$("<a>").addClass("folder"),j=d.data("filetypes");b.append(c);c.append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Current folder:")).append($("<span>").addClass("field_container").append(f).append(g))).append(i); c=$("<div>").addClass("browse_container"),d=b.find(".field").attr("readonly","readonly").css("opacity",0.5),h=$(this),g=$("<button>").text("Stop browsing").click(function(){h.show();c.remove();d.removeAttr("readonly").css("opacity",1)}),e=$("<span>").addClass("field"),f=$("<div>").addClass("browse_contents"),k=$("<a>").addClass("folder"),o=d.data("filetypes");b.append(c);c.append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Current folder:")).append($("<span>").addClass("field_container").append(e).append(g))).append(f);
var l="/";mist.data.config.version.indexOf("indows")>-1&&(l="\\");h.click(function(){var b=f.text()+l+$(this).text();a(b)});b=d.getval();g=b.split("://");g.length>1&&(b=g[0]=="file"?g[1]:"");b=b.split(l);b.pop();b=b.join(l);e.hide();a(b)});break;case "geolimited":case "hostlimited":i={field:l};i.blackwhite=$("<select>").append($("<option>").val("-").text("Blacklist")).append($("<option>").val("+").text("Whitelist"));i.values=$("<span>").addClass("limit_value_list");switch(b.type){case "geolimited":i.prototype= var i="/";mist.data.config.version.indexOf("indows")>-1&&(i="\\");k.click(function(){var b=e.text()+i+$(this).text();a(b)});b=d.getval();g=b.split("://");g.length>1&&(b=g[0]=="file"?g[1]:"");b=b.split(i);b.pop();b=b.join(i);h.hide();a(b)});break;case "geolimited":case "hostlimited":l={field:f};l.blackwhite=$("<select>").append($("<option>").val("-").text("Blacklist")).append($("<option>").val("+").text("Whitelist"));l.values=$("<span>").addClass("limit_value_list");switch(b.type){case "geolimited":l.prototype=
$("<select>").append($("<option>").val("").text("[Select a country]"));for(d in UI.countrylist)i.prototype.append($("<option>").val(d).html(UI.countrylist[d]));break;case "hostlimited":i.prototype=$("<input>").attr("type","text").attr("placeholder","type a host")}i.prototype.on("change keyup",function(){$(this).closest(".field_container").data("subUI").blackwhite.trigger("change")});i.blackwhite.change(function(){var a=$(this).closest(".field_container").data("subUI"),b=[],c=false;a.values.children().each(function(){c= $("<select>").append($("<option>").val("").text("[Select a country]"));for(d in UI.countrylist)l.prototype.append($("<option>").val(d).html(UI.countrylist[d]));break;case "hostlimited":l.prototype=$("<input>").attr("type","text").attr("placeholder","type a host")}l.prototype.on("change keyup",function(){$(this).closest(".field_container").data("subUI").blackwhite.trigger("change")});l.blackwhite.change(function(){var a=$(this).closest(".field_container").data("subUI"),b=[],c=false;a.values.children().each(function(){c=
$(this).val();c!=""?b.push(c):$(this).remove()});a.values.append(a.prototype.clone(true));b.length>0?a.field.val($(this).val()+b.join(" ")):a.field.val("");a.field.trigger("change")});"LTSonly"in b&&!mist.data.LTS&&(i.blackwhite.prop("disabled",!0),i.prototype.prop("disabled",!0));i.values.append(i.prototype.clone(!0));h.data("subUI",i).addClass("limit_list").append(i.blackwhite).append(i.values)}"pointer"in b&&(l.data("pointer",b.pointer).addClass("isSetting"),b.pointer.main&&(i=b.pointer.main[b.pointer.index], $(this).val();c!=""?b.push(c):$(this).remove()});a.values.append(a.prototype.clone(true));b.length>0?a.field.val($(this).val()+b.join(" ")):a.field.val("");a.field.trigger("change")});"LTSonly"in b&&!mist.data.LTS&&(l.blackwhite.prop("disabled",!0),l.prototype.prop("disabled",!0));l.values.append(l.prototype.clone(!0));e.data("subUI",l).addClass("limit_list").append(l.blackwhite).append(l.values)}"pointer"in b&&(f.data("pointer",b.pointer).addClass("isSetting"),b.pointer.main&&(l=b.pointer.main[b.pointer.index],
"undefined"!=i&&l.setval(i)));(""==l.getval()||null==l.getval())&&"value"in b&&l.setval(b.value);if("datalist"in b)for(d in i="datalist_"+d+MD5(l[0].outerHTML),l.attr("list",i),i=$("<datalist>").attr("id",i),h.append(i),b.datalist)i.append($("<option>").val(b.datalist[d]));h=$("<span>").addClass("help_container");j.append(h);"help"in b&&(h.append($("<span>").addClass("ih_balloon").html(b.help)),l.on("focus mouseover",function(){$(this).closest("label").addClass("active")}).on("blur mouseout",function(){$(this).closest("label").removeClass("active")})); "undefined"!=l&&f.setval(l)));(""==f.getval()||null==f.getval())&&"value"in b&&f.setval(b.value);if("datalist"in b)for(d in l="datalist_"+d+MD5(f[0].outerHTML),f.attr("list",l),l=$("<datalist>").attr("id",l),e.append(l),b.datalist)l.append($("<option>").val(b.datalist[d]));e=$("<span>").addClass("help_container");o.append(e);"help"in b&&(e.append($("<span>").addClass("ih_balloon").html(b.help)),f.on("focus mouseover",function(){$(this).closest("label").addClass("active")}).on("blur mouseout",function(){$(this).closest("label").removeClass("active")}));
if("validate"in b){i=[];for(m in b.validate){f=b.validate[m];if("function"!=typeof f)switch(f){case "required":f=function(a){return a==""||a==null?{msg:"This is a required field.",classes:["red"]}:false};break;case "int":f=function(a,b){var c=$(b).data("opts");if(!$(b)[0].validity.valid){var d=[];"min"in c&&d.push(" greater than or equal to "+c.min);"max"in c&&d.push(" smaller than or equal to "+c.max);return{msg:"Please enter an integer"+d.join(" and")+".",classes:["red"]}}if(parseInt(Number(a))!= if("validate"in b){o=[];for(n in b.validate){l=b.validate[n];if("function"!=typeof l)switch(l){case "required":l=function(a){return a==""||a==null?{msg:"This is a required field.",classes:["red"]}:false};break;case "int":l=function(a,b){var c=$(b).data("opts");if(!$(b)[0].validity.valid){var d=[];"min"in c&&d.push(" greater than or equal to "+c.min);"max"in c&&d.push(" smaller than or equal to "+c.max);return{msg:"Please enter an integer"+d.join(" and")+".",classes:["red"]}}if(parseInt(Number(a))!=
a)return{msg:"Please enter an integer.",classes:["red"]}};break;case "streamname":f=function(a,b){if(a!=""){if(!isNaN(a.charAt(0)))return{msg:"The first character may not be a number.",classes:["red"]};if(a.toLowerCase()!=a)return{msg:"Uppercase letters are not allowed.",classes:["red"]};if(a.replace(/[^\da-z_]/g,"")!=a)return{msg:"Special characters (except for underscores) are not allowed.",classes:["red"]};if("streams"in mist.data&&a in mist.data.streams&&$(b).data("pointer").main.name!=a)return{msg:"This streamname already exists.<br>If you want to edit an existing stream, please click edit on the the streams tab.", a)return{msg:"Please enter an integer.",classes:["red"]}};break;case "streamname":l=function(a,b){if(a!=""){if(!isNaN(a.charAt(0)))return{msg:"The first character may not be a number.",classes:["red"]};if(a.toLowerCase()!=a)return{msg:"Uppercase letters are not allowed.",classes:["red"]};if(a.replace(/[^\da-z_]/g,"")!=a)return{msg:"Special characters (except for underscores) are not allowed.",classes:["red"]};if("streams"in mist.data&&a in mist.data.streams&&$(b).data("pointer").main.name!=a)return{msg:"This streamname already exists.<br>If you want to edit an existing stream, please click edit on the the streams tab.",
classes:["red"]}}};break;case "streamname_with_wildcard":f=function(a){if(a!=""){streampart=a.split("+");var b=streampart.slice(1).join("+");streampart=streampart[0];if(!isNaN(streampart.charAt(0)))return{msg:"The first character may not be a number.",classes:["red"]};if(streampart.toLowerCase()!=streampart)return{msg:"Uppercase letters are not allowed in a stream name.",classes:["red"]};if(streampart.replace(/[^\da-z_]/g,"")!=streampart)return{msg:"Special characters (except for underscores) are not allowed in a stream name.", classes:["red"]}}};break;case "streamname_with_wildcard":l=function(a){if(a!=""){streampart=a.split("+");var b=streampart.slice(1).join("+");streampart=streampart[0];if(!isNaN(streampart.charAt(0)))return{msg:"The first character may not be a number.",classes:["red"]};if(streampart.toLowerCase()!=streampart)return{msg:"Uppercase letters are not allowed in a stream name.",classes:["red"]};if(streampart.replace(/[^\da-z_]/g,"")!=streampart)return{msg:"Special characters (except for underscores) are not allowed in a stream name.",
classes:["red"]};if(streampart!=a&&b.replace(/[\00|\0|\/]/g,"")!=b)return{msg:"Slashes or null bytes are not allowed in wildcards.",classes:["red"]}}};break;case "streamname_with_wildcard_and_variables":f=function(a){if(a!=""){streampart=a.split("+");var b=streampart.slice(1).join("+");streampart=streampart[0];if(!isNaN(streampart.charAt(0)))return{msg:"The first character may not be a number.",classes:["red"]};if(streampart.toLowerCase()!=streampart)return{msg:"Uppercase letters are not allowed in a stream name.", classes:["red"]};if(streampart!=a&&b.replace(/[\00|\0|\/]/g,"")!=b)return{msg:"Slashes or null bytes are not allowed in wildcards.",classes:["red"]}}};break;case "streamname_with_wildcard_and_variables":l=function(a){if(a!=""){streampart=a.split("+");var b=streampart.slice(1).join("+");streampart=streampart[0];if(!isNaN(streampart.charAt(0)))return{msg:"The first character may not be a number.",classes:["red"]};if(streampart.toLowerCase()!=streampart)return{msg:"Uppercase letters are not allowed in a stream name.",
classes:["red"]};if(streampart.replace(/[^\da-z_$]/g,"")!=streampart)return{msg:"Special characters (except for underscores) are not allowed in a stream name.",classes:["red"]};if(streampart!=a&&b.replace(/[\00|\0|\/]/g,"")!=b)return{msg:"Slashes or null bytes are not allowed in wildcards.",classes:["red"]}}};break;default:f=function(){}}i.push(f)}l.data("validate_functions",i).data("help_container",h).data("validate",function(a,b){if($(a).is(":visible")||$(a).is('input[type="hidden"]')){var c=$(a).getval(), classes:["red"]};if(streampart.replace(/[^\da-z_$]/g,"")!=streampart)return{msg:"Special characters (except for underscores) are not allowed in a stream name.",classes:["red"]};if(streampart!=a&&b.replace(/[\00|\0|\/]/g,"")!=b)return{msg:"Slashes or null bytes are not allowed in wildcards.",classes:["red"]}}};break;default:l=function(){}}o.push(l)}f.data("validate_functions",o).data("help_container",e).data("validate",function(a,b){if($(a).is(":visible")||$(a).is('input[type="hidden"]')){var c=$(a).getval(),
d=$(a).data("validate_functions"),g=$(a).data("help_container");g.find(".err_balloon").remove();for(var e in d){var f=d[e](c,a);if(f){$err=$("<span>").addClass("err_balloon").html(f.msg);for(var i in f.classes)$err.addClass(f.classes[i]);g.prepend($err);b&&$(a).focus();return typeof f=="object"&&"break"in f?f["break"]:true}}return false}}).addClass("hasValidate").on("change keyup",function(){$(this).data("validate")($(this))});""!=l.getval()&&l.trigger("change")}"function"in b&&(l.on("change keyup", d=$(a).data("validate_functions"),g=$(a).data("help_container");g.find(".err_balloon").remove();for(var h in d){var e=d[h](c,a);if(e){$err=$("<span>").addClass("err_balloon").html(e.msg);for(var f in e.classes)$err.addClass(e.classes[f]);g.prepend($err);b&&$(a).focus();return typeof e=="object"&&"break"in e?e["break"]:true}}return false}}).addClass("hasValidate").on("change keyup",function(){$(this).data("validate")($(this))});""!=f.getval()&&f.trigger("change")}"function"in b&&(f.on("change keyup",
b["function"]),l.trigger("change"))}}c.on("keydown",function(a){var b=!1;switch(a.which){case 13:b=$(this).find("button.save").first();break;case 27:b=$(this).find("button.cancel").first()}b&&b.length&&(b.trigger("click"),a.stopPropagation())});return 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 h in a.labels)b.push($("<tr>").append($("<td>").html(""== b["function"]),f.trigger("change"))}}c.on("keydown",function(a){var b=!1;switch(a.which){case 13:b=$(this).find("button.save").first();break;case 27:b=$(this).find("button.cancel").first()}b&&b.length&&(b.trigger("click"),a.stopPropagation())});return 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 f in a.labels)b.push($("<tr>").append($("<td>").html(""==
a.labels[h]?"&nbsp;":a.labels[h]+":")));for(var m in a.content)for(h in d.append($("<td>").html(a.content[m].header)),a.content[m].body)b[h].append($("<td>").html(a.content[m].body[h]));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); a.labels[f]?"&nbsp;":a.labels[f]+":")));for(var n in a.content)for(f in d.append($("<td>").html(a.content[n].header)),a.content[n].body)b[f].append($("<td>").html(a.content[n].body[f]));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);
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 h=a[d].datasets[b];switch(h.datatype){case "clients":case "upbps":case "downbps":switch(h.origin[0]){case "total":c.totals.push({fields:[h.datatype],end:-15});break;case "stream":c.totals.push({fields:[h.datatype],streams:[h.origin[1]],end:-15});break;case "protocol":c.totals.push({fields:[h.datatype],protocols:[h.origin[1]],end:-15})}break;case "cpuload":case "memload":c.capabilities= 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 f=a[d].datasets[b];switch(f.datatype){case "clients":case "upbps":case "downbps":switch(f.origin[0]){case "total":c.totals.push({fields:[f.datatype],end:-15});break;case "stream":c.totals.push({fields:[f.datatype],streams:[f.origin[1]],end:-15});break;case "protocol":c.totals.push({fields:[f.datatype],protocols:[f.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 b in a){var c=a[b];if(1>c.datasets.length){c.elements.plot.html("");c.elements.legend.html("");break}switch(c.xaxis){case "time":var d=[];c.yaxes={};var h=[],j;for(j in c.datasets){var l=c.datasets[j];l.display&&(l.getdata(),l.yaxistype in c.yaxes||(d.push(UI.plot.yaxes[l.yaxistype]),c.yaxes[l.yaxistype]=d.length),l.yaxis=c.yaxes[l.yaxistype],h.push(l))}d[0]&&(d[0].color=0);c.plot=$.plot(c.elements.plot, {}}}0==c.totals.length&&delete c.totals;0==c.clients.length&&delete c.clients;mist.send(function(){for(var b in a){var c=a[b];if(1>c.datasets.length){c.elements.plot.html("");c.elements.legend.html("");break}switch(c.xaxis){case "time":var d=[];c.yaxes={};var f=[],j;for(j in c.datasets){var l=c.datasets[j];l.display&&(l.getdata(),l.yaxistype in c.yaxes||(d.push(UI.plot.yaxes[l.yaxistype]),c.yaxes[l.yaxistype]=d.length),l.yaxis=c.yaxes[l.yaxistype],f.push(l))}d[0]&&(d[0].color=0);c.plot=$.plot(c.elements.plot,
h,{legend:{show:!1},xaxis:UI.plot.xaxes[c.xaxis],yaxes:d,grid:{hoverable:!0,borderWidth:{top:0,right:0,bottom:1,left:1},color:"black",backgroundColor:{colors:["rgba(0,0,0,0)","rgba(0,0,0,0.025)"]}},crosshair:{mode:"x"}});d=$("<table>").addClass("legend-list").addClass("nolay").html($("<tr>").html($("<td>").html($("<h3>").text(c.id))).append($("<td>").css("padding-right","2em").css("text-align","right").html($("<span>").addClass("value")).append($("<button>").data("opts",c).text("X").addClass("close").click(function(){var b= f,{legend:{show:!1},xaxis:UI.plot.xaxes[c.xaxis],yaxes:d,grid:{hoverable:!0,borderWidth:{top:0,right:0,bottom:1,left:1},color:"black",backgroundColor:{colors:["rgba(0,0,0,0)","rgba(0,0,0,0.025)"]}},crosshair:{mode:"x"}});d=$("<table>").addClass("legend-list").addClass("nolay").html($("<tr>").html($("<td>").html($("<h3>").text(c.id))).append($("<td>").css("padding-right","2em").css("text-align","right").html($("<span>").addClass("value")).append($("<button>").data("opts",c).text("X").addClass("close").click(function(){var b=
$(this).data("opts");if(confirm("Are you sure you want to remove "+b.id+"?")){b.elements.cont.remove();var c=$(".graph_ids option:contains("+b.id+")"),d=c.parent();c.remove();UI.plot.del(b.id);delete a[b.id];d.trigger("change");UI.plot.go(a)}}))));c.elements.legend.html(d);var u=function(a){var b=c.elements.legend.find(".value"),d=1;if(typeof a=="undefined")b.eq(0).html("Latest:");else{var g=c.plot.getXAxes()[0],a=Math.min(g.max,a),a=Math.max(g.min,a);b.eq(0).html(UI.format.time(a/1E3))}for(var f in c.datasets){var h= $(this).data("opts");if(confirm("Are you sure you want to remove "+b.id+"?")){b.elements.cont.remove();var c=$(".graph_ids option:contains("+b.id+")"),d=c.parent();c.remove();UI.plot.del(b.id);delete a[b.id];d.trigger("change");UI.plot.go(a)}}))));c.elements.legend.html(d);var u=function(a){var b=c.elements.legend.find(".value"),d=1;if(typeof a=="undefined")b.eq(0).html("Latest:");else{var g=c.plot.getXAxes()[0],a=Math.min(g.max,a),a=Math.max(g.min,a);b.eq(0).html(UI.format.time(a/1E3))}for(var e in c.datasets){var f=
"&nbsp;";if(c.datasets[f].display){var g=UI.plot.yaxes[c.datasets[f].yaxistype].tickFormatter,j=c.datasets[f].data;if(a)for(var l in j){if(j[l][0]==a){h=g(j[l][1]);break}if(j[l][0]>a){if(l!=0){h=j[l];j=j[l-1];h=g(h[1]+(a-h[0])*(j[1]-h[1])/(j[0]-h[0]))}break}}else h=g(c.datasets[f].data[c.datasets[f].data.length-1][1])}b.eq(d).html(h);d++}};c.plot.getOptions();for(j in c.datasets)h=$("<input>").attr("type","checkbox").data("index",j).data("graph",c).click(function(){var a=$(this).data("graph");$(this).is(":checked")? "&nbsp;";if(c.datasets[e].display){var g=UI.plot.yaxes[c.datasets[e].yaxistype].tickFormatter,j=c.datasets[e].data;if(a)for(var l in j){if(j[l][0]==a){f=g(j[l][1]);break}if(j[l][0]>a){if(l!=0){f=j[l];j=j[l-1];f=g(f[1]+(a-f[0])*(j[1]-f[1])/(j[0]-f[0]))}break}}else f=g(c.datasets[e].data[c.datasets[e].data.length-1][1])}b.eq(d).html(f);d++}};c.plot.getOptions();for(j in c.datasets)f=$("<input>").attr("type","checkbox").data("index",j).data("graph",c).click(function(){var a=$(this).data("graph");$(this).is(":checked")?
a.datasets[$(this).data("index")].display=true:a.datasets[$(this).data("index")].display=false;var b={};b[a.id]=a;UI.plot.go(b)}),c.datasets[j].display&&h.attr("checked","checked"),d.append($("<tr>").html($("<td>").html($("<label>").html(h).append($("<div>").addClass("series-color").css("background-color",c.datasets[j].color)).append(c.datasets[j].label))).append($("<td>").css("padding-right","2em").css("text-align","right").html($("<span>").addClass("value")).append($("<button>").text("X").addClass("close").data("index", a.datasets[$(this).data("index")].display=true:a.datasets[$(this).data("index")].display=false;var b={};b[a.id]=a;UI.plot.go(b)}),c.datasets[j].display&&f.attr("checked","checked"),d.append($("<tr>").html($("<td>").html($("<label>").html(f).append($("<div>").addClass("series-color").css("background-color",c.datasets[j].color)).append(c.datasets[j].label))).append($("<td>").css("padding-right","2em").css("text-align","right").html($("<span>").addClass("value")).append($("<button>").text("X").addClass("close").data("index",
j).data("graph",c).click(function(){var b=$(this).data("index"),c=$(this).data("graph");if(confirm("Are you sure you want to remove "+c.datasets[b].label+" from "+c.id+"?")){c.datasets.splice(b,1);if(c.datasets.length==0){c.elements.cont.remove();var b=$(".graph_ids option:contains("+c.id+")"),d=b.parent();b.remove();d.trigger("change");UI.plot.del(c.id);delete a[c.id];UI.plot.go(a)}else{UI.plot.save(c);b={};b[c.id]=c;UI.plot.go(b)}}}))));u();var g=!1;c.elements.plot.on("plothover",function(a,b,c){if(b.x!= j).data("graph",c).click(function(){var b=$(this).data("index"),c=$(this).data("graph");if(confirm("Are you sure you want to remove "+c.datasets[b].label+" from "+c.id+"?")){c.datasets.splice(b,1);if(c.datasets.length==0){c.elements.cont.remove();var b=$(".graph_ids option:contains("+c.id+")"),d=b.parent();b.remove();d.trigger("change");UI.plot.del(c.id);delete a[c.id];UI.plot.go(a)}else{UI.plot.save(c);b={};b[c.id]=c;UI.plot.go(b)}}}))));u();var g=!1;c.elements.plot.on("plothover",function(a,b,c){if(b.x!=
g){u(b.x);g=b.x}if(c){a=$("<span>").append($("<h3>").text(c.series.label).prepend($("<div>").addClass("series-color").css("background-color",c.series.color))).append($("<table>").addClass("nolay").html($("<tr>").html($("<td>").text("Time:")).append($("<td>").html(UI.format.dateTime(c.datapoint[0]/1E3,"long")))).append($("<tr>").html($("<td>").text("Value:")).append($("<td>").html(c.series.yaxis.tickFormatter(c.datapoint[1],c.series.yaxis)))));UI.tooltip.show(b,a.children())}else UI.tooltip.hide()}).on("mouseout", g){u(b.x);g=b.x}if(c){a=$("<span>").append($("<h3>").text(c.series.label).prepend($("<div>").addClass("series-color").css("background-color",c.series.color))).append($("<table>").addClass("nolay").html($("<tr>").html($("<td>").text("Time:")).append($("<td>").html(UI.format.dateTime(c.datapoint[0]/1E3,"long")))).append($("<tr>").html($("<td>").text("Value:")).append($("<td>").html(c.series.yaxis.tickFormatter(c.datapoint[1],c.series.yaxis)))));UI.tooltip.show(b,a.children())}else UI.tooltip.hide()}).on("mouseout",
function(){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, 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,
@ -69,10 +69,10 @@ d,a),a=$.extend(!0,c,a);switch(a.origin[0]){case "total":switch(a.datatype){case
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", 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:"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", 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",
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- 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-
a.min)/c,d=Math.floor(Math.log(Math.abs(c))/Math.log(1024)),b=c/Math.pow(1024,d),h=-Math.floor(Math.log(b)/Math.LN10),m=a.tickDecimals;null!=m&&h>m&&(h=m);var i=Math.pow(10,-h),b=b/i,f;if(1.5>b)f=1;else if(3>b){if(f=2,2.25<b&&(null==m||h+1<=m))f=2.5,++h}else f=7.5>b?5:10;f=f*i*Math.pow(1024,d);null!=a.minTickSize&&f<a.minTickSize&&(f=a.minTickSize);a.delta=c;a.tickDecimals=Math.max(0,null!=m?m:h);a.tickSize=f;c=[];d=a.tickSize*Math.floor(a.min/a.tickSize);h=0;m=Number.NaN;do i=m,m=d+h*a.tickSize, a.min)/c,d=Math.floor(Math.log(Math.abs(c))/Math.log(1024)),b=c/Math.pow(1024,d),f=-Math.floor(Math.log(b)/Math.LN10),n=a.tickDecimals;null!=n&&f>n&&(f=n);var o=Math.pow(10,-f),b=b/o,e;if(1.5>b)e=1;else if(3>b){if(e=2,2.25<b&&(null==n||f+1<=n))e=2.5,++f}else e=7.5>b?5:10;e=e*o*Math.pow(1024,d);null!=a.minTickSize&&e<a.minTickSize&&(e=a.minTickSize);a.delta=c;a.tickDecimals=Math.max(0,null!=n?n:f);a.tickSize=e;c=[];d=a.tickSize*Math.floor(a.min/a.tickSize);f=0;n=Number.NaN;do o=n,n=d+f*a.tickSize,
c.push(m),++h;while(m<a.max&&m!=i);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, c.push(n),++f;while(n<a.max&&n!=o);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,
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(" "),h=[];"long"==c&&h.push(b[d.getDay()]);h.push(("0"+d.getDate()).slice(-2));h.push("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" ")[d.getMonth()]); 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(" "),f=[];"long"==c&&f.push(b[d.getDay()]);f.push(("0"+d.getDate()).slice(-2));f.push("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" ")[d.getMonth()]);
"short"!=c&&h.push(d.getFullYear());return h.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,52,1E9],d="ms sec min hr day week year".split(" "),b={},h;for(h in d){var a=a/c[h],m=Math.round(a%c[Number(h)+1]);b[d[h]]=m;a-=m}var i;for(h=d.length-1;0<=h;h--)if(0<b[d[h]]){i=d[h];break}c=$("<span>");switch(i){case "year":c.append(UI.format.addUnit(b.year,"years, ")).append(UI.format.addUnit(b.week,"wks"));break;case "week":c.append(UI.format.addUnit(b.week, "short"!=c&&f.push(d.getFullYear());return f.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,52,1E9],d="ms sec min hr day week year".split(" "),b={},f;for(f in d){var a=a/c[f],n=Math.round(a%c[Number(f)+1]);b[d[f]]=n;a-=n}var o;for(f=d.length-1;0<=f;f--)if(0<b[d[f]]){o=d[f];break}c=$("<span>");switch(o){case "year":c.append(UI.format.addUnit(b.year,"years, ")).append(UI.format.addUnit(b.week,"wks"));break;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,"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]= "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]=
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()+ 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()+
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("&"); 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("&");
@ -84,87 +84,87 @@ type:"str",validate:["required"],help:"Enter your desired username. In the futur
{label:"Repeat password",type:"password",validate:["required",function(a,b){return a!=$(".match_password.field").not($(b)).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}}); {label:"Repeat password",type:"password",validate:["required",function(a,b){return a!=$(".match_password.field").not($(b)).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>"); 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>");mist.send(function(a){var b=[],c;for(c in a.capabilities.connectors)if(a.capabilities.connectors[c].required)d.append('Could not enable protocol "'+c+'" because it has required settings.<br>');else{b.push({connector:c});d.append('Enabled protocol "'+c+'".<br>')}d.append("Saving protocol settings..<br>");mist.send(function(){d.append("Protocols enabled. Redirecting..");setTimeout(function(){UI.navto("Overview")},5E3)},{config:{protocols:b}})},{capabilities:true})}}}, else{d.append("Retrieving available protocols..<br>");mist.send(function(a){var b=[],c;for(c in a.capabilities.connectors)if(a.capabilities.connectors[c].required)d.append('Could not enable protocol "'+c+'" because it has required settings.<br>');else{b.push({connector:c});d.append('Enabled protocol "'+c+'".<br>')}d.append("Saving protocol settings..<br>");mist.send(function(){d.append("Protocols enabled. Redirecting..");setTimeout(function(){UI.navto("Overview")},5E3)},{config:{protocols:b}})},{capabilities:true})}}},
{label:"Skip",type:"cancel","function":function(){UI.navto("Overview")}}]}]));break;case "Overview":if("undefined"==typeof mist.data.bandwidth){mist.send(function(){UI.navto(a)},{bandwidth:!0});d.append("Loading..");return}var h=$("<span>").text("Loading.."),m=$("<span>"),i=$("<span>").addClass("logs"),f=$("<span>"),r=$("<span>"),j=$("<span>").text("Unknown"),l=$("<span>"),u=$("<span>"),g={serverid:mist.data.config.serverid,debug:mist.data.config.debug,accesslog:mist.data.config.accesslog,prometheus:mist.data.config.prometheus}, {label:"Skip",type:"cancel","function":function(){UI.navto("Overview")}}]}]));break;case "Overview":if("undefined"==typeof mist.data.bandwidth){mist.send(function(){UI.navto(a)},{bandwidth:!0});d.append("Loading..");return}var f=$("<span>").text("Loading.."),n=$("<span>"),o=$("<span>").addClass("logs"),e=$("<span>"),r=$("<span>"),j=$("<span>").text("Unknown"),l=$("<span>"),u=$("<span>"),g={serverid:mist.data.config.serverid,debug:mist.data.config.debug,accesslog:mist.data.config.accesslog,prometheus:mist.data.config.prometheus},
e={};"bandwidth"in mist.data&&(e=mist.data.bandwidth,null==e&&(e={}),e.limit||(e.limit=""));var k=$("<select>").html($("<option>").val(1).text("bytes/s")).append($("<option>").val(1024).text("KiB/s")).append($("<option>").val(1048576).text("MiB/s")).append($("<option>").val(1073741824).text("GiB/s")),b=parseURL(mist.user.host),b=b.protocol+b.host+b.port;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. "}, h={};"bandwidth"in mist.data&&(h=mist.data.bandwidth,null==h&&(h={}),h.limit||(h.limit=""));var k=$("<select>").html($("<option>").val(1).text("bytes/s")).append($("<option>").val(1024).text("KiB/s")).append($("<option>").val(1048576).text("MiB/s")).append($("<option>").val(1073741824).text("GiB/s")),b=parseURL(mist.user.host),b=b.protocol+b.host+b.port;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:h,LTSonly:!0},{type:"span",label:"Server time",value:r},{type:"span",label:"Licensed to",value:"license"in mist.data.config?mist.data.config.license.user:"",LTSonly:!0},{type:"span",label:"Active products",value:j,LTSonly:!0},{type:"span",label:"Configured streams",value:mist.data.streams?Object.keys(mist.data.streams).length:0},{type:"span",label:"Active streams",value:m},{type:"span", {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:r},{type:"span",label:"Licensed to",value:"license"in mist.data.config?mist.data.config.license.user:"",LTSonly:!0},{type:"span",label:"Active licenses",value:j,LTSonly:!0},{type:"span",label:"Configured streams",value:mist.data.streams?Object.keys(mist.data.streams).length:0},{type:"span",label:"Active streams",value:n},{type:"span",
label:"Current connections",value:f},{type:"span",label:"Enabled protocols",value:l},{type:"span",label:"Disabled protocols",value:u},{type:"span",label:"Recent problems",value:i},$("<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."}, label:"Current connections",value:e},{type:"span",label:"Enabled protocols",value:l},{type:"span",label:"Disabled protocols",value:u},{type:"span",label:"Recent problems",value:o},$("<br>"),{type:"str",label:"Human readable name",pointer:{main:g,index:"serverid"},help:"You can name your MistServer here for personal use. You'll still need to set host name within your network yourself."},{type:"debug",label:"Debug level",pointer:{main:g,index:"debug"},help:"You can set the amount of debug information MistServer saves in the log. A full reboot of MistServer is required before some components of MistServer can post debug information."},
{type:"selectinput",label:"Access log",selectinput:[["","Do not track"],["LOG","Log to MistServer log"],[{type:"str",label:"Path",LTSonly:!0},"Log to file"]],pointer:{main:g,index:"accesslog"},help:"Enable access logs.",LTSonly:!0},{type:"selectinput",label:"Prometheus stats output",selectinput:[["","Disabled"],[{type:"str",label:"Passphrase",LTSonly:!0},"Enabled"]],pointer:{main:g,index:"prometheus"},help:"Make stats available in Prometheus format. These can be accessed via "+b+"/PASSPHRASE or "+ {type:"selectinput",label:"Access log",selectinput:[["","Do not track"],["LOG","Log to MistServer log"],[{type:"str",label:"Path",LTSonly:!0},"Log to file"]],pointer:{main:g,index:"accesslog"},help:"Enable access logs.",LTSonly:!0},{type:"selectinput",label:"Prometheus stats output",selectinput:[["","Disabled"],[{type:"str",label:"Passphrase",LTSonly:!0},"Enabled"]],pointer:{main:g,index:"prometheus"},help:"Make stats available in Prometheus format. These can be accessed via "+b+"/PASSPHRASE or "+
b+"/PASSPHRASE.json.",LTSonly:!0},{type:"selectinput",label:"Load balancer bandwidth limit",selectinput:[["","Default (1 gbps)"],[{label:"Custom",type:"int",min:0,unit:k},"Custom"]],pointer:{main:e,index:"limit"},help:"This setting only applies when MistServer is combined with a load balancer. This is the amount of traffic this server is willing to handle.",LTSonly:!0},{type:"inputlist",label:"Load balancer bandwidth exceptions",pointer:{main:e,index:"exceptions"},help:"This setting only applies when MistServer is combined with a load balancer. Data sent to the hosts and subnets listed here will not count towards reported bandwidth usage.<br>Examples:<ul><li>192.168.0.0/16</li><li>localhost</li><li>10.0.0.0/8</li><li>fe80::/16</li></ul>", b+"/PASSPHRASE.json.",LTSonly:!0},{type:"selectinput",label:"Load balancer bandwidth limit",selectinput:[["","Default (1 gbps)"],[{label:"Custom",type:"int",min:0,unit:k},"Custom"]],pointer:{main:h,index:"limit"},help:"This setting only applies when MistServer is combined with a load balancer. This is the amount of traffic this server is willing to handle.",LTSonly:!0},{type:"inputlist",label:"Load balancer bandwidth exceptions",pointer:{main:h,index:"exceptions"},help:"This setting only applies when MistServer is combined with a load balancer. Data sent to the hosts and subnets listed here will not count towards reported bandwidth usage.<br>Examples:<ul><li>192.168.0.0/16</li><li>localhost</li><li>10.0.0.0/8</li><li>fe80::/16</li></ul>",
LTSonly:!0},{type:"checkbox",label:"Force configurations save",pointer:{main:g,index:"save"},help:"Tick the box in order to force an immediate save to the config.json MistServer uses to save your settings. Saving will otherwise happen upon closing MistServer. Don't forget to press save after ticking the box."},{type:"buttons",buttons:[{type:"save",label:"Save","function":function(){var a={config:g},b={};b.limit=e.limit?k.val()*e.limit:0;b.exceptions=e.exceptions;if(b.exceptions===null)b.exceptions= LTSonly:!0},{type:"checkbox",label:"Force configurations save",pointer:{main:g,index:"save"},help:"Tick the box in order to force an immediate save to the config.json MistServer uses to save your settings. Saving will otherwise happen upon closing MistServer. Don't forget to press save after ticking the box."},{type:"buttons",buttons:[{type:"save",label:"Save","function":function(){var a={config:g},b={};b.limit=h.limit?k.val()*h.limit:0;b.exceptions=h.exceptions;if(b.exceptions===null)b.exceptions=
[];a.bandwidth=b;if(g.save)a.save=g.save;delete g.save;mist.send(function(){UI.navto("Overview")},a)}}]}]));if(mist.data.LTS){var n=function(a){function b(a){if(a.update){var d="";"progress"in a.update&&(d=" ("+a.update.progress+"%)");h.text("Updating.."+d);c(a.log);setTimeout(function(){mist.send(function(a){b(a)},{update:true})},1E3)}else UI.showTab("Overview")}function c(a){a=a.filter(function(a){return a[1]=="UPDR"});if(a.length){var b=$("<div>");h.append(b);for(var d in a)b.append($("<div>").text(a[d][2]))}} [];a.bandwidth=b;if(g.save)a.save=g.save;delete g.save;mist.send(function(){UI.navto("Overview")},a)}}]}]));if(mist.data.LTS){var i=function(a){function b(a){if(a.update){var d="";"progress"in a.update&&(d=" ("+a.update.progress+"%)");f.text("Updating.."+d);c(a.log);setTimeout(function(){mist.send(function(a){b(a)},{update:true})},1E3)}else UI.showTab("Overview")}function c(a){a=a.filter(function(a){return a[1]=="UPDR"});if(a.length){var b=$("<div>");f.append(b);for(var d in a)b.append($("<div>").text(a[d][2]))}}
if(!a.update||!("uptodate"in a.update)){h.text("Unknown, checking..");setTimeout(function(){mist.send(function(a){"update"in a&&n(a)},{checkupdate:true})},5E3)}else if(a.update.error)h.addClass("red").text(a.update.error);else if(a.update.uptodate)h.text("Your version is up to date.").addClass("green");else{if(a.update.progress){h.addClass("orange").removeClass("red").text("Updating..");b(a)}else{h.text("");h.append($("<span>").addClass("red").text("On "+(new Date(a.update.date)).toLocaleDateString()+ if(!a.update||!("uptodate"in a.update)){f.text("Unknown, checking..");setTimeout(function(){mist.send(function(a){"update"in a&&i(a)},{checkupdate:true})},5E3)}else if(a.update.error)f.addClass("red").text(a.update.error);else if(a.update.uptodate)f.text("Your version is up to date.").addClass("green");else{if(a.update.progress){f.addClass("orange").removeClass("red").text("Updating..");b(a)}else{f.text("");f.append($("<span>").addClass("red").text("On "+(new Date(a.update.date)).toLocaleDateString()+
" version "+a.update.version+" became available."));(!a.update.url||a.update.url.slice(-4)!=".zip")&&h.append($("<button>").text("Rolling update").css({"font-size":"1em","margin-left":"1em"}).click(function(){if(confirm("Are you sure you want to execute a rolling update?")){h.addClass("orange").removeClass("red").text("Rolling update command sent..");mist.send(function(a){b(a)},{autoupdate:true})}}));var d=$("<a>").attr("href",a.update.url).attr("target","_blank").text("Manual download");d[0].protocol= " version "+a.update.version+" became available."));(!a.update.url||a.update.url.slice(-4)!=".zip")&&f.append($("<button>").text("Rolling update").css({"font-size":"1em","margin-left":"1em"}).click(function(){if(confirm("Are you sure you want to execute a rolling update?")){f.addClass("orange").removeClass("red").text("Rolling update command sent..");mist.send(function(a){b(a)},{autoupdate:true})}}));var d=$("<a>").attr("href",a.update.url).attr("target","_blank").text("Manual download");d[0].protocol=
"https:";h.append($("<div>").append(d))}c(a.log)}};n(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 I=$("<table>").css("text-indent","0");j.html(I);I.append($("<tr>").append($("<th>").append("Product")).append($("<th>").append("Updates until")).append($("<th>").append("Use until")).append($("<th>").append("Max. simul. instances")));for(var o in mist.data.config.license.active_products)b= "https:";f.append($("<div>").append(d))}c(a.log)}};i(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");j.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(var m in mist.data.config.license.active_products)b=
mist.data.config.license.active_products[o],I.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 j.text("None. ");j.append($("<a>").text("More details").attr("href","https://shop.mistserver.org/myinvoices").attr("target","_blank"))}}else h.text("");o=function(){var a={totals:{fields:["clients"],start:-10},active_streams:true}; mist.data.config.license.active_products[m],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 j.text("None. ");j.append($("<a>").text("More details").attr("href","https://shop.mistserver.org/myinvoices").attr("target","_blank"))}}else f.text("");m=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(){m.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..";f.text(a);r.text(UI.format.dateTime(mist.data.config.time,"long"));i.html("");a=0;"license"in mist.data.config&&"user_msg"in if(!("cabailities"in mist.data))a.capabilities=true;mist.send(function(){fa()},a)};var fa=function(){n.text("active_streams"in mist.data?mist.data.active_streams?mist.data.active_streams.length:0:"?");if("totals"in mist.data&&"all_streams"in mist.data.totals)var a=mist.data.totals.all_streams.all_protocols.clients,a=a.length?UI.format.number(a[a.length-1][1]):0;else a="Loading..";e.text(a);r.text(UI.format.dateTime(mist.data.config.time,"long"));o.html("");a=0;"license"in mist.data.config&&"user_msg"in
mist.data.config.license&&mist.data.log.unshift([mist.data.config.license.time,"ERROR",mist.data.config.license.user_msg]);for(var b in mist.data.log){var c=mist.data.log[b];if(["FAIL","ERROR"].indexOf(c[1])>-1){a++;var d=$("<span>").addClass("content").addClass("red"),g=c[2].split("|");for(b in g)d.append($("<span>").text(g[b]));i.append($("<div>").append($("<span>").append(UI.format.time(c[0]))).append(d));if(a==5)break}}a==0&&i.html("None.");a=[];c=[];for(b in mist.data.config.protocols){d=mist.data.config.protocols[b]; mist.data.config.license&&mist.data.log.unshift([mist.data.config.license.time,"ERROR",mist.data.config.license.user_msg]);for(var b in mist.data.log){var c=mist.data.log[b];if(["FAIL","ERROR"].indexOf(c[1])>-1){a++;var d=$("<span>").addClass("content").addClass("red"),g=c[2].split("|");for(b in g)d.append($("<span>").text(g[b]));o.append($("<div>").append($("<span>").append(UI.format.time(c[0]))).append(d));if(a==5)break}}a==0&&o.html("None.");a=[];c=[];for(b in mist.data.config.protocols){d=mist.data.config.protocols[b];
a.indexOf(d.connector)>-1||a.push(d.connector)}l.text(a.length?a.join(", "):"None.");if("capabilities"in mist.data){for(b in mist.data.capabilities.connectors)a.indexOf(b)==-1&&c.push(b);u.text(c.length?c.join(", "):"None.")}else u.text("Loading..")};o();ga();UI.interval.set(o,3E4);break;case "Protocols":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});d.append("Loading..");return}var A=$("<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= a.indexOf(d.connector)>-1||a.push(d.connector)}l.text(a.length?a.join(", "):"None.");if("capabilities"in mist.data){for(b in mist.data.capabilities.connectors)a.indexOf(b)==-1&&c.push(b);u.text(c.length?c.join(", "):"None.")}else u.text("Loading..")};m();fa();UI.interval.set(m,3E4);break;case "Protocols":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});d.append("Loading..");return}var A=$("<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),b;for(b in mist.data.config.protocols){var c=a.indexOf(mist.data.config.protocols[b].connector);c>-1&&a.splice(c,1)}var d=[];for(b in a)(!("required"in mist.data.capabilities.connectors[a[b]])||Object.keys(mist.data.capabilities.connectors[a[b]].required).length==0)&&d.push(a[b]);c="Click OK to enable disabled protocols with their default settings:\n "; [];mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}})).append($("<button>").text("Enable default protocols").click(function(){var a=Object.keys(mist.data.capabilities.connectors),b;for(b in mist.data.config.protocols){var c=a.indexOf(mist.data.config.protocols[b].connector);c>-1&&a.splice(c,1)}var d=[];for(b in a)(!("required"in mist.data.capabilities.connectors[a[b]])||Object.keys(mist.data.capabilities.connectors[a[b]].required).length==0)&&d.push(a[b]);c="Click OK to enable disabled protocols with their default settings:\n ";
c=d.length?c+d.join(", "):c+"None.";if(d.length!=a.length){a=a.filter(function(a){return d.indexOf(a)<0});c=c+("\n\nThe following protocols can only be set manually:\n "+a.join(", "))}if(confirm(c)&&d.length){if(mist.data.config.protocols===null)mist.data.config.protocols=[];for(b in d)mist.data.config.protocols.push({connector:d[b]});mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}})).append("<br>").append($("<button>").text("New protocol").click(function(){UI.navto("Edit Protocol")}).css("clear", c=d.length?c+d.join(", "):c+"None.";if(d.length!=a.length){a=a.filter(function(a){return d.indexOf(a)<0});c=c+("\n\nThe following protocols can only be set manually:\n "+a.join(", "))}if(confirm(c)&&d.length){if(mist.data.config.protocols===null)mist.data.config.protocols=[];for(b in d)mist.data.config.protocols.push({connector:d[b]});mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}})).append("<br>").append($("<button>").text("New protocol").click(function(){UI.navto("Edit Protocol")}).css("clear",
"both")).append($("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Protocol")).append($("<th>").text("Status")).append($("<th>").text("Settings")).append($("<th>")))).append(A));var ha=function(){function a(b){var c=mist.data.capabilities.connectors[b.connector];if(!c)return"";var d=[],g=["required","optional"],f;for(f in g)for(var w in c[g[f]])b[w]&&b[w]!=""?d.push(w+": "+b[w]):c[g[f]][w]["default"]&&d.push(w+": "+c[g[f]][w]["default"]);return $("<span>").addClass("description").text(d.join(", "))} "both")).append($("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Protocol")).append($("<th>").text("Status")).append($("<th>").text("Settings")).append($("<th>")))).append(A));var ga=function(){function a(b){var c=mist.data.capabilities.connectors[b.connector];if(!c)return"";var d=[],g=["required","optional"],e;for(e in g)for(var f in c[g[e]])b[f]&&b[f]!=""?d.push(f+": "+b[f]):c[g[e]][f]["default"]&&d.push(f+": "+c[g[e]][f]["default"]);return $("<span>").addClass("description").text(d.join(", "))}
A.html("");for(var b in mist.data.config.protocols){var c=mist.data.config.protocols[b],d=mist.data.capabilities.connectors[c.connector];A.append($("<tr>").data("index",b).append($("<td>").text(d&&d.friendly?d.friendly:c.connector)).append($("<td>").html(UI.format.status(c))).append($("<td>").html(a(c))).append($("<td>").css("text-align","right").html($("<button>").text("Edit").click(function(){UI.navto("Edit Protocol",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a= A.html("");for(var b in mist.data.config.protocols){var c=mist.data.config.protocols[b],d=mist.data.capabilities.connectors[c.connector];A.append($("<tr>").data("index",b).append($("<td>").text(d&&d.friendly?d.friendly:c.connector)).append($("<td>").html(UI.format.status(c))).append($("<td>").html(a(c))).append($("<td>").css("text-align","right").html($("<button>").text("Edit").click(function(){UI.navto("Edit Protocol",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a=
$(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the protocol "'+mist.data.config.protocols[a].connector+'"?')){mist.send(function(){UI.navto("Protocols")},{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 E= $(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)}}))))}};ga();UI.interval.set(function(){mist.send(function(){ga()})},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 E=
!1;""!=c&&0<=c&&(E=!0);var M={};for(o in mist.data.config.protocols)M[mist.data.config.protocols[o].connector]=1;var ia=function(a){var b=mist.data.capabilities.connectors[a],c=mist.convertBuildOptions(b,p);if(E)var d=$.extend({},p);c.push({type:"hidden",pointer:{main:p,index:"connector"},value:a});c.push({type:"buttons",buttons:[{type:"save",label:"Save","function":function(){var a={};E?a.updateprotocol=[d,p]:a.addprotocol=p;mist.send(function(){UI.navto("Protocols")},a)}},{type:"cancel",label:"Cancel", !1;""!=c&&0<=c&&(E=!0);var L={};for(m in mist.data.config.protocols)L[mist.data.config.protocols[m].connector]=1;var ha=function(a){var b=mist.data.capabilities.connectors[a],c=mist.convertBuildOptions(b,p);if(E)var d=$.extend({},p);c.push({type:"hidden",pointer:{main:p,index:"connector"},value:a});c.push({type:"buttons",buttons:[{type:"save",label:"Save","function":function(){var a={};E?a.updateprotocol=[d,p]:a.addprotocol=p;mist.send(function(){UI.navto("Protocols")},a)}},{type:"cancel",label:"Cancel",
"function":function(){UI.navto("Protocols")}}]});if("deps"in b&&b.deps!=""){I=$("<span>").text("Dependencies:");$ul=$("<ul>");I.append($ul);if(typeof b.deps=="string")b.deps=b.deps.split(", ");for(var g in b.deps){a=$("<li>").text(b.deps[g]+" ");$ul.append(a);typeof M[b.deps[g]]!="undefined"||typeof M[b.deps[g]+".exe"]!="undefined"?a.append($("<span>").addClass("green").text("(Configured)")):a.append($("<span>").addClass("red").text("(Not yet configured)"))}c.unshift({type:"text",text:I[0].innerHTML})}return UI.buildUI(c)}, "function":function(){UI.navto("Protocols")}}]});if("deps"in b&&b.deps!=""){z=$("<span>").text("Dependencies:");$ul=$("<ul>");z.append($ul);if(typeof b.deps=="string")b.deps=b.deps.split(", ");for(var g in b.deps){a=$("<li>").text(b.deps[g]+" ");$ul.append(a);typeof L[b.deps[g]]!="undefined"||typeof L[b.deps[g]+".exe"]!="undefined"?a.append($("<span>").addClass("green").text("(Configured)")):a.append($("<span>").addClass("red").text("(Not yet configured)"))}c.unshift({type:"text",text:z[0].innerHTML})}return UI.buildUI(c)},
M={};for(o in mist.data.config.protocols)M[mist.data.config.protocols[o].connector]=1;if(E){var t=mist.data.config.protocols[c],p=t;d.find("h2").append(' "'+t.connector+'"');d.append(ia(t.connector))}else{d.html($("<h2>").text("New Protocol"));var p={},s=[["",""]];for(o in mist.data.capabilities.connectors)s.push([o,mist.data.capabilities.connectors[o].friendly?mist.data.capabilities.connectors[o].friendly:o]);var J=$("<span>");d.append(UI.buildUI([{label:"Protocol",type:"select",select:s,"function":function(){$(this).getval()!= L={};for(m in mist.data.config.protocols)L[mist.data.config.protocols[m].connector]=1;if(E){var s=mist.data.config.protocols[c],p=s;d.find("h2").append(' "'+s.connector+'"');d.append(ha(s.connector))}else{d.html($("<h2>").text("New Protocol"));var p={},t=[["",""]];for(m in mist.data.capabilities.connectors)t.push([m,mist.data.capabilities.connectors[m].friendly?mist.data.capabilities.connectors[m].friendly:m]);var I=$("<span>");d.append(UI.buildUI([{label:"Protocol",type:"select",select:t,"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}o=$("<button>");var F=$("<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(o).append($("<button>").text("Create a new stream").click(function(){UI.navto("Edit")}))])).append(F); ""&&I.html(ha($(this).getval()))}}])).append(I)}break;case "Streams":if(!("capabilities"in mist.data)){d.html("Loading..");mist.send(function(){UI.navto(a)},{capabilities:!0});return}m=$("<button>");var F=$("<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(m).append($("<button>").text("Create a new stream").click(function(){UI.navto("Edit")}))])).append(F);
""==c&&(g=mist.stored.get(),"viewmode"in g&&(c=g.viewmode));o.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 z=$.extend(!0,{},mist.data.streams),U=function(a,b){var c=$.extend({},b);delete c.meta;delete c.error;c.online=2;c.name=a;c.ischild=true;return c},V=function(b,c,g){F.remove();switch(b){case "thumbnails":var f=$("<div>").addClass("preview_icons"), ""==c&&(g=mist.stored.get(),"viewmode"in g&&(c=g.viewmode));m.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),T=function(a,b){var c=$.extend({},b);delete c.meta;delete c.error;c.online=2;c.name=a;c.ischild=true;return c},U=function(b,c,g){F.remove();switch(b){case "thumbnails":var f=$("<div>").addClass("preview_icons"),
e;e=g||[];c.sort();c.unshift("");F.remove();d.append($("<h2>").text(a)).append(UI.buildUI([{label:"Filter the streams",type:"datalist",datalist:c,pointer:{main:{},index:"stream"},help:"If you type something here, the box below will only show streams with names that contain your text.","function":function(){var a=$(this).val();f.children().each(function(){$(this).hide();$(this).attr("data-stream").indexOf(a)>-1&&$(this).show()})}}]));c.shift();d.append($("<span>").addClass("description").text("Choose a stream below.")).append(f); e;e=g||[];c.sort();c.unshift("");F.remove();d.append($("<h2>").text(a)).append(UI.buildUI([{label:"Filter the streams",type:"datalist",datalist:c,pointer:{main:{},index:"stream"},help:"If you type something here, the box below will only show streams with names that contain your text.","function":function(){var a=$(this).val();f.children().each(function(){$(this).hide();$(this).attr("data-stream").indexOf(a)>-1&&$(this).show()})}}]));c.shift();d.append($("<span>").addClass("description").text("Choose a stream below.")).append(f);
for(var h in c){var b=c[h],i="",k=$("<button>").text("Delete").click(function(){var a=$(this).closest("div").attr("data-stream");if(confirm('Are you sure you want to delete the stream "'+a+'"?')){delete mist.data.streams[a];var b={};b.deletestream=[a];mist.send(function(){UI.navto("Streams")},b)}}),j=$("<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"))}), for(var h in c){var b=c[h],j="",k=$("<button>").text("Delete").click(function(){var a=$(this).closest("div").attr("data-stream");if(confirm('Are you sure you want to delete the stream "'+a+'"?')){delete mist.data.streams[a];var b={};b.deletestream=[a];mist.send(function(){UI.navto("Streams")},b)}}),i=$("<button>").text("Settings").click(function(){UI.navto("Edit",$(this).closest("div").attr("data-stream"))}),g=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("div").attr("data-stream"))}),
l=$("<button>").text("Embed").click(function(){UI.navto("Embed",$(this).closest("div").attr("data-stream"))}),n=$("<span>").addClass("image");if(b.indexOf("+")>-1){i=b.split("+");i=mist.data.streams[i[0]].source+i[1];j=k="";n.addClass("wildcard")}else{i=mist.data.streams[b].source;if(e.indexOf(b)>-1){l=g="";n.addClass("folder")}}f.append($("<div>").append($("<span>").addClass("streamname").text(b)).append(n).append($("<span>").addClass("description").text(i)).append($("<span>").addClass("button_container").append(j).append(k).append(g).append(l)).attr("title", l=$("<button>").text("Embed").click(function(){UI.navto("Embed",$(this).closest("div").attr("data-stream"))}),o=$("<span>").addClass("image");if(b.indexOf("+")>-1){j=b.split("+");j=mist.data.streams[j[0]].source+j[1];i=k="";o.addClass("wildcard")}else{j=mist.data.streams[b].source;if(e.indexOf(b)>-1){l=g="";o.addClass("folder")}}f.append($("<div>").append($("<span>").addClass("streamname").text(b)).append(o).append($("<span>").addClass("description").text(j)).append($("<span>").addClass("button_container").append(i).append(k).append(g).append(l)).attr("title",
b).attr("data-stream",b))}break;default:var o=$("<tbody>").append($("<tr>").append("<td>").attr("colspan",6).text("Loading.."));h=$("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Stream name").attr("data-sort-type","string").addClass("sorting-asc")).append($("<th>").text("Source").attr("data-sort-type","string")).append($("<th>").text("Status").attr("data-sort-type","int")).append($("<th>").css("text-align","right").text("Connections").attr("data-sort-type","int")).append($("<th>")).append($("<th>")))).append(o); b).attr("data-stream",b))}break;default:var m=$("<tbody>").append($("<tr>").append("<td>").attr("colspan",6).text("Loading.."));h=$("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Stream name").attr("data-sort-type","string").addClass("sorting-asc")).append($("<th>").text("Source").attr("data-sort-type","string")).append($("<th>").text("Status").attr("data-sort-type","int")).append($("<th>").css("text-align","right").text("Connections").attr("data-sort-type","int")).append($("<th>")).append($("<th>")))).append(m);
d.append(h);h.stupidtable();var m=function(){var a=[],b;for(b in mist.data.active_streams)a.push({streams:[mist.data.active_streams[b]],fields:["clients"],start:-2});mist.send(function(){$.extend(true,z,mist.data.streams);var a=0;o.html("");c.sort();for(var b in c){var d=c[b],g;g=d in mist.data.streams?mist.data.streams[d]:z[d];var f=$("<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(h);h.stupidtable();var n=function(){var a=[],b;for(b in mist.data.active_streams)a.push({streams:[mist.data.active_streams[b]],fields:["clients"],start:-2});mist.send(function(){$.extend(true,y,mist.data.streams);var a=0;m.html("");c.sort();for(var b in c){var d=c[b],g;g=d in mist.data.streams?mist.data.streams[d]:y[d];var e=$("<td>").css("text-align","right").html($("<span>").addClass("description").text("Loading..")),f=0;if(typeof mist.data.totals!="undefined"&&typeof mist.data.totals[d]!=
"undefined"){var w=mist.data.totals[d].all_protocols.clients,e=0;if(w.length){for(a in w)e=e+w[a][1];e=Math.round(e/w.length)}}f.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 h=mist.data.totals[d].all_protocols.clients,f=0;if(h.length){for(a in h)f=f+h[a][1];f=Math.round(f/h.length)}}e.html(UI.format.number(f));if(f==0&&g.online==1)g.online=2;f=$("<td>").css("text-align","right").css("white-space","nowrap");(!("ischild"in g)||!g.ischild)&&f.html($("<button>").text("Settings").click(function(){UI.navto("Edit",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the stream "'+
a+'"?')){delete mist.data.streams[a];var b={};mist.data.LTS?b.deletestream=[a]:b.streams=mist.data.streams;mist.send(function(){UI.navto("Streams")},b)}}));w=$("<span>").text(g.name);g.ischild&&w.css("padding-left","1em");var h=UI.format.status(g),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 z[d]||g.online<0){h.html(""); a+'"?')){delete mist.data.streams[a];var b={};mist.data.LTS?b.deletestream=[a]:b.streams=mist.data.streams;mist.send(function(){UI.navto("Streams")},b)}}));h=$("<span>").text(g.name);g.ischild&&h.css("padding-left","1em");var la=UI.format.status(g),ma=$("<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]||g.online<0){la.html("");
i="";f.html("");ja=""}o.append($("<tr>").data("index",d).html($("<td>").html(w).attr("title",g.name=="..."?"The results were truncated":g.name).addClass("overflow_ellipsis")).append($("<td>").text(g.source).attr("title",g.source).addClass("description").addClass("overflow_ellipsis").css("max-width","20em")).append($("<td>").data("sort-value",g.online).html(h)).append(f).append($("<td>").css("white-space","nowrap").html(i).append(ja)).append(e));a++}},{totals:a,active_streams:true})};if(mist.data.LTS){var r= ma="";e.html("");j=""}m.append($("<tr>").data("index",d).html($("<td>").html(h).attr("title",g.name=="..."?"The results were truncated":g.name).addClass("overflow_ellipsis")).append($("<td>").text(g.source).attr("title",g.source).addClass("description").addClass("overflow_ellipsis").css("max-width","20em")).append($("<td>").data("sort-value",g.online).html(la)).append(e).append($("<td>").css("white-space","nowrap").html(ma).append(j)).append(f));a++}},{totals:a,active_streams:true})};if(mist.data.LTS){var r=
0,p=0;for(e in mist.data.streams){h=mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"];if(!h)break;if(mist.inputMatch(h.source_match,mist.data.streams[e].source)){z[e].source=z[e].source+"*";z[e].filesfound=null;mist.send(function(a,b){var c=b.stream,d=0,g;a:for(g in a.browse.files){var f;for(f in mist.data.capabilities.inputs)if(!(f.indexOf("Buffer")>=0||f.indexOf("Buffer.exe")>=0||f.indexOf("Folder")>=0||f.indexOf("Folder.exe")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[f].source_match, 0,p=0;for(e in mist.data.streams){h=mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"];if(!h)break;if(mist.inputMatch(h.source_match,mist.data.streams[e].source)){y[e].source=y[e].source+"*";y[e].filesfound=null;mist.send(function(a,b){var c=b.stream,d=0,g;a:for(g in a.browse.files){var f;for(f in mist.data.capabilities.inputs)if(!(f.indexOf("Buffer")>=0||f.indexOf("Buffer.exe")>=0||f.indexOf("Folder")>=0||f.indexOf("Folder.exe")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[f].source_match,
"/"+a.browse.files[g])){var e=c+"+"+a.browse.files[g];z[e]=U(e,mist.data.streams[c]);z[e].source=mist.data.streams[c].source+a.browse.files[g];d++;if(d>=500){z[c+"+zzzzzzzzz"]={ischild:true,name:"...",online:-1};break a}}}"files"in a.browse&&a.browse.files.length?z[c].filesfound=true:mist.data.streams[c].filesfound=false;p++;if(r==p){mist.send(function(){m()},{active_streams:true});UI.interval.set(function(){m()},5E3)}},{browse:mist.data.streams[e].source},{stream:e});r++}}if(r==0){mist.send(function(){m()}, "/"+a.browse.files[g])){var e=c+"+"+a.browse.files[g];y[e]=T(e,mist.data.streams[c]);y[e].source=mist.data.streams[c].source+a.browse.files[g];d++;if(d>=500){y[c+"+zzzzzzzzz"]={ischild:true,name:"...",online:-1};break a}}}"files"in a.browse&&a.browse.files.length?y[c].filesfound=true:mist.data.streams[c].filesfound=false;p++;if(r==p){mist.send(function(){n()},{active_streams:true});UI.interval.set(function(){n()},5E3)}},{browse:mist.data.streams[e].source},{stream:e});r++}}if(r==0){mist.send(function(){n()},
{active_streams:true});UI.interval.set(function(){m()},5E3)}}else{mist.send(function(){m()},{active_streams:true});UI.interval.set(function(){m()},5E3)}}};if(mist.data.LTS){var W=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,g=0,f;a:for(f in a.browse.files){var e;for(e in mist.data.capabilities.inputs)if(!(e.indexOf("Buffer")>= {active_streams:true});UI.interval.set(function(){n()},5E3)}}else{mist.send(function(){n()},{active_streams:true});UI.interval.set(function(){n()},5E3)}}};if(mist.data.LTS){var V=0,ia=0,t={},ja=[];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))ja.push(g),mist.send(function(a,b){var d=b.stream,g=0,f;a:for(f in a.browse.files){var e;for(e in mist.data.capabilities.inputs)if(!(e.indexOf("Buffer")>=
0||e.indexOf("Folder")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[e].source_match,"/"+a.browse.files[f])){s[d+"+"+a.browse.files[f]]=true;g++;if(g>=500){s[d+"+zzzzzzzzz"]=true;break a}}}ka++;W==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;z[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)); 0||e.indexOf("Folder")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[e].source_match,"/"+a.browse.files[f])){t[d+"+"+a.browse.files[f]]=true;g++;if(g>=500){t[d+"+zzzzzzzzz"]=true;break a}}}ia++;V==ia&&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){t[mist.data.active_streams[a]]=true;y[mist.data.active_streams[a]]=T(mist.data.active_streams[a],mist.data.streams[b[0]])}}t=Object.keys(t);t=t.concat(Object.keys(mist.data.streams));
s.sort();V(c,s,la)},{active_streams:true})},{browse:mist.data.streams[g].source},{stream:g}),W++;0==W&&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;z[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)); t.sort();U(c,t,ja)},{active_streams:true})},{browse:mist.data.streams[g].source},{stream:g}),V++;0==V&&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){t[mist.data.active_streams[a]]=true;y[mist.data.active_streams[a]]=T(mist.data.active_streams[a],mist.data.streams[b[0]])}}t=Object.keys(t);mist.data.streams&&(t=t.concat(Object.keys(mist.data.streams)));t.sort();U(c,t)},{active_streams:!0})}else U(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}E=!1;""!=c&&(E=!0);E?(j=c,p=mist.data.streams[j],d.find("h2").append(' "'+j+'"')):(d.html($("<h2>").text("New Stream")),p={});j=[];for(o in mist.data.capabilities.inputs)j.push(mist.data.capabilities.inputs[o].source_match);var R=$("<div>"),ma=function(a){var b={};if(!mist.data.streams)mist.data.streams={};mist.data.streams[p.name]=p;c!=p.name&&delete mist.data.streams[c]; break;case "Edit":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});d.append("Loading..");return}E=!1;""!=c&&(E=!0);E?(j=c,p=mist.data.streams[j],d.find("h2").append(' "'+j+'"')):(d.html($("<h2>").text("New Stream")),p={});j=[];for(m in mist.data.capabilities.inputs)j.push(mist.data.capabilities.inputs[m].source_match);var Q=$("<div>"),ka=function(a){var b={};if(!mist.data.streams)mist.data.streams={};mist.data.streams[p.name]=p;c!=p.name&&delete mist.data.streams[c];
b.addstream={};b.addstream[p.name]=p;if(c!=p.name)b.deletestream=[c];if(p.stop_sessions&&c!=""){b.stop_sessions=c;delete p.stop_sessions}mist.send(function(){delete mist.data.streams[p.name].online;delete mist.data.streams[p.name].error;UI.navto(a,a=="Preview"?p.name:"")},b)},na=$("<style>").text("button.saveandpreview { display: none; }"),G=$("<span>"),X=function(){var a=d.find("[name=name]").val();if(a){var b=parseURL(mist.user.host),c=d.find("[name=source]").val(),g=c.match(/@.*/);g&&(g=g[0].substring(1)); b.addstream={};b.addstream[p.name]=p;if(c!=p.name)b.deletestream=[c];if(p.stop_sessions&&c!=""){b.stop_sessions=c;delete p.stop_sessions}mist.send(function(){delete mist.data.streams[p.name].online;delete mist.data.streams[p.name].error;UI.navto(a,a=="Preview"?p.name:"")},b)},na=$("<style>").text("button.saveandpreview { display: none; }"),G=$("<span>"),W=function(){var a=d.find("[name=name]").val();if(a){var b=parseURL(mist.user.host),c=d.find("[name=source]").val(),g=c.match(/@.*/);g&&(g=g[0].substring(1));
var f=c.replace(/(?:.+?):\/\//,""),f=f.split("/"),f=f[0],f=f.split(":"),f=f[0];(c=c.match(/:\d+/))&&(c=c[0]);var e={},h=["RTMP","RTSP","RTMP.exe","RTSP.exe"],i;for(i in h)h[i]in mist.data.capabilities.connectors&&(e[h[i]]=mist.data.capabilities.connectors[h[i]].optional.port["default"]);var h={RTMP:1935,"RTMP.exe":1935,RTSP:554,"RTSP.exe":554,TS:-1,"TS.exe":-1},k;for(k in e){for(i in mist.data.config.protocols){var j=mist.data.config.protocols[i];if(j.connector==k){if("port"in j)e[k]=j.port;break}}e[k]= var f=c.replace(/(?:.+?):\/\//,""),f=f.split("/"),f=f[0],f=f.split(":"),f=f[0];(c=c.match(/:\d+/))&&(c=c[0]);var e={},h=["RTMP","RTSP","RTMP.exe","RTSP.exe"],j;for(j in h)h[j]in mist.data.capabilities.connectors&&(e[h[j]]=mist.data.capabilities.connectors[h[j]].optional.port["default"]);var h={RTMP:1935,"RTMP.exe":1935,RTSP:554,"RTSP.exe":554,TS:-1,"TS.exe":-1},k;for(k in e){for(j in mist.data.config.protocols){var i=mist.data.config.protocols[j];if(i.connector==k){if("port"in i)e[k]=i.port;break}}e[k]=
e[k]==h[k]?"":":"+e[k]}e.TS="";e["TS.exe"]="";G.find(".field").closest("label").hide();for(i in e){var l;k=c?c:e[i];switch(i){case "RTMP":case "RTMP.exe":l="rtmp://"+b.host+k+"/"+(g?g:"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://"+b.host+k+"/"+(a==""?"STREAMNAME":a)+(g?"?pass="+g:"");break;case "TS":case "TS.exe":l="udp://"+ e[k]==h[k]?"":":"+e[k]}e.TS="";e["TS.exe"]="";G.find(".field").closest("label").hide();for(j in e){var l;k=c?c:e[j];switch(j){case "RTMP":case "RTMP.exe":l="rtmp://"+b.host+k+"/"+(g?g:"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://"+b.host+k+"/"+(a==""?"STREAMNAME":a)+(g?"?pass="+g:"");break;case "TS":case "TS.exe":l="udp://"+
(f==""?b.host:f)+k+"/"}G.find(".field."+i.replace(".exe","")).setval(l).closest("label").show()}}},b=$("<div>"),Y={},s=[],oa=$("<div>");for(o in mist.data.capabilities.processes)s.push([o,mist.data.capabilities.processes[o].hrn?mist.data.capabilities.processes[o].hrn:mist.data.capabilities.processes[o].name]);s.length&&(o=[{label:"New process",type:"select",select:s,value:s[0][0],pointer:{main:Y,index:"process"},"function":function(){var a=$(this).getval();if(a!=null){var a=mist.data.capabilities.processes[a], (f==""?b.host:f)+k+"/"}G.find(".field."+j.replace(".exe","")).setval(l).closest("label").show()}}},b=$("<div>"),X={},t=[],oa=$("<div>");for(m in mist.data.capabilities.processes)t.push([m,mist.data.capabilities.processes[m].hrn?mist.data.capabilities.processes[m].hrn:mist.data.capabilities.processes[m].name]);t.length&&(m=[{label:"New process",type:"select",select:t,value:t[0][0],pointer:{main:X,index:"process"},"function":function(){var a=$(this).getval();if(a!=null){var a=mist.data.capabilities.processes[a],
b=[$("<h4>").text(a.name+" Process options")];oa.html(UI.buildUI(b.concat(mist.convertBuildOptions(a,Y))))}}},oa],b.append(UI.buildUI([$("<br>"),$("<h3>").text("Stream processes"),{label:"Stream processes",itemLabel:"stream process",type:"sublist",sublist:o,saveas:Y,pointer:{main:p,index:"processes"}}])));d.append(UI.buildUI([{label:"Stream name",type:"str",validate:["required","streamname"],pointer:{main:p,index:"name"},help:"Set the name this stream will be recognised by for players and/or stream pushing."}, b=[$("<h4>").text(a.name+" Process options")];oa.html(UI.buildUI(b.concat(mist.convertBuildOptions(a,X))))}}},oa],b.append(UI.buildUI([$("<br>"),$("<h3>").text("Stream processes"),{label:"Stream processes",itemLabel:"stream process",type:"sublist",sublist:m,saveas:X,pointer:{main:p,index:"processes"}}])));d.append(UI.buildUI([{label:"Stream name",type:"str",validate:["required","streamname"],pointer:{main:p,index:"name"},help:"Set the name this stream will be recognised by for players and/or stream pushing."},
{label:"Source",type:"browse",filetypes:j,pointer:{main:p,index:"source"},help:"<p> Below is the explanation of the input methods for MistServer. Anything between brackets () will go to default settings if not specified. </p> <table class=valigntop> <tr> <th colspan=3><b>File inputs</b></th> </tr> <tr> <th>File</th> <td> Linux/MacOS:&nbsp;/PATH/FILE<br> Windows:&nbsp;/cygdrive/DRIVE/PATH/FILE </td> <td> For file input please specify the proper path and file.<br> Supported inputs are: DTSC, FLV, MP3. MistServer Pro has TS, MP4, ISMV added as input. </td> </tr> <th> Folder </th> <td> Linux/MacOS:&nbsp;/PATH/<br> Windows:&nbsp;/cygdrive/DRIVE/PATH/ </td> <td class=LTSonly> A folder stream makes all the recognised files in the selected folder available as a stream. </td> </tr> <tr><td colspan=3>&nbsp;</td></tr> <tr> <th colspan=3><b>Push inputs</b></th> </tr> <tr> <th>RTMP</th> <td>push://(IP)(@PASSWORD)</td> <td> IP is white listed IP for pushing towards MistServer, if left empty all are white listed.<br> PASSWORD is the application under which to push to MistServer, if it doesn't match the stream will be rejected. PASSWORD is MistServer Pro only. </td> </tr> <tr> <th>RTSP</th> <td>push://(IP)(@PASSWORD)</td> <td class=LTSonly>IP is white listed IP for pushing towards MistServer, if left empty all are white listed.</td> </tr> <tr> <th>TS</th> <td>tsudp://(IP):PORT(/INTERFACE)</td> <td class=LTSonly> IP is the IP address used to listen for this stream, multi-cast IP range is: 224.0.0.0 - 239.255.255.255. If IP is not set all addresses will listened to.<br> PORT is the port you reserve for this stream on the chosen IP.<br> INTERFACE is the interface used, if left all interfaces will be used. </td> </tr> <tr><td colspan=3>&nbsp;</td></tr> <tr> <th colspan=3><b>Pull inputs</b></th> </tr> <tr> <th>DTSC</th> <td>dtsc://MISTSERVER_IP:PORT/(STREAMNAME)</td> <td>MISTSERVER_IP is the IP of another MistServer to pull from.<br> PORT is the DTSC port of the other MistServer. (default is 4200)<br> STREAMNAME is the name of the target stream on the other MistServer. If left empty, the name of this stream will be used. </td> </tr> <tr> <th>HLS</th> <td>http://URL/TO/STREAM.m3u8</td> <td class=LTSonly>The URL where the HLS stream is available to MistServer.</td> </tr> <tr> <th>RTSP</th> <td>rtsp://(USER:PASSWORD@)IP(:PORT)(/path)</td> <td class=LTSonly> USER:PASSWORD is the account used if authorization is required.<br> IP is the IP address used to pull this stream from.<br> PORT is the port used to connect through.<br> PATH is the path to be used to identify the correct stream. </td> </tr> </table>".replace(/LTSonly/g, {label:"Source",type:"browse",filetypes:j,pointer:{main:p,index:"source"},help:"<p> Below is the explanation of the input methods for MistServer. Anything between brackets () will go to default settings if not specified. </p> <table class=valigntop> <tr> <th colspan=3><b>File inputs</b></th> </tr> <tr> <th>File</th> <td> Linux/MacOS:&nbsp;/PATH/FILE<br> Windows:&nbsp;/cygdrive/DRIVE/PATH/FILE </td> <td> For file input please specify the proper path and file.<br> Supported inputs are: DTSC, FLV, MP3. MistServer Pro has TS, MP4, ISMV added as input. </td> </tr> <th> Folder </th> <td> Linux/MacOS:&nbsp;/PATH/<br> Windows:&nbsp;/cygdrive/DRIVE/PATH/ </td> <td class=LTSonly> A folder stream makes all the recognised files in the selected folder available as a stream. </td> </tr> <tr><td colspan=3>&nbsp;</td></tr> <tr> <th colspan=3><b>Push inputs</b></th> </tr> <tr> <th>RTMP</th> <td>push://(IP)(@PASSWORD)</td> <td> IP is white listed IP for pushing towards MistServer, if left empty all are white listed.<br> PASSWORD is the application under which to push to MistServer, if it doesn't match the stream will be rejected. PASSWORD is MistServer Pro only. </td> </tr> <tr> <th>RTSP</th> <td>push://(IP)(@PASSWORD)</td> <td class=LTSonly>IP is white listed IP for pushing towards MistServer, if left empty all are white listed.</td> </tr> <tr> <th>TS</th> <td>tsudp://(IP):PORT(/INTERFACE)</td> <td class=LTSonly> IP is the IP address used to listen for this stream, multi-cast IP range is: 224.0.0.0 - 239.255.255.255. If IP is not set all addresses will listened to.<br> PORT is the port you reserve for this stream on the chosen IP.<br> INTERFACE is the interface used, if left all interfaces will be used. </td> </tr> <tr><td colspan=3>&nbsp;</td></tr> <tr> <th colspan=3><b>Pull inputs</b></th> </tr> <tr> <th>DTSC</th> <td>dtsc://MISTSERVER_IP:PORT/(STREAMNAME)</td> <td>MISTSERVER_IP is the IP of another MistServer to pull from.<br> PORT is the DTSC port of the other MistServer. (default is 4200)<br> STREAMNAME is the name of the target stream on the other MistServer. If left empty, the name of this stream will be used. </td> </tr> <tr> <th>HLS</th> <td>http://URL/TO/STREAM.m3u8</td> <td class=LTSonly>The URL where the HLS stream is available to MistServer.</td> </tr> <tr> <th>RTSP</th> <td>rtsp://(USER:PASSWORD@)IP(:PORT)(/path)</td> <td class=LTSonly> USER:PASSWORD is the account used if authorization is required.<br> IP is the IP address used to pull this stream from.<br> PORT is the port used to connect through.<br> PATH is the path to be used to identify the correct stream. </td> </tr> </table>".replace(/LTSonly/g,
mist.data.LTS?'""':"LTSonly"),"function":function(){var a=$(this).val();na.remove();G.html("");if(a!=""){var b=null,c;for(c in mist.data.capabilities.inputs)if(typeof mist.data.capabilities.inputs[c].source_match!="undefined"&&mist.inputMatch(mist.data.capabilities.inputs[c].source_match,a)){b=c;break}if(b===null)R.html($("<h3>").text("Unrecognized input").addClass("red")).append($("<span>").text("Please edit the stream source.").addClass("red"));else{b=mist.data.capabilities.inputs[b];R.html($("<h3>").text(b.name+ mist.data.LTS?'""':"LTSonly"),"function":function(){var a=$(this).val();na.remove();G.html("");if(a!=""){var b=null,c;for(c in mist.data.capabilities.inputs)if(typeof mist.data.capabilities.inputs[c].source_match!="undefined"&&mist.inputMatch(mist.data.capabilities.inputs[c].source_match,a)){b=c;break}if(b===null)Q.html($("<h3>").text("Unrecognized input").addClass("red")).append($("<span>").text("Please edit the stream source.").addClass("red"));else{b=mist.data.capabilities.inputs[b];Q.html($("<h3>").text(b.name+
" Input options"));var g=mist.convertBuildOptions(b,p);"always_match"in mist.data.capabilities.inputs[c]&&mist.inputMatch(mist.data.capabilities.inputs[c].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:p,index:"always_on"}});R.append(UI.buildUI(g));if(b.name=="Folder")d.append(na);else if(["Buffer","Buffer.exe","TS","TS.exe"].indexOf(b.name)>-1){c=[$("<br>"),$("<span>").text("Configure your source to push to:")]; " Input options"));var g=mist.convertBuildOptions(b,p);"always_match"in mist.data.capabilities.inputs[c]&&mist.inputMatch(mist.data.capabilities.inputs[c].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:p,index:"always_on"}});Q.append(UI.buildUI(g));if(b.name=="Folder")d.append(na);else if(["Buffer","Buffer.exe","TS","TS.exe"].indexOf(b.name)>-1){c=[$("<br>"),$("<span>").text("Configure your source to push to:")];
switch(b.name){case "Buffer":case "Buffer.exe":c.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"});c.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"});c.push({label:"RTMP stream key",type:"span",clipboard:true,readonly:true,classes:["RTMPkey"],help:"Use this key if your client asks for a stream key"}); switch(b.name){case "Buffer":case "Buffer.exe":c.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"});c.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"});c.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"});
c.push({label:"RTSP",type:"span",clipboard:true,readonly:true,classes:["RTSP"]});break;case "TS":case "TS.exe":a.charAt(0)=="/"?c=[]:c.push({label:"TS",type:"span",clipboard:true,readonly:true,classes:["TS"]})}G.html(UI.buildUI(c));X()}}}}},{label:"Stop sessions",type:"checkbox",help:"When saving these stream settings, kill this stream's current connections.",LTSonly:!0,pointer:{main:p,index:"stop_sessions"}},G,$("<br>"),{type:"custom",custom:R},b,$("<br>"),$("<h3>").text("Encryption"),{type:"help", c.push({label:"RTSP",type:"span",clipboard:true,readonly:true,classes:["RTSP"]});break;case "TS":case "TS.exe":a.charAt(0)=="/"?c=[]:c.push({label:"TS",type:"span",clipboard:true,readonly:true,classes:["TS"]})}G.html(UI.buildUI(c));W()}}}}},{label:"Stop sessions",type:"checkbox",help:"When saving these stream settings, kill this stream's current connections.",LTSonly:!0,pointer:{main:p,index:"stop_sessions"}},G,$("<br>"),{type:"custom",custom:Q},b,$("<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:p,index:"la_url"}},$("<br>"),{label:"Content key",type:"str",LTSonly:!0,pointer:{main:p,index:"contentkey"}},{type:"text",text:" - or - "},{label:"Key ID",type:"str",LTSonly:!0,pointer:{main:p, 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:p,index:"la_url"}},$("<br>"),{label:"Content key",type:"str",LTSonly:!0,pointer:{main:p,index:"contentkey"}},{type:"text",text:" - or - "},{label:"Key ID",type:"str",LTSonly:!0,pointer:{main:p,
index:"keyid"}},{label:"Key seed",type:"str",LTSonly:!0,pointer:{main:p,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(){ma("Preview")},classes:["saveandpreview"]}]}]));d.find("[name=name]").keyup(function(){X()});X();break;case "Preview":""==c&&UI.navto("Streams");b=":8080";for(o in mist.data.config.protocols)if(t= index:"keyid"}},{label:"Key seed",type:"str",LTSonly:!0,pointer:{main:p,index:"keyseed"}},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Streams")}},{type:"save",label:"Save","function":function(){ka("Streams")}},{type:"save",label:"Save and Preview","function":function(){ka("Preview")},classes:["saveandpreview"]}]}]));d.find("[name=name]").keyup(function(){W()});W();break;case "Preview":""==c&&UI.navto("Streams");b=":8080";for(m in mist.data.config.protocols)if(s=
mist.data.config.protocols[o],"HTTP"==t.connector||"HTTP.exe"==t.connector)b=t.port?":"+t.port:":8080";var j=parseURL(mist.user.host),K=j.protocol+j.host+b+"/",J=$("<div>").css({display:"flex","flex-flow":"row wrap","flex-shrink":1,"min-width":"auto"}),j="";-1==c.indexOf("+")&&(j=$("<button>").text("Settings").addClass("settings").click(function(){UI.navto("Edit",c)}));d.html($("<div>").addClass("bigbuttons").append(j).append($("<button>").text("Embed").addClass("embed").click(function(){UI.navto("Embed", mist.data.config.protocols[m],"HTTP"==s.connector||"HTTP.exe"==s.connector)b=s.port?":"+s.port:":8080";var j=parseURL(mist.user.host),J=j.protocol+j.host+b+"/",I=$("<div>").css({display:"flex","flex-flow":"row wrap","flex-shrink":1,"min-width":"auto"}),j="";-1==c.indexOf("+")&&(j=$("<button>").text("Settings").addClass("settings").click(function(){UI.navto("Edit",c)}));d.html($("<div>").addClass("bigbuttons").append(j).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 C=encodeURIComponent(c);o=$("<div>").css("flex-shrink","1").css("min-width","auto").css("max-width","100%");J.append(o);var pa=$("<div>"),N=$("<div>").text("Loading player..").css("max-width","100%").css("flex-shrink","1").css("min-width","auto"),Z=$("<div>").addClass("controls");o.append(N).append(pa).append(Z);$("link#devcss").length|| c)})).append($("<button>").addClass("cancel").addClass("return").text("Return").click(function(){UI.navto("Streams")}))).append($("<h2>").text('Preview of "'+c+'"')).append(I);var C=encodeURIComponent(c);m=$("<div>").css("flex-shrink","1").css("min-width","auto").css("max-width","100%");I.append(m);var pa=$("<div>"),M=$("<div>").text("Loading player..").css("max-width","100%").css("flex-shrink","1").css("min-width","auto"),Y=$("<div>").addClass("controls");m.append(M).append(pa).append(Y);$("link#devcss").length||
d.append($("<link>").attr("rel","stylesheet").attr("type","text/css").attr("href",K+"skins/dev.css").attr("id","devcss"));var qa=function(){pa.text("");var b=document.createElement("script");d.append(b);b.src=K+"player.js";b.onerror=function(){N.html("Failed to load player.js").append($("<button>").text("Reload").css("display","block").click(function(){qa()}))};b.onload=function(){var g=c,f=function(){var a=MistVideoObject.reference;Z.html("");Z.append(a.UI.buildStructure({type:"container",classes:["mistvideo-column"], d.append($("<link>").attr("rel","stylesheet").attr("type","text/css").attr("href",J+"skins/dev.css").attr("id","devcss"));var qa=function(){pa.text("");var b=document.createElement("script");d.append(b);b.src=J+"player.js";b.onerror=function(){M.html("Failed to load player.js").append($("<button>").text("Reload").css("display","block").click(function(){qa()}))};b.onload=function(){var g=c,f=function(){var a=MistVideoObject.reference;Y.html("");Y.append(a.UI.buildStructure({type:"container",classes:["mistvideo-column"],
style:{flexShrink:1},children:[{"if":function(){return this.playerName&&this.source},then:{type:"container",classes:["mistvideo-description"],style:{display:"block"},children:[{type:"playername",style:{display:"inline"}},{type:"text",text:"is playing",style:{margin:"0 0.2em"}},{type:"mimetype"}]}},{type:"decodingIssues",style:{"max-width":"30em","flex-flow":"column nowrap"}},{type:"container",classes:["mistvideo-column","mistvideo-devcontrols"],children:[{type:"text",text:"Player control"},{type:"container", style:{flexShrink:1},children:[{"if":function(){return this.playerName&&this.source},then:{type:"container",classes:["mistvideo-description"],style:{display:"block"},children:[{type:"playername",style:{display:"inline"}},{type:"text",text:"is playing",style:{margin:"0 0.2em"}},{type:"mimetype"}]}},{type:"decodingIssues",style:{"max-width":"30em","flex-flow":"column nowrap"}},{type:"container",classes:["mistvideo-column","mistvideo-devcontrols"],children:[{type:"text",text:"Player control"},{type:"container",
classes:["mistvideo-devbuttons"],style:{"flex-wrap":"wrap"},children:[{"if":function(){return!(!this.player||!this.player.api)},then:{type:"button",title:"Reload the video source",label:"Reload video",onclick:function(){this.player.api.load()}}},{type:"button",title:"Build MistVideo again",label:"Reload player",onclick:function(){this.reload()}},{type:"button",title:"Switch to the next available player and source combination",label:"Try next combination",onclick:function(){this.nextCombo()}}]},{type:"forcePlayer"}, classes:["mistvideo-devbuttons"],style:{"flex-wrap":"wrap"},children:[{"if":function(){return!(!this.player||!this.player.api)},then:{type:"button",title:"Reload the video source",label:"Reload video",onclick:function(){this.player.api.load()}}},{type:"button",title:"Build MistVideo again",label:"Reload player",onclick:function(){this.reload()}},{type:"button",title:"Switch to the next available player and source combination",label:"Try next combination",onclick:function(){this.nextCombo()}}]},{type:"forcePlayer"},
{type:"forceType"},{type:"forceSource"}]},{type:"log"}]}))};if(!(a!="Preview"||!c||c==""||g!=c)){N[0].addEventListener("initialized",f);N[0].addEventListener("initializeFailed",f);MistVideoObject.reference=mistPlay(g,{target:N[0],host:K,skin:"dev",loop:true,MistVideoObject:MistVideoObject})}d[0].removeChild(b)};MistVideoObject.reference={unload:function(){b.onload=function(){this.parentElement&&this.parentElement.removeChild(this)}}}};qa();o=$("<div>").append($("<h3>").text("Meta information"));var S= {type:"forceType"},{type:"forceSource"}]},{type:"log"}]}))};if(!(a!="Preview"||!c||c==""||g!=c)){M[0].addEventListener("initialized",f);M[0].addEventListener("initializeFailed",f);MistVideoObject.reference=mistPlay(g,{target:M[0],host:J,skin:"dev",loop:true,MistVideoObject:MistVideoObject})}d[0].removeChild(b)};MistVideoObject.reference={unload:function(){b.onload=function(){this.parentElement&&this.parentElement.removeChild(this)}}}};qa();m=$("<div>").append($("<h3>").text("Meta information"));var R=
$("<span>").text("Loading..");o.append(S);J.append(o);""!=C&&$.ajax({type:"GET",url:K+"json_"+C+".js",success:function(a){var b=function(a,b){return"maxbps"in a?UI.format.bytes(a[b],1):b=="maxbps"?UI.format.bytes(a.bps,1):"unknown"},c=a.meta;if(!c||!c.tracks)S.html("No meta information available.");else{a=[];a.push({label:"Type",type:"span",value:c.live?"Live":"Pre-recorded (VoD)"});"format"in c&&a.push({label:"Format",type:"span",value:c.format});c.live&&a.push({label:"Buffer window",type:"span", $("<span>").text("Loading..");m.append(R);I.append(m);""!=C&&$.ajax({type:"GET",url:J+"json_"+C+".js",success:function(a){var b=function(a,b){return"maxbps"in a?UI.format.bytes(a[b],1):b=="maxbps"?UI.format.bytes(a.bps,1):"unknown"},c=a.meta;if(!c||!c.tracks)R.html("No meta information available.");else{a=[];a.push({label:"Type",type:"span",value:c.live?"Live":"Pre-recorded (VoD)"});"format"in c&&a.push({label:"Format",type:"span",value:c.format});c.live&&a.push({label:"Buffer window",type:"span",
value:UI.format.addUnit(c.buffer_window,"ms")});var d={audio:{vheader:"Audio",labels:["Codec","Duration","Avg bitrate","Peak bitrate","Channels","Samplerate","Language","Track index"],content:[]},video:{vheader:"Video",labels:["Codec","Duration","Avg bitrate","Peak bitrate","Size","Framerate","Language","Track index","Has B-Frames"],content:[]},subtitle:{vheader:"Subtitles",labels:["Codec","Duration","Avg bitrate","Peak bitrate","Language","Track index"],content:[]}},g=Object.keys(c.tracks);g.sort(function(a, value:UI.format.addUnit(c.buffer_window,"ms")});var d={audio:{vheader:"Audio",labels:["Codec","Duration","Avg bitrate","Peak bitrate","Channels","Samplerate","Language","Track index"],content:[]},video:{vheader:"Video",labels:["Codec","Duration","Avg bitrate","Peak bitrate","Size","Framerate","Language","Track index","Has B-Frames"],content:[]},subtitle:{vheader:"Subtitles",labels:["Codec","Duration","Avg bitrate","Peak bitrate","Language","Track index"],content:[]}},g=Object.keys(c.tracks);g.sort(function(a,
b){a=a.split("_").pop();b=b.split("_").pop();return a-b});var f=1,e=1,i=1,h;for(h in g){var k=g[h],j=c.tracks[k];switch(j.type){case "audio":d.audio.content.push({header:"Track "+k.split("_").pop(),body:[j.codec,UI.format.duration((j.lastms-j.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(j.firstms/1E3)+" to "+UI.format.duration(j.lastms/1E3)+"</span>",b(j,"bps"),b(j,"maxbps"),j.channels,UI.format.addUnit(UI.format.number(j.rate),"Hz"),"language"in j?j.language:"unknown",f]});f++; b){a=a.split("_").pop();b=b.split("_").pop();return a-b});var f=1,e=1,h=1,j;for(j in g){var k=g[j],i=c.tracks[k];switch(i.type){case "audio":d.audio.content.push({header:"Track "+k.split("_").pop(),body:[i.codec,UI.format.duration((i.lastms-i.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(i.firstms/1E3)+" to "+UI.format.duration(i.lastms/1E3)+"</span>",b(i,"bps"),b(i,"maxbps"),i.channels,UI.format.addUnit(UI.format.number(i.rate),"Hz"),"language"in i?i.language:"unknown",f]});f++;
break;case "video":d.video.content.push({header:"Track "+k.split("_").pop(),body:[j.codec,UI.format.duration((j.lastms-j.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(j.firstms/1E3)+" to "+UI.format.duration(j.lastms/1E3)+"</span>",b(j,"bps"),b(j,"maxbps"),UI.format.addUnit(j.width,"x ")+UI.format.addUnit(j.height,"px"),UI.format.addUnit(UI.format.number(j.fpks/1E3),"fps"),"language"in j?j.language:"unknown",e,"bframes"in j?"yes":"no"]});e++;break;case "meta":case "subtitle":if(j.codec== break;case "video":d.video.content.push({header:"Track "+k.split("_").pop(),body:[i.codec,UI.format.duration((i.lastms-i.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(i.firstms/1E3)+" to "+UI.format.duration(i.lastms/1E3)+"</span>",b(i,"bps"),b(i,"maxbps"),UI.format.addUnit(i.width,"x ")+UI.format.addUnit(i.height,"px"),UI.format.addUnit(UI.format.number(i.fpks/1E3),"fps"),"language"in i?i.language:"unknown",e,"bframes"in i?"yes":"no"]});e++;break;case "meta":case "subtitle":if(i.codec==
"subtitle"||j.type=="subtitle"){d.subtitle.content.push({header:"Track "+k.split("_").pop(),body:[j.codec,UI.format.duration((j.lastms-j.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(j.firstms/1E3)+" to "+UI.format.duration(j.lastms/1E3)+"</span>",b(j,"bps"),b(j,"maxbps"),"language"in j?j.language:"unknown",i]});i++}}}b=["audio","video","subtitle"];h=$("<div>").css({display:"flex","flex-flow":"row wrap","font-size":"0.9em"});for(k in b)d[b[k]].content.length&&h.append(UI.buildVheaderTable(d[b[k]]).css("width", "subtitle"||i.type=="subtitle"){d.subtitle.content.push({header:"Track "+k.split("_").pop(),body:[i.codec,UI.format.duration((i.lastms-i.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(i.firstms/1E3)+" to "+UI.format.duration(i.lastms/1E3)+"</span>",b(i,"bps"),b(i,"maxbps"),"language"in i?i.language:"unknown",h]});h++}}}b=["audio","video","subtitle"];j=$("<div>").css({display:"flex","flex-flow":"row wrap","font-size":"0.9em"});for(k in b)d[b[k]].content.length&&j.append(UI.buildVheaderTable(d[b[k]]).css("width",
"auto"));a.push($("<span>").text("Tracks:"));a.push(h);S.html(UI.buildUI(a))}},error:function(){S.html("Error while retrieving stream info.")}});break;case "Embed":""==c&&UI.navTo("Streams");j="";-1==c.indexOf("+")&&(j=$("<button>").addClass("settings").text("Settings").click(function(){UI.navto("Edit",c)}));d.html($("<div>").addClass("bigbuttons").append(j).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 "'+ "auto"));a.push($("<span>").text("Tracks:"));a.push(j);R.html(UI.buildUI(a))}},error:function(){R.html("Error while retrieving stream info.")}});break;case "Embed":""==c&&UI.navTo("Streams");j="";-1==c.indexOf("+")&&(j=$("<button>").addClass("settings").text("Settings").click(function(){UI.navto("Edit",c)}));d.html($("<div>").addClass("bigbuttons").append(j).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 O=$("<span>");d.append(O);C=encodeURIComponent(c);j=parseURL(mist.user.host);b={"":{port:":8080"}};for(o in mist.data.config.protocols){t=mist.data.config.protocols[o];if("HTTP"==t.connector||"HTTP.exe"==t.connector)b[""].port=t.port?":"+t.port:":8080";if("HTTPS"==t.connector||"HTTPS.exe"==t.connector)b.s={},b.s.port=t.port?":"+t.port:":4433"}var H=K="http://"+j.host+b[""].port+"/";if(otherhost.host||otherhost.https)H=(otherhost.https&&"s"in b?"https://":"http://")+(otherhost.host?otherhost.host: c+'"'));var N=$("<span>");d.append(N);C=encodeURIComponent(c);j=parseURL(mist.user.host);b={"":{port:":8080"}};for(m in mist.data.config.protocols){s=mist.data.config.protocols[m];if("HTTP"==s.connector||"HTTP.exe"==s.connector)b[""].port=s.port?":"+s.port:":8080";if("HTTPS"==s.connector||"HTTPS.exe"==s.connector)b.s={},b.s.port=s.port?":"+s.port:":4433"}var H=J="http://"+j.host+b[""].port+"/";if(otherhost.host||otherhost.https)H=(otherhost.https&&"s"in b?"https://":"http://")+(otherhost.host?otherhost.host:
j.host)+(otherhost.https&&"s"in b?b.s.port:b[""].port)+"/";var P=!1,aa={forcePlayer:"",forceType:"",controls:!0,autoplay:!0,loop:!1,muted:!1,fillSpace:!1,poster:"",urlappend:"",setTracks:{}},q=$.extend({},aa);o=UI.stored.getOpts();"embedoptions"in o&&(q=$.extend(q,o.embedoptions,!0),"object"!=typeof q.setTracks&&(q.setTracks={}));o={};switch(q.controls){case "stock":o.controls="stock";break;case !0:o.controls=1;break;case !1:o.controls=0}var x=function(){function a(b){switch(typeof b){case "string":return $.isNumeric(b)? j.host)+(otherhost.https&&"s"in b?b.s.port:b[""].port)+"/";var O=!1,Z={forcePlayer:"",forceType:"",controls:!0,autoplay:!0,loop:!1,muted:!1,fillSpace:!1,poster:"",urlappend:"",setTracks:{}},q=$.extend({},Z);m=UI.stored.getOpts();"embedoptions"in m&&(q=$.extend(q,m.embedoptions,!0),"object"!=typeof q.setTracks&&(q.setTracks={}));m={};switch(q.controls){case "stock":m.controls="stock";break;case !0:m.controls=1;break;case !1:m.controls=0}var w=function(){function a(b){switch(typeof b){case "string":return $.isNumeric(b)?
b:'"'+b+'"';case "object":return JSON.stringify(b);default:return b}}P&&UI.stored.saveOpt("embedoptions",q);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 q)e=="prioritize_type"?q[e]&&q[e]!=""&&d.push("forcePriority: "+JSON.stringify({source:[["type",[q[e]]]]})):e=="monitor_action"?q[e]&&q[e]!=""&&q[e]=="nextCombo"&&d.push('monitor: {\n action: function(){\n this.MistVideo.log("Switching to nextCombo because of poor playback in "+this.MistVideo.source.type+" ("+Math.round(this.vars.score*1000)/10+"%)");\n this.MistVideo.nextCombo();\n }\n }'): b:'"'+b+'"';case "object":return JSON.stringify(b);default:return b}}O&&UI.stored.saveOpt("embedoptions",q);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 q)e=="prioritize_type"?q[e]&&q[e]!=""&&d.push("forcePriority: "+JSON.stringify({source:[["type",[q[e]]]]})):e=="monitor_action"?q[e]&&q[e]!=""&&q[e]=="nextCombo"&&d.push('monitor: {\n action: function(){\n this.MistVideo.log("Switching to nextCombo because of poor playback in "+this.MistVideo.source.type+" ("+Math.round(this.vars.score*1000)/10+"%)");\n this.MistVideo.nextCombo();\n }\n }'):
q[e]!=aa[e]&&(q[e]!=null&&(typeof q[e]!="object"||JSON.stringify(q[e])!=JSON.stringify(aa[e])))&&d.push(e+": "+a(q[e]));e=[];e.push('<div class="mistvideo" id="'+b+'">');e.push(" <noscript>");e.push(' <a href="'+H+C+'.html" target="_blank">');e.push(" Click here to play this video");e.push(" </a>");e.push(" </noscript>");e.push(" <script>");e.push(" var a = function(){");e.push(' mistPlay("'+c+'",{');e.push(" "+d.join(",\n "));e.push(" });");e.push(" };"); q[e]!=Z[e]&&(q[e]!=null&&(typeof q[e]!="object"||JSON.stringify(q[e])!=JSON.stringify(Z[e])))&&d.push(e+": "+a(q[e]));e=[];e.push('<div class="mistvideo" id="'+b+'">');e.push(" <noscript>");e.push(' <a href="'+H+C+'.html" target="_blank">');e.push(" Click here to play this video");e.push(" </a>");e.push(" </noscript>");e.push(" <script>");e.push(" var a = function(){");e.push(' mistPlay("'+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 = "'+H+'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.."),t=x(q),L=$("<div>").text("Loading..").css("display","flex").css("flex-flow","column nowrap"),ra="";"s"in b&&(ra=UI.buildUI([{label:"Use HTTPS",type:"checkbox", e.push(" if (!window.mistplayers) {");e.push(' var p = document.createElement("script");');e.push(' p.src = "'+H+'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")},aa=$("<span>").text("Loading.."),s=w(q),K=$("<div>").text("Loading..").css("display","flex").css("flex-flow","column nowrap"),ra="";"s"in b&&(ra=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"));O.append($("<span>").addClass("input_container").append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Use a different host:")).append($("<span>").addClass("field_container").append($("<input>").attr("type","text").addClass("field").val(otherhost.host?otherhost.host:j.host)).append($("<span>").addClass("unit").append($("<button>").text("Apply").click(function(){otherhost.host= "function":function(){if($(this).getval()!=otherhost.https){otherhost.https=$(this).getval();UI.navto("Embed",c)}},value:otherhost.https}]).find("label"));N.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:j.host)).append($("<span>").addClass("unit").append($("<button>").text("Apply").click(function(){otherhost.host=
$(this).closest("label").find("input").val();UI.navto("Embed",c)}))))).append(ra)).append(UI.buildUI([$("<h3>").text("Urls"),{label:"Stream info json",type:"str",value:H+"json_"+C+".js",readonly:!0,clipboard:!0,help:"Information about this stream as a json page."},{label:"Stream info script",type:"str",value:H+"info_"+C+".js",readonly:!0,clipboard:!0,help:"This script loads information about this stream into a mistvideo javascript object."},{label:"HTML page",type:"str",value:H+C+".html",readonly:!0, $(this).closest("label").find("input").val();UI.navto("Embed",c)}))))).append(ra)).append(UI.buildUI([$("<h3>").text("Urls"),{label:"Stream info json",type:"str",value:H+"json_"+C+".js",readonly:!0,clipboard:!0,help:"Information about this stream as a json page."},{label:"Stream info script",type:"str",value:H+"info_"+C+".js",readonly:!0,clipboard:!0,help:"This script loads information about this stream into a mistvideo javascript object."},{label:"HTML page",type:"str",value:H+C+".html",readonly:!0,
qrcode:!0,clipboard:!0,help:"A basic html containing the embedded stream."},$("<h3>").text("Embed code"),{label:"Embed code",type:"textarea",value:t,rows:t.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."}, qrcode:!0,clipboard:!0,help:"A basic html containing the embedded stream."},$("<h3>").text("Embed code"),{label:"Embed code",type:"textarea",value:s,rows:s.split("\n").length+3,readonly:!0,classes:["embed_code"],clipboard:!0,help:"Include this code on your webpage to embed the stream. The options below can be used to configure how your content is displayed."},$("<h4>").text("Embed code options (optional)").css("margin-top",0),{type:"help",help:"Use these controls to customise what this embedded video will look like.<br>Not all players have all of these options."},
{label:"Prioritize type",type:"select",select:[["","Automatic"]],pointer:{main:q,index:"prioritize_type"},classes:["prioritize_type"],"function":function(){if(P){q.prioritize_type=$(this).getval();$(".embed_code").setval(x(q))}},help:"Try to use this source type first, but full back to something else if it is not available."},{label:"Force type",type:"select",select:[["","Automatic"]],pointer:{main:q,index:"forceType"},classes:["forceType"],"function":function(){if(P){q.forceType=$(this).getval(); {label:"Prioritize type",type:"select",select:[["","Automatic"]],pointer:{main:q,index:"prioritize_type"},classes:["prioritize_type"],"function":function(){if(O){q.prioritize_type=$(this).getval();$(".embed_code").setval(w(q))}},help:"Try to use this source type first, but full back to something else if it is not available."},{label:"Force type",type:"select",select:[["","Automatic"]],pointer:{main:q,index:"forceType"},classes:["forceType"],"function":function(){if(O){q.forceType=$(this).getval();
$(".embed_code").setval(x(q))}},help:"Only use this particular source."},{label:"Force player",type:"select",select:[["","Automatic"]],pointer:{main:q,index:"forcePlayer"},classes:["forcePlayer"],"function":function(){if(P){q.forcePlayer=$(this).getval();$(".embed_code").setval(x(q))}},help:"Only use this particular player."},{label:"Controls",type:"select",select:[["1","MistServer Controls"],["stock","Player controls"],["0","None"]],pointer:{main:o,index:"controls"},"function":function(){q.controls= $(".embed_code").setval(w(q))}},help:"Only use this particular source."},{label:"Force player",type:"select",select:[["","Automatic"]],pointer:{main:q,index:"forcePlayer"},classes:["forcePlayer"],"function":function(){if(O){q.forcePlayer=$(this).getval();$(".embed_code").setval(w(q))}},help:"Only use this particular player."},{label:"Controls",type:"select",select:[["1","MistServer Controls"],["stock","Player controls"],["0","None"]],pointer:{main:m,index:"controls"},"function":function(){q.controls=
$(this).getval()==1;switch($(this).getval()){case 0:q.controls=false;break;case 1:q.controls=true;break;case "stock":q.controls="stock"}$(".embed_code").setval(x(q))},help:"The type of controls that should be shown."},{label:"Autoplay",type:"checkbox",pointer:{main:q,index:"autoplay"},"function":function(){q.autoplay=$(this).getval();$(".embed_code").setval(x(q))},help:"Whether or not the video should play as the page is loaded."},{label:"Loop",type:"checkbox",pointer:{main:q,index:"loop"},"function":function(){q.loop= $(this).getval()==1;switch($(this).getval()){case 0:q.controls=false;break;case 1:q.controls=true;break;case "stock":q.controls="stock"}$(".embed_code").setval(w(q))},help:"The type of controls that should be shown."},{label:"Autoplay",type:"checkbox",pointer:{main:q,index:"autoplay"},"function":function(){q.autoplay=$(this).getval();$(".embed_code").setval(w(q))},help:"Whether or not the video should play as the page is loaded."},{label:"Loop",type:"checkbox",pointer:{main:q,index:"loop"},"function":function(){q.loop=
$(this).getval();$(".embed_code").setval(x(q))},help:"If the video should restart when the end is reached."},{label:"Start muted",type:"checkbox",pointer:{main:q,index:"muted"},"function":function(){q.muted=$(this).getval();$(".embed_code").setval(x(q))},help:"If the video should restart when the end is reached."},{label:"Fill available space",type:"checkbox",pointer:{main:q,index:"fillSpace"},"function":function(){q.fillSpace=$(this).getval();$(".embed_code").setval(x(q))},help:"The video will fit the available space in its container, even if the video stream has a smaller resolution."}, $(this).getval();$(".embed_code").setval(w(q))},help:"If the video should restart when the end is reached."},{label:"Start muted",type:"checkbox",pointer:{main:q,index:"muted"},"function":function(){q.muted=$(this).getval();$(".embed_code").setval(w(q))},help:"If the video should restart when the end is reached."},{label:"Fill available space",type:"checkbox",pointer:{main:q,index:"fillSpace"},"function":function(){q.fillSpace=$(this).getval();$(".embed_code").setval(w(q))},help:"The video will fit the available space in its container, even if the video stream has a smaller resolution."},
{label:"Poster",type:"str",pointer:{main:q,index:"poster"},"function":function(){q.poster=$(this).getval();$(".embed_code").setval(x(q))},help:"URL to an image that is displayed when the video is not playing."},{label:"Video URL addition",type:"str",pointer:{main:q,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(){q.urlappend=$(this).getval();$(".embed_code").setval(x(q))}}, {label:"Poster",type:"str",pointer:{main:q,index:"poster"},"function":function(){q.poster=$(this).getval();$(".embed_code").setval(w(q))},help:"URL to an image that is displayed when the video is not playing."},{label:"Video URL addition",type:"str",pointer:{main:q,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(){q.urlappend=$(this).getval();$(".embed_code").setval(w(q))}},
{label:"Preselect tracks",type:"DOMfield",DOMfield:L,help:"Pre-select these tracks."},{label:"Monitoring action",type:"select",select:[["","Ask the viewer what to do"],["nextCombo","Try the next source / player combination"]],pointer:{main:q,index:"monitor_action"},"function":function(){q.monitor_action=$(this).getval();$(".embed_code").setval(x(q))},help:"What the player should do when playback is poor."},$("<h3>").text("Protocol stream urls"),ba]));$.ajax({type:"GET",url:H+"json_"+C+".js",success:function(a){var b= {label:"Preselect tracks",type:"DOMfield",DOMfield:K,help:"Pre-select these tracks."},{label:"Monitoring action",type:"select",select:[["","Ask the viewer what to do"],["nextCombo","Try the next source / player combination"]],pointer:{main:q,index:"monitor_action"},"function":function(){q.monitor_action=$(this).getval();$(".embed_code").setval(w(q))},help:"What the player should do when playback is poor."},$("<h3>").text("Protocol stream urls"),aa]));$.ajax({type:"GET",url:H+"json_"+C+".js",success:function(a){var b=
[],c=O.find(".field.forceType"),d=O.find(".field.prioritize_type"),g;for(g in a.source){var e=a.source[g],f=UI.humanMime(e.type);b.push({label:f?f+" <span class=description>("+e.type+")</span>":UI.format.capital(e.type),type:"str",value:e.url,readonly:true,qrcode:true,clipboard:true});f=UI.humanMime(e.type);if(c.children('option[value="'+e.type+'"]').length==0){c.append($("<option>").text(f?f+" ("+e.type+")":UI.format.capital(e.type)).val(e.type));d.append($("<option>").text(f?f+" ("+e.type+")":UI.format.capital(e.type)).val(e.type))}}c.val(q.forceType); [],c=N.find(".field.forceType"),d=N.find(".field.prioritize_type"),g;for(g in a.source){var e=a.source[g],f=UI.humanMime(e.type);b.push({label:f?f+" <span class=description>("+e.type+")</span>":UI.format.capital(e.type),type:"str",value:e.url,readonly:true,qrcode:true,clipboard:true});f=UI.humanMime(e.type);if(c.children('option[value="'+e.type+'"]').length==0){c.append($("<option>").text(f?f+" ("+e.type+")":UI.format.capital(e.type)).val(e.type));d.append($("<option>").text(f?f+" ("+e.type+")":UI.format.capital(e.type)).val(e.type))}}c.val(q.forceType);
d.val(q.prioritize_type);ba.html(UI.buildUI(b));L.html("");b={};for(g in a.meta.tracks){c=a.meta.tracks[g];if(c.codec=="subtitle")c.type="subtitle";if(!(c.type!="audio"&&c.type!="video"&&c.type!="subtitle")){c.type in b||(b[c.type]=c.type=="subtitle"?[]:[["","Autoselect "+c.type]]);b[c.type].push([c.trackid,UI.format.capital(c.type)+" track "+(b[c.type].length+(c.type=="subtitle"?1:0))])}}if(Object.keys(b).length){L.closest("label").show();var a=["audio","video","subtitle"],h;for(h in a){g=a[h];if(b[g]&& d.val(q.prioritize_type);aa.html(UI.buildUI(b));K.html("");b={};for(g in a.meta.tracks){c=a.meta.tracks[g];if(c.codec=="subtitle")c.type="subtitle";if(!(c.type!="audio"&&c.type!="video"&&c.type!="subtitle")){c.type in b||(b[c.type]=c.type=="subtitle"?[]:[["","Autoselect "+c.type]]);b[c.type].push([c.trackid,UI.format.capital(c.type)+" track "+(b[c.type].length+(c.type=="subtitle"?1:0))])}}if(Object.keys(b).length){K.closest("label").show();var a=["audio","video","subtitle"],h;for(h in a){g=a[h];if(b[g]&&
b[g].length){c=$("<select>").attr("data-type",g).css("flex-grow","1").change(function(){$(this).val()==""?delete q.setTracks[$(this).attr("data-type")]:q.setTracks[$(this).attr("data-type")]=$(this).val();$(".embed_code").setval(x(q))});L.append(c);g=="subtitle"?b[g].unshift(["","No "+g]):b[g].push([-1,"No "+g]);for(var i in b[g])c.append($("<option>").val(b[g][i][0]).text(b[g][i][1]));if(g in q.setTracks){c.val(q.setTracks[g]);if(c.val()==null){c.val("");delete q.setTracks[g];$(".embed_code").setval(x(q))}}}}}else L.closest("label").hide(); b[g].length){c=$("<select>").attr("data-type",g).css("flex-grow","1").change(function(){$(this).val()==""?delete q.setTracks[$(this).attr("data-type")]:q.setTracks[$(this).attr("data-type")]=$(this).val();$(".embed_code").setval(w(q))});K.append(c);g=="subtitle"?b[g].unshift(["","No "+g]):b[g].push([-1,"No "+g]);for(var i in b[g])c.append($("<option>").val(b[g][i][0]).text(b[g][i][1]));if(g in q.setTracks){c.val(q.setTracks[g]);if(c.val()==null){c.val("");delete q.setTracks[g];$(".embed_code").setval(w(q))}}}}}else K.closest("label").hide();
P=true},error:function(){ba.html("Error while retrieving stream info.");L.closest("label").hide();q.setTracks={}}});o=document.createElement("script");o.src=K+"player.js";document.head.appendChild(o);o.onload=function(){var a=O.find(".field.forcePlayer"),b;for(b in mistplayers)a.append($("<option>").text(mistplayers[b].name).val(b));document.head.removeChild(this)};o.onerror=function(){document.head.removeChild(this)};break;case "Push":var D=$("<div>").text("Loading..");d.append(D);mist.send(function(a){function b(a){setTimeout(function(){mist.send(function(c){var d= O=true},error:function(){aa.html("Error while retrieving stream info.");K.closest("label").hide();q.setTracks={}}});m=document.createElement("script");m.src=J+"player.js";document.head.appendChild(m);m.onload=function(){var a=N.find(".field.forcePlayer"),b;for(b in mistplayers)a.append($("<option>").text(mistplayers[b].name).val(b));document.head.removeChild(this)};m.onerror=function(){document.head.removeChild(this)};break;case "Push":var D=$("<div>").text("Loading..");d.append(D);mist.send(function(a){function b(a){setTimeout(function(){mist.send(function(c){var d=
false;if("push_list"in c&&c.push_list&&c.push_list.length){var d=true,e;for(e in c.push_list)if(a.indexOf(c.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 b()},{push_list:1})},1E3)}function c(e,f){var h=$("<span>");if(f=="Automatic"&&e.length>=4){h.append($("<span>").text(e[2]));e[3]&&h.append($("<span>").text(", schedule on "+(new Date(e[3]*1E3)).toLocaleString()));e.length>=5&&e[4]&&h.append($("<span>").text(", complete on "+(new Date(e[4]* false;if("push_list"in c&&c.push_list&&c.push_list.length){var d=true,e;for(e in c.push_list)if(a.indexOf(c.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 b()},{push_list:1})},1E3)}function c(e,f){var h=$("<span>");if(f=="Automatic"&&e.length>=4){h.append($("<span>").text(e[2]));e[3]&&h.append($("<span>").text(", schedule on "+(new Date(e[3]*1E3)).toLocaleString()));e.length>=5&&e[4]&&h.append($("<span>").text(", complete on "+(new Date(e[4]*
1E3)).toLocaleString()))}else e.length>=4&&e[2]!=e[3]?h.append($("<span>").text(e[2])).append($("<span>").html("&#187").addClass("unit").css("margin","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== 1E3)).toLocaleString()))}else e.length>=4&&e[2]!=e[3]?h.append($("<span>").text(e[2])).append($("<span>").html("&#187").addClass("unit").css("margin","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..")));if(f=="Automatic"){var c=e.slice(1);mist.send(function(){a.remove()},{push_auto_remove:[c]})}else mist.send(function(){b([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"'+e[1]+" to "+e[2]+'"?'+(d.wait!=0?"\n\nRetrying is enabled. You'll probably want to set that to 0.": "Automatic"?"Removing..":"Stopping..")));if(f=="Automatic"){var c=e.slice(1);mist.send(function(){a.remove()},{push_auto_remove:[c]})}else mist.send(function(){b([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"'+e[1]+" to "+e[2]+'"?'+(d.wait!=0?"\n\nRetrying is enabled. You'll probably want to set that to 0.":
@ -175,63 +175,63 @@ unit:"s",type:"int",min:0,help:"How long the delay should be before MistServer r
"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])==-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]));D.append($("<button>").text("Stop all pushes").click(function(){var c= "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])==-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]));D.append($("<button>").text("Stop all pushes").click(function(){var c=
[],d;for(d in a.push_list)c.push(a.push_list[d][0]);if(c.length!=0&&confirm("Are you sure you want to stop all pushes?")){mist.send(function(){b(c)},{push_stop:c});g.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", [],d;for(d in a.push_list)c.push(a.push_list[d][0]);if(c.length!=0&&confirm("Are you sure you want to stop all pushes?")){mist.send(function(){b(c)},{push_stop:c});g.find("tr:not(:first-child)").html($("<td colspan=99>").append($("<span>").addClass("red").text("Stopping..")));$(this).remove()}})).append($("<label>").css("margin-left","1em").append($("<span>").text("Stop all pushes that match: ").css("font-size","0.9em")).append(i).append($("<span>").css("margin-left","0.5em").text("and").css("font-size",
"0.9em")).append(j).append($("<button>").css("margin-left","0.5em").text("Apply").click(function(){var c=i.val(),d=j.val();if(c==""&&d=="")return alert("Looks like you want to stop all pushes. Maybe you should use that button?");var e={},f;for(f in a.push_list)if((c==""||a.push_list[f][1]==c)&&(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.");c="Are you sure you want to stop these pushes?\n\n";for(f in e)c=c+(e[f][1]+ "0.9em")).append(j).append($("<button>").css("margin-left","0.5em").text("Apply").click(function(){var c=i.val(),d=j.val();if(c==""&&d=="")return alert("Looks like you want to stop all pushes. Maybe you should use that button?");var e={},f;for(f in a.push_list)if((c==""||a.push_list[f][1]==c)&&(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.");c="Are you sure you want to stop these pushes?\n\n";for(f in e)c=c+(e[f][1]+
" to "+e[f][2]+"\n");if(confirm(c)){e=Object.keys(e);mist.send(function(){b(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});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 v,T=function(a){var b=false,e=c.split("_"); " to "+e[f][2]+"\n");if(confirm(c)){e=Object.keys(e);mist.send(function(){b(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});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 v,S=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){T(a.push_auto_list[b])},{push_auto_list:1});else{var g=[],f;for(f in mist.data.capabilities.connectors){e=mist.data.capabilities.connectors[f];"push_urls"in e&&(g=g.concat(e.push_urls))}c=="auto"&&d.find("h2").text("Add automatic push");var h={};if(c=="auto"&&typeof a!="undefined"){h={stream:a[0],target:a[1]};if(a.length>=3)h.scheduletime=a[2];if(a.length>=4)h.completetime=a[3];if(h.target.indexOf("recstartunix=")> c=e[0];e.length==2&&(b=e[1]);if(b!==false&&typeof a=="undefined")mist.send(function(a){S(a.push_auto_list[b])},{push_auto_list:1});else{var g=[],f;for(f in mist.data.capabilities.connectors){e=mist.data.capabilities.connectors[f];"push_urls"in e&&(g=g.concat(e.push_urls))}c=="auto"&&d.find("h2").text("Add automatic push");var h={};if(c=="auto"&&typeof a!="undefined"){h={stream:a[0],target:a[1]};if(a.length>=3)h.scheduletime=a[2];if(a.length>=4)h.completetime=a[3];if(h.target.indexOf("recstartunix=")>
-1){f=h.target.split("recstartunix=")[1];h.recstartunix=f.split("&")[0];h.target=h.target.replace("recstartunix="+h.recstartunix,"").replace("?&","?").replace("&&","&");if(h.target[h.target.length-1]=="?")h.target=h.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>", -1){f=h.target.split("recstartunix=")[1];h.recstartunix=f.split("&")[0];h.target=h.target.replace("recstartunix="+h.recstartunix,"").replace("?&","?").replace("&&","&");if(h.target[h.target.length-1]=="?")h.target=h.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:h,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:v,LTSonly:1},{label:"Target",type:"str",help:"Where the stream will be pushed to.<br> Valid formats: <ul> <li>"+g.join("</li><li>")+"</li> </ul> Valid text replacements: <ul> <li>$stream - inserts the stream name used to push to MistServer</li> <li>$day - inserts the current day number</li><li>$month - inserts the current month number</li> <li>$year - inserts the current year number</li><li>$hour - inserts the hour timestamp when stream was received</li> <li>$minute - inserts the minute timestamp the stream was received</li> <li>$seconds - inserts the seconds timestamp when the stream was received</li> <li>$datetime - inserts $year.$month.$day.$hour.$minute.$seconds timestamp when the stream was received</li> </ul> Valid URL parameters: <ul> <li>recstart=123 - media timestamp in milisseconds where the push should start</li> <li>recstop=456 - media timestamp in miliseconds where the push should stop</li> <li>recstartunix=150000000 - unix time in seconds where the push should start. This will override the recstart parameter.</li> <li>recstopunix=150000000 - unix time in seconds where the push should stop. This will override the recstop parameter.</li> </ul>", pointer:{main:h,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:v,LTSonly:1},{label:"Target",type:"str",help:"Where the stream will be pushed to.<br> Valid formats: <ul> <li>"+g.join("</li><li>")+"</li> </ul> Valid text replacements: <ul> <li>$stream - inserts the stream name used to push to MistServer</li> <li>$day - inserts the current day number</li><li>$month - inserts the current month number</li> <li>$year - inserts the current year number</li><li>$hour - inserts the hour timestamp when stream was received</li> <li>$minute - inserts the minute timestamp the stream was received</li> <li>$seconds - inserts the seconds timestamp when the stream was received</li> <li>$datetime - inserts $year.$month.$day.$hour.$minute.$seconds timestamp when the stream was received</li> </ul> Valid URL parameters: <ul> <li>recstart=123 - media timestamp in milisseconds where the push should start</li> <li>recstop=456 - media timestamp in miliseconds where the push should stop</li> <li>recstartunix=150000000 - unix time in seconds where the push should start. This will override the recstart parameter.</li> <li>recstopunix=150000000 - unix time in seconds where the push should stop. This will override the recstop parameter.</li> </ul>",
pointer:{main:h,index:"target"},validate:["required",function(a){for(var b in g)if(mist.inputMatch(g[b],a))return false;return{msg:"Does not match a valid target.<br>Valid formats:<ul><li>"+g.join("</li><li>")+"</li></ul>",classes:["red"]}}],LTSonly:1}];c=="auto"&&f.push($("<h4>").text("Optional parameters"),{type:"unix",label:"Schedule time",min:0,help:"The time where the push will become active. The default is to start immediately.",pointer:{main:h,index:"scheduletime"}},{type:"unix",label:"Recording start time", pointer:{main:h,index:"target"},validate:["required",function(a){for(var b in g)if(mist.inputMatch(g[b],a))return false;return{msg:"Does not match a valid target.<br>Valid formats:<ul><li>"+g.join("</li><li>")+"</li></ul>",classes:["red"]}}],LTSonly:1}];c=="auto"&&f.push($("<h4>").text("Optional parameters"),{type:"unix",label:"Schedule time",min:0,help:"The time where the push will become active. The default is to start immediately.",pointer:{main:h,index:"scheduletime"}},{type:"unix",label:"Recording start time",
min:0,help:"Where in the media buffer the recording will start. Defaults to the most recently received keyframe.<br>Only makes sense for live streams.",pointer:{main:h,index:"recstartunix"}},{type:"unix",label:"Complete time",min:0,help:"The time where the push will stop. Defaults to never stop automatically.<br>Only makes sense for live streams.",pointer:{main:h,index:"completetime"}});f.push({type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Push")}},{type:"save", min:0,help:"Where in the media buffer the recording will start. Defaults to the most recently received keyframe.<br>Only makes sense for live streams.",pointer:{main:h,index:"recstartunix"}},{type:"unix",label:"Complete time",min:0,help:"The time where the push will stop. Defaults to never stop automatically.<br>Only makes sense for live streams.",pointer:{main:h,index:"completetime"}});f.push({type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Push")}},{type:"save",
label:"Save","function":function(){var b={};h.recstartunix?b.recstartunix="recstartunix="+h.recstartunix:h.scheduletime&&(b.recstartunix="recstartunix="+h.scheduletime);delete h.recstartunix;if(Object.keys(b).length){var d="?",e=h.target.split("?");if(e.length>1){var d="&",e=e[e.length-1],e=e.split("&"),g;for(g in e){var f=e[g].split("=")[0];f in b&&delete b[f]}}if(Object.keys(b).length){d=d+Object.values(b).join("&");h.target=h.target+d}}b={};b[c=="auto"?"push_auto_add":"push_start"]=h;if(typeof a!= label:"Save","function":function(){var b={};h.recstartunix?b.recstartunix="recstartunix="+h.recstartunix:h.scheduletime&&(b.recstartunix="recstartunix="+h.scheduletime);delete h.recstartunix;if(Object.keys(b).length){var d="?",e=h.target.split("?");if(e.length>1){var d="&",e=e[e.length-1],e=e.split("&"),g;for(g in e){var f=e[g].split("=")[0];f in b&&delete b[f]}}if(Object.keys(b).length){d=d+Object.values(b).join("&");h.target=h.target+d}}b={};b[c=="auto"?"push_auto_add":"push_start"]=h;if(typeof a!=
"undefined"&&(a[0]!=h.stream||a[1]!=h.target))b.push_auto_remove=[a];mist.send(function(){UI.navto("Push")},b)}}]});d.append(UI.buildUI(f))}};mist.data.LTS?mist.send(function(a){(v=a.active_streams)||(v=[]);var a=[],b;for(b in v)v[b].indexOf("+")!=-1&&a.push(v[b].replace(/\+.*/,"")+"+");v=v.concat(a);var c=0,d=0;for(b in mist.data.streams){v.push(b);if(mist.inputMatch(UI.findInput("Folder").source_match,mist.data.streams[b].source)){v.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")>= "undefined"&&(a[0]!=h.stream||a[1]!=h.target))b.push_auto_remove=[a];mist.send(function(){UI.navto("Push")},b)}}]});d.append(UI.buildUI(f))}};mist.data.LTS?mist.send(function(a){(v=a.active_streams)||(v=[]);var a=[],b;for(b in v)v[b].indexOf("+")!=-1&&a.push(v[b].replace(/\+.*/,"")+"+");v=v.concat(a);var c=0,d=0;for(b in mist.data.streams){v.push(b);if(mist.inputMatch(UI.findInput("Folder").source_match,mist.data.streams[b].source)){v.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")>=0)||mist.inputMatch(mist.data.capabilities.inputs[f].source_match,"/"+a.browse.files[g])&&v.push(e+"+"+a.browse.files[g]);d++;if(c==d){v=v.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();T()}},{browse:mist.data.streams[b].source},{stream:b});c++}}if(c==d){v=v.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();T()}},{active_streams:1}):(v=Object.keys(mist.data.streams),T());break;case "Triggers":if(!("triggers"in 0||(f.indexOf("Folder")>=0||f.indexOf("Buffer.exe")>=0||f.indexOf("Folder.exe")>=0)||mist.inputMatch(mist.data.capabilities.inputs[f].source_match,"/"+a.browse.files[g])&&v.push(e+"+"+a.browse.files[g]);d++;if(c==d){v=v.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();S()}},{browse:mist.data.streams[b].source},{stream:b});c++}}if(c==d){v=v.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();S()}},{active_streams:1}):(v=Object.keys(mist.data.streams),S());break;case "Triggers":if(!("triggers"in
mist.data.config)||!mist.data.config.triggers)mist.data.config.triggers={};A=$("<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","string")).append($("<th>")))).append(A);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); mist.data.config)||!mist.data.config.triggers)mist.data.config.triggers={};A=$("<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","string")).append($("<th>")))).append(A);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;for(o in b)for(j in b[o])t=triggerRewrite(b[o][j]),A.append($("<tr>").attr("data-index",o+","+j).append($("<td>").text(o)).append($("<td>").text("streams"in t?t.streams.join(", "):"")).append($("<td>").text(t.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(","); b.stupidtable();b=mist.data.config.triggers;for(m in b)for(j in b[m])s=triggerRewrite(b[m][j]),A.append($("<tr>").attr("data-index",m+","+j).append($("<td>").text(m)).append($("<td>").text("streams"in s?s.streams.join(", "):"")).append($("<td>").text(s.handler)).append($("<td>").html($("<button>").text("Edit").click(function(){UI.navto("Edit Trigger",$(this).closest("tr").attr("data-index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").attr("data-index").split(",");
if(confirm("Are you sure you want to delete this "+a[0]+" trigger?")){mist.data.config.triggers[a[0]].splice(a[1],1);mist.data.config.triggers[a[0]].length==0&&delete mist.data.config.triggers[a[0]];mist.send(function(){UI.navto("Triggers")},{config:mist.data.config})}}))));break;case "Edit Trigger":if(!("triggers"in mist.data.config)||!mist.data.config.triggers)mist.data.config.triggers={};if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});d.append("Loading.."); if(confirm("Are you sure you want to delete this "+a[0]+" trigger?")){mist.data.config.triggers[a[0]].splice(a[1],1);mist.data.config.triggers[a[0]].length==0&&delete mist.data.config.triggers[a[0]];mist.send(function(){UI.navto("Triggers")},{config:mist.data.config})}}))));break;case "Edit Trigger":if(!("triggers"in mist.data.config)||!mist.data.config.triggers)mist.data.config.triggers={};if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});d.append("Loading..");
return}c?(c=c.split(","),j=triggerRewrite(mist.data.config.triggers[c[0]][c[1]]),p={triggeron:c[0],appliesto:j.streams,url:j.handler,async:j.sync,"default":j["default"],params:j.params}):(d.html($("<h2>").text("New Trigger")),p={});j=[];for(o in mist.data.capabilities.triggers)j.push([o,o+": "+mist.data.capabilities.triggers[o].when]);var ca=$("<div>").addClass("desc"),sa=$("<div>");d.append(UI.buildUI([{label:"Trigger on",pointer:{main:p,index:"triggeron"},help:"For what event this trigger should activate.", return}c?(c=c.split(","),j=triggerRewrite(mist.data.config.triggers[c[0]][c[1]]),p={triggeron:c[0],appliesto:j.streams,url:j.handler,async:j.sync,"default":j["default"],params:j.params}):(d.html($("<h2>").text("New Trigger")),p={});j=[];for(m in mist.data.capabilities.triggers)j.push([m,m+": "+mist.data.capabilities.triggers[m].when]);var ba=$("<div>").addClass("desc"),sa=$("<div>");d.append(UI.buildUI([{label:"Trigger on",pointer:{main:p,index:"triggeron"},help:"For what event this trigger should activate.",
type:"select",select:j,LTSonly:!0,validate:["required"],"function":function(){var a=$(this).getval(),b=mist.data.capabilities.triggers[a];ca.html("");if(b){a=[$("<h4>").text("Trigger properties"),{type:"help",help:'The trigger "<i>'+a+'</i>" has the following properties:'},{type:"span",label:"Triggers",value:b.when,help:"When this trigger is activated"}];b.payload!=""&&a.push({label:"Payload",type:"textarea",value:b.payload,rows:b.payload.split("\n").length,readonly:true,clipboard:true,help:"The information this trigger sends to the handler."}); type:"select",select:j,LTSonly:!0,validate:["required"],"function":function(){var a=$(this).getval(),b=mist.data.capabilities.triggers[a];ba.html("");if(b){a=[$("<h4>").text("Trigger properties"),{type:"help",help:'The trigger "<i>'+a+'</i>" has the following properties:'},{type:"span",label:"Triggers",value:b.when,help:"When this trigger is activated"}];b.payload!=""&&a.push({label:"Payload",type:"textarea",value:b.payload,rows:b.payload.split("\n").length,readonly:true,clipboard:true,help:"The information this trigger sends to the handler."});
a.push({type:"span",label:"Requires response",value:function(a){switch(a){case "ignored":return"No. The trigger will ignore the response of the handler.";case "always":return"Yes. The trigger needs a response to proceed.";case "when-blocking":return"The trigger needs a response to proceed if it is configured to be blocking.";default:return a}}(b.response),help:"Whether this trigger requires a response from the trigger handler"});a.push({type:"span",label:"Response action",value:b.response_action, a.push({type:"span",label:"Requires response",value:function(a){switch(a){case "ignored":return"No. The trigger will ignore the response of the handler.";case "always":return"Yes. The trigger needs a response to proceed.";case "when-blocking":return"The trigger needs a response to proceed if it is configured to be blocking.";default:return a}}(b.response),help:"Whether this trigger requires a response from the trigger handler"});a.push({type:"span",label:"Response action",value:b.response_action,
help:"What this trigger will do with its handler's response"});ca.append(UI.buildUI(a));b.stream_specific?$("[name=appliesto]").closest(".UIelement").show():$("[name=appliesto]").setval([]).closest(".UIelement").hide();if(b.argument){$("[name=params]").closest(".UIelement").show();sa.text(b.argument)}else $("[name=params]").setval("").closest(".UIelement").hide()}}},ca,$("<h4>").text("Trigger settings"),{label:"Applies to",pointer:{main:p,index:"appliesto"},help:"For triggers that can apply to specific streams, this value decides what streams they are triggered for. (none checked = always triggered)", help:"What this trigger will do with its handler's response"});ba.append(UI.buildUI(a));b.stream_specific?$("[name=appliesto]").closest(".UIelement").show():$("[name=appliesto]").setval([]).closest(".UIelement").hide();if(b.argument){$("[name=params]").closest(".UIelement").show();sa.text(b.argument)}else $("[name=params]").setval("").closest(".UIelement").hide()}}},ba,$("<h4>").text("Trigger settings"),{label:"Applies to",pointer:{main:p,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:p,index:"url"},validate:["required"],type:"str",LTSonly:!0},{label:"Blocking",type:"checkbox",help:"If checked, pauses processing and uses the response of the handler. If the response does not start with 1, true, yes or cont, further processing is aborted. If unchecked, processing is never paused and the response is not checked.", type:"checklist",checklist:Object.keys(mist.data.streams),LTSonly:!0},$("<br>"),{label:"Handler (URL or executable)",help:"This can be either an HTTP URL or a full path to an executable.",pointer:{main:p,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:p,index:"async"},LTSonly:!0},{label:"Parameters",type:"str",help:$("<div>").text("The extra data you want this trigger to use.").append(sa),pointer:{main:p,index:"params"},LTSonly:!0},{label:"Default response",type:"str",help:"The default response in case the handler fails or is set to non-blocking.",placeholder:"true",pointer:{main:p,index:"default"},LTSonly:!0},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Triggers")}},{type:"save",label:"Save", pointer:{main:p,index:"async"},LTSonly:!0},{label:"Parameters",type:"str",help:$("<div>").text("The extra data you want this trigger to use.").append(sa),pointer:{main:p,index:"params"},LTSonly:!0},{label:"Default response",type:"str",help:"The default response in case the handler fails or is set to non-blocking.",placeholder:"true",pointer:{main:p,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:p.url,sync:p.async?true:false,streams:typeof p.appliesto=="undefined"?[]:p.appliesto,params:p.params,"default":p["default"]};if(!("triggers"in mist.data.config))mist.data.config.triggers={};p.triggeron in mist.data.config.triggers||(mist.data.config.triggers[p.triggeron]=[]);mist.data.config.triggers[p.triggeron].push(a);mist.send(function(){UI.navto("Triggers")},{config:mist.data.config})}}]}]));$("[name=triggeron]").trigger("change"); "function":function(){c&&mist.data.config.triggers[c[0]].splice(c[1],1);var a={handler:p.url,sync:p.async?true:false,streams:typeof p.appliesto=="undefined"?[]:p.appliesto,params:p.params,"default":p["default"]};if(!("triggers"in mist.data.config))mist.data.config.triggers={};p.triggeron in mist.data.config.triggers||(mist.data.config.triggers[p.triggeron]=[]);mist.data.config.triggers[p.triggeron].push(a);mist.send(function(){UI.navto("Triggers")},{config:mist.data.config})}}]}]));$("[name=triggeron]").trigger("change");
break;case "Logs":var ta=$("<button>").text("Refresh now").click(function(){$(this).text("Loading..");mist.send(function(){da();ta.text("Refresh now")})}).css("padding","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, break;case "Logs":var ta=$("<button>").text("Refresh now").click(function(){$(this).text("Loading..");mist.send(function(){ca();ta.text("Refresh now")})}).css("padding","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."},{label:"..or",type:"DOMfield",DOMfield:ta,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})}));A=$("<tbody>").css("font-size","0.9em");d.append($("<table>").addClass("logs").append(A)); "minute"],[300,"5 minutes"]],value:30,"function":function(){UI.interval.clear();UI.interval.set(function(){mist.send(function(){ca()})},$(this).val()*1E3)},help:"How often the table below should be updated."},{label:"..or",type:"DOMfield",DOMfield:ta,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})}));A=$("<tbody>").css("font-size","0.9em");d.append($("<table>").addClass("logs").append(A));
var va=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-1][0]&&a.reverse();A.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]));A.append($("<tr>").html($("<td>").text(UI.format.dateTime(a[b][0],"long")).css("white-space","nowrap")).append($("<td>").html(va(a[b][1])).css("text-align", var va=function(a){var b=$("<span>").text(a);switch(a){case "WARN":b.addClass("orange");break;case "ERROR":case "FAIL":b.addClass("red")}return b},ca=function(){var a=mist.data.log;if(a){a.length>=2&&a[0][0]<a[a.length-1][0]&&a.reverse();A.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]));A.append($("<tr>").html($("<td>").text(UI.format.dateTime(a[b][0],"long")).css("white-space","nowrap")).append($("<td>").html(va(a[b][1])).css("text-align",
"center")).append($("<td>").html(c).css("text-align","left")))}}};da();break;case "Statistics":var B=$("<span>").text("Loading..");d.append(B);var p={graph:"new"},y=mist.stored.get().graphs?$.extend(!0,{},mist.stored.get().graphs):{},Q={};for(o in mist.data.streams)Q[o]=!0;for(o in mist.data.active_streams)Q[mist.data.active_streams[o]]=!0;var Q=Object.keys(Q).sort(),ea=[];for(o in mist.data.config.protocols)ea.push(mist.data.config.protocols[o].connector);ea.sort();mist.send(function(){UI.plot.datatype.templates.cpuload.cores= "center")).append($("<td>").html(c).css("text-align","left")))}}};ca();break;case "Statistics":var B=$("<span>").text("Loading..");d.append(B);var p={graph:"new"},x=mist.stored.get().graphs?$.extend(!0,{},mist.stored.get().graphs):{},P={};for(m in mist.data.streams)P[m]=!0;for(m in mist.data.active_streams)P[mist.data.active_streams[m]]=!0;var P=Object.keys(P).sort(),da=[];for(m in mist.data.config.protocols)da.push(mist.data.config.protocols[m].connector);da.sort();mist.send(function(){UI.plot.datatype.templates.cpuload.cores=
0;for(var a in mist.data.capabilities.cpu)UI.plot.datatype.templates.cpuload.cores=UI.plot.datatype.templates.cpuload.cores+mist.data.capabilities.cpu[a].cores;B.html(UI.buildUI([{type:"help",help:"Here you will find the MistServer stream statistics, you can select various categories yourself. All statistics are live: up to five minutes are saved."},$("<h3>").text("Select the data to display"),{label:"Add to",type:"select",select:[["new","New graph"]],pointer:{main:p,index:"graph"},classes:["graph_ids"], 0;for(var a in mist.data.capabilities.cpu)UI.plot.datatype.templates.cpuload.cores=UI.plot.datatype.templates.cpuload.cores+mist.data.capabilities.cpu[a].cores;B.html(UI.buildUI([{type:"help",help:"Here you will find the MistServer stream statistics, you can select various categories yourself. All statistics are live: up to five minutes are saved."},$("<h3>").text("Select the data to display"),{label:"Add to",type:"select",select:[["new","New graph"]],pointer:{main:p,index:"graph"},classes:["graph_ids"],
"function":function(){if($(this).val()){var a=B.find(".graph_xaxis"),b=B.find(".graph_id");if($(this).val()=="new"){a.children("option").prop("disabled",false);b.setval("Graph "+(Object.keys(y).length+1)).closest("label").show()}else{var c=y[$(this).val()].xaxis;a.children("option").prop("disabled",true).filter('[value="'+c+'"]').prop("disabled",false);b.closest("label").hide()}a.children('option[value="'+a.val()+'"]:disabled').length&&a.val(a.children("option:enabled").first().val());a.trigger("change")}}}, "function":function(){if($(this).val()){var a=B.find(".graph_xaxis"),b=B.find(".graph_id");if($(this).val()=="new"){a.children("option").prop("disabled",false);b.setval("Graph "+(Object.keys(x).length+1)).closest("label").show()}else{var c=x[$(this).val()].xaxis;a.children("option").prop("disabled",true).filter('[value="'+c+'"]').prop("disabled",false);b.closest("label").hide()}a.children('option[value="'+a.val()+'"]:disabled').length&&a.val(a.children("option:enabled").first().val());a.trigger("change")}}},
{label:"Graph id",type:"str",pointer:{main:p,index:"id"},classes:["graph_id"],validate:[function(a){return a in y?{msg:"This graph id has already been used. Please enter something else.",classes:["red"]}:false}]},{label:"Axis type",type:"select",select:[["time","Time line"]],pointer:{main:p,index:"xaxis"},value:"time",classes:["graph_xaxis"],"function":function(){$s=B.find(".graph_datatype");switch($(this).getval()){case "coords":$s.children("option").prop("disabled",true).filter('[value="coords"]').prop("disabled", {label:"Graph id",type:"str",pointer:{main:p,index:"id"},classes:["graph_id"],validate:[function(a){return a in x?{msg:"This graph id has already been used. Please enter something else.",classes:["red"]}:false}]},{label:"Axis type",type:"select",select:[["time","Time line"]],pointer:{main:p,index:"xaxis"},value:"time",classes:["graph_xaxis"],"function":function(){$s=B.find(".graph_datatype");switch($(this).getval()){case "coords":$s.children("option").prop("disabled",true).filter('[value="coords"]').prop("disabled",
false);break;case "time":$s.children("option").prop("disabled",false).filter('[value="coords"]').prop("disabled",true)}if(!$s.val()||$s.children('option[value="'+$s.val()+'"]:disabled').length){$s.val($s.children("option:enabled").first().val());$s.trigger("change")}}},{label:"Data type",type:"select",select:[["clients","Connections"],["upbps","Bandwidth (up)"],["downbps","Bandwidth (down)"],["cpuload","CPU use"],["memload","Memory load"],["coords","Client location"]],pointer:{main:p,index:"datatype"}, false);break;case "time":$s.children("option").prop("disabled",false).filter('[value="coords"]').prop("disabled",true)}if(!$s.val()||$s.children('option[value="'+$s.val()+'"]:disabled').length){$s.val($s.children("option:enabled").first().val());$s.trigger("change")}}},{label:"Data type",type:"select",select:[["clients","Connections"],["upbps","Bandwidth (up)"],["downbps","Bandwidth (down)"],["cpuload","CPU use"],["memload","Memory load"],["coords","Client location"]],pointer:{main:p,index:"datatype"},
classes:["graph_datatype"],"function":function(){$s=B.find(".graph_origin");switch($(this).getval()){case "cpuload":case "memload":$s.find("input[type=radio]").not('[value="total"]').prop("disabled",true);$s.find('input[type=radio][value="total"]').prop("checked",true);break;default:$s.find("input[type=radio]").prop("disabled",false)}}},{label:"Data origin",type:"radioselect",radioselect:[["total","All"],["stream","The stream:",Q],["protocol","The protocol:",ea]],pointer:{main:p,index:"origin"},value:["total"], classes:["graph_datatype"],"function":function(){$s=B.find(".graph_origin");switch($(this).getval()){case "cpuload":case "memload":$s.find("input[type=radio]").not('[value="total"]').prop("disabled",true);$s.find('input[type=radio][value="total"]').prop("checked",true);break;default:$s.find("input[type=radio]").prop("disabled",false)}}},{label:"Data origin",type:"radioselect",radioselect:[["total","All"],["stream","The stream:",P],["protocol","The protocol:",da]],pointer:{main:p,index:"origin"},value:["total"],
classes:["graph_origin"]},{type:"buttons",buttons:[{label:"Add data set",type:"save","function":function(){var a;if(p.graph=="new"){a=UI.plot.addGraph(p,b);y[a.id]=a;B.find("input.graph_id").val("");B.find("select.graph_ids").append($("<option>").text(a.id)).val(a.id).trigger("change")}else a=y[p.graph];var c=UI.plot.datatype.getOptions({datatype:p.datatype,origin:p.origin});a.datasets.push(c);UI.plot.save(a);UI.plot.go(y)}}]}]));var b=$("<div>").addClass("graph_container");d.append(b);var c=B.find("select.graph_ids"); classes:["graph_origin"]},{type:"buttons",buttons:[{label:"Add data set",type:"save","function":function(){var a;if(p.graph=="new"){a=UI.plot.addGraph(p,b);x[a.id]=a;B.find("input.graph_id").val("");B.find("select.graph_ids").append($("<option>").text(a.id)).val(a.id).trigger("change")}else a=x[p.graph];var c=UI.plot.datatype.getOptions({datatype:p.datatype,origin:p.origin});a.datasets.push(c);UI.plot.save(a);UI.plot.go(x)}}]}]));var b=$("<div>").addClass("graph_container");d.append(b);var c=B.find("select.graph_ids");
for(a in y){var e=UI.plot.addGraph(y[a],b);c.append($("<option>").text(e.id)).val(e.id);var g=[],f;for(f in y[a].datasets){var h=UI.plot.datatype.getOptions({datatype:y[a].datasets[f].datatype,origin:y[a].datasets[f].origin});g.push(h)}e.datasets=g;y[e.id]=e}c.trigger("change");UI.plot.go(y);UI.interval.set(function(){UI.plot.go(y)},1E4)},{active_streams:!0,capabilities:!0});break;case "Server Stats":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0}); for(a in x){var e=UI.plot.addGraph(x[a],b);c.append($("<option>").text(e.id)).val(e.id);var g=[],f;for(f in x[a].datasets){var h=UI.plot.datatype.getOptions({datatype:x[a].datasets[f].datatype,origin:x[a].datasets[f].origin});g.push(h)}e.datasets=g;x[e.id]=e}c.trigger("change");UI.plot.go(x);UI.interval.set(function(){UI.plot.go(x)},1E4)},{active_streams:!0,capabilities:!0});break;case "Server Stats":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});
d.append("Loading..");return}var fa=$("<table>"),F=$("<table>"),j={vheader:"CPUs",labels:["Model","Processor speed","Amount of cores","Amount of threads"],content:[]};for(o in mist.data.capabilities.cpu)b=mist.data.capabilities.cpu[o],j.content.push({header:"CPU #"+(Number(o)+1),body:[b.model,UI.format.addUnit(UI.format.number(b.mhz),"MHz"),b.cores,b.threads]});o=UI.buildVheaderTable(j);var ua=function(){var a=mist.data.capabilities.mem,b=mist.data.capabilities.load,a={vheader:"Memory",labels:["Used", d.append("Loading..");return}var ea=$("<table>"),F=$("<table>"),j={vheader:"CPUs",labels:["Model","Processor speed","Amount of cores","Amount of threads"],content:[]};for(m in mist.data.capabilities.cpu)b=mist.data.capabilities.cpu[m],j.content.push({header:"CPU #"+(Number(m)+1),body:[b.model,UI.format.addUnit(UI.format.number(b.mhz),"MHz"),b.cores,b.threads]});m=UI.buildVheaderTable(j);var ua=function(){var a=mist.data.capabilities.mem,b=mist.data.capabilities.load,a={vheader:"Memory",labels:["Used",
"Cached","Available","Total"],content:[{header:"Physical memory",body:[UI.format.bytes(a.used*1048576)+" ("+UI.format.addUnit(b.memory,"%")+")",UI.format.bytes(a.cached*1048576),UI.format.bytes(a.free*1048576),UI.format.bytes(a.total*1048576)]},{header:"Swap memory",body:[UI.format.bytes((a.swaptotal-a.swapfree)*1048576),UI.format.addUnit("","N/A"),UI.format.bytes(a.swapfree*1048576),UI.format.bytes(a.swaptotal*1048576)]}]},a=UI.buildVheaderTable(a);fa.replaceWith(a);fa=a;b={vheader:"Load average", "Cached","Available","Total"],content:[{header:"Physical memory",body:[UI.format.bytes(a.used*1048576)+" ("+UI.format.addUnit(b.memory,"%")+")",UI.format.bytes(a.cached*1048576),UI.format.bytes(a.free*1048576),UI.format.bytes(a.total*1048576)]},{header:"Swap memory",body:[UI.format.bytes((a.swaptotal-a.swapfree)*1048576),UI.format.addUnit("","N/A"),UI.format.bytes(a.swapfree*1048576),UI.format.bytes(a.swaptotal*1048576)]}]},a=UI.buildVheaderTable(a);ea.replaceWith(a);ea=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);F.replaceWith(b);F=b};ua();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", 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);F.replaceWith(b);F=b};ua();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(F))).append($("<tr>").append($("<td>").append(o).attr("colspan",2))));UI.interval.set(function(){mist.send(function(){ua()},{capabilities:true})},3E4);break;case "Email for Help":o=$.extend({},mist.data);delete o.statistics;delete o.totals;delete o.clients;delete o.capabilities;o=JSON.stringify(o);o="Version: "+mist.data.config.version+"\n\nConfig:\n"+o;p={};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."}, "auto").addClass("nolay").append($("<tr>").append($("<td>").append(ea)).append($("<td>").append(F))).append($("<tr>").append($("<td>").append(m).attr("colspan",2))));UI.interval.set(function(){mist.send(function(){ua()},{capabilities:true})},3E4);break;case "Email for Help":m=$.extend({},mist.data);delete m.statistics;delete m.totals;delete m.clients;delete m.capabilities;m=JSON.stringify(m);m="Version: "+mist.data.config.version+"\n\nConfig:\n"+m;p={};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:p,index:"name"},value:mist.user.name},{type:"email",label:"Your email address",validate:["required"],pointer:{main:p,index:"email"}},{type:"hidden",value:"Integrated Help",pointer:{main:p,index:"subject"}},{type:"hidden",value:"-",pointer:{main:p,index:"company"}},{type:"textarea",rows:20,label:"Your message",validate:["required"],pointer:{main:p,index:"message"}},{type:"textarea",rows:20,label:"Your config file",readonly:!0,value:o, {type:"str",label:"Your name",validate:["required"],pointer:{main:p,index:"name"},value:mist.user.name},{type:"email",label:"Your email address",validate:["required"],pointer:{main:p,index:"email"}},{type:"hidden",value:"Integrated Help",pointer:{main:p,index:"subject"}},{type:"hidden",value:"-",pointer:{main:p,index:"company"}},{type:"textarea",rows:20,label:"Your message",validate:["required"],pointer:{main:p,index:"message"}},{type:"textarea",rows:20,label:"Your config file",readonly:!0,value:m,
pointer:{main:p,index:"configfile"}},{type:"buttons",buttons:[{type:"save",label:"Send","function":function(a){$(a).text("Sending..");$.ajax({type:"POST",url:"https://mistserver.org/contact?skin=plain",data:p,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= pointer:{main:p,index:"configfile"}},{type:"buttons",buttons:[{type:"save",label:"Send","function":function(a){$(a).text("Sending..");$.ajax({type:"POST",url:"https://mistserver.org/contact?skin=plain",data:p,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)):a=$(this).find("input, select, textarea");if(a.length){$(a[0]).focus();return false}})}};"origin"in location||(location.origin=location.protocol+"//");var host;host="file://"==location.origin?"http://localhost:4242/api":location.origin+location.pathname.replace(/\/+$/,"")+"/api"; $(this).getval();return a==""||a==null?true:false}).each(function(){var a=[];$(this).is("input, select, textarea")?a.push($(this)):a=$(this).find("input, select, textarea");if(a.length){$(a[0]).focus();return false}})}};"origin"in location||(location.origin=location.protocol+"//");var host;host="file://"==location.origin?"http://localhost:4242/api":location.origin+location.pathname.replace(/\/+$/,"")+"/api";
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));var h={url:mist.user.host,type:"POST",data:{command:JSON.stringify(b)},dataType:"jsonp",crossDomain:true,timeout:d.timeout*1E3,async:true,error:function(b,f,h){console.warn("connection failed :(", 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));var f={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,f){console.warn("connection failed :(",
h);delete mist.user.loggedin;if(!d.hide){switch(f){case "timeout":f=$("<i>").text("The connection timed out. ");break;case "abort":f=$("<i>").text("The connection was aborted. ");break;default:f=$("<i>").text(f+". ").css("text-transform","capitalize")}$("#message").addClass("red").text("An error occurred while attempting to communicate with MistServer:").append($("<br>")).append($("<span>").text(f)).append($("<a>").text("Send server request again").click(function(){mist.send(a,c,d)}))}UI.navto("Login")}, f);delete mist.user.loggedin;if(!d.hide){switch(e){case "timeout":e=$("<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($("<span>").text(e)).append($("<a>").text("Send server request again").click(function(){mist.send(a,c,d)}))}UI.navto("Login")},
success:function(h){log("Receive",$.extend(true,{},h),"as reply to",d.sendData);delete mist.user.loggedin;switch(h.authorize.status){case "OK":if("streams"in h)if(h.streams)if("incomplete list"in h.streams){delete h.streams["incomplete list"];$.extend(mist.data.streams,h.streams)}else mist.data.streams=h.streams;else mist.data.streams={};var f=$.extend({},h),m=["config","capabilities","ui_settings","LTS","active_streams","browse","log","totals","bandwidth"],j;for(j in f)m.indexOf(j)==-1&&delete f[j]; success:function(f){log("Receive",$.extend(true,{},f),"as reply to",d.sendData);delete mist.user.loggedin;switch(f.authorize.status){case "OK":if("streams"in f)if(f.streams)if("incomplete list"in f.streams){delete f.streams["incomplete list"];$.extend(mist.data.streams,f.streams)}else mist.data.streams=f.streams;else mist.data.streams={};var e=$.extend({},f),n=["config","capabilities","ui_settings","LTS","active_streams","browse","log","totals","bandwidth"],j;for(j in e)n.indexOf(j)==-1&&delete e[j];
if("bandwidth"in b&&!("bandwidth"in h))f.bandwidth=null;$.extend(mist.data,f);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));h.LTS&&UI.elements.menu.find(".LTSonly").removeClass("LTSonly");if(h.log){f=h.log[h.log.length-1];UI.elements.connection.msg.append($("<br>")).append($("<span>").text("Last log entry: "+ if("bandwidth"in b&&!("bandwidth"in f))e.bandwidth=null;$.extend(mist.data,e);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));f.LTS&&UI.elements.menu.find(".LTSonly").removeClass("LTSonly");if(f.log){e=f.log[f.log.length-1];UI.elements.connection.msg.append($("<br>")).append($("<span>").text("Last log entry: "+
UI.format.time(f[0])+" ["+f[1]+"] "+f[2]))}if("totals"in h){f=function(a,b,c){var d;d=function(){for(var a in c.fields)f[c.fields[a]].push([i,0])};var f={},h;for(h in c.fields)f[c.fields[h]]=[];var j=0,i;if(c.data){if(c.start>mist.data.config.time-600){i=(mist.data.config.time-600)*1E3;d();i=c.start*1E3;d()}else i=c.start*1E3;for(h in c.data){if(h==0){i=c.start*1E3;var m=0}else{i=i+c.interval[m][1]*1E3;c.interval[m][0]--;if(c.interval[m][0]<=0){m++;m<c.interval.length-1&&(j=j+2)}}if(j%2==1){d();j--}for(var r in c.data[h])f[c.fields[r]].push([i, UI.format.time(e[0])+" ["+e[1]+"] "+e[2]))}if("totals"in f){e=function(a,b,c){var d;d=function(){for(var a in c.fields)e[c.fields[a]].push([m,0])};var e={},f;for(f in c.fields)e[c.fields[f]]=[];var j=0,m;if(c.data){if(c.start>mist.data.config.time-600){m=(mist.data.config.time-600)*1E3;d();m=c.start*1E3;d()}else m=c.start*1E3;for(f in c.data){if(f==0){m=c.start*1E3;var n=0}else{m=m+c.interval[n][1]*1E3;c.interval[n][0]--;if(c.interval[n][0]<=0){n++;n<c.interval.length-1&&(j=j+2)}}if(j%2==1){d();j--}for(var o in c.data[f])e[c.fields[o]].push([m,
c.data[h][r]]);if(j){d();j--}}if(mist.data.config.time-c.end>20){d();i=(mist.data.config.time-15)*1E3;d()}}else{i=(mist.data.config.time-600)*1E3;d();i=(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 h.totals)f(c.totals.streams, c.data[f][o]]);if(j){d();j--}}if(mist.data.config.time-c.end>20){d();m=(mist.data.config.time-15)*1E3;d()}}else{m=(mist.data.config.time-600)*1E3;d();m=(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 f.totals)e(c.totals.streams,
c.totals.protocols,h.totals);else for(j in h.totals)f(c.totals[j].streams,c.totals[j].protocols,h.totals[j])}a&&a(h,d);break;case "CHALL":if(h.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=h.authorize.challenge;mist.send(a,c,d);sessionStorage.setItem("mistLogin",JSON.stringify({host:mist.user.host, c.totals.protocols,f.totals);else for(j in f.totals)e(c.totals[j].streams,c.totals[j].protocols,f.totals[j])}a&&a(f,d);break;case "CHALL":if(f.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=f.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(){m.abort()}));var m=$.ajax(h)},inputMatch:function(a,c){if(typeof a=="undefined")return false;typeof a=="string"&&(a=[a]);for(var d in a){var b= 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(){n.abort()}));var n=$.ajax(f)},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){function d(a,b,d){var e={label:UI.format.capital(d.name?d.name:b),pointer:{main:c,index:b},validate:[]};h[a]=="required"&&(!("default"in d)||d["default"]=="")&&e.validate.push("required");if("default"in d){e.placeholder=d["default"];if(d.type=="select")for(var f in d.select)if(d.select[f][0]==d["default"]){e.placeholder= 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){function d(a,b,d){var e={label:UI.format.capital(d.name?d.name:b),pointer:{main:c,index:b},validate:[]};f[a]=="required"&&(!("default"in d)||d["default"]=="")&&e.validate.push("required");if("default"in d){e.placeholder=d["default"];if(d.type=="select")for(var j in d.select)if(d.select[j][0]==d["default"]){e.placeholder=
d.select[f][1];break}}if("help"in d)e.help=d.help;if("unit"in d)e.unit=d.unit;if("placeholder"in d)e.placeholder=d.placeholder;if("type"in d)switch(d.type){case "int":e.type="int";if("max"in d)e.max=d.max;if("min"in d)e.min=d.min;break;case "uint":e.type="int";e.min=0;if("max"in d)e.max=d.max;if("min"in d)e.min=Math.max(e.min,d.min);break;case "debug":e.type="debug";break;case "radioselect":e.type="radioselect";e.radioselect=d.radioselect;break;case "select":e.type="select";e.select=d.select.slice(0); d.select[j][1];break}}if("help"in d)e.help=d.help;if("unit"in d)e.unit=d.unit;if("placeholder"in d)e.placeholder=d.placeholder;if("type"in d)switch(d.type){case "int":e.type="int";if("max"in d)e.max=d.max;if("min"in d)e.min=d.min;break;case "uint":e.type="int";e.min=0;if("max"in d)e.max=d.max;if("min"in d)e.min=Math.max(e.min,d.min);break;case "debug":e.type="debug";break;case "radioselect":e.type="radioselect";e.radioselect=d.radioselect;break;case "select":e.type="select";e.select=d.select.slice(0);
e.validate.indexOf("required")>=0&&e.select.unshift(["","placeholder"in e?"Default ("+e.placeholder+")":""]);break;case "sublist":e.type="sublist";e.saveas={};e.itemLabel=d.itemLabel;e.sublist=mist.convertBuildOptions(d,e.saveas);break;default:e.type="str"}else e.type="checkbox";"influences"in d&&(e["function"]=function(){var a=$(this).closest(".UIelement"),c=a.find("style");if(c.length)c=c[0];else{c=$("<style>").addClass("dependencies")[0];a.append(c)}c.innerHTML=".UIelement[data-dependent-"+b+"]:not([data-dependent-"+ e.validate.indexOf("required")>=0&&e.select.unshift(["","placeholder"in e?"Default ("+e.placeholder+")":""]);break;case "sublist":e.type="sublist";e.saveas={};e.itemLabel=d.itemLabel;e.sublist=mist.convertBuildOptions(d,e.saveas);break;default:e.type="str"}else e.type="checkbox";"influences"in d&&(e["function"]=function(){var a=$(this).closest(".UIelement"),c=a.find("style");if(c.length)c=c[0];else{c=$("<style>").addClass("dependencies")[0];a.append(c)}c.innerHTML=".UIelement[data-dependent-"+b+"]:not([data-dependent-"+
b+'~="'+$(this).getval()+'"]) { display: none; }\n';$(c).data("content",c.innerHTML);$("style.dependencies.hidden").each(function(){$(this).html($(this).data("content")).removeClass("hidden")});$(".UIelement:not(:visible) style.dependencies:not(.hidden)").each(function(){$(this).addClass("hidden");$(this).html("")})});if("dependent"in d)e.dependent=d.dependent;if("value"in d)e.value=d.value;if("validate"in d)e.validate=e.validate.concat(d.validate);return e}var b=[],h=["required","optional"];"desc"in b+'~="'+$(this).getval()+'"]) { display: none; }\n';$(c).data("content",c.innerHTML);$("style.dependencies.hidden").each(function(){$(this).html($(this).data("content")).removeClass("hidden")});$(".UIelement:not(:visible) style.dependencies:not(.hidden)").each(function(){$(this).addClass("hidden");$(this).html("")})});if("dependent"in d)e.dependent=d.dependent;if("value"in d)e.value=d.value;if("validate"in d)e.validate=e.validate.concat(d.validate);return e}var b=[],f=["required","optional"];"desc"in
a&&b.push({type:"help",help:a.desc});if("sort"in a){var m=[],i;for(i in h)if(a[h[i]])for(var f in a[h[i]]){var r=a[h[i]][f];if(Array.isArray(r))for(var j in r){if(!("validate"in r[j]))r[j].validate=[];r[j].validate=h[i];r[j].id=f;m.push(r[j])}else{if(!("validate"in r))r.validate=[];r.validate.push(h[i]);r.id=f;m.push(r)}}m.sort(function(b,c){return(""+b[a.sort]).localeCompare(c[a.sort])});for(f in m){r=m[f];b.push(d(r.validate,r.id,r))}}else for(i in h)if(a[h[i]]){b.push($("<h4>").text(UI.format.capital(h[i])+ a&&b.push({type:"help",help:a.desc});if("sort"in a){var n=[],o;for(o in f)if(a[f[o]])for(var e in a[f[o]]){var r=a[f[o]][e];if(Array.isArray(r))for(var j in r){if(!("validate"in r[j]))r[j].validate=[];r[j].validate=f[o];r[j].id=e;n.push(r[j])}else{if(!("validate"in r))r.validate=[];r.validate.push(f[o]);r.id=e;n.push(r)}}n.sort(function(b,c){return(""+b[a.sort]).localeCompare(c[a.sort])});for(e in n){r=n[e];b.push(d(r.validate,r.id,r))}}else for(o in f)if(a[f[o]]){b.push($("<h4>").text(UI.format.capital(f[o])+
" parameters"));for(f in a[h[i]]){r=a[h[i]][f];if(Array.isArray(r))for(j in r)b.push(d(i,f,r[j]));else b.push(d(i,f,r))}}return b},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})}}}; " parameters"));for(e in a[f[o]]){r=a[f[o]][e];if(Array.isArray(r))for(j in r)b.push(d(o,e,r[j]));else b.push(d(o,e,r))}}return b},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"))}); $.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));break;case "selectinput":c=$(this).children("select").first().val();c=="CUSTOM"&&(c=$(this).children("label").first().find(".field_container").children().first().getval());break;case "inputlist":c=[];$(this).children().each(function(){$(this).val()!=""&&c.push($(this).val())});break;case "sublist":c=$(this).data("savelist")}return c}; break;case "unix":c!=""&&(c=Math.round(new Date($(this).val())/1E3));break;case "selectinput":c=$(this).children("select").first().val();c=="CUSTOM"&&(c=$(this).children("label").first().find(".field_container").children().first().getval());break;case "inputlist":c=[];$(this).children().each(function(){$(this).val()!=""&&c.push($(this).val())});break;case "sublist":c=$(this).data("savelist")}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);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])}break;case "selectinput":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);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])}break;case "selectinput":a===
null&&(a="");var b=false;for(d in c.selectinput){var h;typeof c.selectinput[d]=="string"?h=c.selectinput[d]:typeof c.selectinput[d][0]=="string"&&(h=c.selectinput[d][0]);if(h==a){$(this).children("select").first().val(a);b=true;break}}if(!b){$(this).children("label").first().find(".field_container").children().first().setval(a);$(this).children("select").first().val("CUSTOM").trigger("change")}break;case "inputlist":for(d in a)$(this).append($(this).data("newitem")().val(a[d]));$(this).append($(this).children().first()); null&&(a="");var b=false;for(d in c.selectinput){var f;typeof c.selectinput[d]=="string"?f=c.selectinput[d]:typeof c.selectinput[d][0]=="string"&&(f=c.selectinput[d][0]);if(f==a){$(this).children("select").first().val(a);b=true;break}}if(!b){$(this).children("label").first().find(".field_container").children().first().setval(a);$(this).children("select").first().val("CUSTOM").trigger("change")}break;case "inputlist":for(d in a)$(this).append($(this).data("newitem")().val(a[d]));$(this).append($(this).children().first());
break;case "sublist":var m=$(this),c=$(this).children(".curvals");c.html("");if(a&&a.length)for(d in a){var b=$.extend(true,{},a[d]),i=function(a){for(var b in a)b.slice(0,6)=="x-LSP-"?delete a[b]:typeof a[b]=="object"&&i(a[b])};i(b);c.append($("<div>").addClass("subitem").append($("<span>").addClass("itemdetails").text(a[d]["x-LSP-name"]?a[d]["x-LSP-name"]:JSON.stringify(b)).attr("title",JSON.stringify(b,null,2))).append($("<button>").addClass("move").text("^").attr("title","Move item up").click(function(){var a= break;case "sublist":var n=$(this),c=$(this).children(".curvals");c.html("");if(a&&a.length)for(d in a){var b=$.extend(true,{},a[d]),o=function(a){for(var b in a)b.slice(0,6)=="x-LSP-"?delete a[b]:typeof a[b]=="object"&&o(a[b])};o(b);c.append($("<div>").addClass("subitem").append($("<span>").addClass("itemdetails").text(a[d]["x-LSP-name"]?a[d]["x-LSP-name"]:JSON.stringify(b)).attr("title",JSON.stringify(b,null,2))).append($("<button>").addClass("move").text("^").attr("title","Move item up").click(function(){var a=
$(this).parent().index();if(a!=0){var b=m.getval();b.splice(a-1,0,b.splice(a,1)[0]);m.setval(b)}})).append($("<button>").text("Edit").click(function(){var a=$(this).parent().index(),b=$(this).closest(".field");b.data("build")(Object.assign({},b.getval()[a]),a)})).append($("<button>").text("x").attr("title","Remove item").click(function(a){var b=$(this).parent().index(),c=m.data("savelist");c.splice(b,1);m.setval(c);a.preventDefault()})))}else c.append("None.");m.data("savelist",a)}$(this).trigger("change"); $(this).parent().index();if(a!=0){var b=n.getval();b.splice(a-1,0,b.splice(a,1)[0]);n.setval(b)}})).append($("<button>").text("Edit").click(function(){var a=$(this).parent().index(),b=$(this).closest(".field");b.data("build")(Object.assign({},b.getval()[a]),a)})).append($("<button>").text("x").attr("title","Remove item").click(function(a){var b=$(this).parent().index(),c=n.data("savelist");c.splice(b,1);n.setval(c);a.preventDefault()})))}else c.append("None.");n.data("savelist",a)}$(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:""}}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

@ -732,16 +732,19 @@ var UI = {
var $itemsettings = $("<div>").addClass("itemsettings"); var $itemsettings = $("<div>").addClass("itemsettings");
var $newitembutton = $("<button>").text("New "+e.itemLabel); var $newitembutton = $("<button>").text("New "+e.itemLabel);
var sublist = e.sublist; var sublist = e.sublist;
var local_e = e;
var $local_field = $field;
var $local_e = $e;
$field.data("build",function(values,index){ $field.data("build",function(values,index){
var savepos = index; var savepos = index;
//apply settings of var values //apply settings of var values
for (var i in e.saveas) { for (var i in local_e.saveas) {
if (!(i in values)) { if (!(i in values)) {
delete e.saveas[i]; delete local_e.saveas[i];
} }
} }
e.saveas = Object.assign(e.saveas,values); local_e.saveas = Object.assign(local_e.saveas,values);
var mode = "New"; var mode = "New";
if (typeof index != "undefined") { if (typeof index != "undefined") {
@ -749,7 +752,7 @@ var UI = {
} }
//Object.assign(e.saveas,values); //Object.assign(e.saveas,values);
var newUI = UI.buildUI( var newUI = UI.buildUI(
[$("<h4>").text(mode+" "+e.itemLabel)].concat( [$("<h4>").text(mode+" "+local_e.itemLabel)].concat(
sublist sublist
).concat([ ).concat([
{ {
@ -758,7 +761,7 @@ var UI = {
classes: ["onlyshowhelp"], classes: ["onlyshowhelp"],
validate: [function(){ validate: [function(){
return { return {
msg: "Did you want to save this "+e.itemLabel+"?", msg: "Did you want to save this "+local_e.itemLabel+"?",
classes: ["red"] classes: ["red"]
}; };
}] }]
@ -770,10 +773,10 @@ var UI = {
"function": function(){ "function": function(){
$itemsettings.html(""); $itemsettings.html("");
$newitembutton.show(); $newitembutton.show();
$e.show(); $local_e.show();
} }
},{ },{
label: "Save "+e.itemLabel, label: "Save "+local_e.itemLabel,
type: "save", type: "save",
preSave: function(){ preSave: function(){
$(this).closest('.input_container').find(".onlyshowhelp").closest("label").hide(); $(this).closest('.input_container').find(".onlyshowhelp").closest("label").hide();
@ -782,8 +785,8 @@ var UI = {
$(this).closest('.input_container').find(".onlyshowhelp").closest("label").show(); $(this).closest('.input_container').find(".onlyshowhelp").closest("label").show();
}, },
"function": function(){ "function": function(){
var savelist = $field.getval(); var savelist = $local_field.getval();
var save = Object.assign({},e.saveas); var save = Object.assign({},local_e.saveas);
for (var i in save) { for (var i in save) {
if (save[i] === null) { if (save[i] === null) {
delete save[i]; delete save[i];
@ -795,10 +798,10 @@ var UI = {
else { else {
savelist[savepos] = save; savelist[savepos] = save;
} }
$field.setval(savelist); $local_field.setval(savelist);
$itemsettings.html(""); $itemsettings.html("");
$newitembutton.show(); $newitembutton.show();
$e.show(); $local_e.show();
} }
}] }]
} }
@ -806,10 +809,11 @@ var UI = {
); );
$itemsettings.html(newUI); $itemsettings.html(newUI);
$newitembutton.hide(); $newitembutton.hide();
$e.hide(); $local_e.hide();
}); });
var $sublistfield = $field;
$newitembutton.click(function(){ $newitembutton.click(function(){
$field.data("build")({}); $sublistfield.data("build")({});
}); });
sublist.unshift({ sublist.unshift({
type: "str", type: "str",
@ -2411,7 +2415,7 @@ var UI = {
LTSonly: true LTSonly: true
},{ },{
type: 'span', type: 'span',
label: 'Active products', label: 'Active licenses',
value: $activeproducts, value: $activeproducts,
LTSonly: true LTSonly: true
},{ },{