LSP: added more push stop all buttons
This commit is contained in:
parent
45ef9daac9
commit
a32ec4999e
2 changed files with 264 additions and 169 deletions
184
lsp/minified.js
184
lsp/minified.js
|
@ -1,11 +1,11 @@
|
|||
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 m(a){var c="",b="",d;for(d=0;3>=d;d++)b=a>>>8*d&255,b="0"+b.toString(16),c+=b.substr(b.length-2,2);return c}var f=[],p,n,s,l,g,h,k,j,f=a.replace(/\r\n/g,"\n"),a="";for(p=0;p<f.length;p++)n=f.charCodeAt(p),128>n?a+=String.fromCharCode(n):(127<n&&2048>n?a+=String.fromCharCode(n>>6|192):(a+=String.fromCharCode(n>>12|224),a+=String.fromCharCode(n>>6&63|128)),a+=String.fromCharCode(n&63|128));f=a;a=f.length;p=a+8;n=16*((p-p%64)/64+1);s=Array(n-1);for(g=l=0;g<a;)p=
|
||||
(g-g%4)/4,l=8*(g%4),s[p]|=f.charCodeAt(g)<<l,g++;p=(g-g%4)/4;s[p]|=128<<8*(g%4);s[n-2]=a<<3;s[n-1]=a>>>29;f=s;g=1732584193;h=4023233417;k=2562383102;j=271733878;for(a=0;a<f.length;a+=16)p=g,n=h,s=k,l=j,g=e(g,h,k,j,f[a+0],7,3614090360),j=e(j,g,h,k,f[a+1],12,3905402710),k=e(k,j,g,h,f[a+2],17,606105819),h=e(h,k,j,g,f[a+3],22,3250441966),g=e(g,h,k,j,f[a+4],7,4118548399),j=e(j,g,h,k,f[a+5],12,1200080426),k=e(k,j,g,h,f[a+6],17,2821735955),h=e(h,k,j,g,f[a+7],22,4249261313),g=e(g,h,k,j,f[a+8],7,1770035416),
|
||||
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,n),k=c(k,s),j=c(j,l);return(m(g)+m(h)+m(k)+m(j)).toLowerCase()};(function(a){a.fn.stupidtable=function(){a(this).on("click","thead th",function(){a(this).stupidsort()})};a.fn.stupidsort=function(){function c(c){var b=0,d;a(c).children("td,th").each(function(){if(b==p)return d=a(this),!1;var c=a(this).attr("colspan");b+=c?Number(c):1});c="undefined"!=typeof d.data("sort-value")?d.data("sort-value"):"undefined"!=typeof d.attr("data-sort-value")?d.attr("data-sort-value"):d.text();switch(m){case "string":case "string-ins":c=String(c).toLowerCase();break;case "int":c=
|
||||
parseInt(Number(c));break;case "float":c=Number(c)}return c}var e=a(this),b=e.closest("table"),d=b.children("tbody"),i=d.children("tr"),m=e.attr("data-sort-type");if(m){var f=!0;e.hasClass("sorting-asc")&&(f=!1);var p=0;e.prevAll().each(function(){var c=a(this).attr("colspan");p+=c?Number(c):1});i.sort(function(a,b){var d=f?1:-1,a=c(a),b=c(b);return a>b?1*d:a<b?-1*d:0});d.append(i);b.find("thead th").removeClass("sorting-asc").removeClass("sorting-desc");e.addClass(f?"sorting-asc":"sorting-desc")}}})(jQuery);$(function(){UI.elements={menu:$("nav > .menu"),secondary_menu:$("nav.secondary_menu"),main:$("main"),connection:{status:$("#connection"),user_and_host:$("#user_and_host"),msg:$("#message")}};UI.buildMenu();UI.stored.getOpts();if(location.hash){var a=decodeURIComponent(location.hash).substring(1).split("@")[0].split("&");mist.user.name=a[0];a[1]&&(mist.user.host=a[1])}mist.send(function(){$(window).trigger("hashchange")},{},{timeout:5,hide:!0})});
|
||||
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 l(a){var c="",b="",d;for(d=0;3>=d;d++)b=a>>>8*d&255,b="0"+b.toString(16),c+=b.substr(b.length-2,2);return c}var g=[],p,n,s,m,f,h,k,j,g=a.replace(/\r\n/g,"\n"),a="";for(p=0;p<g.length;p++)n=g.charCodeAt(p),128>n?a+=String.fromCharCode(n):(127<n&&2048>n?a+=String.fromCharCode(n>>6|192):(a+=String.fromCharCode(n>>12|224),a+=String.fromCharCode(n>>6&63|128)),a+=String.fromCharCode(n&63|128));g=a;a=g.length;p=a+8;n=16*((p-p%64)/64+1);s=Array(n-1);for(f=m=0;f<a;)p=
|
||||
(f-f%4)/4,m=8*(f%4),s[p]|=g.charCodeAt(f)<<m,f++;p=(f-f%4)/4;s[p]|=128<<8*(f%4);s[n-2]=a<<3;s[n-1]=a>>>29;g=s;f=1732584193;h=4023233417;k=2562383102;j=271733878;for(a=0;a<g.length;a+=16)p=f,n=h,s=k,m=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,n),k=c(k,s),j=c(j,m);return(l(f)+l(h)+l(k)+l(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(l){case "string":case "string-ins":c=String(c).toLowerCase();break;case "int":c=
|
||||
parseInt(Number(c));break;case "float":c=Number(c)}return c}var e=a(this),b=e.closest("table"),d=b.children("tbody"),i=d.children("tr"),l=e.attr("data-sort-type");if(l){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})});
|
||||
$(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,47 +20,47 @@ 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 m=$("<span>").addClass("submenu");i.addClass("arrowdown").append(m);for(var f in d.submenu)m.append(a(f,d.submenu[f]))}}}e=$("<div>").attr("id","ih_button").text("?").click(function(){$("body").toggleClass("helpme");UI.stored.saveOpt("helpme",$("body").hasClass("helpme"))}).attr("title","Click to toggle the display of integrated help");UI.stored.getOpts().helpme&&$("body").addClass("helpme");c.after(e).after($("<div>").addClass("separator"))},
|
||||
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 l=$("<span>").addClass("submenu");i.addClass("arrowdown").append(l);for(var g in d.submenu)l.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"))},
|
||||
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 m=b.buttons[i],f=$("<button>").text(m.label).data("opts",m);"css"in m&&f.css(m.css);d.append(f);switch(m.type){case "cancel":f.addClass("cancel").click(m["function"]);break;case "save":f.addClass("save").click(function(){var a=$(this).closest(".input_container"),c=!1;a.find(".hasValidate").each(function(){if(c=$(this).data("validate")(this,!0))return!1});
|
||||
c||(a.find(".isSetting").each(function(){var a=$(this).getval(),c=$(this).data("pointer");if(""==a)if("default"in $(this).data("opts"))a=$(this).data("opts")["default"];else return delete c.main[c.index],!0;c.main[c.index]=a}),(a=$(this).data("opts")["function"])&&a(this))});break;default:f.click(m["function"])}}else{m=$("<label>").addClass("UIelement");c.append(m);"css"in b&&m.css(b.css);m.append($("<span>").addClass("label").html("label"in b?b.label+":":""));f=$("<span>").addClass("field_container");
|
||||
m.append(f);switch(b.type){case "password":d=$("<input>").attr("type","password");break;case "int":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 l=b.buttons[i],g=$("<button>").text(l.label).data("opts",l);"css"in l&&g.css(l.css);d.append(g);switch(l.type){case "cancel":g.addClass("cancel").click(l["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(l["function"])}}else{l=$("<label>").addClass("UIelement");c.append(l);"css"in b&&l.css(b.css);l.append($("<span>").addClass("label").html("label"in b?b.label+":":""));g=$("<span>").addClass("field_container");
|
||||
l.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"],
|
||||
[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");m.hide();break;case "email":d=$("<input>").attr("type","email").attr("autocomplete","on").attr("required","");break;case "browse":d=$("<input>").attr("type","text");"filetypes"in b&&d.data("filetypes",b.filetypes);break;case "geolimited":case "hostlimited":d=$("<input>").attr("type",
|
||||
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");l.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 n=$("<input>").attr("type","radio").val(b.radioselect[e][0]).attr("name",b.label);("LTSonly"in b&&!mist.data.LTS||b.readonly)&&n.prop("disabled",!0);p=$("<label>").append(n).append($("<span>").html(b.radioselect[e][1]));d.append(p);if(2<b.radioselect[e].length)for(i in n=$("<select>").change(function(){$(this).parent().find("input[type=radio]:enabled").prop("checked","true")}),p.append(n),("LTSonly"in
|
||||
b&&!mist.data.LTS||b.readonly)&&n.prop("disabled",!0),b.radioselect[e][2])p=$("<option>"),n.append(p),b.radioselect[e][2][i]instanceof Array?p.val(b.radioselect[e][2][i][0]).html(b.radioselect[e][2][i][1]):p.html(b.radioselect[e][2][i])}break;case "checklist":d=$("<div>").addClass("checkcontainer");$controls=$("<div>").addClass("controls");$checklist=$("<div>").addClass("checklist");d.append($controls).append($checklist);$controls.append($("<label>").text("All").prepend($("<input>").attr("type","checkbox").click(function(){$(this).is(":checked")?
|
||||
$(this).closest(".checkcontainer").find("input[type=checkbox]").prop("checked",!0):$(this).closest(".checkcontainer").find("input[type=checkbox]").prop("checked",!1)})));for(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);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":n=$("<div>").addClass("grouper").append(m);c.append(n);n=$("<button>").text("Browse").on("keydown",function(a){a.stopPropagation()});
|
||||
f.append(n);n.click(function(){function a(c){i.text("Loading..");mist.send(function(a){f.text(a.browse.path[0]);i.html(n.clone(true).text("..").attr("title","Folder up"));if(a.browse.subdirectories){a.browse.subdirectories.sort();for(var c in a.browse.subdirectories){var m=a.browse.subdirectories[c];i.append(n.clone(true).attr("title",f.text()+o+m).text(m))}}if(a.browse.files){a.browse.files.sort();for(c in a.browse.files){var m=a.browse.files[c],l=f.text()+o+m,m=$("<a>").text(m).addClass("file").attr("title",
|
||||
l);i.append(m);if(p){var s=true,w;for(w in p)if(typeof p[w]!="undefined"&&mist.inputMatch(p[w],l)){s=false;break}s&&m.hide()}m.click(function(){var a=$(this).attr("title");d.setval(a);e.show();b.remove()})}}},{browse:c})}var c=$(this).closest(".grouper"),b=$("<div>").addClass("browse_container"),d=c.find(".field"),e=$(this),f=$("<span>").addClass("field"),m=$("<button>").text("Select this folder").on("keydown",function(a){a.stopPropagation()}),i=$("<div>").addClass("browse_contents"),n=$("<a>").addClass("folder"),
|
||||
p=d.data("filetypes");c.append(b);b.append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Current folder:")).append($("<span>").addClass("field_container").append(f).append(m))).append(i);m.click(function(){var a=f.text()+"/";d.setval(a);e.show();b.remove()});var o="/";mist.data.config.version.indexOf("indows")>-1&&(o="\\");n.click(function(){var c=f.text()+o+$(this).text();a(c)});c=d.getval();c=c.split(o);c.pop();c=c.join(o);e.hide();a(c)});break;case "geolimited":case "hostlimited":n=
|
||||
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":n=$("<div>").addClass("grouper").append(l);c.append(n);n=$("<button>").text("Browse").on("keydown",function(a){a.stopPropagation()});
|
||||
g.append(n);n.click(function(){function a(c){i.text("Loading..");mist.send(function(a){g.text(a.browse.path[0]);i.html(n.clone(true).text("..").attr("title","Folder up"));if(a.browse.subdirectories){a.browse.subdirectories.sort();for(var c in a.browse.subdirectories){var l=a.browse.subdirectories[c];i.append(n.clone(true).attr("title",g.text()+o+l).text(l))}}if(a.browse.files){a.browse.files.sort();for(c in a.browse.files){var l=a.browse.files[c],m=g.text()+o+l,l=$("<a>").text(l).addClass("file").attr("title",
|
||||
m);i.append(l);if(p){var s=true,x;for(x in p)if(typeof p[x]!="undefined"&&mist.inputMatch(p[x],m)){s=false;break}s&&l.hide()}l.click(function(){var a=$(this).attr("title");d.setval(a);e.show();b.remove()})}}},{browse:c})}var c=$(this).closest(".grouper"),b=$("<div>").addClass("browse_container"),d=c.find(".field"),e=$(this),g=$("<span>").addClass("field"),l=$("<button>").text("Select this folder").on("keydown",function(a){a.stopPropagation()}),i=$("<div>").addClass("browse_contents"),n=$("<a>").addClass("folder"),
|
||||
p=d.data("filetypes");c.append(b);b.append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Current folder:")).append($("<span>").addClass("field_container").append(g).append(l))).append(i);l.click(function(){var a=g.text()+"/";d.setval(a);e.show();b.remove()});var o="/";mist.data.config.version.indexOf("indows")>-1&&(o="\\");n.click(function(){var c=g.text()+o+$(this).text();a(c)});c=d.getval();c=c.split(o);c.pop();c=c.join(o);e.hide();a(c)});break;case "geolimited":case "hostlimited":n=
|
||||
{field:d};n.blackwhite=$("<select>").append($("<option>").val("-").text("Blacklist")).append($("<option>").val("+").text("Whitelist"));n.values=$("<span>").addClass("limit_value_list");switch(b.type){case "geolimited":n.prototype=$("<select>").append($("<option>").val("").text("[Select a country]"));for(e in UI.countrylist)n.prototype.append($("<option>").val(e).html(UI.countrylist[e]));break;case "hostlimited":n.prototype=$("<input>").attr("type","text").attr("placeholder","type a host")}n.prototype.on("change keyup",
|
||||
function(){$(this).closest(".field_container").data("subUI").blackwhite.trigger("change")});n.blackwhite.change(function(){var a=$(this).closest(".field_container").data("subUI"),c=[],b=false;a.values.children().each(function(){b=$(this).val();b!=""?c.push(b):$(this).remove()});a.values.append(a.prototype.clone(true));c.length>0?a.field.val($(this).val()+c.join(" ")):a.field.val("");a.field.trigger("change")});"LTSonly"in b&&!mist.data.LTS&&(n.blackwhite.prop("disabled",!0),n.prototype.prop("disabled",
|
||||
!0));n.values.append(n.prototype.clone(!0));f.data("subUI",n).addClass("limit_list").append(n.blackwhite).append(n.values)}"pointer"in b&&(d.data("pointer",b.pointer).addClass("isSetting"),n=b.pointer.main[b.pointer.index],"undefined"!=n&&d.setval(n));"value"in b&&d.setval(b.value);if("datalist"in b)for(e in n="datalist_"+e+MD5(d[0].outerHTML),d.attr("list",n),n=$("<datalist>").attr("id",n),f.append(n),b.datalist)n.append($("<option>").val(b.datalist[e]));f=$("<span>").addClass("help_container");
|
||||
m.append(f);"help"in b&&(f.append($("<span>").addClass("ih_balloon").html(b.help)),d.on("focus mouseover",function(){$(this).closest("label").addClass("active")}).on("blur mouseout",function(){$(this).closest("label").removeClass("active")}));if("validate"in b){m=[];for(i in b.validate){n=b.validate[i];if("function"!=typeof n)switch(n){case "required":n=function(a){return a==""?{msg:"This is a required field.",classes:["red"]}:false};break;case "int":n=function(a,c){var b=$(c).data("opts");if(!$(c)[0].validity.valid){var d=
|
||||
!0));n.values.append(n.prototype.clone(!0));g.data("subUI",n).addClass("limit_list").append(n.blackwhite).append(n.values)}"pointer"in b&&(d.data("pointer",b.pointer).addClass("isSetting"),n=b.pointer.main[b.pointer.index],"undefined"!=n&&d.setval(n));"value"in b&&d.setval(b.value);if("datalist"in b)for(e in n="datalist_"+e+MD5(d[0].outerHTML),d.attr("list",n),n=$("<datalist>").attr("id",n),g.append(n),b.datalist)n.append($("<option>").val(b.datalist[e]));g=$("<span>").addClass("help_container");
|
||||
l.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){l=[];for(i in b.validate){n=b.validate[i];if("function"!=typeof n)switch(n){case "required":n=function(a){return a==""?{msg:"This is a required field.",classes:["red"]}:false};break;case "int":n=function(a,c){var b=$(c).data("opts");if(!$(c)[0].validity.valid){var d=
|
||||
[];"min"in b&&d.push(" greater than or equal to "+b.min);"max"in b&&d.push(" smaller than or equal to "+b.max);return{msg:"Please enter an integer"+d.join(" and")+".",classes:["red"]}}if(parseInt(Number(a))!=a)return{msg:"Please enter an integer.",classes:["red"]}};break;case "streamname":n=function(a,c){if(!isNaN(a.charAt(0)))return{msg:"The first character may not be a number.",classes:["red"]};if(a.toLowerCase()!=a)return{msg:"Uppercase letters are not allowed.",classes:["red"]};if(a.replace(/[^\da-z_]/g,
|
||||
"")!=a)return{msg:"Special characters (except for underscores) are not allowed.",classes:["red"]};if("streams"in mist.data&&a in mist.data.streams&&$(c).data("pointer").main.name!=a)return{msg:"This streamname already exists.<br>If you want to edit an existing stream, please click edit on the the streams tab.",classes:["red"]}};break;default:n=function(){}}m.push(n)}d.data("validate_functions",m).data("help_container",f).data("validate",function(a,c){var b=$(a).getval(),d=$(a).data("validate_functions"),
|
||||
e=$(a).data("help_container");e.find(".err_balloon").remove();for(var f in d){var m=d[f](b,a);if(m){$err=$("<span>").addClass("err_balloon").html(m.msg);for(var i in m.classes)$err.addClass(m.classes[i]);e.prepend($err);c&&$(a).focus();return true}}return false}).addClass("hasValidate").on("change keyup",function(){$(this).data("validate")($(this))});""!=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");
|
||||
"")!=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:n=function(){}}l.push(n)}d.data("validate_functions",l).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 l=d[g](b,a);if(l){$err=$("<span>").addClass("err_balloon").html(l.msg);for(var i in l.classes)$err.addClass(l.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=[],n;for(n in b.datasets){var s=b.datasets[n];s.display&&(s.getdata(),s.yaxistype in b.yaxes||(d.push(UI.plot.yaxes[s.yaxistype]),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 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(n in b.datasets)e=$("<input>").attr("type","checkbox").data("index",n).data("graph",b).click(function(){var a=$(this).data("graph");$(this).is(":checked")?a.datasets[$(this).data("index")].display=true:a.datasets[$(this).data("index")].display=
|
||||
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 m=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 m in i){if(i[m][0]==a){f=e(i[m][1]);break}if(i[m][0]>a){if(m!=0){f=i[m];i=i[m-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(n in b.datasets)e=$("<input>").attr("type","checkbox").data("index",n).data("graph",b).click(function(){var a=$(this).data("graph");$(this).is(":checked")?a.datasets[$(this).data("index")].display=true:a.datasets[$(this).data("index")].display=
|
||||
false;var c={};c[a.id]=a;UI.plot.go(c)}),b.datasets[n].display&&e.attr("checked","checked"),d.append($("<tr>").html($("<td>").html($("<label>").html(e).append($("<div>").addClass("series-color").css("background-color",b.datasets[n].color)).append(b.datasets[n].label))).append($("<td>").css("padding-right","2em").css("text-align","right").html($("<span>").addClass("value")).append($("<button>").text("X").addClass("close").data("index",n).data("graph",b).click(function(){var c=$(this).data("index"),
|
||||
b=$(this).data("graph");if(confirm("Are you sure you want to remove "+b.datasets[c].label+" from "+b.id+"?")){b.datasets.splice(c,1);if(b.datasets.length==0){b.elements.cont.remove();var c=$(".graph_ids option:contains("+b.id+")"),d=c.parent();c.remove();d.trigger("change");UI.plot.del(b.id);delete a[b.id];UI.plot.go(a)}else{UI.plot.save(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,
|
||||
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)}}}))));m();var f=!1;b.elements.plot.on("plothover",function(a,c,b){if(c.x!=f){m(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",function(){m()})}}},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 m=Math.pow(10,-d),b=b/m,f;if(1.5>b)f=1;else if(3>b){if(f=2,2.25<b&&(null==i||d+1<=i))f=2.5,++d}else f=7.5>b?5:10;f=f*m*Math.pow(1024,e);null!=a.minTickSize&&f<a.minTickSize&&(f=a.minTickSize);a.delta=c;a.tickDecimals=Math.max(0,null!=i?i:d);a.tickSize=f;c=[];e=a.tickSize*Math.floor(a.min/a.tickSize);d=0;i=Number.NaN;do m=i,i=e+d*a.tickSize,c.push(i),++d;while(i<a.max&&i!=m);return c},min:0}},xaxes:{time:{name:"time",mode:"time",timezone:"browser",ticks:5}}},
|
||||
i=a.tickDecimals;null!=i&&d>i&&(d=i);var l=Math.pow(10,-d),b=b/l,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*l*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 l=i,i=e+d*a.tickSize,c.push(i),++d;while(i<a.max&&i!=l);return c},min:0}},xaxes:{time:{name:"time",mode:"time",timezone:"browser",ticks:5}}},
|
||||
draggable:function(a){a.attr("draggable",!0);a.on("dragstart",function(a){$(this).css("opacity",0.4).data("dragstart",{click:{x:a.originalEvent.pageX,y:a.originalEvent.pageY},ele:{x:this.offsetLeft,y:this.offsetTop}})}).on("dragend",function(a){var 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 m;for(d=e.length-1;0<=d;d--)if(0<b[e[d]]){m=e[d];break}c=$("<span>");switch(m){case "week":c.append(UI.format.addUnit(b.week,"wks, ")).append(UI.format.addUnit(b.day,"days"));break;case "day":c.append(UI.format.addUnit(b.day,"days, ")).append(UI.format.addUnit(b.hr,"hrs"));break;default:c.append([("0"+
|
||||
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 l;for(d=e.length-1;0<=d;d--)if(0<b[e[d]]){l=e[d];break}c=$("<span>");switch(l){case "week":c.append(UI.format.addUnit(b.week,"wks, ")).append(UI.format.addUnit(b.day,"days"));break;case "day":c.append(UI.format.addUnit(b.day,"days, ")).append(UI.format.addUnit(b.hr,"hrs"));break;default:c.append([("0"+
|
||||
b.hr).slice(-2),("0"+b.min).slice(-2),("0"+b.sec).slice(-2)+(b.ms?"."+b.ms:"")].join(":"))}return c[0].innerHTML},number:function(a){if(isNaN(Number(a))||0==a)return a;var c=Math.pow(10,3-Math.floor(Math.log(a)/Math.LN10)-1),a=Math.round(a*c)/c;if(1E4<a){number=a.toString().split(".");for(a=/(\d+)(\d{3})/;a.test(number[0]);)number[0]=number[0].replace(a,"$1 $2");a=number.join(".")}return a},status:function(a){var c=$("<span>");if("undefined"==typeof a.online)return c.text("Unknown, checking.."),"undefined"!=
|
||||
typeof a.error&&c.text(a.error),c;switch(a.online){case -1:c.text("Enabling");break;case 0:c.text("Unavailable").addClass("red");break;case 1:c.text("Active").addClass("green");break;case 2:c.text("Standby").addClass("orange");break;default:c.text(a.online)}"error"in a&&c.text(a.error);return c},capital:function(a){return a.charAt(0).toUpperCase()+a.substring(1)},addUnit:function(a,c){var e=$("<span>").html(a);e.append($("<span>").addClass("unit").html(c));return e[0].innerHTML},bytes:function(a,
|
||||
c){var e="bytes KiB MiB GiB TiB PiB".split(" ");if(0==a)unit=e[0];else{var b=Math.floor(Math.log(Math.abs(a))/Math.log(1024));0>b?unit=e[0]:(a/=Math.pow(1024,b),unit=e[b])}return UI.format.addUnit(UI.format.number(a),unit+(c?"/s":""))}},navto:function(a,c){var e=location.hash,b=e.split("@");b[0]=[mist.user.name,mist.user.host].join("&");b[1]=[a,c].join("&");"undefined"!=typeof screenlog&&screenlog.navto(b[1]);location.hash=b.join("@");location.hash==e&&$(window).trigger("hashchange")},showTab:function(a,
|
||||
|
@ -71,64 +71,68 @@ 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.."),m=$("<span>"),f=$("<span>"),p=$("<span>");d.append(UI.buildUI([{type:"help",help:"You can find most basic information about your MistServer here.<br>You can also set the debug level and force a save to the config.json file that MistServer uses to save your settings. "},
|
||||
{type:"span",label:"Version",pointer:{main:mist.data.config,index:"version"}},{type:"span",label:"Version check",value:i,LTSonly:!0},{type:"span",label:"Server time",value:p},{type:"span",label:"Current streams",value:m},{type:"span",label:"Current connections",value:f},$("<br>"),{type:"str",label:"Human readable name",pointer:{main:mist.data.config,index:"name"},help:"You can name your MistServer here for personal use. You'll still need to set host name within your network yourself."},{type:"debug",
|
||||
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.."),l=$("<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:l},{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",
|
||||
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 n=function(){var a=mist.stored.get().update||{};"uptodate"in a?a.error?i.addClass("red").text(a.error):a.uptodate?i.text("Your version is up to date.").addClass("green"):i.addClass("red").text("Version outdated!").append($("<button>").text("Update").css({"font-size":"1em","margin-left":"1em"}).click(function(){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));n()},{checkupdate:!0})}else n()}else i.text("");var l=function(){mist.send(function(){g()},{totals:{fields:["clients"],start:-10},active_streams:true})},
|
||||
g=function(){m.text(("active_streams"in mist.data?mist.data.active_streams?mist.data.active_streams.length:0:"?")+" active, "+(mist.data.streams?Object.keys(mist.data.streams).length:0)+" configured");if("totals"in mist.data&&"all_streams"in mist.data.totals)var a=mist.data.totals.all_streams.all_protocols.clients,a=a.length?UI.format.number(a[a.length-1][1]):0;else a="Loading..";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"==
|
||||
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));n()},{checkupdate:!0})}else n()}else i.text("");var m=function(){mist.send(function(){f()},{totals:{fields:["clients"],start:-10},active_streams:true})},
|
||||
f=function(){l.text(("active_streams"in mist.data?mist.data.active_streams?mist.data.active_streams.length:0:"?")+" active, "+(mist.data.streams?Object.keys(mist.data.streams).length:0)+" configured");if("totals"in mist.data&&"all_streams"in mist.data.totals)var a=mist.data.totals.all_streams.all_protocols.clients,a=a.length?UI.format.number(a[a.length-1][1]):0;else a="Loading..";g.text(a);p.text(UI.format.dateTime(mist.data.config.time,"long"))};m();f();UI.interval.set(m,3E4);break;case "Protocols":if("undefined"==
|
||||
typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});d.append("Loading..");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"],f;for(f in e)for(var g in b[e[f]])c[g]&&c[g]!=""?d.push(g+": "+c[g]):b[e[f]][g]["default"]&&d.push(g+": "+b[e[f]][g]["default"]);return $("<span>").addClass("description").text(d.join(", "))}h.html("");for(var c in mist.data.config.protocols){var b=mist.data.config.protocols[c];h.append($("<tr>").data("index",c).append($("<td>").text(b.connector)).append($("<td>").html(UI.format.status(b))).append($("<td>").html(a(b))).append($("<td>").css("text-align",
|
||||
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 t in b[e[g]])c[t]&&c[t]!=""?d.push(t+": "+c[t]):b[e[g]][t]["default"]&&d.push(t+": "+b[e[g]][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 w={},q;for(q in mist.data.config.protocols)w[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 x={},q;for(q in mist.data.config.protocols)x[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 w[b.deps[e]]!="undefined"||typeof w[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)},w={};for(q in mist.data.config.protocols)w[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",
|
||||
" ");$ul.append(a);typeof x[b.deps[e]]!="undefined"||typeof x[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)},x={};for(q in mist.data.config.protocols)x[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={},y=[];for(q in mist.data.capabilities.connectors)y.push([q,q]);var V=$("<span>");d.append(UI.buildUI([{label:"Protocol",type:"select",select:y,"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=[],b;for(b in mist.data.active_streams)a.push({streams:[mist.data.active_streams[b]],fields:["clients"],start:-2});mist.send(function(){$.extend(true,z,mist.data.streams);var a=0;h.html("");if(mist.data.LTS)for(a in mist.data.active_streams){var b=mist.data.active_streams[a].split("+");if(!(b.length<2)&&b[0]in mist.data.streams){b=W(mist.data.active_streams[a],mist.data.streams[b[0]]);b.online=1;z[mist.data.active_streams[a]]=b}}b=Object.keys(z);b.sort();for(var c in b){var d=
|
||||
b[c],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 C=mist.data.totals[d].all_protocols.clients,g=0;if(C.length){for(a in C)g=g+C[a][1];g=Math.round(g/C.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 b={};mist.data.LTS?b.deletestream=[a]:b.streams=mist.data.streams;mist.send(function(){UI.navto("Streams")},b)}}));C=$("<span>").text(d);e.ischild&&C.css("padding-left","1em");var i=
|
||||
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(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(f).append($("<td>").html(j)).append(g));
|
||||
a++}},{totals:a,active_streams:true})},z=$.extend(!0,{},mist.data.streams),W=function(a,b){var c=$.extend({},b);delete c.meta;delete c.error;c.online=2;c.name=a;c.ischild=true;return c};if(mist.data.LTS){var 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)&&(z[l].source+="*",mist.send(function(a,b){var c=b.stream,d;for(d in a.browse.files)for(var e in mist.data.capabilities.inputs)if(!(e.indexOf("Buffer")>=
|
||||
0||e.indexOf("Folder")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[e].source_match,"/"+a.browse.files[d])){var g=c+"+"+a.browse.files[d];z[g]=W(g,mist.data.streams[c]);z[g].source=mist.data.streams[c].source+a.browse.files[d]}"files"in a.browse&&a.browse.files.length?z[c].filesfound=true:mist.data.streams[c].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()},
|
||||
{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 b=null,c;for(c in mist.data.capabilities.inputs)if(typeof mist.data.capabilities.inputs[c].source_match!="undefined"&&mist.inputMatch(mist.data.capabilities.inputs[c].source_match,a)){b=c;break}if(b===null)J.html($("<h3>").text("Unrecognized input").addClass("red")).append($("<span>").text("Please edit the stream source.").addClass("red"));else{a=mist.data.capabilities.inputs[b];J.html($("<h3>").text(a.name+" Input options"));a=mist.convertBuildOptions(a,
|
||||
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,A,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;A[mist.data.active_streams[a]]=c}}c=Object.keys(A);c.sort();for(var b in c){var d=
|
||||
c[b],e;e=d in mist.data.streams?mist.data.streams[d]:A[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 t=mist.data.totals[d].all_protocols.clients,f=0;if(t.length){for(a in t)f=f+t[a][1];f=Math.round(f/t.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)}}));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="";g.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(g).append($("<td>").html(j)).append(f));
|
||||
a++}},{totals:a,active_streams:true})},A=$.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(m in mist.data.streams)r=mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"],mist.inputMatch(r.source_match,mist.data.streams[m].source)&&(A[m].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];A[g]=W(g,mist.data.streams[b]);A[g].source=mist.data.streams[b].source+a.browse.files[d]}"files"in a.browse&&a.browse.files.length?A[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[m].source},{stream:m}),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?(m=c,o=mist.data.streams[m],d.find("h2").append(' "'+m+'"')):(d.html($("<h2>").text("New Stream")),o={});m=[];for(q in mist.data.capabilities.inputs)m.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:m,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{a=mist.data.capabilities.inputs[c];J.html($("<h3>").text(a.name+" Input options"));a=mist.convertBuildOptions(a,
|
||||
o);J.append(UI.buildUI(a))}}}},$("<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(b){var c={};b.sort();d.html($("<h2>").text(a)).append(UI.buildUI([{label:"Select a stream",type:"select",select:b,pointer:{main:c,index:"stream"}},{type:"buttons",buttons:[{type:"save",label:"Go","function":function(){UI.navto(a,c.stream)}}]}]));
|
||||
UI.elements.secondary_menu.html("").append($("<a>").addClass("button").addClass("active").text("Choose stream").click(function(){UI.navto("Preview")}));var e=$("<div>").addClass("preview_icons");d.append($("<span>").addClass("description").text("Or, click a stream from the list below.")).append(e);for(var g in b){var f=b[g],h="";if(f.indexOf("+")>-1){h=f.split("+");h=mist.data.streams[h[0]].source+h[1]}else h=mist.data.streams[f].source;e.append($("<button>").append($("<span>").text(f)).append($("<span>").addClass("description").text(h)).attr("title",
|
||||
f).attr("data-stream",f).click(function(){UI.navto("Preview",$(this).attr("data-stream"))}))}};if(mist.data.LTS){if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});d.append("Loading..");break}G=B=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,b){var c=b.stream,d;for(d in mist.data.browse.files)for(var e in mist.data.capabilities.inputs)e.indexOf("Buffer")>=
|
||||
0||e.indexOf("Folder")>=0||mist.inputMatch(mist.data.capabilities.inputs[e].source_match,"/"+mist.data.browse.files[d])&&(x[c+"+"+mist.data.browse.files[d]]=true);G++;B==G&&mist.send(function(){for(var a in mist.data.active_streams){var b=mist.data.active_streams[a].split("+");b.length>1&&b[0]in mist.data.streams&&(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}),
|
||||
B++);0==B&&mist.send(function(){var b=[],c;for(c in mist.data.active_streams){var e=mist.data.active_streams[c].split("+");e.length>1&&e[0]in mist.data.streams&&(b[mist.data.active_streams[c]]=true)}mist.data.streams&&(b=b.concat(Object.keys(mist.data.streams)));if(b.length==0)d.html($("<h2>").text(a)).append("Please set up a stream first.");else{b.sort();N(b)}},{active_streams:!0})}else N(Object.keys(mist.data.streams));break}d.find("h2").append(' of "'+c+'"');l=":8080";for(q in mist.data.config.protocols)if(r=
|
||||
mist.data.config.protocols[q],"HTTP"==r.connector||"HTTP.exe"==r.connector)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_"+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_"+c+".js",readonly:!0},{label:"Stream info script",type:"str",value:H+"info_"+c+".js",readonly:!0},{label:"Autodetect player",type:"str",value:H+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%"}),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_"+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()));
|
||||
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=C=0;y={};for(m in mist.data.streams)r=mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"],mist.inputMatch(r.source_match,mist.data.streams[m].source)&&(mist.send(function(a,c){var b=c.stream,d;for(d in mist.data.browse.files)for(var e in mist.data.capabilities.inputs)e.indexOf("Buffer")>=
|
||||
0||e.indexOf("Folder")>=0||mist.inputMatch(mist.data.capabilities.inputs[e].source_match,"/"+mist.data.browse.files[d])&&(y[b+"+"+mist.data.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&&(y[mist.data.active_streams[a]]=true)}y=Object.keys(y);y=y.concat(Object.keys(mist.data.streams));y.sort();N(y)},{active_streams:true})},{browse:mist.data.streams[m].source},{stream:m}),
|
||||
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+'"');m=":8080";for(q in mist.data.config.protocols)if(r=
|
||||
mist.data.config.protocols[q],"HTTP"==r.connector||"HTTP.exe"==r.connector)m=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+m+"/",z={autoplay:!0},K=function(a){var b=["div"],d='\n <script src="'+H+"embed_"+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_"+c+".js",readonly:!0},{label:"Stream info script",type:"str",value:H+"info_"+c+".js",readonly:!0},{label:"Autodetect player",type:"str",value:H+c+".html",readonly:!0,qrcode:!0},$("<h3>").text("Embed code"),{label:"Embed code",type:"textarea",value:K(z),rows:4,
|
||||
readonly:!0,classes:["embed_code"]},$("<h4>").text("Embed code options").css("margin-top",0),{label:"Autoplay",type:"checkbox",value:!0,pointer:{main:z,index:"autoplay"},"function":function(){z.autoplay=$(this).getval();$(".embed_code").setval(K(z))}},{label:"Force protocol",type:"select",select:[["","Automatic"]],pointer:{main:z,index:"protocol"},classes:["embed_code_forceprotocol"],"function":function(){z.forceprotocol=$(this).getval();$(".embed_code").setval(K(z))}},{label:"Video URL addition",
|
||||
type:"str",pointer:{main:z,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(){z.urlappend=$(this).getval();$(".embed_code").setval(K(z))}},$("<h3>").text("Protocol stream urls"),X]));m=$("<span>").append($("<h3>").text("Meta information")).hide();D["Meta information"]=m;var O=$("<span>");m.append(O);d.append(m);m=$("<span>").hide();D.Preview=m;d.append(m);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");m.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_"+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 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",
|
||||
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(){u.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,b){a=a.split("_").pop();b=b.split("_").pop();return a-b});for(var l in d){e=d[l];f=j.tracks[e];switch(f.type){case "audio":b.content.push({header:"Track "+e.split("_").pop(),body:[f.codec,UI.format.duration((f.lastms-f.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(f.firstms/1E3)+" to "+UI.format.duration(f.lastms/1E3)+"</span>",UI.format.bytes(f.bps,1),f.channels,UI.format.addUnit(UI.format.number(f.rate),
|
||||
"Hz")]});break;case "video":g.content.push({header:"Track "+e.split("_").pop(),body:[f.codec,UI.format.duration((f.lastms-f.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(f.firstms/1E3)+" to "+UI.format.duration(f.lastms/1E3)+"</span>",UI.format.bytes(f.bps,1),UI.format.addUnit(f.width,"x ")+UI.format.addUnit(f.height,"px"),UI.format.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"];w=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]==w&&(r.addClass("active"),D[w].show());break;case "Push":t=$("<div>").text("Loading..");d.append(t);mist.send(function(a){function b(a,c){var d=$("<span>");a.length>=4&&a[2]!=a[3]?d.append($("<span>").text(a[2])).append($("<span>").html("»").addClass("unit").css("margin","0 0.5em")).append($("<span>").text(a[3])):d.append($("<span>").text(a[2]));return $("<tr>").append($("<td>").text(a[1])).append($("<td>").append(d.children())).append($("<td>").append($("<button>").text(c==
|
||||
"Automatic"?"Remove":"Stop").click(function(){if(confirm("Are you sure you want to "+$(this).text().toLowerCase()+" this push?\n"+a[1]+" to "+a[2])){var b=$(this).closest("tr");b.html($("<td colspan=99>").html($("<span>").addClass("red").text(c=="Automatic"?"Removing..":"Stopping..")));c=="Automatic"?mist.send(function(){b.remove()},{push_auto_remove:{stream:a[1],target:a[2]}}):mist.send(function(){function c(){setTimeout(function(){mist.send(function(d){var e=false;if("push_list"in d&&d.push_list&&
|
||||
d.push_list.length){var e=true,f;for(f in d.push_list)if(d.push_list[f][0]==a[0]){e=false;break}}else e=true;e?b.remove():c()},{push_list:1})},1E3)}c()},{push_stop:[a[0]]})}})))}t.html("");var c=a.push_settings;c||(c={});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:c,index:"wait"},LTSonly:1},{label:"Maximum retries",unit:"/s",type:"int",min:0,help:"The maximum amount of retries per second (for all automatic pushes).<br>If set to 0, there is no limit.","default":0,pointer:{main:c,index:"maxspeed"},LTSonly:1},{type:"buttons",buttons:[{type:"save",label:"Save","function":function(){mist.send(function(){UI.navto("Push")},{push_settings:c})}}]}]));var d=$("<table>").append($("<tr>").append($("<th>").text("Stream")).append($("<th>").text("Target")).append($("<th>"))),
|
||||
e=d.clone();if("push_list"in a)for(var f in a.push_list)d.append(b(a.push_list[f],"Manual"));if("push_auto_list"in a)for(f in a.push_auto_list)e.append(b([-1,a.push_auto_list[f][0],a.push_auto_list[f][1]],"Automatic"));t.append($("<h3>").text("Automatic pushes")).append($("<button>").text("Add an automatic push").click(function(){UI.navto("Start Push","auto")}));e.find("tr").length==1?t.append($("<div>").text("No automatic pushes have been configured.").addClass("text").css("margin-top","0.5em")):
|
||||
t.append(e);t.append($("<h3>").text("Pushes")).append($("<button>").text("Start a push").click(function(){UI.navto("Start Push")}));d.find("tr").length==1?t.append($("<div>").text("No pushes are active.").addClass("text").css("margin-top","0.5em")):t.append($("<button>").text("Stop all pushes").click(function(){var b=[],c;for(c in a.push_list)b.push(a.push_list[c][0]);if(b.length!=0&&confirm("Are you sure you want to stop all pushes?")){mist.send(function(){function a(){setTimeout(function(){mist.send(function(c){var d=
|
||||
false;if("push_list"in c&&c.push_list&&c.push_list.length){var d=true,e;for(e in c.push_list)if(b.indexOf(c.push_list[e][0])==-1){d=false;break}}else d=true;d?UI.navto("Push"):a()},{push_list:1})},1E3)}a()},{push_stop:b});d.find("tr:not(:first-child)").html($("<td colspan=99>").append($("<span>").addClass("red").text("Stopping..")));$(this).remove()}})).append(d)},{push_settings:1,push_list:1,push_auto_list:1});break;case "Start Push":if(!("capabilities"in mist.data)){d.append("Loading Mist capabilities..");
|
||||
mist.send(function(){UI.navto("Start Push")},{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>",
|
||||
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];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");t=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(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"));m=["Preview","Embed urls","Meta information"];x=m[0];for(q in m)r=$("<a>").addClass("button").text(m[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),m[q]==x&&(r.addClass("active"),D[x].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,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)}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>"))),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"));u.append($("<h3>").text("Automatic pushes")).append($("<button>").text("Add an automatic push").click(function(){UI.navto("Start Push","auto")}));f.find("tr").length==1?u.append($("<div>").text("No automatic pushes have been configured.").addClass("text").css("margin-top","0.5em")):u.append(f);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 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]));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 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 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 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: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: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",
|
||||
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,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])&&v.push(e+"+"+a.browse.files[f]);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",
|
||||
e.stupidtable();m=mist.data.config.triggers;for(q in m)for(r in m[q])h.append($("<tr>").attr("data-index",q+","+r).append($("<td>").text(q)).append($("<td>").text(m[q][r][2].join(", "))).append($("<td>").text(m[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(","),m=mist.data.config.triggers[c[0]][c[1]],o={triggeron:c[0],appliesto:m[2],url:m[0],async:m[1],"default":m[3]}):(d.html($("<h2>").text("New Trigger")),o={});d.append(UI.buildUI([{label:"Trigger on",
|
||||
pointer:{main:o,index:"triggeron"},help:"For what event this trigger should activate.",type:"select",select:[["SYSTEM_START","SYSTEM_START: after MistServer boot"],["SYSTEM_STOP","SYSTEM_STOP: right before MistServer shutdown"],["SYSTEM_CONFIG","SYSTEM_CONFIG: after MistServer configurations have changed"],["OUTPUT_START","OUTPUT_START: right after the start command has been send to a protocol"],["OUTPUT_STOP","OUTPUT_STOP: right after the close command has been send to a protocol "],["STREAM_ADD",
|
||||
"STREAM_ADD: right before new stream configured"],["STREAM_CONFIG","STREAM_CONFIG: right before a stream configuration has changed"],["STREAM_REMOVE","STREAM_REMOVE: right before a stream has been deleted"],["STREAM_SOURCE","STREAM_SOURCE: right before stream source is loaded"],["STREAM_LOAD","STREAM_LOAD: right before stream input is loaded in memory"],["STREAM_READY","STREAM_READY: when the stream input is loaded and ready for playback"],["STREAM_UNLOAD","STREAM_UNLOAD: right before the stream input is removed from memory"],
|
||||
["STREAM_PUSH","STREAM_PUSH: right before an incoming push is accepted"],["STREAM_TRACK_ADD","STREAM_TRACK_ADD: right before a track will be added to a stream; e.g.: additional push received"],["STREAM_TRACK_REMOVE","STREAM_TRACK_REMOVE: right before a track will be removed track from a stream; e.g.: push timeout"],["STREAM_BUFFER","STREAM_BUFFER: when a buffer changes between mostly full or mostly empty"],["RTMP_PUSH_REWRITE","RTMP_PUSH_REWRITE: allows rewriting of RTMP push URLs from external to internal representation before further parsing"],
|
||||
|
@ -139,30 +143,30 @@ 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),
|
||||
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-
|
||||
"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 f=[],g;for(g in w[a].datasets){var h=UI.plot.datatype.getOptions({datatype:w[a].datasets[g].datatype,origin:w[a].datasets[g].origin});f.push(h)}e.datasets=f;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>"),m={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],m.content.push({header:"CPU #"+(Number(q)+1),
|
||||
body:[r.model,UI.format.addUnit(UI.format.number(r.mhz),"MHz"),r.cores,r.threads]});var m=UI.buildVheaderTable(m),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);
|
||||
delete l.statistics;delete l.totals;delete l.clients;delete l.capabilities;l=JSON.stringify(l);l="Version: "+mist.data.config.version+"\n\nConfig:\n"+l;o={};d.append(UI.buildUI([{type:"help",help:"You can use this form to email MistServer support if you're having difficulties.<br>A copy of your server config file will automatically be included."},{type:"str",label:"Your name",validate:["required"],pointer:{main:o,index:"name"},value:mist.user.name},{type:"email",label:"Your email address",validate:["required"],
|
||||
pointer:{main:o,index:"email"}},{type:"hidden",value:"Integrated Help",pointer:{main:o,index:"subject"}},{type:"hidden",value:"-",pointer:{main:o,index:"company"}},{type:"textarea",rows:20,label:"Your message",validate:["required"],pointer:{main:o,index:"message"}},{type:"textarea",rows:20,label:"Your config file",readonly:!0,value:l,pointer:{main:o,index:"configfile"}},{type:"buttons",buttons:[{type:"save",label:"Send","function":function(a){$(a).text("Sending..");$.ajax({type:"POST",url:"http://mistserver.org/contact?skin=plain",
|
||||
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(m).attr("colspan",2))));UI.interval.set(function(){mist.send(function(){aa()},{capabilities:true})},3E4);break;case "Email for Help":m=$.extend({},mist.data);
|
||||
delete m.statistics;delete m.totals;delete m.clients;delete m.capabilities;m=JSON.stringify(m);m="Version: "+mist.data.config.version+"\n\nConfig:\n"+m;o={};d.append(UI.buildUI([{type:"help",help:"You can use this form to email MistServer support if you're having difficulties.<br>A copy of your server config file will automatically be included."},{type:"str",label:"Your name",validate:["required"],pointer:{main:o,index:"name"},value:mist.user.name},{type:"email",label:"Your email address",validate:["required"],
|
||||
pointer:{main:o,index:"email"}},{type:"hidden",value:"Integrated Help",pointer:{main:o,index:"subject"}},{type:"hidden",value:"-",pointer:{main:o,index:"company"}},{type:"textarea",rows:20,label:"Your message",validate:["required"],pointer:{main:o,index:"message"}},{type:"textarea",rows:20,label:"Your config file",readonly:!0,value:m,pointer:{main:o,index:"configfile"}},{type:"buttons",buttons:[{type:"save",label:"Send","function":function(a){$(a).text("Sending..");$.ajax({type:"POST",url:"http://mistserver.org/contact?skin=plain",
|
||||
data:o,success:function(a){a=$("<span>").html(a);a.find("script").remove();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),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,
|
||||
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,
|
||||
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([m,0])};var e={},f;for(f in c.fields)e[c.fields[f]]=[];var i=0,m;if(c.data){if(c.start>mist.data.config.time-600){m=(mist.data.config.time-600)*1E3;d();m=c.start*1E3;d()}else m=c.start*1E3;for(f in c.data){if(f==0){m=c.start*1E3;var p=0}else{m=m+c.interval[p][1]*1E3;c.interval[p][0]--;if(c.interval[p][0]<=0){p++;p<c.interval.length-1&&(i=i+2)}}if(i%2==1){d();i--}for(var F in c.data[f])e[c.fields[F]].push([m,
|
||||
c.data[f][F]]);if(i){d();i--}}if(mist.data.config.time-c.end>20){d();m=(mist.data.config.time-15)*1E3;d()}}else{m=(mist.data.config.time-600)*1E3;d();m=(mist.data.config.time-15)*1E3;d()}d=e;stream=a?a.join(" "):"all_streams";protocol=b?b.join("_"):"all_protocols";stream in mist.data.totals||(mist.data.totals[stream]={});protocol in mist.data.totals[stream]||(mist.data.totals[stream][protocol]={});$.extend(mist.data.totals[stream][protocol],d)};mist.data.totals={};if("fields"in b.totals)d(c.totals.streams,
|
||||
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([l,0])};var e={},g;for(g in c.fields)e[c.fields[g]]=[];var i=0,l;if(c.data){if(c.start>mist.data.config.time-600){l=(mist.data.config.time-600)*1E3;d();l=c.start*1E3;d()}else l=c.start*1E3;for(g in c.data){if(g==0){l=c.start*1E3;var p=0}else{l=l+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([l,
|
||||
c.data[g][F]]);if(i){d();i--}}if(mist.data.config.time-c.end>20){d();l=(mist.data.config.time-15)*1E3;d()}}else{l=(mist.data.config.time-600)*1E3;d();l=(mist.data.config.time-15)*1E3;d()}d=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 m=a[b[d]][i],f={label:UI.format.capital(m.name),pointer:{main:c,index:i},validate:[]};b[d]=="required"&&!("default"in m)&&f.validate.push("required");
|
||||
if("default"in m)f.placeholder=m["default"];if("help"in m)f.help=m.help;if("unit"in m)f.unit=m.unit;switch(m.type){case "int":f.type="int";break;case "uint":f.type="int";f.min=0;break;case "debug":f.type="debug";break;case "select":f.type="select";f.select=m.select;break;default:f.type="str"}e.push(f)}}return e},stored:{get:function(){return mist.data.ui_settings||{}},set:function(a,c){var e=this.get();e[a]=c;mist.send(function(){},{ui_settings:e})},del:function(a){delete mist.data.ui_settings[a];
|
||||
"\\$&");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 l=a[b[d]][i],g={label:UI.format.capital(l.name),pointer:{main:c,index:i},validate:[]};b[d]=="required"&&!("default"in l)&&g.validate.push("required");
|
||||
if("default"in l)g.placeholder=l["default"];if("help"in l)g.help=l.help;if("unit"in l)g.unit=l.unit;switch(l.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=l.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];
|
||||
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==
|
||||
|
|
211
lsp/mist.js
211
lsp/mist.js
|
@ -3269,6 +3269,34 @@ var UI = {
|
|||
)
|
||||
);
|
||||
var $autopush = $push.clone();
|
||||
//check if push ids have been stopped untill the answer is yes
|
||||
function checkgone(ids) {
|
||||
setTimeout(function(){
|
||||
mist.send(function(d){
|
||||
var gone = false;
|
||||
if (('push_list' in d) && (d.push_list) && (d.push_list.length)) {
|
||||
gone = true;
|
||||
for (var i in d.push_list) {
|
||||
if (ids.indexOf(d.push_list[i][0]) > -1) {
|
||||
gone = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
gone = true;
|
||||
}
|
||||
if (gone) {
|
||||
for (var i in ids) {
|
||||
$push.find('tr[data-pushid='+ids[i]+']').remove();
|
||||
}
|
||||
}
|
||||
else {
|
||||
checkgone();
|
||||
}
|
||||
},{push_list:1});
|
||||
},1e3);
|
||||
}
|
||||
function buildTr(push,type) {
|
||||
var $target = $('<span>');
|
||||
if ((push.length >= 4) && (push[2] != push[3])) {
|
||||
|
@ -3285,12 +3313,7 @@ var UI = {
|
|||
$('<span>').text(push[2])
|
||||
);
|
||||
}
|
||||
return $('<tr>').append(
|
||||
$('<td>').text(push[1])
|
||||
).append(
|
||||
$('<td>').append($target.children())
|
||||
).append(
|
||||
$('<td>').append(
|
||||
var $buttons = $('<td>').append(
|
||||
$('<button>').text((type == 'Automatic' ? 'Remove' : 'Stop')).click(function(){
|
||||
if (confirm("Are you sure you want to "+$(this).text().toLowerCase()+" this push?\n"+push[1]+' to '+push[2])) {
|
||||
var $tr = $(this).closest('tr');
|
||||
|
@ -3309,39 +3332,57 @@ var UI = {
|
|||
}
|
||||
else {
|
||||
mist.send(function(d){
|
||||
//check if it has been stopped untill the answer is yes
|
||||
function checkgone() {
|
||||
setTimeout(function(){
|
||||
mist.send(function(d){
|
||||
var gone = false;
|
||||
if (('push_list' in d) && (d.push_list) && (d.push_list.length)) {
|
||||
gone = true;
|
||||
for (var i in d.push_list) {
|
||||
if (d.push_list[i][0] == push[0]) {
|
||||
gone = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
gone = true;
|
||||
}
|
||||
if (gone) {
|
||||
$tr.remove();
|
||||
}
|
||||
else {
|
||||
checkgone();
|
||||
}
|
||||
},{push_list:1});
|
||||
},1e3);
|
||||
}
|
||||
checkgone();
|
||||
checkgone([push[0]]);
|
||||
},{'push_stop':[push[0]]});
|
||||
}
|
||||
}
|
||||
})
|
||||
);
|
||||
if (type == 'Automatic') {
|
||||
$buttons.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"+push[1]+' to '+push[2])) {
|
||||
var $tr = $(this).closest('tr');
|
||||
$tr.html(
|
||||
$('<td colspan=99>').html(
|
||||
$('<span>').addClass('red').text('Removing and stopping..')
|
||||
)
|
||||
);
|
||||
//also stop the matching pushes
|
||||
var pushIds = [];
|
||||
for (var i in d.push_list) {
|
||||
// streamname target
|
||||
if ((push[1] == d.push_list[i][1]) && (push[2] == d.push_list[i][2])) {
|
||||
pushIds.push(d.push_list[i][0]);
|
||||
$push.find('tr[data-pushid='+d.push_list[i][0]+']').html(
|
||||
$('<td colspan=99>').html(
|
||||
$('<span>').addClass('red').text('Stopping..')
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
mist.send(function(){
|
||||
$tr.remove();
|
||||
checkgone(pushIds);
|
||||
},{
|
||||
push_auto_remove:{
|
||||
stream: push[1],
|
||||
target: push[2]
|
||||
},
|
||||
push_stop: pushIds
|
||||
});
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
return $('<tr>').attr('data-pushid',push[0]).append(
|
||||
$('<td>').text(push[1])
|
||||
).append(
|
||||
$('<td>').append($target.children())
|
||||
).append(
|
||||
$buttons
|
||||
);
|
||||
}
|
||||
|
||||
if ('push_list' in d) {
|
||||
|
@ -3384,6 +3425,35 @@ var UI = {
|
|||
);
|
||||
}
|
||||
else {
|
||||
var streams = [];
|
||||
var targets = [];
|
||||
var $select_streams = $('<select>').css('margin-left','0.5em').append(
|
||||
$('<option>').text('Any stream').val('')
|
||||
);
|
||||
var $select_targets = $('<select>').css('margin-left','0.5em').append(
|
||||
$('<option>').text('Any target').val('')
|
||||
);
|
||||
for (var i in d.push_list) {
|
||||
if (streams.indexOf(d.push_list[i][1]) == -1) {
|
||||
streams.push(d.push_list[i][1]);
|
||||
}
|
||||
if (targets.indexOf(d.push_list[i][2]) == -1) {
|
||||
targets.push(d.push_list[i][2]);
|
||||
}
|
||||
}
|
||||
streams.sort();
|
||||
targets.sort();
|
||||
for (var i in streams) {
|
||||
$select_streams.append(
|
||||
$('<option>').text(streams[i])
|
||||
);
|
||||
}
|
||||
for (var i in targets) {
|
||||
$select_targets.append(
|
||||
$('<option>').text(targets[i])
|
||||
);
|
||||
}
|
||||
|
||||
$c.append(
|
||||
$('<button>').text('Stop all pushes').click(function(){
|
||||
var push_list = [];
|
||||
|
@ -3393,32 +3463,7 @@ var UI = {
|
|||
if (push_list.length == 0) { return; }
|
||||
if (confirm('Are you sure you want to stop all pushes?')) {
|
||||
mist.send(function(d){
|
||||
function checkgone() {
|
||||
setTimeout(function(){
|
||||
mist.send(function(d){
|
||||
var gone = false;
|
||||
if (('push_list' in d) && (d.push_list) && (d.push_list.length)) {
|
||||
gone = true;
|
||||
for (var i in d.push_list) {
|
||||
if (push_list.indexOf(d.push_list[i][0]) == -1) {
|
||||
gone = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
gone = true;
|
||||
}
|
||||
if (gone) {
|
||||
UI.navto('Push');
|
||||
}
|
||||
else {
|
||||
checkgone();
|
||||
}
|
||||
},{push_list:1});
|
||||
},1e3);
|
||||
}
|
||||
checkgone();
|
||||
checkgone(push_list);
|
||||
},{push_stop:push_list});
|
||||
$push.find('tr:not(:first-child)').html(
|
||||
$('<td colspan=99>').append(
|
||||
|
@ -3429,6 +3474,52 @@ var UI = {
|
|||
}
|
||||
|
||||
})
|
||||
).append(
|
||||
$('<label>').css('margin-left','1em').append(
|
||||
$('<span>').text('Stop all pushes that match: ').css('font-size','0.9em')
|
||||
).append(
|
||||
$select_streams
|
||||
).append(
|
||||
$('<span>').css('margin-left','0.5em').text('and').css('font-size','0.9em')
|
||||
).append(
|
||||
$select_targets
|
||||
).append(
|
||||
$('<button>').css('margin-left','0.5em').text('Apply').click(function(){
|
||||
var s = $select_streams.val();
|
||||
var t = $select_targets.val();
|
||||
|
||||
if ((s == '') && (t == '')) { return alert('Looks like you want to stop all pushes. Maybe you should use that button?'); }
|
||||
var pushes = {};
|
||||
|
||||
for (var i in d.push_list) {
|
||||
if (((s == '') || (d.push_list[i][1] == s)) && ((t == '') || (d.push_list[i][2] == t))) {
|
||||
pushes[d.push_list[i][0]] = d.push_list[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (Object.keys(pushes).length == 0) {
|
||||
return alert('No matching pushes.');
|
||||
}
|
||||
|
||||
var msg = 'Are you sure you want to stop these pushes?'+"\n\n";
|
||||
for (var i in pushes) {
|
||||
msg += pushes[i][1]+' to '+pushes[i][2]+"\n";
|
||||
}
|
||||
if (confirm(msg)) {
|
||||
pushes = Object.keys(pushes);
|
||||
mist.send(function(d){
|
||||
checkgone(pushes);
|
||||
},{'push_stop':pushes});
|
||||
for (var i in pushes) {
|
||||
$push.find('tr[data-pushid='+pushes[i]+']').html(
|
||||
$('<td colspan=99>').html(
|
||||
$('<span>').addClass('red').text('Stopping..')
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
).append($push);
|
||||
}
|
||||
|
||||
|
@ -3440,7 +3531,7 @@ var UI = {
|
|||
if (!('capabilities' in mist.data)) {
|
||||
$main.append('Loading Mist capabilities..');
|
||||
mist.send(function(){
|
||||
UI.navto('Start Push');
|
||||
UI.navto('Start Push',other);
|
||||
},{capabilities:1});
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue