LSP: IPv6 compat fix, autoplay default on, push page LTSified

This commit is contained in:
cat 2016-05-31 10:14:15 +02:00 committed by Thulinma
parent 0b2355c5bb
commit 56e9b79d68
3 changed files with 169 additions and 165 deletions

View file

@ -1,11 +1,11 @@
var MD5=function(a){function c(a,b){var c,d,f,i,h;f=a&2147483648;i=b&2147483648;c=a&1073741824;d=b&1073741824;h=(a&1073741823)+(b&1073741823);return c&d?h^2147483648^f^i:c|d?h&1073741824?h^3221225472^f^i:h^1073741824^f^i:h^f^i}function b(a,b,d,f,i,h,g){a=c(a,c(c(b&d|~b&f,i),g));return c(a<<h|a>>>32-h,b)}function d(a,b,d,f,i,h,g){a=c(a,c(c(b&f|d&~f,i),g));return c(a<<h|a>>>32-h,b)}function e(a,b,d,f,i,h,g){a=c(a,c(c(b^d^f,i),g));return c(a<<h|a>>>32-h,b)}function j(a,b,d,f,i,h,g){a=c(a,c(c(d^(b|~f), var MD5=function(a){function c(a,c){var b,e,d,h,g;d=a&2147483648;h=c&2147483648;b=a&1073741824;e=c&1073741824;g=(a&1073741823)+(c&1073741823);return b&e?g^2147483648^d^h:b|e?g&1073741824?g^3221225472^d^h:g^1073741824^d^h:g^d^h}function e(a,b,d,e,h,g,f){a=c(a,c(c(b&d|~b&e,h),f));return c(a<<g|a>>>32-g,b)}function b(a,b,d,e,h,g,f){a=c(a,c(c(b&e|d&~e,h),f));return c(a<<g|a>>>32-g,b)}function d(a,b,d,e,h,g,f){a=c(a,c(c(b^d^e,h),f));return c(a<<g|a>>>32-g,b)}function i(a,b,d,e,h,g,f){a=c(a,c(c(d^(b|~e),
i),g));return c(a<<h|a>>>32-h,b)}function n(a){var b="",c="",d;for(d=0;3>=d;d++)c=a>>>8*d&255,c="0"+c.toString(16),b+=c.substr(c.length-2,2);return b}var g=[],p,m,h,s,f,i,l,k,g=a.replace(/\r\n/g,"\n"),a="";for(p=0;p<g.length;p++)m=g.charCodeAt(p),128>m?a+=String.fromCharCode(m):(127<m&&2048>m?a+=String.fromCharCode(m>>6|192):(a+=String.fromCharCode(m>>12|224),a+=String.fromCharCode(m>>6&63|128)),a+=String.fromCharCode(m&63|128));g=a;a=g.length;p=a+8;m=16*((p-p%64)/64+1);h=Array(m-1);for(f=s=0;f<a;)p= h),f));return c(a<<g|a>>>32-g,b)}function m(a){var c="",b="",d;for(d=0;3>=d;d++)b=a>>>8*d&255,b="0"+b.toString(16),c+=b.substr(b.length-2,2);return c}var f=[],p,n,s,l,g,h,k,j,f=a.replace(/\r\n/g,"\n"),a="";for(p=0;p<f.length;p++)n=f.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));f=a;a=f.length;p=a+8;n=16*((p-p%64)/64+1);s=Array(n-1);for(g=l=0;g<a;)p=
(f-f%4)/4,s=8*(f%4),h[p]|=g.charCodeAt(f)<<s,f++;p=(f-f%4)/4;h[p]|=128<<8*(f%4);h[m-2]=a<<3;h[m-1]=a>>>29;g=h;f=1732584193;i=4023233417;l=2562383102;k=271733878;for(a=0;a<g.length;a+=16)p=f,m=i,h=l,s=k,f=b(f,i,l,k,g[a+0],7,3614090360),k=b(k,f,i,l,g[a+1],12,3905402710),l=b(l,k,f,i,g[a+2],17,606105819),i=b(i,l,k,f,g[a+3],22,3250441966),f=b(f,i,l,k,g[a+4],7,4118548399),k=b(k,f,i,l,g[a+5],12,1200080426),l=b(l,k,f,i,g[a+6],17,2821735955),i=b(i,l,k,f,g[a+7],22,4249261313),f=b(f,i,l,k,g[a+8],7,1770035416), (g-g%4)/4,l=8*(g%4),s[p]|=f.charCodeAt(g)<<l,g++;p=(g-g%4)/4;s[p]|=128<<8*(g%4);s[n-2]=a<<3;s[n-1]=a>>>29;f=s;g=1732584193;h=4023233417;k=2562383102;j=271733878;for(a=0;a<f.length;a+=16)p=g,n=h,s=k,l=j,g=e(g,h,k,j,f[a+0],7,3614090360),j=e(j,g,h,k,f[a+1],12,3905402710),k=e(k,j,g,h,f[a+2],17,606105819),h=e(h,k,j,g,f[a+3],22,3250441966),g=e(g,h,k,j,f[a+4],7,4118548399),j=e(j,g,h,k,f[a+5],12,1200080426),k=e(k,j,g,h,f[a+6],17,2821735955),h=e(h,k,j,g,f[a+7],22,4249261313),g=e(g,h,k,j,f[a+8],7,1770035416),
k=b(k,f,i,l,g[a+9],12,2336552879),l=b(l,k,f,i,g[a+10],17,4294925233),i=b(i,l,k,f,g[a+11],22,2304563134),f=b(f,i,l,k,g[a+12],7,1804603682),k=b(k,f,i,l,g[a+13],12,4254626195),l=b(l,k,f,i,g[a+14],17,2792965006),i=b(i,l,k,f,g[a+15],22,1236535329),f=d(f,i,l,k,g[a+1],5,4129170786),k=d(k,f,i,l,g[a+6],9,3225465664),l=d(l,k,f,i,g[a+11],14,643717713),i=d(i,l,k,f,g[a+0],20,3921069994),f=d(f,i,l,k,g[a+5],5,3593408605),k=d(k,f,i,l,g[a+10],9,38016083),l=d(l,k,f,i,g[a+15],14,3634488961),i=d(i,l,k,f,g[a+4],20,3889429448), j=e(j,g,h,k,f[a+9],12,2336552879),k=e(k,j,g,h,f[a+10],17,4294925233),h=e(h,k,j,g,f[a+11],22,2304563134),g=e(g,h,k,j,f[a+12],7,1804603682),j=e(j,g,h,k,f[a+13],12,4254626195),k=e(k,j,g,h,f[a+14],17,2792965006),h=e(h,k,j,g,f[a+15],22,1236535329),g=b(g,h,k,j,f[a+1],5,4129170786),j=b(j,g,h,k,f[a+6],9,3225465664),k=b(k,j,g,h,f[a+11],14,643717713),h=b(h,k,j,g,f[a+0],20,3921069994),g=b(g,h,k,j,f[a+5],5,3593408605),j=b(j,g,h,k,f[a+10],9,38016083),k=b(k,j,g,h,f[a+15],14,3634488961),h=b(h,k,j,g,f[a+4],20,3889429448),
f=d(f,i,l,k,g[a+9],5,568446438),k=d(k,f,i,l,g[a+14],9,3275163606),l=d(l,k,f,i,g[a+3],14,4107603335),i=d(i,l,k,f,g[a+8],20,1163531501),f=d(f,i,l,k,g[a+13],5,2850285829),k=d(k,f,i,l,g[a+2],9,4243563512),l=d(l,k,f,i,g[a+7],14,1735328473),i=d(i,l,k,f,g[a+12],20,2368359562),f=e(f,i,l,k,g[a+5],4,4294588738),k=e(k,f,i,l,g[a+8],11,2272392833),l=e(l,k,f,i,g[a+11],16,1839030562),i=e(i,l,k,f,g[a+14],23,4259657740),f=e(f,i,l,k,g[a+1],4,2763975236),k=e(k,f,i,l,g[a+4],11,1272893353),l=e(l,k,f,i,g[a+7],16,4139469664), g=b(g,h,k,j,f[a+9],5,568446438),j=b(j,g,h,k,f[a+14],9,3275163606),k=b(k,j,g,h,f[a+3],14,4107603335),h=b(h,k,j,g,f[a+8],20,1163531501),g=b(g,h,k,j,f[a+13],5,2850285829),j=b(j,g,h,k,f[a+2],9,4243563512),k=b(k,j,g,h,f[a+7],14,1735328473),h=b(h,k,j,g,f[a+12],20,2368359562),g=d(g,h,k,j,f[a+5],4,4294588738),j=d(j,g,h,k,f[a+8],11,2272392833),k=d(k,j,g,h,f[a+11],16,1839030562),h=d(h,k,j,g,f[a+14],23,4259657740),g=d(g,h,k,j,f[a+1],4,2763975236),j=d(j,g,h,k,f[a+4],11,1272893353),k=d(k,j,g,h,f[a+7],16,4139469664),
i=e(i,l,k,f,g[a+10],23,3200236656),f=e(f,i,l,k,g[a+13],4,681279174),k=e(k,f,i,l,g[a+0],11,3936430074),l=e(l,k,f,i,g[a+3],16,3572445317),i=e(i,l,k,f,g[a+6],23,76029189),f=e(f,i,l,k,g[a+9],4,3654602809),k=e(k,f,i,l,g[a+12],11,3873151461),l=e(l,k,f,i,g[a+15],16,530742520),i=e(i,l,k,f,g[a+2],23,3299628645),f=j(f,i,l,k,g[a+0],6,4096336452),k=j(k,f,i,l,g[a+7],10,1126891415),l=j(l,k,f,i,g[a+14],15,2878612391),i=j(i,l,k,f,g[a+5],21,4237533241),f=j(f,i,l,k,g[a+12],6,1700485571),k=j(k,f,i,l,g[a+3],10,2399980690), h=d(h,k,j,g,f[a+10],23,3200236656),g=d(g,h,k,j,f[a+13],4,681279174),j=d(j,g,h,k,f[a+0],11,3936430074),k=d(k,j,g,h,f[a+3],16,3572445317),h=d(h,k,j,g,f[a+6],23,76029189),g=d(g,h,k,j,f[a+9],4,3654602809),j=d(j,g,h,k,f[a+12],11,3873151461),k=d(k,j,g,h,f[a+15],16,530742520),h=d(h,k,j,g,f[a+2],23,3299628645),g=i(g,h,k,j,f[a+0],6,4096336452),j=i(j,g,h,k,f[a+7],10,1126891415),k=i(k,j,g,h,f[a+14],15,2878612391),h=i(h,k,j,g,f[a+5],21,4237533241),g=i(g,h,k,j,f[a+12],6,1700485571),j=i(j,g,h,k,f[a+3],10,2399980690),
l=j(l,k,f,i,g[a+10],15,4293915773),i=j(i,l,k,f,g[a+1],21,2240044497),f=j(f,i,l,k,g[a+8],6,1873313359),k=j(k,f,i,l,g[a+15],10,4264355552),l=j(l,k,f,i,g[a+6],15,2734768916),i=j(i,l,k,f,g[a+13],21,1309151649),f=j(f,i,l,k,g[a+4],6,4149444226),k=j(k,f,i,l,g[a+11],10,3174756917),l=j(l,k,f,i,g[a+2],15,718787259),i=j(i,l,k,f,g[a+9],21,3951481745),f=c(f,p),i=c(i,m),l=c(l,h),k=c(k,s);return(n(f)+n(i)+n(l)+n(k)).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(n){case "string":case "string-ins":b=String(b).toLowerCase();break;case "int":b= k=i(k,j,g,h,f[a+10],15,4293915773),h=i(h,k,j,g,f[a+1],21,2240044497),g=i(g,h,k,j,f[a+8],6,1873313359),j=i(j,g,h,k,f[a+15],10,4264355552),k=i(k,j,g,h,f[a+6],15,2734768916),h=i(h,k,j,g,f[a+13],21,1309151649),g=i(g,h,k,j,f[a+4],6,4149444226),j=i(j,g,h,k,f[a+11],10,3174756917),k=i(k,j,g,h,f[a+2],15,718787259),h=i(h,k,j,g,f[a+9],21,3951481745),g=c(g,p),h=c(h,n),k=c(k,s),j=c(j,l);return(m(g)+m(h)+m(k)+m(j)).toLowerCase()};(function(a){a.fn.stupidtable=function(){a(this).on("click","thead th",function(){a(this).stupidsort()})};a.fn.stupidsort=function(){function c(c){var b=0,d;a(c).children("td,th").each(function(){if(b==p)return d=a(this),!1;var c=a(this).attr("colspan");b+=c?Number(c):1});c="undefined"!=typeof d.data("sort-value")?d.data("sort-value"):"undefined"!=typeof d.attr("data-sort-value")?d.attr("data-sort-value"):d.text();switch(m){case "string":case "string-ins":c=String(c).toLowerCase();break;case "int":c=
parseInt(Number(b));break;case "float":b=Number(b)}return b}var b=a(this),d=b.closest("table"),e=d.children("tbody"),j=e.children("tr"),n=b.attr("data-sort-type");if(n){var g=!0;b.hasClass("sorting-asc")&&(g=!1);var p=0;b.prevAll().each(function(){var b=a(this).attr("colspan");p+=b?Number(b):1});j.sort(function(a,b){var d=g?1:-1,a=c(a),b=c(b);return a>b?1*d:a<b?-1*d:0});e.append(j);d.find("thead th").removeClass("sorting-asc").removeClass("sorting-desc");b.addClass(g?"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=decodeURIComponent(location.hash).substring(1).split("@")[0].split("&");mist.user.name=a[0];a[1]&&(mist.user.host=a[1])}mist.send(function(){$(window).trigger("hashchange")},{},{timeout:5,hide:!0})}); parseInt(Number(c));break;case "float":c=Number(c)}return c}var e=a(this),b=e.closest("table"),d=b.children("tbody"),i=d.children("tr"),m=e.attr("data-sort-type");if(m){var f=!0;e.hasClass("sorting-asc")&&(f=!1);var p=0;e.prevAll().each(function(){var c=a(this).attr("colspan");p+=c?Number(c):1});i.sort(function(a,b){var d=f?1:-1,a=c(a),b=c(b);return a>b?1*d:a<b?-1*d:0});d.append(i);b.find("thead th").removeClass("sorting-asc").removeClass("sorting-desc");e.addClass(f?"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=decodeURIComponent(location.hash).substring(1).split("@")[0].split("&");mist.user.name=a[0];a[1]&&(mist.user.host=a[1])}mist.send(function(){$(window).trigger("hashchange")},{},{timeout:5,hide:!0})});
$(window).on("hashchange",function(){var a=decodeURIComponent(location.hash).substring(1).split("@");a[1]||(a[1]="");a=a[1].split("&");""==a[0]&&(a[0]="Overview");UI.showTab(a[0],a[1])}); $(window).on("hashchange",function(){var a=decodeURIComponent(location.hash).substring(1).split("@");a[1]||(a[1]="");a=a[1].split("&");""==a[0]&&(a[0]="Overview");UI.showTab(a[0],a[1])});
var 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};
this.opts.id=setInterval(a,c)}},returnTab:["Overview"],countrylist:{AF:"Afghanistan",AX:"&Aring;land Islands",AL:"Albania",DZ:"Algeria",AS:"American Samoa",AD:"Andorra",AO:"Angola",AI:"Anguilla",AQ:"Antarctica",AG:"Antigua and Barbuda",AR:"Argentina",AM:"Armenia",AW:"Aruba",AU:"Australia",AT:"Austria",AZ:"Azerbaijan",BS:"Bahamas",BH:"Bahrain",BD:"Bangladesh",BB:"Barbados",BY:"Belarus",BE:"Belgium",BZ:"Belize",BJ:"Benin",BM:"Bermuda",BT:"Bhutan",BO:"Bolivia, Plurinational State of",BQ:"Bonaire, Sint Eustatius and Saba", this.opts.id=setInterval(a,c)}},returnTab:["Overview"],countrylist:{AF:"Afghanistan",AX:"&Aring;land Islands",AL:"Albania",DZ:"Algeria",AS:"American Samoa",AD:"Andorra",AO:"Angola",AI:"Anguilla",AQ:"Antarctica",AG:"Antigua and Barbuda",AR:"Argentina",AM:"Armenia",AW:"Aruba",AU:"Australia",AT:"Austria",AZ:"Azerbaijan",BS:"Bahamas",BH:"Bahrain",BD:"Bangladesh",BB:"Barbados",BY:"Belarus",BE:"Belgium",BZ:"Belize",BJ:"Benin",BM:"Bermuda",BT:"Bhutan",BO:"Bolivia, Plurinational State of",BQ:"Bonaire, Sint Eustatius and Saba",
@ -17,151 +17,151 @@ MN:"Mongolia",ME:"Montenegro",MS:"Montserrat",MA:"Morocco",MZ:"Mozambique",MM:"M
RO:"Romania",RU:"Russian Federation",RW:"Rwanda",BL:"Saint Barth&eacute;lemy",SH:"Saint Helena, Ascension and Tristan da Cunha",KN:"Saint Kitts and Nevis",LC:"Saint Lucia",MF:"Saint Martin (French part)",PM:"Saint Pierre and Miquelon",VC:"Saint Vincent and the Grenadines",WS:"Samoa",SM:"San Marino",ST:"Sao Tome and Principe",SA:"Saudi Arabia",SN:"Senegal",RS:"Serbia",SC:"Seychelles",SL:"Sierra Leone",SG:"Singapore",SX:"Sint Maarten (Dutch part)",SK:"Slovakia",SI:"Slovenia",SB:"Solomon Islands",SO:"Somalia", RO:"Romania",RU:"Russian Federation",RW:"Rwanda",BL:"Saint Barth&eacute;lemy",SH:"Saint Helena, Ascension and Tristan da Cunha",KN:"Saint Kitts and Nevis",LC:"Saint Lucia",MF:"Saint Martin (French part)",PM:"Saint Pierre and Miquelon",VC:"Saint Vincent and the Grenadines",WS:"Samoa",SM:"San Marino",ST:"Sao Tome and Principe",SA:"Saudi Arabia",SN:"Senegal",RS:"Serbia",SC:"Seychelles",SL:"Sierra Leone",SG:"Singapore",SX:"Sint Maarten (Dutch part)",SK:"Slovakia",SI:"Slovenia",SB:"Solomon Islands",SO:"Somalia",
ZA:"South Africa",GS:"South Georgia and the South Sandwich Islands",SS:"South Sudan",ES:"Spain",LK:"Sri Lanka",SD:"Sudan",SR:"Suriname",SJ:"Svalbard and Jan Mayen",SZ:"Swaziland",SE:"Sweden",CH:"Switzerland",SY:"Syrian Arab Republic",TW:"Taiwan, Province of China",TJ:"Tajikistan",TZ:"Tanzania, United Republic of",TH:"Thailand",TL:"Timor-Leste",TG:"Togo",TK:"Tokelau",TO:"Tonga",TT:"Trinidad and Tobago",TN:"Tunisia",TR:"Turkey",TM:"Turkmenistan",TC:"Turks and Caicos Islands",TV:"Tuvalu",UG:"Uganda", ZA:"South Africa",GS:"South Georgia and the South Sandwich Islands",SS:"South Sudan",ES:"Spain",LK:"Sri Lanka",SD:"Sudan",SR:"Suriname",SJ:"Svalbard and Jan Mayen",SZ:"Swaziland",SE:"Sweden",CH:"Switzerland",SY:"Syrian Arab Republic",TW:"Taiwan, Province of China",TJ:"Tajikistan",TZ:"Tanzania, United Republic of",TH:"Thailand",TL:"Timor-Leste",TG:"Togo",TK:"Tokelau",TO:"Tonga",TT:"Trinidad and Tobago",TN:"Tunisia",TR:"Turkey",TM:"Turkmenistan",TC:"Turks and Caicos Islands",TV:"Tuvalu",UG:"Uganda",
UA:"Ukraine",AE:"United Arab Emirates",GB:"United Kingdom",US:"United States",UM:"United States Minor Outlying Islands",UY:"Uruguay",UZ:"Uzbekistan",VU:"Vanuatu",VE:"Venezuela, Bolivarian Republic of",VN:"Viet Nam",VG:"Virgin Islands, British",VI:"Virgin Islands, U.S.",WF:"Wallis and Futuna",EH:"Western Sahara",YE:"Yemen",ZM:"Zambia",ZW:"Zimbabwe"},tooltip:{show:function(a,c){$tooltip=this.element;$.contains(document.body,$tooltip[0])||$("body").append($tooltip);$tooltip.html(c);clearTimeout(this.hiding); UA:"Ukraine",AE:"United Arab Emirates",GB:"United Kingdom",US:"United States",UM:"United States Minor Outlying Islands",UY:"Uruguay",UZ:"Uzbekistan",VU:"Vanuatu",VE:"Venezuela, Bolivarian Republic of",VN:"Viet Nam",VG:"Virgin Islands, British",VI:"Virgin Islands, U.S.",WF:"Wallis and Futuna",EH:"Western Sahara",YE:"Yemen",ZM:"Zambia",ZW:"Zimbabwe"},tooltip:{show:function(a,c){$tooltip=this.element;$.contains(document.body,$tooltip[0])||$("body").append($tooltip);$tooltip.html(c);clearTimeout(this.hiding);
delete this.hiding;var b=$(document).height()-$tooltip.outerHeight(),d=$(document).width()-$tooltip.outerWidth();$tooltip.css("left",Math.min(a.pageX+10,d-10));$tooltip.css("top",Math.min(a.pageY+25,b-10));$tooltip.show().addClass("show")},hide:function(){$tooltip=this.element;$tooltip.removeClass("show");this.hiding=setTimeout(function(){$tooltip.hide()},500)},element:$("<div>").attr("id","tooltip")},popup:{element:null,show:function(a){this.element=$("<div>").attr("id","popup").append($("<button>").text("Close").addClass("close").click(function(){UI.popup.element.fadeOut("fast", delete this.hiding;var e=$(document).height()-$tooltip.outerHeight(),b=$(document).width()-$tooltip.outerWidth();$tooltip.css("left",Math.min(a.pageX+10,b-10));$tooltip.css("top",Math.min(a.pageY+25,e-10));$tooltip.show().addClass("show")},hide:function(){$tooltip=this.element;$tooltip.removeClass("show");this.hiding=setTimeout(function(){$tooltip.hide()},500)},element:$("<div>").attr("id","tooltip")},popup:{element:null,show:function(a){this.element=$("<div>").attr("id","popup").append($("<button>").text("Close").addClass("close").click(function(){UI.popup.element.fadeOut("fast",
function(){UI.popup.element.remove();UI.popup.element=null})})).append(a);$("body").append(this.element)}},menu:[{Overview:{},Protocols:{},Streams:{},Preview:{},Push:{LTSonly:!0},Triggers:{LTSonly:!1},Logs:{},Statistics:{},"Server Stats":{}},{Disconnect:{classes:["red"]}},{Guides:{link:"http://mistserver.org/documentation#Userdocs"},Tools:{submenu:{"Release notes":{link:"http://mistserver.org/documentation#Devdocs"},"Mist Shop":{link:"http://mistserver.org/products"},"Email for Help":{},"Terms & Conditions":{link:"http://mistserver.org/documentation#Legal"}}}}], function(){UI.popup.element.remove();UI.popup.element=null})})).append(a);$("body").append(this.element)}},menu:[{Overview:{},Protocols:{},Streams:{},Preview:{},Push:{LTSonly:!0},Triggers:{LTSonly:!1},Logs:{},Statistics:{},"Server Stats":{}},{Disconnect:{classes:["red"]}},{Guides:{link:"http://mistserver.org/documentation#Userdocs"},Tools:{submenu:{"Release notes":{link:"http://mistserver.org/documentation#Devdocs"},"Mist Shop":{link:"http://mistserver.org/products"},"Email for Help":{},"Terms & Conditions":{link:"http://mistserver.org/documentation#Legal"}}}}],
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 e=UI.menu[b][d], buildMenu:function(){function a(a,c){var b=$("<a>").addClass("button");b.html($("<span>").addClass("plain").text(a)).append($("<span>").addClass("highlighted").text(a));for(var d in c.classes)b.addClass(c.classes[d]);"LTSonly"in c&&b.addClass("LTSonly");"link"in c?b.attr("href",c.link).attr("target","_blank"):"submenu"in c||b.click(function(c){UI.navto(a);c.stopPropagation()});return b}var c=UI.elements.menu,e;for(e in UI.menu){0<e&&c.append($("<br>"));for(var b in UI.menu[e]){var d=UI.menu[e][b],
j=a(d,e);c.append(j);if("submenu"in e){var n=$("<span>").addClass("submenu");j.addClass("arrowdown").append(n);for(var g in e.submenu)n.append(a(g,e.submenu[g]))}}}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= i=a(b,d);c.append(i);if("submenu"in d){var m=$("<span>").addClass("submenu");i.addClass("arrowdown").append(m);for(var f in d.submenu)m.append(a(f,d.submenu[f]))}}}e=$("<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(e).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 e=$("<span>").addClass("text_container").append($("<span>").addClass("description").append(d.help));c.append(e);if("classes"in d)for(var j in d.classes)e.addClass(d.classes[j])}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(j in e= $("<div>").addClass("input_container"),e;for(e in a){var b=a[e];if(b instanceof jQuery)c.append(b);else if("help"==b.type){var d=$("<span>").addClass("text_container").append($("<span>").addClass("description").append(b.help));c.append(d);if("classes"in b)for(var i in b.classes)d.addClass(b.classes[i])}else if("text"==b.type)c.append($("<span>").addClass("text_container").append($("<span>").addClass("text").append(b.text)));else if("custom"==b.type)c.append(b.custom);else if("buttons"==b.type)for(i in d=
$("<span>").addClass("button_container"),"css"in d&&e.css(d.css),c.append(e),d.buttons){var n=d.buttons[j],g=$("<button>").text(n.label).data("opts",n);"css"in n&&g.css(n.css);e.append(g);switch(n.type){case "cancel":g.addClass("cancel").click(n["function"]);break;case "save":g.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(), $("<span>").addClass("button_container"),"css"in b&&d.css(b.css),c.append(d),b.buttons){var m=b.buttons[i],f=$("<button>").text(m.label).data("opts",m);"css"in m&&f.css(m.css);d.append(f);switch(m.type){case "cancel":f.addClass("cancel").click(m["function"]);break;case "save":f.addClass("save").click(function(){var a=$(this).closest(".input_container"),c=!1;a.find(".hasValidate").each(function(){if(c=$(this).data("validate")(this,!0))return!1});c||(a.find(".isSetting").each(function(){var a=$(this).getval(),
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:g.click(n["function"])}}else{n=$("<label>").addClass("UIelement");c.append(n);"css"in d&&n.css(d.css);n.append($("<span>").addClass("label").html("label"in d?d.label+":":""));g=$("<span>").addClass("field_container");n.append(g);switch(d.type){case "password":e=$("<input>").attr("type", c=$(this).data("pointer");if(""==a)if("default"in $(this).data("opts"))a=$(this).data("opts")["default"];else return delete c.main[c.index],!0;c.main[c.index]=a}),(a=$(this).data("opts")["function"])&&a(this))});break;default:f.click(m["function"])}}else{m=$("<label>").addClass("UIelement");c.append(m);"css"in b&&m.css(b.css);m.append($("<span>").addClass("label").html("label"in b?b.label+":":""));f=$("<span>").addClass("field_container");m.append(f);switch(b.type){case "password":d=$("<input>").attr("type",
"password");break;case "int":e=$("<input>").attr("type","number");"min"in d&&e.attr("min",d.min);"max"in d&&e.attr("max",d.min);"validate"in d?d.validate.push("int"):d.validate=["int"];break;case "span":e=$("<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, "password");break;case "int":d=$("<input>").attr("type","number");"min"in b&&d.attr("min",b.min);"max"in b&&d.attr("max",b.min);"validate"in b?b.validate.push("int"):b.validate=["int"];break;case "span":d=$("<span>");break;case "debug":b.select=[["","Default"],[0,"0 - All debugging messages disabled"],[1,"1 - Messages about failed operations"],[2,"2 - Previous level, and error messages"],[3,"3 - Previous level, and warning messages"],[4,"4 - Previous level, and status messages for development"],[5,
"5 - Previous level, and more status messages for development"],[6,"6 - Previous level, and verbose debugging messages"],[7,"7 - Previous level, and very verbose debugging messages"],[8,"8 - Report everything in extreme detail"],[9,"9 - Report everything in insane detail"],[10,"10 - All messages enabled"]];case "select":e=$("<select>");for(j in d.select){var p=$("<option>");"string"==typeof d.select[j]?p.text(d.select[j]):p.val(d.select[j][0]).text(d.select[j][1]);e.append(p)}break;case "textarea":e= "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":d=$("<select>");for(i in b.select){var p=$("<option>");"string"==typeof b.select[i]?p.text(b.select[i]):p.val(b.select[i][0]).text(b.select[i][1]);d.append(p)}break;case "textarea":d=
$("<textarea>").on("keydown",function(a){a.stopPropagation()});break;case "checkbox":e=$("<input>").attr("type","checkbox");break;case "hidden":e=$("<input>").attr("type","hidden");n.hide();break;case "email":e=$("<input>").attr("type","email").attr("autocomplete","on").attr("required","");break;case "browse":e=$("<input>").attr("type","text");"filetypes"in d&&e.data("filetypes",d.filetypes);break;case "geolimited":case "hostlimited":e=$("<input>").attr("type","hidden");break;case "radioselect":e= $("<textarea>").on("keydown",function(a){a.stopPropagation()});break;case "checkbox":d=$("<input>").attr("type","checkbox");break;case "hidden":d=$("<input>").attr("type","hidden");m.hide();break;case "email":d=$("<input>").attr("type","email").attr("autocomplete","on").attr("required","");break;case "browse":d=$("<input>").attr("type","text");"filetypes"in b&&d.data("filetypes",b.filetypes);break;case "geolimited":case "hostlimited":d=$("<input>").attr("type","hidden");break;case "radioselect":d=
$("<div>").addClass("radioselect");for(b in d.radioselect){var m=$("<input>").attr("type","radio").val(d.radioselect[b][0]).attr("name",d.label);("LTSonly"in d&&!mist.data.LTS||d.readonly)&&m.prop("disabled",!0);p=$("<label>").append(m).append($("<span>").html(d.radioselect[b][1]));e.append(p);if(2<d.radioselect[b].length)for(j in m=$("<select>").change(function(){$(this).parent().find("input[type=radio]:enabled").prop("checked","true")}),p.append(m),("LTSonly"in d&&!mist.data.LTS||d.readonly)&&m.prop("disabled", $("<div>").addClass("radioselect");for(e in b.radioselect){var n=$("<input>").attr("type","radio").val(b.radioselect[e][0]).attr("name",b.label);("LTSonly"in b&&!mist.data.LTS||b.readonly)&&n.prop("disabled",!0);p=$("<label>").append(n).append($("<span>").html(b.radioselect[e][1]));d.append(p);if(2<b.radioselect[e].length)for(i in n=$("<select>").change(function(){$(this).parent().find("input[type=radio]:enabled").prop("checked","true")}),p.append(n),("LTSonly"in b&&!mist.data.LTS||b.readonly)&&n.prop("disabled",
!0),d.radioselect[b][2])p=$("<option>"),m.append(p),d.radioselect[b][2][j]instanceof Array?p.val(d.radioselect[b][2][j][0]).html(d.radioselect[b][2][j][1]):p.html(d.radioselect[b][2][j])}break;case "checklist":e=$("<div>").addClass("checkcontainer");$controls=$("<div>").addClass("controls");$checklist=$("<div>").addClass("checklist");e.append($controls).append($checklist);$controls.append($("<label>").text("All").prepend($("<input>").attr("type","checkbox").click(function(){$(this).is(":checked")? !0),b.radioselect[e][2])p=$("<option>"),n.append(p),b.radioselect[e][2][i]instanceof Array?p.val(b.radioselect[e][2][i][0]).html(b.radioselect[e][2][i][1]):p.html(b.radioselect[e][2][i])}break;case "checklist":d=$("<div>").addClass("checkcontainer");$controls=$("<div>").addClass("controls");$checklist=$("<div>").addClass("checklist");d.append($controls).append($checklist);$controls.append($("<label>").text("All").prepend($("<input>").attr("type","checkbox").click(function(){$(this).is(":checked")?
$(this).closest(".checkcontainer").find("input[type=checkbox]").prop("checked",!0):$(this).closest(".checkcontainer").find("input[type=checkbox]").prop("checked",!1)})));for(b in d.checklist)"string"==typeof d.checklist[b]&&(d.checklist[b]=[d.checklist[b],d.checklist[b]]),$checklist.append($("<label>").text(d.checklist[b][1]).prepend($("<input>").attr("type","checkbox").attr("name",d.checklist[b][0])));break;case "DOMfield":e=d.DOMfield;break;default:e=$("<input>").attr("type","text")}e.addClass("field").data("opts", $(this).closest(".checkcontainer").find("input[type=checkbox]").prop("checked",!0):$(this).closest(".checkcontainer").find("input[type=checkbox]").prop("checked",!1)})));for(e in b.checklist)"string"==typeof b.checklist[e]&&(b.checklist[e]=[b.checklist[e],b.checklist[e]]),$checklist.append($("<label>").text(b.checklist[e][1]).prepend($("<input>").attr("type","checkbox").attr("name",b.checklist[e][0])));break;case "DOMfield":d=b.DOMfield;break;default:d=$("<input>").attr("type","text")}d.addClass("field").data("opts",
d);"pointer"in d&&e.attr("name",d.pointer.index);g.append(e);if("classes"in d)for(j in d.classes)e.addClass(d.classes[j]);"placeholder"in d&&e.attr("placeholder",d.placeholder);"default"in d&&e.attr("placeholder",d["default"]);"unit"in d&&g.append($("<span>").addClass("unit").html(d.unit));"readonly"in d&&(e.attr("readonly","readonly"),e.click(function(){$(this).select()}));"qrcode"in d&&g.append($("<span>").addClass("unit").html($("<button>").text("QR").click(function(){var a=String($(this).closest(".field_container").find(".field").getval()), b);"pointer"in b&&d.attr("name",b.pointer.index);f.append(d);if("classes"in b)for(i in b.classes)d.addClass(b.classes[i]);"placeholder"in b&&d.attr("placeholder",b.placeholder);"default"in b&&d.attr("placeholder",b["default"]);"unit"in b&&f.append($("<span>").addClass("unit").html(b.unit));"readonly"in b&&(d.attr("readonly","readonly"),d.click(function(){$(this).select()}));"qrcode"in b&&f.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&&e.attr("rows",d.rows);"LTSonly"in d&&!mist.data.LTS&&(g.addClass("LTSonly"),e.prop("disabled",!0));switch(d.type){case "browse":m=$("<div>").addClass("grouper").append(n);c.append(m);m=$("<button>").text("Browse");g.append(m);m.click(function(){function a(b){j.text("Loading..");mist.send(function(a){e.text(a.browse.path[0]); c=$("<div>").addClass("qrcode");UI.popup.show($("<span>").addClass("qr_container").append($("<p>").text(a)).append(c));c.qrcode({text:a,size:Math.min(c.width(),c.height())})})));"rows"in b&&d.attr("rows",b.rows);"LTSonly"in b&&!mist.data.LTS&&(f.addClass("LTSonly"),d.prop("disabled",!0));switch(b.type){case "browse":n=$("<div>").addClass("grouper").append(m);c.append(n);n=$("<button>").text("Browse");f.append(n);n.click(function(){function a(c){i.text("Loading..");mist.send(function(a){f.text(a.browse.path[0]);
j.html(m.clone(true).text("..").attr("title","Folder up"));if(a.browse.subdirectories){a.browse.subdirectories.sort();for(var b in a.browse.subdirectories){var h=a.browse.subdirectories[b];j.append(m.clone(true).attr("title",e.text()+p+h).text(h))}}if(a.browse.files){a.browse.files.sort();for(b in a.browse.files){var h=a.browse.files[b],n=e.text()+p+h,h=$("<a>").text(h).addClass("file").attr("title",n);j.append(h);if(o){var q=true,s;for(s in o)if(typeof o[s]!="undefined"&&mist.inputMatch(o[s],n)){q= i.html(n.clone(true).text("..").attr("title","Folder up"));if(a.browse.subdirectories){a.browse.subdirectories.sort();for(var c in a.browse.subdirectories){var m=a.browse.subdirectories[c];i.append(n.clone(true).attr("title",f.text()+o+m).text(m))}}if(a.browse.files){a.browse.files.sort();for(c in a.browse.files){var m=a.browse.files[c],l=f.text()+o+m,m=$("<a>").text(m).addClass("file").attr("title",l);i.append(m);if(p){var s=true,v;for(v in p)if(typeof p[v]!="undefined"&&mist.inputMatch(p[v],l)){s=
false;break}q&&h.hide()}h.click(function(){var a=$(this).attr("title");d.setval(a);g.show();c.remove()})}}},{browse:b})}var b=$(this).closest(".grouper"),c=$("<div>").addClass("browse_container"),d=b.find(".field"),g=$(this),e=$("<span>").addClass("field"),n=$("<button>").text("Select this folder"),j=$("<div>").addClass("browse_contents"),m=$("<a>").addClass("folder"),o=d.data("filetypes");b.append(c);c.append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Current folder:")).append($("<span>").addClass("field_container").append(e).append(n))).append(j); false;break}s&&m.hide()}m.click(function(){var a=$(this).attr("title");d.setval(a);e.show();b.remove()})}}},{browse:c})}var c=$(this).closest(".grouper"),b=$("<div>").addClass("browse_container"),d=c.find(".field"),e=$(this),f=$("<span>").addClass("field"),m=$("<button>").text("Select this folder"),i=$("<div>").addClass("browse_contents"),n=$("<a>").addClass("folder"),p=d.data("filetypes");c.append(b);b.append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Current folder:")).append($("<span>").addClass("field_container").append(f).append(m))).append(i);
n.click(function(){var a=e.text()+"/";d.setval(a);g.show();c.remove()});var p="/";mist.data.config.version.indexOf("indows")>-1&&(p="\\");m.click(function(){var b=e.text()+p+$(this).text();a(b)});b=d.getval();b=b.split(p);b.pop();b=b.join(p);g.hide();a(b)});break;case "geolimited":case "hostlimited":m={field:e};m.blackwhite=$("<select>").append($("<option>").val("-").text("Blacklist")).append($("<option>").val("+").text("Whitelist"));m.values=$("<span>").addClass("limit_value_list");switch(d.type){case "geolimited":m.prototype= m.click(function(){var a=f.text()+"/";d.setval(a);e.show();b.remove()});var o="/";mist.data.config.version.indexOf("indows")>-1&&(o="\\");n.click(function(){var c=f.text()+o+$(this).text();a(c)});c=d.getval();c=c.split(o);c.pop();c=c.join(o);e.hide();a(c)});break;case "geolimited":case "hostlimited":n={field:d};n.blackwhite=$("<select>").append($("<option>").val("-").text("Blacklist")).append($("<option>").val("+").text("Whitelist"));n.values=$("<span>").addClass("limit_value_list");switch(b.type){case "geolimited":n.prototype=
$("<select>").append($("<option>").val("").text("[Select a country]"));for(b in UI.countrylist)m.prototype.append($("<option>").val(b).html(UI.countrylist[b]));break;case "hostlimited":m.prototype=$("<input>").attr("type","text").attr("placeholder","type a host")}m.prototype.on("change keyup",function(){$(this).closest(".field_container").data("subUI").blackwhite.trigger("change")});m.blackwhite.change(function(){var a=$(this).closest(".field_container").data("subUI"),b=[],c=false;a.values.children().each(function(){c= $("<select>").append($("<option>").val("").text("[Select a country]"));for(e in UI.countrylist)n.prototype.append($("<option>").val(e).html(UI.countrylist[e]));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"),c=[],b=false;a.values.children().each(function(){b=
$(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&&(m.blackwhite.prop("disabled",!0),m.prototype.prop("disabled",!0));m.values.append(m.prototype.clone(!0));g.data("subUI",m).addClass("limit_list").append(m.blackwhite).append(m.values)}"pointer"in d&&(e.data("pointer",d.pointer).addClass("isSetting"),m=d.pointer.main[d.pointer.index],"undefined"!= $(this).val();b!=""?c.push(b):$(this).remove()});a.values.append(a.prototype.clone(true));c.length>0?a.field.val($(this).val()+c.join(" ")):a.field.val("");a.field.trigger("change")});"LTSonly"in b&&!mist.data.LTS&&(n.blackwhite.prop("disabled",!0),n.prototype.prop("disabled",!0));n.values.append(n.prototype.clone(!0));f.data("subUI",n).addClass("limit_list").append(n.blackwhite).append(n.values)}"pointer"in b&&(d.data("pointer",b.pointer).addClass("isSetting"),n=b.pointer.main[b.pointer.index],"undefined"!=
m&&e.setval(m));"value"in d&&e.setval(d.value);if("datalist"in d)for(b in m="datalist_"+b+MD5(e[0].outerHTML),e.attr("list",m),m=$("<datalist>").attr("id",m),g.append(m),d.datalist)m.append($("<option>").val(d.datalist[b]));g=$("<span>").addClass("help_container");n.append(g);"help"in d&&(g.append($("<span>").addClass("ih_balloon").html(d.help)),e.on("focus mouseover",function(){$(this).closest("label").addClass("active")}).on("blur mouseout",function(){$(this).closest("label").removeClass("active")})); n&&d.setval(n));"value"in b&&d.setval(b.value);if("datalist"in b)for(e in n="datalist_"+e+MD5(d[0].outerHTML),d.attr("list",n),n=$("<datalist>").attr("id",n),f.append(n),b.datalist)n.append($("<option>").val(b.datalist[e]));f=$("<span>").addClass("help_container");m.append(f);"help"in b&&(f.append($("<span>").addClass("ih_balloon").html(b.help)),d.on("focus mouseover",function(){$(this).closest("label").addClass("active")}).on("blur mouseout",function(){$(this).closest("label").removeClass("active")}));
if("validate"in d){n=[];for(j in d.validate){m=d.validate[j];if("function"!=typeof m)switch(m){case "required":m=function(a){return a==""?{msg:"This is a required field.",classes:["red"]}:false};break;case "int":m=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.", if("validate"in b){m=[];for(i in b.validate){n=b.validate[i];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,c){var b=$(c).data("opts");if(!$(c)[0].validity.valid){var d=[];"min"in b&&d.push(" greater than or equal to "+b.min);"max"in b&&d.push(" smaller than or equal to "+b.max);return{msg:"Please enter an integer"+d.join(" and")+".",classes:["red"]}}if(parseInt(Number(a))!=a)return{msg:"Please enter an integer.",
classes:["red"]}};break;case "streamname":m=function(a,b){if(!isNaN(a.charAt(0)))return{msg:"The first character may not be a number.",classes:["red"]};if(a.toLowerCase()!=a)return{msg:"Uppercase letters are not allowed.",classes:["red"]};if(a.replace(/[^\da-z_]/g,"")!=a)return{msg:"Special characters (except for underscores) are not allowed.",classes:["red"]};if("streams"in mist.data&&a in mist.data.streams&&$(b).data("pointer").main.name!=a)return{msg:"This streamname already exists.<br>If you want to edit an existing stream, please click edit on the the streams tab.", classes:["red"]}};break;case "streamname":n=function(a,c){if(!isNaN(a.charAt(0)))return{msg:"The first character may not be a number.",classes:["red"]};if(a.toLowerCase()!=a)return{msg:"Uppercase letters are not allowed.",classes:["red"]};if(a.replace(/[^\da-z_]/g,"")!=a)return{msg:"Special characters (except for underscores) are not allowed.",classes:["red"]};if("streams"in mist.data&&a in mist.data.streams&&$(c).data("pointer").main.name!=a)return{msg:"This streamname already exists.<br>If you want to edit an existing stream, please click edit on the the streams tab.",
classes:["red"]}};break;default:m=function(){}}n.push(m)}e.data("validate_functions",n).data("help_container",g).data("validate",function(a,b){var c=$(a).getval(),d=$(a).data("validate_functions"),g=$(a).data("help_container");g.find(".err_balloon").remove();for(var e in d){var n=d[e](c,a);if(n){$err=$("<span>").addClass("err_balloon").html(n.msg);for(var j in n.classes)$err.addClass(n.classes[j]);g.prepend($err);b&&$(a).focus();return true}}return false}).addClass("hasValidate").on("change keyup", classes:["red"]}};break;default:n=function(){}}m.push(n)}d.data("validate_functions",m).data("help_container",f).data("validate",function(a,c){var b=$(a).getval(),d=$(a).data("validate_functions"),e=$(a).data("help_container");e.find(".err_balloon").remove();for(var f in d){var m=d[f](b,a);if(m){$err=$("<span>").addClass("err_balloon").html(m.msg);for(var i in m.classes)$err.addClass(m.classes[i]);e.prepend($err);c&&$(a).focus();return true}}return false}).addClass("hasValidate").on("change keyup",
function(){$(this).data("validate")($(this))});""!=e.getval()&&e.trigger("change")}"function"in d&&(e.on("change keyup",d["function"]),e.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))), function(){$(this).data("validate")($(this))});""!=d.getval()&&d.trigger("change")}"function"in b&&(d.on("change keyup",b["function"]),d.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"),e=$("<tr>").addClass("header").append($("<td>").addClass("vheader").attr("rowspan",a.labels.length+1).append($("<span>").text(a.vheader))),
d=[];b.append($("<td>"));for(var e in a.labels)d.push($("<tr>").append($("<td>").html(""==a.labels[e]?"&nbsp;":a.labels[e]+":")));for(var j in a.content)for(e in b.append($("<td>").html(a.content[j].header)),a.content[j].body)d[e].append($("<td>").html(a.content[j].body[e]));c.append($("<tbody>").append(b).append(d));return c},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").attr("draggable", b=[];e.append($("<td>"));for(var d in a.labels)b.push($("<tr>").append($("<td>").html(""==a.labels[d]?"&nbsp;":a.labels[d]+":")));for(var i in a.content)for(d in e.append($("<td>").html(a.content[i].header)),a.content[i].body)b[d].append($("<td>").html(a.content[i].body[d]));c.append($("<tbody>").append(e).append(b));return c},plot:{addGraph:function(a,c){var e={id:a.id,xaxis:a.xaxis,datasets:[],elements:{cont:$("<div>").addClass("graph"),plot:$("<div>").addClass("plot"),legend:$("<div>").addClass("legend").attr("draggable",
"true")}};UI.draggable(b.elements.legend);b.elements.cont.append(b.elements.plot).append(b.elements.legend);c.append(b.elements.cont);return b},go:function(a){if(!(1>Object.keys(a).length)){var c={totals:[],clients:[]},b;for(b in a)for(var d in a[b].datasets){var e=a[b].datasets[d];switch(e.datatype){case "clients":case "upbps":case "downbps":switch(e.origin[0]){case "total":c.totals.push({fields:[e.datatype],end:-15});break;case "stream":c.totals.push({fields:[e.datatype],streams:[e.origin[1]],end:-15}); "true")}};UI.draggable(e.elements.legend);e.elements.cont.append(e.elements.plot).append(e.elements.legend);c.append(e.elements.cont);return e},go:function(a){if(!(1>Object.keys(a).length)){var c={totals:[],clients:[]},e;for(e in a)for(var b in a[e].datasets){var d=a[e].datasets[b];switch(d.datatype){case "clients":case "upbps":case "downbps":switch(d.origin[0]){case "total":c.totals.push({fields:[d.datatype],end:-15});break;case "stream":c.totals.push({fields:[d.datatype],streams:[d.origin[1]],end:-15});
break;case "protocol":c.totals.push({fields:[e.datatype],protocols:[e.origin[1]],end:-15})}break;case "cpuload":case "memload":c.capabilities={}}}0==c.totals.length&&delete c.totals;0==c.clients.length&&delete c.clients;mist.send(function(){for(var b in a){var c=a[b];if(1>c.datasets.length){c.elements.plot.html("");c.elements.legend.html("");break}switch(c.xaxis){case "time":var d=[];c.yaxes={};var e=[],m;for(m in c.datasets){var h=c.datasets[m];h.display&&(h.getdata(),h.yaxistype in c.yaxes||(d.push(UI.plot.yaxes[h.yaxistype]), break;case "protocol":c.totals.push({fields:[d.datatype],protocols:[d.origin[1]],end:-15})}break;case "cpuload":case "memload":c.capabilities={}}}0==c.totals.length&&delete c.totals;0==c.clients.length&&delete c.clients;mist.send(function(){for(var c in a){var b=a[c];if(1>b.datasets.length){b.elements.plot.html("");b.elements.legend.html("");break}switch(b.xaxis){case "time":var d=[];b.yaxes={};var e=[],n;for(n in b.datasets){var s=b.datasets[n];s.display&&(s.getdata(),s.yaxistype in b.yaxes||(d.push(UI.plot.yaxes[s.yaxistype]),
c.yaxes[h.yaxistype]=d.length),h.yaxis=c.yaxes[h.yaxistype],e.push(h))}d[0]&&(d[0].color=0);c.plot=$.plot(c.elements.plot,e,{legend:{show:!1},xaxis:UI.plot.xaxes[c.xaxis],yaxes:d,grid:{hoverable:!0,borderWidth:{top:0,right:0,bottom:1,left:1},color:"black",backgroundColor:{colors:["rgba(0,0,0,0)","rgba(0,0,0,0.025)"]}},crosshair:{mode:"x"}});d=$("<table>").addClass("legend-list").addClass("nolay").html($("<tr>").html($("<td>").html($("<h3>").text(c.id))).append($("<td>").css("padding-right","2em").css("text-align", b.yaxes[s.yaxistype]=d.length),s.yaxis=b.yaxes[s.yaxistype],e.push(s))}d[0]&&(d[0].color=0);b.plot=$.plot(b.elements.plot,e,{legend:{show:!1},xaxis:UI.plot.xaxes[b.xaxis],yaxes:d,grid:{hoverable:!0,borderWidth:{top:0,right:0,bottom:1,left:1},color:"black",backgroundColor:{colors:["rgba(0,0,0,0)","rgba(0,0,0,0.025)"]}},crosshair:{mode:"x"}});d=$("<table>").addClass("legend-list").addClass("nolay").html($("<tr>").html($("<td>").html($("<h3>").text(b.id))).append($("<td>").css("padding-right","2em").css("text-align",
"right").html($("<span>").addClass("value")).append($("<button>").data("opts",c).text("X").addClass("close").click(function(){var b=$(this).data("opts");if(confirm("Are you sure you want to remove "+b.id+"?")){b.elements.cont.remove();var c=$(".graph_ids option:contains("+b.id+")"),d=c.parent();c.remove();UI.plot.del(b.id);delete a[b.id];d.trigger("change");UI.plot.go(a)}}))));c.elements.legend.html(d);var s=function(a){var b=c.elements.legend.find(".value"),d=1;if(typeof a=="undefined")b.eq(0).html("Latest:"); "right").html($("<span>").addClass("value")).append($("<button>").data("opts",b).text("X").addClass("close").click(function(){var c=$(this).data("opts");if(confirm("Are you sure you want to remove "+c.id+"?")){c.elements.cont.remove();var b=$(".graph_ids option:contains("+c.id+")"),d=b.parent();b.remove();UI.plot.del(c.id);delete a[c.id];d.trigger("change");UI.plot.go(a)}}))));b.elements.legend.html(d);var l=function(a){var c=b.elements.legend.find(".value"),d=1;if(typeof a=="undefined")c.eq(0).html("Latest:");
else{var e=c.plot.getXAxes()[0],a=Math.min(e.max,a),a=Math.max(e.min,a);b.eq(0).html(UI.format.time(a/1E3))}for(var g in c.datasets){var f="&nbsp;";if(c.datasets[g].display){var e=UI.plot.yaxes[c.datasets[g].yaxistype].tickFormatter,h=c.datasets[g].data;if(a)for(var j in h){if(h[j][0]==a){f=e(h[j][1]);break}if(h[j][0]>a){if(j!=0){f=h[j];h=h[j-1];f=e(f[1]+(a-f[0])*(h[1]-f[1])/(h[0]-f[0]))}break}}else f=e(c.datasets[g].data[c.datasets[g].data.length-1][1])}b.eq(d).html(f);d++}};c.plot.getOptions(); else{var e=b.plot.getXAxes()[0],a=Math.min(e.max,a),a=Math.max(e.min,a);c.eq(0).html(UI.format.time(a/1E3))}for(var f in b.datasets){var g="&nbsp;";if(b.datasets[f].display){var e=UI.plot.yaxes[b.datasets[f].yaxistype].tickFormatter,i=b.datasets[f].data;if(a)for(var l in i){if(i[l][0]==a){g=e(i[l][1]);break}if(i[l][0]>a){if(l!=0){g=i[l];i=i[l-1];g=e(g[1]+(a-g[0])*(i[1]-g[1])/(i[0]-g[0]))}break}}else g=e(b.datasets[f].data[b.datasets[f].data.length-1][1])}c.eq(d).html(g);d++}};b.plot.getOptions();
for(m in c.datasets)e=$("<input>").attr("type","checkbox").data("index",m).data("graph",c).click(function(){var a=$(this).data("graph");$(this).is(":checked")?a.datasets[$(this).data("index")].display=true:a.datasets[$(this).data("index")].display=false;var b={};b[a.id]=a;UI.plot.go(b)}),c.datasets[m].display&&e.attr("checked","checked"),d.append($("<tr>").html($("<td>").html($("<label>").html(e).append($("<div>").addClass("series-color").css("background-color",c.datasets[m].color)).append(c.datasets[m].label))).append($("<td>").css("padding-right", for(n in b.datasets)e=$("<input>").attr("type","checkbox").data("index",n).data("graph",b).click(function(){var a=$(this).data("graph");$(this).is(":checked")?a.datasets[$(this).data("index")].display=true:a.datasets[$(this).data("index")].display=false;var c={};c[a.id]=a;UI.plot.go(c)}),b.datasets[n].display&&e.attr("checked","checked"),d.append($("<tr>").html($("<td>").html($("<label>").html(e).append($("<div>").addClass("series-color").css("background-color",b.datasets[n].color)).append(b.datasets[n].label))).append($("<td>").css("padding-right",
"2em").css("text-align","right").html($("<span>").addClass("value")).append($("<button>").text("X").addClass("close").data("index",m).data("graph",c).click(function(){var b=$(this).data("index"),c=$(this).data("graph");if(confirm("Are you sure you want to remove "+c.datasets[b].label+" from "+c.id+"?")){c.datasets.splice(b,1);if(c.datasets.length==0){c.elements.cont.remove();var b=$(".graph_ids option:contains("+c.id+")"),d=b.parent();b.remove();d.trigger("change");UI.plot.del(c.id);delete a[c.id]; "2em").css("text-align","right").html($("<span>").addClass("value")).append($("<button>").text("X").addClass("close").data("index",n).data("graph",b).click(function(){var c=$(this).data("index"),b=$(this).data("graph");if(confirm("Are you sure you want to remove "+b.datasets[c].label+" from "+b.id+"?")){b.datasets.splice(c,1);if(b.datasets.length==0){b.elements.cont.remove();var c=$(".graph_ids option:contains("+b.id+")"),d=c.parent();c.remove();d.trigger("change");UI.plot.del(b.id);delete a[b.id];
UI.plot.go(a)}else{UI.plot.save(c);b={};b[c.id]=c;UI.plot.go(b)}}}))));s();var f=!1;c.elements.plot.on("plothover",function(a,b,c){if(b.x!=f){s(b.x);f=b.x}if(c){a=$("<span>").append($("<h3>").text(c.series.label).prepend($("<div>").addClass("series-color").css("background-color",c.series.color))).append($("<table>").addClass("nolay").html($("<tr>").html($("<td>").text("Time:")).append($("<td>").html(UI.format.dateTime(c.datapoint[0]/1E3,"long")))).append($("<tr>").html($("<td>").text("Value:")).append($("<td>").html(c.series.yaxis.tickFormatter(c.datapoint[1], UI.plot.go(a)}else{UI.plot.save(b);c={};c[b.id]=b;UI.plot.go(c)}}}))));l();var g=!1;b.elements.plot.on("plothover",function(a,c,b){if(c.x!=g){l(c.x);g=c.x}if(b){a=$("<span>").append($("<h3>").text(b.series.label).prepend($("<div>").addClass("series-color").css("background-color",b.series.color))).append($("<table>").addClass("nolay").html($("<tr>").html($("<td>").text("Time:")).append($("<td>").html(UI.format.dateTime(b.datapoint[0]/1E3,"long")))).append($("<tr>").html($("<td>").text("Value:")).append($("<td>").html(b.series.yaxis.tickFormatter(b.datapoint[1],
c.series.yaxis)))));UI.tooltip.show(b,a.children())}else UI.tooltip.hide()}).on("mouseout",function(){s()})}}},c)}},save:function(a){var c={id:a.id,xaxis:a.xaxis,datasets:[]},b;for(b in a.datasets)c.datasets.push({origin:a.datasets[b].origin,datatype:a.datasets[b].datatype});a=mist.stored.get().graphs||{};a[c.id]=c;mist.stored.set("graphs",a)},del:function(a){var c=mist.stored.get().graphs||{};delete c[a];mist.stored.set("graphs",c)},datatype:{getOptions:function(a){var c=$.extend(!0,{},UI.plot.datatype.templates.general), b.series.yaxis)))));UI.tooltip.show(c,a.children())}else UI.tooltip.hide()}).on("mouseout",function(){l()})}}},c)}},save:function(a){var c={id:a.id,xaxis:a.xaxis,datasets:[]},e;for(e in a.datasets)c.datasets.push({origin:a.datasets[e].origin,datatype:a.datasets[e].datatype});a=mist.stored.get().graphs||{};a[c.id]=c;mist.stored.set("graphs",a)},del:function(a){var c=mist.stored.get().graphs||{};delete c[a];mist.stored.set("graphs",c)},datatype:{getOptions:function(a){var c=$.extend(!0,{},UI.plot.datatype.templates.general),
b=$.extend(!0,{},UI.plot.datatype.templates[a.datatype]),a=$.extend(!0,b,a),a=$.extend(!0,c,a);switch(a.origin[0]){case "total":switch(a.datatype){case "cpuload":case "memload":break;default:a.label+=" (total)"}break;case "stream":case "protocol":a.label+=" ("+a.origin[1]+")"}var c=[],d;for(d in a.basecolor)b=a.basecolor[d],b+=50*(0.5-Math.random()),b=Math.round(b),b=Math.min(255,Math.max(0,b)),c.push(b);a.color="rgb("+c.join(",")+")";return a},templates:{general:{display:!0,datatype:"general",label:"", e=$.extend(!0,{},UI.plot.datatype.templates[a.datatype]),a=$.extend(!0,e,a),a=$.extend(!0,c,a);switch(a.origin[0]){case "total":switch(a.datatype){case "cpuload":case "memload":break;default:a.label+=" (total)"}break;case "stream":case "protocol":a.label+=" ("+a.origin[1]+")"}var c=[],b;for(b in a.basecolor)e=a.basecolor[b],e+=50*(0.5-Math.random()),e=Math.round(e),e=Math.min(255,Math.max(0,e)),c.push(e);a.color="rgb("+c.join(",")+")";return a},templates:{general:{display:!0,datatype:"general",label:"",
yaxistype:"amount",data:[],lines:{show:!0},points:{show:!1},getdata:function(){var a=mist.data.totals["stream"==this.origin[0]?this.origin[1]:"all_streams"]["protocol"==this.origin[0]?this.origin[1]:"all_protocols"][this.datatype];return this.data=a}},cpuload:{label:"CPU use",yaxistype:"percentage",basecolor:[237,194,64],cores:1,getdata:function(){var a=!1,c;for(c in this.data)this.data[c][0]<1E3*(mist.data.config.time-600)&&(a=c);!1!==a&&this.data.splice(0,Number(a)+1);this.data.push([1E3*mist.data.config.time, yaxistype:"amount",data:[],lines:{show:!0},points:{show:!1},getdata:function(){var a=mist.data.totals["stream"==this.origin[0]?this.origin[1]:"all_streams"]["protocol"==this.origin[0]?this.origin[1]:"all_protocols"][this.datatype];return this.data=a}},cpuload:{label:"CPU use",yaxistype:"percentage",basecolor:[237,194,64],cores:1,getdata:function(){var a=!1,c;for(c in this.data)this.data[c][0]<1E3*(mist.data.config.time-600)&&(a=c);!1!==a&&this.data.splice(0,Number(a)+1);this.data.push([1E3*mist.data.config.time,
mist.data.capabilities.cpu_use/10]);return this.data}},memload:{label:"Memory load",yaxistype:"percentage",basecolor:[175,216,248],getdata:function(){var a=!1,c;for(c in this.data)this.data[c][0]<1E3*(mist.data.config.time-600)&&(a=c);!1!==a&&this.data.splice(0,Number(a)+1);this.data.push([1E3*mist.data.config.time,mist.data.capabilities.load.memory]);return this.data}},clients:{label:"Connections",basecolor:[203,75,75]},upbps:{label:"Bandwidth up",yaxistype:"bytespersec",basecolor:[77,167,77]},downbps:{label:"Bandwidth down", mist.data.capabilities.cpu_use/10]);return this.data}},memload:{label:"Memory load",yaxistype:"percentage",basecolor:[175,216,248],getdata:function(){var a=!1,c;for(c in this.data)this.data[c][0]<1E3*(mist.data.config.time-600)&&(a=c);!1!==a&&this.data.splice(0,Number(a)+1);this.data.push([1E3*mist.data.config.time,mist.data.capabilities.load.memory]);return this.data}},clients:{label:"Connections",basecolor:[203,75,75]},upbps:{label:"Bandwidth up",yaxistype:"bytespersec",basecolor:[77,167,77]},downbps:{label:"Bandwidth down",
yaxistype:"bytespersec",basecolor:[148,64,237]}}},yaxes:{percentage:{name:"percentage",color:"black",tickColor:0,tickDecimals:0,tickFormatter:function(a){return UI.format.addUnit(UI.format.number(a),"%")},tickLength:0,min:0,max:100},amount:{name:"amount",color:"black",tickColor:0,tickDecimals:0,tickFormatter:function(a){return UI.format.number(a)},tickLength:0,min:0},bytespersec:{name:"bytespersec",color:"black",tickColor:0,tickDecimals:1,tickFormatter:function(a){return UI.format.bytes(a,!0)},tickLength:0, yaxistype:"bytespersec",basecolor:[148,64,237]}}},yaxes:{percentage:{name:"percentage",color:"black",tickColor:0,tickDecimals:0,tickFormatter:function(a){return UI.format.addUnit(UI.format.number(a),"%")},tickLength:0,min:0,max:100},amount:{name:"amount",color:"black",tickColor:0,tickDecimals:0,tickFormatter:function(a){return UI.format.number(a)},tickLength:0,min:0},bytespersec:{name:"bytespersec",color:"black",tickColor:0,tickDecimals:1,tickFormatter:function(a){return UI.format.bytes(a,!0)},tickLength:0,
ticks:function(a){var c=0.3*Math.sqrt($(".graph").first().height()),c=(a.max-a.min)/c,b=Math.floor(Math.log(Math.abs(c))/Math.log(1024)),d=c/Math.pow(1024,b),e=-Math.floor(Math.log(d)/Math.LN10),j=a.tickDecimals;null!=j&&e>j&&(e=j);var n=Math.pow(10,-e),d=d/n,g;if(1.5>d)g=1;else if(3>d){if(g=2,2.25<d&&(null==j||e+1<=j))g=2.5,++e}else g=7.5>d?5:10;g=g*n*Math.pow(1024,b);null!=a.minTickSize&&g<a.minTickSize&&(g=a.minTickSize);a.delta=c;a.tickDecimals=Math.max(0,null!=j?j:e);a.tickSize=g;c=[];b=a.tickSize* ticks:function(a){var c=0.3*Math.sqrt($(".graph").first().height()),c=(a.max-a.min)/c,e=Math.floor(Math.log(Math.abs(c))/Math.log(1024)),b=c/Math.pow(1024,e),d=-Math.floor(Math.log(b)/Math.LN10),i=a.tickDecimals;null!=i&&d>i&&(d=i);var m=Math.pow(10,-d),b=b/m,f;if(1.5>b)f=1;else if(3>b){if(f=2,2.25<b&&(null==i||d+1<=i))f=2.5,++d}else f=7.5>b?5:10;f=f*m*Math.pow(1024,e);null!=a.minTickSize&&f<a.minTickSize&&(f=a.minTickSize);a.delta=c;a.tickDecimals=Math.max(0,null!=i?i:d);a.tickSize=f;c=[];e=a.tickSize*
Math.floor(a.min/a.tickSize);e=0;j=Number.NaN;do n=j,j=b+e*a.tickSize,c.push(j),++e;while(j<a.max&&j!=n);return c},min:0}},xaxes:{time:{name:"time",mode:"time",timezone:"browser",ticks:5}}},draggable:function(a){a.attr("draggable",!0);a.on("dragstart",function(a){$(this).css("opacity",0.4).data("dragstart",{click:{x:a.originalEvent.pageX,y:a.originalEvent.pageY},ele:{x:this.offsetLeft,y:this.offsetTop}})}).on("dragend",function(a){var b=$(this).data("dragstart"),d=b.ele.x-b.click.x+a.originalEvent.pageX, Math.floor(a.min/a.tickSize);d=0;i=Number.NaN;do m=i,i=e+d*a.tickSize,c.push(i),++d;while(i<a.max&&i!=m);return c},min:0}},xaxes:{time:{name:"time",mode:"time",timezone:"browser",ticks:5}}},draggable:function(a){a.attr("draggable",!0);a.on("dragstart",function(a){$(this).css("opacity",0.4).data("dragstart",{click:{x:a.originalEvent.pageX,y:a.originalEvent.pageY},ele:{x:this.offsetLeft,y:this.offsetTop}})}).on("dragend",function(a){var e=$(this).data("dragstart"),b=e.ele.x-e.click.x+a.originalEvent.pageX,
a=b.ele.y-b.click.y+a.originalEvent.pageY;$(this).css({opacity:1,top:a,left:d,right:"auto",bottom:"auto"})});a.parent().on("dragleave",function(){})},format:{time:function(a,c){var b=new Date(1E3*a),d=[];d.push(("0"+b.getHours()).slice(-2));d.push(("0"+b.getMinutes()).slice(-2));"short"!=c&&d.push(("0"+b.getSeconds()).slice(-2));return d.join(":")},date:function(a,c){var b=new Date(1E3*a),d="Sun Mon Tue Wed Thu Fri Sat".split(" "),e=[];"long"==c&&e.push(d[b.getDay()]);e.push(("0"+b.getDate()).slice(-2)); a=e.ele.y-e.click.y+a.originalEvent.pageY;$(this).css({opacity:1,top:a,left:b,right:"auto",bottom:"auto"})});a.parent().on("dragleave",function(){})},format:{time:function(a,c){var e=new Date(1E3*a),b=[];b.push(("0"+e.getHours()).slice(-2));b.push(("0"+e.getMinutes()).slice(-2));"short"!=c&&b.push(("0"+e.getSeconds()).slice(-2));return b.join(":")},date:function(a,c){var e=new Date(1E3*a),b="Sun Mon Tue Wed Thu Fri Sat".split(" "),d=[];"long"==c&&d.push(b[e.getDay()]);d.push(("0"+e.getDate()).slice(-2));
e.push("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" ")[b.getMonth()]);"short"!=c&&e.push(b.getFullYear());return e.join(" ")},dateTime:function(a,c){return UI.format.date(a,c)+", "+UI.format.time(a,c)},duration:function(a){var c=[0.001,1E3,60,60,24,7,1E9],b="ms sec min hr day week".split(" "),d={},e;for(e in b){var a=a/c[e],j=Math.round(a%c[Number(e)+1]);d[b[e]]=j;a-=j}var n;for(e=b.length-1;0<=e;e--)if(0<d[b[e]]){n=b[e];break}c=$("<span>");switch(n){case "week":c.append(UI.format.addUnit(d.week, d.push("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" ")[e.getMonth()]);"short"!=c&&d.push(e.getFullYear());return d.join(" ")},dateTime:function(a,c){return UI.format.date(a,c)+", "+UI.format.time(a,c)},duration:function(a){var c=[0.001,1E3,60,60,24,7,1E9],e="ms sec min hr day week".split(" "),b={},d;for(d in e){var a=a/c[d],i=Math.round(a%c[Number(d)+1]);b[e[d]]=i;a-=i}var m;for(d=e.length-1;0<=d;d--)if(0<b[e[d]]){m=e[d];break}c=$("<span>");switch(m){case "week":c.append(UI.format.addUnit(b.week,
"wks, ")).append(UI.format.addUnit(d.day,"days"));break;case "day":c.append(UI.format.addUnit(d.day,"days, ")).append(UI.format.addUnit(d.hr,"hrs"));break;default:c.append([("0"+d.hr).slice(-2),("0"+d.min).slice(-2),("0"+d.sec).slice(-2)+(d.ms?"."+d.ms:"")].join(":"))}return c[0].innerHTML},number:function(a){if(isNaN(Number(a))||0==a)return a;var c=Math.pow(10,3-Math.floor(Math.log(a)/Math.LN10)-1),a=Math.round(a*c)/c;if(1E4<a){number=a.toString().split(".");for(a=/(\d+)(\d{3})/;a.test(number[0]);)number[0]= "wks, ")).append(UI.format.addUnit(b.day,"days"));break;case "day":c.append(UI.format.addUnit(b.day,"days, ")).append(UI.format.addUnit(b.hr,"hrs"));break;default:c.append([("0"+b.hr).slice(-2),("0"+b.min).slice(-2),("0"+b.sec).slice(-2)+(b.ms?"."+b.ms:"")].join(":"))}return c[0].innerHTML},number:function(a){if(isNaN(Number(a))||0==a)return a;var c=Math.pow(10,3-Math.floor(Math.log(a)/Math.LN10)-1),a=Math.round(a*c)/c;if(1E4<a){number=a.toString().split(".");for(a=/(\d+)(\d{3})/;a.test(number[0]);)number[0]=
number[0].replace(a,"$1 $2");a=number.join(".")}return a},status:function(a){var c=$("<span>");if("undefined"==typeof a.online)return c.text("Unknown, checking.."),"undefined"!=typeof a.error&&c.text(a.error),c;switch(a.online){case -1:c.text("Enabling");break;case 0:c.text("Unavailable").addClass("red");break;case 1:c.text("Active").addClass("green");break;case 2:c.text("Standby").addClass("orange");break;default:c.text(a.online)}"error"in a&&c.text(a.error);return c},capital:function(a){return a.charAt(0).toUpperCase()+ number[0].replace(a,"$1 $2");a=number.join(".")}return a},status:function(a){var c=$("<span>");if("undefined"==typeof a.online)return c.text("Unknown, checking.."),"undefined"!=typeof a.error&&c.text(a.error),c;switch(a.online){case -1:c.text("Enabling");break;case 0:c.text("Unavailable").addClass("red");break;case 1:c.text("Active").addClass("green");break;case 2:c.text("Standby").addClass("orange");break;default:c.text(a.online)}"error"in a&&c.text(a.error);return c},capital:function(a){return a.charAt(0).toUpperCase()+
a.substring(1)},addUnit:function(a,c){var b=$("<span>").html(a);b.append($("<span>").addClass("unit").html(c));return b[0].innerHTML},bytes:function(a,c){var b="bytes KiB MiB GiB TiB PiB".split(" ");if(0==a)unit=b[0];else{var d=Math.floor(Math.log(Math.abs(a))/Math.log(1024));0>d?unit=b[0]:(a/=Math.pow(1024,d),unit=b[d])}return UI.format.addUnit(UI.format.number(a),unit+(c?"/s":""))}},navto:function(a,c){var b=location.hash,d=b.split("@");d[0]=[mist.user.name,mist.user.host].join("&");d[1]=[a,c].join("&"); a.substring(1)},addUnit:function(a,c){var e=$("<span>").html(a);e.append($("<span>").addClass("unit").html(c));return e[0].innerHTML},bytes:function(a,c){var e="bytes KiB MiB GiB TiB PiB".split(" ");if(0==a)unit=e[0];else{var b=Math.floor(Math.log(Math.abs(a))/Math.log(1024));0>b?unit=e[0]:(a/=Math.pow(1024,b),unit=e[b])}return UI.format.addUnit(UI.format.number(a),unit+(c?"/s":""))}},navto:function(a,c){var e=location.hash,b=e.split("@");b[0]=[mist.user.name,mist.user.host].join("&");b[1]=[a,c].join("&");
"undefined"!=typeof screenlog&&screenlog.navto(d[1]);location.hash=d.join("@");location.hash==b&&$(window).trigger("hashchange")},showTab:function(a,c){var b=UI.elements.main;if(mist.user.loggedin&&!("ui_settings"in mist.data))b.html("Loading.."),mist.send(function(){UI.showTab(a,c)},{ui_settings:!0});else{var d=UI.elements.menu.css("opacity","1").find(".button").filter(function(){if($(this).find(".plain").text()==a)return!0});0<d.length&&(UI.elements.menu.find(".button.active").removeClass("active"), "undefined"!=typeof screenlog&&screenlog.navto(b[1]);location.hash=b.join("@");location.hash==e&&$(window).trigger("hashchange")},showTab:function(a,c){var e,b,d=UI.elements.main;if(mist.user.loggedin&&!("ui_settings"in mist.data))d.html("Loading.."),mist.send(function(){UI.showTab(a,c)},{ui_settings:!0});else switch(e=UI.elements.menu.css("opacity","1").find(".button").filter(function(){if($(this).find(".plain").text()==a)return!0}),0<e.length&&(UI.elements.menu.find(".button.active").removeClass("active"),
d.addClass("active"));UI.elements.secondary_menu.html("");UI.interval.clear();b.html($("<h2>").text(a));switch(a){case "Login":if(mist.user.loggedin){UI.navto("Overview");break}UI.elements.menu.css("opacity","0");UI.elements.connection.status.text("Disconnected").removeClass("green").addClass("red");b.append(UI.buildUI([{type:"help",help:"Please provide your account details.<br>You were asked to set these when MistController was started for the first time. If you did not yet set any account details, log in with your desired credentials to create a new account."}, e.addClass("active")),UI.elements.secondary_menu.html(""),UI.interval.clear(),d.html($("<h2>").text(a)),a){case "Login":if(mist.user.loggedin){UI.navto("Overview");break}UI.elements.menu.css("opacity","0");UI.elements.connection.status.text("Disconnected").removeClass("green").addClass("red");d.append(UI.buildUI([{type:"help",help:"Please provide your account details.<br>You were asked to set these when MistController was started for the first time. If you did not yet set any account details, log in with your desired credentials to create a new account."},
{label:"Host",help:"Url location of the MistServer API. Generally located at http://MistServerIP:4242/api","default":"http://localhost:4242/api",pointer:{main:mist.user,index:"host"}},{label:"Username",help:"Please enter your username here.",validate:["required"],pointer:{main:mist.user,index:"name"}},{label:"Password",type:"password",help:"Please enter your password here.",validate:["required"],pointer:{main:mist.user,index:"password"}},{type:"buttons",buttons:[{label:"Login",type:"save","function":function(){mist.send(function(){UI.navto("Overview")})}}]}])); {label:"Host",help:"Url location of the MistServer API. Generally located at http://MistServerIP:4242/api","default":"http://localhost:4242/api",pointer:{main:mist.user,index:"host"}},{label:"Username",help:"Please enter your username here.",validate:["required"],pointer:{main:mist.user,index:"name"}},{label:"Password",type:"password",help:"Please enter your password here.",validate:["required"],pointer:{main:mist.user,index:"password"}},{type:"buttons",buttons:[{label:"Login",type:"save","function":function(){mist.send(function(){UI.navto("Overview")})}}]}]));
break;case "Create a new account":UI.elements.menu.css("visibility","hidden");b.append($("<p>").text("No account has been created yet in the MistServer at ").append($("<i>").text(mist.user.host)).append("."));b.append(UI.buildUI([{type:"buttons",buttons:[{label:"Select other host",type:"cancel",css:{"float":"left"},"function":function(){UI.navto("Login")}}]},{type:"custom",custom:$("<br>")},{label:"Desired username",type:"str",validate:["required"],help:"Enter your desired username. In the future, you will need this to access the Management Interface.", break;case "Create a new account":UI.elements.menu.css("visibility","hidden");d.append($("<p>").text("No account has been created yet in the MistServer at ").append($("<i>").text(mist.user.host)).append("."));d.append(UI.buildUI([{type:"buttons",buttons:[{label:"Select other host",type:"cancel",css:{"float":"left"},"function":function(){UI.navto("Login")}}]},{type:"custom",custom:$("<br>")},{label:"Desired username",type:"str",validate:["required"],help:"Enter your desired username. In the future, you will need this to access the Management Interface.",
pointer:{main:mist.user,index:"name"}},{label:"Desired password",type:"password",validate:["required",function(a,b){$(".match_password").not($(b)).trigger("change");return false}],help:"Enter your desired password. In the future, you will need this to access the Management Interface.",pointer:{main:mist.user,index:"password"},classes:["match_password"]},{label:"Repeat password",type:"password",validate:["required",function(a,b){return a!=$(".match_password").not($(b)).val()?{msg:'The fields "Desired password" and "Repeat password" do not match.', pointer:{main:mist.user,index:"name"}},{label:"Desired password",type:"password",validate:["required",function(a,c){$(".match_password").not($(c)).trigger("change");return false}],help:"Enter your desired password. In the future, you will need this to access the Management Interface.",pointer:{main:mist.user,index:"password"},classes:["match_password"]},{label:"Repeat password",type:"password",validate:["required",function(a,c){return a!=$(".match_password").not($(c)).val()?{msg:'The fields "Desired password" and "Repeat password" do not match.',
classes:["red"]}:false}],help:"Repeat your desired password.",classes:["match_password"]},{type:"buttons",buttons:[{type:"save",label:"Create new account","function":function(){mist.send(function(){UI.navto("Account created")},{authorize:{new_username:mist.user.name,new_password:mist.user.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");d.append($("<p>").text("Your account has been created succesfully.")).append(UI.buildUI([{type:"text",text:"Would you like to enable all (currently) available protocols with their default settings?"},
{type:"buttons",buttons:[{label:"Enable protocols",type:"save","function":function(){if(mist.data.config.protocols)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)d.append("Unable to enable all protocols as protocol settings already exist.<br>");else{d.append("Retrieving available protocols..<br>");mist.send(function(a){var c=[],b;for(b in a.capabilities.connectors)if(a.capabilities.connectors[b].required)d.append('Could not enable protocol "'+b+'" because it has required settings.<br>');else{c.push({connector:b});d.append('Enabled protocol "'+
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 e=$("<span>").text("Loading.."),j=$("<span>"),n=$("<span>"),g=$("<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. "}, b+'".<br>')}d.append("Saving protocol settings..<br>");mist.send(function(){d.append("Protocols enabled. Redirecting..");setTimeout(function(){UI.navto("Overview")},5E3)},{config:{protocols:c}})},{capabilities:true})}}},{label:"Skip",type:"cancel","function":function(){UI.navto("Overview")}}]}]));break;case "Overview":var i=$("<span>").text("Loading.."),m=$("<span>"),f=$("<span>"),p=$("<span>");d.append(UI.buildUI([{type:"help",help:"You can find most basic information about your MistServer here.<br>You can also set the debug level and force a save to the config.json file that MistServer uses to save your settings. "},
{type:"span",label:"Version",pointer:{main:mist.data.config,index:"version"}},{type:"span",label:"Version check",value:e,LTSonly:!0},{type:"span",label:"Server time",value:g},{type:"span",label:"Current streams",value:j},{type:"span",label:"Current connections",value:n},$("<br>"),{type:"str",label:"Human readable name",pointer:{main:mist.data.config,index:"name"},help:"You can name your MistServer here for personal use. You'll still need to set host name within your network yourself."},{type:"debug", {type:"span",label:"Version",pointer:{main:mist.data.config,index:"version"}},{type:"span",label:"Version check",value:i,LTSonly:!0},{type:"span",label:"Server time",value:p},{type:"span",label:"Current streams",value:m},{type:"span",label:"Current connections",value:f},$("<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't 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 configurations save",pointer:{main:mist.data,index:"save"},help:"Tick the box in order to force an immediate save to the config.json MistServer uses to save your settings. Saving will otherwise happen upon closing MistServer. Don't forget to press save after ticking the box."},
{type:"buttons",buttons:[{type:"save",label:"Save","function":function(){var a={config:mist.data.config};if(mist.data.save)a.save=mist.data.save;mist.send(function(){UI.navto("Overview")},a)}}]}]));if(mist.data.LTS){var p=function(){var a=mist.stored.get().update||{};"uptodate"in a?a.error?e.addClass("red").text(a.error):a.uptodate?e.text("Your version is up to date.").addClass("green"):e.addClass("red").text("Version outdated!").append($("<button>").text("Update").css({"font-size":"1em","margin-left":"1em"}).click(function(){confirm("Are you sure you want to execute a rolling update?")&& {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 n=function(){var a=mist.stored.get().update||{};"uptodate"in a?a.error?i.addClass("red").text(a.error):a.uptodate?i.text("Your version is up to date.").addClass("green"):i.addClass("red").text("Version outdated!").append($("<button>").text("Update").css({"font-size":"1em","margin-left":"1em"}).click(function(){confirm("Are you sure you want to execute a rolling update?")&&
mist.send(function(){UI.navto("Overview")},{autoupdate:true})})):e.text("Unknown")};if(!mist.stored.get().update||864E5<(new Date).getTime()-mist.stored.get().update.lastchecked){var m=mist.stored.get().update||{};m.lastchecked=(new Date).getTime();mist.send(function(a){mist.stored.set("update",$.extend(true,m,a.update));p()},{checkupdate:!0})}else p()}else e.text("");var h=function(){mist.send(function(){s()},{totals:{fields:["clients"],start:-10},active_streams:true})},s=function(){j.text(("active_streams"in mist.send(function(){UI.navto("Overview")},{autoupdate:true})})):i.text("Unknown")};if(!mist.stored.get().update||864E5<(new Date).getTime()-mist.stored.get().update.lastchecked){var s=mist.stored.get().update||{};s.lastchecked=(new Date).getTime();mist.send(function(a){mist.stored.set("update",$.extend(true,s,a.update));n()},{checkupdate:!0})}else n()}else i.text("");var l=function(){mist.send(function(){g()},{totals:{fields:["clients"],start:-10},active_streams:true})},g=function(){m.text(("active_streams"in
mist.data?mist.data.active_streams?mist.data.active_streams.length:0:"?")+" active, "+(mist.data.streams?Object.keys(mist.data.streams).length:0)+" configured");if("totals"in mist.data&&"all_streams"in mist.data.totals)var a=mist.data.totals.all_streams.all_protocols.clients,a=a.length?UI.format.number(a[a.length-1][1]):0;else a="Loading..";n.text(a);g.text(UI.format.dateTime(mist.data.config.time,"long"))};h();s();UI.interval.set(h,3E4);break;case "Protocols":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)}, 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..";f.text(a);p.text(UI.format.dateTime(mist.data.config.time,"long"))};l();g();UI.interval.set(l,3E4);break;case "Protocols":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},
{capabilities:!0});b.append("Loading..");break}var f=$("<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(f)); {capabilities:!0});d.append("Loading..");break}var h=$("<tbody>");d.append(UI.buildUI([{type:"help",help:"You can find an overview of all the protocols and their relevant information here. You can add, edit or delete protocols."}])).append($("<button>").text("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 i=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(", "))}f.html("");for(var b in mist.data.config.protocols){var c=mist.data.config.protocols[b];f.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(c){var b=mist.data.capabilities.connectors[c.connector];if(!b)return"";var d=[],e=["required","optional"],f;for(f in e)for(var g in b[e[f]])c[g]&&c[g]!=""?d.push(g+": "+c[g]):b[e[f]][g]["default"]&&d.push(g+": "+b[e[f]][g]["default"]);return $("<span>").addClass("description").text(d.join(", "))}h.html("");for(var c in mist.data.config.protocols){var b=mist.data.config.protocols[c];h.append($("<tr>").data("index",c).append($("<td>").text(b.connector)).append($("<td>").html(UI.format.status(b))).append($("<td>").html(a(b))).append($("<td>").css("text-align",
"right").html($("<button>").text("Edit").click(function(){UI.navto("Edit Protocol",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the protocol "'+mist.data.config.protocols[a].connector+'"?')){mist.data.config.protocols.splice(a,1);mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}}))))}};i();UI.interval.set(function(){mist.send(function(){i()})}, "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 l=!1;""!=c&&0<=c&&(l=!0);var k={},q;for(q in mist.data.config.protocols)k[mist.data.config.protocols[q].connector]=1;var T=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", 3E4);break;case "Edit Protocol":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});d.append("Loading..");break}var j=!1;""!=c&&0<=c&&(j=!0);var v={},q;for(q in mist.data.config.protocols)v[mist.data.config.protocols[q].connector]=1;var G=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(l)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]+ "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]+
" ");$ul.append(a);typeof k[b.deps[e]]!="undefined"||typeof k[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)},k={};for(q in mist.data.config.protocols)k[mist.data.config.protocols[q].connector]=1;if(l){var r=mist.data.config.protocols[c],o=r;b.find("h2").append(' "'+r.connector+'"');b.append(T(r.connector))}else{b.html($("<h2>").text("New Protocol")); " ");$ul.append(a);typeof v[b.deps[e]]!="undefined"||typeof v[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)},v={};for(q in mist.data.config.protocols)v[mist.data.config.protocols[q].connector]=1;if(j){var r=mist.data.config.protocols[c],o=r;d.find("h2").append(' "'+r.connector+'"');d.append(G(r.connector))}else{d.html($("<h2>").text("New Protocol"));
var o={},v=[];for(q in mist.data.capabilities.connectors)v.push([q,q]);var U=$("<span>");b.append(UI.buildUI([{label:"Protocol",type:"select",select:v,"function":function(){U.html(T($(this).getval()))}}])).append(U)}break;case "Streams":if(!("capabilities"in mist.data)){b.html("Loading..");mist.send(function(){UI.navto(a)},{capabilities:!0});break}f=$("<tbody>").append($("<tr>").append("<td>").attr("colspan",6).text("Loading.."));d=$("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Stream name").attr("data-sort-type", var o={},w=[];for(q in mist.data.capabilities.connectors)w.push([q,q]);var V=$("<span>");d.append(UI.buildUI([{label:"Protocol",type:"select",select:w,"function":function(){V.html(G($(this).getval()))}}])).append(V)}break;case "Streams":if(!("capabilities"in mist.data)){d.html("Loading..");mist.send(function(){UI.navto(a)},{capabilities:!0});break}h=$("<tbody>").append($("<tr>").append("<td>").attr("colspan",6).text("Loading.."));e=$("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Stream name").attr("data-sort-type",
"string").addClass("sorting-asc")).append($("<th>").text("Source").attr("data-sort-type","string")).append($("<th>").text("Status").attr("data-sort-type","int")).append($("<th>").css("text-align","right").text("Connections").attr("data-sort-type","int")).append($("<th>")).append($("<th>")))).append(f);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(d); "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);d.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(e);
d.stupidtable();var E=function(){var a=[],b;for(b in mist.data.active_streams)a.push({streams:[mist.data.active_streams[b]],fields:["clients"],start:-2});mist.send(function(){$.extend(true,x,mist.data.streams);var a=0;f.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=V(mist.data.active_streams[a],mist.data.streams[b[0]]);b.online=1;x[mist.data.active_streams[a]]=b}}b=Object.keys(x);b.sort();for(var c in b){var d= e.stupidtable();var F=function(){var a=[],b;for(b in mist.data.active_streams)a.push({streams:[mist.data.active_streams[b]],fields:["clients"],start:-2});mist.send(function(){$.extend(true,y,mist.data.streams);var a=0;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=W(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;e=d in mist.data.streams?mist.data.streams[d]:x[d];var g=$("<td>").css("text-align","right").html($("<span>").addClass("description").text("Loading..")),h=0;if(typeof mist.data.totals!="undefined"&&typeof mist.data.totals[d]!="undefined"){var C=mist.data.totals[d].all_protocols.clients,h=0;if(C.length){for(a in C)h=h+C[a][1];h=Math.round(h/C.length)}}g.html(UI.format.number(h));if(h==0&&e.online==1)e.online=2;h=$("<td>").css("text-align","right").css("white-space","nowrap");(!("ischild"in e)|| b[c],e;e=d in mist.data.streams?mist.data.streams[d]:y[d];var f=$("<td>").css("text-align","right").html($("<span>").addClass("description").text("Loading..")),g=0;if(typeof mist.data.totals!="undefined"&&typeof mist.data.totals[d]!="undefined"){var D=mist.data.totals[d].all_protocols.clients,g=0;if(D.length){for(a in D)g=g+D[a][1];g=Math.round(g/D.length)}}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");(!("ischild"in e)||
!e.ischild)&&h.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 "'+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)}}));C=$("<span>").text(d);e.ischild&&C.css("padding-left","1em");var i= !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=$(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)}}));D=$("<span>").text(d);e.ischild&&D.css("padding-left","1em");var i=
UI.format.status(e),j=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("tr").data("index"))});if(e.filesfound){i.html("");j="";g.html("")}f.append($("<tr>").data("index",d).html($("<td>").html(C).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(i)).append(g).append($("<td>").html(j)).append(h)); UI.format.status(e),j=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("tr").data("index"))});if(e.filesfound){i.html("");j="";f.html("")}h.append($("<tr>").data("index",d).html($("<td>").html(D).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(i)).append(f).append($("<td>").html(j)).append(g));
a++}},{totals:a,active_streams:true})},x=$.extend(!0,{},mist.data.streams),V=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 B=0,F=0;for(h in mist.data.streams)r=mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"],mist.inputMatch(r.source_match,mist.data.streams[h].source)&&(x[h].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")>= a++}},{totals:a,active_streams:true})},y=$.extend(!0,{},mist.data.streams),W=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 C=0,H=0;for(l in mist.data.streams)r=mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"],mist.inputMatch(r.source_match,mist.data.streams[l].source)&&(y[l].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];x[g]=V(g,mist.data.streams[c]);x[g].source=mist.data.streams[c].source+a.browse.files[d]}"files"in a.browse&&a.browse.files.length?x[c].filesfound=true:mist.data.streams[c].filesfound=false;F++;if(B==F){mist.send(function(){E()},{active_streams:true});UI.interval.set(function(){E()},1E4)}},{browse:mist.data.streams[h].source},{stream:h}),B++);0==B&&(mist.send(function(){E()}, 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]=W(g,mist.data.streams[c]);y[g].source=mist.data.streams[c].source+a.browse.files[d]}"files"in a.browse&&a.browse.files.length?y[c].filesfound=true:mist.data.streams[c].filesfound=false;H++;if(C==H){mist.send(function(){F()},{active_streams:true});UI.interval.set(function(){F()},1E4)}},{browse:mist.data.streams[l].source},{stream:l}),C++);0==C&&(mist.send(function(){F()},
{active_streams:!0}),UI.interval.set(function(){E()},3E4))}else mist.send(function(){E()},{active_streams:!0}),UI.interval.set(function(){E()},1E4);break;case "Edit Stream":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});b.append("Loading..");break}l=!1;""!=c&&(l=!0);l?(h=c,o=mist.data.streams[h],b.find("h2").append(' "'+h+'"')):(b.html($("<h2>").text("New Stream")),o={});h=[];for(q in mist.data.capabilities.inputs)h.push(mist.data.capabilities.inputs[q].source_match); {active_streams:!0}),UI.interval.set(function(){F()},3E4))}else mist.send(function(){F()},{active_streams:!0}),UI.interval.set(function(){F()},1E4);break;case "Edit Stream":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});d.append("Loading..");break}j=!1;""!=c&&(j=!0);j?(l=c,o=mist.data.streams[l],d.find("h2").append(' "'+l+'"')):(d.html($("<h2>").text("New Stream")),o={});l=[];for(q in mist.data.capabilities.inputs)l.push(mist.data.capabilities.inputs[q].source_match);
var I=$("<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:h,pointer:{main:o,index:"source"},help:'Set the stream source.<table><tr><td>VoD:</td><td>You can browse to the file or folder as a source or simply enter the path to the file.</td></tr><tr><td>Live:</td><td>You\'ll need to enter "push://IP" with the IP of the machine pushing towards MistServer.<br>You can use "push://" to accept any source.</td></tr><tr><td>(Pro only)</td><td>Use "push://(IP)@password" to set a password protection for pushes.</td></tr></table>If you\'re unsure how to set the source properly, please view our Live pushing guide at the tools section.', var K=$("<div>");d.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:l,pointer:{main:o,index:"source"},help:'Set the stream source.<table><tr><td>VoD:</td><td>You can browse to the file or folder as a source or simply enter the path to the file.</td></tr><tr><td>Live:</td><td>You\'ll need to enter "push://IP" with the IP of the machine pushing towards MistServer.<br>You can use "push://" to accept any source.</td></tr><tr><td>(Pro only)</td><td>Use "push://(IP)@password" to set a password protection for pushes.</td></tr></table>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();if(a!=""){var b=null,c;for(c in mist.data.capabilities.inputs)if(typeof mist.data.capabilities.inputs[c].source_match!="undefined"&&mist.inputMatch(mist.data.capabilities.inputs[c].source_match,a)){b=c;break}if(b===null)I.html($("<h3>").text("Unrecognized input").addClass("red")).append($("<span>").text("Please edit the stream source.").addClass("red"));else{a=mist.data.capabilities.inputs[b];I.html($("<h3>").text(a.name+" Input options"));a=mist.convertBuildOptions(a, "function":function(){var a=$(this).val();if(a!=""){var b=null,c;for(c in mist.data.capabilities.inputs)if(typeof mist.data.capabilities.inputs[c].source_match!="undefined"&&mist.inputMatch(mist.data.capabilities.inputs[c].source_match,a)){b=c;break}if(b===null)K.html($("<h3>").text("Unrecognized input").addClass("red")).append($("<span>").text("Please edit the stream source.").addClass("red"));else{a=mist.data.capabilities.inputs[b];K.html($("<h3>").text(a.name+" Input options"));a=mist.convertBuildOptions(a,
o);I.append(UI.buildUI(a))}}}},$("<br>"),{type:"custom",custom:I},$("<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, o);K.append(UI.buildUI(a))}}}},$("<br>"),{type:"custom",custom:K},$("<br>"),$("<h3>").text("Encryption"),{type:"help",help:"To enable encryption, the licence acquisition url must be entered, as well as either the content key or the key ID and seed.<br>Unsure how you should fill in your encryption or missing your preferred encryption? Please contact us."},{label:"License acquisition url",type:"str",LTSonly:!0,pointer:{main: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]= 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=[c]}else a.streams=mist.data.streams;mist.send(function(){delete mist.data.streams[o.name].online;delete mist.data.streams[o.name].error;UI.navto("Streams")},a)}}]}]));break;case "Preview":if(""==c){b.append("Loading..");var L=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)}}]}])); o;if(c!=o.name)a.deletestream=[c]}else a.streams=mist.data.streams;mist.send(function(){delete mist.data.streams[o.name].online;delete mist.data.streams[o.name].error;UI.navto("Streams")},a)}}]}]));break;case "Preview":if(""==c){d.append("Loading..");var N=function(b){var c={};b.sort();d.html($("<h2>").text(a)).append(UI.buildUI([{label:"Select a stream",type:"select",select:b,pointer:{main:c,index:"stream"}},{type:"buttons",buttons:[{type:"save",label:"Go","function":function(){UI.navto(a,c.stream)}}]}]));
UI.elements.secondary_menu.html("").append($("<a>").addClass("button").addClass("active").text("Choose stream").click(function(){UI.navto("Preview")}));var e=$("<div>").addClass("preview_icons");b.append($("<span>").addClass("description").text("Or, click a stream from the list below.")).append(e);for(var g in c){var f=c[g],h="";if(f.indexOf("+")>-1){h=f.split("+");h=mist.data.streams[h[0]].source+h[1]}else h=mist.data.streams[f].source;e.append($("<button>").append($("<span>").text(f)).append($("<span>").addClass("description").text(h)).attr("title", UI.elements.secondary_menu.html("").append($("<a>").addClass("button").addClass("active").text("Choose stream").click(function(){UI.navto("Preview")}));var e=$("<div>").addClass("preview_icons");d.append($("<span>").addClass("description").text("Or, click a stream from the list below.")).append(e);for(var g in b){var f=b[g],h="";if(f.indexOf("+")>-1){h=f.split("+");h=mist.data.streams[h[0]].source+h[1]}else h=mist.data.streams[f].source;e.append($("<button>").append($("<span>").text(f)).append($("<span>").addClass("description").text(h)).attr("title",
f).attr("data-stream",f).click(function(){UI.navto("Preview",$(this).attr("data-stream"))}))}};if(mist.data.LTS){if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});b.append("Loading..");break}F=B=0;v={};for(h in mist.data.streams)r=mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"],mist.inputMatch(r.source_match,mist.data.streams[h].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")>= f).attr("data-stream",f).click(function(){UI.navto("Preview",$(this).attr("data-stream"))}))}};if(mist.data.LTS){if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});d.append("Loading..");break}H=C=0;w={};for(l in mist.data.streams)r=mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"],mist.inputMatch(r.source_match,mist.data.streams[l].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])&&(v[c+"+"+mist.data.browse.files[d]]=true);F++;B==F&&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&&(v[mist.data.active_streams[a]]=true)}v=Object.keys(v);v=v.concat(Object.keys(mist.data.streams));v.sort();L(v)},{active_streams:true})},{browse:mist.data.streams[h].source},{stream:h}), 0||e.indexOf("Folder")>=0||mist.inputMatch(mist.data.capabilities.inputs[e].source_match,"/"+mist.data.browse.files[d])&&(w[c+"+"+mist.data.browse.files[d]]=true);H++;C==H&&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&&(w[mist.data.active_streams[a]]=true)}w=Object.keys(w);w=w.concat(Object.keys(mist.data.streams));w.sort();N(w)},{active_streams:true})},{browse:mist.data.streams[l].source},{stream:l}),
B++);0==B&&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();L(c)}},{active_streams:!0})}else L(Object.keys(mist.data.streams));break}b.find("h2").append(' of "'+c+'"');h=":8080";for(q in mist.data.config.protocols)if(r= C++);0==C&&mist.send(function(){var b=[],c;for(c in mist.data.active_streams){var e=mist.data.active_streams[c].split("+");e.length>1&&e[0]in mist.data.streams&&(b[mist.data.active_streams[c]]=true)}mist.data.streams&&(b=b.concat(Object.keys(mist.data.streams)));if(b.length==0)d.html($("<h2>").text(a)).append("Please set up a stream first.");else{b.sort();N(b)}},{active_streams:!0})}else N(Object.keys(mist.data.streams));break}d.find("h2").append(' of "'+c+'"');l=":8080";for(q in mist.data.config.protocols)if(r=
mist.data.config.protocols[q],"HTTP"==r.connector||"HTTP.exe"==r.connector)h=r.port?":"+r.port:":8080";var D={},r=$("<span>").hide();D["Embed urls"]=r;b.append(r);var d="",W=mist.user.host.match(/(https?)\:\/\/([^:\/]+)\:(\d+)?/i);null!=W&&(d=W[2]);var G="http://"+d+h+"/",w={},J=function(a){var b=["div"],d='\n <script src="'+G+"embed_"+c+'.js"><\/script>\n';a.autoplay&&b.push("data-autoplay");a.forceprotocol&&a.forceprotocol!=""&&b.push('data-forcetype="'+a.forceprotocol+'"');a.urlappend&&a.urlappend!= mist.data.config.protocols[q],"HTTP"==r.connector||"HTTP.exe"==r.connector)l=r.port?":"+r.port:":8080";var E={},r=$("<span>").hide();E["Embed urls"]=r;d.append(r);e=mist.user.host;b=document.createElement("a");b.href=e;e=b.protocol+"//";b=b.hostname;var I=e+b+l+"/",x={autoplay:!0},L=function(a){var b=["div"],d='\n <script src="'+I+"embed_"+c+'.js"><\/script>\n';a.autoplay||b.push("data-noautoplay");a.forceprotocol&&a.forceprotocol!=""&&b.push('data-forcetype="'+a.forceprotocol+'"');a.urlappend&&
""&&b.push('data-urlappend="'+a.urlappend.replace(/\"/g,'\\"')+'"');return"<"+b.join(" ")+">"+d+"</div>"},X=$("<span>");r.append($("<h3>").text("Embed urls")).append(UI.buildUI([{label:"Embedable script",type:"str",value:G+"embed_"+c+".js",readonly:!0},{label:"Stream info script",type:"str",value:G+"info_"+c+".js",readonly:!0},{label:"Autodetect player",type:"str",value:G+c+".html",readonly:!0,qrcode:!0},$("<h3>").text("Embed code"),{label:"Embed code",type:"textarea",value:J(w),rows:4,readonly:!0, a.urlappend!=""&&b.push('data-urlappend="'+a.urlappend.replace(/\"/g,'\\"')+'"');return"<"+b.join(" ")+">"+d+"</div>"},X=$("<span>");r.append($("<h3>").text("Embed urls")).append(UI.buildUI([{label:"Embedable script",type:"str",value:I+"embed_"+c+".js",readonly:!0},{label:"Stream info script",type:"str",value:I+"info_"+c+".js",readonly:!0},{label:"Autodetect player",type:"str",value:I+c+".html",readonly:!0,qrcode:!0},$("<h3>").text("Embed code"),{label:"Embed code",type:"textarea",value:L(x),rows:4,
classes:["embed_code"]},$("<h4>").text("Embed code options").css("margin-top",0),{label:"Autoplay",type:"checkbox",pointer:{main:w,index:"autoplay"},"function":function(){w.autoplay=$(this).getval();$(".embed_code").setval(J(w))}},{label:"Force protocol",type:"select",select:[["","Automatic"]],pointer:{main:w,index:"protocol"},classes:["embed_code_forceprotocol"],"function":function(){w.forceprotocol=$(this).getval();$(".embed_code").setval(J(w))}},{label:"Video URL addition",type:"str",pointer:{main:w, readonly:!0,classes:["embed_code"]},$("<h4>").text("Embed code options").css("margin-top",0),{label:"Autoplay",type:"checkbox",value:!0,pointer:{main:x,index:"autoplay"},"function":function(){x.autoplay=$(this).getval();$(".embed_code").setval(L(x))}},{label:"Force protocol",type:"select",select:[["","Automatic"]],pointer:{main:x,index:"protocol"},classes:["embed_code_forceprotocol"],"function":function(){x.forceprotocol=$(this).getval();$(".embed_code").setval(L(x))}},{label:"Video URL addition",
index:"urlappend"},help:"The embed script will append this string to the video url, useful for sending through params.",classes:["embed_code_forceprotocol"],"function":function(){w.urlappend=$(this).getval();$(".embed_code").setval(J(w))}},$("<h3>").text("Protocol stream urls"),X]));h=$("<span>").append($("<h3>").text("Meta information")).hide();D["Meta information"]=h;var M=$("<span>");h.append(M);b.append(h);h=$("<span>").hide();D.Preview=h;b.append(h);var z=$("<div>").css("float","left").css("margin-right", type:"str",pointer:{main:x,index:"urlappend"},help:"The embed script will append this string to the video url, useful for sending through params.",classes:["embed_code_forceprotocol"],"function":function(){x.urlappend=$(this).getval();$(".embed_code").setval(L(x))}},$("<h3>").text("Protocol stream urls"),X]));l=$("<span>").append($("<h3>").text("Meta information")).hide();E["Meta information"]=l;var O=$("<span>");l.append(O);d.append(l);l=$("<span>").hide();E.Preview=l;d.append(l);var A=$("<div>").css("float",
"1em").attr("data-forcesupportcheck",""),Y=$("<div>").css("float","left");h.append(z).append(Y);mist.stored.get().autoplay&&z.attr("data-autoplay","");var K=function(){z.text("Loading..");var a=document.createElement("script");a.src=G+"embed_"+c+".js";a.onerror=function(){z.html('Error loading "'+a.src+'".<br>').append($("<button>").text("Try again").click(function(){K()}))};a.onload=function(){if(typeof mistvideo[c].error!="undefined")z.html(mistvideo[c].error+"<br>").append($("<button>").text("Try again").click(function(){K()})); "left").css("margin-right","1em").attr("data-forcesupportcheck",""),Y=$("<div>").css("float","left");l.append(A).append(Y);mist.stored.get().autoplay||A.attr("data-noautoplay","");var M=function(){A.text("Loading..");var a=document.createElement("script");a.src=I+"embed_"+c+".js";a.onerror=function(){A.html('Error loading "'+a.src+'".<br>').append($("<button>").text("Try again").click(function(){M()}))};a.onload=function(){if(typeof mistvideo[c].error!="undefined")A.html(mistvideo[c].error+"<br>").append($("<button>").text("Try again").click(function(){M()}));
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();z.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")))); 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();A.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"))));
Y.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],h=f.type.split("/"),i=h[0];i.length<6&&(i=i.toUpperCase());switch(h.length){case 1:break;case 2:i=UI.format.capital(h[0])+" v"+h[1];if(h[0]=="flash")switch(h[1]){case "7":i="Progressive ("+i+")";break;case "10":i="RTMP ("+i+")";break;case "11":i="HDS ("+i+")"}break;case 3:switch(h[2]){case "vnd.apple.mpegurl":i=i+" HLS";break;case "vnd.ms-ss":i=i+" Smooth"; Y.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],h=f.type.split("/"),i=h[0];i.length<6&&(i=i.toUpperCase());switch(h.length){case 1:break;case 2:i=UI.format.capital(h[0])+" v"+h[1];if(h[0]=="flash")switch(h[1]){case "7":i="Progressive ("+i+")";break;case "10":i="RTMP ("+i+")";break;case "11":i="HDS ("+i+")"}break;case 3:switch(h[2]){case "vnd.apple.mpegurl":i=i+" HLS";break;case "vnd.ms-ss":i=i+" Smooth";
break;case "mp2t":i=i+" TS";break;default:h[2].length<6&&(h[2]=h[2].toUpperCase());i=i+(" "+h[2]);h[1]!="video"&&(i=i+(" ("+h[1]+")"))}break;default:i=f.type}i=UI.format.capital(i);d.append($("<option>").text(i).val(f.type).addClass("clear"));e.push({label:i,type:"str",value:f.url,readonly:true,qrcode:true});h=$("<tr>");b.append(h);h.html($("<td>").html($("<input>").attr("type","radio").attr("name","protocolforce").change(function(){z.attr("data-forcetype",$(this).val()).html("Loading embed..");K()}).val(f.type))).append($("<td>").text(i)).append($("<td>").text(f.priority)).append($("<td>").text(f.simul_tracks+ break;case "mp2t":i=i+" TS";break;default:h[2].length<6&&(h[2]=h[2].toUpperCase());i=i+(" "+h[2]);h[1]!="video"&&(i=i+(" ("+h[1]+")"))}break;default:i=f.type}i=UI.format.capital(i);d.append($("<option>").text(i).val(f.type).addClass("clear"));e.push({label:i,type:"str",value:f.url,readonly:true,qrcode:true});h=$("<tr>");b.append(h);h.html($("<td>").html($("<input>").attr("type","radio").attr("name","protocolforce").change(function(){A.attr("data-forcetype",$(this).val()).html("Loading embed..");M()}).val(f.type))).append($("<td>").text(i)).append($("<td>").text(f.priority)).append($("<td>").text(f.simul_tracks+
"/"+f.total_matches)).append($("<td>").text(f.browser_support?"yes":"no"));if(a.embedded&&a.embedded.type==f.type){h.css("outline","1px solid rgba(0,0,0,0.5)");h.find("input[type=radio]").prop("checked",true)}}X.html(UI.buildUI(e));var j;if(c in mistvideo)j=mistvideo[c].meta;if(j){a=[];a.push({label:"Type",type:"span",value:j.live?"Live":"Pre-recorded (VoD)"});"format"in j&&a.push({label:"Format",type:"span",value:j.format});j.live&&a.push({label:"Buffer window",type:"span",value:UI.format.addUnit(j.buffer_window, "/"+f.total_matches)).append($("<td>").text(f.browser_support?"yes":"no"));if(a.embedded&&a.embedded.type==f.type){h.css("outline","1px solid rgba(0,0,0,0.5)");h.find("input[type=radio]").prop("checked",true)}}X.html(UI.buildUI(e));var j;if(c in mistvideo)j=mistvideo[c].meta;if(j){a=[];a.push({label:"Type",type:"span",value:j.live?"Live":"Pre-recorded (VoD)"});"format"in j&&a.push({label:"Format",type:"span",value:j.format});j.live&&a.push({label:"Buffer window",type:"span",value:UI.format.addUnit(j.buffer_window,
"ms")});b={vheader:"Audio",labels:["Codec","Duration","Peak bitrate","Channels","Samplerate"],content:[]};g={vheader:"Video",labels:["Codec","Duration","Peak bitrate","Size","Framerate"],content:[]};d=Object.keys(j.tracks);d.sort(function(a,b){a=a.split("_").pop();b=b.split("_").pop();return a-b});for(var k in d){e=d[k];f=j.tracks[e];switch(f.type){case "audio":b.content.push({header:"Track "+e.split("_").pop(),body:[f.codec,UI.format.duration((f.lastms-f.firstms)/1E3)+"<br><span class=description>"+ "ms")});b={vheader:"Audio",labels:["Codec","Duration","Peak bitrate","Channels","Samplerate"],content:[]};g={vheader:"Video",labels:["Codec","Duration","Peak bitrate","Size","Framerate"],content:[]};d=Object.keys(j.tracks);d.sort(function(a,b){a=a.split("_").pop();b=b.split("_").pop();return a-b});for(var l in d){e=d[l];f=j.tracks[e];switch(f.type){case "audio":b.content.push({header:"Track "+e.split("_").pop(),body:[f.codec,UI.format.duration((f.lastms-f.firstms)/1E3)+"<br><span class=description>"+
UI.format.duration(f.firstms/1E3)+" to "+UI.format.duration(f.lastms/1E3)+"</span>",UI.format.bytes(f.bps,1),f.channels,UI.format.addUnit(UI.format.number(f.rate),"Hz")]});break;case "video":g.content.push({header:"Track "+e.split("_").pop(),body:[f.codec,UI.format.duration((f.lastms-f.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(f.firstms/1E3)+" to "+UI.format.duration(f.lastms/1E3)+"</span>",UI.format.bytes(f.bps,1),UI.format.addUnit(f.width,"x ")+UI.format.addUnit(f.height,"px"), UI.format.duration(f.firstms/1E3)+" to "+UI.format.duration(f.lastms/1E3)+"</span>",UI.format.bytes(f.bps,1),f.channels,UI.format.addUnit(UI.format.number(f.rate),"Hz")]});break;case "video":g.content.push({header:"Track "+e.split("_").pop(),body:[f.codec,UI.format.duration((f.lastms-f.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(f.firstms/1E3)+" to "+UI.format.duration(f.lastms/1E3)+"</span>",UI.format.bytes(f.bps,1),UI.format.addUnit(f.width,"x ")+UI.format.addUnit(f.height,"px"),
UI.format.addUnit(UI.format.number(f.fpks/1E3),"fps")]})}}j=UI.buildVheaderTable(b).css("width","auto");k=UI.buildVheaderTable(g).css("width","auto");a.push($("<span>").text("Tracks:"));a.push($("<div>").css({display:"flex","flex-flow":"row wrap","justify-content":"center","font-size":"0.9em"}).append(j).append(k));M.html(UI.buildUI(a))}else M.html("No meta information available.")}};z.html("")[0].appendChild(a)};K();var N=UI.elements.secondary_menu;N.html("").append($("<a>").addClass("button").text("Choose stream").click(function(){UI.navto("Preview")})).append($("<span>").addClass("separator")); UI.format.addUnit(UI.format.number(f.fpks/1E3),"fps")]})}}j=UI.buildVheaderTable(b).css("width","auto");l=UI.buildVheaderTable(g).css("width","auto");a.push($("<span>").text("Tracks:"));a.push($("<div>").css({display:"flex","flex-flow":"row wrap","justify-content":"center","font-size":"0.9em"}).append(j).append(l));O.html(UI.buildUI(a))}else O.html("No meta information available.")}};A.html("")[0].appendChild(a)};M();var P=UI.elements.secondary_menu;P.html("").append($("<a>").addClass("button").text("Choose stream").click(function(){UI.navto("Preview")})).append($("<span>").addClass("separator"));
h=["Preview","Embed urls","Meta information"];k=h[0];for(q in h)r=$("<a>").addClass("button").text(h[q]).click(function(){N.find(".active").removeClass("active");$(this).addClass("active");for(q in D)D[q].hide();D[$(this).text()].show()}),N.append(r),h[q]==k&&(r.addClass("active"),D[k].show());break;case "Push":var y=$("<div>").text("Loading..");b.append(y);mist.send(function(a){function b(a,c){var d=$("<span>");a.length>=4&&a[2]!=a[3]?d.append($("<span>").text(a[2])).append($("<span>").html("&#187").addClass("unit").css("margin", l=["Preview","Embed urls","Meta information"];v=l[0];for(q in l)r=$("<a>").addClass("button").text(l[q]).click(function(){P.find(".active").removeClass("active");$(this).addClass("active");for(q in E)E[q].hide();E[$(this).text()].show()}),P.append(r),l[q]==v&&(r.addClass("active"),E[v].show());break;case "Push":var z=$("<div>").text("Loading..");d.append(z);mist.send(function(a){function b(a,c){var d=$("<span>");a.length>=4&&a[2]!=a[3]?d.append($("<span>").text(a[2])).append($("<span>").html("&#187").addClass("unit").css("margin",
"0 0.5em")).append($("<span>").text(a[3])):d.append($("<span>").text(a[2]));return $("<tr>").append($("<td>").text(a[1])).append($("<td>").append(d.children())).append($("<td>").append($("<button>").text(c=="Automatic"?"Remove":"Stop").click(function(){if(confirm("Are you sure you want to "+$(this).text().toLowerCase()+" this push?\n"+a[1]+" to "+a[2])){var b=$(this).closest("tr");b.html($("<td colspan=99>").html($("<span>").addClass("red").text(c=="Automatic"?"Removing..":"Stopping..")));c=="Automatic"? "0 0.5em")).append($("<span>").text(a[3])):d.append($("<span>").text(a[2]));return $("<tr>").append($("<td>").text(a[1])).append($("<td>").append(d.children())).append($("<td>").append($("<button>").text(c=="Automatic"?"Remove":"Stop").click(function(){if(confirm("Are you sure you want to "+$(this).text().toLowerCase()+" this push?\n"+a[1]+" to "+a[2])){var b=$(this).closest("tr");b.html($("<td colspan=99>").html($("<span>").addClass("red").text(c=="Automatic"?"Removing..":"Stopping..")));c=="Automatic"?
mist.send(function(){b.remove()},{push_auto_remove:{stream:a[1],target:a[2]}}):mist.send(function(){function c(){setTimeout(function(){mist.send(function(d){var f=false;if("push_list"in d&&d.push_list&&d.push_list.length){var f=true,e;for(e in d.push_list)if(d.push_list[e][0]==a[0]){f=false;break}}else f=true;f?b.remove():c()},{push_list:1})},1E3)}c()},{push_stop:[a[0]]})}})))}y.html("");var c=a.push_settings;c||(c={});y.append(UI.buildUI([{type:"help",help:"You can push streams to files or other servers, allowing them to broadcast your stream as well."}, mist.send(function(){b.remove()},{push_auto_remove:{stream:a[1],target:a[2]}}):mist.send(function(){function c(){setTimeout(function(){mist.send(function(d){var e=false;if("push_list"in d&&d.push_list&&d.push_list.length){var e=true,f;for(f in d.push_list)if(d.push_list[f][0]==a[0]){e=false;break}}else e=true;e?b.remove():c()},{push_list:1})},1E3)}c()},{push_stop:[a[0]]})}})))}z.html("");var c=a.push_settings;c||(c={});z.append(UI.buildUI([{type:"help",help:"You can push streams to files or other servers, allowing them to broadcast your stream as well."},
$("<h3>").text("Settings"),{label:"Delay before retry",unit:"s",type:"int",min:0,help:"How long the delay should be before MistServer retries an automatic push.<br>If set to 0, it does not retry.","default":0,pointer:{main:c,index:"wait"}},{label:"Maximum retries",unit:"/s",type:"int",min:0,help:"The maximum amount of retries per second (for all automatic pushes).<br>If set to 0, there is no limit.","default":0,pointer:{main:c,index:"maxspeed"}},{type:"buttons",buttons:[{type:"save",label:"Save", $("<h3>").text("Settings"),{label:"Delay before retry",unit:"s",type:"int",min:0,help:"How long the delay should be before MistServer retries an automatic push.<br>If set to 0, it does not retry.","default":0,pointer:{main:c,index:"wait"},LTSonly:1},{label:"Maximum retries",unit:"/s",type:"int",min:0,help:"The maximum amount of retries per second (for all automatic pushes).<br>If set to 0, there is no limit.","default":0,pointer:{main:c,index:"maxspeed"},LTSonly:1},{type:"buttons",buttons:[{type:"save",
"function":function(){mist.send(function(){UI.navto("Push")},{push_settings:c})}}]}]));var d=$("<table>").append($("<tr>").append($("<th>").text("Stream")).append($("<th>").text("Target")).append($("<th>"))),e=d.clone();if("push_list"in a)for(var f in a.push_list)d.append(b(a.push_list[f],"Manual"));if("push_auto_list"in a)for(f in a.push_auto_list)e.append(b([-1,a.push_auto_list[f][0],a.push_auto_list[f][1]],"Automatic"));y.append($("<h3>").text("Automatic pushes")).append($("<button>").text("Add an automatic push").click(function(){UI.navto("Start Push", label:"Save","function":function(){mist.send(function(){UI.navto("Push")},{push_settings:c})}}]}]));var d=$("<table>").append($("<tr>").append($("<th>").text("Stream")).append($("<th>").text("Target")).append($("<th>"))),e=d.clone();if("push_list"in a)for(var f in a.push_list)d.append(b(a.push_list[f],"Manual"));if("push_auto_list"in a)for(f in a.push_auto_list)e.append(b([-1,a.push_auto_list[f][0],a.push_auto_list[f][1]],"Automatic"));z.append($("<h3>").text("Automatic pushes")).append($("<button>").text("Add an automatic push").click(function(){UI.navto("Start Push",
"auto")}));e.find("tr").length==1?y.append($("<div>").text("No automatic pushes have been configured.").addClass("text").css("margin-top","0.5em")):y.append(e);y.append($("<h3>").text("Pushes")).append($("<button>").text("Start a push").click(function(){UI.navto("Start Push")}));d.find("tr").length==1?y.append($("<div>").text("No pushes are active.").addClass("text").css("margin-top","0.5em")):y.append($("<button>").text("Stop all pushes").click(function(){var b=[],c;for(c in a.push_list)b.push(a.push_list[c][0]); "auto")}));e.find("tr").length==1?z.append($("<div>").text("No automatic pushes have been configured.").addClass("text").css("margin-top","0.5em")):z.append(e);z.append($("<h3>").text("Pushes")).append($("<button>").text("Start a push").click(function(){UI.navto("Start Push")}));d.find("tr").length==1?z.append($("<div>").text("No pushes are active.").addClass("text").css("margin-top","0.5em")):z.append($("<button>").text("Stop all pushes").click(function(){var b=[],c;for(c in a.push_list)b.push(a.push_list[c][0]);
if(b.length!=0&&confirm("Are you sure you want to stop all pushes?")){mist.send(function(){function a(){setTimeout(function(){mist.send(function(c){var d=false;if("push_list"in c&&c.push_list&&c.push_list.length){var d=true,f;for(f in c.push_list)if(b.indexOf(c.push_list[f][0])==-1){d=false;break}}else d=true;d?UI.navto("Push"):a()},{push_list:1})},1E3)}a()},{push_stop:b});d.find("tr:not(:first-child)").html($("<td colspan=99>").append($("<span>").addClass("red").text("Stopping..")));$(this).remove()}})).append(d)}, if(b.length!=0&&confirm("Are you sure you want to stop all pushes?")){mist.send(function(){function a(){setTimeout(function(){mist.send(function(c){var d=false;if("push_list"in c&&c.push_list&&c.push_list.length){var d=true,e;for(e in c.push_list)if(b.indexOf(c.push_list[e][0])==-1){d=false;break}}else d=true;d?UI.navto("Push"):a()},{push_list:1})},1E3)}a()},{push_stop:b});d.find("tr:not(:first-child)").html($("<td colspan=99>").append($("<span>").addClass("red").text("Stopping..")));$(this).remove()}})).append(d)},
{push_settings:1,push_list:1,push_auto_list:1});break;case "Start Push":if(!("capabilities"in mist.data)){b.append("Loading Mist capabilities..");mist.send(function(){UI.navto("Start Push")},{capabilities:1});break}var t,O=function(){var a=[],d;for(d in mist.data.capabilities.connectors){var f=mist.data.capabilities.connectors[d];"push_urls"in f&&(a=a.concat(f.push_urls))}c=="auto"&&b.find("h2").text("Add automatic push");var e={};b.append(UI.buildUI([{label:"Stream name",type:"str",help:"This may either be a full stream name, a partial wildcard stream name, or a full wildcard stream name.<br>For example, given the stream <i>a</i> you can use:<ul><li><i>a</i>: the stream configured as <i>a</i></li><li><i>a+</i>: all streams configured as <i>a</i> with a wildcard behind it, but not <i>a</i> itself</li><li><i>a+b</i>: only the version of stream <i>a</i> that has wildcard <i>b</i></li></ul>", {push_settings:1,push_list:1,push_auto_list:1});break;case "Start Push":if(!("capabilities"in mist.data)){d.append("Loading Mist capabilities..");mist.send(function(){UI.navto("Start Push")},{capabilities:1});break}var t,Q=function(){var a=[],b;for(b in mist.data.capabilities.connectors){var e=mist.data.capabilities.connectors[b];"push_urls"in e&&(a=a.concat(e.push_urls))}c=="auto"&&d.find("h2").text("Add automatic push");var f={};d.append(UI.buildUI([{label:"Stream name",type:"str",help:"This may either be a full stream name, a partial wildcard stream name, or a full wildcard stream name.<br>For example, given the stream <i>a</i> you can use:<ul><li><i>a</i>: the stream configured as <i>a</i></li><li><i>a+</i>: all streams configured as <i>a</i> with a wildcard behind it, but not <i>a</i> itself</li><li><i>a+b</i>: only the version of stream <i>a</i> that has wildcard <i>b</i></li></ul>",
pointer:{main:e,index:"stream"},validate:["required",function(a){a=a.split("+");a=a[0];return a in mist.data.streams?false:{msg:"'"+a+"' is not a stream name.",classes:["red"]}}],datalist:t},{label:"Target",type:"str",help:"Where the stream will be pushed to.<br>Valid formats:<ul><li>"+a.join("</li><li>")+"</li></ul>",pointer:{main:e,index:"target"},validate:["required",function(b){for(var c in a)if(mist.inputMatch(a[c],b))return false;return{msg:"Does not match a valid target.<br>Valid formats:<ul><li>"+ pointer:{main:f,index:"stream"},validate:["required",function(a){a=a.split("+");a=a[0];return a in mist.data.streams?false:{msg:"'"+a+"' is not a stream name.",classes:["red"]}}],datalist:t,LTSonly:1},{label:"Target",type:"str",help:"Where the stream will be pushed to.<br>Valid formats:<ul><li>"+a.join("</li><li>")+"</li></ul> Valid text replacements:<ul><li>$stream - inserts the stream name used to push to MistServer</li><li>$day - inserts the current day number</li><li>$month - inserts the current month number</li><li>$year - inserts the current year number</li><li>$hour - inserts the hour timestamp when stream was received</li><li>$minute - inserts the minute timestamp the stream was received</li><li>$seconds - inserts the seconds timestamp when the stream was received</li><li>$datetime - inserts $year.$month.$day.$hour.$minute.$seconds timestamp when the stream was received</li>",
a.join("</li><li>")+"</li></ul>",classes:["red"]}}]},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Push")}},{type:"save",label:"Save","function":function(){var a={};a[c=="auto"?"push_auto_add":"push_start"]=e;mist.send(function(){UI.navto("Push")},a)}}]}]))};mist.data.LTS?mist.send(function(a){(t=a.active_streams)||(t=[]);var a=[],b;for(b in t)t[b].indexOf("+")!=-1&&a.push(t[b].replace(/\+.*/,"")+"+");t=t.concat(a);var c=0,d=0;for(b in mist.data.streams){t.push(b); pointer:{main:f,index:"target"},validate:["required",function(b){for(var c in a)if(mist.inputMatch(a[c],b))return false;return{msg:"Does not match a valid target.<br>Valid formats:<ul><li>"+a.join("</li><li>")+"</li></ul>",classes:["red"]}}],LTSonly:1},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Push")}},{type:"save",label:"Save","function":function(){var a={};a[c=="auto"?"push_auto_add":"push_start"]=f;mist.send(function(){UI.navto("Push")},a)}}]}]))};mist.data.LTS?
if(mist.inputMatch(mist.data.capabilities.inputs.Folder.source_match,mist.data.streams[b].source)){t.push(b+"+");mist.send(function(a,b){var f=b.stream,e;for(e in a.browse.files)for(var g in mist.data.capabilities.inputs)g.indexOf("Buffer")>=0||g.indexOf("Folder")>=0||mist.inputMatch(mist.data.capabilities.inputs[g].source_match,"/"+a.browse.files[e])&&t.push(f+"+"+a.browse.files[e]);d++;if(c==d){t=t.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();O()}},{browse:mist.data.streams[b].source}, mist.send(function(a){(t=a.active_streams)||(t=[]);var a=[],b;for(b in t)t[b].indexOf("+")!=-1&&a.push(t[b].replace(/\+.*/,"")+"+");t=t.concat(a);var c=0,d=0;for(b in mist.data.streams){t.push(b);if(mist.inputMatch(mist.data.capabilities.inputs.Folder.source_match,mist.data.streams[b].source)){t.push(b+"+");mist.send(function(a,b){var e=b.stream,f;for(f in a.browse.files)for(var g in mist.data.capabilities.inputs)g.indexOf("Buffer")>=0||g.indexOf("Folder")>=0||mist.inputMatch(mist.data.capabilities.inputs[g].source_match,
{stream:b});c++}}if(c==d){t=t.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();O()}},{active_streams:1}):(t=Object.keys(mist.data.streams),O());break;case "Triggers":"triggers"in mist.data.config||(mist.data.config.triggers={});f=$("<tbody>");d=$("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Trigger on").attr("data-sort-type","string").addClass("sorting-asc")).append($("<th>").text("Applies to").attr("data-sort-type","string")).append($("<th>").text("Handler").attr("data-sort-type", "/"+a.browse.files[f])&&t.push(e+"+"+a.browse.files[f]);d++;if(c==d){t=t.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();Q()}},{browse:mist.data.streams[b].source},{stream:b});c++}}if(c==d){t=t.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();Q()}},{active_streams:1}):(t=Object.keys(mist.data.streams),Q());break;case "Triggers":"triggers"in mist.data.config||(mist.data.config.triggers={});h=$("<tbody>");e=$("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Trigger on").attr("data-sort-type",
"string")).append($("<th>")))).append(f);b.append(UI.buildUI([{type:"help",help:"Triggers are the system you can use to react to events that occur inside MistServer. These allow you to block specific users, redirect streams, keep tabs on what is being pushed where, etcetera. For full documentation, please refer to the developer documentation section on the MistServer website."}])).append($("<button>").text("New trigger").click(function(){UI.navto("Edit Trigger")})).append(d);d.stupidtable();h=mist.data.config.triggers; "string").addClass("sorting-asc")).append($("<th>").text("Applies to").attr("data-sort-type","string")).append($("<th>").text("Handler").attr("data-sort-type","string")).append($("<th>")))).append(h);d.append(UI.buildUI([{type:"help",help:"Triggers are the system you can use to react to events that occur inside MistServer. These allow you to block specific users, redirect streams, keep tabs on what is being pushed where, etcetera. For full documentation, please refer to the developer documentation section on the MistServer website."}])).append($("<button>").text("New trigger").click(function(){UI.navto("Edit Trigger")})).append(e);
for(q in h)for(r in h[q])f.append($("<tr>").attr("data-index",q+","+r).append($("<td>").text(q)).append($("<td>").text(h[q][r][2].join(", "))).append($("<td>").text(h[q][r][0])).append($("<td>").html($("<button>").text("Edit").click(function(){UI.navto("Edit Trigger",$(this).closest("tr").attr("data-index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").attr("data-index").split(",");if(confirm("Are you sure you want to delete this "+a[0]+" trigger?")){mist.data.config.triggers[a[0]].splice(a[1], e.stupidtable();l=mist.data.config.triggers;for(q in l)for(r in l[q])h.append($("<tr>").attr("data-index",q+","+r).append($("<td>").text(q)).append($("<td>").text(l[q][r][2].join(", "))).append($("<td>").text(l[q][r][0])).append($("<td>").html($("<button>").text("Edit").click(function(){UI.navto("Edit Trigger",$(this).closest("tr").attr("data-index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").attr("data-index").split(",");if(confirm("Are you sure you want to delete this "+
1);mist.data.config.triggers[a[0]].length==0&&delete mist.data.config.triggers[a[0]];mist.send(function(){UI.navto("Triggers")},{config:mist.data.config})}}))));break;case "Edit Trigger":"triggers"in mist.data.config||(mist.data.config.triggers={});c?(c=c.split(","),h=mist.data.config.triggers[c[0]][c[1]],o={triggeron:c[0],appliesto:h[2],url:h[0],async:h[1],"default":h[3]}):(b.html($("<h2>").text("New Trigger")),o={});b.append(UI.buildUI([{label:"Trigger on",pointer:{main:o,index:"triggeron"},help:"For what event this trigger should activate.", a[0]+" trigger?")){mist.data.config.triggers[a[0]].splice(a[1],1);mist.data.config.triggers[a[0]].length==0&&delete mist.data.config.triggers[a[0]];mist.send(function(){UI.navto("Triggers")},{config:mist.data.config})}}))));break;case "Edit Trigger":"triggers"in mist.data.config||(mist.data.config.triggers={});c?(c=c.split(","),l=mist.data.config.triggers[c[0]][c[1]],o={triggeron:c[0],appliesto:l[2],url:l[0],async:l[1],"default":l[3]}):(d.html($("<h2>").text("New Trigger")),o={});d.append(UI.buildUI([{label:"Trigger on",
type:"select",select:[["SYSTEM_START","SYSTEM_START: after MistServer boot"],["SYSTEM_STOP","SYSTEM_STOP: right before MistServer shutdown"],["SYSTEM_CONFIG","SYSTEM_CONFIG: after MistServer configurations have changed"],["OUTPUT_START","OUTPUT_START: right after the start command has been send to a protocol"],["OUTPUT_STOP","OUTPUT_STOP: right after the close command has been send to a protocol "],["STREAM_ADD","STREAM_ADD: right before new stream configured"],["STREAM_CONFIG","STREAM_CONFIG: right before a stream configuration has changed"], pointer:{main:o,index:"triggeron"},help:"For what event this trigger should activate.",type:"select",select:[["SYSTEM_START","SYSTEM_START: after MistServer boot"],["SYSTEM_STOP","SYSTEM_STOP: right before MistServer shutdown"],["SYSTEM_CONFIG","SYSTEM_CONFIG: after MistServer configurations have changed"],["OUTPUT_START","OUTPUT_START: right after the start command has been send to a protocol"],["OUTPUT_STOP","OUTPUT_STOP: right after the close command has been send to a protocol "],["STREAM_ADD",
["STREAM_REMOVE","STREAM_REMOVE: right before a stream has been deleted"],["STREAM_SOURCE","STREAM_SOURCE: right before stream source is loaded"],["STREAM_LOAD","STREAM_LOAD: right before stream input is loaded in memory"],["STREAM_READY","STREAM_READY: when the stream input is loaded and ready for playback"],["STREAM_UNLOAD","STREAM_UNLOAD: right before the stream input is removed from memory"],["STREAM_PUSH","STREAM_PUSH: right before an incoming push is accepted"],["STREAM_TRACK_ADD","STREAM_TRACK_ADD: right before a track will be added to a stream; e.g.: additional push received"], "STREAM_ADD: right before new stream configured"],["STREAM_CONFIG","STREAM_CONFIG: right before a stream configuration has changed"],["STREAM_REMOVE","STREAM_REMOVE: right before a stream has been deleted"],["STREAM_SOURCE","STREAM_SOURCE: right before stream source is loaded"],["STREAM_LOAD","STREAM_LOAD: right before stream input is loaded in memory"],["STREAM_READY","STREAM_READY: when the stream input is loaded and ready for playback"],["STREAM_UNLOAD","STREAM_UNLOAD: right before the stream input is removed from memory"],
["STREAM_TRACK_REMOVE","STREAM_TRACK_REMOVE: right before a track will be removed track from a stream; e.g.: push timeout"],["STREAM_BUFFER","STREAM_BUFFER: when a buffer changes between mostly full or mostly empty"],["RTMP_PUSH_REWRITE","RTMP_PUSH_REWRITE: allows rewriting of RTMP push URLs from external to internal representation before further parsing"],["PUSH_OUT_START","RECORDING_VALIDATE: before recording/pushing, allow target changes."],["CONN_OPEN","CONN_OPEN: right after a new incoming connection has been received"], ["STREAM_PUSH","STREAM_PUSH: right before an incoming push is accepted"],["STREAM_TRACK_ADD","STREAM_TRACK_ADD: right before a track will be added to a stream; e.g.: additional push received"],["STREAM_TRACK_REMOVE","STREAM_TRACK_REMOVE: right before a track will be removed track from a stream; e.g.: push timeout"],["STREAM_BUFFER","STREAM_BUFFER: when a buffer changes between mostly full or mostly empty"],["RTMP_PUSH_REWRITE","RTMP_PUSH_REWRITE: allows rewriting of RTMP push URLs from external to internal representation before further parsing"],
["CONN_CLOSE","CONN_CLOSE: right after a connection has been closed"],["CONN_PLAY","CONN_PLAY: right before a stream playback of a connection"],["USER_NEW","USER_NEW: A new user connects that hasn't been allowed or denied access before"]],LTSonly:!0,"function":function(){switch($(this).getval()){case "SYSTEM_START":case "SYSTEM_STOP":case "SYSTEM_CONFIG":case "OUTPUT_START":case "OUTPUT_STOP":case "RTMP_PUSH_REWRITE":$("[name=appliesto]").setval([]).closest(".UIelement").hide();break;default:$("[name=appliesto]").closest(".UIelement").show()}}}, ["PUSH_OUT_START","RECORDING_VALIDATE: before recording/pushing, allow target changes."],["CONN_OPEN","CONN_OPEN: right after a new incoming connection has been received"],["CONN_CLOSE","CONN_CLOSE: right after a connection has been closed"],["CONN_PLAY","CONN_PLAY: right before a stream playback of a connection"],["USER_NEW","USER_NEW: A new user connects that hasn't been allowed or denied access before"]],LTSonly:!0,"function":function(){switch($(this).getval()){case "SYSTEM_START":case "SYSTEM_STOP":case "SYSTEM_CONFIG":case "OUTPUT_START":case "OUTPUT_STOP":case "RTMP_PUSH_REWRITE":$("[name=appliesto]").setval([]).closest(".UIelement").hide();
{label:"Applies to",pointer:{main:o,index:"appliesto"},help:"For triggers that can apply to specific streams, this value decides what streams they are triggered for. (none checked = always triggered)",type:"checklist",checklist:Object.keys(mist.data.streams),LTSonly:!0},$("<br>"),{label:"Handler (URL or executable)",help:"This can be either an HTTP URL or a full path to an executable.",pointer:{main:o,index:"url"},validate:["required"],type:"str",LTSonly:!0},{label:"Blocking",type:"checkbox",help:"If checked, pauses processing and uses the response of the handler. If the response does not start with 1, true, yes or cont, further processing is aborted. If unchecked, processing is never paused and the response is not checked.", break;default:$("[name=appliesto]").closest(".UIelement").show()}}},{label:"Applies to",pointer:{main:o,index:"appliesto"},help:"For triggers that can apply to specific streams, this value decides what streams they are triggered for. (none checked = always triggered)",type:"checklist",checklist:Object.keys(mist.data.streams),LTSonly:!0},$("<br>"),{label:"Handler (URL or executable)",help:"This can be either an HTTP URL or a full path to an executable.",pointer:{main:o,index:"url"},validate:["required"],
pointer:{main:o,index:"async"},LTSonly:!0},{label:"Default response",type:"str",help:"For blocking requests, the default response in case the handler cannot be executed for any reason.",pointer:{main:o,index:"default"},LTSonly:!0},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Triggers")}},{type:"save",label:"Save","function":function(){c&&mist.data.config.triggers[c[0]].splice(c[1],1);var a=[o.url,o.async?true:false,typeof o.appliesto!="undefined"?o.appliesto: type:"str",LTSonly:!0},{label:"Blocking",type:"checkbox",help:"If checked, pauses processing and uses the response of the handler. If the response does not start with 1, true, yes or cont, further processing is aborted. If unchecked, processing is never paused and the response is not checked.",pointer:{main:o,index:"async"},LTSonly:!0},{label:"Default response",type:"str",help:"For blocking requests, the default response in case the handler cannot be executed for any reason.",pointer:{main:o,index:"default"},
[]];typeof o["default"]!="undefined"&&a.push(o["default"]);o.triggeron in mist.data.config.triggers||(mist.data.config.triggers[o.triggeron]=[]);mist.data.config.triggers[o.triggeron].push(a);mist.send(function(){UI.navto("Triggers")},{config:mist.data.config})}}]}]));$("[name=triggeron]").trigger("change");break;case "Logs":var Z=$("<button>").text("Refresh now").click(function(){$(this).text("Loading..");mist.send(function(){P();Z.text("Refresh now")})}).css("padding","0.2em 0.5em").css("flex-grow", LTSonly:!0},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Triggers")}},{type:"save",label:"Save","function":function(){c&&mist.data.config.triggers[c[0]].splice(c[1],1);var a=[o.url,o.async?true:false,typeof o.appliesto!="undefined"?o.appliesto:[]];typeof o["default"]!="undefined"&&a.push(o["default"]);o.triggeron in mist.data.config.triggers||(mist.data.config.triggers[o.triggeron]=[]);mist.data.config.triggers[o.triggeron].push(a);mist.send(function(){UI.navto("Triggers")},
0);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(){UI.interval.clear();UI.interval.set(function(){mist.send(function(){P()})},$(this).val()*1E3)},help:"How often the table below should be updated."}, {config:mist.data.config})}}]}]));$("[name=triggeron]").trigger("change");break;case "Logs":var Z=$("<button>").text("Refresh now").click(function(){$(this).text("Loading..");mist.send(function(){R();Z.text("Refresh now")})}).css("padding","0.2em 0.5em").css("flex-grow",0);d.append(UI.buildUI([{type:"help",help:"Here you have an overview of all edited settings within MistServer and possible warnings or errors MistServer has encountered. MistServer stores up to 100 logs at a time."},{label:"Refresh every",
{label:"..or",type:"DOMfield",DOMfield:Z,help:"Instantly refresh the table below."}]));b.append($("<button>").text("Purge logs").click(function(){mist.send(function(){mist.data.log=[];UI.navto("Logs")},{clearstatlogs:true})}));f=$("<tbody>").css("font-size","0.9em");b.append($("<table>").append(f));var ba=function(a){var b=$("<span>").text(a);switch(a){case "WARN":b.addClass("orange");break;case "ERROR":case "FAIL":b.addClass("red")}return b},P=function(){var a=mist.data.log;if(a){a.length>=2&&a[0][0]< type:"select",select:[[10,"10 seconds"],[30,"30 seconds"],[60,"minute"],[300,"5 minutes"]],value:30,"function":function(){UI.interval.clear();UI.interval.set(function(){mist.send(function(){R()})},$(this).val()*1E3)},help:"How often the table below should be updated."},{label:"..or",type:"DOMfield",DOMfield:Z,help:"Instantly refresh the table below."}]));d.append($("<button>").text("Purge logs").click(function(){mist.send(function(){mist.data.log=[];UI.navto("Logs")},{clearstatlogs:true})}));h=$("<tbody>").css("font-size",
a[a.length-1][0]&&a.reverse();f.html("");for(var b in a)f.append($("<tr>").html($("<td>").text(UI.format.dateTime(a[b][0],"long")).css("white-space","nowrap")).append($("<td>").html(ba(a[b][1])).css("text-align","center")).append($("<td>").text(a[b][2]).css("text-align","left")))}};P();break;case "Statistics":var A=$("<span>").text("Loading..");b.append(A);var o={},u=mist.stored.get().graphs?$.extend(!0,{},mist.stored.get().graphs):{},H={};for(q in mist.data.streams)H[q]=!0;for(q in mist.data.active_streams)H[mist.data.active_streams[q]]= "0.9em");d.append($("<table>").append(h));var ba=function(a){var b=$("<span>").text(a);switch(a){case "WARN":b.addClass("orange");break;case "ERROR":case "FAIL":b.addClass("red")}return b},R=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(ba(a[b][1])).css("text-align","center")).append($("<td>").text(a[b][2]).css("text-align",
!0;var H=Object.keys(H).sort(),Q=[];for(q in mist.data.config.protocols)Q.push(mist.data.config.protocols[q].connector);Q.sort();mist.send(function(){UI.plot.datatype.templates.cpuload.cores=0;for(var a in mist.data.capabilities.cpu)UI.plot.datatype.templates.cpuload.cores=UI.plot.datatype.templates.cpuload.cores+mist.data.capabilities.cpu[a].cores;A.html(UI.buildUI([{type:"help",help:"Here you will find the MistServer stream statistics, you can select various categories yourself. All statistics are live: up to five minutes are saved."}, "left")))}};R();break;case "Statistics":var B=$("<span>").text("Loading..");d.append(B);var o={},u=mist.stored.get().graphs?$.extend(!0,{},mist.stored.get().graphs):{},J={};for(q in mist.data.streams)J[q]=!0;for(q in mist.data.active_streams)J[mist.data.active_streams[q]]=!0;var J=Object.keys(J).sort(),S=[];for(q in mist.data.config.protocols)S.push(mist.data.config.protocols[q].connector);S.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=
$("<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=A.find(".graph_xaxis"),b=A.find(".graph_id");if($(this).val()=="new"){a.children("option").prop("disabled",false);b.setval("Graph "+(Object.keys(u).length+1)).closest("label").show()}else{var c=u[$(this).val()].xaxis;a.children("option").prop("disabled",true).filter('[value="'+c+'"]').prop("disabled", UI.plot.datatype.templates.cpuload.cores+mist.data.capabilities.cpu[a].cores;B.html(UI.buildUI([{type:"help",help:"Here you will find the MistServer stream statistics, you can select various categories yourself. All statistics are live: up to five minutes are saved."},$("<h3>").text("Select the data to display"),{label:"Add to",type:"select",select:[["new","New graph"]],pointer:{main:o,index:"graph"},classes:["graph_ids"],"function":function(){if($(this).val()){var a=B.find(".graph_xaxis"),b=B.find(".graph_id");
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 u?{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"], if($(this).val()=="new"){a.children("option").prop("disabled",false);b.setval("Graph "+(Object.keys(u).length+1)).closest("label").show()}else{var c=u[$(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
"function":function(){$s=A.find(".graph_datatype");switch($(this).getval()){case "coords":$s.children("option").prop("disabled",true).filter('[value="coords"]').prop("disabled",false);break;case "time":$s.children("option").prop("disabled",false).filter('[value="coords"]').prop("disabled",true)}if(!$s.val()||$s.children('option[value="'+$s.val()+'"]:disabled').length){$s.val($s.children("option:enabled").first().val());$s.trigger("change")}}},{label:"Data type",type:"select",select:[["clients","Connections"], u?{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=B.find(".graph_datatype");switch($(this).getval()){case "coords":$s.children("option").prop("disabled",true).filter('[value="coords"]').prop("disabled",false);break;case "time":$s.children("option").prop("disabled",false).filter('[value="coords"]').prop("disabled",
["upbps","Bandwidth (up)"],["downbps","Bandwidth (down)"],["cpuload","CPU use"],["memload","Memory load"],["coords","Client location"]],pointer:{main:o,index:"datatype"},classes:["graph_datatype"],"function":function(){$s=A.find(".graph_origin");switch($(this).getval()){case "cpuload":case "memload":$s.find("input[type=radio]").not('[value="total"]').prop("disabled",true);$s.find('input[type=radio][value="total"]').prop("checked",true);break;default:$s.find("input[type=radio]").prop("disabled",false)}}}, true)}if(!$s.val()||$s.children('option[value="'+$s.val()+'"]:disabled').length){$s.val($s.children("option:enabled").first().val());$s.trigger("change")}}},{label:"Data type",type:"select",select:[["clients","Connections"],["upbps","Bandwidth (up)"],["downbps","Bandwidth (down)"],["cpuload","CPU use"],["memload","Memory load"],["coords","Client location"]],pointer:{main:o,index:"datatype"},classes:["graph_datatype"],"function":function(){$s=B.find(".graph_origin");switch($(this).getval()){case "cpuload":case "memload":$s.find("input[type=radio]").not('[value="total"]').prop("disabled",
{label:"Data origin",type:"radioselect",radioselect:[["total","All"],["stream","The stream:",H],["protocol","The protocol:",Q]],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);u[a.id]=a;A.find("select.graph_ids").append($("<option>").text(a.id)).val(a.id).trigger("change")}else a=u[o.graph];var b=UI.plot.datatype.getOptions({datatype:o.datatype, true);$s.find('input[type=radio][value="total"]').prop("checked",true);break;default:$s.find("input[type=radio]").prop("disabled",false)}}},{label:"Data origin",type:"radioselect",radioselect:[["total","All"],["stream","The stream:",J],["protocol","The protocol:",S]],pointer:{main:o,index:"origin"},value:["total"],classes:["graph_origin"]},{type:"buttons",buttons:[{label:"Add data set",type:"save","function":function(){var a;if(o.graph=="new"){a=UI.plot.addGraph(o,b);u[a.id]=a;B.find("select.graph_ids").append($("<option>").text(a.id)).val(a.id).trigger("change")}else a=
origin:o.origin});a.datasets.push(b);UI.plot.save(a);UI.plot.go(u)}}]}]));var c=$("<div>").addClass("graph_container");b.append(c);var d=A.find("select.graph_ids");for(a in u){var f=UI.plot.addGraph(u[a],c);d.append($("<option>").text(f.id)).val(f.id);var e=[],g;for(g in u[a].datasets){var h=UI.plot.datatype.getOptions({datatype:u[a].datasets[g].datatype,origin:u[a].datasets[g].origin});e.push(h)}f.datasets=e;u[f.id]=f}d.trigger("change");UI.plot.go(u);UI.interval.set(function(){UI.plot.go(u)},1E4)}, u[o.graph];var c=UI.plot.datatype.getOptions({datatype:o.datatype,origin:o.origin});a.datasets.push(c);UI.plot.save(a);UI.plot.go(u)}}]}]));var b=$("<div>").addClass("graph_container");d.append(b);var c=B.find("select.graph_ids");for(a in u){var e=UI.plot.addGraph(u[a],b);c.append($("<option>").text(e.id)).val(e.id);var f=[],g;for(g in u[a].datasets){var h=UI.plot.datatype.getOptions({datatype:u[a].datasets[g].datatype,origin:u[a].datasets[g].origin});f.push(h)}e.datasets=f;u[e.id]=e}c.trigger("change");
{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 R=$("<table>"),S=$("<table>"),h={vheader:"CPUs",labels:["Model","Processor speed","Amount of cores","Amount of threads"],content:[]};for(q in mist.data.capabilities.cpu)r=mist.data.capabilities.cpu[q],h.content.push({header:"CPU #"+(Number(q)+1),body:[r.model,UI.format.addUnit(UI.format.number(r.mhz),"MHz"), UI.plot.go(u);UI.interval.set(function(){UI.plot.go(u)},1E4)},{active_streams:!0,capabilities:!0});break;case "Server Stats":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});d.append("Loading..");break}var T=$("<table>"),U=$("<table>"),l={vheader:"CPUs",labels:["Model","Processor speed","Amount of cores","Amount of threads"],content:[]};for(q in mist.data.capabilities.cpu)r=mist.data.capabilities.cpu[q],l.content.push({header:"CPU #"+(Number(q)+1),
r.cores,r.threads]});var h=UI.buildVheaderTable(h),aa=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("", body:[r.model,UI.format.addUnit(UI.format.number(r.mhz),"MHz"),r.cores,r.threads]});var l=UI.buildVheaderTable(l),aa=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-
"N/A"),UI.format.bytes(a.swapfree*1048576),UI.format.bytes(a.swaptotal*1048576)]}]},a=UI.buildVheaderTable(a);R.replaceWith(a);R=a;b={vheader:"Load average",labels:["CPU use","1 minute","5 minutes","15 minutes"],content:[{header:"&nbsp;",body:[UI.format.addUnit(UI.format.number(mist.data.capabilities.cpu_use/10),"%"),UI.format.number(b.one/100),UI.format.number(b.five/100),UI.format.number(b.fifteen/100)]}]};b=UI.buildVheaderTable(b);S.replaceWith(b);S=b};aa();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", a.swapfree)*1048576),UI.format.addUnit("","N/A"),UI.format.bytes(a.swapfree*1048576),UI.format.bytes(a.swaptotal*1048576)]}]},a=UI.buildVheaderTable(a);T.replaceWith(a);T=a;b={vheader:"Load average",labels:["CPU use","1 minute","5 minutes","15 minutes"],content:[{header:"&nbsp;",body:[UI.format.addUnit(UI.format.number(mist.data.capabilities.cpu_use/10),"%"),UI.format.number(b.one/100),UI.format.number(b.five/100),UI.format.number(b.fifteen/100)]}]};b=UI.buildVheaderTable(b);U.replaceWith(b);U=b};
"auto").addClass("nolay").append($("<tr>").append($("<td>").append(R)).append($("<td>").append(S))).append($("<tr>").append($("<td>").append(h).attr("colspan",2))));UI.interval.set(function(){mist.send(function(){aa()},{capabilities:true})},3E4);break;case "Email for Help":h=$.extend({},mist.data);delete h.statistics;delete h.totals;delete h.clients;delete h.capabilities;h=JSON.stringify(h);h="Version: "+mist.data.config.version+"\n\nConfig:\n"+h;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."}, aa();d.append(UI.buildUI([{type:"help",help:"You can find general server statistics here. Note that memory and CPU usage is for your entire machine, not just MistServer."}])).append($("<table>").css("width","auto").addClass("nolay").append($("<tr>").append($("<td>").append(T)).append($("<td>").append(U))).append($("<tr>").append($("<td>").append(l).attr("colspan",2))));UI.interval.set(function(){mist.send(function(){aa()},{capabilities:true})},3E4);break;case "Email for Help":l=$.extend({},mist.data);
{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:h, delete l.statistics;delete l.totals;delete l.clients;delete l.capabilities;l=JSON.stringify(l);l="Version: "+mist.data.config.version+"\n\nConfig:\n"+l;o={};d.append(UI.buildUI([{type:"help",help:"You can use this form to email MistServer support if you're having difficulties.<br>A copy of your server config file will automatically be included."},{type:"str",label:"Your name",validate:["required"],pointer:{main:o,index:"name"},value:mist.user.name},{type:"email",label:"Your email address",validate:["required"],
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?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."))}}}}; 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:l,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?skin=plain",
"origin"in location||(location.origin=location.protocol+"//"+location.hostname+(location.port?":"+location.port:"")); data:o,success:function(a){a=$("<span>").html(a);a.find("script").remove();d.html(a[0].innerHTML)}})}}]}]));break;case "Disconnect":mist.user.password="";delete mist.user.authstring;delete mist.user.loggedin;UI.navto("Login");break;default:d.append($("<p>").text("This tab does not exist."))}}};"origin"in location||(location.origin=location.protocol+"//"+location.hostname+(location.port?":"+location.port:""));
var mist={data:{},user:{name:"",password:"",host:location.origin+location.pathname.replace(/\/+$/,"")+"/api"},send:function(a,c,b){var c=c||{},b=b||{},b=$.extend(true,{timeout:30,sendData:c},b),d={authorize:{password:mist.user.authstring?MD5(MD5(mist.user.password)+mist.user.authstring):"",username:mist.user.name}};$.extend(true,d,c);log("Send",$.extend(true,{},c));d={url:mist.user.host,type:"POST",data:{command:JSON.stringify(d)},dataType:"jsonp",crossDomain:true,timeout:b.timeout*1E3,async:true, var mist={data:{},user:{name:"",password:"",host:location.origin+location.pathname.replace(/\/+$/,"")+"/api"},send:function(a,c,e){var c=c||{},e=e||{},e=$.extend(true,{timeout:30,sendData:c},e),b={authorize:{password:mist.user.authstring?MD5(MD5(mist.user.password)+mist.user.authstring):"",username:mist.user.name}};$.extend(true,b,c);log("Send",$.extend(true,{},c));b={url:mist.user.host,type:"POST",data:{command:JSON.stringify(b)},dataType:"jsonp",crossDomain:true,timeout:e.timeout*1E3,async:true,
error:function(d,e){delete mist.user.loggedin;if(!b.hide){switch(e){case "timeout":e=$("<i>").text("The connection timed out. ");break;case "abort":e=$("<i>").text("The connection was aborted. ");break;default:e=$("<i>").text(e+". ").css("text-transform","capitalize")}$("#message").addClass("red").text("An error occurred while attempting to communicate with MistServer:").append($("<br>")).append(e).append($("<a>").text("Send server request again").click(function(){mist.send(a,c,b)}))}UI.navto("Login")}, error:function(b,d){delete mist.user.loggedin;if(!e.hide){switch(d){case "timeout":d=$("<i>").text("The connection timed out. ");break;case "abort":d=$("<i>").text("The connection was aborted. ");break;default:d=$("<i>").text(d+". ").css("text-transform","capitalize")}$("#message").addClass("red").text("An error occurred while attempting to communicate with MistServer:").append($("<br>")).append(d).append($("<a>").text("Send server request again").click(function(){mist.send(a,c,e)}))}UI.navto("Login")},
success:function(d){log("Receive",$.extend(true,{},d),"as reply to",b.sendData);delete mist.user.loggedin;switch(d.authorize.status){case "OK":if("streams"in d)if(d.streams)if("incomplete list"in d.streams){delete d.streams["incomplete list"];$.extend(mist.data.streams,d.streams)}else mist.data.streams=d.streams;else mist.data.streams={};var e=$.extend({},d),g=["config","capabilities","ui_settings","LTS","active_streams","browse","log","totals"],p;for(p in e)g.indexOf(p)==-1&&delete e[p];$.extend(true, success:function(b){log("Receive",$.extend(true,{},b),"as reply to",e.sendData);delete mist.user.loggedin;switch(b.authorize.status){case "OK":if("streams"in b)if(b.streams)if("incomplete list"in b.streams){delete b.streams["incomplete list"];$.extend(mist.data.streams,b.streams)}else mist.data.streams=b.streams;else mist.data.streams={};var d=$.extend({},b),f=["config","capabilities","ui_settings","LTS","active_streams","browse","log","totals"],p;for(p in d)f.indexOf(p)==-1&&delete d[p];$.extend(true,
mist.data,e);mist.user.loggedin=true;UI.elements.connection.status.text("Connected").removeClass("red").addClass("green");UI.elements.connection.user_and_host.text(mist.user.name+" @ "+mist.user.host);UI.elements.connection.msg.removeClass("red").text("Last communication with the server at "+UI.format.time((new Date).getTime()/1E3));d.LTS&&UI.elements.menu.find(".LTSonly").removeClass("LTSonly");if(d.log){e=d.log[d.log.length-1];UI.elements.connection.msg.append($("<br>")).append("Last log entry: "+ mist.data,d);mist.user.loggedin=true;UI.elements.connection.status.text("Connected").removeClass("red").addClass("green");UI.elements.connection.user_and_host.text(mist.user.name+" @ "+mist.user.host);UI.elements.connection.msg.removeClass("red").text("Last communication with the server at "+UI.format.time((new Date).getTime()/1E3));b.LTS&&UI.elements.menu.find(".LTSonly").removeClass("LTSonly");if(b.log){d=b.log[b.log.length-1];UI.elements.connection.msg.append($("<br>")).append("Last log entry: "+
UI.format.time(e[0])+" ["+e[1]+"] "+e[2])}if("totals"in d){e=function(a,b,c){var d;d=function(){for(var a in c.fields)e[c.fields[a]].push([j,0])};var e={},g;for(g in c.fields)e[c.fields[g]]=[];var k=0,j;if(c.data){if(c.start>mist.data.config.time-600){j=(mist.data.config.time-600)*1E3;d();j=c.start*1E3;d()}else j=c.start*1E3;for(g in c.data){if(g==0){j=c.start*1E3;var n=0}else{j=j+c.interval[n][1]*1E3;c.interval[n][0]--;if(c.interval[n][0]<=0){n++;n<c.interval.length-1&&(k=k+2)}}if(k%2==1){d();k--}for(var p in c.data[g])e[c.fields[p]].push([j, UI.format.time(d[0])+" ["+d[1]+"] "+d[2])}if("totals"in b){d=function(a,b,c){var d;d=function(){for(var a in c.fields)e[c.fields[a]].push([m,0])};var e={},f;for(f in c.fields)e[c.fields[f]]=[];var i=0,m;if(c.data){if(c.start>mist.data.config.time-600){m=(mist.data.config.time-600)*1E3;d();m=c.start*1E3;d()}else m=c.start*1E3;for(f in c.data){if(f==0){m=c.start*1E3;var p=0}else{m=m+c.interval[p][1]*1E3;c.interval[p][0]--;if(c.interval[p][0]<=0){p++;p<c.interval.length-1&&(i=i+2)}}if(i%2==1){d();i--}for(var G in c.data[f])e[c.fields[G]].push([m,
c.data[g][p]]);if(k){d();k--}}if(mist.data.config.time-c.end>20){d();j=(mist.data.config.time-15)*1E3;d()}}else{j=(mist.data.config.time-600)*1E3;d();j=(mist.data.config.time-15)*1E3;d()}d=e;stream=a?a.join(" "):"all_streams";protocol=b?b.join("_"):"all_protocols";stream in mist.data.totals||(mist.data.totals[stream]={});protocol in mist.data.totals[stream]||(mist.data.totals[stream][protocol]={});$.extend(mist.data.totals[stream][protocol],d)};mist.data.totals={};if("fields"in d.totals)e(c.totals.streams, c.data[f][G]]);if(i){d();i--}}if(mist.data.config.time-c.end>20){d();m=(mist.data.config.time-15)*1E3;d()}}else{m=(mist.data.config.time-600)*1E3;d();m=(mist.data.config.time-15)*1E3;d()}d=e;stream=a?a.join(" "):"all_streams";protocol=b?b.join("_"):"all_protocols";stream in mist.data.totals||(mist.data.totals[stream]={});protocol in mist.data.totals[stream]||(mist.data.totals[stream][protocol]={});$.extend(mist.data.totals[stream][protocol],d)};mist.data.totals={};if("fields"in b.totals)d(c.totals.streams,
c.totals.protocols,d.totals);else for(p in d.totals)e(c.totals[p].streams,c.totals[p].protocols,d.totals[p])}a&&a(d,b);break;case "CHALL":if(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")}else if(mist.user.password=="")UI.navto("Login");else{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; c.totals.protocols,b.totals);else for(p in b.totals)d(c.totals[p].streams,c.totals[p].protocols,b.totals[p])}a&&a(b,e);break;case "CHALL":if(b.authorize.challenge==mist.user.authstring){mist.user.password!=""&&UI.elements.connection.msg.text("The credentials you provided are incorrect.").addClass("red");UI.navto("Login")}else if(mist.user.password=="")UI.navto("Login");else{mist.user.authstring=b.authorize.challenge;mist.send(a,c,e)}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(){e.abort()}));var e=$.ajax(d)},inputMatch:function(a,c){if(typeof a=="undefined")return false;if(typeof a=="string"){var b=a.replace(/[^\w\s]/g,"\\$&"),b=b.replace(/\\\?/g,".").replace(/\\\*/g,"(?:.)*"),b=RegExp("^"+b+"$","i");return b.test(c)}for(var d in a){b=a[d].replace(/[^\w\s]/g, mist.send(a,c,e);break;default:UI.navto("Login")}}};e.hide||UI.elements.connection.msg.removeClass("red").text("Data sent, waiting for a reply..").append($("<br>")).append($("<a>").text("Cancel request").click(function(){d.abort()}));var d=$.ajax(b)},inputMatch:function(a,c){if(typeof a=="undefined")return false;if(typeof a=="string"){var e=a.replace(/[^\w\s]/g,"\\$&"),e=e.replace(/\\\?/g,".").replace(/\\\*/g,"(?:.)*"),e=RegExp("^"+e+"$","i");return e.test(c)}for(var b in a){e=a[b].replace(/[^\w\s]/g,
"\\$&");b=b.replace(/\\\?/g,".").replace(/\\\*/g,"(?:.)*");b=RegExp("^"+b+"$","i");if(b.test(c))return true}return false},convertBuildOptions:function(a,c){var b=[],d=["required","optional"];"desc"in a&&b.push({type:"help",help:a.desc});for(var e in d)if(a[d[e]]){b.push($("<h4>").text(UI.format.capital(d[e])+" parameters"));for(var j in a[d[e]]){var n=a[d[e]][j],g={label:UI.format.capital(n.name),pointer:{main:c,index:j},validate:[]};d[e]=="required"&&!("default"in n)&&g.validate.push("required"); "\\$&");e=e.replace(/\\\?/g,".").replace(/\\\*/g,"(?:.)*");e=RegExp("^"+e+"$","i");if(e.test(c))return true}return false},convertBuildOptions:function(a,c){var e=[],b=["required","optional"];"desc"in a&&e.push({type:"help",help:a.desc});for(var d in b)if(a[b[d]]){e.push($("<h4>").text(UI.format.capital(b[d])+" parameters"));for(var i in a[b[d]]){var m=a[b[d]][i],f={label:UI.format.capital(m.name),pointer:{main:c,index:i},validate:[]};b[d]=="required"&&!("default"in m)&&f.validate.push("required");
if("default"in n)g.placeholder=n["default"];if("help"in n)g.help=n.help;if("unit"in n)g.unit=n.unit;switch(n.type){case "int":g.type="int";break;case "uint":g.type="int";g.min=0;break;case "debug":g.type="debug";break;case "select":g.type="select";g.select=n.select;break;default:g.type="str"}b.push(g)}}return b},stored:{get:function(){return mist.data.ui_settings||{}},set:function(a,c){var b=this.get();b[a]=c;mist.send(function(){},{ui_settings:b})},del:function(a){delete mist.data.ui_settings[a]; if("default"in m)f.placeholder=m["default"];if("help"in m)f.help=m.help;if("unit"in m)f.unit=m.unit;switch(m.type){case "int":f.type="int";break;case "uint":f.type="int";f.min=0;break;case "debug":f.type="debug";break;case "select":f.type="select";f.select=m.select;break;default:f.type="str"}e.push(f)}}return e},stored:{get:function(){return mist.data.ui_settings||{}},set:function(a,c){var e=this.get();e[a]=c;mist.send(function(){},{ui_settings:e})},del:function(a){delete mist.data.ui_settings[a];
mist.send(function(){},{ui_settings:mist.data.ui_settings})}}};function log(){try{UI.debug&&[].push.call(arguments,Error().stack);[].unshift.call(arguments,"["+UI.format.time((new Date).getTime()/1E3)+"]");console.log.apply(console,arguments)}catch(a){}} mist.send(function(){},{ui_settings:mist.data.ui_settings})}}};function log(){try{UI.debug&&[].push.call(arguments,Error().stack);[].unshift.call(arguments,"["+UI.format.time((new Date).getTime()/1E3)+"]");console.log.apply(console,arguments)}catch(a){}}
$.fn.getval=function(){var a=$(this).data("opts"),c=$(this).val();if(a&&"type"in a)switch(a.type){case "span":c=$(this).html();break;case "checkbox":c=$(this).prop("checked");break;case "radioselect":a=$(this).find("label > input[type=radio]:checked").parent();if(a.length){c=[];c.push(a.children("input[type=radio]").val());a=a.children("select");a.length&&c.push(a.val())}else c="";break;case "checklist":c=[];$(this).find(".checklist input[type=checkbox]:checked").each(function(){c.push($(this).attr("name"))})}return c}; $.fn.getval=function(){var a=$(this).data("opts"),c=$(this).val();if(a&&"type"in a)switch(a.type){case "span":c=$(this).html();break;case "checkbox":c=$(this).prop("checked");break;case "radioselect":a=$(this).find("label > input[type=radio]:checked").parent();if(a.length){c=[];c.push(a.children("input[type=radio]").val());a=a.children("select");a.length&&c.push(a.val())}else c="";break;case "checklist":c=[];$(this).find(".checklist input[type=checkbox]:checked").each(function(){c.push($(this).attr("name"))})}return c};
$.fn.setval=function(a){var c=$(this).data("opts");$(this).val(a);if(c&&"type"in c)switch(c.type){case "span":$(this).html(a);break;case "checkbox":$(this).prop("checked",a);break;case "geolimited":case "hostlimited":c=$(this).closest(".field_container").data("subUI");if(typeof a=="undefined"||a.length==0)a="-";c.blackwhite.val(a.charAt(0));var a=a.substr(1).split(" "),b;for(b in a)c.values.append(c.prototype.clone(true).val(a[b]));c.blackwhite.trigger("change");break;case "radioselect":if(typeof a== $.fn.setval=function(a){var c=$(this).data("opts");$(this).val(a);if(c&&"type"in c)switch(c.type){case "span":$(this).html(a);break;case "checkbox":$(this).prop("checked",a);break;case "geolimited":case "hostlimited":c=$(this).closest(".field_container").data("subUI");if(typeof a=="undefined"||a.length==0)a="-";c.blackwhite.val(a.charAt(0));var a=a.substr(1).split(" "),e;for(e in a)c.values.append(c.prototype.clone(true).val(a[e]));c.blackwhite.trigger("change");break;case "radioselect":if(typeof a==
"undefined")return $(this);b=$(this).find('label > input[type=radio][value="'+a[0]+'"]').prop("checked",true).parent();a.length>1&&b.children("select").val(a[1]);break;case "checklist":c=$(this).find(".checklist input[type=checkbox]").prop("checked",false);for(b in a)c.filter('[name="'+a[b]+'"]').prop("checked",true)}$(this).trigger("change");return $(this)}; "undefined")return $(this);e=$(this).find('label > input[type=radio][value="'+a[0]+'"]').prop("checked",true).parent();a.length>1&&e.children("select").val(a[1]);break;case "checklist":c=$(this).find(".checklist input[type=checkbox]").prop("checked",false);for(e in a)c.filter('[name="'+a[e]+'"]').prop("checked",true)}$(this).trigger("change");return $(this)};

View file

@ -2789,23 +2789,22 @@ var UI = {
tabs['Embed urls'] = $embedlinks; tabs['Embed urls'] = $embedlinks;
$main.append($embedlinks); $main.append($embedlinks);
function parseURL(url) { function parseURL(url) {
var pattern = /(https?)\:\/\/([^:\/]+)\:(\d+)?/i; var a = document.createElement('a');
var retobj = {protocol: '', host: '', port: ''}; a.href = url;
var results = url.match(pattern); return {
if(results != null) { protocol: a.protocol+'//',
retobj.protocol = results[1]; host: a.hostname,
retobj.host = results[2]; port: (a.port ? ':'+a.port : '')
retobj.port = results[3]; };
} }
return retobj; var parsed = parseURL(mist.user.host);
} var embedbase = parsed.protocol+parsed.host+http_port+'/';
var embedbase = 'http://'+parseURL(mist.user.host).host+http_port+'/'; var embedoptions = {autoplay: true};
var embedoptions = {};
function embedhtml(opts) { function embedhtml(opts) {
var open = ['div']; var open = ['div'];
var inner = "\n"+' <script src="'+embedbase+'embed_'+other+'.js"><'+'/script>'+"\n"; //don't leave the closing script tag complete var inner = "\n"+' <script src="'+embedbase+'embed_'+other+'.js"><'+'/script>'+"\n"; //don't leave the closing script tag complete
if (opts.autoplay) { if (!opts.autoplay) {
open.push('data-autoplay'); open.push('data-noautoplay');
} }
if ((opts.forceprotocol) && (opts.forceprotocol != '')) { if ((opts.forceprotocol) && (opts.forceprotocol != '')) {
open.push('data-forcetype="'+opts.forceprotocol+'"'); open.push('data-forcetype="'+opts.forceprotocol+'"');
@ -2846,6 +2845,7 @@ var UI = {
},$('<h4>').text('Embed code options').css('margin-top',0),{ },$('<h4>').text('Embed code options').css('margin-top',0),{
label: 'Autoplay', label: 'Autoplay',
type: 'checkbox', type: 'checkbox',
value: true,
pointer: { pointer: {
main: embedoptions, main: embedoptions,
index: 'autoplay' index: 'autoplay'
@ -2989,8 +2989,8 @@ var UI = {
var $protocols = $('<div>').css('float','left'); var $protocols = $('<div>').css('float','left');
$preview.append($video).append($protocols); $preview.append($video).append($protocols);
if (mist.stored.get().autoplay) { if (!mist.stored.get().autoplay) {
$video.attr('data-autoplay',''); $video.attr('data-noautoplay','');
} }
function loadVideo() { function loadVideo() {
@ -3209,7 +3209,8 @@ var UI = {
pointer: { pointer: {
main: push_settings, main: push_settings,
index: 'wait' index: 'wait'
} },
LTSonly: 1
},{ },{
label: 'Maximum retries', label: 'Maximum retries',
unit: '/s', unit: '/s',
@ -3220,7 +3221,8 @@ var UI = {
pointer: { pointer: {
main: push_settings, main: push_settings,
index: 'maxspeed' index: 'maxspeed'
} },
LTSonly: 1
},{ },{
type: 'buttons', type: 'buttons',
buttons: [{ buttons: [{
@ -3460,7 +3462,8 @@ var UI = {
classes: ['red'] classes: ['red']
}; };
}], }],
datalist: allthestreams datalist: allthestreams,
LTSonly: 1
},{ },{
label: 'Target', label: 'Target',
type: 'str', type: 'str',
@ -3479,7 +3482,8 @@ var UI = {
msg: 'Does not match a valid target.<br>Valid formats:<ul><li>'+target_match.join('</li><li>')+'</li></ul>', msg: 'Does not match a valid target.<br>Valid formats:<ul><li>'+target_match.join('</li><li>')+'</li></ul>',
classes: ['red'] classes: ['red']
} }
}] }],
LTSonly: 1
},{ },{
type: 'buttons', type: 'buttons',
buttons: [ buttons: [

View file

@ -236,7 +236,7 @@ function mistembed(streamname) {
container = document.createElement('div'), container = document.createElement('div'),
forceType = false, forceType = false,
forceSupportCheck = false, forceSupportCheck = false,
autoplay = false, autoplay = true,
urlappend = false; urlappend = false;
if (me.parentNode.hasAttribute('data-forcetype')) { if (me.parentNode.hasAttribute('data-forcetype')) {
@ -245,8 +245,8 @@ function mistembed(streamname) {
if (me.parentNode.hasAttribute('data-forcesupportcheck')) { if (me.parentNode.hasAttribute('data-forcesupportcheck')) {
forceSupportCheck = true; forceSupportCheck = true;
} }
if (me.parentNode.hasAttribute('data-autoplay')) { if (me.parentNode.hasAttribute('data-noautoplay')) {
autoplay = true; autoplay = false;
} }
if (me.parentNode.hasAttribute('data-urlappend')) { if (me.parentNode.hasAttribute('data-urlappend')) {
urlappend = me.parentNode.getAttribute('data-urlappend'); urlappend = me.parentNode.getAttribute('data-urlappend');