LSP: stop_sessions when editing a stream
This commit is contained in:
parent
80bd99de44
commit
5501c67b49
2 changed files with 103 additions and 89 deletions
179
lsp/minified.js
179
lsp/minified.js
|
@ -1,11 +1,11 @@
|
|||
var MD5=function(a){function c(a,c){var b,e,d,h,f;d=a&2147483648;h=c&2147483648;b=a&1073741824;e=c&1073741824;f=(a&1073741823)+(c&1073741823);return b&e?f^2147483648^d^h:b|e?f&1073741824?f^3221225472^d^h:f^1073741824^d^h:f^d^h}function e(a,b,d,e,h,f,g){a=c(a,c(c(b&d|~b&e,h),g));return c(a<<f|a>>>32-f,b)}function b(a,b,d,e,h,f,g){a=c(a,c(c(b&e|d&~e,h),g));return c(a<<f|a>>>32-f,b)}function d(a,b,d,e,h,f,g){a=c(a,c(c(b^d^e,h),g));return c(a<<f|a>>>32-f,b)}function i(a,b,d,e,h,f,g){a=c(a,c(c(d^(b|~e),
|
||||
h),g));return c(a<<f|a>>>32-f,b)}function n(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 g=[],p,m,s,l,f,h,k,j,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);s=Array(m-1);for(f=l=0;f<a;)p=
|
||||
(f-f%4)/4,l=8*(f%4),s[p]|=g.charCodeAt(f)<<l,f++;p=(f-f%4)/4;s[p]|=128<<8*(f%4);s[m-2]=a<<3;s[m-1]=a>>>29;g=s;f=1732584193;h=4023233417;k=2562383102;j=271733878;for(a=0;a<g.length;a+=16)p=f,m=h,s=k,l=j,f=e(f,h,k,j,g[a+0],7,3614090360),j=e(j,f,h,k,g[a+1],12,3905402710),k=e(k,j,f,h,g[a+2],17,606105819),h=e(h,k,j,f,g[a+3],22,3250441966),f=e(f,h,k,j,g[a+4],7,4118548399),j=e(j,f,h,k,g[a+5],12,1200080426),k=e(k,j,f,h,g[a+6],17,2821735955),h=e(h,k,j,f,g[a+7],22,4249261313),f=e(f,h,k,j,g[a+8],7,1770035416),
|
||||
j=e(j,f,h,k,g[a+9],12,2336552879),k=e(k,j,f,h,g[a+10],17,4294925233),h=e(h,k,j,f,g[a+11],22,2304563134),f=e(f,h,k,j,g[a+12],7,1804603682),j=e(j,f,h,k,g[a+13],12,4254626195),k=e(k,j,f,h,g[a+14],17,2792965006),h=e(h,k,j,f,g[a+15],22,1236535329),f=b(f,h,k,j,g[a+1],5,4129170786),j=b(j,f,h,k,g[a+6],9,3225465664),k=b(k,j,f,h,g[a+11],14,643717713),h=b(h,k,j,f,g[a+0],20,3921069994),f=b(f,h,k,j,g[a+5],5,3593408605),j=b(j,f,h,k,g[a+10],9,38016083),k=b(k,j,f,h,g[a+15],14,3634488961),h=b(h,k,j,f,g[a+4],20,3889429448),
|
||||
f=b(f,h,k,j,g[a+9],5,568446438),j=b(j,f,h,k,g[a+14],9,3275163606),k=b(k,j,f,h,g[a+3],14,4107603335),h=b(h,k,j,f,g[a+8],20,1163531501),f=b(f,h,k,j,g[a+13],5,2850285829),j=b(j,f,h,k,g[a+2],9,4243563512),k=b(k,j,f,h,g[a+7],14,1735328473),h=b(h,k,j,f,g[a+12],20,2368359562),f=d(f,h,k,j,g[a+5],4,4294588738),j=d(j,f,h,k,g[a+8],11,2272392833),k=d(k,j,f,h,g[a+11],16,1839030562),h=d(h,k,j,f,g[a+14],23,4259657740),f=d(f,h,k,j,g[a+1],4,2763975236),j=d(j,f,h,k,g[a+4],11,1272893353),k=d(k,j,f,h,g[a+7],16,4139469664),
|
||||
h=d(h,k,j,f,g[a+10],23,3200236656),f=d(f,h,k,j,g[a+13],4,681279174),j=d(j,f,h,k,g[a+0],11,3936430074),k=d(k,j,f,h,g[a+3],16,3572445317),h=d(h,k,j,f,g[a+6],23,76029189),f=d(f,h,k,j,g[a+9],4,3654602809),j=d(j,f,h,k,g[a+12],11,3873151461),k=d(k,j,f,h,g[a+15],16,530742520),h=d(h,k,j,f,g[a+2],23,3299628645),f=i(f,h,k,j,g[a+0],6,4096336452),j=i(j,f,h,k,g[a+7],10,1126891415),k=i(k,j,f,h,g[a+14],15,2878612391),h=i(h,k,j,f,g[a+5],21,4237533241),f=i(f,h,k,j,g[a+12],6,1700485571),j=i(j,f,h,k,g[a+3],10,2399980690),
|
||||
k=i(k,j,f,h,g[a+10],15,4293915773),h=i(h,k,j,f,g[a+1],21,2240044497),f=i(f,h,k,j,g[a+8],6,1873313359),j=i(j,f,h,k,g[a+15],10,4264355552),k=i(k,j,f,h,g[a+6],15,2734768916),h=i(h,k,j,f,g[a+13],21,1309151649),f=i(f,h,k,j,g[a+4],6,4149444226),j=i(j,f,h,k,g[a+11],10,3174756917),k=i(k,j,f,h,g[a+2],15,718787259),h=i(h,k,j,f,g[a+9],21,3951481745),f=c(f,p),h=c(h,m),k=c(k,s),j=c(j,l);return(n(f)+n(h)+n(k)+n(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(n){case "string":case "string-ins":c=String(c).toLowerCase();break;case "int":c=
|
||||
parseInt(Number(c));break;case "float":c=Number(c)}return c}var e=a(this),b=e.closest("table"),d=b.children("tbody"),i=d.children("tr"),n=e.attr("data-sort-type");if(n){var g=!0;e.hasClass("sorting-asc")&&(g=!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=g?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(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})});
|
||||
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),
|
||||
h),f));return c(a<<g|a>>>32-g,b)}function n(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,m,s,l,g,h,k,j,f=a.replace(/\r\n/g,"\n"),a="";for(p=0;p<f.length;p++)m=f.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));f=a;a=f.length;p=a+8;m=16*((p-p%64)/64+1);s=Array(m-1);for(g=l=0;g<a;)p=
|
||||
(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[m-2]=a<<3;s[m-1]=a>>>29;f=s;g=1732584193;h=4023233417;k=2562383102;j=271733878;for(a=0;a<f.length;a+=16)p=g,m=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),
|
||||
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),
|
||||
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),
|
||||
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),
|
||||
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,m),k=c(k,s),j=c(j,l);return(n(g)+n(h)+n(k)+n(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(n){case "string":case "string-ins":c=String(c).toLowerCase();break;case "int":c=
|
||||
parseInt(Number(c));break;case "float":c=Number(c)}return c}var e=a(this),b=e.closest("table"),d=b.children("tbody"),i=d.children("tr"),n=e.attr("data-sort-type");if(n){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])});
|
||||
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:"Å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",
|
||||
|
@ -20,44 +20,44 @@ UA:"Ukraine",AE:"United Arab Emirates",GB:"United Kingdom",US:"United States",UM
|
|||
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"}}}}],
|
||||
buildMenu:function(){function a(a,c){var b=$("<a>").addClass("button");b.html($("<span>").addClass("plain").text(a)).append($("<span>").addClass("highlighted").text(a));for(var d in c.classes)b.addClass(c.classes[d]);"LTSonly"in c&&b.addClass("LTSonly");"link"in c?b.attr("href",c.link).attr("target","_blank"):"submenu"in c||b.click(function(c){$(this).closest(".menu").hasClass("hide")||(UI.navto(a),c.stopPropagation())});return b}var c=UI.elements.menu,e;for(e in UI.menu){0<e&&c.append($("<br>"));
|
||||
for(var b in UI.menu[e]){var d=UI.menu[e][b],i=a(b,d);c.append(i);if("submenu"in d){var n=$("<span>").addClass("submenu");i.addClass("arrowdown").append(n);for(var g in d.submenu)n.append(a(g,d.submenu[g]))}}}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"))},
|
||||
for(var b in UI.menu[e]){var d=UI.menu[e][b],i=a(b,d);c.append(i);if("submenu"in d){var n=$("<span>").addClass("submenu");i.addClass("arrowdown").append(n);for(var f in d.submenu)n.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"),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").on("keydown",function(a){a.stopPropagation()}),"css"in b&&d.css(b.css),c.append(d),b.buttons){var n=b.buttons[i],g=$("<button>").text(n.label).data("opts",n);"css"in n&&g.css(n.css);d.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"),c=!1;a.find(".hasValidate").each(function(){if(c=$(this).data("validate")(this,!0))return!1});
|
||||
c||(a.find(".isSetting").each(function(){var a=$(this).getval(),c=$(this).data("pointer");if(""==a)if("default"in $(this).data("opts"))a=$(this).data("opts")["default"];else return delete c.main[c.index],!0;c.main[c.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 b&&n.css(b.css);n.append($("<span>").addClass("label").html("label"in b?b.label+":":""));g=$("<span>").addClass("field_container");
|
||||
n.append(g);switch(b.type){case "password":d=$("<input>").attr("type","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"],
|
||||
b.type)for(i in d=$("<span>").addClass("button_container").on("keydown",function(a){a.stopPropagation()}),"css"in b&&d.css(b.css),c.append(d),b.buttons){var n=b.buttons[i],f=$("<button>").text(n.label).data("opts",n);"css"in n&&f.css(n.css);d.append(f);switch(n.type){case "cancel":f.addClass("cancel").click(n["function"]);break;case "save":f.addClass("save").click(function(){var a=$(this).closest(".input_container"),c=!1;a.find(".hasValidate").each(function(){if(c=$(this).data("validate")(this,!0))return!1});
|
||||
c||(a.find(".isSetting").each(function(){var a=$(this).getval(),c=$(this).data("pointer");if(""==a)if("default"in $(this).data("opts"))a=$(this).data("opts")["default"];else return delete c.main[c.index],!0;c.main[c.index]=a}),(a=$(this).data("opts")["function"])&&a(this))});break;default:f.click(n["function"])}}else{n=$("<label>").addClass("UIelement");c.append(n);"css"in b&&n.css(b.css);n.append($("<span>").addClass("label").html("label"in b?b.label+":":""));f=$("<span>").addClass("field_container");
|
||||
n.append(f);switch(b.type){case "password":d=$("<input>").attr("type","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":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":d=$("<input>").attr("type","checkbox");break;case "hidden":d=$("<input>").attr("type","hidden");n.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(e in b.radioselect){var m=$("<input>").attr("type","radio").val(b.radioselect[e][0]).attr("name",b.label);("LTSonly"in b&&!mist.data.LTS||b.readonly)&&m.prop("disabled",!0);p=$("<label>").append(m).append($("<span>").html(b.radioselect[e][1]));d.append(p);if(2<b.radioselect[e].length)for(i in m=$("<select>").change(function(){$(this).parent().find("input[type=radio]:enabled").prop("checked","true")}),p.append(m),("LTSonly"in
|
||||
b&&!mist.data.LTS||b.readonly)&&m.prop("disabled",!0),b.radioselect[e][2])p=$("<option>"),m.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(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",
|
||||
b);"pointer"in b&&d.attr("name",b.pointer.index);g.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&&g.append($("<span>").addClass("unit").html(b.unit));"readonly"in b&&(d.attr("readonly","readonly"),d.click(function(){$(this).select()}));"qrcode"in b&&g.append($("<span>").addClass("unit").html($("<button>").text("QR").on("keydown",function(a){a.stopPropagation()}).click(function(){var a=
|
||||
String($(this).closest(".field_container").find(".field").getval()),c=$("<div>").addClass("qrcode");UI.popup.show($("<span>").addClass("qr_container").append($("<p>").text(a)).append(c));c.qrcode({text:a,size:Math.min(c.width(),c.height())})})));"rows"in b&&d.attr("rows",b.rows);"LTSonly"in b&&!mist.data.LTS&&(g.addClass("LTSonly"),d.prop("disabled",!0));switch(b.type){case "browse":m=$("<div>").addClass("grouper").append(n);c.append(m);m=$("<button>").text("Browse").on("keydown",function(a){a.stopPropagation()});
|
||||
g.append(m);m.click(function(){function a(c){i.text("Loading..");mist.send(function(a){n.text(a.browse.path[0]);mist.data.LTS&&d.setval(a.browse.path[0]+"/");i.html(m.clone(true).text("..").attr("title","Folder up"));if(a.browse.subdirectories){a.browse.subdirectories.sort();for(var c in a.browse.subdirectories){var g=a.browse.subdirectories[c];i.append(m.clone(true).attr("title",n.text()+o+g).text(g))}}if(a.browse.files){a.browse.files.sort();for(c in a.browse.files){var g=a.browse.files[c],j=n.text()+
|
||||
o+g,g=$("<a>").text(g).addClass("file").attr("title",j);i.append(g);if(p){var l=true,s;for(s in p)if(typeof p[s]!="undefined"&&mist.inputMatch(p[s],j)){l=false;break}l&&g.hide()}g.click(function(){var a=$(this).attr("title");d.setval(a).removeAttr("readonly").css("opacity",1);e.show();b.remove()})}}},{browse:c})}var c=$(this).closest(".grouper"),b=$("<div>").addClass("browse_container"),d=c.find(".field").attr("readonly","readonly").css("opacity",0.5),e=$(this),g=$("<button>").text("Stop browsing").click(function(){e.show();
|
||||
b.remove();d.removeAttr("readonly").css("opacity",1)}),n=$("<span>").addClass("field"),i=$("<div>").addClass("browse_contents"),m=$("<a>").addClass("folder"),p=d.data("filetypes");c.append(b);b.append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Current folder:")).append($("<span>").addClass("field_container").append(n).append(g))).append(i);var o="/";mist.data.config.version.indexOf("indows")>-1&&(o="\\");m.click(function(){var c=n.text()+o+$(this).text();a(c)});
|
||||
c=d.getval();g=c.split("://");g.length>1&&(c=g[0]=="file"?g[1]:"");o=="\\"&&(c="/cygdrive/C/");c=c.split(o);c.pop();c=c.join(o);e.hide();a(c)});break;case "geolimited":case "hostlimited":m={field:d};m.blackwhite=$("<select>").append($("<option>").val("-").text("Blacklist")).append($("<option>").val("+").text("Whitelist"));m.values=$("<span>").addClass("limit_value_list");switch(b.type){case "geolimited":m.prototype=$("<select>").append($("<option>").val("").text("[Select a country]"));for(e in UI.countrylist)m.prototype.append($("<option>").val(e).html(UI.countrylist[e]));
|
||||
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").on("keydown",function(a){a.stopPropagation()}).click(function(){var a=
|
||||
String($(this).closest(".field_container").find(".field").getval()),c=$("<div>").addClass("qrcode");UI.popup.show($("<span>").addClass("qr_container").append($("<p>").text(a)).append(c));c.qrcode({text:a,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":m=$("<div>").addClass("grouper").append(n);c.append(m);m=$("<button>").text("Browse").on("keydown",function(a){a.stopPropagation()});
|
||||
f.append(m);m.click(function(){function a(c){i.text("Loading..");mist.send(function(a){n.text(a.browse.path[0]);mist.data.LTS&&d.setval(a.browse.path[0]+"/");i.html(m.clone(true).text("..").attr("title","Folder up"));if(a.browse.subdirectories){a.browse.subdirectories.sort();for(var c in a.browse.subdirectories){var f=a.browse.subdirectories[c];i.append(m.clone(true).attr("title",n.text()+o+f).text(f))}}if(a.browse.files){a.browse.files.sort();for(c in a.browse.files){var f=a.browse.files[c],j=n.text()+
|
||||
o+f,f=$("<a>").text(f).addClass("file").attr("title",j);i.append(f);if(p){var l=true,s;for(s in p)if(typeof p[s]!="undefined"&&mist.inputMatch(p[s],j)){l=false;break}l&&f.hide()}f.click(function(){var a=$(this).attr("title");d.setval(a).removeAttr("readonly").css("opacity",1);e.show();b.remove()})}}},{browse:c})}var c=$(this).closest(".grouper"),b=$("<div>").addClass("browse_container"),d=c.find(".field").attr("readonly","readonly").css("opacity",0.5),e=$(this),f=$("<button>").text("Stop browsing").click(function(){e.show();
|
||||
b.remove();d.removeAttr("readonly").css("opacity",1)}),n=$("<span>").addClass("field"),i=$("<div>").addClass("browse_contents"),m=$("<a>").addClass("folder"),p=d.data("filetypes");c.append(b);b.append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Current folder:")).append($("<span>").addClass("field_container").append(n).append(f))).append(i);var o="/";mist.data.config.version.indexOf("indows")>-1&&(o="\\");m.click(function(){var c=n.text()+o+$(this).text();a(c)});
|
||||
c=d.getval();f=c.split("://");f.length>1&&(c=f[0]=="file"?f[1]:"");o=="\\"&&(c="/cygdrive/C/");c=c.split(o);c.pop();c=c.join(o);e.hide();a(c)});break;case "geolimited":case "hostlimited":m={field:d};m.blackwhite=$("<select>").append($("<option>").val("-").text("Blacklist")).append($("<option>").val("+").text("Whitelist"));m.values=$("<span>").addClass("limit_value_list");switch(b.type){case "geolimited":m.prototype=$("<select>").append($("<option>").val("").text("[Select a country]"));for(e in UI.countrylist)m.prototype.append($("<option>").val(e).html(UI.countrylist[e]));
|
||||
break;case "hostlimited":m.prototype=$("<input>").attr("type","text").attr("placeholder","type a host")}m.prototype.on("change keyup",function(){$(this).closest(".field_container").data("subUI").blackwhite.trigger("change")});m.blackwhite.change(function(){var a=$(this).closest(".field_container").data("subUI"),c=[],b=false;a.values.children().each(function(){b=$(this).val();b!=""?c.push(b):$(this).remove()});a.values.append(a.prototype.clone(true));c.length>0?a.field.val($(this).val()+c.join(" ")):
|
||||
a.field.val("");a.field.trigger("change")});"LTSonly"in b&&!mist.data.LTS&&(m.blackwhite.prop("disabled",!0),m.prototype.prop("disabled",!0));m.values.append(m.prototype.clone(!0));g.data("subUI",m).addClass("limit_list").append(m.blackwhite).append(m.values)}"pointer"in b&&(d.data("pointer",b.pointer).addClass("isSetting"),m=b.pointer.main[b.pointer.index],"undefined"!=m&&d.setval(m));"value"in b&&d.setval(b.value);if("datalist"in b)for(e in m="datalist_"+e+MD5(d[0].outerHTML),d.attr("list",m),m=
|
||||
$("<datalist>").attr("id",m),g.append(m),b.datalist)m.append($("<option>").val(b.datalist[e]));g=$("<span>").addClass("help_container");n.append(g);"help"in b&&(g.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 b){n=[];for(i in b.validate){m=b.validate[i];if("function"!=typeof m)switch(m){case "required":m=function(a){return a==
|
||||
a.field.val("");a.field.trigger("change")});"LTSonly"in b&&!mist.data.LTS&&(m.blackwhite.prop("disabled",!0),m.prototype.prop("disabled",!0));m.values.append(m.prototype.clone(!0));f.data("subUI",m).addClass("limit_list").append(m.blackwhite).append(m.values)}"pointer"in b&&(d.data("pointer",b.pointer).addClass("isSetting"),m=b.pointer.main[b.pointer.index],"undefined"!=m&&d.setval(m));"value"in b&&d.setval(b.value);if("datalist"in b)for(e in m="datalist_"+e+MD5(d[0].outerHTML),d.attr("list",m),m=
|
||||
$("<datalist>").attr("id",m),f.append(m),b.datalist)m.append($("<option>").val(b.datalist[e]));f=$("<span>").addClass("help_container");n.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 b){n=[];for(i in b.validate){m=b.validate[i];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,c){var b=$(c).data("opts");if(!$(c)[0].validity.valid){var d=[];"min"in b&&d.push(" greater than or equal to "+b.min);"max"in b&&d.push(" smaller than or equal to "+b.max);return{msg:"Please enter an integer"+d.join(" and")+".",classes:["red"]}}if(parseInt(Number(a))!=a)return{msg:"Please enter an integer.",classes:["red"]}};break;case "streamname":m=function(a,c){if(!isNaN(a.charAt(0)))return{msg:"The first character may not be a number.",
|
||||
classes:["red"]};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)}d.data("validate_functions",
|
||||
n).data("help_container",g).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 g in d){var n=d[g](b,a);if(n){$err=$("<span>").addClass("err_balloon").html(n.msg);for(var i in n.classes)$err.addClass(n.classes[i]);e.prepend($err);c&&$(a).focus();return true}}return false}).addClass("hasValidate").on("change keyup",function(){$(this).data("validate")($(this))});""!=d.getval()&&d.trigger("change")}"function"in
|
||||
n).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 n=d[f](b,a);if(n){$err=$("<span>").addClass("err_balloon").html(n.msg);for(var i in n.classes)$err.addClass(n.classes[i]);e.prepend($err);c&&$(a).focus();return true}}return false}).addClass("hasValidate").on("change keyup",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))),b=[];e.append($("<td>"));for(var d in a.labels)b.push($("<tr>").append($("<td>").html(""==
|
||||
a.labels[d]?" ":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(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:[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=[],m;for(m in b.datasets){var s=b.datasets[m];s.display&&(s.getdata(),s.yaxistype in b.yaxes||(d.push(UI.plot.yaxes[s.yaxistype]),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",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=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 g in b.datasets){var f=
|
||||
" ";if(b.datasets[g].display){var e=UI.plot.yaxes[b.datasets[g].yaxistype].tickFormatter,i=b.datasets[g].data;if(a)for(var l in i){if(i[l][0]==a){f=e(i[l][1]);break}if(i[l][0]>a){if(l!=0){f=i[l];i=i[l-1];f=e(f[1]+(a-f[0])*(i[1]-f[1])/(i[0]-f[0]))}break}}else f=e(b.datasets[g].data[b.datasets[g].data.length-1][1])}c.eq(d).html(f);d++}};b.plot.getOptions();for(m in b.datasets)e=$("<input>").attr("type","checkbox").data("index",m).data("graph",b).click(function(){var a=$(this).data("graph");$(this).is(":checked")?
|
||||
$(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=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=
|
||||
" ";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 b.datasets)e=$("<input>").attr("type","checkbox").data("index",m).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[m].display&&e.attr("checked","checked"),d.append($("<tr>").html($("<td>").html($("<label>").html(e).append($("<div>").addClass("series-color").css("background-color",b.datasets[m].color)).append(b.datasets[m].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",b).click(function(){var c=$(this).data("index"),b=$(this).data("graph");if(confirm("Are you sure you want to remove "+b.datasets[c].label+" from "+b.id+"?")){b.datasets.splice(c,1);if(b.datasets.length==0){b.elements.cont.remove();var c=$(".graph_ids option:contains("+b.id+")"),d=c.parent();c.remove();d.trigger("change");UI.plot.del(b.id);delete a[b.id];UI.plot.go(a)}else{UI.plot.save(b);c={};c[b.id]=b;UI.plot.go(c)}}}))));l();var f=!1;b.elements.plot.on("plothover",function(a,c,b){if(c.x!=
|
||||
f){l(c.x);f=c.x}if(b){a=$("<span>").append($("<h3>").text(b.series.label).prepend($("<div>").addClass("series-color").css("background-color",b.series.color))).append($("<table>").addClass("nolay").html($("<tr>").html($("<td>").text("Time:")).append($("<td>").html(UI.format.dateTime(b.datapoint[0]/1E3,"long")))).append($("<tr>").html($("<td>").text("Value:")).append($("<td>").html(b.series.yaxis.tickFormatter(b.datapoint[1],b.series.yaxis)))));UI.tooltip.show(c,a.children())}else UI.tooltip.hide()}).on("mouseout",
|
||||
m).data("graph",b).click(function(){var c=$(this).data("index"),b=$(this).data("graph");if(confirm("Are you sure you want to remove "+b.datasets[c].label+" from "+b.id+"?")){b.datasets.splice(c,1);if(b.datasets.length==0){b.elements.cont.remove();var c=$(".graph_ids option:contains("+b.id+")"),d=c.parent();c.remove();d.trigger("change");UI.plot.del(b.id);delete a[b.id];UI.plot.go(a)}else{UI.plot.save(b);c={};c[b.id]=b;UI.plot.go(c)}}}))));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],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),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,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,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 n=Math.pow(10,-d),b=b/n,g;if(1.5>b)g=1;else if(3>b){if(g=2,2.25<b&&(null==i||d+1<=i))g=2.5,++d}else g=7.5>b?5:10;g=g*n*Math.pow(1024,e);null!=a.minTickSize&&g<a.minTickSize&&(g=a.minTickSize);a.delta=c;a.tickDecimals=Math.max(0,null!=i?i:d);a.tickSize=g;c=[];e=a.tickSize*Math.floor(a.min/a.tickSize);d=0;i=Number.NaN;do n=i,i=e+d*a.tickSize,
|
||||
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 n=Math.pow(10,-d),b=b/n,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*n*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);d=0;i=Number.NaN;do n=i,i=e+d*a.tickSize,
|
||||
c.push(i),++d;while(i<a.max&&i!=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 e=$(this).data("dragstart"),b=e.ele.x-e.click.x+a.originalEvent.pageX,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));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 n;for(d=e.length-1;0<=d;d--)if(0<b[e[d]]){n=e[d];break}c=$("<span>");switch(n){case "week":c.append(UI.format.addUnit(b.week,"wks, ")).append(UI.format.addUnit(b.day,"days"));break;case "day":c.append(UI.format.addUnit(b.day,
|
||||
|
@ -71,65 +71,66 @@ d.append($("<p>").text("No account has been created yet in the MistServer at ").
|
|||
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.addClass("hide");d.append($("<p>").text("Your account has been created succesfully.")).append(UI.buildUI([{type:"text",text:"Would you like to enable all (currently) available protocols with their default settings?"},
|
||||
{type:"buttons",buttons:[{label:"Enable protocols",type:"save","function":function(){if(mist.data.config.protocols)d.append("Unable to enable all protocols as protocol settings already exist.<br>");else{d.append("Retrieving available protocols..<br>");mist.send(function(a){var c=[],b;for(b in a.capabilities.connectors)if(a.capabilities.connectors[b].required)d.append('Could not enable protocol "'+b+'" because it has required settings.<br>');else{c.push({connector:b});d.append('Enabled protocol "'+
|
||||
b+'".<br>')}d.append("Saving protocol settings..<br>");mist.send(function(){d.append("Protocols enabled. Redirecting..");setTimeout(function(){UI.navto("Overview")},5E3)},{config:{protocols:c}})},{capabilities:true})}}},{label:"Skip",type:"cancel","function":function(){UI.navto("Overview")}}]}]));break;case "Overview":var i=$("<span>").text("Loading.."),n=$("<span>"),g=$("<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:i,LTSonly:!0},{type:"span",label:"Server time",value:p},{type:"span",label:"Current streams",value:n},{type:"span",label:"Current connections",value:g},$("<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",
|
||||
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.."),n=$("<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:i,LTSonly:!0},{type:"span",label:"Server time",value:p},{type:"span",label:"Current streams",value:n},{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 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 m=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(){if(confirm("Are you sure you want to execute a rolling update?")){i.addClass("orange").removeClass("red").text("Rolling update command sent..");
|
||||
mist.stored.del("update");mist.send(function(){UI.navto("Overview")},{autoupdate:true})}})):i.text("Unknown")};if(!mist.stored.get().update||36E5<(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));m()},{checkupdate:!0})}else m()}else i.text("");var l=function(){mist.send(function(){f()},{totals:{fields:["clients"],start:-10},active_streams:true})},
|
||||
f=function(){n.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..";g.text(a);p.text(UI.format.dateTime(mist.data.config.time,"long"))};l();f();UI.interval.set(l,3E4);break;case "Protocols":if("undefined"==
|
||||
mist.stored.del("update");mist.send(function(){UI.navto("Overview")},{autoupdate:true})}})):i.text("Unknown")};if(!mist.stored.get().update||36E5<(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));m()},{checkupdate:!0})}else m()}else i.text("");var l=function(){mist.send(function(){g()},{totals:{fields:["clients"],start:-10},active_streams:true})},
|
||||
g=function(){n.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..";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});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 k=function(){function a(c){var b=mist.data.capabilities.connectors[c.connector];if(!b)return"";var d=[],e=["required","optional"],g;for(g in e)for(var f in b[e[g]])c[f]&&c[f]!=""?d.push(f+": "+c[f]):b[e[g]][f]["default"]&&d.push(f+": "+b[e[g]][f]["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",
|
||||
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 t in b[e[f]])c[t]&&c[t]!=""?d.push(t+": "+c[t]):b[e[f]][t]["default"]&&d.push(t+": "+b[e[f]][t]["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})}}))))}};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});d.append("Loading..");break}var j=!1;""!=c&&0<=c&&(j=!0);var z={},q;for(q in mist.data.config.protocols)z[mist.data.config.protocols[q].connector]=1;var F=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 A={},q;for(q in mist.data.config.protocols)A[mist.data.config.protocols[q].connector]=1;var F=function(a){var b=mist.data.capabilities.connectors[a],d=mist.convertBuildOptions(b,o);d.push({type:"hidden",pointer:{main:o,index:"connector"},value:a});d.push({type:"buttons",buttons:[{type:"save",label:"Save",
|
||||
"function":function(){if(j)mist.data.config.protocols[c]=o;else{if(!mist.data.config.protocols)mist.data.config.protocols=[];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 z[b.deps[e]]!="undefined"||typeof z[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)},z={};for(q in mist.data.config.protocols)z[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(F(r.connector))}else{d.html($("<h2>").text("New Protocol"));
|
||||
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(F($(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",
|
||||
" ");$ul.append(a);typeof A[b.deps[e]]!="undefined"||typeof A[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)},A={};for(q in mist.data.config.protocols)A[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(F(r.connector))}else{d.html($("<h2>").text("New Protocol"));
|
||||
var o={},x=[];for(q in mist.data.capabilities.connectors)x.push([q,q]);var V=$("<span>");d.append(UI.buildUI([{label:"Protocol",type:"select",select:x,"function":function(){V.html(F($(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(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);
|
||||
e.stupidtable();var E=function(){var a=[],c;for(c in mist.data.active_streams)a.push({streams:[mist.data.active_streams[c]],fields:["clients"],start:-2});mist.send(function(){$.extend(true,y,mist.data.streams);var a=0;h.html("");if(mist.data.LTS)for(a in mist.data.active_streams){var c=mist.data.active_streams[a].split("+");if(!(c.length<2)&&c[0]in mist.data.streams){c=W(mist.data.active_streams[a],mist.data.streams[c[0]]);c.online=1;y[mist.data.active_streams[a]]=c}}c=Object.keys(y);c.sort();for(var b in c){var d=
|
||||
c[b],e;e=d in mist.data.streams?mist.data.streams[d]:y[d];var g=$("<td>").css("text-align","right").html($("<span>").addClass("description").text("Loading..")),f=0;if(typeof mist.data.totals!="undefined"&&typeof mist.data.totals[d]!="undefined"){var C=mist.data.totals[d].all_protocols.clients,f=0;if(C.length){for(a in C)f=f+C[a][1];f=Math.round(f/C.length)}}g.html(UI.format.number(f));if(f==0&&e.online==1)e.online=2;f=$("<td>").css("text-align","right").css("white-space","nowrap");(!("ischild"in e)||
|
||||
!e.ischild)&&f.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 c={};mist.data.LTS?c.deletestream=[a]:c.streams=mist.data.streams;mist.send(function(){UI.navto("Streams")},c)}}));C=$("<span>").text(d);e.ischild&&C.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("")}h.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(f));
|
||||
a++}},{totals:a,active_streams:true})},y=$.extend(!0,{},mist.data.streams),W=function(a,c){var b=$.extend({},c);delete b.meta;delete b.error;b.online=2;b.name=a;b.ischild=true;return b};if(mist.data.LTS){var B=0,G=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,c){var b=c.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=b+"+"+a.browse.files[d];y[g]=W(g,mist.data.streams[b]);y[g].source=mist.data.streams[b].source+a.browse.files[d]}"files"in a.browse&&a.browse.files.length?y[b].filesfound=true:mist.data.streams[b].filesfound=false;G++;if(B==G){mist.send(function(){E()},{active_streams:true});UI.interval.set(function(){E()},1E4)}},{browse:mist.data.streams[l].source},{stream:l}),B++);0==B&&(mist.send(function(){E()},
|
||||
e.stupidtable();var E=function(){var a=[],c;for(c in mist.data.active_streams)a.push({streams:[mist.data.active_streams[c]],fields:["clients"],start:-2});mist.send(function(){$.extend(true,z,mist.data.streams);var a=0;h.html("");if(mist.data.LTS)for(a in mist.data.active_streams){var c=mist.data.active_streams[a].split("+");if(!(c.length<2)&&c[0]in mist.data.streams){c=W(mist.data.active_streams[a],mist.data.streams[c[0]]);c.online=1;z[mist.data.active_streams[a]]=c}}c=Object.keys(z);c.sort();for(var b in c){var d=
|
||||
c[b],e;e=d in mist.data.streams?mist.data.streams[d]:z[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 t=mist.data.totals[d].all_protocols.clients,g=0;if(t.length){for(a in t)g=g+t[a][1];g=Math.round(g/t.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)&&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 c={};mist.data.LTS?c.deletestream=[a]:c.streams=mist.data.streams;mist.send(function(){UI.navto("Streams")},c)}}));t=$("<span>").text(d);e.ischild&&t.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="";f.html("")}h.append($("<tr>").data("index",d).html($("<td>").html(t).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})},z=$.extend(!0,{},mist.data.streams),W=function(a,c){var b=$.extend({},c);delete b.meta;delete b.error;b.online=2;b.name=a;b.ischild=true;return b};if(mist.data.LTS){var C=0,G=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)&&(z[l].source+="*",mist.send(function(a,c){var b=c.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 f=b+"+"+a.browse.files[d];z[f]=W(f,mist.data.streams[b]);z[f].source=mist.data.streams[b].source+a.browse.files[d]}"files"in a.browse&&a.browse.files.length?z[b].filesfound=true:mist.data.streams[b].filesfound=false;G++;if(C==G){mist.send(function(){E()},{active_streams:true});UI.interval.set(function(){E()},1E4)}},{browse:mist.data.streams[l].source},{stream:l}),C++);0==C&&(mist.send(function(){E()},
|
||||
{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});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 J=$("<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 c=null,b;for(b in mist.data.capabilities.inputs)if(typeof mist.data.capabilities.inputs[b].source_match!="undefined"&&mist.inputMatch(mist.data.capabilities.inputs[b].source_match,a)){c=b;break}if(c===null)J.html($("<h3>").text("Unrecognized input").addClass("red")).append($("<span>").text("Please edit the stream source.").addClass("red"));else{c=mist.data.capabilities.inputs[c];J.html($("<h3>").text(c.name+" Input options"));c=mist.convertBuildOptions(c,
|
||||
o);"always_match"in mist.data.capabilities.inputs[b]&&mist.inputMatch(mist.data.capabilities.inputs[b].always_match,a)&&c.push({label:"Always on",type:"checkbox",help:"Keep this input available at all times, even when there are no active viewers.",pointer:{main:o,index:"always_on"}});J.append(UI.buildUI(c))}}}},$("<br>"),{type:"custom",custom:J},$("<br>"),$("<h3>").text("Encryption"),{type:"help",help:"To enable encryption, the licence acquisition url must be entered, as well as either the content key or the key ID and seed.<br>Unsure how you should fill in your encryption or missing your preferred encryption? Please contact us."},
|
||||
{label:"License acquisition url",type:"str",LTSonly:!0,pointer:{main:o,index:"la_url"}},$("<br>"),{label:"Content key",type:"str",LTSonly:!0,pointer:{main:o,index:"contentkey"}},{type:"text",text:" - or - "},{label:"Key ID",type:"str",LTSonly:!0,pointer:{main:o,index:"keyid"}},{label:"Key seed",type:"str",LTSonly:!0,pointer:{main:o,index:"keyseed"}},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Streams")}},{type:"save",label:"Save","function":function(){if(!mist.data.streams)mist.data.streams=
|
||||
{};mist.data.streams[o.name]=o;c!=o.name&&delete mist.data.streams[c];var a={};if(mist.data.LTS){a.addstream={};a.addstream[o.name]=o;if(c!=o.name)a.deletestream=[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(c){var b={};c.sort();d.html($("<h2>").text(a)).append(UI.buildUI([{label:"Select a stream",type:"select",
|
||||
select:c,pointer:{main:b,index:"stream"}},{type:"buttons",buttons:[{type:"save",label:"Go","function":function(){UI.navto(a,b.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");d.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",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}G=B=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,c){var b=c.stream,d;for(d in a.browse.files)for(var e in mist.data.capabilities.inputs)e.indexOf("Buffer")>=0||e.indexOf("Folder")>=0||mist.inputMatch(mist.data.capabilities.inputs[e].source_match,"/"+a.browse.files[d])&&(w[b+"+"+a.browse.files[d]]=true);G++;B==G&&mist.send(function(){for(var a in mist.data.active_streams){var c=mist.data.active_streams[a].split("+");c.length>
|
||||
1&&c[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=[],b;for(b in mist.data.active_streams){var e=mist.data.active_streams[b].split("+");e.length>1&&e[0]in mist.data.streams&&(c[mist.data.active_streams[b]]=true)}mist.data.streams&&(c=c.concat(Object.keys(mist.data.streams)));if(c.length==0)d.html($("<h2>").text(a)).append("Please set up a stream first.");
|
||||
else{c.sort();N(c)}},{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)l=r.port?":"+r.port:":8080";var D={},r=$("<span>").hide();D["Embed urls"]=r;d.append(r);e=mist.user.host;b=document.createElement("a");b.href=e;e=b.protocol+"//";b=b.hostname;var H=e+b+l+"/",x={autoplay:!0},K=function(a){var b=["div"],d='\n <script src="'+
|
||||
H+"embed_"+encodeURIComponent(c)+'.js"><\/script>\n';a.autoplay||b.push("data-noautoplay");a.forceprotocol&&a.forceprotocol!=""&&b.push('data-forcetype="'+a.forceprotocol+'"');a.urlappend&&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:H+"embed_"+encodeURIComponent(c)+".js",readonly:!0},{label:"Stream info script",
|
||||
type:"str",value:H+"info_"+encodeURIComponent(c)+".js",readonly:!0},{label:"Autodetect player",type:"str",value:H+encodeURIComponent(c)+".html",readonly:!0,qrcode:!0},$("<h3>").text("Embed code"),{label:"Embed code",type:"textarea",value:K(x),rows:4,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(K(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(K(x))}},{label:"Video URL addition",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(K(x))}},
|
||||
$("<h3>").text("Protocol stream urls"),X]));l=$("<span>").append($("<h3>").text("Meta information")).hide();D["Meta information"]=l;var O=$("<span>");l.append(O);d.append(l);l=$("<span>").hide();D.Preview=l;d.append(l);var L=$("<div>").css({"float":"left","margin-right":"1em",width:"100%"}),t=$("<div>").addClass("video_container").attr("data-forcesupportcheck","");L.html(t);var Y=$("<div>").css("float","left");l.append(L).append(Y);mist.stored.get().autoplay||t.attr("data-noautoplay","");var M=function(){t.text("Loading..");
|
||||
L.children(".input_container").remove();var a=document.createElement("script");a.src=H+"embed_"+encodeURIComponent(c)+".js";a.onerror=function(){t.html('Error loading "'+a.src+'".<br>').append($("<button>").text("Try again").click(function(){M()}))};a.onload=function(){if(typeof mistvideo[c].error!="undefined")t.height("5em").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)}}]);t.height(Math.min(a.height,t.height()));b.find(".help_container").remove();L.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";
|
||||
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(){t.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,
|
||||
"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,c){a=a.split("_").pop();c=c.split("_").pop();return a-c});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.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.")}};t.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"));
|
||||
l=["Preview","Embed urls","Meta information"];z=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 D)D[q].hide();D[$(this).text()].show()}),P.append(r),l[q]==z&&(r.addClass("active"),D[z].show());break;case "Push":t=$("<div>").text("Loading..");d.append(t);mist.send(function(a){function c(a){setTimeout(function(){mist.send(function(b){var d=false;if("push_list"in b&&b.push_list&&b.push_list.length){var d=
|
||||
true,f;for(f in b.push_list)if(a.indexOf(b.push_list[f][0])>-1){d=false;break}}else d=true;if(d)for(f in a)e.find("tr[data-pushid="+a[f]+"]").remove();else c()},{push_list:1})},1E3)}function b(d,f){var g=$("<span>");d.length>=4&&d[2]!=d[3]?g.append($("<span>").text(d[2])).append($("<span>").html("»").addClass("unit").css("margin","0 0.5em")).append($("<span>").text(d[3])):g.append($("<span>").text(d[2]));var h=$("<td>").append($("<button>").text(f=="Automatic"?"Remove":"Stop").click(function(){if(confirm("Are you sure you want to "+
|
||||
$(this).text().toLowerCase()+" this push?\n"+d[1]+" to "+d[2])){var a=$(this).closest("tr");a.html($("<td colspan=99>").html($("<span>").addClass("red").text(f=="Automatic"?"Removing..":"Stopping..")));f=="Automatic"?mist.send(function(){a.remove()},{push_auto_remove:{stream:d[1],target:d[2]}}):mist.send(function(){c([d[0]])},{push_stop:[d[0]]})}}));f=="Automatic"&&h.append($("<button>").text("Remove and stop pushes").click(function(){if(confirm("Are you sure you want to remove this automatic push, and also stop all pushes matching it?\n"+
|
||||
d[1]+" to "+d[2])){var b=$(this).closest("tr");b.html($("<td colspan=99>").html($("<span>").addClass("red").text("Removing and stopping..")));var f=[],g;for(g in a.push_list)if(d[1]==a.push_list[g][1]&&d[2]==a.push_list[g][2]){f.push(a.push_list[g][0]);e.find("tr[data-pushid="+a.push_list[g][0]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}mist.send(function(){b.remove();c(f)},{push_auto_remove:{stream:d[1],target:d[2]},push_stop:f})}}));return $("<tr>").attr("data-pushid",
|
||||
d[0]).append($("<td>").text(d[1])).append($("<td>").append(g.children())).append(h)}t.html("");var d=a.push_settings;d||(d={});t.append(UI.buildUI([{type:"help",help:"You can push streams to files or other servers, allowing them to broadcast your stream as well."},$("<h3>").text("Settings"),{label:"Delay before retry",unit:"s",type:"int",min:0,help:"How long the delay should be before MistServer retries an automatic push.<br>If set to 0, it does not retry.","default":0,pointer:{main:d,index:"wait"},
|
||||
LTSonly:1},{label:"Maximum retries",unit:"/s",type:"int",min:0,help:"The maximum amount of retries per second (for all automatic pushes).<br>If set to 0, there is no limit.","default":0,pointer:{main:d,index:"maxspeed"},LTSonly:1},{type:"buttons",buttons:[{type:"save",label:"Save","function":function(){mist.send(function(){UI.navto("Push")},{push_settings:d})}}]}]));var e=$("<table>").append($("<tr>").append($("<th>").text("Stream")).append($("<th>").text("Target")).append($("<th>"))),f=e.clone();
|
||||
if("push_list"in a)for(var g in a.push_list)e.append(b(a.push_list[g],"Manual"));if("push_auto_list"in a)for(g in a.push_auto_list)f.append(b([-1,a.push_auto_list[g][0],a.push_auto_list[g][1]],"Automatic"));t.append($("<h3>").text("Automatic pushes")).append($("<button>").text("Add an automatic push").click(function(){UI.navto("Start Push","auto")}));f.find("tr").length==1?t.append($("<div>").text("No automatic pushes have been configured.").addClass("text").css("margin-top","0.5em")):t.append(f);
|
||||
t.append($("<h3>").text("Pushes")).append($("<button>").text("Start a push").click(function(){UI.navto("Start Push")}));if(e.find("tr").length==1)t.append($("<div>").text("No pushes are active.").addClass("text").css("margin-top","0.5em"));else{var f=[],h=[],i=$("<select>").css("margin-left","0.5em").append($("<option>").text("Any stream").val("")),j=$("<select>").css("margin-left","0.5em").append($("<option>").text("Any target").val(""));for(g in a.push_list){f.indexOf(a.push_list[g][1])==-1&&f.push(a.push_list[g][1]);
|
||||
h.indexOf(a.push_list[g][2])==-1&&h.push(a.push_list[g][2])}f.sort();h.sort();for(g in f)i.append($("<option>").text(f[g]));for(g in h)j.append($("<option>").text(h[g]));t.append($("<button>").text("Stop all pushes").click(function(){var b=[],d;for(d in a.push_list)b.push(a.push_list[d][0]);if(b.length!=0&&confirm("Are you sure you want to stop all pushes?")){mist.send(function(){c(b)},{push_stop:b});e.find("tr:not(:first-child)").html($("<td colspan=99>").append($("<span>").addClass("red").text("Stopping..")));
|
||||
$(this).remove()}})).append($("<label>").css("margin-left","1em").append($("<span>").text("Stop all pushes that match: ").css("font-size","0.9em")).append(i).append($("<span>").css("margin-left","0.5em").text("and").css("font-size","0.9em")).append(j).append($("<button>").css("margin-left","0.5em").text("Apply").click(function(){var b=i.val(),d=j.val();if(b==""&&d=="")return alert("Looks like you want to stop all pushes. Maybe you should use that button?");var f={},g;for(g in a.push_list)if((b==""||
|
||||
a.push_list[g][1]==b)&&(d==""||a.push_list[g][2]==d))f[a.push_list[g][0]]=a.push_list[g];if(Object.keys(f).length==0)return alert("No matching pushes.");b="Are you sure you want to stop these pushes?\n\n";for(g in f)b=b+(f[g][1]+" to "+f[g][2]+"\n");if(confirm(b)){f=Object.keys(f);mist.send(function(){c(f)},{push_stop:f});for(g in f)e.find("tr[data-pushid="+f[g]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}}))).append(e)}},{push_settings:1,push_list:1,push_auto_list:1});
|
||||
break;case "Start Push":if(!("capabilities"in mist.data)){d.append("Loading Mist capabilities..");mist.send(function(){UI.navto("Start Push",c)},{capabilities:1});break}var u,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: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:u,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>",
|
||||
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?
|
||||
mist.send(function(a){(u=a.active_streams)||(u=[]);var a=[],b;for(b in u)u[b].indexOf("+")!=-1&&a.push(u[b].replace(/\+.*/,"")+"+");u=u.concat(a);var c=0,d=0;for(b in mist.data.streams){u.push(b);if(mist.inputMatch(mist.data.capabilities.inputs.Folder.source_match,mist.data.streams[b].source)){u.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,
|
||||
"/"+a.browse.files[f])&&u.push(e+"+"+a.browse.files[f]);d++;if(c==d){u=u.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();Q()}},{browse:mist.data.streams[b].source},{stream:b});c++}}if(c==d){u=u.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();Q()}},{active_streams:1}):(u=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",
|
||||
o);"always_match"in mist.data.capabilities.inputs[b]&&mist.inputMatch(mist.data.capabilities.inputs[b].always_match,a)&&c.push({label:"Always on",type:"checkbox",help:"Keep this input available at all times, even when there are no active viewers.",pointer:{main:o,index:"always_on"}});J.append(UI.buildUI(c))}}}},{label:"Stop sessions",type:"checkbox",help:"When saving these stream settings, kill this stream's current connections.",pointer:{main:o,index:"stop_sessions"}},$("<br>"),{type:"custom",custom:J},
|
||||
$("<br>"),$("<h3>").text("Encryption"),{type:"help",help:"To enable encryption, the licence acquisition url must be entered, as well as either the content key or the key ID and seed.<br>Unsure how you should fill in your encryption or missing your preferred encryption? Please contact us."},{label:"License acquisition url",type:"str",LTSonly:!0,pointer:{main:o,index:"la_url"}},$("<br>"),{label:"Content key",type:"str",LTSonly:!0,pointer:{main:o,index:"contentkey"}},{type:"text",text:" - or - "},{label:"Key ID",
|
||||
type:"str",LTSonly:!0,pointer:{main:o,index:"keyid"}},{label:"Key seed",type:"str",LTSonly:!0,pointer:{main:o,index:"keyseed"}},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Streams")}},{type:"save",label:"Save","function":function(){if(!mist.data.streams)mist.data.streams={};mist.data.streams[o.name]=o;c!=o.name&&delete mist.data.streams[c];var a={};if(mist.data.LTS){a.addstream={};a.addstream[o.name]=o;if(c!=o.name)a.deletestream=[c]}else a.streams=mist.data.streams;
|
||||
if(o.stop_sessions&&c!=""){a.stop_sessions=c;delete o.stop_sessions}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(c){var b={};c.sort();d.html($("<h2>").text(a)).append(UI.buildUI([{label:"Select a stream",type:"select",select:c,pointer:{main:b,index:"stream"}},{type:"buttons",buttons:[{type:"save",label:"Go","function":function(){UI.navto(a,b.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");d.append($("<span>").addClass("description").text("Or, click a stream from the list below.")).append(e);for(var f in c){var g=c[f],h="";if(g.indexOf("+")>-1){h=g.split("+");h=mist.data.streams[h[0]].source+h[1]}else h=mist.data.streams[g].source;e.append($("<button>").append($("<span>").text(g)).append($("<span>").addClass("description").text(h)).attr("title",
|
||||
g).attr("data-stream",g).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}G=C=0;x={};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,c){var b=c.stream,d;for(d in a.browse.files)for(var e in mist.data.capabilities.inputs)e.indexOf("Buffer")>=
|
||||
0||e.indexOf("Folder")>=0||mist.inputMatch(mist.data.capabilities.inputs[e].source_match,"/"+a.browse.files[d])&&(x[b+"+"+a.browse.files[d]]=true);G++;C==G&&mist.send(function(){for(var a in mist.data.active_streams){var c=mist.data.active_streams[a].split("+");c.length>1&&c[0]in mist.data.streams&&(x[mist.data.active_streams[a]]=true)}x=Object.keys(x);x=x.concat(Object.keys(mist.data.streams));x.sort();N(x)},{active_streams:true})},{browse:mist.data.streams[l].source},{stream:l}),C++);0==C&&mist.send(function(){var c=
|
||||
[],b;for(b in mist.data.active_streams){var e=mist.data.active_streams[b].split("+");e.length>1&&e[0]in mist.data.streams&&(c[mist.data.active_streams[b]]=true)}mist.data.streams&&(c=c.concat(Object.keys(mist.data.streams)));if(c.length==0)d.html($("<h2>").text(a)).append("Please set up a stream first.");else{c.sort();N(c)}},{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)l=r.port?":"+r.port:":8080";var D={},r=$("<span>").hide();D["Embed urls"]=r;d.append(r);e=mist.user.host;b=document.createElement("a");b.href=e;e=b.protocol+"//";b=b.hostname;var H=e+b+l+"/",y={autoplay:!0},K=function(a){var b=["div"],d='\n <script src="'+H+"embed_"+encodeURIComponent(c)+'.js"><\/script>\n';a.autoplay||b.push("data-noautoplay");a.forceprotocol&&a.forceprotocol!=""&&b.push('data-forcetype="'+a.forceprotocol+'"');a.urlappend&&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:H+"embed_"+encodeURIComponent(c)+".js",readonly:!0},{label:"Stream info script",type:"str",value:H+"info_"+encodeURIComponent(c)+".js",readonly:!0},{label:"Autodetect player",type:"str",value:H+encodeURIComponent(c)+".html",readonly:!0,qrcode:!0},$("<h3>").text("Embed code"),{label:"Embed code",
|
||||
type:"textarea",value:K(y),rows:4,readonly:!0,classes:["embed_code"]},$("<h4>").text("Embed code options").css("margin-top",0),{label:"Autoplay",type:"checkbox",value:!0,pointer:{main:y,index:"autoplay"},"function":function(){y.autoplay=$(this).getval();$(".embed_code").setval(K(y))}},{label:"Force protocol",type:"select",select:[["","Automatic"]],pointer:{main:y,index:"protocol"},classes:["embed_code_forceprotocol"],"function":function(){y.forceprotocol=$(this).getval();$(".embed_code").setval(K(y))}},
|
||||
{label:"Video URL addition",type:"str",pointer:{main:y,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(){y.urlappend=$(this).getval();$(".embed_code").setval(K(y))}},$("<h3>").text("Protocol stream urls"),X]));l=$("<span>").append($("<h3>").text("Meta information")).hide();D["Meta information"]=l;var O=$("<span>");l.append(O);d.append(l);l=$("<span>").hide();D.Preview=l;
|
||||
d.append(l);var L=$("<div>").css({"float":"left","margin-right":"1em",width:"100%"}),u=$("<div>").addClass("video_container").attr("data-forcesupportcheck","");L.html(u);var Y=$("<div>").css("float","left");l.append(L).append(Y);mist.stored.get().autoplay||u.attr("data-noautoplay","");var M=function(){u.text("Loading..");L.children(".input_container").remove();var a=document.createElement("script");a.src=H+"embed_"+encodeURIComponent(c)+".js";a.onerror=function(){u.html('Error loading "'+a.src+'".<br>').append($("<button>").text("Try again").click(function(){M()}))};
|
||||
a.onload=function(){if(typeof mistvideo[c].error!="undefined")u.height("5em").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)}}]);u.height(Math.min(a.height,u.height()));
|
||||
b.find(".help_container").remove();L.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 f in a.source){var g=a.source[f],h=g.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=g.type}i=UI.format.capital(i);d.append($("<option>").text(i).val(g.type).addClass("clear"));
|
||||
e.push({label:i,type:"str",value:g.url,readonly:true,qrcode:true});h=$("<tr>");b.append(h);h.html($("<td>").html($("<input>").attr("type","radio").attr("name","protocolforce").change(function(){u.attr("data-forcetype",$(this).val()).html("Loading embed..");M()}).val(g.type))).append($("<td>").text(i)).append($("<td>").text(g.priority)).append($("<td>").text(g.simul_tracks+"/"+g.total_matches)).append($("<td>").text(g.browser_support?"yes":"no"));if(a.embedded&&a.embedded.type==g.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:[]};f={vheader:"Video",
|
||||
labels:["Codec","Duration","Peak bitrate","Size","Framerate"],content:[]};d=Object.keys(j.tracks);d.sort(function(a,c){a=a.split("_").pop();c=c.split("_").pop();return a-c});for(var t in d){e=d[t];g=j.tracks[e];switch(g.type){case "audio":b.content.push({header:"Track "+e.split("_").pop(),body:[g.codec,UI.format.duration((g.lastms-g.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(g.firstms/1E3)+" to "+UI.format.duration(g.lastms/1E3)+"</span>",UI.format.bytes(g.bps,1),g.channels,UI.format.addUnit(UI.format.number(g.rate),
|
||||
"Hz")]});break;case "video":f.content.push({header:"Track "+e.split("_").pop(),body:[g.codec,UI.format.duration((g.lastms-g.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(g.firstms/1E3)+" to "+UI.format.duration(g.lastms/1E3)+"</span>",UI.format.bytes(g.bps,1),UI.format.addUnit(g.width,"x ")+UI.format.addUnit(g.height,"px"),UI.format.addUnit(UI.format.number(g.fpks/1E3),"fps")]})}}j=UI.buildVheaderTable(b).css("width","auto");t=UI.buildVheaderTable(f).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(t));O.html(UI.buildUI(a))}else O.html("No meta information available.")}};u.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"));l=["Preview","Embed urls","Meta information"];A=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 D)D[q].hide();D[$(this).text()].show()}),P.append(r),l[q]==A&&(r.addClass("active"),D[A].show());break;case "Push":u=$("<div>").text("Loading..");d.append(u);mist.send(function(a){function c(a){setTimeout(function(){mist.send(function(b){var d=false;if("push_list"in b&&b.push_list&&b.push_list.length){var d=true,g;for(g in b.push_list)if(a.indexOf(b.push_list[g][0])>-1){d=false;break}}else d=true;if(d)for(g in a)e.find("tr[data-pushid="+a[g]+"]").remove();else c()},
|
||||
{push_list:1})},1E3)}function b(d,g){var f=$("<span>");d.length>=4&&d[2]!=d[3]?f.append($("<span>").text(d[2])).append($("<span>").html("»").addClass("unit").css("margin","0 0.5em")).append($("<span>").text(d[3])):f.append($("<span>").text(d[2]));var h=$("<td>").append($("<button>").text(g=="Automatic"?"Remove":"Stop").click(function(){if(confirm("Are you sure you want to "+$(this).text().toLowerCase()+" this push?\n"+d[1]+" to "+d[2])){var a=$(this).closest("tr");a.html($("<td colspan=99>").html($("<span>").addClass("red").text(g==
|
||||
"Automatic"?"Removing..":"Stopping..")));g=="Automatic"?mist.send(function(){a.remove()},{push_auto_remove:{stream:d[1],target:d[2]}}):mist.send(function(){c([d[0]])},{push_stop:[d[0]]})}}));g=="Automatic"&&h.append($("<button>").text("Remove and stop pushes").click(function(){if(confirm("Are you sure you want to remove this automatic push, and also stop all pushes matching it?\n"+d[1]+" to "+d[2])){var b=$(this).closest("tr");b.html($("<td colspan=99>").html($("<span>").addClass("red").text("Removing and stopping..")));
|
||||
var g=[],f;for(f in a.push_list)if(d[1]==a.push_list[f][1]&&d[2]==a.push_list[f][2]){g.push(a.push_list[f][0]);e.find("tr[data-pushid="+a.push_list[f][0]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}mist.send(function(){b.remove();c(g)},{push_auto_remove:{stream:d[1],target:d[2]},push_stop:g})}}));return $("<tr>").attr("data-pushid",d[0]).append($("<td>").text(d[1])).append($("<td>").append(f.children())).append(h)}u.html("");var d=a.push_settings;d||(d={});
|
||||
u.append(UI.buildUI([{type:"help",help:"You can push streams to files or other servers, allowing them to broadcast your stream as well."},$("<h3>").text("Settings"),{label:"Delay before retry",unit:"s",type:"int",min:0,help:"How long the delay should be before MistServer retries an automatic push.<br>If set to 0, it does not retry.","default":0,pointer:{main:d,index:"wait"},LTSonly:1},{label:"Maximum retries",unit:"/s",type:"int",min:0,help:"The maximum amount of retries per second (for all automatic pushes).<br>If set to 0, there is no limit.",
|
||||
"default":0,pointer:{main:d,index:"maxspeed"},LTSonly:1},{type:"buttons",buttons:[{type:"save",label:"Save","function":function(){mist.send(function(){UI.navto("Push")},{push_settings:d})}}]}]));var e=$("<table>").append($("<tr>").append($("<th>").text("Stream")).append($("<th>").text("Target")).append($("<th>"))),g=e.clone();if("push_list"in a)for(var f in a.push_list)e.append(b(a.push_list[f],"Manual"));if("push_auto_list"in a)for(f in a.push_auto_list)g.append(b([-1,a.push_auto_list[f][0],a.push_auto_list[f][1]],
|
||||
"Automatic"));u.append($("<h3>").text("Automatic pushes")).append($("<button>").text("Add an automatic push").click(function(){UI.navto("Start Push","auto")}));g.find("tr").length==1?u.append($("<div>").text("No automatic pushes have been configured.").addClass("text").css("margin-top","0.5em")):u.append(g);u.append($("<h3>").text("Pushes")).append($("<button>").text("Start a push").click(function(){UI.navto("Start Push")}));if(e.find("tr").length==1)u.append($("<div>").text("No pushes are active.").addClass("text").css("margin-top",
|
||||
"0.5em"));else{var g=[],h=[],i=$("<select>").css("margin-left","0.5em").append($("<option>").text("Any stream").val("")),j=$("<select>").css("margin-left","0.5em").append($("<option>").text("Any target").val(""));for(f in a.push_list){g.indexOf(a.push_list[f][1])==-1&&g.push(a.push_list[f][1]);h.indexOf(a.push_list[f][2])==-1&&h.push(a.push_list[f][2])}g.sort();h.sort();for(f in g)i.append($("<option>").text(g[f]));for(f in h)j.append($("<option>").text(h[f]));u.append($("<button>").text("Stop all pushes").click(function(){var b=
|
||||
[],d;for(d in a.push_list)b.push(a.push_list[d][0]);if(b.length!=0&&confirm("Are you sure you want to stop all pushes?")){mist.send(function(){c(b)},{push_stop:b});e.find("tr:not(:first-child)").html($("<td colspan=99>").append($("<span>").addClass("red").text("Stopping..")));$(this).remove()}})).append($("<label>").css("margin-left","1em").append($("<span>").text("Stop all pushes that match: ").css("font-size","0.9em")).append(i).append($("<span>").css("margin-left","0.5em").text("and").css("font-size",
|
||||
"0.9em")).append(j).append($("<button>").css("margin-left","0.5em").text("Apply").click(function(){var b=i.val(),d=j.val();if(b==""&&d=="")return alert("Looks like you want to stop all pushes. Maybe you should use that button?");var g={},f;for(f in a.push_list)if((b==""||a.push_list[f][1]==b)&&(d==""||a.push_list[f][2]==d))g[a.push_list[f][0]]=a.push_list[f];if(Object.keys(g).length==0)return alert("No matching pushes.");b="Are you sure you want to stop these pushes?\n\n";for(f in g)b=b+(g[f][1]+
|
||||
" to "+g[f][2]+"\n");if(confirm(b)){g=Object.keys(g);mist.send(function(){c(g)},{push_stop:g});for(f in g)e.find("tr[data-pushid="+g[f]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}}))).append(e)}},{push_settings:1,push_list:1,push_auto_list:1});break;case "Start Push":if(!("capabilities"in mist.data)){d.append("Loading Mist capabilities..");mist.send(function(){UI.navto("Start Push",c)},{capabilities:1});break}var v,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 g={};d.append(UI.buildUI([{label:"Stream name",type:"str",help:"This may either be a full stream name, a partial wildcard stream name, or a full wildcard stream name.<br>For example, given the stream <i>a</i> you can use:<ul><li><i>a</i>: the stream configured as <i>a</i></li><li><i>a+</i>: all streams configured as <i>a</i> with a wildcard behind it, but not <i>a</i> itself</li><li><i>a+b</i>: only the version of stream <i>a</i> that has wildcard <i>b</i></li></ul>",
|
||||
pointer:{main:g,index:"stream"},validate:["required",function(a){a=a.split("+");a=a[0];return a in mist.data.streams?false:{msg:"'"+a+"' is not a stream name.",classes:["red"]}}],datalist:v,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>",
|
||||
pointer:{main:g,index:"target"},validate:["required",function(b){for(var c in a)if(mist.inputMatch(a[c],b))return false;return{msg:"Does not match a valid target.<br>Valid formats:<ul><li>"+a.join("</li><li>")+"</li></ul>",classes:["red"]}}],LTSonly:1},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Push")}},{type:"save",label:"Save","function":function(){var a={};a[c=="auto"?"push_auto_add":"push_start"]=g;mist.send(function(){UI.navto("Push")},a)}}]}]))};mist.data.LTS?
|
||||
mist.send(function(a){(v=a.active_streams)||(v=[]);var a=[],b;for(b in v)v[b].indexOf("+")!=-1&&a.push(v[b].replace(/\+.*/,"")+"+");v=v.concat(a);var c=0,d=0;for(b in mist.data.streams){v.push(b);if(mist.inputMatch(mist.data.capabilities.inputs.Folder.source_match,mist.data.streams[b].source)){v.push(b+"+");mist.send(function(a,b){var e=b.stream,g;for(g in a.browse.files)for(var f in mist.data.capabilities.inputs)f.indexOf("Buffer")>=0||f.indexOf("Folder")>=0||mist.inputMatch(mist.data.capabilities.inputs[f].source_match,
|
||||
"/"+a.browse.files[g])&&v.push(e+"+"+a.browse.files[g]);d++;if(c==d){v=v.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();Q()}},{browse:mist.data.streams[b].source},{stream:b});c++}}if(c==d){v=v.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();Q()}},{active_streams:1}):(v=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").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);
|
||||
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 "+
|
||||
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",
|
||||
|
@ -143,14 +144,14 @@ LTSonly:!0},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":fu
|
|||
{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",
|
||||
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",
|
||||
"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",
|
||||
"left")))}};R();break;case "Statistics":var A=$("<span>").text("Loading..");d.append(A);var o={},v=mist.stored.get().graphs?$.extend(!0,{},mist.stored.get().graphs):{},I={};for(q in mist.data.streams)I[q]=!0;for(q in mist.data.active_streams)I[mist.data.active_streams[q]]=!0;var I=Object.keys(I).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=
|
||||
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."},$("<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(v).length+1)).closest("label").show()}else{var c=v[$(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
|
||||
v?{msg:"This graph id has already been used. Please enter something else.",classes:["red"]}:false}]},{label:"Axis type",type:"select",select:[["time","Time line"]],pointer:{main:o,index:"xaxis"},value:"time",classes:["graph_xaxis"],"function":function(){$s=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"],["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)}}},{label:"Data origin",type:"radioselect",radioselect:[["total","All"],["stream","The stream:",I],["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);v[a.id]=a;A.find("select.graph_ids").append($("<option>").text(a.id)).val(a.id).trigger("change")}else a=
|
||||
v[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(v)}}]}]));var b=$("<div>").addClass("graph_container");d.append(b);var c=A.find("select.graph_ids");for(a in v){var e=UI.plot.addGraph(v[a],b);c.append($("<option>").text(e.id)).val(e.id);var f=[],g;for(g in v[a].datasets){var h=UI.plot.datatype.getOptions({datatype:v[a].datasets[g].datatype,origin:v[a].datasets[g].origin});f.push(h)}e.datasets=f;v[e.id]=e}c.trigger("change");
|
||||
UI.plot.go(v);UI.interval.set(function(){UI.plot.go(v)},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),
|
||||
"left")))}};R();break;case "Statistics":var B=$("<span>").text("Loading..");d.append(B);var o={},w=mist.stored.get().graphs?$.extend(!0,{},mist.stored.get().graphs):{},I={};for(q in mist.data.streams)I[q]=!0;for(q in mist.data.active_streams)I[mist.data.active_streams[q]]=!0;var I=Object.keys(I).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=
|
||||
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");
|
||||
if($(this).val()=="new"){a.children("option").prop("disabled",false);b.setval("Graph "+(Object.keys(w).length+1)).closest("label").show()}else{var c=w[$(this).val()].xaxis;a.children("option").prop("disabled",true).filter('[value="'+c+'"]').prop("disabled",false);b.closest("label").hide()}a.children('option[value="'+a.val()+'"]:disabled').length&&a.val(a.children("option:enabled").first().val());a.trigger("change")}}},{label:"Graph id",type:"str",pointer:{main:o,index:"id"},classes:["graph_id"],validate:[function(a){return a in
|
||||
w?{msg:"This graph id has already been used. Please enter something else.",classes:["red"]}:false}]},{label:"Axis type",type:"select",select:[["time","Time line"]],pointer:{main:o,index:"xaxis"},value:"time",classes:["graph_xaxis"],"function":function(){$s=B.find(".graph_datatype");switch($(this).getval()){case "coords":$s.children("option").prop("disabled",true).filter('[value="coords"]').prop("disabled",false);break;case "time":$s.children("option").prop("disabled",false).filter('[value="coords"]').prop("disabled",
|
||||
true)}if(!$s.val()||$s.children('option[value="'+$s.val()+'"]:disabled').length){$s.val($s.children("option:enabled").first().val());$s.trigger("change")}}},{label:"Data type",type:"select",select:[["clients","Connections"],["upbps","Bandwidth (up)"],["downbps","Bandwidth (down)"],["cpuload","CPU use"],["memload","Memory load"],["coords","Client location"]],pointer:{main: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",
|
||||
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:",I],["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);w[a.id]=a;B.find("select.graph_ids").append($("<option>").text(a.id)).val(a.id).trigger("change")}else a=
|
||||
w[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(w)}}]}]));var b=$("<div>").addClass("graph_container");d.append(b);var c=B.find("select.graph_ids");for(a in w){var e=UI.plot.addGraph(w[a],b);c.append($("<option>").text(e.id)).val(e.id);var g=[],f;for(f in w[a].datasets){var h=UI.plot.datatype.getOptions({datatype:w[a].datasets[f].datatype,origin:w[a].datasets[f].origin});g.push(h)}e.datasets=g;w[e.id]=e}c.trigger("change");
|
||||
UI.plot.go(w);UI.interval.set(function(){UI.plot.go(w)},1E4)},{active_streams:!0,capabilities:!0});break;case "Server Stats":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});d.append("Loading..");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),
|
||||
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-
|
||||
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:" ",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};
|
||||
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);
|
||||
|
@ -159,14 +160,14 @@ pointer:{main:o,index:"email"}},{type:"hidden",value:"Integrated Help",pointer:{
|
|||
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,e){var c=c||{},e=e||{},e=$.extend(true,{timeOut:3E4,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(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(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),g=["config","capabilities","ui_settings","LTS","active_streams","browse","log","totals"],p;for(p in d)g.indexOf(p)==-1&&delete d[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,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(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([n,0])};var e={},g;for(g in c.fields)e[c.fields[g]]=[];var i=0,n;if(c.data){if(c.start>mist.data.config.time-600){n=(mist.data.config.time-600)*1E3;d();n=c.start*1E3;d()}else n=c.start*1E3;for(g in c.data){if(g==0){n=c.start*1E3;var p=0}else{n=n+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 F in c.data[g])e[c.fields[F]].push([n,
|
||||
c.data[g][F]]);if(i){d();i--}}if(mist.data.config.time-c.end>20){d();n=(mist.data.config.time-15)*1E3;d()}}else{n=(mist.data.config.time-600)*1E3;d();n=(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,
|
||||
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([n,0])};var e={},f;for(f in c.fields)e[c.fields[f]]=[];var i=0,n;if(c.data){if(c.start>mist.data.config.time-600){n=(mist.data.config.time-600)*1E3;d();n=c.start*1E3;d()}else n=c.start*1E3;for(f in c.data){if(f==0){n=c.start*1E3;var p=0}else{n=n+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 F in c.data[f])e[c.fields[F]].push([n,
|
||||
c.data[f][F]]);if(i){d();i--}}if(mist.data.config.time-c.end>20){d();n=(mist.data.config.time-15)*1E3;d()}}else{n=(mist.data.config.time-600)*1E3;d();n=(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,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,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,
|
||||
"\\$&");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 n=a[b[d]][i],g={label:UI.format.capital(n.name),pointer:{main:c,index:i},validate:[]};b[d]=="required"&&!("default"in n)&&g.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"}e.push(g)}}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];
|
||||
"\\$&");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 n=a[b[d]][i],f={label:UI.format.capital(n.name),pointer:{main:c,index:i},validate:[]};b[d]=="required"&&!("default"in n)&&f.validate.push("required");
|
||||
if("default"in n)f.placeholder=n["default"];if("help"in n)f.help=n.help;if("unit"in n)f.unit=n.unit;switch(n.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=n.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){}}
|
||||
$.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(" "),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==
|
||||
|
|
13
lsp/mist.js
13
lsp/mist.js
|
@ -2582,6 +2582,14 @@ var UI = {
|
|||
}
|
||||
$inputoptions.append(UI.buildUI(build));
|
||||
}
|
||||
},{
|
||||
label: 'Stop sessions',
|
||||
type: 'checkbox',
|
||||
help: 'When saving these stream settings, kill this stream\'s current connections.',
|
||||
pointer: {
|
||||
main: saveas,
|
||||
index: 'stop_sessions'
|
||||
}
|
||||
},$('<br>'),{
|
||||
type: 'custom',
|
||||
custom: $inputoptions
|
||||
|
@ -2656,6 +2664,11 @@ var UI = {
|
|||
else {
|
||||
send.streams = mist.data.streams;
|
||||
}
|
||||
if ((saveas.stop_sessions) && (other != '')) {
|
||||
send.stop_sessions = other;
|
||||
delete saveas.stop_sessions;
|
||||
}
|
||||
|
||||
mist.send(function(){
|
||||
delete mist.data.streams[saveas.name].online;
|
||||
delete mist.data.streams[saveas.name].error;
|
||||
|
|
Loading…
Add table
Reference in a new issue