LSP - should now be minified

This commit is contained in:
cat 2015-04-10 16:41:11 +02:00
parent 9140994aca
commit f94141ca26

View file

@ -1,10 +1,10 @@
var MD5=function(a){function c(a,c){var b,d,g,i,e;g=a&2147483648;i=c&2147483648;b=a&1073741824;d=c&1073741824;e=(a&1073741823)+(c&1073741823);return b&d?e^2147483648^g^i:b|d?e&1073741824?e^3221225472^g^i:e^1073741824^g^i:e^g^i}function b(a,b,d,g,i,e,k){a=c(a,c(c(b&d|~b&g,i),k));return c(a<<e|a>>>32-e,b)}function d(a,b,d,g,i,e,k){a=c(a,c(c(b&g|d&~g,i),k));return c(a<<e|a>>>32-e,b)}function f(a,b,d,g,i,e,k){a=c(a,c(c(b^d^g,i),k));return c(a<<e|a>>>32-e,b)}function l(a,b,d,g,i,e,k){a=c(a,c(c(d^(b|~g), var MD5=function(a){function c(a,c){var b,d,h,i,e;h=a&2147483648;i=c&2147483648;b=a&1073741824;d=c&1073741824;e=(a&1073741823)+(c&1073741823);return b&d?e^2147483648^h^i:b|d?e&1073741824?e^3221225472^h^i:e^1073741824^h^i:e^h^i}function b(a,b,d,h,i,e,g){a=c(a,c(c(b&d|~b&h,i),g));return c(a<<e|a>>>32-e,b)}function d(a,b,d,h,i,e,g){a=c(a,c(c(b&h|d&~h,i),g));return c(a<<e|a>>>32-e,b)}function f(a,b,d,h,i,e,g){a=c(a,c(c(b^d^h,i),g));return c(a<<e|a>>>32-e,b)}function l(a,b,d,h,i,e,g){a=c(a,c(c(d^(b|~h),
i),k));return c(a<<e|a>>>32-e,b)}function m(a){var b="",c="",d;for(d=0;3>=d;d++)c=a>>>8*d&255,c="0"+c.toString(16),b+=c.substr(c.length-2,2);return b}var e=[],p,n,i,v,g,k,j,h,e=a.replace(/\r\n/g,"\n"),a="";for(p=0;p<e.length;p++)n=e.charCodeAt(p),128>n?a+=String.fromCharCode(n):(127<n&&2048>n?a+=String.fromCharCode(n>>6|192):(a+=String.fromCharCode(n>>12|224),a+=String.fromCharCode(n>>6&63|128)),a+=String.fromCharCode(n&63|128));e=a;a=e.length;p=a+8;n=16*((p-p%64)/64+1);i=Array(n-1);for(g=v=0;g<a;)p= i),g));return c(a<<e|a>>>32-e,b)}function m(a){var b="",c="",d;for(d=0;3>=d;d++)c=a>>>8*d&255,c="0"+c.toString(16),b+=c.substr(c.length-2,2);return b}var e=[],p,n,i,v,h,k,j,g,e=a.replace(/\r\n/g,"\n"),a="";for(p=0;p<e.length;p++)n=e.charCodeAt(p),128>n?a+=String.fromCharCode(n):(127<n&&2048>n?a+=String.fromCharCode(n>>6|192):(a+=String.fromCharCode(n>>12|224),a+=String.fromCharCode(n>>6&63|128)),a+=String.fromCharCode(n&63|128));e=a;a=e.length;p=a+8;n=16*((p-p%64)/64+1);i=Array(n-1);for(h=v=0;h<a;)p=
(g-g%4)/4,v=8*(g%4),i[p]|=e.charCodeAt(g)<<v,g++;p=(g-g%4)/4;i[p]|=128<<8*(g%4);i[n-2]=a<<3;i[n-1]=a>>>29;e=i;g=1732584193;k=4023233417;j=2562383102;h=271733878;for(a=0;a<e.length;a+=16)p=g,n=k,i=j,v=h,g=b(g,k,j,h,e[a+0],7,3614090360),h=b(h,g,k,j,e[a+1],12,3905402710),j=b(j,h,g,k,e[a+2],17,606105819),k=b(k,j,h,g,e[a+3],22,3250441966),g=b(g,k,j,h,e[a+4],7,4118548399),h=b(h,g,k,j,e[a+5],12,1200080426),j=b(j,h,g,k,e[a+6],17,2821735955),k=b(k,j,h,g,e[a+7],22,4249261313),g=b(g,k,j,h,e[a+8],7,1770035416), (h-h%4)/4,v=8*(h%4),i[p]|=e.charCodeAt(h)<<v,h++;p=(h-h%4)/4;i[p]|=128<<8*(h%4);i[n-2]=a<<3;i[n-1]=a>>>29;e=i;h=1732584193;k=4023233417;j=2562383102;g=271733878;for(a=0;a<e.length;a+=16)p=h,n=k,i=j,v=g,h=b(h,k,j,g,e[a+0],7,3614090360),g=b(g,h,k,j,e[a+1],12,3905402710),j=b(j,g,h,k,e[a+2],17,606105819),k=b(k,j,g,h,e[a+3],22,3250441966),h=b(h,k,j,g,e[a+4],7,4118548399),g=b(g,h,k,j,e[a+5],12,1200080426),j=b(j,g,h,k,e[a+6],17,2821735955),k=b(k,j,g,h,e[a+7],22,4249261313),h=b(h,k,j,g,e[a+8],7,1770035416),
h=b(h,g,k,j,e[a+9],12,2336552879),j=b(j,h,g,k,e[a+10],17,4294925233),k=b(k,j,h,g,e[a+11],22,2304563134),g=b(g,k,j,h,e[a+12],7,1804603682),h=b(h,g,k,j,e[a+13],12,4254626195),j=b(j,h,g,k,e[a+14],17,2792965006),k=b(k,j,h,g,e[a+15],22,1236535329),g=d(g,k,j,h,e[a+1],5,4129170786),h=d(h,g,k,j,e[a+6],9,3225465664),j=d(j,h,g,k,e[a+11],14,643717713),k=d(k,j,h,g,e[a+0],20,3921069994),g=d(g,k,j,h,e[a+5],5,3593408605),h=d(h,g,k,j,e[a+10],9,38016083),j=d(j,h,g,k,e[a+15],14,3634488961),k=d(k,j,h,g,e[a+4],20,3889429448), g=b(g,h,k,j,e[a+9],12,2336552879),j=b(j,g,h,k,e[a+10],17,4294925233),k=b(k,j,g,h,e[a+11],22,2304563134),h=b(h,k,j,g,e[a+12],7,1804603682),g=b(g,h,k,j,e[a+13],12,4254626195),j=b(j,g,h,k,e[a+14],17,2792965006),k=b(k,j,g,h,e[a+15],22,1236535329),h=d(h,k,j,g,e[a+1],5,4129170786),g=d(g,h,k,j,e[a+6],9,3225465664),j=d(j,g,h,k,e[a+11],14,643717713),k=d(k,j,g,h,e[a+0],20,3921069994),h=d(h,k,j,g,e[a+5],5,3593408605),g=d(g,h,k,j,e[a+10],9,38016083),j=d(j,g,h,k,e[a+15],14,3634488961),k=d(k,j,g,h,e[a+4],20,3889429448),
g=d(g,k,j,h,e[a+9],5,568446438),h=d(h,g,k,j,e[a+14],9,3275163606),j=d(j,h,g,k,e[a+3],14,4107603335),k=d(k,j,h,g,e[a+8],20,1163531501),g=d(g,k,j,h,e[a+13],5,2850285829),h=d(h,g,k,j,e[a+2],9,4243563512),j=d(j,h,g,k,e[a+7],14,1735328473),k=d(k,j,h,g,e[a+12],20,2368359562),g=f(g,k,j,h,e[a+5],4,4294588738),h=f(h,g,k,j,e[a+8],11,2272392833),j=f(j,h,g,k,e[a+11],16,1839030562),k=f(k,j,h,g,e[a+14],23,4259657740),g=f(g,k,j,h,e[a+1],4,2763975236),h=f(h,g,k,j,e[a+4],11,1272893353),j=f(j,h,g,k,e[a+7],16,4139469664), h=d(h,k,j,g,e[a+9],5,568446438),g=d(g,h,k,j,e[a+14],9,3275163606),j=d(j,g,h,k,e[a+3],14,4107603335),k=d(k,j,g,h,e[a+8],20,1163531501),h=d(h,k,j,g,e[a+13],5,2850285829),g=d(g,h,k,j,e[a+2],9,4243563512),j=d(j,g,h,k,e[a+7],14,1735328473),k=d(k,j,g,h,e[a+12],20,2368359562),h=f(h,k,j,g,e[a+5],4,4294588738),g=f(g,h,k,j,e[a+8],11,2272392833),j=f(j,g,h,k,e[a+11],16,1839030562),k=f(k,j,g,h,e[a+14],23,4259657740),h=f(h,k,j,g,e[a+1],4,2763975236),g=f(g,h,k,j,e[a+4],11,1272893353),j=f(j,g,h,k,e[a+7],16,4139469664),
k=f(k,j,h,g,e[a+10],23,3200236656),g=f(g,k,j,h,e[a+13],4,681279174),h=f(h,g,k,j,e[a+0],11,3936430074),j=f(j,h,g,k,e[a+3],16,3572445317),k=f(k,j,h,g,e[a+6],23,76029189),g=f(g,k,j,h,e[a+9],4,3654602809),h=f(h,g,k,j,e[a+12],11,3873151461),j=f(j,h,g,k,e[a+15],16,530742520),k=f(k,j,h,g,e[a+2],23,3299628645),g=l(g,k,j,h,e[a+0],6,4096336452),h=l(h,g,k,j,e[a+7],10,1126891415),j=l(j,h,g,k,e[a+14],15,2878612391),k=l(k,j,h,g,e[a+5],21,4237533241),g=l(g,k,j,h,e[a+12],6,1700485571),h=l(h,g,k,j,e[a+3],10,2399980690), k=f(k,j,g,h,e[a+10],23,3200236656),h=f(h,k,j,g,e[a+13],4,681279174),g=f(g,h,k,j,e[a+0],11,3936430074),j=f(j,g,h,k,e[a+3],16,3572445317),k=f(k,j,g,h,e[a+6],23,76029189),h=f(h,k,j,g,e[a+9],4,3654602809),g=f(g,h,k,j,e[a+12],11,3873151461),j=f(j,g,h,k,e[a+15],16,530742520),k=f(k,j,g,h,e[a+2],23,3299628645),h=l(h,k,j,g,e[a+0],6,4096336452),g=l(g,h,k,j,e[a+7],10,1126891415),j=l(j,g,h,k,e[a+14],15,2878612391),k=l(k,j,g,h,e[a+5],21,4237533241),h=l(h,k,j,g,e[a+12],6,1700485571),g=l(g,h,k,j,e[a+3],10,2399980690),
j=l(j,h,g,k,e[a+10],15,4293915773),k=l(k,j,h,g,e[a+1],21,2240044497),g=l(g,k,j,h,e[a+8],6,1873313359),h=l(h,g,k,j,e[a+15],10,4264355552),j=l(j,h,g,k,e[a+6],15,2734768916),k=l(k,j,h,g,e[a+13],21,1309151649),g=l(g,k,j,h,e[a+4],6,4149444226),h=l(h,g,k,j,e[a+11],10,3174756917),j=l(j,h,g,k,e[a+2],15,718787259),k=l(k,j,h,g,e[a+9],21,3951481745),g=c(g,p),k=c(k,n),j=c(j,i),h=c(h,v);return(m(g)+m(k)+m(j)+m(h)).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==p)return d=a(this),!1;var b=a(this).attr("colspan");c+=b?Number(b):1});b="undefined"!=typeof d.data("sort-value")?d.data("sort-value"):"undefined"!=typeof d.attr("data-sort-value")?d.attr("data-sort-value"):d.text();switch(m){case "string":case "string-ins":b=String(b).toLowerCase();break;case "int":b= j=l(j,g,h,k,e[a+10],15,4293915773),k=l(k,j,g,h,e[a+1],21,2240044497),h=l(h,k,j,g,e[a+8],6,1873313359),g=l(g,h,k,j,e[a+15],10,4264355552),j=l(j,g,h,k,e[a+6],15,2734768916),k=l(k,j,g,h,e[a+13],21,1309151649),h=l(h,k,j,g,e[a+4],6,4149444226),g=l(g,h,k,j,e[a+11],10,3174756917),j=l(j,g,h,k,e[a+2],15,718787259),k=l(k,j,g,h,e[a+9],21,3951481745),h=c(h,p),k=c(k,n),j=c(j,i),g=c(g,v);return(m(h)+m(k)+m(j)+m(g)).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==p)return d=a(this),!1;var b=a(this).attr("colspan");c+=b?Number(b):1});b="undefined"!=typeof d.data("sort-value")?d.data("sort-value"):"undefined"!=typeof d.attr("data-sort-value")?d.attr("data-sort-value"):d.text();switch(m){case "string":case "string-ins":b=String(b).toLowerCase();break;case "int":b=
parseInt(Number(b));break;case "float":b=Number(b)}return b}var b=a(this),d=b.closest("table"),f=d.children("tbody"),l=f.children("tr"),m=b.attr("data-sort-type");if(m){var e=!0;b.hasClass("sorting-asc")&&(e=!1);var p=0;b.prevAll().each(function(){var b=a(this).attr("colspan");p+=b?Number(b):1});l.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(l);d.find("thead th").removeClass("sorting-asc").removeClass("sorting-desc");b.addClass(e?"sorting-asc":"sorting-desc")}}})(jQuery);$(function(){UI.elements={menu:$("nav > .menu"),secondary_menu:$("nav.secondary_menu"),main:$("main"),connection:{status:$("#connection"),user_and_host:$("#user_and_host"),msg:$("#message")}};UI.buildMenu();UI.stored.getOpts();if(location.hash){var a=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})}); parseInt(Number(b));break;case "float":b=Number(b)}return b}var b=a(this),d=b.closest("table"),f=d.children("tbody"),l=f.children("tr"),m=b.attr("data-sort-type");if(m){var e=!0;b.hasClass("sorting-asc")&&(e=!1);var p=0;b.prevAll().each(function(){var b=a(this).attr("colspan");p+=b?Number(b):1});l.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(l);d.find("thead th").removeClass("sorting-asc").removeClass("sorting-desc");b.addClass(e?"sorting-asc":"sorting-desc")}}})(jQuery);$(function(){UI.elements={menu:$("nav > .menu"),secondary_menu:$("nav.secondary_menu"),main:$("main"),connection:{status:$("#connection"),user_and_host:$("#user_and_host"),msg:$("#message")}};UI.buildMenu();UI.stored.getOpts();if(location.hash){var a=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})});
$(window).on("hashchange",function(){var a=location.hash.substring(1).split("@");a[1]||(a[1]="");a=a[1].split("&");""==a[0]&&(a[0]="Overview");UI.showTab(a[0],a[1])}); $(window).on("hashchange",function(){var a=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 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}; var 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};
@ -22,7 +22,7 @@ function(){UI.popup.element.remove();UI.popup.element=null})})).append(a);$("bod
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){UI.navto(a);b.stopPropagation()});return c}var c=UI.elements.menu,b;for(b in UI.menu){0<b&&c.append($("<br>"));for(var d in UI.menu[b]){var f=UI.menu[b][d], 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){UI.navto(a);b.stopPropagation()});return c}var c=UI.elements.menu,b;for(b in UI.menu){0<b&&c.append($("<br>"));for(var d in UI.menu[b]){var f=UI.menu[b][d],
l=a(d,f);c.append(l);if("submenu"in f){var m=$("<span>").addClass("submenu");l.addClass("arrowdown").append(m);for(var e in f.submenu)m.append(a(e,f.submenu[e]))}}}b=$("<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(b).after($("<div>").addClass("separator"))},buildUI:function(a){var c= l=a(d,f);c.append(l);if("submenu"in f){var m=$("<span>").addClass("submenu");l.addClass("arrowdown").append(m);for(var e in f.submenu)m.append(a(e,f.submenu[e]))}}}b=$("<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(b).after($("<div>").addClass("separator"))},buildUI:function(a){var c=
$("<div>").addClass("input_container"),b;for(b in a){var d=a[b];if(d instanceof jQuery)c.append(d);else if("help"==d.type){var f=$("<span>").addClass("text_container").append($("<span>").addClass("description").append(d.help));c.append(f);if("classes"in d)for(var l in d.classes)f.addClass(d.classes[l])}else if("text"==d.type)c.append($("<span>").addClass("text_container").append($("<span>").addClass("text").append(d.text)));else if("custom"==d.type)c.append(d.custom);else if("buttons"==d.type)for(l in f= $("<div>").addClass("input_container"),b;for(b in a){var d=a[b];if(d instanceof jQuery)c.append(d);else if("help"==d.type){var f=$("<span>").addClass("text_container").append($("<span>").addClass("description").append(d.help));c.append(f);if("classes"in d)for(var l in d.classes)f.addClass(d.classes[l])}else if("text"==d.type)c.append($("<span>").addClass("text_container").append($("<span>").addClass("text").append(d.text)));else if("custom"==d.type)c.append(d.custom);else if("buttons"==d.type)for(l in f=
$("<span>").addClass("button_container"),"css"in d&&f.css(d.css),c.append(f),d.buttons){var m=d.buttons[l],e=$("<button>").text(m.label).data("opts",m);"css"in m&&e.css(m.css);f.append(e);switch(m.type){case "cancel":e.addClass("cancel").click(m["function"]);break;case "save":e.addClass("save").click(function(){var a=$(this).closest(".input_container"),b=!1;a.find(".hasValidate").each(function(){if(b=$(this).data("validate")(this))return!1});b||(a.find(".isSetting").each(function(){var a=$(this).getval(), $("<span>").addClass("button_container"),"css"in d&&f.css(d.css),c.append(f),d.buttons){var m=d.buttons[l],e=$("<button>").text(m.label).data("opts",m);"css"in m&&e.css(m.css);f.append(e);switch(m.type){case "cancel":e.addClass("cancel").click(m["function"]);break;case "save":e.addClass("save").click(function(){var a=$(this).closest(".input_container"),b=!1;a.find(".hasValidate").each(function(){if(b=$(this).data("validate")(this,!0))return!1});b||(a.find(".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 delete b.main[b.index],!0;b.main[b.index]=a}),(a=$(this).data("opts")["function"])&&a(this))});break;default:e.click(m["function"])}}else{m=$("<label>").addClass("UIelement");c.append(m);"css"in d&&m.css(d.css);m.append($("<span>").addClass("label").html(d.label+":"));e=$("<span>").addClass("field_container");m.append(e);switch(d.type){case "password":f=$("<input>").attr("type","password"); b=$(this).data("pointer");if(""==a)if("default"in $(this).data("opts"))a=$(this).data("opts")["default"];else return delete b.main[b.index],!0;b.main[b.index]=a}),(a=$(this).data("opts")["function"])&&a(this))});break;default:e.click(m["function"])}}else{m=$("<label>").addClass("UIelement");c.append(m);"css"in d&&m.css(d.css);m.append($("<span>").addClass("label").html(d.label+":"));e=$("<span>").addClass("field_container");m.append(e);switch(d.type){case "password":f=$("<input>").attr("type","password");
break;case "int":f=$("<input>").attr("type","number");"min"in d&&f.attr("min",d.min);"max"in d&&f.attr("max",d.min);"validate"in d?d.validate.push("int"):d.validate=["int"];break;case "span":f=$("<span>");break;case "debug":d.select=[["","Default"],[0,"0 - All debugging messages disabled"],[1,"1 - Messages about failed operations"],[2,"2 - Previous level, and error messages"],[3,"3 - Previous level, and warning messages"],[4,"4 - Previous level, and status messages for development"],[5,"5 - Previous level, and more status messages for development"], break;case "int":f=$("<input>").attr("type","number");"min"in d&&f.attr("min",d.min);"max"in d&&f.attr("max",d.min);"validate"in d?d.validate.push("int"):d.validate=["int"];break;case "span":f=$("<span>");break;case "debug":d.select=[["","Default"],[0,"0 - All debugging messages disabled"],[1,"1 - Messages about failed operations"],[2,"2 - Previous level, and error messages"],[3,"3 - Previous level, and warning messages"],[4,"4 - Previous level, and status messages for development"],[5,"5 - Previous level, and more status messages for development"],
[6,"6 - Previous level, and verbose debugging messages"],[7,"7 - Previous level, and very verbose debugging messages"],[8,"8 - Report everything in extreme detail"],[9,"9 - Report everything in insane detail"],[10,"10 - All messages enabled"]];case "select":f=$("<select>");for(l in d.select){var p=$("<option>");"string"==typeof d.select[l]?p.text(d.select[l]):p.val(d.select[l][0]).text(d.select[l][1]);f.append(p)}break;case "textarea":f=$("<textarea>").on("keydown",function(a){a.stopPropagation()}); [6,"6 - Previous level, and verbose debugging messages"],[7,"7 - Previous level, and very verbose debugging messages"],[8,"8 - Report everything in extreme detail"],[9,"9 - Report everything in insane detail"],[10,"10 - All messages enabled"]];case "select":f=$("<select>");for(l in d.select){var p=$("<option>");"string"==typeof d.select[l]?p.text(d.select[l]):p.val(d.select[l][0]).text(d.select[l][1]);f.append(p)}break;case "textarea":f=$("<textarea>").on("keydown",function(a){a.stopPropagation()});
@ -30,19 +30,19 @@ break;case "checkbox":f=$("<input>").attr("type","checkbox");break;case "hidden"
$("<input>").attr("type","radio").val(d.radioselect[b][0]).attr("name",d.label);("LTSonly"in d&&!mist.data.LTS||d.readonly)&&n.prop("disabled",!0);p=$("<label>").append(n).append($("<span>").html(d.radioselect[b][1]));f.append(p);if(2<d.radioselect[b].length)for(l in n=$("<select>").change(function(){$(this).parent().find("input[type=radio]:enabled").prop("checked","true")}),p.append(n),("LTSonly"in d&&!mist.data.LTS||d.readonly)&&n.prop("disabled",!0),d.radioselect[b][2])p=$("<option>"),n.append(p), $("<input>").attr("type","radio").val(d.radioselect[b][0]).attr("name",d.label);("LTSonly"in d&&!mist.data.LTS||d.readonly)&&n.prop("disabled",!0);p=$("<label>").append(n).append($("<span>").html(d.radioselect[b][1]));f.append(p);if(2<d.radioselect[b].length)for(l in n=$("<select>").change(function(){$(this).parent().find("input[type=radio]:enabled").prop("checked","true")}),p.append(n),("LTSonly"in d&&!mist.data.LTS||d.readonly)&&n.prop("disabled",!0),d.radioselect[b][2])p=$("<option>"),n.append(p),
d.radioselect[b][2][l]instanceof Array?p.val(d.radioselect[b][2][l][0]).html(d.radioselect[b][2][l][1]):p.html(d.radioselect[b][2][l])}break;default:f=$("<input>").attr("type","text")}f.addClass("field").data("opts",d);e.append(f);if("classes"in d)for(l in d.classes)f.addClass(d.classes[l]);"placeholder"in d&&f.attr("placeholder",d.placeholder);"default"in d&&f.attr("placeholder",d["default"]);"unit"in d&&e.append($("<span>").addClass("unit").html(d.unit));"readonly"in d&&(f.attr("readonly","readonly"), d.radioselect[b][2][l]instanceof Array?p.val(d.radioselect[b][2][l][0]).html(d.radioselect[b][2][l][1]):p.html(d.radioselect[b][2][l])}break;default:f=$("<input>").attr("type","text")}f.addClass("field").data("opts",d);e.append(f);if("classes"in d)for(l in d.classes)f.addClass(d.classes[l]);"placeholder"in d&&f.attr("placeholder",d.placeholder);"default"in d&&f.attr("placeholder",d["default"]);"unit"in d&&e.append($("<span>").addClass("unit").html(d.unit));"readonly"in d&&(f.attr("readonly","readonly"),
f.click(function(){$(this).select()}));"qrcode"in d&&e.append($("<span>").addClass("unit").html($("<button>").text("QR").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())})})));"rows"in d&&f.attr("rows",d.rows);"LTSonly"in d&&!mist.data.LTS&&(e.addClass("LTSonly"),f.prop("disabled",!0)); f.click(function(){$(this).select()}));"qrcode"in d&&e.append($("<span>").addClass("unit").html($("<button>").text("QR").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())})})));"rows"in d&&f.attr("rows",d.rows);"LTSonly"in d&&!mist.data.LTS&&(e.addClass("LTSonly"),f.prop("disabled",!0));
switch(d.type){case "browse":n=$("<div>").addClass("grouper").append(m);c.append(n);n=$("<button>").text("Browse");e.append(n);n.click(function(){function a(b){m.text("Loading..");mist.send(function(a){h.text(a.browse.path[0]);m.html(l.clone(true).text("..").attr("title","Folder up"));if(a.browse.subdirectories){a.browse.subdirectories.sort();for(var b in a.browse.subdirectories){var i=a.browse.subdirectories[b];m.append(l.clone(true).attr("title",h.text()+p+i).text(i))}}if(a.browse.files){a.browse.files.sort(); switch(d.type){case "browse":n=$("<div>").addClass("grouper").append(m);c.append(n);n=$("<button>").text("Browse");e.append(n);n.click(function(){function a(b){m.text("Loading..");mist.send(function(a){g.text(a.browse.path[0]);m.html(l.clone(true).text("..").attr("title","Folder up"));if(a.browse.subdirectories){a.browse.subdirectories.sort();for(var b in a.browse.subdirectories){var i=a.browse.subdirectories[b];m.append(l.clone(true).attr("title",g.text()+p+i).text(i))}}if(a.browse.files){a.browse.files.sort();
for(b in a.browse.files){var i=a.browse.files[b],f=h.text()+p+i,i=$("<a>").text(i).addClass("file").attr("title",f);m.append(i);if(n){var v=true,w;for(w in n)if(typeof n[w]!="undefined"&&mist.inputMatch(n[w],f)){v=false;break}v&&i.hide()}i.click(function(){var a=$(this).attr("title");d.setval(a);e.show();c.remove()})}}},{browse:b})}var b=$(this).closest(".grouper"),c=$("<div>").addClass("browse_container"),d=b.find(".field"),e=$(this),h=$("<span>").addClass("field"),f=$("<button>").text("Select this folder"), for(b in a.browse.files){var i=a.browse.files[b],f=g.text()+p+i,i=$("<a>").text(i).addClass("file").attr("title",f);m.append(i);if(n){var v=true,r;for(r in n)if(typeof n[r]!="undefined"&&mist.inputMatch(n[r],f)){v=false;break}v&&i.hide()}i.click(function(){var a=$(this).attr("title");d.setval(a);e.show();c.remove()})}}},{browse:b})}var b=$(this).closest(".grouper"),c=$("<div>").addClass("browse_container"),d=b.find(".field"),e=$(this),g=$("<span>").addClass("field"),f=$("<button>").text("Select this folder"),
m=$("<div>").addClass("browse_contents"),l=$("<a>").addClass("folder"),n=d.data("filetypes");b.append(c);c.append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Current folder:")).append($("<span>").addClass("field_container").append(h).append(f))).append(m);f.click(function(){var a=h.text()+"/";d.setval(a);e.show();c.remove()});var p="/";mist.data.config.version.indexOf("indows")>-1&&(p="\\");l.click(function(){var b=h.text()+p+$(this).text();a(b)});b=d.getval();b= m=$("<div>").addClass("browse_contents"),l=$("<a>").addClass("folder"),n=d.data("filetypes");b.append(c);c.append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Current folder:")).append($("<span>").addClass("field_container").append(g).append(f))).append(m);f.click(function(){var a=g.text()+"/";d.setval(a);e.show();c.remove()});var p="/";mist.data.config.version.indexOf("indows")>-1&&(p="\\");l.click(function(){var b=g.text()+p+$(this).text();a(b)});b=d.getval();b=
b.split(p);b.pop();b=b.join(p);e.hide();a(b)});break;case "geolimited":case "hostlimited":n={field:f};n.blackwhite=$("<select>").append($("<option>").val("-").text("Blacklist")).append($("<option>").val("+").text("Whitelist"));n.values=$("<span>").addClass("limit_value_list");switch(d.type){case "geolimited":n.prototype=$("<select>").append($("<option>").val("").text("[Select a country]"));for(b in UI.countrylist)n.prototype.append($("<option>").val(b).html(UI.countrylist[b]));break;case "hostlimited":n.prototype= b.split(p);b.pop();b=b.join(p);e.hide();a(b)});break;case "geolimited":case "hostlimited":n={field:f};n.blackwhite=$("<select>").append($("<option>").val("-").text("Blacklist")).append($("<option>").val("+").text("Whitelist"));n.values=$("<span>").addClass("limit_value_list");switch(d.type){case "geolimited":n.prototype=$("<select>").append($("<option>").val("").text("[Select a country]"));for(b in UI.countrylist)n.prototype.append($("<option>").val(b).html(UI.countrylist[b]));break;case "hostlimited":n.prototype=
$("<input>").attr("type","text").attr("placeholder","type a host")}n.prototype.on("change keyup",function(){$(this).closest(".field_container").data("subUI").blackwhite.trigger("change")});n.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")}); $("<input>").attr("type","text").attr("placeholder","type a host")}n.prototype.on("change keyup",function(){$(this).closest(".field_container").data("subUI").blackwhite.trigger("change")});n.blackwhite.change(function(){var a=$(this).closest(".field_container").data("subUI"),b=[],c=false;a.values.children().each(function(){c=$(this).val();c!=""?b.push(c):$(this).remove()});a.values.append(a.prototype.clone(true));b.length>0?a.field.val($(this).val()+b.join(" ")):a.field.val("");a.field.trigger("change")});
"LTSonly"in d&&!mist.data.LTS&&(n.blackwhite.prop("disabled",!0),n.prototype.prop("disabled",!0));n.values.append(n.prototype.clone(!0));e.data("subUI",n).addClass("limit_list").append(n.blackwhite).append(n.values)}"pointer"in d&&(f.data("pointer",d.pointer).addClass("isSetting"),e=d.pointer.main[d.pointer.index],"undefined"!=e&&f.setval(e));"value"in d&&f.setval(d.value);e=$("<span>").addClass("help_container");m.append(e);"help"in d&&(e.append($("<span>").addClass("ih_balloon").html(d.help)),f.on("focus mouseover", "LTSonly"in d&&!mist.data.LTS&&(n.blackwhite.prop("disabled",!0),n.prototype.prop("disabled",!0));n.values.append(n.prototype.clone(!0));e.data("subUI",n).addClass("limit_list").append(n.blackwhite).append(n.values)}"pointer"in d&&(f.data("pointer",d.pointer).addClass("isSetting"),e=d.pointer.main[d.pointer.index],"undefined"!=e&&f.setval(e));"value"in d&&f.setval(d.value);e=$("<span>").addClass("help_container");m.append(e);"help"in d&&(e.append($("<span>").addClass("ih_balloon").html(d.help)),f.on("focus mouseover",
function(){$(this).closest("label").addClass("active")}).on("blur mouseout",function(){$(this).closest("label").removeClass("active")}));if("validate"in d){m=[];for(l in d.validate){n=d.validate[l];if("function"!=typeof n)switch(n){case "required":n=function(a){return a==""?{msg:"This is a required field.",classes:["red"]}:false};break;case "int":n=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 "+ function(){$(this).closest("label").addClass("active")}).on("blur mouseout",function(){$(this).closest("label").removeClass("active")}));if("validate"in d){m=[];for(l in d.validate){n=d.validate[l];if("function"!=typeof n)switch(n){case "required":n=function(a){return a==""?{msg:"This is a required field.",classes:["red"]}:false};break;case "int":n=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":n=function(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"]}}; 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":n=function(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"]}};
break;default:n=function(){}}m.push(n)}f.data("validate_functions",m).data("help_container",e).data("validate",function(a){var b=$(a).getval(),c=$(a).data("validate_functions"),d=$(a).data("help_container");d.find(".err_balloon").remove();for(var e in c){var f=c[e](b,a);if(f){$err=$("<span>").addClass("err_balloon").html(f.msg);for(var m in f.classes)$err.addClass(f.classes[m]);d.prepend($err);$(a).focus();return true}}return false}).addClass("hasValidate").on("change keyup",function(){$(this).data("validate")($(this))}); break;default:n=function(){}}m.push(n)}f.data("validate_functions",m).data("help_container",e).data("validate",function(a,b){var c=$(a).getval(),d=$(a).data("validate_functions"),e=$(a).data("help_container");e.find(".err_balloon").remove();for(var g in d){var f=d[g](c,a);if(f){$err=$("<span>").addClass("err_balloon").html(f.msg);for(var m in f.classes)$err.addClass(f.classes[m]);e.prepend($err);b&&$(a).focus();return true}}return false}).addClass("hasValidate").on("change keyup",function(){$(this).data("validate")($(this))});
""!=f.getval()&&f.trigger("change")}"function"in d&&(f.on("change keyup",d["function"]),f.trigger("change"))}}c.on("keydown",function(a){switch(a.which){case 13:$(this).find("button.save").trigger("click");break;case 27:$(this).find("button.cancel").trigger("click")}});return c},buildVheaderTable:function(a){var c=$("<table>").css("margin","0.2em"),b=$("<tr>").addClass("header").append($("<td>").addClass("vheader").attr("rowspan",a.labels.length+1).append($("<span>").text(a.vheader))),d=[];b.append($("<td>")); ""!=f.getval()&&f.trigger("change")}"function"in d&&(f.on("change keyup",d["function"]),f.trigger("change"))}}c.on("keydown",function(a){switch(a.which){case 13:$(this).find("button.save").trigger("click");break;case 27:$(this).find("button.cancel").trigger("click")}});return c},buildVheaderTable:function(a){var c=$("<table>").css("margin","0.2em"),b=$("<tr>").addClass("header").append($("<td>").addClass("vheader").attr("rowspan",a.labels.length+1).append($("<span>").text(a.vheader))),d=[];b.append($("<td>"));
for(var f in a.labels)d.push($("<tr>").append($("<td>").html(""==a.labels[f]?"&nbsp;":a.labels[f]+":")));for(var l in a.content)for(f in b.append($("<td>").html(a.content[l].header)),a.content[l].body)d[f].append($("<td>").html(a.content[l].body[f]));c.append($("<tbody>").append(b).append(d));return c},buildLimits:function(a,c,b){function d(a,d){var e=$("<tbody>"),g;for(g in a){var f=$("<tr>");f.data("pointer",d.concat(g));var j="";switch(d[0]){case "server":j="The entire server";break;case "stream":j= for(var f in a.labels)d.push($("<tr>").append($("<td>").html(""==a.labels[f]?"&nbsp;":a.labels[f]+":")));for(var l in a.content)for(f in b.append($("<td>").html(a.content[l].header)),a.content[l].body)d[f].append($("<td>").html(a.content[l].body[f]));c.append($("<tbody>").append(b).append(d));return c},buildLimits:function(a,c,b){function d(a,d){var e=$("<tbody>"),h;for(h in a){var f=$("<tr>");f.data("pointer",d.concat(h));var j="";switch(d[0]){case "server":j="The entire server";break;case "stream":j=
'The stream "'+d[1]+'"'}f.append($("<td>").addClass("applies_to").text(j));var j=a[g].name,h=a[g].value;switch(a[g].name){case "kbps_max":j="Maximum bandwidth";h=UI.format.bytes(h,!0);break;case "users":j="Maximum connected users";h=UI.format.number(h);break;case "geo":var j="Geolimited",m=h,h="<span class=unit>["+("-"==h.charAt(0)?"Blacklist":"Whitelist")+"]</span> ",m=m.substr(1).split(" "),l=[],p;for(p in m){var o=UI.countrylist[m[p]];l.push("undefined"==typeof o?m[p]:o)}h+=l.join(", ");break; 'The stream "'+d[1]+'"'}f.append($("<td>").addClass("applies_to").text(j));var j=a[h].name,g=a[h].value;switch(a[h].name){case "kbps_max":j="Maximum bandwidth";g=UI.format.bytes(g,!0);break;case "users":j="Maximum connected users";g=UI.format.number(g);break;case "geo":var j="Geolimited",m=g,g="<span class=unit>["+("-"==g.charAt(0)?"Blacklist":"Whitelist")+"]</span> ",m=m.substr(1).split(" "),l=[],p;for(p in m){var o=UI.countrylist[m[p]];l.push("undefined"==typeof o?m[p]:o)}g+=l.join(", ");break;
case "host":j="Hostlimited",m=h,h="<span class=unit>["+("-"==h.charAt(0)?"Blacklist":"Whitelist")+"]</span> ",m=m.substr(1).split(" "),h+=m.join(", ")}f.append($("<td>").text(a[g].type).addClass("kind")).append($("<td>").text(j).addClass("type")).append($("<td>").html(h).addClass("value")).append($("<td>").css("text-align","right").html($("<button>").text("Edit").click(function(){UI.navto("Edit Limit",$(this).closest("tr").data("pointer").join("^"));UI.returnTab=[c,b]})).append($("<button>").text("Delete").click(function(){var a= case "host":j="Hostlimited",m=g,g="<span class=unit>["+("-"==g.charAt(0)?"Blacklist":"Whitelist")+"]</span> ",m=m.substr(1).split(" "),g+=m.join(", ")}f.append($("<td>").text(a[h].type).addClass("kind")).append($("<td>").text(j).addClass("type")).append($("<td>").html(g).addClass("value")).append($("<td>").css("text-align","right").html($("<button>").text("Edit").click(function(){UI.navto("Edit Limit",$(this).closest("tr").data("pointer").join("^"));UI.returnTab=[c,b]})).append($("<button>").text("Delete").click(function(){var a=
$(this).closest("tr"),d="Are you sure you want to delete the "+a.find(".kind").text()+" "+a.find(".type").text()+" limit for "+a.find(".applies_to").text()+"?";if(confirm(d)){var a=a.data("pointer"),d=a[a.length-1],e={};switch(a[0]){case "server":mist.data.config.limits.splice(d,1);e={config:mist.data.config};break;case "stream":mist.data.streams[a[1]].limits.splice(d,1),1==mist.data.LTS?(d={},d[a[1]]=mist.data.streams[a[1]],e={addstream:d}):e={streams:mist.data.streams}}mist.send(function(){UI.navto(c, $(this).closest("tr"),d="Are you sure you want to delete the "+a.find(".kind").text()+" "+a.find(".type").text()+" limit for "+a.find(".applies_to").text()+"?";if(confirm(d)){var a=a.data("pointer"),d=a[a.length-1],e={};switch(a[0]){case "server":mist.data.config.limits.splice(d,1);e={config:mist.data.config};break;case "stream":mist.data.streams[a[1]].limits.splice(d,1),1==mist.data.LTS?(d={},d[a[1]]=mist.data.streams[a[1]],e={addstream:d}):e={streams:mist.data.streams}}mist.send(function(){UI.navto(c,
b)},e)}})));e.append(f)}return e.children()}var f=$("<div>"),l=$("<table>");f.append(l);var m=$("<tr>").append($("<th>").text("Kind").attr("data-sort-type","string")).append($("<th>").text("Type").attr("data-sort-type","string")).append($("<th>").text("Value")).append($("<th>"));a instanceof Array?a={noapply:a}:m.prepend($("<th>").text("Applies to").attr("data-sort-type","string").addClass("sorting-asc").addClass("applies_to"));l.append($("<thead>").append(m));m=$("<tbody>");l.append(m);for(var e in a)switch(e){case "server":m.append(d(a[e], b)},e)}})));e.append(f)}return e.children()}var f=$("<div>"),l=$("<table>");f.append(l);var m=$("<tr>").append($("<th>").text("Kind").attr("data-sort-type","string")).append($("<th>").text("Type").attr("data-sort-type","string")).append($("<th>").text("Value")).append($("<th>"));a instanceof Array?a={noapply:a}:m.prepend($("<th>").text("Applies to").attr("data-sort-type","string").addClass("sorting-asc").addClass("applies_to"));l.append($("<thead>").append(m));m=$("<tbody>");l.append(m);for(var e in a)switch(e){case "server":m.append(d(a[e],
["server"]));break;case "streams":for(var p in a[e])m.append(d(a[e][p],["stream",p]))}f.prepend($("<button>").text("New limit").click(function(){UI.navto("Edit Limit");UI.returnTab=[c,b]}));0<m.children().length?l.stupidtable():(l.remove(),f.append($("<span>").text("No limits set.")));return f.children()},plot:{addGraph:function(a,c){var b={id:a.id,xaxis:a.xaxis,datasets:[],elements:{cont:$("<div>").addClass("graph"),plot:$("<div>").addClass("plot"),legend:$("<div>").addClass("legend")}};b.elements.cont.append(b.elements.plot).append(b.elements.legend); ["server"]));break;case "streams":for(var p in a[e])m.append(d(a[e][p],["stream",p]))}f.prepend($("<button>").text("New limit").click(function(){UI.navto("Edit Limit");UI.returnTab=[c,b]}));0<m.children().length?l.stupidtable():(l.remove(),f.append($("<span>").text("No limits set.")));return f.children()},plot:{addGraph:function(a,c){var b={id:a.id,xaxis:a.xaxis,datasets:[],elements:{cont:$("<div>").addClass("graph"),plot:$("<div>").addClass("plot"),legend:$("<div>").addClass("legend")}};b.elements.cont.append(b.elements.plot).append(b.elements.legend);
@ -71,73 +71,73 @@ pointer:{main:mist.user,index:"name"}},{label:"Desired password",type:"password"
classes:["red"]}:false}],help:"Repeat your desired password.",classes:["match_password"]},{type:"buttons",buttons:[{type:"save",label:"Create new account","function":function(){mist.send(function(){UI.navto("Account created")},{authorize:{new_username:mist.user.name,new_password:mist.user.password}})}}]}]));break;case "Account created":UI.elements.menu.css("visibility","hidden");b.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?"}, 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.password}})}}]}]));break;case "Account created":UI.elements.menu.css("visibility","hidden");b.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)b.append("Unable to enable all protocols as protocol settings already exist.<br>");else{b.append("Retrieving available protocols..<br>");mist.send(function(a){var c=[],d;for(d in a.capabilities.connectors)if(a.capabilities.connectors[d].required)b.append('Could not enable protocol "'+d+'" because it has required settings.<br>');else{c.push({connector:d});b.append('Enabled protocol "'+ {type:"buttons",buttons:[{label:"Enable protocols",type:"save","function":function(){if(mist.data.config.protocols)b.append("Unable to enable all protocols as protocol settings already exist.<br>");else{b.append("Retrieving available protocols..<br>");mist.send(function(a){var c=[],d;for(d in a.capabilities.connectors)if(a.capabilities.connectors[d].required)b.append('Could not enable protocol "'+d+'" because it has required settings.<br>');else{c.push({connector:d});b.append('Enabled protocol "'+
d+'".<br>')}b.append("Saving protocol settings..<br>");mist.send(function(){b.append("Protocols enabled. Redirecting..");setTimeout(function(){UI.navto("Overview")},5E3)},{config:{protocols:c}})},{capabilities:true})}}},{label:"Skip",type:"cancel","function":function(){UI.navto("Overview")}}]}]));break;case "Overview":var f=$("<span>").text("Loading.."),l=$("<span>"),m=$("<span>"),e=$("<span>");b.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. "}, d+'".<br>')}b.append("Saving protocol settings..<br>");mist.send(function(){b.append("Protocols enabled. Redirecting..");setTimeout(function(){UI.navto("Overview")},5E3)},{config:{protocols:c}})},{capabilities:true})}}},{label:"Skip",type:"cancel","function":function(){UI.navto("Overview")}}]}]));break;case "Overview":var f=$("<span>").text("Loading.."),l=$("<span>"),m=$("<span>"),e=$("<span>");b.append(UI.buildUI([{type:"help",help:"You can find most basic information about your MistServer here.<br>You can also set the debug level and force a save to the config.json file that MistServer uses to save your settings. "},
{type:"span",label:"Version",pointer:{main:mist.data.config,index:"version"}},{type:"span",label:"Version check",value:f,LTSonly:!0},{type:"span",label:"Server time",value:e},{type:"span",label:"Current streams",value:l},{type:"span",label:"Current connections",value:m},$("<br>"),{type:"str",label:"Human readable name",pointer:{main:mist.data.config,index:"name"},help:"You can name your MistServer here for personal use. You\u2019ll still need to set host name within your network yourself."},{type:"debug", {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:e},{type:"span",label:"Current streams",value:l},{type:"span",label:"Current connections",value:m},$("<br>"),{type:"str",label:"Human readable name",pointer:{main:mist.data.config,index:"name"},help:"You can name your MistServer here for personal use. You???ll still need to set host name within your network yourself."},{type:"debug",
label:"Debug level",pointer:{main:mist.data.config,index:"debug"},help:"You can set the amount of debug information MistServer saves in the log. A full reboot of MistServer is required before some components of MistServer can post debug information."},{type:"checkbox",label:"Force JSON file save",pointer:{main:mist.data,index:"save"},help:"Tick the box in order to force an immediate save to the config.json MistServer uses to save your settings. Saving will otherwise happen upon closing MistServer. Don\u2019t forget to press save after ticking the box."}, label:"Debug level",pointer:{main:mist.data.config,index:"debug"},help:"You can set the amount of debug information MistServer saves in the log. A full reboot of MistServer is required before some components of MistServer can post debug information."},{type:"checkbox",label:"Force JSON file save",pointer:{main:mist.data,index:"save"},help:"Tick the box in order to force an immediate save to the config.json MistServer uses to save your settings. Saving will otherwise happen upon closing MistServer. Don???t forget to press save after ticking the box."},
{type:"buttons",buttons:[{type:"save",label:"Save","function":function(){var a={config:mist.data.config};if(mist.data.save)a.save=mist.data.save;mist.send(function(){UI.navto("Overview")},a)}}]}]));if(mist.data.LTS){var p=function(){var a=mist.stored.get().update||{};"uptodate"in a?a.error?f.addClass("red").text(a.error):a.uptodate?f.text("Your version is up to date.").addClass("green"):f.addClass("red").text("Version outdated!").append($("<button>").text("Update").css({"font-size":"1em","margin-left":"1em"}).click(function(){mist.send(function(){UI.navto("Overview")}, {type:"buttons",buttons:[{type:"save",label:"Save","function":function(){var a={config:mist.data.config};if(mist.data.save)a.save=mist.data.save;mist.send(function(){UI.navto("Overview")},a)}}]}]));if(mist.data.LTS){var p=function(){var a=mist.stored.get().update||{};"uptodate"in a?a.error?f.addClass("red").text(a.error):a.uptodate?f.text("Your version is up to date.").addClass("green"):f.addClass("red").text("Version outdated!").append($("<button>").text("Update").css({"font-size":"1em","margin-left":"1em"}).click(function(){mist.send(function(){UI.navto("Overview")},
{autoupdate:true})})):f.text("Unknown")};if(!mist.stored.get().update||864E5<(new Date).getTime()-mist.stored.get().update.lastchecked){var n=mist.stored.get().update||{};n.lastchecked=(new Date).getTime();mist.send(function(a){mist.stored.set("update",$.extend(true,n,a.update));p()},{checkupdate:!0})}else p()}else f.text("");var i=function(){mist.send(function(){v()},{totals:{fields:["clients"],start:-10},active_streams:true})},v=function(){l.text(("active_streams"in mist.data?mist.data.active_streams? {autoupdate:true})})):f.text("Unknown")};if(!mist.stored.get().update||864E5<(new Date).getTime()-mist.stored.get().update.lastchecked){var n=mist.stored.get().update||{};n.lastchecked=(new Date).getTime();mist.send(function(a){mist.stored.set("update",$.extend(true,n,a.update));p()},{checkupdate:!0})}else p()}else f.text("");var i=function(){mist.send(function(){v()},{totals:{fields:["clients"],start:-10},active_streams:true})},v=function(){l.text(("active_streams"in mist.data?mist.data.active_streams?
mist.data.active_streams.length:0:"?")+" active, "+(mist.data.streams?Object.keys(mist.data.streams).length:0)+" configured");if("totals"in mist.data&&"all_streams"in mist.data.totals)var a=mist.data.totals.all_streams.all_protocols.clients,a=a.length?UI.format.number(a[a.length-1][1]):0;else a="Loading..";m.text(a);e.text(UI.format.dateTime(mist.data.config.time,"long"))};i();v();UI.interval.set(i,3E4);break;case "Protocols":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)}, mist.data.active_streams.length:0:"?")+" active, "+(mist.data.streams?Object.keys(mist.data.streams).length:0)+" configured");if("totals"in mist.data&&"all_streams"in mist.data.totals)var a=mist.data.totals.all_streams.all_protocols.clients,a=a.length?UI.format.number(a[a.length-1][1]):0;else a="Loading..";m.text(a);e.text(UI.format.dateTime(mist.data.config.time,"long"))};i();v();UI.interval.set(i,3E4);break;case "Protocols":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},
{capabilities:!0});b.append("Loading..");break}var g=$("<tbody>");b.append(UI.buildUI([{type:"help",help:"You can find an overview of all the protocols and their relevant information here. You can add, edit or delete protocols."}])).append($("<button>").text("New protocol").click(function(){UI.navto("Edit Protocol")})).append($("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Protocol")).append($("<th>").text("Status")).append($("<th>").text("Settings")).append($("<th>")))).append(g)); {capabilities:!0});b.append("Loading..");break}var h=$("<tbody>");b.append(UI.buildUI([{type:"help",help:"You can find an overview of all the protocols and their relevant information here. You can add, edit or delete protocols."}])).append($("<button>").text("New protocol").click(function(){UI.navto("Edit Protocol")})).append($("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Protocol")).append($("<th>").text("Status")).append($("<th>").text("Settings")).append($("<th>")))).append(h));
var k=function(){function a(b){var c=mist.data.capabilities.connectors[b.connector];if(!c)return"";var d=[],e=["required","optional"],f;for(f in e)for(var g in c[e[f]])b[g]&&b[g]!=""?d.push(g+": "+b[g]):c[e[f]][g]["default"]&&d.push(g+": "+c[e[f]][g]["default"]);return $("<span>").addClass("description").text(d.join(", "))}g.html("");for(var b in mist.data.config.protocols){var c=mist.data.config.protocols[b];g.append($("<tr>").data("index",b).append($("<td>").text(c.connector)).append($("<td>").html(UI.format.status(c))).append($("<td>").html(a(c))).append($("<td>").css("text-align", var k=function(){function a(b){var c=mist.data.capabilities.connectors[b.connector];if(!c)return"";var d=[],e=["required","optional"],f;for(f in e)for(var g in c[e[f]])b[g]&&b[g]!=""?d.push(g+": "+b[g]):c[e[f]][g]["default"]&&d.push(g+": "+c[e[f]][g]["default"]);return $("<span>").addClass("description").text(d.join(", "))}h.html("");for(var b in mist.data.config.protocols){var c=mist.data.config.protocols[b];h.append($("<tr>").data("index",b).append($("<td>").text(c.connector)).append($("<td>").html(UI.format.status(c))).append($("<td>").html(a(c))).append($("<td>").css("text-align",
"right").html($("<button>").text("Edit").click(function(){UI.navto("Edit Protocol",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the protocol "'+mist.data.config.protocols[a].connector+'"?')){mist.data.config.protocols.splice(a,1);mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}}))))}};k();UI.interval.set(function(){mist.send(function(){k()})}, "right").html($("<button>").text("Edit").click(function(){UI.navto("Edit Protocol",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the protocol "'+mist.data.config.protocols[a].connector+'"?')){mist.data.config.protocols.splice(a,1);mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}}))))}};k();UI.interval.set(function(){mist.send(function(){k()})},
3E4);break;case "Edit Protocol":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});b.append("Loading..");break}var j=!1;""!=c&&0<=c&&(j=!0);var h=function(a){var b=mist.data.capabilities.connectors[a],d=mist.convertBuildOptions(b,o);d.push({type:"hidden",pointer:{main:o,index:"connector"},value:a});d.push({type:"buttons",buttons:[{type:"save",label:"Save","function":function(){if(j)mist.data.config.protocols[c]=o;else{if(!mist.data.config.protocols)mist.data.config.protocols= 3E4);break;case "Edit Protocol":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});b.append("Loading..");break}var j=!1;""!=c&&0<=c&&(j=!0);var g={},r;for(r in mist.data.config.protocols)g[mist.data.config.protocols[r].connector]=1;var O=function(a){var b=mist.data.capabilities.connectors[a],d=mist.convertBuildOptions(b,o);d.push({type:"hidden",pointer:{main:o,index:"connector"},value:a});d.push({type:"buttons",buttons:[{type:"save",label:"Save",
[];mist.data.config.protocols.push(o)}mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}},{type:"cancel",label:"Cancel","function":function(){UI.navto("Protocols")}}]});if("deps"in b&&b.deps!=""){$t=$("<span>").text("Dependencies:");$ul=$("<ul>");$t.append($ul);if(typeof b.deps=="string")b.deps=b.deps.split(", ");for(var e in b.deps){a=$("<li>").text(b.deps[e]+" ");$ul.append(a);typeof w[b.deps[e]]!="undefined"?a.append($("<span>").addClass("green").text("(Configured)")):a.append($("<span>").addClass("red").text("(Not yet configured)"))}d.unshift({type:"text", "function":function(){if(j)mist.data.config.protocols[c]=o;else{if(!mist.data.config.protocols)mist.data.config.protocols=[];mist.data.config.protocols.push(o)}mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}},{type:"cancel",label:"Cancel","function":function(){UI.navto("Protocols")}}]});if("deps"in b&&b.deps!=""){$t=$("<span>").text("Dependencies:");$ul=$("<ul>");$t.append($ul);if(typeof b.deps=="string")b.deps=b.deps.split(", ");for(var e in b.deps){a=$("<li>").text(b.deps[e]+
text:$t[0].innerHTML})}return UI.buildUI(d)},w={},r;for(r in mist.data.config.protocols)w[mist.data.config.protocols[r].connector]=1;if(j){var q=mist.data.config.protocols[c],o=q;b.find("h2").append(' "'+q.connector+'"');b.append(h(q.connector))}else{b.html($("<h2>").text("New Protocol"));var o={},t=[];for(r in mist.data.capabilities.connectors)t.push([r,r]);var P=$("<span>");b.append(UI.buildUI([{label:"Protocol",type:"select",select:t,"function":function(){P.html(h($(this).getval()))}}])).append(P)}break; " ");$ul.append(a);typeof g[b.deps[e]]!="undefined"||typeof g[b.deps[e]+".exe"]!="undefined"?a.append($("<span>").addClass("green").text("(Configured)")):a.append($("<span>").addClass("red").text("(Not yet configured)"))}d.unshift({type:"text",text:$t[0].innerHTML})}return UI.buildUI(d)},g={};for(r in mist.data.config.protocols)g[mist.data.config.protocols[r].connector]=1;if(j){var q=mist.data.config.protocols[c],o=q;b.find("h2").append(' "'+q.connector+'"');b.append(O(q.connector))}else{b.html($("<h2>").text("New Protocol"));
case "Streams":if(!("capabilities"in mist.data)){b.html("Loading..");mist.send(function(){UI.navto(a)},{capabilities:!0});break}g=$("<tbody>").append($("<tr>").append("<td>").attr("colspan",6).text("Loading.."));q=$("<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", var o={},t=[];for(r in mist.data.capabilities.connectors)t.push([r,r]);var P=$("<span>");b.append(UI.buildUI([{label:"Protocol",type:"select",select:t,"function":function(){P.html(O($(this).getval()))}}])).append(P)}break;case "Streams":if(!("capabilities"in mist.data)){b.html("Loading..");mist.send(function(){UI.navto(a)},{capabilities:!0});break}h=$("<tbody>").append($("<tr>").append("<td>").attr("colspan",6).text("Loading.."));q=$("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Stream name").attr("data-sort-type",
"right").text("Connections").attr("data-sort-type","int")).append($("<th>")).append($("<th>")))).append(g);b.append(UI.buildUI([{type:"help",help:"Here you can create, edit or delete new and existing streams. Immidiately go to the stream preview or view the information available about the stream with the info button."}])).append($("<button>").text("New stream").click(function(){UI.navto("Edit Stream")})).append(q);q.stupidtable();var D=function(){var a=[],b;for(b in mist.data.active_streams)a.push({streams:[mist.data.active_streams[b]], "string").addClass("sorting-asc")).append($("<th>").text("Source").attr("data-sort-type","string")).append($("<th>").text("Status").attr("data-sort-type","int")).append($("<th>").css("text-align","right").text("Connections").attr("data-sort-type","int")).append($("<th>")).append($("<th>")))).append(h);b.append(UI.buildUI([{type:"help",help:"Here you can create, edit or delete new and existing streams. Immidiately go to the stream preview or view the information available about the stream with the info button."}])).append($("<button>").text("New stream").click(function(){UI.navto("Edit Stream")})).append(q);
fields:["clients"],start:-10});mist.send(function(){var a=0;g.html("");if(mist.data.LTS)for(a in mist.data.active_streams){var b=mist.data.active_streams[a].split("+");if(!(b.length<2)&&b[0]in mist.data.streams){b=Q(mist.data.active_streams[a],mist.data.streams[b[0]]);b.online=1;z[mist.data.active_streams[a]]=b}}b=Object.keys(z);b.sort();for(var c in b){var d=b[c],e=z[d],f=$("<td>").css("text-align","right").html($("<span>").addClass("description").text("Loading..")),i=0;if(typeof mist.data.totals!= q.stupidtable();var C=function(){var a=[],b;for(b in mist.data.active_streams)a.push({streams:[mist.data.active_streams[b]],fields:["clients"],start:-10});mist.send(function(){var a=0;h.html("");if(mist.data.LTS)for(a in mist.data.active_streams){var b=mist.data.active_streams[a].split("+");if(!(b.length<2)&&b[0]in mist.data.streams){b=Q(mist.data.active_streams[a],mist.data.streams[b[0]]);b.online=1;y[mist.data.active_streams[a]]=b}}b=Object.keys(y);b.sort();for(var c in b){var d=b[c],e=y[d],f=$("<td>").css("text-align",
"undefined"&&typeof mist.data.totals[d]!="undefined"){i=mist.data.totals[d].all_protocols.clients;i=i.length?i[i.length-1][1]:0}f.html(UI.format.number(i));if(i==0&&e.online==1)e.online=2;i=$("<td>").css("text-align","right").css("white-space","nowrap");e.ischild||i.html($("<button>").text("Edit").click(function(){UI.navto("Edit Stream",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the stream "'+ "right").html($("<span>").addClass("description").text("Loading..")),g=0;if(typeof mist.data.totals!="undefined"&&typeof mist.data.totals[d]!="undefined"){g=mist.data.totals[d].all_protocols.clients;g=g.length?g[g.length-1][1]:0}f.html(UI.format.number(g));if(g==0&&e.online==1)e.online=2;g=$("<td>").css("text-align","right").css("white-space","nowrap");e.ischild||g.html($("<button>").text("Edit").click(function(){UI.navto("Edit Stream",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a=
a+'"?')){delete mist.data.streams[a];var b={};mist.data.LTS?b.deletestream=[a]:b.streams=mist.data.streams;mist.send(function(){UI.navto("Streams")},b)}}));var h=$("<span>").text(d);e.ischild&&h.css("padding-left","1em");g.append($("<tr>").data("index",d).html($("<td>").html(h).attr("title",d).addClass("overflow_ellipsis")).append($("<td>").text(e.source).attr("title",e.source).addClass("description").addClass("overflow_ellipsis").css("max-width","20em")).append($("<td>").data("sort-value",e.online).html(UI.format.status(e))).append(f).append($("<td>").html($("<button>").text("Preview").click(function(){UI.navto("Preview", $(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the stream "'+a+'"?')){delete mist.data.streams[a];var b={};mist.data.LTS?b.deletestream=[a]:b.streams=mist.data.streams;mist.send(function(){UI.navto("Streams")},b)}}));var i=$("<span>").text(d);e.ischild&&i.css("padding-left","1em");h.append($("<tr>").data("index",d).html($("<td>").html(i).attr("title",d).addClass("overflow_ellipsis")).append($("<td>").text(e.source).attr("title",e.source).addClass("description").addClass("overflow_ellipsis").css("max-width",
$(this).closest("tr").data("index"))}))).append(i));a++}},{totals:a,active_streams:true})},z=$.extend(!0,{},mist.data.streams),Q=function(a,b){var c=$.extend({},b);delete c.meta;delete c.error;c.online=2;c.name=a;c.ischild=true;return c};if(mist.data.LTS){var A=0,E=0;for(i in mist.data.streams)q=mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"],mist.inputMatch(q.source_match,mist.data.streams[i].source)&&(z[i].source+="*",mist.send(function(a,b){var c=b.stream,d;for(d in a.browse.files)for(var e in mist.data.capabilities.inputs)if(!(e.indexOf("Buffer")>= "20em")).append($("<td>").data("sort-value",e.online).html(UI.format.status(e))).append(f).append($("<td>").html($("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("tr").data("index"))}))).append(g));a++}},{totals:a,active_streams:true})},y=$.extend(!0,{},mist.data.streams),Q=function(a,b){var c=$.extend({},b);delete c.meta;delete c.error;c.online=2;c.name=a;c.ischild=true;return c};if(mist.data.LTS){var z=0,D=0;for(i in mist.data.streams)q=mist.data.capabilities.inputs.Folder||
0||e.indexOf("Folder")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[e].source_match,"/"+a.browse.files[d])){var f=c+"+"+a.browse.files[d];z[f]=Q(f,mist.data.streams[c]);z[f].source=mist.data.streams[c].source+a.browse.files[d]}E++;if(A==E){mist.send(function(){D()},{active_streams:true});UI.interval.set(function(){D()},3E4)}},{browse:mist.data.streams[i].source},{stream:i}),A++);0==A&&(mist.send(function(){D()},{active_streams:!0}),UI.interval.set(function(){D()},3E4))}else mist.send(function(){D()}, mist.data.capabilities.inputs["Folder.exe"],mist.inputMatch(q.source_match,mist.data.streams[i].source)&&(y[i].source+="*",mist.send(function(a,b){var c=b.stream,d;for(d in a.browse.files)for(var e in mist.data.capabilities.inputs)if(!(e.indexOf("Buffer")>=0||e.indexOf("Folder")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[e].source_match,"/"+a.browse.files[d])){var g=c+"+"+a.browse.files[d];y[g]=Q(g,mist.data.streams[c]);y[g].source=mist.data.streams[c].source+a.browse.files[d]}D++;if(z==D){mist.send(function(){C()},
{active_streams:!0}),UI.interval.set(function(){D()},3E4);break;case "Edit Stream":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});b.append("Loading..");break}j=!1;""!=c&&(j=!0);j?(q=c,o=mist.data.streams[q],b.find("h2").append(' "'+q+'"')):(b.html($("<h2>").text("New Stream")),o={});i=[];for(r in mist.data.capabilities.inputs)i.push(mist.data.capabilities.inputs[r].source_match);var F=$("<div>");b.append(UI.buildUI([{label:"Stream name",type:"str", {active_streams:true});UI.interval.set(function(){C()},3E4)}},{browse:mist.data.streams[i].source},{stream:i}),z++);0==z&&(mist.send(function(){C()},{active_streams:!0}),UI.interval.set(function(){C()},3E4))}else mist.send(function(){C()},{active_streams:!0}),UI.interval.set(function(){C()},3E4);break;case "Edit Stream":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});b.append("Loading..");break}j=!1;""!=c&&(j=!0);j?(q=c,o=mist.data.streams[q],
validate:["required","streamname"],pointer:{main:o,index:"name"},help:"Set the name this stream will be recognised by for players and/or stream pushing."},{label:"Source",type:"browse",validate:["required"],filetypes:i,pointer:{main:o,index:"source"},help:'Set the stream source.<br>VoD: You can browse to the file or folder as a source or simply enter the path to the file.<br>Live: You\u2019ll need to enter "push://IP" with the IP of the machine pushing towards MistServer. You can use "push://" to accept any source.<br>Pro only: use "push://(IP)@password" to set a password protection for pushes.<br>If you\'re unsure how to set the source properly please view our Live pushing guide at the tools section.', b.find("h2").append(' "'+q+'"')):(b.html($("<h2>").text("New Stream")),o={});i=[];for(r in mist.data.capabilities.inputs)i.push(mist.data.capabilities.inputs[r].source_match);var E=$("<div>");b.append(UI.buildUI([{label:"Stream name",type:"str",validate:["required","streamname"],pointer:{main:o,index:"name"},help:"Set the name this stream will be recognised by for players and/or stream pushing."},{label:"Source",type:"browse",validate:["required"],filetypes:i,pointer:{main:o,index:"source"},help:'Set the stream source.<br>VoD: You can browse to the file or folder as a source or simply enter the path to the file.<br>Live: You???ll need to enter "push://IP" with the IP of the machine pushing towards MistServer. You can use "push://" to accept any source.<br>Pro only: use "push://(IP)@password" to set a password protection for pushes.<br>If you\'re unsure how to set the source properly please view our Live pushing guide at the tools section.',
"function":function(){var a=$(this).val(),b=null,c;for(c in mist.data.capabilities.inputs)if(typeof mist.data.capabilities.inputs[c].source_match!="undefined"&&mist.inputMatch(mist.data.capabilities.inputs[c].source_match,a)){b=c;break}if(b===null)F.html($("<h3>").text("Unrecognized input")).append($("<span>").text("Please edit the stream source."));else{a=mist.data.capabilities.inputs[b];F.html($("<h3>").text(a.name+" Input options"));a=mist.convertBuildOptions(a,o);F.append(UI.buildUI(a))}}},$("<br>"), "function":function(){var a=$(this).val(),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)E.html($("<h3>").text("Unrecognized input")).append($("<span>").text("Please edit the stream source."));else{a=mist.data.capabilities.inputs[b];E.html($("<h3>").text(a.name+" Input options"));a=mist.convertBuildOptions(a,o);E.append(UI.buildUI(a))}}},$("<br>"),
{type:"custom",custom:F},$("<br>"),$("<h3>").text("Encryption"),{type:"help",help:"To enable encryption, the licence acquisition url must be entered, as well as either the content key or the key ID and seed.<br>Unsure how you should fill in your encryption or missing your preferred encryption? Please contact us."},{label:"License acquisition url",type:"str",LTSonly:!0,pointer:{main:o,index:"la_url"}},$("<br>"),{label:"Content key",type:"str",LTSonly:!0,pointer:{main:o,index:"contentkey"}},{type:"text", {type:"custom",custom:E},$("<br>"),$("<h3>").text("Encryption"),{type:"help",help:"To enable encryption, the licence acquisition url must be entered, as well as either the content key or the key ID and seed.<br>Unsure how you should fill in your encryption or missing your preferred encryption? Please contact us."},{label:"License acquisition url",type:"str",LTSonly:!0,pointer:{main:o,index:"la_url"}},$("<br>"),{label:"Content key",type:"str",LTSonly:!0,pointer:{main:o,index:"contentkey"}},{type:"text",
text:" - or - "},{label:"Key ID",type:"str",LTSonly:!0,pointer:{main:o,index:"keyid"}},{label:"Key seed",type:"str",LTSonly:!0,pointer:{main:o,index:"keyseed"}},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Streams")}},{type:"save",label:"Save","function":function(){if(!mist.data.streams)mist.data.streams={};mist.data.streams[o.name]=o;c!=o.name&&delete mist.data.streams[c];var a={};if(mist.data.LTS){a.addstream={};a.addstream[o.name]=o;if(c!=o.name)a.deletestream= text:" - or - "},{label:"Key ID",type:"str",LTSonly:!0,pointer:{main:o,index:"keyid"}},{label:"Key seed",type:"str",LTSonly:!0,pointer:{main:o,index:"keyseed"}},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Streams")}},{type:"save",label:"Save","function":function(){if(!mist.data.streams)mist.data.streams={};mist.data.streams[o.name]=o;c!=o.name&&delete mist.data.streams[c];var a={};if(mist.data.LTS){a.addstream={};a.addstream[o.name]=o;if(c!=o.name)a.deletestream=
[c]}else a.streams=mist.data.streams;mist.send(function(){UI.navto("Streams")},a)}}]}]));j&&(i={streams:{}},i.streams[q]=mist.data.streams[q].limits,b.append($("<h3>").text("Limits")).append(UI.buildLimits(i,a,c)));break;case "Preview":if(""==c){b.append("Loading..");var I=function(c){var d={};c.sort();b.html($("<h2>").text(a)).append(UI.buildUI([{label:"Select a stream",type:"select",select:c,pointer:{main:d,index:"stream"}},{type:"buttons",buttons:[{type:"save",label:"Go","function":function(){UI.navto(a, [c]}else a.streams=mist.data.streams;mist.send(function(){UI.navto("Streams")},a)}}]}]));j&&(i={streams:{}},i.streams[q]=mist.data.streams[q].limits,b.append($("<h3>").text("Limits")).append(UI.buildLimits(i,a,c)));break;case "Preview":if(""==c){b.append("Loading..");var H=function(c){var d={};c.sort();b.html($("<h2>").text(a)).append(UI.buildUI([{label:"Select a stream",type:"select",select:c,pointer:{main:d,index:"stream"}},{type:"buttons",buttons:[{type:"save",label:"Go","function":function(){UI.navto(a,
d.stream)}}]}]));UI.elements.secondary_menu.html("").append($("<a>").addClass("button").addClass("active").text("Choose stream").click(function(){UI.navto("Preview")}))};if(mist.data.LTS){if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});b.append("Loading..");break}E=A=0;t={};for(i in mist.data.streams)q=mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"],mist.inputMatch(q.source_match,mist.data.streams[i].source)&& d.stream)}}]}]));UI.elements.secondary_menu.html("").append($("<a>").addClass("button").addClass("active").text("Choose stream").click(function(){UI.navto("Preview")}))};if(mist.data.LTS){if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});b.append("Loading..");break}D=z=0;t={};for(i in mist.data.streams)q=mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"],mist.inputMatch(q.source_match,mist.data.streams[i].source)&&
(mist.send(function(a,b){var c=b.stream,d;for(d in mist.data.browse.files)for(var e in mist.data.capabilities.inputs)e.indexOf("Buffer")>=0||e.indexOf("Folder")>=0||mist.inputMatch(mist.data.capabilities.inputs[e].source_match,"/"+mist.data.browse.files[d])&&(t[c+"+"+mist.data.browse.files[d]]=true);E++;A==E&&mist.send(function(){for(var a in mist.data.active_streams){var b=mist.data.active_streams[a].split("+");b.length>1&&b[0]in mist.data.streams&&(t[mist.data.active_streams[a]]=true)}t=Object.keys(t); (mist.send(function(a,b){var c=b.stream,d;for(d in mist.data.browse.files)for(var e in mist.data.capabilities.inputs)e.indexOf("Buffer")>=0||e.indexOf("Folder")>=0||mist.inputMatch(mist.data.capabilities.inputs[e].source_match,"/"+mist.data.browse.files[d])&&(t[c+"+"+mist.data.browse.files[d]]=true);D++;z==D&&mist.send(function(){for(var a in mist.data.active_streams){var b=mist.data.active_streams[a].split("+");b.length>1&&b[0]in mist.data.streams&&(t[mist.data.active_streams[a]]=true)}t=Object.keys(t);
t=t.concat(Object.keys(mist.data.streams));t.sort();I(t)},{active_streams:true})},{browse:mist.data.streams[i].source},{stream:i}),A++);0==A&&mist.send(function(){var c=[],d;for(d in mist.data.active_streams){var e=mist.data.active_streams[d].split("+");e.length>1&&e[0]in mist.data.streams&&(c[mist.data.active_streams[d]]=true)}mist.data.streams&&(c=c.concat(Object.keys(mist.data.streams)));if(c.length==0)b.html($("<h2>").text(a)).append("Please set up a stream first.");else{c.sort();I(c)}},{active_streams:!0})}else I(Object.keys(mist.data.streams)); t=t.concat(Object.keys(mist.data.streams));t.sort();H(t)},{active_streams:true})},{browse:mist.data.streams[i].source},{stream:i}),z++);0==z&&mist.send(function(){var c=[],d;for(d in mist.data.active_streams){var e=mist.data.active_streams[d].split("+");e.length>1&&e[0]in mist.data.streams&&(c[mist.data.active_streams[d]]=true)}mist.data.streams&&(c=c.concat(Object.keys(mist.data.streams)));if(c.length==0)b.html($("<h2>").text(a)).append("Please set up a stream first.");else{c.sort();H(c)}},{active_streams:!0})}else H(Object.keys(mist.data.streams));
break}b.find("h2").append(' of "'+c+'"');i=":8080";for(r in mist.data.config.protocols)if(q=mist.data.config.protocols[r],"HTTP"==q.connector||"HTTP.exe"==q.connector)i=q.port?":"+q.port:":8080";var B={},q=$("<span>").hide();B["Embed urls"]=q;b.append(q);var d="",R=mist.user.host.match(/(https?)\:\/\/([^:\/]+)\:(\d+)?/i);null!=R&&(d=R[2]);var G="http://"+d+i+"/",C={},J=function(a){var b=["div"],d='\n <script src="'+G+"embed_"+c+'.js"><\/script>\n';a.autoplay&&b.push("data-autoplay");a.forceprotocol&& break}b.find("h2").append(' of "'+c+'"');i=":8080";for(r in mist.data.config.protocols)if(q=mist.data.config.protocols[r],"HTTP"==q.connector||"HTTP.exe"==q.connector)i=q.port?":"+q.port:":8080";var A={},q=$("<span>").hide();A["Embed urls"]=q;b.append(q);var d="",R=mist.user.host.match(/(https?)\:\/\/([^:\/]+)\:(\d+)?/i);null!=R&&(d=R[2]);var F="http://"+d+i+"/",B={},I=function(a){var b=["div"],d='\n <script src="'+F+"embed_"+c+'.js"><\/script>\n';a.autoplay&&b.push("data-autoplay");a.forceprotocol&&
a.forceprotocol!=""&&b.push('data-forcetype="'+a.forceprotocol+'"');return"<"+b.join(" ")+">"+d+"</div>"},S=$("<span>");q.append($("<h3>").text("Embed urls")).append(UI.buildUI([{label:"Embed url",type:"str",value:G+"embed_"+c+".js",readonly:!0,qrcode:!0},{label:"Info url",type:"str",value:G+"info_"+c+".js",qrcode:!0,readonly:!0},$("<h3>").text("Embed code"),{label:"Embed code",type:"textarea",value:J(C),rows:4,readonly:!0,classes:["embed_code"]},$("<h4>").text("Embed code options").css("margin-top", a.forceprotocol!=""&&b.push('data-forcetype="'+a.forceprotocol+'"');return"<"+b.join(" ")+">"+d+"</div>"},S=$("<span>");q.append($("<h3>").text("Embed urls")).append(UI.buildUI([{label:"Embed url",type:"str",value:F+"embed_"+c+".js",readonly:!0,qrcode:!0},{label:"Info url",type:"str",value:F+"info_"+c+".js",qrcode:!0,readonly:!0},$("<h3>").text("Embed code"),{label:"Embed code",type:"textarea",value:I(B),rows:4,readonly:!0,classes:["embed_code"]},$("<h4>").text("Embed code options").css("margin-top",
0),{label:"Autoplay",type:"checkbox",pointer:{main:C,index:"autoplay"},"function":function(){C.autoplay=$(this).getval();$(".embed_code").setval(J(C))}},{label:"Force protocol",type:"select",select:[["","Automatic"]],pointer:{main:C,index:"protocol"},classes:["embed_code_forceprotocol"],"function":function(){C.forceprotocol=$(this).getval();$(".embed_code").setval(J(C))}},$("<h3>").text("Protocol stream urls"),S]));i=$("<span>").append($("<h3>").text("Meta information")).hide();B["Meta information"]= 0),{label:"Autoplay",type:"checkbox",pointer:{main:B,index:"autoplay"},"function":function(){B.autoplay=$(this).getval();$(".embed_code").setval(I(B))}},{label:"Force protocol",type:"select",select:[["","Automatic"]],pointer:{main:B,index:"protocol"},classes:["embed_code_forceprotocol"],"function":function(){B.forceprotocol=$(this).getval();$(".embed_code").setval(I(B))}},$("<h3>").text("Protocol stream urls"),S]));i=$("<span>").append($("<h3>").text("Meta information")).hide();A["Meta information"]=
i;var K=$("<span>");i.append(K);b.append(i);var T=function(){var a;if(c in mist.data.streams)a=mist.data.streams[c].meta;if(a){var b=[];b.push({label:"Type",type:"span",value:a.live?"Live":"Pre-recorded (VoD)"});"format"in a&&b.push({label:"Format",type:"span",value:a.format});a.live&&b.push({label:"Buffer window",type:"span",value:UI.format.addUnit(a.buffer_window,"ms")});var d={vheader:"Audio",labels:["Codec","Duration","Average bitrate","Channels","Samplerate"],content:[]},e={vheader:"Video",labels:["Codec", i;var J=$("<span>");i.append(J);b.append(i);var T=function(){var a;if(c in mist.data.streams)a=mist.data.streams[c].meta;if(a){var b=[];b.push({label:"Type",type:"span",value:a.live?"Live":"Pre-recorded (VoD)"});"format"in a&&b.push({label:"Format",type:"span",value:a.format});a.live&&b.push({label:"Buffer window",type:"span",value:UI.format.addUnit(a.buffer_window,"ms")});var d={vheader:"Audio",labels:["Codec","Duration","Average bitrate","Channels","Samplerate"],content:[]},e={vheader:"Video",labels:["Codec",
"Duration","Average bitrate","Size","Framerate"],content:[]},f=Object.keys(a.tracks);f.sort(function(a,b){a=a.split("_").pop();b=b.split("_").pop();return a-b});for(var g in f){var i=f[g],h=a.tracks[i];switch(h.type){case "audio":d.content.push({header:"Track "+i.split("_").pop(),body:[h.codec,UI.format.duration((h.lastms-h.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(h.firstms/1E3)+" to "+UI.format.duration(h.lastms/1E3)+"</span>",UI.format.bytes(h.bps,1),h.channels,UI.format.addUnit(UI.format.number(h.rate), "Duration","Average bitrate","Size","Framerate"],content:[]},g=Object.keys(a.tracks);g.sort(function(a,b){a=a.split("_").pop();b=b.split("_").pop();return a-b});for(var f in g){var h=g[f],i=a.tracks[h];switch(i.type){case "audio":d.content.push({header:"Track "+h.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>",UI.format.bytes(i.bps,1),i.channels,UI.format.addUnit(UI.format.number(i.rate),
"Hz")]});break;case "video":e.content.push({header:"Track "+i.split("_").pop(),body:[h.codec,UI.format.duration((h.lastms-h.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(h.firstms/1E3)+" to "+UI.format.duration(h.lastms/1E3)+"</span>",UI.format.bytes(h.bps,1),UI.format.addUnit(h.width,"x ")+UI.format.addUnit(h.height,"px"),UI.format.addUnit(UI.format.number(h.fpks/1E3),"fps")]})}}a=UI.buildVheaderTable(d).css("width","auto");e=UI.buildVheaderTable(e).css("width","auto");b.push($("<span>").text("Tracks:")); "Hz")]});break;case "video":e.content.push({header:"Track "+h.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>",UI.format.bytes(i.bps,1),UI.format.addUnit(i.width,"x ")+UI.format.addUnit(i.height,"px"),UI.format.addUnit(UI.format.number(i.fpks/1E3),"fps")]})}}a=UI.buildVheaderTable(d).css("width","auto");e=UI.buildVheaderTable(e).css("width","auto");b.push($("<span>").text("Tracks:"));
b.push($("<div>").css({display:"flex","flex-flow":"row wrap","justify-content":"center","font-size":"0.9em"}).append(a).append(e));K.html(UI.buildUI(b))}else K.html("No meta information available.")};T();c in mist.data.streams&&!("meta"in mist.data.streams[c])&&mist.send(function(){T()});i=$("<span>").hide();B.Preview=i;b.append(i);var x=$("<div>").css("float","left").css("margin-right","1em").attr("data-forcesupportcheck",""),U=$("<div>").css("float","left");i.append(x).append(U);mist.stored.get().autoplay&& b.push($("<div>").css({display:"flex","flex-flow":"row wrap","justify-content":"center","font-size":"0.9em"}).append(a).append(e));J.html(UI.buildUI(b))}else J.html("No meta information available.")};T();c in mist.data.streams&&!("meta"in mist.data.streams[c])&&mist.send(function(){T()});i=$("<span>").hide();A.Preview=i;b.append(i);var w=$("<div>").css("float","left").css("margin-right","1em").attr("data-forcesupportcheck",""),U=$("<div>").css("float","left");i.append(w).append(U);mist.stored.get().autoplay&&
x.attr("data-autoplay","");var H=function(){x.text("Loading..");var a=document.createElement("script");a.src=G+"embed_"+c+".js";a.onerror=function(){x.html('Error loading "'+a.src+'".<br>').append($("<button>").text("Try again").click(function(){H()}))};a.onload=function(){if(typeof mistvideo[c].error!="undefined")x.html(mistvideo[c].error+"<br>").append($("<button>").text("Try again").click(function(){H()}));else{var a=mistvideo[c],b=UI.buildUI([{label:"Protocol stream url",type:"str",readonly:true, w.attr("data-autoplay","");var G=function(){w.text("Loading..");var a=document.createElement("script");a.src=F+"embed_"+c+".js";a.onerror=function(){w.html('Error loading "'+a.src+'".<br>').append($("<button>").text("Try again").click(function(){G()}))};a.onload=function(){if(typeof mistvideo[c].error!="undefined")w.html(mistvideo[c].error+"<br>").append($("<button>").text("Try again").click(function(){G()}));else{var a=mistvideo[c],b=UI.buildUI([{label:"Protocol stream url",type:"str",readonly:true,
value:a.embedded?a.embedded.url:"",qrcode:true},{label:"Autoplay (from now on)",type:"checkbox",value:mist.stored.get().autoplay,"function":function(){mist.stored.set("autoplay",$(this).getval()?1:0)}}]);b.find(".help_container").remove();x.append(b);var d=$("<table>").css("font-size","0.9em").html($("<thead>").html($("<tr>").html($("<th>")).append($("<th>").text("Type")).append($("<th>").text("Priority")).append($("<th>").text("Simul. tracks")).append($("<th>").html("Your browser<br>support")))); value:a.embedded?a.embedded.url:"",qrcode:true},{label:"Autoplay (from now on)",type:"checkbox",value:mist.stored.get().autoplay,"function":function(){mist.stored.set("autoplay",$(this).getval()?1:0)}}]);b.find(".help_container").remove();w.append(b);var d=$("<table>").css("font-size","0.9em").html($("<thead>").html($("<tr>").html($("<th>")).append($("<th>").text("Type")).append($("<th>").text("Priority")).append($("<th>").text("Simul. tracks")).append($("<th>").html("Your browser<br>support"))));
U.html(d);b=$("<tbody>");d.append(b);var d=$(".embed_code_forceprotocol"),e=[];d.find(".clear").remove();for(var f in a.source){var h=a.source[f],g=h.type.split("/"),i=g[0];i.length<6&&(i=i.toUpperCase());switch(g.length){case 1:break;case 2:i=UI.format.capital(g[0])+" v"+g[1];if(g[0]=="flash")switch(g[1]){case "7":i="Progressive ("+i+")";break;case "10":i="RTMP ("+i+")";break;case "11":i="HDS ("+i+")"}break;case 3:switch(g[2]){case "vnd.apple.mpegurl":i=i+" HLS";break;case "vnd.ms-ss":i=i+" Smooth"; U.html(d);b=$("<tbody>");d.append(b);var d=$(".embed_code_forceprotocol"),e=[];d.find(".clear").remove();for(var g in a.source){var f=a.source[g],i=f.type.split("/"),h=i[0];h.length<6&&(h=h.toUpperCase());switch(i.length){case 1:break;case 2:h=UI.format.capital(i[0])+" v"+i[1];if(i[0]=="flash")switch(i[1]){case "7":h="Progressive ("+h+")";break;case "10":h="RTMP ("+h+")";break;case "11":h="HDS ("+h+")"}break;case 3:switch(i[2]){case "vnd.apple.mpegurl":h=h+" HLS";break;case "vnd.ms-ss":h=h+" Smooth";
break;case "mp2t":i=i+" TS";break;default:g[2].length<6&&(g[2]=g[2].toUpperCase());i=i+(" "+g[2]);g[1]!="video"&&(i=i+(" ("+g[1]+")"))}break;default:i=h.type}i=UI.format.capital(i);d.append($("<option>").text(i).val(h.type).addClass("clear"));e.push({label:i,type:"str",value:h.url,readonly:true,qrcode:true});g=$("<tr>");b.append(g);g.html($("<td>").html($("<input>").attr("type","radio").attr("name","protocolforce").change(function(){x.attr("data-forcetype",$(this).val()).html("Loading embed..");H()}).val(h.type))).append($("<td>").text(i)).append($("<td>").text(h.priority)).append($("<td>").text(h.simul_tracks+ break;case "mp2t":h=h+" TS";break;default:i[2].length<6&&(i[2]=i[2].toUpperCase());h=h+(" "+i[2]);i[1]!="video"&&(h=h+(" ("+i[1]+")"))}break;default:h=f.type}h=UI.format.capital(h);d.append($("<option>").text(h).val(f.type).addClass("clear"));e.push({label:h,type:"str",value:f.url,readonly:true,qrcode:true});i=$("<tr>");b.append(i);i.html($("<td>").html($("<input>").attr("type","radio").attr("name","protocolforce").change(function(){w.attr("data-forcetype",$(this).val()).html("Loading embed..");G()}).val(f.type))).append($("<td>").text(h)).append($("<td>").text(f.priority)).append($("<td>").text(f.simul_tracks+
"/"+h.total_matches)).append($("<td>").text(h.browser_support?"yes":"no"));if(a.embedded&&a.embedded.type==h.type){g.css("outline","1px solid rgba(0,0,0,0.5)");g.find("input[type=radio]").prop("checked",true)}}S.html(UI.buildUI(e))}};x.html("")[0].appendChild(a)};H();var L=UI.elements.secondary_menu;L.html("").append($("<a>").addClass("button").text("Choose stream").click(function(){UI.navto("Preview")})).append($("<span>").addClass("separator"));i=["Preview","Embed urls","Meta information"];w=i[0]; "/"+f.total_matches)).append($("<td>").text(f.browser_support?"yes":"no"));if(a.embedded&&a.embedded.type==f.type){i.css("outline","1px solid rgba(0,0,0,0.5)");i.find("input[type=radio]").prop("checked",true)}}S.html(UI.buildUI(e))}};w.html("")[0].appendChild(a)};G();var K=UI.elements.secondary_menu;K.html("").append($("<a>").addClass("button").text("Choose stream").click(function(){UI.navto("Preview")})).append($("<span>").addClass("separator"));i=["Preview","Embed urls","Meta information"];g=i[0];
for(r in i)q=$("<a>").addClass("button").text(i[r]).click(function(){L.find(".active").removeClass("active");$(this).addClass("active");for(r in B)B[r].hide();B[$(this).text()].show()}),L.append(q),i[r]==w&&(q.addClass("active"),B[w].show());break;case "Limits":b.append(UI.buildUI([{type:"help",help:"Here you can see an overview of all the limits you currently have. Limits are an LTS only feature and you can simply add new limits by selecting new, by selecting edit you can edit the existing limit, by selecting delete you can delete the existing limit."}])); for(r in i)q=$("<a>").addClass("button").text(i[r]).click(function(){K.find(".active").removeClass("active");$(this).addClass("active");for(r in A)A[r].hide();A[$(this).text()].show()}),K.append(q),i[r]==g&&(q.addClass("active"),A[g].show());break;case "Limits":b.append(UI.buildUI([{type:"help",help:"Here you can see an overview of all the limits you currently have. Limits are an LTS only feature and you can simply add new limits by selecting new, by selecting edit you can edit the existing limit, by selecting delete you can delete the existing limit."}]));
i={server:mist.data.config.limits,streams:{}};for(r in mist.data.streams)"limits"in mist.data.streams[r]&&(i.streams[r]=mist.data.streams[r].limits);b.append(UI.buildLimits(i,a,c));break;case "Edit Limit":j=!1;""!=c&&(j=!0);o={};i=[{type:"help",help:"Here you can set the limit specifications, soft limits only warn while hard limits restrict access. Please feel free to set up limits according to your preferences."}];"Overview"==UI.returnTab[0]&&(UI.returnTab=["Limits"]);if(j){q=c.split("^");d=a;switch(q[0]){case "server":o= i={server:mist.data.config.limits,streams:{}};for(r in mist.data.streams)"limits"in mist.data.streams[r]&&(i.streams[r]=mist.data.streams[r].limits);b.append(UI.buildLimits(i,a,c));break;case "Edit Limit":j=!1;""!=c&&(j=!0);o={};i=[{type:"help",help:"Here you can set the limit specifications, soft limits only warn while hard limits restrict access. Please feel free to set up limits according to your preferences."}];"Overview"==UI.returnTab[0]&&(UI.returnTab=["Limits"]);if(j){q=c.split("^");d=a;switch(q[0]){case "server":o=
mist.data.config.limits[q[1]];d="For the entire server";break;case "stream":o=mist.data.streams[q[1]].limits[q[2]],d='For the stream "'+q[1]+'"'}i.push({type:"text",text:d})}else{b.html($("<h2>").text("New limit"));var y=[];for(r in mist.data.streams)y.push(r);t=[["server","The entire server"],["stream","The stream:",y]];q={label:"Applies to",type:"radioselect",radioselect:t,pointer:{main:o,index:"applies_to"},LTSonly:!0,validate:["required"]};"Edit Stream"==UI.returnTab[0]&&UI.returnTab[1]&&(q.value= mist.data.config.limits[q[1]];d="For the entire server";break;case "stream":o=mist.data.streams[q[1]].limits[q[2]],d='For the stream "'+q[1]+'"'}i.push({type:"text",text:d})}else{b.html($("<h2>").text("New limit"));var x=[];for(r in mist.data.streams)x.push(r);t=[["server","The entire server"],["stream","The stream:",x]];q={label:"Applies to",type:"radioselect",radioselect:t,pointer:{main:o,index:"applies_to"},LTSonly:!0,validate:["required"]};"Edit Stream"==UI.returnTab[0]&&UI.returnTab[1]&&(q.value=
["stream",UI.returnTab[1]],q.readonly=!0);i.push(q)}var i=i.concat([$("<br>"),{label:"Kind",type:"select",select:[["soft","Soft"],["hard","Hard"]],pointer:{main:o,index:"type"},help:"The server will not allow a hard limit to be passed. A soft limit can be used to set alerts.",LTSonly:!0,validate:["required"]},{label:"Value",pointer:{main:o,index:"value"},classes:["limit_value"],LTSonly:!0},{label:"Type",type:"select",select:[["kbps_max","Maximum bandwidth"],["users","Maximum connected users"],["geo", ["stream",UI.returnTab[1]],q.readonly=!0);i.push(q)}var i=i.concat([$("<br>"),{label:"Kind",type:"select",select:[["soft","Soft"],["hard","Hard"]],pointer:{main:o,index:"type"},help:"The server will not allow a hard limit to be passed. A soft limit can be used to set alerts.",LTSonly:!0,validate:["required"]},{label:"Value",pointer:{main:o,index:"value"},classes:["limit_value"],LTSonly:!0},{label:"Type",type:"select",select:[["kbps_max","Maximum bandwidth"],["users","Maximum connected users"],["geo",
"Geo limited"],["host","Host limited"]],pointer:{main:o,index:"name"},LTSonly:!0,validate:["required"],classes:["limit_type"],"function":function(){var a=$(this).getval(),b=$(this).closest(".input_container").find(".limit_value"),c=b.closest("label"),b=b.data("opts");delete b.type;delete b.min;delete b.unit;b.validate=["required"];switch(a){case "kbps_max":b.type="int";b.min=1;b.unit="bytes/s";break;case "users":b.type="int";b.min=1;break;case "geo":b.type="geolimited";break;case "host":b.type="hostlimited"}a= "Geo limited"],["host","Host limited"]],pointer:{main:o,index:"name"},LTSonly:!0,validate:["required"],classes:["limit_type"],"function":function(){var a=$(this).getval(),b=$(this).closest(".input_container").find(".limit_value"),c=b.closest("label"),b=b.data("opts");delete b.type;delete b.min;delete b.unit;b.validate=["required"];switch(a){case "kbps_max":b.type="int";b.min=1;b.unit="bytes/s";break;case "users":b.type="int";b.min=1;break;case "geo":b.type="geolimited";break;case "host":b.type="hostlimited"}a=
UI.buildUI([b]);c.replaceWith(a.children())}},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto(UI.returnTab[0],UI.returnTab[1])}},{type:"save",label:"Save","function":function(){var a={};if(j){var b=c.split("^");switch(b[0]){case "server":a={config:{limits:mist.data.config.limits}};break;case "stream":if(mist.data.LTS){a={addstream:{}};a.addstream[b[1]]=mist.data.streams[b[1]]}else a={streams:mist.data.streams}}}else{b=o.applies_to;delete o.applies_to;switch(b[0]){case "server":if(!mist.data.config.limits)mist.data.config.limits= UI.buildUI([b]);c.replaceWith(a.children())}},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto(UI.returnTab[0],UI.returnTab[1])}},{type:"save",label:"Save","function":function(){var a={};if(j){var b=c.split("^");switch(b[0]){case "server":a={config:{limits:mist.data.config.limits}};break;case "stream":if(mist.data.LTS){a={addstream:{}};a.addstream[b[1]]=mist.data.streams[b[1]]}else a={streams:mist.data.streams}}}else{b=o.applies_to;delete o.applies_to;switch(b[0]){case "server":if(!mist.data.config.limits)mist.data.config.limits=
[];mist.data.config.limits.push(o);a={config:{limits:mist.data.config.limits}};break;case "stream":if(typeof mist.data.streams[b[1]].limits=="undefined")mist.data.streams[b[1]].limits=[];mist.data.streams[b[1]].limits.push(o);if(mist.data.LTS){a={addstream:{}};a.addstream[b[1]]=mist.data.streams[b[1]]}else a={streams:mist.data.streams}}}mist.send(function(){UI.navto(UI.returnTab[0],UI.returnTab[1])},a)}}]}]),u=UI.buildUI(i);b.append(u);u.find(".limit_type").closest("label").after(u.find(".limit_value").closest("label")); [];mist.data.config.limits.push(o);a={config:{limits:mist.data.config.limits}};break;case "stream":if(typeof mist.data.streams[b[1]].limits=="undefined")mist.data.streams[b[1]].limits=[];mist.data.streams[b[1]].limits.push(o);if(mist.data.LTS){a={addstream:{}};a.addstream[b[1]]=mist.data.streams[b[1]]}else a={streams:mist.data.streams}}}mist.send(function(){UI.navto(UI.returnTab[0],UI.returnTab[1])},a)}}]}]),u=UI.buildUI(i);b.append(u);u.find(".limit_type").closest("label").after(u.find(".limit_value").closest("label"));
u.find(".limit_type").trigger("change");break;case "Logs":b.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(){clearInterval(UI.interval);UI.interval.set(function(){mist.send(function(){V()})},$(this).val()* u.find(".limit_type").trigger("change");break;case "Logs":b.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(){clearInterval(UI.interval);UI.interval.set(function(){mist.send(function(){V()})},$(this).val()*
1E3)}}]));b.append($("<button>").text("Purge logs").click(function(){mist.send(function(){mist.data.log=[];UI.navto("Logs")},{clearstatlogs:true})}));g=$("<tbody>").css("font-size","0.9em");b.append($("<table>").append(g));var X=function(a){var b=$("<span>").text(a);switch(a){case "WARN":b.addClass("orange");break;case "ERROR":case "FAIL":b.addClass("red")}return b},V=function(){var a=mist.data.log;if(a){a.length>=2&&a[0][0]<a[a.length-1][0]&&a.reverse();g.html("");for(var b in a)g.append($("<tr>").html($("<td>").text(UI.format.dateTime(a[b][0], 1E3)}}]));b.append($("<button>").text("Purge logs").click(function(){mist.send(function(){mist.data.log=[];UI.navto("Logs")},{clearstatlogs:true})}));h=$("<tbody>").css("font-size","0.9em");b.append($("<table>").append(h));var X=function(a){var b=$("<span>").text(a);switch(a){case "WARN":b.addClass("orange");break;case "ERROR":case "FAIL":b.addClass("red")}return b},V=function(){var a=mist.data.log;if(a){a.length>=2&&a[0][0]<a[a.length-1][0]&&a.reverse();h.html("");for(var b in a)h.append($("<tr>").html($("<td>").text(UI.format.dateTime(a[b][0],
"long")).css("white-space","nowrap")).append($("<td>").html(X(a[b][1])).css("text-align","center")).append($("<td>").text(a[b][2]).css("text-align","left")))}};V();break;case "Statistics":u=$("<span>").text("Loading..");b.append(u);var o={},s=mist.stored.get().graphs?$.extend(!0,{},mist.stored.get().graphs):{},y={};for(r in mist.data.streams)y[r]=!0;for(r in mist.data.active_streams)y[mist.data.active_streams[r]]=!0;var y=Object.keys(y).sort(),M=[];for(r in mist.data.config.protocols)M.push(mist.data.config.protocols[r].connector); "long")).css("white-space","nowrap")).append($("<td>").html(X(a[b][1])).css("text-align","center")).append($("<td>").text(a[b][2]).css("text-align","left")))}};V();break;case "Statistics":u=$("<span>").text("Loading..");b.append(u);var o={},s=mist.stored.get().graphs?$.extend(!0,{},mist.stored.get().graphs):{},x={};for(r in mist.data.streams)x[r]=!0;for(r in mist.data.active_streams)x[mist.data.active_streams[r]]=!0;var x=Object.keys(x).sort(),L=[];for(r in mist.data.config.protocols)L.push(mist.data.config.protocols[r].connector);
M.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;u.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", L.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;u.html(UI.buildUI([{type:"help",help:"Here you will find the MistServer stream statistics, you can select various categories yourself. All statistics are live: up to five minutes are saved."},$("<h3>").text("Select the data to display"),{label:"Add to",type:"select",select:[["new",
"New graph"]],pointer:{main:o,index:"graph"},classes:["graph_ids"],"function":function(){if($(this).val()){var a=u.find(".graph_xaxis"),b=u.find(".graph_id");if($(this).val()=="new"){a.children("option").prop("disabled",false);b.setval("Graph "+(Object.keys(s).length+1)).closest("label").show()}else{var c=s[$(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&& "New graph"]],pointer:{main:o,index:"graph"},classes:["graph_ids"],"function":function(){if($(this).val()){var a=u.find(".graph_xaxis"),b=u.find(".graph_id");if($(this).val()=="new"){a.children("option").prop("disabled",false);b.setval("Graph "+(Object.keys(s).length+1)).closest("label").show()}else{var c=s[$(this).val()].xaxis;a.children("option").prop("disabled",true).filter('[value="'+c+'"]').prop("disabled",false);b.closest("label").hide()}a.children('option[value="'+a.val()+'"]:disabled').length&&
a.val(a.children("option:enabled").first().val());a.trigger("change")}}},{label:"Graph id",type:"str",pointer:{main:o,index:"id"},classes:["graph_id"],validate:[function(a){return a in s?{msg:"This graph id has already been used. Please enter something else.",classes:["red"]}:false}]},{label:"Axis type",type:"select",select:[["time","Time line"],["coords","Geographical"]],pointer:{main:o,index:"xaxis"},classes:["graph_xaxis"],"function":function(){$s=u.find(".graph_datatype");switch($(this).getval()){case "coords":$s.children("option").prop("disabled", a.val(a.children("option:enabled").first().val());a.trigger("change")}}},{label:"Graph id",type:"str",pointer:{main:o,index:"id"},classes:["graph_id"],validate:[function(a){return a in s?{msg:"This graph id has already been used. Please enter something else.",classes:["red"]}:false}]},{label:"Axis type",type:"select",select:[["time","Time line"],["coords","Geographical"]],pointer:{main:o,index:"xaxis"},classes:["graph_xaxis"],"function":function(){$s=u.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 load"],["memload","Memory load"],["coords", 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 load"],["memload","Memory load"],["coords",
"Client location"]],pointer:{main:o,index:"datatype"},classes:["graph_datatype"],"function":function(){$s=u.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:",y],["protocol", "Client location"]],pointer:{main:o,index:"datatype"},classes:["graph_datatype"],"function":function(){$s=u.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:",x],["protocol",
"The protocol:",M]],pointer:{main:o,index:"origin"},value:["total"],classes:["graph_origin"]},{type:"buttons",buttons:[{label:"Add data set",type:"save","function":function(){var a;if(o.graph=="new"){a=UI.plot.addGraph(o,c);s[a.id]=a;u.find("select.graph_ids").append($("<option>").text(a.id)).val(a.id).trigger("change")}else a=s[o.graph];var b=UI.plot.datatype.getOptions({datatype:o.datatype,origin:o.origin});a.datasets.push(b);UI.plot.save(a);UI.plot.go(s)}}]}]));var c=$("<div>").addClass("graph_container"); "The protocol:",L]],pointer:{main:o,index:"origin"},value:["total"],classes:["graph_origin"]},{type:"buttons",buttons:[{label:"Add data set",type:"save","function":function(){var a;if(o.graph=="new"){a=UI.plot.addGraph(o,c);s[a.id]=a;u.find("select.graph_ids").append($("<option>").text(a.id)).val(a.id).trigger("change")}else a=s[o.graph];var b=UI.plot.datatype.getOptions({datatype:o.datatype,origin:o.origin});a.datasets.push(b);UI.plot.save(a);UI.plot.go(s)}}]}]));var c=$("<div>").addClass("graph_container");
b.append(c);var d=u.find("select.graph_ids");for(a in s){var e=UI.plot.addGraph(s[a],c);d.append($("<option>").text(e.id)).val(e.id);var f=[],i;for(i in s[a].datasets){var g=UI.plot.datatype.getOptions({datatype:s[a].datasets[i].datatype,origin:s[a].datasets[i].origin});f.push(g)}e.datasets=f;s[e.id]=e}d.trigger("change");UI.plot.go(s);UI.interval.set(function(){UI.plot.go(s)},1E4)},{active_streams:!0,capabilities:!0});break;case "Server Stats":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)}, b.append(c);var d=u.find("select.graph_ids");for(a in s){var e=UI.plot.addGraph(s[a],c);d.append($("<option>").text(e.id)).val(e.id);var f=[],g;for(g in s[a].datasets){var h=UI.plot.datatype.getOptions({datatype:s[a].datasets[g].datatype,origin:s[a].datasets[g].origin});f.push(h)}e.datasets=f;s[e.id]=e}d.trigger("change");UI.plot.go(s);UI.interval.set(function(){UI.plot.go(s)},1E4)},{active_streams:!0,capabilities:!0});break;case "Server Stats":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},
{capabilities:!0});b.append("Loading..");break}var N=$("<table>"),O=$("<table>"),i={vheader:"CPUs",labels:["Model","Processor speed","Amount of cores","Amount of threads"],content:[]};for(r in mist.data.capabilities.cpu)q=mist.data.capabilities.cpu[r],i.content.push({header:"CPU #"+(Number(r)+1),body:[q.model,UI.format.addUnit(UI.format.number(q.mhz),"MHz"),q.cores,q.threads]});var i=UI.buildVheaderTable(i),W=function(){var a=mist.data.capabilities.mem,b=mist.data.capabilities.load,a={vheader:"Memory", {capabilities:!0});b.append("Loading..");break}var M=$("<table>"),N=$("<table>"),i={vheader:"CPUs",labels:["Model","Processor speed","Amount of cores","Amount of threads"],content:[]};for(r in mist.data.capabilities.cpu)q=mist.data.capabilities.cpu[r],i.content.push({header:"CPU #"+(Number(r)+1),body:[q.model,UI.format.addUnit(UI.format.number(q.mhz),"MHz"),q.cores,q.threads]});var i=UI.buildVheaderTable(i),W=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);N.replaceWith(a);N=a;b={vheader:"Load average", 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);M.replaceWith(a);M=a;b={vheader:"Load average",
labels:["1 minute","5 minutes","15 minutes",""],content:[{header:"&nbsp;",body:[UI.format.number(b.one/100),UI.format.number(b.five/100),UI.format.number(b.fifteen/100),""]}]};b=UI.buildVheaderTable(b);O.replaceWith(b);O=b};W();b.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(N)).append($("<td>").append(O))).append($("<tr>").append($("<td>").append(i).attr("colspan", labels:["1 minute","5 minutes","15 minutes",""],content:[{header:"&nbsp;",body:[UI.format.number(b.one/100),UI.format.number(b.five/100),UI.format.number(b.fifteen/100),""]}]};b=UI.buildVheaderTable(b);N.replaceWith(b);N=b};W();b.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(M)).append($("<td>").append(N))).append($("<tr>").append($("<td>").append(i).attr("colspan",
2))));UI.interval.set(function(){mist.send(function(){W()},{capabilities:true})},3E4);break;case "Email for Help":i=$.extend({},mist.data);delete i.statistics;delete i.totals;delete i.clients;delete i.capabilities;i=JSON.stringify(i);i="Version: "+mist.data.config.version+"\n\nConfig:\n"+i;o={};b.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", 2))));UI.interval.set(function(){mist.send(function(){W()},{capabilities:true})},3E4);break;case "Email for Help":i=$.extend({},mist.data);delete i.statistics;delete i.totals;delete i.clients;delete i.capabilities;i=JSON.stringify(i);i="Version: "+mist.data.config.version+"\n\nConfig:\n"+i;o={};b.append(UI.buildUI([{type:"help",help:"You can use this form to email MistServer support if you're having difficulties.<br>A copy of your server config file will automatically be included."},{type:"str",label:"Your name",
validate:["required"],pointer:{main:o,index:"name"},value:mist.user.name},{type:"email",label:"Your email address",validate:["required"],pointer:{main:o,index:"email"}},{type:"hidden",value:"Integrated Help",pointer:{main:o,index:"subject"}},{type:"hidden",value:"-",pointer:{main:o,index:"company"}},{type:"textarea",rows:20,label:"Your message",validate:["required"],pointer:{main:o,index:"message"}},{type:"textarea",rows:20,label:"Your config file",readonly:!0,value:i,pointer:{main:o,index:"configfile"}}, validate:["required"],pointer:{main:o,index:"name"},value:mist.user.name},{type:"email",label:"Your email address",validate:["required"],pointer:{main:o,index:"email"}},{type:"hidden",value:"Integrated Help",pointer:{main:o,index:"subject"}},{type:"hidden",value:"-",pointer:{main:o,index:"company"}},{type:"textarea",rows:20,label:"Your message",validate:["required"],pointer:{main:o,index:"message"}},{type:"textarea",rows:20,label:"Your config file",readonly:!0,value:i,pointer:{main:o,index:"configfile"}},
{type:"buttons",buttons:[{type:"save",label:"Send","function":function(a){$(a).text("Sending..");$.ajax({type:"POST",url:"http://mistserver.org/contact_us?skin=plain",data:o,success:function(a){a=$("<span>").html(a);a.find("script").remove();b.html(a[0].innerHTML)}})}}]}]));break;case "Disconnect":mist.user.password="";delete mist.user.authstring;delete mist.user.loggedin;UI.navto("Login");break;default:b.append($("<p>").text("This tab does not exist."))}}}},mist={data:{},user:{name:"",password:"", {type:"buttons",buttons:[{type:"save",label:"Send","function":function(a){$(a).text("Sending..");$.ajax({type:"POST",url:"http://mistserver.org/contact_us?skin=plain",data:o,success:function(a){a=$("<span>").html(a);a.find("script").remove();b.html(a[0].innerHTML)}})}}]}]));break;case "Disconnect":mist.user.password="";delete mist.user.authstring;delete mist.user.loggedin;UI.navto("Login");break;default:b.append($("<p>").text("This tab does not exist."))}}}},mist={data:{},user:{name:"",password:"",
host:"http://"+(location.hostname?location.hostname:"localhost")+":4242/api"},send:function(a,c,b){var c=c||{},b=b||{},b=$.extend(!0,{timeout:30,sendData:c},b),d={authorize:{password:mist.user.authstring?MD5(MD5(mist.user.password)+mist.user.authstring):"",username:mist.user.name}};$.extend(!0,d,c);log("Send",$.extend(!0,{},c));d={url:mist.user.host,type:"POST",data:{command:JSON.stringify(d)},dataType:"jsonp",crossDomain:!0,timeout:1E3*b.timeout,async:!0,error:function(d,f){delete mist.user.loggedin; host:"http://"+(location.hostname?location.hostname:"localhost")+":4242/api"},send:function(a,c,b){var c=c||{},b=b||{},b=$.extend(!0,{timeout:30,sendData:c},b),d={authorize:{password:mist.user.authstring?MD5(MD5(mist.user.password)+mist.user.authstring):"",username:mist.user.name}};$.extend(!0,d,c);log("Send",$.extend(!0,{},c));d={url:mist.user.host,type:"POST",data:{command:JSON.stringify(d)},dataType:"jsonp",crossDomain:!0,timeout:1E3*b.timeout,async:!0,error:function(d,f){delete mist.user.loggedin;
if(!b.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(f).append($("<a>").text("Send server request again").click(function(){mist.send(a,c,b)}))}UI.navto("Login")},success:function(d){log("Receive",$.extend(!0, if(!b.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(f).append($("<a>").text("Send server request again").click(function(){mist.send(a,c,b)}))}UI.navto("Login")},success:function(d){log("Receive",$.extend(!0,
{},d),"as reply to",b.sendData);delete mist.user.loggedin;switch(d.authorize.status){case "OK":$.extend(!0,mist.data,d);mist.data.streams=d.streams;mist.data.config.protocols=d.config.protocols;mist.data.config.limits=d.config.limits;mist.user.loggedin=!0;UI.elements.connection.status.text("Connected").removeClass("red").addClass("green");UI.elements.connection.user_and_host.text(mist.user.name+" @ "+mist.user.host);UI.elements.connection.msg.removeClass("red").text("Last communication with the server at "+ {},d),"as reply to",b.sendData);delete mist.user.loggedin;switch(d.authorize.status){case "OK":$.extend(!0,mist.data,d);mist.data.streams=d.streams;mist.data.config.protocols=d.config.protocols;mist.data.config.limits=d.config.limits;mist.user.loggedin=!0;UI.elements.connection.status.text("Connected").removeClass("red").addClass("green");UI.elements.connection.user_and_host.text(mist.user.name+" @ "+mist.user.host);UI.elements.connection.msg.removeClass("red").text("Last communication with the server at "+
UI.format.time((new Date).getTime()/1E3));d.LTS&&UI.elements.menu.find(".LTSonly").removeClass("LTSonly");if(d.log){var f=d.log[d.log.length-1];UI.elements.connection.msg.append($("<br>")).append("Last log entry: "+UI.format.time(f[0])+" ["+f[1]+"] "+f[2])}if("totals"in d)if(f=function(a,b,c){var d;d=function(){for(var a in c.fields)e[c.fields[a]].push([h,0])};var e={},f;for(f in c.fields)e[c.fields[f]]=[];var j=0,h;if(c.data){600>c.end-c.start?(h=1E3*(c.end-600),d(),h=1E3*c.start,d()):h=1E3*c.start; UI.format.time((new Date).getTime()/1E3));d.LTS&&UI.elements.menu.find(".LTSonly").removeClass("LTSonly");if(d.log){var f=d.log[d.log.length-1];UI.elements.connection.msg.append($("<br>")).append("Last log entry: "+UI.format.time(f[0])+" ["+f[1]+"] "+f[2])}if("totals"in d)if(f=function(a,b,c){var d;d=function(){for(var a in c.fields)e[c.fields[a]].push([g,0])};var e={},f;for(f in c.fields)e[c.fields[f]]=[];var j=0,g;if(c.data){600>c.end-c.start?(g=1E3*(c.end-600),d(),g=1E3*c.start,d()):g=1E3*c.start;
for(f in c.data){if(0==f){h=1E3*c.start;var l=0}else h+=1E3*c.interval[l][1],c.interval[l][0]--,0>=c.interval[l][0]&&(l++,l<c.interval.length-1&&(j=2));1==j&&(d(),j--);for(var m in c.data[f])e[c.fields[m]].push([h,c.data[f][m]]);j&&(d(),j--)}5<mist.data.config.time-c.end&&(d(),h=1E3*mist.data.config.time,d())}else h=1E3*(mist.data.config.time-600),d(),h=1E3*mist.data.config.time,d();d=e;stream=a?a.join(" "):"all_streams";protocol=b?b.join("_"):"all_protocols";stream in mist.data.totals||(mist.data.totals[stream]= for(f in c.data){if(0==f){g=1E3*c.start;var l=0}else g+=1E3*c.interval[l][1],c.interval[l][0]--,0>=c.interval[l][0]&&(l++,l<c.interval.length-1&&(j=2));1==j&&(d(),j--);for(var m in c.data[f])e[c.fields[m]].push([g,c.data[f][m]]);j&&(d(),j--)}5<mist.data.config.time-c.end&&(d(),g=1E3*mist.data.config.time,d())}else g=1E3*(mist.data.config.time-600),d(),g=1E3*mist.data.config.time,d();d=e;stream=a?a.join(" "):"all_streams";protocol=b?b.join("_"):"all_protocols";stream in mist.data.totals||(mist.data.totals[stream]=
{});protocol in mist.data.totals[stream]||(mist.data.totals[stream][protocol]={});$.extend(mist.data.totals[stream][protocol],d)},mist.data.totals={},"fields"in d.totals)f(c.totals.streams,c.totals.protocols,d.totals);else for(var e in d.totals)f(c.totals[e].streams,c.totals[e].protocols,d.totals[e]);a&&a(d,b);break;case "CHALL":d.authorize.challenge==mist.user.authstring?(""!=mist.user.password&&UI.elements.connection.msg.text("The credentials you provided are incorrect.").addClass("red"),UI.navto("Login")): {});protocol in mist.data.totals[stream]||(mist.data.totals[stream][protocol]={});$.extend(mist.data.totals[stream][protocol],d)},mist.data.totals={},"fields"in d.totals)f(c.totals.streams,c.totals.protocols,d.totals);else for(var e in d.totals)f(c.totals[e].streams,c.totals[e].protocols,d.totals[e]);a&&a(d,b);break;case "CHALL":d.authorize.challenge==mist.user.authstring?(""!=mist.user.password&&UI.elements.connection.msg.text("The credentials you provided are incorrect.").addClass("red"),UI.navto("Login")):
""==mist.user.password?UI.navto("Login"):(mist.user.authstring=d.authorize.challenge,mist.send(a,c,b));break;case "NOACC":UI.navto("Create a new account");break;case "ACC_MADE":delete c.authorize;mist.send(a,c,b);break;default:UI.navto("Login")}}};b.hide||UI.elements.connection.msg.removeClass("red").text("Data sent, waiting for a reply..").append($("<br>")).append($("<a>").text("Cancel request").click(function(){f.abort()}));var f=$.ajax(d)},inputMatch:function(a,c){if("undefined"==typeof a)return!1; ""==mist.user.password?UI.navto("Login"):(mist.user.authstring=d.authorize.challenge,mist.send(a,c,b));break;case "NOACC":UI.navto("Create a new account");break;case "ACC_MADE":delete c.authorize;mist.send(a,c,b);break;default:UI.navto("Login")}}};b.hide||UI.elements.connection.msg.removeClass("red").text("Data sent, waiting for a reply..").append($("<br>")).append($("<a>").text("Cancel request").click(function(){f.abort()}));var f=$.ajax(d)},inputMatch:function(a,c){if("undefined"==typeof a)return!1;
var b=a.replace(/[^\w\s]/g,"\\$&"),b=b.replace(/\\\?/g,".").replace(/\\\*/g,"(?:.)*");return RegExp("^"+b+"$","i").test(c)},convertBuildOptions:function(a,c){var b=[],d=["required","optional"];"desc"in a&&b.push({type:"help",help:a.desc});for(var f in d)if(a[d[f]]){b.push($("<h4>").text(UI.format.capital(d[f])+" parameters"));for(var l in a[d[f]]){var m=a[d[f]][l],e={label:UI.format.capital(m.name),pointer:{main:c,index:l},validate:[]};"required"==d[f]&&!("default"in m)&&e.validate.push("required"); var b=a.replace(/[^\w\s]/g,"\\$&"),b=b.replace(/\\\?/g,".").replace(/\\\*/g,"(?:.)*");return RegExp("^"+b+"$","i").test(c)},convertBuildOptions:function(a,c){var b=[],d=["required","optional"];"desc"in a&&b.push({type:"help",help:a.desc});for(var f in d)if(a[d[f]]){b.push($("<h4>").text(UI.format.capital(d[f])+" parameters"));for(var l in a[d[f]]){var m=a[d[f]][l],e={label:UI.format.capital(m.name),pointer:{main:c,index:l},validate:[]};"required"==d[f]&&!("default"in m)&&e.validate.push("required");