LSP: bugfix for saving on the overview page
This commit is contained in:
parent
b2f5676ca7
commit
6d34de94f5
2 changed files with 125 additions and 127 deletions
214
lsp/minified.js
214
lsp/minified.js
|
@ -1,10 +1,10 @@
|
||||||
var MD5=function(a){function c(a,c){var b,d,f,e,g;f=a&2147483648;e=c&2147483648;b=a&1073741824;d=c&1073741824;g=(a&1073741823)+(c&1073741823);return b&d?g^2147483648^f^e:b|d?g&1073741824?g^3221225472^f^e:g^1073741824^f^e:g^f^e}function d(a,b,d,f,e,g,i){a=c(a,c(c(b&d|~b&f,e),i));return c(a<<g|a>>>32-g,b)}function b(a,b,d,f,e,g,i){a=c(a,c(c(b&f|d&~f,e),i));return c(a<<g|a>>>32-g,b)}function e(a,b,d,f,e,g,i){a=c(a,c(c(b^d^f,e),i));return c(a<<g|a>>>32-g,b)}function g(a,b,d,f,e,g,i){a=c(a,c(c(d^(b|~f),
|
var MD5=function(a){function c(a,c){var b,d,f,g,i;f=a&2147483648;g=c&2147483648;b=a&1073741824;d=c&1073741824;i=(a&1073741823)+(c&1073741823);return b&d?i^2147483648^f^g:b|d?i&1073741824?i^3221225472^f^g:i^1073741824^f^g:i^f^g}function d(a,b,d,f,g,i,h){a=c(a,c(c(b&d|~b&f,g),h));return c(a<<i|a>>>32-i,b)}function b(a,b,d,f,g,i,h){a=c(a,c(c(b&f|d&~f,g),h));return c(a<<i|a>>>32-i,b)}function e(a,b,d,f,g,i,h){a=c(a,c(c(b^d^f,g),h));return c(a<<i|a>>>32-i,b)}function g(a,b,d,f,g,i,h){a=c(a,c(c(d^(b|~f),
|
||||||
e),i));return c(a<<g|a>>>32-g,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 h=[],q,p,m,t,f,i,j,k,h=a.replace(/\r\n/g,"\n"),a="";for(q=0;q<h.length;q++)p=h.charCodeAt(q),128>p?a+=String.fromCharCode(p):(127<p&&2048>p?a+=String.fromCharCode(p>>6|192):(a+=String.fromCharCode(p>>12|224),a+=String.fromCharCode(p>>6&63|128)),a+=String.fromCharCode(p&63|128));h=a;a=h.length;q=a+8;p=16*((q-q%64)/64+1);m=Array(p-1);for(f=t=0;f<a;)q=
|
g),h));return c(a<<i|a>>>32-i,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 h=[],q,p,m,u,f,i,j,k,h=a.replace(/\r\n/g,"\n"),a="";for(q=0;q<h.length;q++)p=h.charCodeAt(q),128>p?a+=String.fromCharCode(p):(127<p&&2048>p?a+=String.fromCharCode(p>>6|192):(a+=String.fromCharCode(p>>12|224),a+=String.fromCharCode(p>>6&63|128)),a+=String.fromCharCode(p&63|128));h=a;a=h.length;q=a+8;p=16*((q-q%64)/64+1);m=Array(p-1);for(f=u=0;f<a;)q=
|
||||||
(f-f%4)/4,t=8*(f%4),m[q]|=h.charCodeAt(f)<<t,f++;q=(f-f%4)/4;m[q]|=128<<8*(f%4);m[p-2]=a<<3;m[p-1]=a>>>29;h=m;f=1732584193;i=4023233417;j=2562383102;k=271733878;for(a=0;a<h.length;a+=16)q=f,p=i,m=j,t=k,f=d(f,i,j,k,h[a+0],7,3614090360),k=d(k,f,i,j,h[a+1],12,3905402710),j=d(j,k,f,i,h[a+2],17,606105819),i=d(i,j,k,f,h[a+3],22,3250441966),f=d(f,i,j,k,h[a+4],7,4118548399),k=d(k,f,i,j,h[a+5],12,1200080426),j=d(j,k,f,i,h[a+6],17,2821735955),i=d(i,j,k,f,h[a+7],22,4249261313),f=d(f,i,j,k,h[a+8],7,1770035416),
|
(f-f%4)/4,u=8*(f%4),m[q]|=h.charCodeAt(f)<<u,f++;q=(f-f%4)/4;m[q]|=128<<8*(f%4);m[p-2]=a<<3;m[p-1]=a>>>29;h=m;f=1732584193;i=4023233417;j=2562383102;k=271733878;for(a=0;a<h.length;a+=16)q=f,p=i,m=j,u=k,f=d(f,i,j,k,h[a+0],7,3614090360),k=d(k,f,i,j,h[a+1],12,3905402710),j=d(j,k,f,i,h[a+2],17,606105819),i=d(i,j,k,f,h[a+3],22,3250441966),f=d(f,i,j,k,h[a+4],7,4118548399),k=d(k,f,i,j,h[a+5],12,1200080426),j=d(j,k,f,i,h[a+6],17,2821735955),i=d(i,j,k,f,h[a+7],22,4249261313),f=d(f,i,j,k,h[a+8],7,1770035416),
|
||||||
k=d(k,f,i,j,h[a+9],12,2336552879),j=d(j,k,f,i,h[a+10],17,4294925233),i=d(i,j,k,f,h[a+11],22,2304563134),f=d(f,i,j,k,h[a+12],7,1804603682),k=d(k,f,i,j,h[a+13],12,4254626195),j=d(j,k,f,i,h[a+14],17,2792965006),i=d(i,j,k,f,h[a+15],22,1236535329),f=b(f,i,j,k,h[a+1],5,4129170786),k=b(k,f,i,j,h[a+6],9,3225465664),j=b(j,k,f,i,h[a+11],14,643717713),i=b(i,j,k,f,h[a+0],20,3921069994),f=b(f,i,j,k,h[a+5],5,3593408605),k=b(k,f,i,j,h[a+10],9,38016083),j=b(j,k,f,i,h[a+15],14,3634488961),i=b(i,j,k,f,h[a+4],20,3889429448),
|
k=d(k,f,i,j,h[a+9],12,2336552879),j=d(j,k,f,i,h[a+10],17,4294925233),i=d(i,j,k,f,h[a+11],22,2304563134),f=d(f,i,j,k,h[a+12],7,1804603682),k=d(k,f,i,j,h[a+13],12,4254626195),j=d(j,k,f,i,h[a+14],17,2792965006),i=d(i,j,k,f,h[a+15],22,1236535329),f=b(f,i,j,k,h[a+1],5,4129170786),k=b(k,f,i,j,h[a+6],9,3225465664),j=b(j,k,f,i,h[a+11],14,643717713),i=b(i,j,k,f,h[a+0],20,3921069994),f=b(f,i,j,k,h[a+5],5,3593408605),k=b(k,f,i,j,h[a+10],9,38016083),j=b(j,k,f,i,h[a+15],14,3634488961),i=b(i,j,k,f,h[a+4],20,3889429448),
|
||||||
f=b(f,i,j,k,h[a+9],5,568446438),k=b(k,f,i,j,h[a+14],9,3275163606),j=b(j,k,f,i,h[a+3],14,4107603335),i=b(i,j,k,f,h[a+8],20,1163531501),f=b(f,i,j,k,h[a+13],5,2850285829),k=b(k,f,i,j,h[a+2],9,4243563512),j=b(j,k,f,i,h[a+7],14,1735328473),i=b(i,j,k,f,h[a+12],20,2368359562),f=e(f,i,j,k,h[a+5],4,4294588738),k=e(k,f,i,j,h[a+8],11,2272392833),j=e(j,k,f,i,h[a+11],16,1839030562),i=e(i,j,k,f,h[a+14],23,4259657740),f=e(f,i,j,k,h[a+1],4,2763975236),k=e(k,f,i,j,h[a+4],11,1272893353),j=e(j,k,f,i,h[a+7],16,4139469664),
|
f=b(f,i,j,k,h[a+9],5,568446438),k=b(k,f,i,j,h[a+14],9,3275163606),j=b(j,k,f,i,h[a+3],14,4107603335),i=b(i,j,k,f,h[a+8],20,1163531501),f=b(f,i,j,k,h[a+13],5,2850285829),k=b(k,f,i,j,h[a+2],9,4243563512),j=b(j,k,f,i,h[a+7],14,1735328473),i=b(i,j,k,f,h[a+12],20,2368359562),f=e(f,i,j,k,h[a+5],4,4294588738),k=e(k,f,i,j,h[a+8],11,2272392833),j=e(j,k,f,i,h[a+11],16,1839030562),i=e(i,j,k,f,h[a+14],23,4259657740),f=e(f,i,j,k,h[a+1],4,2763975236),k=e(k,f,i,j,h[a+4],11,1272893353),j=e(j,k,f,i,h[a+7],16,4139469664),
|
||||||
i=e(i,j,k,f,h[a+10],23,3200236656),f=e(f,i,j,k,h[a+13],4,681279174),k=e(k,f,i,j,h[a+0],11,3936430074),j=e(j,k,f,i,h[a+3],16,3572445317),i=e(i,j,k,f,h[a+6],23,76029189),f=e(f,i,j,k,h[a+9],4,3654602809),k=e(k,f,i,j,h[a+12],11,3873151461),j=e(j,k,f,i,h[a+15],16,530742520),i=e(i,j,k,f,h[a+2],23,3299628645),f=g(f,i,j,k,h[a+0],6,4096336452),k=g(k,f,i,j,h[a+7],10,1126891415),j=g(j,k,f,i,h[a+14],15,2878612391),i=g(i,j,k,f,h[a+5],21,4237533241),f=g(f,i,j,k,h[a+12],6,1700485571),k=g(k,f,i,j,h[a+3],10,2399980690),
|
i=e(i,j,k,f,h[a+10],23,3200236656),f=e(f,i,j,k,h[a+13],4,681279174),k=e(k,f,i,j,h[a+0],11,3936430074),j=e(j,k,f,i,h[a+3],16,3572445317),i=e(i,j,k,f,h[a+6],23,76029189),f=e(f,i,j,k,h[a+9],4,3654602809),k=e(k,f,i,j,h[a+12],11,3873151461),j=e(j,k,f,i,h[a+15],16,530742520),i=e(i,j,k,f,h[a+2],23,3299628645),f=g(f,i,j,k,h[a+0],6,4096336452),k=g(k,f,i,j,h[a+7],10,1126891415),j=g(j,k,f,i,h[a+14],15,2878612391),i=g(i,j,k,f,h[a+5],21,4237533241),f=g(f,i,j,k,h[a+12],6,1700485571),k=g(k,f,i,j,h[a+3],10,2399980690),
|
||||||
j=g(j,k,f,i,h[a+10],15,4293915773),i=g(i,j,k,f,h[a+1],21,2240044497),f=g(f,i,j,k,h[a+8],6,1873313359),k=g(k,f,i,j,h[a+15],10,4264355552),j=g(j,k,f,i,h[a+6],15,2734768916),i=g(i,j,k,f,h[a+13],21,1309151649),f=g(f,i,j,k,h[a+4],6,4149444226),k=g(k,f,i,j,h[a+11],10,3174756917),j=g(j,k,f,i,h[a+2],15,718787259),i=g(i,j,k,f,h[a+9],21,3951481745),f=c(f,q),i=c(i,p),j=c(j,m),k=c(k,t);return(l(f)+l(i)+l(j)+l(k)).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==q)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=
|
j=g(j,k,f,i,h[a+10],15,4293915773),i=g(i,j,k,f,h[a+1],21,2240044497),f=g(f,i,j,k,h[a+8],6,1873313359),k=g(k,f,i,j,h[a+15],10,4264355552),j=g(j,k,f,i,h[a+6],15,2734768916),i=g(i,j,k,f,h[a+13],21,1309151649),f=g(f,i,j,k,h[a+4],6,4149444226),k=g(k,f,i,j,h[a+11],10,3174756917),j=g(j,k,f,i,h[a+2],15,718787259),i=g(i,j,k,f,h[a+9],21,3951481745),f=c(f,q),i=c(i,p),j=c(j,m),k=c(k,u);return(l(f)+l(i)+l(j)+l(k)).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==q)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 d=a(this),b=d.closest("table"),e=b.children("tbody"),g=e.children("tr"),l=d.attr("data-sort-type");if(l){var h=!0;d.hasClass("sorting-asc")&&(h=!1);var q=0;d.prevAll().each(function(){var c=a(this).attr("colspan");q+=c?Number(c):1});g.sort(function(a,b){var d=h?1:-1,a=c(a),b=c(b);return a>b?1*d:a<b?-1*d:0});e.append(g);b.find("thead th").removeClass("sorting-asc").removeClass("sorting-desc");d.addClass(h?"sorting-asc":"sorting-desc")}}})(jQuery);$(function(){UI.elements={menu:$("nav > .menu"),main:$("main"),header:$("header"),connection:{status:$("#connection"),user_and_host:$("#user_and_host"),msg:$("#message")}};UI.buildMenu();UI.stored.getOpts();try{if("mistLogin"in sessionStorage){var a=JSON.parse(sessionStorage.mistLogin);mist.user.name=a.name;mist.user.password=a.password;mist.user.host=a.host}}catch(c){}location.hash&&(a=decodeURIComponent(location.hash).substring(1).split("@")[0].split("&"),mist.user.name=a[0],a[1]&&(mist.user.host=
|
parseInt(Number(c));break;case "float":c=Number(c)}return c}var d=a(this),b=d.closest("table"),e=b.children("tbody"),g=e.children("tr"),l=d.attr("data-sort-type");if(l){var h=!0;d.hasClass("sorting-asc")&&(h=!1);var q=0;d.prevAll().each(function(){var c=a(this).attr("colspan");q+=c?Number(c):1});g.sort(function(a,b){var d=h?1:-1,a=c(a),b=c(b);return a>b?1*d:a<b?-1*d:0});e.append(g);b.find("thead th").removeClass("sorting-asc").removeClass("sorting-desc");d.addClass(h?"sorting-asc":"sorting-desc")}}})(jQuery);$(function(){UI.elements={menu:$("nav > .menu"),main:$("main"),header:$("header"),connection:{status:$("#connection"),user_and_host:$("#user_and_host"),msg:$("#message")}};UI.buildMenu();UI.stored.getOpts();try{if("mistLogin"in sessionStorage){var a=JSON.parse(sessionStorage.mistLogin);mist.user.name=a.name;mist.user.password=a.password;mist.user.host=a.host}}catch(c){}location.hash&&(a=decodeURIComponent(location.hash).substring(1).split("@")[0].split("&"),mist.user.name=a[0],a[1]&&(mist.user.host=
|
||||||
a[1]));mist.send(function(){$(window).trigger("hashchange")},{},{timeout:5,hide:!0});var d=0;$("body > div.filler").on("scroll",function(){var a=$(this).scrollLeft();a!=d&&UI.elements.header.css("margin-right",-1*a+"px");d=a})});$(window).on("hashchange",function(){var a=decodeURIComponent(location.hash).substring(1).split("@");a[1]||(a[1]="");a=a[1].split("&");""==a[0]&&(a[0]="Overview");UI.showTab(a[0],a[1])});
|
a[1]));mist.send(function(){$(window).trigger("hashchange")},{},{timeout:5,hide:!0});var d=0;$("body > div.filler").on("scroll",function(){var a=$(this).scrollLeft();a!=d&&UI.elements.header.css("margin-right",-1*a+"px");d=a})});$(window).on("hashchange",function(){var a=decodeURIComponent(location.hash).substring(1).split("@");a[1]||(a[1]="");a=a[1].split("&");""==a[0]&&(a[0]="Overview");UI.showTab(a[0],a[1])});
|
||||||
var otherhost={host:!1,https:!1},UI={debug:!1,elements:{},stored:{getOpts:function(){var a=localStorage.stored;a&&(a=JSON.parse(a));$.extend(!0,this.vars,a);return this.vars},saveOpt:function(a,c){this.vars[a]=c;localStorage.stored=JSON.stringify(this.vars);return this.vars},vars:{helpme:!0}},interval:{clear:function(){"undefined"!=typeof this.opts&&(clearInterval(this.opts.id),delete this.opts)},set:function(a,c){this.opts&&log("[interval]","Set called on interval, but an interval is already active.");
|
var otherhost={host:!1,https:!1},UI={debug:!1,elements:{},stored:{getOpts:function(){var a=localStorage.stored;a&&(a=JSON.parse(a));$.extend(!0,this.vars,a);return this.vars},saveOpt:function(a,c){this.vars[a]=c;localStorage.stored=JSON.stringify(this.vars);return this.vars},vars:{helpme:!0}},interval:{clear:function(){"undefined"!=typeof this.opts&&(clearInterval(this.opts.id),delete this.opts)},set:function(a,c){this.opts&&log("[interval]","Set called on interval, but an interval is already active.");
|
||||||
|
@ -34,28 +34,28 @@ p.append(m),("LTSonly"in b&&!mist.data.LTS||b.readonly)&&m.prop("disabled",!0),b
|
||||||
[b.checklist[d],b.checklist[d]]),$checklist.append($("<label>").text(b.checklist[d][1]).prepend($("<input>").attr("type","checkbox").attr("name",b.checklist[d][0])));break;case "DOMfield":e=b.DOMfield;break;default:e=$("<input>").attr("type","text")}e.addClass("field").data("opts",b);"pointer"in b&&e.attr("name",b.pointer.index);h.append(e);if("classes"in b)for(g in b.classes)e.addClass(b.classes[g]);"placeholder"in b&&e.attr("placeholder",b.placeholder);"default"in b&&e.attr("placeholder",b["default"]);
|
[b.checklist[d],b.checklist[d]]),$checklist.append($("<label>").text(b.checklist[d][1]).prepend($("<input>").attr("type","checkbox").attr("name",b.checklist[d][0])));break;case "DOMfield":e=b.DOMfield;break;default:e=$("<input>").attr("type","text")}e.addClass("field").data("opts",b);"pointer"in b&&e.attr("name",b.pointer.index);h.append(e);if("classes"in b)for(g in b.classes)e.addClass(b.classes[g]);"placeholder"in b&&e.attr("placeholder",b.placeholder);"default"in b&&e.attr("placeholder",b["default"]);
|
||||||
"unit"in b&&h.append($("<span>").addClass("unit").html(b.unit));"readonly"in b&&(e.attr("readonly","readonly"),e.click(function(){$(this).select()}));"qrcode"in b&&h.append($("<span>").addClass("unit").html($("<button>").text("QR").on("keydown",function(a){a.stopPropagation()}).click(function(){var a=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,
|
"unit"in b&&h.append($("<span>").addClass("unit").html(b.unit));"readonly"in b&&(e.attr("readonly","readonly"),e.click(function(){$(this).select()}));"qrcode"in b&&h.append($("<span>").addClass("unit").html($("<button>").text("QR").on("keydown",function(a){a.stopPropagation()}).click(function(){var a=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())})})));"clipboard"in b&&document.queryCommandSupported("copy")&&h.append($("<span>").addClass("unit").html($("<button>").text("Copy").on("keydown",function(a){a.stopPropagation()}).click(function(){var a=String($(this).closest(".field_container").find(".field").getval()),c=document.createElement("textarea");c.value=a;document.body.appendChild(c);c.select();var b=false;try{b=document.execCommand("copy")}catch(d){}if(b){$(this).text("Copied to clipboard!");document.body.removeChild(c);
|
size:Math.min(c.width(),c.height())})})));"clipboard"in b&&document.queryCommandSupported("copy")&&h.append($("<span>").addClass("unit").html($("<button>").text("Copy").on("keydown",function(a){a.stopPropagation()}).click(function(){var a=String($(this).closest(".field_container").find(".field").getval()),c=document.createElement("textarea");c.value=a;document.body.appendChild(c);c.select();var b=false;try{b=document.execCommand("copy")}catch(d){}if(b){$(this).text("Copied to clipboard!");document.body.removeChild(c);
|
||||||
var g=$(this);setTimeout(function(){g.text("Copy")},5E3)}else{document.body.removeChild(c);alert("Failed to copy:\n"+a)}})));"rows"in b&&e.attr("rows",b.rows);"LTSonly"in b&&!mist.data.LTS&&(h.addClass("LTSonly"),e.prop("disabled",!0));switch(b.type){case "browse":m=$("<div>").addClass("grouper").append(l);c.append(m);m=$("<button>").text("Browse").on("keydown",function(a){a.stopPropagation()});h.append(m);m.click(function(){function a(c){l.text("Loading..");mist.send(function(a){h.text(a.browse.path[0]);
|
var g=$(this);setTimeout(function(){g.text("Copy")},5E3)}else{document.body.removeChild(c);alert("Failed to copy:\n"+a)}})));"rows"in b&&e.attr("rows",b.rows);"LTSonly"in b&&!mist.data.LTS&&(h.addClass("LTSonly"),e.prop("disabled",!0));switch(b.type){case "browse":m=$("<div>").addClass("grouper").append(l);c.append(m);m=$("<button>").text("Browse").on("keydown",function(a){a.stopPropagation()});h.append(m);m.click(function(){function a(c){l.text("Loading..");mist.send(function(a){e.text(a.browse.path[0]);
|
||||||
mist.data.LTS&&d.setval(a.browse.path[0]+"/");l.html(m.clone(true).text("..").attr("title","Folder up"));if(a.browse.subdirectories){a.browse.subdirectories.sort();for(var c in a.browse.subdirectories){var e=a.browse.subdirectories[c];l.append(m.clone(true).attr("title",h.text()+q+e).text(e))}}if(a.browse.files){a.browse.files.sort();for(c in a.browse.files){var e=a.browse.files[c],f=h.text()+q+e,e=$("<a>").text(e).addClass("file").attr("title",f);l.append(e);if(p){var t=true,z;for(z in p)if(typeof p[z]!=
|
mist.data.LTS&&d.setval(a.browse.path[0]+"/");l.html(m.clone(true).text("..").attr("title","Folder up"));if(a.browse.subdirectories){a.browse.subdirectories.sort();for(var c in a.browse.subdirectories){var f=a.browse.subdirectories[c];l.append(m.clone(true).attr("title",e.text()+q+f).text(f))}}if(a.browse.files){a.browse.files.sort();for(c in a.browse.files){var f=a.browse.files[c],h=e.text()+q+f,f=$("<a>").text(f).addClass("file").attr("title",h);l.append(f);if(p){var u=true,z;for(z in p)if(typeof p[z]!=
|
||||||
"undefined"&&mist.inputMatch(p[z],f)){t=false;break}t&&e.hide()}e.click(function(){var a=$(this).attr("title");d.setval(a).removeAttr("readonly").css("opacity",1);g.show();b.remove()})}}},{browse:c})}var c=$(this).closest(".grouper"),b=$("<div>").addClass("browse_container"),d=c.find(".field").attr("readonly","readonly").css("opacity",0.5),g=$(this),e=$("<button>").text("Stop browsing").click(function(){g.show();b.remove();d.removeAttr("readonly").css("opacity",1)}),h=$("<span>").addClass("field"),
|
"undefined"&&mist.inputMatch(p[z],h)){u=false;break}u&&f.hide()}f.click(function(){var a=$(this).attr("title");d.setval(a).removeAttr("readonly").css("opacity",1);g.show();b.remove()})}}},{browse:c})}var c=$(this).closest(".grouper"),b=$("<div>").addClass("browse_container"),d=c.find(".field").attr("readonly","readonly").css("opacity",0.5),g=$(this),h=$("<button>").text("Stop browsing").click(function(){g.show();b.remove();d.removeAttr("readonly").css("opacity",1)}),e=$("<span>").addClass("field"),
|
||||||
l=$("<div>").addClass("browse_contents"),m=$("<a>").addClass("folder"),p=d.data("filetypes");c.append(b);b.append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Current folder:")).append($("<span>").addClass("field_container").append(h).append(e))).append(l);var q="/";mist.data.config.version.indexOf("indows")>-1&&(q="\\");m.click(function(){var c=h.text()+q+$(this).text();a(c)});c=d.getval();e=c.split("://");e.length>1&&(c=e[0]=="file"?e[1]:"");c=c.split(q);c.pop();
|
l=$("<div>").addClass("browse_contents"),m=$("<a>").addClass("folder"),p=d.data("filetypes");c.append(b);b.append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Current folder:")).append($("<span>").addClass("field_container").append(e).append(h))).append(l);var q="/";mist.data.config.version.indexOf("indows")>-1&&(q="\\");m.click(function(){var c=e.text()+q+$(this).text();a(c)});c=d.getval();h=c.split("://");h.length>1&&(c=h[0]=="file"?h[1]:"");c=c.split(q);c.pop();
|
||||||
c=c.join(q);g.hide();a(c)});break;case "geolimited":case "hostlimited":m={field:e};m.blackwhite=$("<select>").append($("<option>").val("-").text("Blacklist")).append($("<option>").val("+").text("Whitelist"));m.values=$("<span>").addClass("limit_value_list");switch(b.type){case "geolimited":m.prototype=$("<select>").append($("<option>").val("").text("[Select a country]"));for(d in UI.countrylist)m.prototype.append($("<option>").val(d).html(UI.countrylist[d]));break;case "hostlimited":m.prototype=$("<input>").attr("type",
|
c=c.join(q);g.hide();a(c)});break;case "geolimited":case "hostlimited":m={field:e};m.blackwhite=$("<select>").append($("<option>").val("-").text("Blacklist")).append($("<option>").val("+").text("Whitelist"));m.values=$("<span>").addClass("limit_value_list");switch(b.type){case "geolimited":m.prototype=$("<select>").append($("<option>").val("").text("[Select a country]"));for(d in UI.countrylist)m.prototype.append($("<option>").val(d).html(UI.countrylist[d]));break;case "hostlimited":m.prototype=$("<input>").attr("type",
|
||||||
"text").attr("placeholder","type a host")}m.prototype.on("change keyup",function(){$(this).closest(".field_container").data("subUI").blackwhite.trigger("change")});m.blackwhite.change(function(){var a=$(this).closest(".field_container").data("subUI"),c=[],b=false;a.values.children().each(function(){b=$(this).val();b!=""?c.push(b):$(this).remove()});a.values.append(a.prototype.clone(true));c.length>0?a.field.val($(this).val()+c.join(" ")):a.field.val("");a.field.trigger("change")});"LTSonly"in b&&
|
"text").attr("placeholder","type a host")}m.prototype.on("change keyup",function(){$(this).closest(".field_container").data("subUI").blackwhite.trigger("change")});m.blackwhite.change(function(){var a=$(this).closest(".field_container").data("subUI"),c=[],b=false;a.values.children().each(function(){b=$(this).val();b!=""?c.push(b):$(this).remove()});a.values.append(a.prototype.clone(true));c.length>0?a.field.val($(this).val()+c.join(" ")):a.field.val("");a.field.trigger("change")});"LTSonly"in b&&
|
||||||
!mist.data.LTS&&(m.blackwhite.prop("disabled",!0),m.prototype.prop("disabled",!0));m.values.append(m.prototype.clone(!0));h.data("subUI",m).addClass("limit_list").append(m.blackwhite).append(m.values)}"pointer"in b&&(e.data("pointer",b.pointer).addClass("isSetting"),b.pointer.main&&(m=b.pointer.main[b.pointer.index],"undefined"!=m&&e.setval(m)));"value"in b&&e.setval(b.value);if("datalist"in b)for(d in m="datalist_"+d+MD5(e[0].outerHTML),e.attr("list",m),m=$("<datalist>").attr("id",m),h.append(m),
|
!mist.data.LTS&&(m.blackwhite.prop("disabled",!0),m.prototype.prop("disabled",!0));m.values.append(m.prototype.clone(!0));h.data("subUI",m).addClass("limit_list").append(m.blackwhite).append(m.values)}"pointer"in b&&(e.data("pointer",b.pointer).addClass("isSetting"),b.pointer.main&&(m=b.pointer.main[b.pointer.index],"undefined"!=m&&e.setval(m)));"value"in b&&e.setval(b.value);if("datalist"in b)for(d in m="datalist_"+d+MD5(e[0].outerHTML),e.attr("list",m),m=$("<datalist>").attr("id",m),h.append(m),
|
||||||
b.datalist)m.append($("<option>").val(b.datalist[d]));h=$("<span>").addClass("help_container");l.append(h);"help"in b&&(h.append($("<span>").addClass("ih_balloon").html(b.help)),e.on("focus mouseover",function(){$(this).closest("label").addClass("active")}).on("blur mouseout",function(){$(this).closest("label").removeClass("active")}));if("validate"in b){l=[];for(g in b.validate){m=b.validate[g];if("function"!=typeof m)switch(m){case "required":m=function(a){return a==""||a==null?{msg:"This is a required field.",
|
b.datalist)m.append($("<option>").val(b.datalist[d]));h=$("<span>").addClass("help_container");l.append(h);"help"in b&&(h.append($("<span>").addClass("ih_balloon").html(b.help)),e.on("focus mouseover",function(){$(this).closest("label").addClass("active")}).on("blur mouseout",function(){$(this).closest("label").removeClass("active")}));if("validate"in b){l=[];for(g in b.validate){m=b.validate[g];if("function"!=typeof m)switch(m){case "required":m=function(a){return a==""||a==null?{msg:"This is a required field.",
|
||||||
classes:["red"]}:false};break;case "int":m=function(a,c){var b=$(c).data("opts");if(!$(c)[0].validity.valid){var d=[];"min"in b&&d.push(" greater than or equal to "+b.min);"max"in b&&d.push(" smaller than or equal to "+b.max);return{msg:"Please enter an integer"+d.join(" and")+".",classes:["red"]}}if(parseInt(Number(a))!=a)return{msg:"Please enter an integer.",classes:["red"]}};break;case "streamname":m=function(a,c){if(!isNaN(a.charAt(0)))return{msg:"The first character may not be a number.",classes:["red"]};
|
classes:["red"]}:false};break;case "int":m=function(a,c){var b=$(c).data("opts");if(!$(c)[0].validity.valid){var d=[];"min"in b&&d.push(" greater than or equal to "+b.min);"max"in b&&d.push(" smaller than or equal to "+b.max);return{msg:"Please enter an integer"+d.join(" and")+".",classes:["red"]}}if(parseInt(Number(a))!=a)return{msg:"Please enter an integer.",classes:["red"]}};break;case "streamname":m=function(a,c){if(!isNaN(a.charAt(0)))return{msg:"The first character may not be a number.",classes:["red"]};
|
||||||
if(a.toLowerCase()!=a)return{msg:"Uppercase letters are not allowed.",classes:["red"]};if(a.replace(/[^\da-z_]/g,"")!=a)return{msg:"Special characters (except for underscores) are not allowed.",classes:["red"]};if("streams"in mist.data&&a in mist.data.streams&&$(c).data("pointer").main.name!=a)return{msg:"This streamname already exists.<br>If you want to edit an existing stream, please click edit on the the streams tab.",classes:["red"]}};break;default:m=function(){}}l.push(m)}e.data("validate_functions",
|
if(a.toLowerCase()!=a)return{msg:"Uppercase letters are not allowed.",classes:["red"]};if(a.replace(/[^\da-z_]/g,"")!=a)return{msg:"Special characters (except for underscores) are not allowed.",classes:["red"]};if("streams"in mist.data&&a in mist.data.streams&&$(c).data("pointer").main.name!=a)return{msg:"This streamname already exists.<br>If you want to edit an existing stream, please click edit on the the streams tab.",classes:["red"]}};break;default:m=function(){}}l.push(m)}e.data("validate_functions",
|
||||||
l).data("help_container",h).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 h=d[g](b,a);if(h){$err=$("<span>").addClass("err_balloon").html(h.msg);for(var l in h.classes)$err.addClass(h.classes[l]);e.prepend($err);c&&$(a).focus();return true}}return false}).addClass("hasValidate").on("change keyup",function(){$(this).data("validate")($(this))});""!=e.getval()&&e.trigger("change")}"function"in
|
l).data("help_container",h).data("validate",function(a,c){var b=$(a).getval(),d=$(a).data("validate_functions"),g=$(a).data("help_container");g.find(".err_balloon").remove();for(var h in d){var e=d[h](b,a);if(e){$err=$("<span>").addClass("err_balloon").html(e.msg);for(var l in e.classes)$err.addClass(e.classes[l]);g.prepend($err);c&&$(a).focus();return true}}return false}).addClass("hasValidate").on("change keyup",function(){$(this).data("validate")($(this))});""!=e.getval()&&e.trigger("change")}"function"in
|
||||||
b&&(e.on("change keyup",b["function"]),e.trigger("change"))}}c.on("keydown",function(a){switch(a.which){case 13:$(this).find("button.save").first().trigger("click");break;case 27:$(this).find("button.cancel").first().trigger("click")}});return c},buildVheaderTable:function(a){var c=$("<table>").css("margin","0.2em"),d=$("<tr>").addClass("header").append($("<td>").addClass("vheader").attr("rowspan",a.labels.length+1).append($("<span>").text(a.vheader))),b=[];d.append($("<td>"));for(var e in a.labels)b.push($("<tr>").append($("<td>").html(""==
|
b&&(e.on("change keyup",b["function"]),e.trigger("change"))}}c.on("keydown",function(a){switch(a.which){case 13:$(this).find("button.save").first().trigger("click");break;case 27:$(this).find("button.cancel").first().trigger("click")}});return c},buildVheaderTable:function(a){var c=$("<table>").css("margin","0.2em"),d=$("<tr>").addClass("header").append($("<td>").addClass("vheader").attr("rowspan",a.labels.length+1).append($("<span>").text(a.vheader))),b=[];d.append($("<td>"));for(var e in a.labels)b.push($("<tr>").append($("<td>").html(""==
|
||||||
a.labels[e]?" ":a.labels[e]+":")));for(var g in a.content)for(e in d.append($("<td>").html(a.content[g].header)),a.content[g].body)b[e].append($("<td>").html(a.content[g].body[e]));c.append($("<tbody>").append(d).append(b));return c},plot:{addGraph:function(a,c){var d={id:a.id,xaxis:a.xaxis,datasets:[],elements:{cont:$("<div>").addClass("graph"),plot:$("<div>").addClass("plot"),legend:$("<div>").addClass("legend").attr("draggable","true")}};UI.draggable(d.elements.legend);d.elements.cont.append(d.elements.plot).append(d.elements.legend);
|
a.labels[e]?" ":a.labels[e]+":")));for(var g in a.content)for(e in d.append($("<td>").html(a.content[g].header)),a.content[g].body)b[e].append($("<td>").html(a.content[g].body[e]));c.append($("<tbody>").append(d).append(b));return c},plot:{addGraph:function(a,c){var d={id:a.id,xaxis:a.xaxis,datasets:[],elements:{cont:$("<div>").addClass("graph"),plot:$("<div>").addClass("plot"),legend:$("<div>").addClass("legend").attr("draggable","true")}};UI.draggable(d.elements.legend);d.elements.cont.append(d.elements.plot).append(d.elements.legend);
|
||||||
c.append(d.elements.cont);return d},go:function(a){if(!(1>Object.keys(a).length)){var c={totals:[],clients:[]},d;for(d in a)for(var b in a[d].datasets){var e=a[d].datasets[b];switch(e.datatype){case "clients":case "upbps":case "downbps":switch(e.origin[0]){case "total":c.totals.push({fields:[e.datatype],end:-15});break;case "stream":c.totals.push({fields:[e.datatype],streams:[e.origin[1]],end:-15});break;case "protocol":c.totals.push({fields:[e.datatype],protocols:[e.origin[1]],end:-15})}break;case "cpuload":case "memload":c.capabilities=
|
c.append(d.elements.cont);return d},go:function(a){if(!(1>Object.keys(a).length)){var c={totals:[],clients:[]},d;for(d in a)for(var b in a[d].datasets){var e=a[d].datasets[b];switch(e.datatype){case "clients":case "upbps":case "downbps":switch(e.origin[0]){case "total":c.totals.push({fields:[e.datatype],end:-15});break;case "stream":c.totals.push({fields:[e.datatype],streams:[e.origin[1]],end:-15});break;case "protocol":c.totals.push({fields:[e.datatype],protocols:[e.origin[1]],end:-15})}break;case "cpuload":case "memload":c.capabilities=
|
||||||
{}}}0==c.totals.length&&delete c.totals;0==c.clients.length&&delete c.clients;mist.send(function(){for(var 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=[],p;for(p in b.datasets){var m=b.datasets[p];m.display&&(m.getdata(),m.yaxistype in b.yaxes||(d.push(UI.plot.yaxes[m.yaxistype]),b.yaxes[m.yaxistype]=d.length),m.yaxis=b.yaxes[m.yaxistype],e.push(m))}d[0]&&(d[0].color=0);b.plot=$.plot(b.elements.plot,
|
{}}}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=[],p;for(p in b.datasets){var m=b.datasets[p];m.display&&(m.getdata(),m.yaxistype in b.yaxes||(d.push(UI.plot.yaxes[m.yaxistype]),b.yaxes[m.yaxistype]=d.length),m.yaxis=b.yaxes[m.yaxistype],e.push(m))}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=
|
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 t=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=
|
$(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 u=function(a){var c=b.elements.legend.find(".value"),d=1;if(typeof a=="undefined")c.eq(0).html("Latest:");else{var g=b.plot.getXAxes()[0],a=Math.min(g.max,a),a=Math.max(g.min,a);c.eq(0).html(UI.format.time(a/1E3))}for(var f in b.datasets){var e=
|
||||||
" ";if(b.datasets[g].display){var e=UI.plot.yaxes[b.datasets[g].yaxistype].tickFormatter,h=b.datasets[g].data;if(a)for(var m in h){if(h[m][0]==a){f=e(h[m][1]);break}if(h[m][0]>a){if(m!=0){f=h[m];h=h[m-1];f=e(f[1]+(a-f[0])*(h[1]-f[1])/(h[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(p in b.datasets)e=$("<input>").attr("type","checkbox").data("index",p).data("graph",b).click(function(){var a=$(this).data("graph");$(this).is(":checked")?
|
" ";if(b.datasets[f].display){var g=UI.plot.yaxes[b.datasets[f].yaxistype].tickFormatter,h=b.datasets[f].data;if(a)for(var m in h){if(h[m][0]==a){e=g(h[m][1]);break}if(h[m][0]>a){if(m!=0){e=h[m];h=h[m-1];e=g(e[1]+(a-e[0])*(h[1]-e[1])/(h[0]-e[0]))}break}}else e=g(b.datasets[f].data[b.datasets[f].data.length-1][1])}c.eq(d).html(e);d++}};b.plot.getOptions();for(p in b.datasets)e=$("<input>").attr("type","checkbox").data("index",p).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[p].display&&e.attr("checked","checked"),d.append($("<tr>").html($("<td>").html($("<label>").html(e).append($("<div>").addClass("series-color").css("background-color",b.datasets[p].color)).append(b.datasets[p].label))).append($("<td>").css("padding-right","2em").css("text-align","right").html($("<span>").addClass("value")).append($("<button>").text("X").addClass("close").data("index",
|
a.datasets[$(this).data("index")].display=true:a.datasets[$(this).data("index")].display=false;var c={};c[a.id]=a;UI.plot.go(c)}),b.datasets[p].display&&e.attr("checked","checked"),d.append($("<tr>").html($("<td>").html($("<label>").html(e).append($("<div>").addClass("series-color").css("background-color",b.datasets[p].color)).append(b.datasets[p].label))).append($("<td>").css("padding-right","2em").css("text-align","right").html($("<span>").addClass("value")).append($("<button>").text("X").addClass("close").data("index",
|
||||||
p).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)}}}))));t();var f=!1;b.elements.plot.on("plothover",function(a,c,b){if(c.x!=
|
p).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)}}}))));u();var f=!1;b.elements.plot.on("plothover",function(a,c,b){if(c.x!=
|
||||||
f){t(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",
|
f){u(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(){t()})}}},c)}},save:function(a){var c={id:a.id,xaxis:a.xaxis,datasets:[]},d;for(d in a.datasets)c.datasets.push({origin:a.datasets[d].origin,datatype:a.datasets[d].datatype});a=mist.stored.get().graphs||{};a[c.id]=c;mist.stored.set("graphs",a)},del:function(a){var c=mist.stored.get().graphs||{};delete c[a];mist.stored.set("graphs",c)},datatype:{getOptions:function(a){var c=$.extend(!0,{},UI.plot.datatype.templates.general),d=$.extend(!0,{},UI.plot.datatype.templates[a.datatype]),a=$.extend(!0,
|
function(){u()})}}},c)}},save:function(a){var c={id:a.id,xaxis:a.xaxis,datasets:[]},d;for(d in a.datasets)c.datasets.push({origin:a.datasets[d].origin,datatype:a.datasets[d].datatype});a=mist.stored.get().graphs||{};a[c.id]=c;mist.stored.set("graphs",a)},del:function(a){var c=mist.stored.get().graphs||{};delete c[a];mist.stored.set("graphs",c)},datatype:{getOptions:function(a){var c=$.extend(!0,{},UI.plot.datatype.templates.general),d=$.extend(!0,{},UI.plot.datatype.templates[a.datatype]),a=$.extend(!0,
|
||||||
d,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)d=a.basecolor[b],d+=50*(0.5-Math.random()),d=Math.round(d),d=Math.min(255,Math.max(0,d)),c.push(d);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=
|
d,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)d=a.basecolor[b],d+=50*(0.5-Math.random()),d=Math.round(d),d=Math.min(255,Math.max(0,d)),c.push(d);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",
|
mist.data.totals["stream"==this.origin[0]?this.origin[1]:"all_streams"]["protocol"==this.origin[0]?this.origin[1]:"all_protocols"][this.datatype];return this.data=a}},cpuload:{label:"CPU use",yaxistype:"percentage",basecolor:[237,194,64],cores:1,getdata:function(){var a=!1,c;for(c in this.data)this.data[c][0]<1E3*(mist.data.config.time-600)&&(a=c);!1!==a&&this.data.splice(0,Number(a)+1);this.data.push([1E3*mist.data.config.time,mist.data.capabilities.cpu_use/10]);return this.data}},memload:{label:"Memory load",
|
||||||
yaxistype:"percentage",basecolor:[175,216,248],getdata:function(){var a=!1,c;for(c in this.data)this.data[c][0]<1E3*(mist.data.config.time-600)&&(a=c);!1!==a&&this.data.splice(0,Number(a)+1);this.data.push([1E3*mist.data.config.time,mist.data.capabilities.load.memory]);return this.data}},clients:{label:"Connections",basecolor:[203,75,75]},upbps:{label:"Bandwidth up",yaxistype:"bytespersec",basecolor:[77,167,77]},downbps:{label:"Bandwidth down",yaxistype:"bytespersec",basecolor:[148,64,237]}}},yaxes:{percentage:{name:"percentage",
|
yaxistype:"percentage",basecolor:[175,216,248],getdata:function(){var a=!1,c;for(c in this.data)this.data[c][0]<1E3*(mist.data.config.time-600)&&(a=c);!1!==a&&this.data.splice(0,Number(a)+1);this.data.push([1E3*mist.data.config.time,mist.data.capabilities.load.memory]);return this.data}},clients:{label:"Connections",basecolor:[203,75,75]},upbps:{label:"Bandwidth up",yaxistype:"bytespersec",basecolor:[77,167,77]},downbps:{label:"Bandwidth down",yaxistype:"bytespersec",basecolor:[148,64,237]}}},yaxes:{percentage:{name:"percentage",
|
||||||
|
@ -75,95 +75,95 @@ type:"str",validate:["required"],help:"Enter your desired username. In the futur
|
||||||
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.rawpassword}});mist.user.password=MD5(mist.user.rawpassword);
|
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.rawpassword}});mist.user.password=MD5(mist.user.rawpassword);
|
||||||
delete mist.user.rawpassword}}]}]));break;case "Account created":UI.elements.menu.addClass("hide");d.append($("<p>").text("Your account has been created succesfully.")).append(UI.buildUI([{type:"text",text:"Would you like to enable all (currently) available protocols with their default settings?"},{type:"buttons",buttons:[{label:"Enable protocols",type:"save","function":function(){if(mist.data.config.protocols)d.append("Unable to enable all protocols as protocol settings already exist.<br>");else{d.append("Retrieving available protocols..<br>");
|
delete mist.user.rawpassword}}]}]));break;case "Account created":UI.elements.menu.addClass("hide");d.append($("<p>").text("Your account has been created succesfully.")).append(UI.buildUI([{type:"text",text:"Would you like to enable all (currently) available protocols with their default settings?"},{type:"buttons",buttons:[{label:"Enable protocols",type:"save","function":function(){if(mist.data.config.protocols)d.append("Unable to enable all protocols as protocol settings already exist.<br>");else{d.append("Retrieving available protocols..<br>");
|
||||||
mist.send(function(a){var 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")}}]}]));
|
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 h=$("<span>").text("Loading.."),q=$("<span>"),p=$("<span>").addClass("logs"),m=$("<span>"),t=$("<span>"),f=$("<span>").text("Unknown"),i=$("<span>"),j=$("<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",
|
break;case "Overview":var h=$("<span>").text("Loading.."),q=$("<span>"),p=$("<span>").addClass("logs"),m=$("<span>"),u=$("<span>"),f=$("<span>").text("Unknown"),i=$("<span>"),j=$("<span>");e={serverid:mist.data.config.serverid,debug:mist.data.config.debug};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",
|
||||||
label:"Version check",value:h,LTSonly:!0},{type:"span",label:"Server time",value:t},{type:"span",label:"Licensed to",value:"license"in mist.data.config?mist.data.config.license.name:"",LTSonly:!0},{type:"span",label:"Active products",value:f,LTSonly:!0},{type:"span",label:"Configured streams",value:mist.data.streams?Object.keys(mist.data.streams).length:0},{type:"span",label:"Active streams",value:q},{type:"span",label:"Current connections",value:m},{type:"span",label:"Enabled protocols",value:i},
|
pointer:{main:mist.data.config,index:"version"}},{type:"span",label:"Version check",value:h,LTSonly:!0},{type:"span",label:"Server time",value:u},{type:"span",label:"Licensed to",value:"license"in mist.data.config?mist.data.config.license.name:"",LTSonly:!0},{type:"span",label:"Active products",value:f,LTSonly:!0},{type:"span",label:"Configured streams",value:mist.data.streams?Object.keys(mist.data.streams).length:0},{type:"span",label:"Active streams",value:q},{type:"span",label:"Current connections",
|
||||||
{type:"span",label:"Disabled protocols",value:j},{type:"span",label:"Recent problems",value:p},$("<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."},
|
value:m},{type:"span",label:"Enabled protocols",value:i},{type:"span",label:"Disabled protocols",value:j},{type:"span",label:"Recent problems",value:p},$("<br>"),{type:"str",label:"Human readable name",pointer:{main:e,index:"serverid"},help:"You can name your MistServer here for personal use. You'll still need to set host name within your network yourself."},{type:"debug",label:"Debug level",pointer:{main:e,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)}}]}]));
|
{type:"checkbox",label:"Force configurations save",pointer:{main:e,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:e};if(e.save)a.save=e.save;delete e.save;mist.send(function(){UI.navto("Overview")},a)}}]}]));if(mist.data.LTS){var k=
|
||||||
if(mist.data.LTS){var k=function(a){function c(a){if(a.update){var b="";"progress"in a.update&&(b=" ("+a.update.progress+"%)");h.text("Updating.."+b);setTimeout(function(){mist.send(function(a){c(a)},{update:true})},5E3)}else UI.showTab("Overview")}if(!a.update||!("uptodate"in a.update)){h.text("Unknown, checking..");setTimeout(function(){mist.send(function(a){k(a)},{checkupdate:true})},5E3)}else if(a.update.error)h.addClass("red").text(a.update.error);else if(a.update.uptodate)h.text("Your version is up to date.").addClass("green");
|
function(a){function c(a){if(a.update){var b="";"progress"in a.update&&(b=" ("+a.update.progress+"%)");h.text("Updating.."+b);setTimeout(function(){mist.send(function(a){c(a)},{update:true})},5E3)}else UI.showTab("Overview")}if(!a.update||!("uptodate"in a.update)){h.text("Unknown, checking..");setTimeout(function(){mist.send(function(a){"update"in a&&k(a)},{checkupdate:true})},5E3)}else if(a.update.error)h.addClass("red").text(a.update.error);else if(a.update.uptodate)h.text("Your version is up to date.").addClass("green");
|
||||||
else if(a.update.progress){h.addClass("orange").removeClass("red").text("Updating..");c(a)}else h.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?")){h.addClass("orange").removeClass("red").text("Rolling update command sent..");mist.send(function(a){c(a)},{autoupdate:true})}}))};k(mist.data);if("license"in mist.data.config){if("active_products"in
|
else if(a.update.progress){h.addClass("orange").removeClass("red").text("Updating..");c(a)}else h.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?")){h.addClass("orange").removeClass("red").text("Rolling update command sent..");mist.send(function(a){c(a)},{autoupdate:true})}}))};k(mist.data);if("license"in mist.data.config){if("active_products"in
|
||||||
mist.data.config.license&&Object.keys(mist.data.config.license.active_products).length){var z=$("<table>").css("text-indent","0");f.html(z);z.append($("<tr>").append($("<th>").append("Product")).append($("<th>").append("Updates until")).append($("<th>").append("Use until")).append($("<th>").append("Max. simul. instances")));for(g in mist.data.config.license.active_products)e=mist.data.config.license.active_products[g],z.append($("<tr>").append($("<td>").append(e.name)).append($("<td>").append(e.updates_final?
|
mist.data.config.license&&Object.keys(mist.data.config.license.active_products).length){var z=$("<table>").css("text-indent","0");f.html(z);z.append($("<tr>").append($("<th>").append("Product")).append($("<th>").append("Updates until")).append($("<th>").append("Use until")).append($("<th>").append("Max. simul. instances")));for(g in mist.data.config.license.active_products)b=mist.data.config.license.active_products[g],z.append($("<tr>").append($("<td>").append(b.name)).append($("<td>").append(b.updates_final?
|
||||||
e.updates_final:"∞")).append($("<td>").append(e.use_final?e.use_final:"∞")).append($("<td>").append(e.amount?e.amount:"∞")))}else f.text("None.");f.append($("<a>").text("More details").attr("href","https://shop.mistserver.org/myinvoices").attr("target","_blank"))}}else h.text("");g=function(){var a={totals:{fields:["clients"],start:-10},active_streams:true};if(!("cabailities"in mist.data))a.capabilities=true;mist.send(function(){fa()},a)};var fa=function(){q.text("active_streams"in
|
b.updates_final:"∞")).append($("<td>").append(b.use_final?b.use_final:"∞")).append($("<td>").append(b.amount?b.amount:"∞")))}else f.text("None.");f.append($("<a>").text("More details").attr("href","https://shop.mistserver.org/myinvoices").attr("target","_blank"))}}else h.text("");g=function(){var a={totals:{fields:["clients"],start:-10},active_streams:true};if(!("cabailities"in mist.data))a.capabilities=true;mist.send(function(){ga()},a)};var ga=function(){q.text("active_streams"in
|
||||||
mist.data?mist.data.active_streams?mist.data.active_streams.length:0:"?");if("totals"in mist.data&&"all_streams"in mist.data.totals)var a=mist.data.totals.all_streams.all_protocols.clients,a=a.length?UI.format.number(a[a.length-1][1]):0;else a="Loading..";m.text(a);t.text(UI.format.dateTime(mist.data.config.time,"long"));p.html("");var a=0,c;for(c in mist.data.log){var b=mist.data.log[c];if(["FAIL","ERROR"].indexOf(b[1])>-1){a++;var d=$("<span>").addClass("content").addClass("red"),e=b[2].split("|");
|
mist.data?mist.data.active_streams?mist.data.active_streams.length:0:"?");if("totals"in mist.data&&"all_streams"in mist.data.totals)var a=mist.data.totals.all_streams.all_protocols.clients,a=a.length?UI.format.number(a[a.length-1][1]):0;else a="Loading..";m.text(a);u.text(UI.format.dateTime(mist.data.config.time,"long"));p.html("");var a=0,c;for(c in mist.data.log){var b=mist.data.log[c];if(["FAIL","ERROR"].indexOf(b[1])>-1){a++;var d=$("<span>").addClass("content").addClass("red"),g=b[2].split("|");
|
||||||
for(c in e)d.append($("<span>").text(e[c]));p.append($("<div>").append($("<span>").append(UI.format.time(b[0]))).append(d));if(a==5)break}}a==0&&p.html("None.");a=[];b=[];for(c in mist.data.config.protocols){d=mist.data.config.protocols[c];a.indexOf(d.connector)>-1||a.push(d.connector)}i.text(a.length?a.join(", "):"None.");if("capabilities"in mist.data){for(c in mist.data.capabilities.connectors)a.indexOf(c)==-1&&b.push(c);j.text(b.length?b.join(", "):"None.")}else j.text("Loading..")};g();fa();UI.interval.set(g,
|
for(c in g)d.append($("<span>").text(g[c]));p.append($("<div>").append($("<span>").append(UI.format.time(b[0]))).append(d));if(a==5)break}}a==0&&p.html("None.");a=[];b=[];for(c in mist.data.config.protocols){d=mist.data.config.protocols[c];a.indexOf(d.connector)>-1||a.push(d.connector)}i.text(a.length?a.join(", "):"None.");if("capabilities"in mist.data){for(c in mist.data.capabilities.connectors)a.indexOf(c)==-1&&b.push(c);j.text(b.length?b.join(", "):"None.")}else j.text("Loading..")};g();ga();UI.interval.set(g,
|
||||||
3E4);break;case "Protocols":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});d.append("Loading..");return}var x=$("<tbody>");d.append(UI.buildUI([{type:"help",help:"You can find an overview of all the protocols and their relevant information here. You can add, edit or delete protocols."}])).append($("<button>").text("Delete all protocols").click(function(){if(confirm("Are you sure you want to delete all currently configured protocols?")){mist.data.config.protocols=
|
3E4);break;case "Protocols":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});d.append("Loading..");return}var x=$("<tbody>");d.append(UI.buildUI([{type:"help",help:"You can find an overview of all the protocols and their relevant information here. You can add, edit or delete protocols."}])).append($("<button>").text("Delete all protocols").click(function(){if(confirm("Are you sure you want to delete all currently configured protocols?")){mist.data.config.protocols=
|
||||||
[];mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}})).append($("<button>").text("Enable default protocols").click(function(){var a=Object.keys(mist.data.capabilities.connectors),c;for(c in mist.data.config.protocols){var b=a.indexOf(mist.data.config.protocols[c].connector);b>-1&&a.splice(b,1)}var d=[];for(c in a)(!("required"in mist.data.capabilities.connectors[a[c]])||Object.keys(mist.data.capabilities.connectors[a[c]].required).length==0)&&d.push(a[c]);b="Click OK to enable disabled protocols with their default settings:\n ";
|
[];mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}})).append($("<button>").text("Enable default protocols").click(function(){var a=Object.keys(mist.data.capabilities.connectors),c;for(c in mist.data.config.protocols){var b=a.indexOf(mist.data.config.protocols[c].connector);b>-1&&a.splice(b,1)}var d=[];for(c in a)(!("required"in mist.data.capabilities.connectors[a[c]])||Object.keys(mist.data.capabilities.connectors[a[c]].required).length==0)&&d.push(a[c]);b="Click OK to enable disabled protocols with their default settings:\n ";
|
||||||
b=d.length?b+d.join(", "):b+"None.";if(d.length!=a.length){a=a.filter(function(a){return d.indexOf(a)<0});b=b+("\n\nThe following protocols can only be set manually:\n "+a.join(", "))}if(confirm(b)&&d.length){for(c in d)mist.data.config.protocols.push({connector:d[c]});mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}})).append("<br>").append($("<button>").text("New protocol").click(function(){UI.navto("Edit Protocol")}).css("clear","both")).append($("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Protocol")).append($("<th>").text("Status")).append($("<th>").text("Settings")).append($("<th>")))).append(x));
|
b=d.length?b+d.join(", "):b+"None.";if(d.length!=a.length){a=a.filter(function(a){return d.indexOf(a)<0});b=b+("\n\nThe following protocols can only be set manually:\n "+a.join(", "))}if(confirm(b)&&d.length){for(c in d)mist.data.config.protocols.push({connector:d[c]});mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}})).append("<br>").append($("<button>").text("New protocol").click(function(){UI.navto("Edit Protocol")}).css("clear","both")).append($("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Protocol")).append($("<th>").text("Status")).append($("<th>").text("Settings")).append($("<th>")))).append(x));
|
||||||
var ga=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 u in b[e[g]])c[u]&&c[u]!=""?d.push(u+": "+c[u]):b[e[g]][u]["default"]&&d.push(u+": "+b[e[g]][u]["default"]);return $("<span>").addClass("description").text(d.join(", "))}x.html("");for(var c in mist.data.config.protocols){var b=mist.data.config.protocols[c];x.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 ha=function(){function a(c){var b=mist.data.capabilities.connectors[c.connector];if(!b)return"";var d=[],g=["required","optional"],F;for(F in g)for(var f in b[g[F]])c[f]&&c[f]!=""?d.push(f+": "+c[f]):b[g[F]][f]["default"]&&d.push(f+": "+b[g[F]][f]["default"]);return $("<span>").addClass("description").text(d.join(", "))}x.html("");for(var c in mist.data.config.protocols){var b=mist.data.config.protocols[c];x.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.send(function(){UI.navto("Protocols")},{deleteprotocol:mist.data.config.protocols[a]});mist.data.config.protocols.splice(a,1)}}))))}};ga();UI.interval.set(function(){mist.send(function(){ga()})},
|
"right").html($("<button>").text("Edit").click(function(){UI.navto("Edit Protocol",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the protocol "'+mist.data.config.protocols[a].connector+'"?')){mist.send(function(){UI.navto("Protocols")},{deleteprotocol:mist.data.config.protocols[a]});mist.data.config.protocols.splice(a,1)}}))))}};ha();UI.interval.set(function(){mist.send(function(){ha()})},
|
||||||
1E4);break;case "Edit Protocol":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});d.append("Loading..");return}var D=!1;""!=c&&0<=c&&(D=!0);var K={};for(g in mist.data.config.protocols)K[mist.data.config.protocols[g].connector]=1;var ha=function(a){var c=mist.data.capabilities.connectors[a],b=mist.convertBuildOptions(c,n);if(D)var d=$.extend({},n);b.push({type:"hidden",pointer:{main:n,index:"connector"},value:a});b.push({type:"buttons",buttons:[{type:"save",
|
1E4);break;case "Edit Protocol":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});d.append("Loading..");return}var D=!1;""!=c&&0<=c&&(D=!0);var L={};for(g in mist.data.config.protocols)L[mist.data.config.protocols[g].connector]=1;var ia=function(a){var c=mist.data.capabilities.connectors[a],b=mist.convertBuildOptions(c,n);if(D)var d=$.extend({},n);b.push({type:"hidden",pointer:{main:n,index:"connector"},value:a});b.push({type:"buttons",buttons:[{type:"save",
|
||||||
label:"Save","function":function(){var a={};D?a.updateprotocol=[d,n]:a.addprotocol=n;mist.send(function(){UI.navto("Protocols")},a)}},{type:"cancel",label:"Cancel","function":function(){UI.navto("Protocols")}}]});if("deps"in c&&c.deps!=""){z=$("<span>").text("Dependencies:");$ul=$("<ul>");z.append($ul);if(typeof c.deps=="string")c.deps=c.deps.split(", ");for(var e in c.deps){a=$("<li>").text(c.deps[e]+" ");$ul.append(a);typeof K[c.deps[e]]!="undefined"||typeof K[c.deps[e]+".exe"]!="undefined"?a.append($("<span>").addClass("green").text("(Configured)")):
|
label:"Save","function":function(){var a={};D?a.updateprotocol=[d,n]:a.addprotocol=n;mist.send(function(){UI.navto("Protocols")},a)}},{type:"cancel",label:"Cancel","function":function(){UI.navto("Protocols")}}]});if("deps"in c&&c.deps!=""){z=$("<span>").text("Dependencies:");$ul=$("<ul>");z.append($ul);if(typeof c.deps=="string")c.deps=c.deps.split(", ");for(var g in c.deps){a=$("<li>").text(c.deps[g]+" ");$ul.append(a);typeof L[c.deps[g]]!="undefined"||typeof L[c.deps[g]+".exe"]!="undefined"?a.append($("<span>").addClass("green").text("(Configured)")):
|
||||||
a.append($("<span>").addClass("red").text("(Not yet configured)"))}b.unshift({type:"text",text:z[0].innerHTML})}return UI.buildUI(b)},K={};for(g in mist.data.config.protocols)K[mist.data.config.protocols[g].connector]=1;if(D)n=b=mist.data.config.protocols[c],d.find("h2").append(' "'+b.connector+'"'),d.append(ha(b.connector));else{d.html($("<h2>").text("New Protocol"));var n={},r=[["",""]];for(g in mist.data.capabilities.connectors)r.push([g,g]);var I=$("<span>");d.append(UI.buildUI([{label:"Protocol",
|
a.append($("<span>").addClass("red").text("(Not yet configured)"))}b.unshift({type:"text",text:z[0].innerHTML})}return UI.buildUI(b)},L={};for(g in mist.data.config.protocols)L[mist.data.config.protocols[g].connector]=1;if(D){var r=mist.data.config.protocols[c],n=r;d.find("h2").append(' "'+r.connector+'"');d.append(ia(r.connector))}else{d.html($("<h2>").text("New Protocol"));var n={},s=[["",""]];for(g in mist.data.capabilities.connectors)s.push([g,g]);var J=$("<span>");d.append(UI.buildUI([{label:"Protocol",
|
||||||
type:"select",select:r,"function":function(){$(this).getval()!=""&&I.html(ha($(this).getval()))}}])).append(I)}break;case "Streams":if(!("capabilities"in mist.data)){d.html("Loading..");mist.send(function(){UI.navto(a)},{capabilities:!0});return}g=$("<button>");var E=$("<span>").text("Loading..");d.append(UI.buildUI([{type:"help",help:"Here you can create, edit or delete new and existing streams. Go to stream preview or embed a video player on your website."},$("<div>").css({width:"45.25em",display:"flex",
|
type:"select",select:s,"function":function(){$(this).getval()!=""&&J.html(ia($(this).getval()))}}])).append(J)}break;case "Streams":if(!("capabilities"in mist.data)){d.html("Loading..");mist.send(function(){UI.navto(a)},{capabilities:!0});return}g=$("<button>");var E=$("<span>").text("Loading..");d.append(UI.buildUI([{type:"help",help:"Here you can create, edit or delete new and existing streams. Go to stream preview or embed a video player on your website."},$("<div>").css({width:"45.25em",display:"flex",
|
||||||
"justify-content":"flex-end"}).append(g).append($("<button>").text("Create a new stream").click(function(){UI.navto("Edit")}))])).append(E);""==c&&(e=mist.stored.get(),"viewmode"in e&&(c=e.viewmode));g.text("Switch to "+("thumbnails"==c?"list":"thumbnail")+" view").click(function(){mist.stored.set("viewmode",c=="thumbnails"?"list":"thumbnails");UI.navto("Streams",c=="thumbnails"?"list":"thumbnails")});var y=$.extend(!0,{},mist.data.streams),T=function(a,c){var b=$.extend({},c);delete b.meta;delete b.error;
|
"justify-content":"flex-end"}).append(g).append($("<button>").text("Create a new stream").click(function(){UI.navto("Edit")}))])).append(E);""==c&&(e=mist.stored.get(),"viewmode"in e&&(c=e.viewmode));g.text("Switch to "+("thumbnails"==c?"list":"thumbnail")+" view").click(function(){mist.stored.set("viewmode",c=="thumbnails"?"list":"thumbnails");UI.navto("Streams",c=="thumbnails"?"list":"thumbnails")});var y=$.extend(!0,{},mist.data.streams),U=function(a,c){var b=$.extend({},c);delete b.meta;delete b.error;
|
||||||
b.online=2;b.name=a;b.ischild=true;return b},U=function(c,b,e){E.remove();switch(c){case "thumbnails":var g=$("<div>").addClass("preview_icons"),f;f=e||[];b.sort();b.unshift("");E.remove();d.append($("<h2>").text(a)).append(UI.buildUI([{label:"Filter the streams",type:"datalist",datalist:b,pointer:{main:{},index:"stream"},help:"If you type something here, the box below will only show streams with names that contain your text.","function":function(){var a=$(this).val();g.children().each(function(){$(this).hide();
|
b.online=2;b.name=a;b.ischild=true;return b},V=function(c,b,g){E.remove();switch(c){case "thumbnails":var f=$("<div>").addClass("preview_icons"),e;e=g||[];b.sort();b.unshift("");E.remove();d.append($("<h2>").text(a)).append(UI.buildUI([{label:"Filter the streams",type:"datalist",datalist:b,pointer:{main:{},index:"stream"},help:"If you type something here, the box below will only show streams with names that contain your text.","function":function(){var a=$(this).val();f.children().each(function(){$(this).hide();
|
||||||
$(this).attr("data-stream").indexOf(a)>-1&&$(this).show()})}}]));b.shift();d.append($("<span>").addClass("description").text("Choose a stream below.")).append(g);for(var h in b){var c=b[h],i="",j=$("<button>").text("Delete").click(function(){var a=$(this).closest("div").attr("data-stream");if(confirm('Are you sure you want to delete the stream "'+a+'"?')){delete mist.data.streams[a];var c={};c.deletestream=[a];mist.send(function(){UI.navto("Streams")},c)}}),k=$("<button>").text("Settings").click(function(){UI.navto("Edit",
|
$(this).attr("data-stream").indexOf(a)>-1&&$(this).show()})}}]));b.shift();d.append($("<span>").addClass("description").text("Choose a stream below.")).append(f);for(var h in b){var c=b[h],i="",j=$("<button>").text("Delete").click(function(){var a=$(this).closest("div").attr("data-stream");if(confirm('Are you sure you want to delete the stream "'+a+'"?')){delete mist.data.streams[a];var c={};c.deletestream=[a];mist.send(function(){UI.navto("Streams")},c)}}),k=$("<button>").text("Settings").click(function(){UI.navto("Edit",
|
||||||
$(this).closest("div").attr("data-stream"))}),e=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("div").attr("data-stream"))}),l=$("<button>").text("Embed").click(function(){UI.navto("Embed",$(this).closest("div").attr("data-stream"))}),m=$("<span>").addClass("image");if(c.indexOf("+")>-1){i=c.split("+");i=mist.data.streams[i[0]].source+i[1];k=j="";m.addClass("wildcard")}else{i=mist.data.streams[c].source;if(f.indexOf(c)>-1){l=e="";m.addClass("folder")}}g.append($("<div>").append($("<span>").addClass("streamname").text(c)).append(m).append($("<span>").addClass("description").text(i)).append($("<span>").addClass("button_container").append(k).append(j).append(e).append(l)).attr("title",
|
$(this).closest("div").attr("data-stream"))}),g=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("div").attr("data-stream"))}),l=$("<button>").text("Embed").click(function(){UI.navto("Embed",$(this).closest("div").attr("data-stream"))}),m=$("<span>").addClass("image");if(c.indexOf("+")>-1){i=c.split("+");i=mist.data.streams[i[0]].source+i[1];k=j="";m.addClass("wildcard")}else{i=mist.data.streams[c].source;if(e.indexOf(c)>-1){l=g="";m.addClass("folder")}}f.append($("<div>").append($("<span>").addClass("streamname").text(c)).append(m).append($("<span>").addClass("description").text(i)).append($("<span>").addClass("button_container").append(k).append(j).append(g).append(l)).attr("title",
|
||||||
c).attr("data-stream",c))}break;default:var n=$("<tbody>").append($("<tr>").append("<td>").attr("colspan",6).text("Loading.."));h=$("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Stream name").attr("data-sort-type","string").addClass("sorting-asc")).append($("<th>").text("Source").attr("data-sort-type","string")).append($("<th>").text("Status").attr("data-sort-type","int")).append($("<th>").css("text-align","right").text("Connections").attr("data-sort-type","int")).append($("<th>")).append($("<th>")))).append(n);
|
c).attr("data-stream",c))}break;default:var n=$("<tbody>").append($("<tr>").append("<td>").attr("colspan",6).text("Loading.."));h=$("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Stream name").attr("data-sort-type","string").addClass("sorting-asc")).append($("<th>").text("Source").attr("data-sort-type","string")).append($("<th>").text("Status").attr("data-sort-type","int")).append($("<th>").css("text-align","right").text("Connections").attr("data-sort-type","int")).append($("<th>")).append($("<th>")))).append(n);
|
||||||
d.append(h);h.stupidtable();var o=function(){var a=[],c;for(c in mist.data.active_streams)a.push({streams:[mist.data.active_streams[c]],fields:["clients"],start:-2});mist.send(function(){$.extend(true,y,mist.data.streams);var a=0;n.html("");b.sort();for(var c in b){var d=b[c],e;e=d in mist.data.streams?mist.data.streams[d]:y[d];var g=$("<td>").css("text-align","right").html($("<span>").addClass("description").text("Loading..")),f=0;if(typeof mist.data.totals!="undefined"&&typeof mist.data.totals[d]!=
|
d.append(h);h.stupidtable();var o=function(){var a=[],c;for(c in mist.data.active_streams)a.push({streams:[mist.data.active_streams[c]],fields:["clients"],start:-2});mist.send(function(){$.extend(true,y,mist.data.streams);var a=0;n.html("");b.sort();for(var c in b){var d=b[c],g;g=d in mist.data.streams?mist.data.streams[d]:y[d];var f=$("<td>").css("text-align","right").html($("<span>").addClass("description").text("Loading..")),e=0;if(typeof mist.data.totals!="undefined"&&typeof mist.data.totals[d]!=
|
||||||
"undefined"){var u=mist.data.totals[d].all_protocols.clients,f=0;if(u.length){for(a in u)f=f+u[a][1];f=Math.round(f/u.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("Settings").click(function(){UI.navto("Edit",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the stream "'+
|
"undefined"){var h=mist.data.totals[d].all_protocols.clients,e=0;if(h.length){for(a in h)e=e+h[a][1];e=Math.round(e/h.length)}}f.html(UI.format.number(e));if(e==0&&g.online==1)g.online=2;e=$("<td>").css("text-align","right").css("white-space","nowrap");(!("ischild"in g)||!g.ischild)&&e.html($("<button>").text("Settings").click(function(){UI.navto("Edit",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the stream "'+
|
||||||
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)}}));u=$("<span>").text(d);e.ischild&&u.css("padding-left","1em");var h=UI.format.status(e),i=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("tr").data("index"))}),j=$("<button>").text("Embed").click(function(){UI.navto("Embed",$(this).closest("tr").data("index"))});if("filesfound"in y[d]){h.html("");i="";g.html("");
|
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)}}));h=$("<span>").text(d);g.ischild&&h.css("padding-left","1em");var F=UI.format.status(g),i=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("tr").data("index"))}),j=$("<button>").text("Embed").click(function(){UI.navto("Embed",$(this).closest("tr").data("index"))});if("filesfound"in y[d]){F.html("");i="";f.html("");
|
||||||
j=""}n.append($("<tr>").data("index",d).html($("<td>").html(u).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(h)).append(g).append($("<td>").css("white-space","nowrap").html(i).append(j)).append(f));a++}},{totals:a,active_streams:true})};if(mist.data.LTS){var p=0,q=0;for(f in mist.data.streams){h=mist.data.capabilities.inputs.Folder||
|
j=""}n.append($("<tr>").data("index",d).html($("<td>").html(h).attr("title",d).addClass("overflow_ellipsis")).append($("<td>").text(g.source).attr("title",g.source).addClass("description").addClass("overflow_ellipsis").css("max-width","20em")).append($("<td>").data("sort-value",g.online).html(F)).append(f).append($("<td>").css("white-space","nowrap").html(i).append(j)).append(e));a++}},{totals:a,active_streams:true})};if(mist.data.LTS){var p=0,q=0;for(e in mist.data.streams){h=mist.data.capabilities.inputs.Folder||
|
||||||
mist.data.capabilities.inputs["Folder.exe"];if(!h)break;if(mist.inputMatch(h.source_match,mist.data.streams[f].source)){y[f].source=y[f].source+"*";y[f].filesfound=null;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("Buffer.exe")>=0||e.indexOf("Folder")>=0||e.indexOf("Folder.exe")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[e].source_match,"/"+a.browse.files[d])){var g=b+"+"+a.browse.files[d];
|
mist.data.capabilities.inputs["Folder.exe"];if(!h)break;if(mist.inputMatch(h.source_match,mist.data.streams[e].source)){y[e].source=y[e].source+"*";y[e].filesfound=null;mist.send(function(a,c){var b=c.stream,d;for(d in a.browse.files)for(var g in mist.data.capabilities.inputs)if(!(g.indexOf("Buffer")>=0||g.indexOf("Buffer.exe")>=0||g.indexOf("Folder")>=0||g.indexOf("Folder.exe")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[g].source_match,"/"+a.browse.files[d])){var e=b+"+"+a.browse.files[d];
|
||||||
y[g]=T(g,mist.data.streams[b]);y[g].source=mist.data.streams[b].source+a.browse.files[d]}"files"in a.browse&&a.browse.files.length?y[b].filesfound=true:mist.data.streams[b].filesfound=false;q++;if(p==q){mist.send(function(){o()},{active_streams:true});UI.interval.set(function(){o()},5E3)}},{browse:mist.data.streams[f].source},{stream:f});p++}}if(p==0){mist.send(function(){o()},{active_streams:true});UI.interval.set(function(){o()},5E3)}}else{mist.send(function(){o()},{active_streams:true});UI.interval.set(function(){o()},
|
y[e]=U(e,mist.data.streams[b]);y[e].source=mist.data.streams[b].source+a.browse.files[d]}"files"in a.browse&&a.browse.files.length?y[b].filesfound=true:mist.data.streams[b].filesfound=false;q++;if(p==q){mist.send(function(){o()},{active_streams:true});UI.interval.set(function(){o()},5E3)}},{browse:mist.data.streams[e].source},{stream:e});p++}}if(p==0){mist.send(function(){o()},{active_streams:true});UI.interval.set(function(){o()},5E3)}}else{mist.send(function(){o()},{active_streams:true});UI.interval.set(function(){o()},
|
||||||
5E3)}}};if(mist.data.LTS){var V=0,ia=0,r={},ja=[];for(e in mist.data.streams)if(mist.inputMatch((mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"]).source_match,mist.data.streams[e].source))ja.push(e),mist.send(function(a,b){var d=b.stream,e;for(e in a.browse.files)for(var g in mist.data.capabilities.inputs)g.indexOf("Buffer")>=0||g.indexOf("Folder")>=0||mist.inputMatch(mist.data.capabilities.inputs[g].source_match,"/"+a.browse.files[e])&&(r[d+"+"+a.browse.files[e]]=
|
5E3)}}};if(mist.data.LTS){var W=0,ja=0,s={},ka=[];for(e in mist.data.streams)if(mist.inputMatch((mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"]).source_match,mist.data.streams[e].source))ka.push(e),mist.send(function(a,b){var d=b.stream,g;for(g in a.browse.files)for(var e in mist.data.capabilities.inputs)e.indexOf("Buffer")>=0||e.indexOf("Folder")>=0||mist.inputMatch(mist.data.capabilities.inputs[e].source_match,"/"+a.browse.files[g])&&(s[d+"+"+a.browse.files[g]]=
|
||||||
true);ia++;V==ia&&mist.send(function(){for(var a in mist.data.active_streams){var b=mist.data.active_streams[a].split("+");if(b.length>1&&b[0]in mist.data.streams){r[mist.data.active_streams[a]]=true;y[mist.data.active_streams[a]]=T(mist.data.active_streams[a],mist.data.streams[b[0]])}}r=Object.keys(r);r=r.concat(Object.keys(mist.data.streams));r.sort();U(c,r,ja)},{active_streams:true})},{browse:mist.data.streams[e].source},{stream:e}),V++;0==V&&mist.send(function(){for(var a in mist.data.active_streams){var b=
|
true);ja++;W==ja&&mist.send(function(){for(var a in mist.data.active_streams){var b=mist.data.active_streams[a].split("+");if(b.length>1&&b[0]in mist.data.streams){s[mist.data.active_streams[a]]=true;y[mist.data.active_streams[a]]=U(mist.data.active_streams[a],mist.data.streams[b[0]])}}s=Object.keys(s);s=s.concat(Object.keys(mist.data.streams));s.sort();V(c,s,ka)},{active_streams:true})},{browse:mist.data.streams[e].source},{stream:e}),W++;0==W&&mist.send(function(){for(var a in mist.data.active_streams){var b=
|
||||||
mist.data.active_streams[a].split("+");if(b.length>1&&b[0]in mist.data.streams){r[mist.data.active_streams[a]]=true;y[mist.data.active_streams[a]]=T(mist.data.active_streams[a],mist.data.streams[b[0]])}}r=Object.keys(r);mist.data.streams&&(r=r.concat(Object.keys(mist.data.streams)));r.sort();U(c,r)},{active_streams:!0})}else U(c,Object.keys(mist.data.streams));break;case "Edit":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});d.append("Loading..");
|
mist.data.active_streams[a].split("+");if(b.length>1&&b[0]in mist.data.streams){s[mist.data.active_streams[a]]=true;y[mist.data.active_streams[a]]=U(mist.data.active_streams[a],mist.data.streams[b[0]])}}s=Object.keys(s);mist.data.streams&&(s=s.concat(Object.keys(mist.data.streams)));s.sort();V(c,s)},{active_streams:!0})}else V(c,Object.keys(mist.data.streams));break;case "Edit":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});d.append("Loading..");
|
||||||
return}D=!1;""!=c&&(D=!0);D?(f=c,n=mist.data.streams[f],d.find("h2").append(' "'+f+'"')):(d.html($("<h2>").text("New Stream")),n={});f=[];for(g in mist.data.capabilities.inputs)f.push(mist.data.capabilities.inputs[g].source_match);var P=$("<div>"),ka=function(a){var b={};if(!mist.data.streams)mist.data.streams={};mist.data.streams[n.name]=n;c!=n.name&&delete mist.data.streams[c];b.addstream={};b.addstream[n.name]=n;if(c!=n.name)b.deletestream=[c];if(n.stop_sessions&&c!=""){b.stop_sessions=c;delete n.stop_sessions}mist.send(function(){delete mist.data.streams[n.name].online;
|
return}D=!1;""!=c&&(D=!0);D?(f=c,n=mist.data.streams[f],d.find("h2").append(' "'+f+'"')):(d.html($("<h2>").text("New Stream")),n={});f=[];for(g in mist.data.capabilities.inputs)f.push(mist.data.capabilities.inputs[g].source_match);var Q=$("<div>"),la=function(a){var b={};if(!mist.data.streams)mist.data.streams={};mist.data.streams[n.name]=n;c!=n.name&&delete mist.data.streams[c];b.addstream={};b.addstream[n.name]=n;if(c!=n.name)b.deletestream=[c];if(n.stop_sessions&&c!=""){b.stop_sessions=c;delete n.stop_sessions}mist.send(function(){delete mist.data.streams[n.name].online;
|
||||||
delete mist.data.streams[n.name].error;UI.navto(a,a=="Preview"?n.name:"")},b)},la=$("<style>").text("button.saveandpreview { display: none; }"),F=$("<span>"),W=function(){var a=d.find("[name=name]").val();if(a){var c=parseURL(mist.user.host),b=d.find("[name=source]").val(),e=b.match(/@.*/);e&&(e=e[0].substring(1));var g=b.replace(/(?:.+?):\/\//,""),g=g.split("/"),g=g[0],g=g.split(":"),g=g[0];(b=b.match(/:\d+/))&&(b=b[0]);var f={},h=["RTMP","RTSP","TS","RTMP.exe","RTSP.exe","TS.exe"],i;for(i in h)h[i]in
|
delete mist.data.streams[n.name].error;UI.navto(a,a=="Preview"?n.name:"")},b)},ma=$("<style>").text("button.saveandpreview { display: none; }"),G=$("<span>"),X=function(){var a=d.find("[name=name]").val();if(a){var c=parseURL(mist.user.host),b=d.find("[name=source]").val(),g=b.match(/@.*/);g&&(g=g[0].substring(1));var e=b.replace(/(?:.+?):\/\//,""),e=e.split("/"),e=e[0],e=e.split(":"),e=e[0];(b=b.match(/:\d+/))&&(b=b[0]);var f={},h=["RTMP","RTSP","TS","RTMP.exe","RTSP.exe","TS.exe"],i;for(i in h)h[i]in
|
||||||
mist.data.capabilities.connectors&&(f[h[i]]=mist.data.capabilities.connectors[h[i]].optional.port["default"]);var h={RTMP:1935,"RTMP.exe":1935,RTSP:554,"RTSP.exe":554,TS:-1,"TS.exe":-1},j;for(j in f){for(i in mist.data.config.protocols){var k=mist.data.config.protocols[i];if(k.connector==j){if("port"in k)f[j]=k.port;break}}f[j]=f[j]==h[j]?"":":"+f[j]}F.find(".field").closest("label").hide();for(i in f){var l;j=b?b:f[i];switch(i){case "RTMP":case "RTMP.exe":l="rtmp://"+c.host+j+"/"+(e?e:"live")+"/";
|
mist.data.capabilities.connectors&&(f[h[i]]=mist.data.capabilities.connectors[h[i]].optional.port["default"]);var h={RTMP:1935,"RTMP.exe":1935,RTSP:554,"RTSP.exe":554,TS:-1,"TS.exe":-1},j;for(j in f){for(i in mist.data.config.protocols){var k=mist.data.config.protocols[i];if(k.connector==j){if("port"in k)f[j]=k.port;break}}f[j]=f[j]==h[j]?"":":"+f[j]}G.find(".field").closest("label").hide();for(i in f){var l;j=b?b:f[i];switch(i){case "RTMP":case "RTMP.exe":l="rtmp://"+c.host+j+"/"+(g?g:"live")+"/";
|
||||||
F.find(".field.RTMPurl").setval(l).closest("label").show();F.find(".field.RTMPkey").setval(a==""?"STREAMNAME":a).closest("label").show();l=l+(a==""?"STREAMNAME":a);break;case "RTSP":case "RTSP.exe":l="rtsp://"+c.host+j+"/"+(a==""?"STREAMNAME":a)+(e?"?pass="+e:"");break;case "TS":case "TS.exe":l="udp://"+(g==""?c.host:g)+j+"/"}F.find(".field."+i.replace(".exe","")).setval(l).closest("label").show()}}};d.append(UI.buildUI([{label:"Stream name",type:"str",validate:["required","streamname"],pointer:{main:n,
|
G.find(".field.RTMPurl").setval(l).closest("label").show();G.find(".field.RTMPkey").setval(a==""?"STREAMNAME":a).closest("label").show();l=l+(a==""?"STREAMNAME":a);break;case "RTSP":case "RTSP.exe":l="rtsp://"+c.host+j+"/"+(a==""?"STREAMNAME":a)+(g?"?pass="+g:"");break;case "TS":case "TS.exe":l="udp://"+(e==""?c.host:e)+j+"/"}G.find(".field."+i.replace(".exe","")).setval(l).closest("label").show()}}};d.append(UI.buildUI([{label:"Stream name",type:"str",validate:["required","streamname"],pointer:{main:n,
|
||||||
index:"name"},help:"Set the name this stream will be recognised by for players and/or stream pushing."},{label:"Source",type:"browse",filetypes:f,pointer:{main:n,index:"source"},help:"<p>Below is the explanation of the input methods for MistServer. Anything between brackets () will go to default settings if not specified.</p><table><tr><td>File input</td><td>Syntax</td><td>Explanation</td></tr><tr><th>File</th><td>Linux/MacOS: /PATH/FILE<br>Windows: /cygdrive/DRIVE/PATH/FILE</td><td>For file input please specify the proper path and file.<br>Supported inputs are: DTSC, FLV, MP3. MistServer Pro has TS, MP4, ISMV added as input.</td></tr><th>Folder<br>(Pro only)</th><td>Linux/MacOS: /PATH/<br>Windows: /cygdrive/DRIVE/PATH/</td><td>A folder stream makes all the recognised files in the selected folder available as a stream.</td></tr><tr><td>Push input</td><td>Syntax</td><td>Explanation</td></tr><tr><th>RTMP</th><td>push://(IP)(@PASSWORD)</td><td>IP is white listed IP for pushing towards MistServer, if left empty all are white listed.<br>PASSWORD is the application under which to push to MistServer, if it doesn't match the stream will be rejected. PASSWORD is MistServer Pro only. <tr><th>RTSP<br>(Pro only)</th><td>push://(IP)(@PASSWORD)</td><td>IP is white listed IP for pushing towards MistServer, if left empty all are white listed.</td></tr> <tr><th>TS<br>(Pro only)</th><td>tsudp://(IP):PORT(/INTERFACE)</td><td>IP is the IP address used to listen for this stream, multi-cast IP range is: 224.0.0.0 - 239.255.255.255. If IP is not set all addresses will listened to.<br>PORT is the port you reserve for this stream on the chosen IP.<br>INTERFACE is the interface used, if left all interfaces will be used.</td></tr><tr><td>Pull input</td><td>Syntax</td><td>Explanation</td></tr><tr><th>DTSC</th><td>dtsc://MISTSERVER_IP:PORT/(STREAMNAME)</td><td>MISTSERVER_IP is the IP of another MistServer to pull from.<br>PORT is the DTSC port of the other MistServer. (default is 4200)<br>STREAMNAME is the name of the target stream on the other MistServer. If left empty, the name of this stream will be used.</td></tr><tr><th>HLS<br>(Pro only)</th><td>http://URL/TO/STREAM.m3u8</td><td>The URL where the HLS stream is available to MistServer.</td></tr></table>",
|
index:"name"},help:"Set the name this stream will be recognised by for players and/or stream pushing."},{label:"Source",type:"browse",filetypes:f,pointer:{main:n,index:"source"},help:"<p>Below is the explanation of the input methods for MistServer. Anything between brackets () will go to default settings if not specified.</p><table><tr><td>File input</td><td>Syntax</td><td>Explanation</td></tr><tr><th>File</th><td>Linux/MacOS: /PATH/FILE<br>Windows: /cygdrive/DRIVE/PATH/FILE</td><td>For file input please specify the proper path and file.<br>Supported inputs are: DTSC, FLV, MP3. MistServer Pro has TS, MP4, ISMV added as input.</td></tr><th>Folder<br>(Pro only)</th><td>Linux/MacOS: /PATH/<br>Windows: /cygdrive/DRIVE/PATH/</td><td>A folder stream makes all the recognised files in the selected folder available as a stream.</td></tr><tr><td>Push input</td><td>Syntax</td><td>Explanation</td></tr><tr><th>RTMP</th><td>push://(IP)(@PASSWORD)</td><td>IP is white listed IP for pushing towards MistServer, if left empty all are white listed.<br>PASSWORD is the application under which to push to MistServer, if it doesn't match the stream will be rejected. PASSWORD is MistServer Pro only. <tr><th>RTSP<br>(Pro only)</th><td>push://(IP)(@PASSWORD)</td><td>IP is white listed IP for pushing towards MistServer, if left empty all are white listed.</td></tr> <tr><th>TS<br>(Pro only)</th><td>tsudp://(IP):PORT(/INTERFACE)</td><td>IP is the IP address used to listen for this stream, multi-cast IP range is: 224.0.0.0 - 239.255.255.255. If IP is not set all addresses will listened to.<br>PORT is the port you reserve for this stream on the chosen IP.<br>INTERFACE is the interface used, if left all interfaces will be used.</td></tr><tr><td>Pull input</td><td>Syntax</td><td>Explanation</td></tr><tr><th>DTSC</th><td>dtsc://MISTSERVER_IP:PORT/(STREAMNAME)</td><td>MISTSERVER_IP is the IP of another MistServer to pull from.<br>PORT is the DTSC port of the other MistServer. (default is 4200)<br>STREAMNAME is the name of the target stream on the other MistServer. If left empty, the name of this stream will be used.</td></tr><tr><th>HLS<br>(Pro only)</th><td>http://URL/TO/STREAM.m3u8</td><td>The URL where the HLS stream is available to MistServer.</td></tr></table>",
|
||||||
"function":function(){var a=$(this).val();la.remove();F.html("");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)P.html($("<h3>").text("Unrecognized input").addClass("red")).append($("<span>").text("Please edit the stream source.").addClass("red"));else{c=mist.data.capabilities.inputs[c];P.html($("<h3>").text(c.name+" Input options"));
|
"function":function(){var a=$(this).val();ma.remove();G.html("");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)Q.html($("<h3>").text("Unrecognized input").addClass("red")).append($("<span>").text("Please edit the stream source.").addClass("red"));else{c=mist.data.capabilities.inputs[c];Q.html($("<h3>").text(c.name+" Input options"));
|
||||||
var e=mist.convertBuildOptions(c,n);"always_match"in mist.data.capabilities.inputs[b]&&mist.inputMatch(mist.data.capabilities.inputs[b].always_match,a)&&e.push({label:"Always on",type:"checkbox",help:"Keep this input available at all times, even when there are no active viewers.",pointer:{main:n,index:"always_on"}});P.append(UI.buildUI(e));if(c.name=="Folder")d.append(la);else if(["Buffer","Buffer.exe","TS","TS.exe"].indexOf(c.name)>-1){a=[$("<span>").text("Configure your source to push to:")];switch(c.name){case "Buffer":case "Buffer.exe":a.push({label:"RTMP full url",
|
var g=mist.convertBuildOptions(c,n);"always_match"in mist.data.capabilities.inputs[b]&&mist.inputMatch(mist.data.capabilities.inputs[b].always_match,a)&&g.push({label:"Always on",type:"checkbox",help:"Keep this input available at all times, even when there are no active viewers.",pointer:{main:n,index:"always_on"}});Q.append(UI.buildUI(g));if(c.name=="Folder")d.append(ma);else if(["Buffer","Buffer.exe","TS","TS.exe"].indexOf(c.name)>-1){a=[$("<span>").text("Configure your source to push to:")];switch(c.name){case "Buffer":case "Buffer.exe":a.push({label:"RTMP full url",
|
||||||
type:"span",clipboard:true,readonly:true,classes:["RTMP"],help:"Use this RTMP url if your client doesn't ask for a stream key"});a.push({label:"RTMP url",type:"span",clipboard:true,readonly:true,classes:["RTMPurl"],help:"Use this RTMP url if your client also asks for a stream key"});a.push({label:"RTMP stream key",type:"span",clipboard:true,readonly:true,classes:["RTMPkey"],help:"Use this key if your client asks for a stream key"});a.push({label:"RTSP",type:"span",clipboard:true,readonly:true,classes:["RTSP"]});
|
type:"span",clipboard:true,readonly:true,classes:["RTMP"],help:"Use this RTMP url if your client doesn't ask for a stream key"});a.push({label:"RTMP url",type:"span",clipboard:true,readonly:true,classes:["RTMPurl"],help:"Use this RTMP url if your client also asks for a stream key"});a.push({label:"RTMP stream key",type:"span",clipboard:true,readonly:true,classes:["RTMPkey"],help:"Use this key if your client asks for a stream key"});a.push({label:"RTSP",type:"span",clipboard:true,readonly:true,classes:["RTSP"]});
|
||||||
break;case "TS":case "TS.exe":a.push({label:"TS",type:"span",clipboard:true,readonly:true,classes:["TS"]})}F.html("<br>").append(UI.buildUI(a));W()}}}}},{label:"Stop sessions",type:"checkbox",help:"When saving these stream settings, kill this stream's current connections.",LTSonly:!0,pointer:{main:n,index:"stop_sessions"}},F,$("<br>"),{type:"custom",custom:P},$("<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."},
|
break;case "TS":case "TS.exe":a.push({label:"TS",type:"span",clipboard:true,readonly:true,classes:["TS"]})}G.html("<br>").append(UI.buildUI(a));X()}}}}},{label:"Stop sessions",type:"checkbox",help:"When saving these stream settings, kill this stream's current connections.",LTSonly:!0,pointer:{main:n,index:"stop_sessions"}},G,$("<br>"),{type:"custom",custom:Q},$("<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:n,index:"la_url"}},$("<br>"),{label:"Content key",type:"str",LTSonly:!0,pointer:{main:n,index:"contentkey"}},{type:"text",text:" - or - "},{label:"Key ID",type:"str",LTSonly:!0,pointer:{main:n,index:"keyid"}},{label:"Key seed",type:"str",LTSonly:!0,pointer:{main:n,index:"keyseed"}},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Streams")}},{type:"save",label:"Save","function":function(){ka("Streams")}},
|
{label:"License acquisition url",type:"str",LTSonly:!0,pointer:{main:n,index:"la_url"}},$("<br>"),{label:"Content key",type:"str",LTSonly:!0,pointer:{main:n,index:"contentkey"}},{type:"text",text:" - or - "},{label:"Key ID",type:"str",LTSonly:!0,pointer:{main:n,index:"keyid"}},{label:"Key seed",type:"str",LTSonly:!0,pointer:{main:n,index:"keyseed"}},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Streams")}},{type:"save",label:"Save","function":function(){la("Streams")}},
|
||||||
{type:"save",label:"Save and Preview","function":function(){ka("Preview")},classes:["saveandpreview"]}]}]));d.find("[name=name]").keyup(function(){W()});W();break;case "Preview":""==c&&UI.navto("Streams");e=":8080";for(g in mist.data.config.protocols)if(b=mist.data.config.protocols[g],"HTTP"==b.connector||"HTTP.exe"==b.connector)e=b.port?":"+b.port:":8080";var f=parseURL(mist.user.host),L=f.protocol+f.host+e+"/",I=$("<div>").css({display:"flex","flex-flow":"row wrap"}),f="";-1==c.indexOf("+")&&(f=
|
{type:"save",label:"Save and Preview","function":function(){la("Preview")},classes:["saveandpreview"]}]}]));d.find("[name=name]").keyup(function(){X()});X();break;case "Preview":""==c&&UI.navto("Streams");b=":8080";for(g in mist.data.config.protocols)if(r=mist.data.config.protocols[g],"HTTP"==r.connector||"HTTP.exe"==r.connector)b=r.port?":"+r.port:":8080";var f=parseURL(mist.user.host),M=f.protocol+f.host+b+"/",J=$("<div>").css({display:"flex","flex-flow":"row wrap"}),f="";-1==c.indexOf("+")&&(f=
|
||||||
$("<button>").text("Settings").addClass("settings").click(function(){UI.navto("Edit",c)}));d.html($("<div>").addClass("bigbuttons").append(f).append($("<button>").text("Embed").addClass("embed").click(function(){UI.navto("Embed",c)})).append($("<button>").addClass("cancel").addClass("return").text("Return").click(function(){UI.navto("Streams")}))).append($("<h2>").text('Preview of "'+c+'"')).append(I);var G=encodeURIComponent(c);g=$("<div>");I.append(g);var X=$("<div>"),Q=$("<select>").append($("<option>").text("Automatic").val("")).change(function(){Y()}),
|
$("<button>").text("Settings").addClass("settings").click(function(){UI.navto("Edit",c)}));d.html($("<div>").addClass("bigbuttons").append(f).append($("<button>").text("Embed").addClass("embed").click(function(){UI.navto("Embed",c)})).append($("<button>").addClass("cancel").addClass("return").text("Return").click(function(){UI.navto("Streams")}))).append($("<h2>").text('Preview of "'+c+'"')).append(J);var H=encodeURIComponent(c);g=$("<div>");J.append(g);var Y=$("<div>"),R=$("<select>").append($("<option>").text("Automatic").val("")).change(function(){Z()}),
|
||||||
M=$("<select>").append($("<option>").text("Automatic").val("")).change(function(){Y()}),f=UI.buildUI([{label:"Use player",type:"DOMfield",DOMfield:Q,help:"Choose a player to preview"},{label:"Use source",type:"DOMfield",DOMfield:M,help:"Choose an output type to preview"}]),N=$("<div>").addClass("mistvideo").text("Loading player..");g.append(N).append(X).append(f);var Y=function(){A.html("");if(typeof mistvideo!="undefined")for(var a in mistvideo)if("embedded"in mistvideo[a])for(var b in mistvideo[a].embedded)try{mistvideo[a].embedded[b].player.unload()}catch(d){}a=
|
N=$("<select>").append($("<option>").text("Automatic").val("")).change(function(){Z()}),f=UI.buildUI([{label:"Use player",type:"DOMfield",DOMfield:R,help:"Choose a player to preview"},{label:"Use source",type:"DOMfield",DOMfield:N,help:"Choose an output type to preview"}]),O=$("<div>").addClass("mistvideo").text("Loading player..");g.append(O).append(Y).append(f);var Z=function(){A.html("");if(typeof mistvideo!="undefined")for(var a in mistvideo)if("embedded"in mistvideo[a])for(var b in mistvideo[a].embedded)try{mistvideo[a].embedded[b].player.unload()}catch(d){}a=
|
||||||
{target:N[0],maxheight:window.innerHeight-$("header").height(),maxwidth:window.innerWidth-UI.elements.menu.width()-100,host:L.replace(/\/$/,""),loop:true};if(Q.val()!="")a.forcePlayer=Q.val();if(M.val()!="")a.forceSource=M.val();mistPlay(c,a)},A=$("<div>").addClass("player_log");g.append($("<div>").append($("<h3>").text("Player log:")).append(A));var ma="";N.on("log error",function(a){var c=false;A.height()+A.scrollTop()==A[0].scrollHeight&&(c=true);var b=a.type+a.originalEvent.message,d="["+UI.format.time((new Date).getTime()/
|
{target:O[0],maxheight:window.innerHeight-$("header").height(),maxwidth:window.innerWidth-UI.elements.menu.width()-100,host:M.replace(/\/$/,""),loop:true};if(R.val()!="")a.forcePlayer=R.val();if(N.val()!="")a.forceSource=N.val();mistPlay(c,a)},A=$("<div>").addClass("player_log");g.append($("<div>").append($("<h3>").text("Player log:")).append(A));var na="";O.on("log error",function(a){var c=false;A.height()+A.scrollTop()==A[0].scrollHeight&&(c=true);var b=a.type+a.originalEvent.message,d="["+UI.format.time((new Date).getTime()/
|
||||||
1E3)+"]";if(ma==b){var a=A.children().last(),c=a.children("[data-amount]"),e=c.attr("data-amount");e++;c.text("("+e+"x)").attr("data-amount",e);a.children(".timestamp").text(d)}else{A.append($("<div>").append($("<span>").addClass("timestamp").text(d).css("margin-right","0.5em")).append($("<span>").text(a.originalEvent.message)).append($("<span>").attr("data-amount",1).css("margin-left","0.5em")).addClass(a.type=="error"?"red":""));c&&A.scrollTop(A[0].scrollHeight)}ma=b});var na=function(){X.text("");
|
1E3)+"]";if(na==b){var a=A.children().last(),c=a.children("[data-amount]"),g=c.attr("data-amount");g++;c.text("("+g+"x)").attr("data-amount",g);a.children(".timestamp").text(d)}else{A.append($("<div>").append($("<span>").addClass("timestamp").text(d).css("margin-right","0.5em")).append($("<span>").text(a.originalEvent.message)).append($("<span>").attr("data-amount",1).css("margin-left","0.5em")).addClass(a.type=="error"?"red":""));c&&A.scrollTop(A[0].scrollHeight)}na=b});var oa=function(){Y.text("");
|
||||||
var a=document.createElement("script");d.append(a);a.src=L+"player.js";a.onerror=function(){N.html("Failed to load player.js").append($("<button>").text("Reload").css("display","block").click(function(){na()}))};a.onload=function(){for(var b in mistplayers)Q.append($("<option>").text(mistplayers[b].name).val(b));Y();N.on("initialized",function(){if(M.children().length<=1)for(var a in mistvideo[c].source){var b=mistvideo[c].source[a],d=UI.humanMime(b.type);M.append($("<option>").val(a).text(d?d+" @ "+
|
var a=document.createElement("script");d.append(a);a.src=M+"player.js";a.onerror=function(){O.html("Failed to load player.js").append($("<button>").text("Reload").css("display","block").click(function(){oa()}))};a.onload=function(){for(var b in mistplayers)R.append($("<option>").text(mistplayers[b].name).val(b));Z();O.on("initialized",function(){if(N.children().length<=1)for(var a in mistvideo[c].source){var b=mistvideo[c].source[a],d=UI.humanMime(b.type);N.append($("<option>").val(a).text(d?d+" @ "+
|
||||||
b.url.substring(b.url.length-b.relurl.length,0):UI.format.capital(b.type)+" @ "+b.url.substring(b.url.length-b.relurl.length,0)))}a=mistvideo[c].embedded[mistvideo[c].embedded.length-1];d=UI.humanMime(a.player.options.source.type);X.html("You're watching "+(d?d+" <span class=description>("+a.player.options.source.type+")</span>":UI.format.capital(a.player.options.source.type))+" through "+mistplayers[a.selectedPlayer].name+".")});d[0].removeChild(a)}};na();g=$("<div>").append($("<h3>").text("Meta information"));
|
b.url.substring(b.url.length-b.relurl.length,0):UI.format.capital(b.type)+" @ "+b.url.substring(b.url.length-b.relurl.length,0)))}a=mistvideo[c].embedded[mistvideo[c].embedded.length-1];d=UI.humanMime(a.player.options.source.type);Y.html("You're watching "+(d?d+" <span class=description>("+a.player.options.source.type+")</span>":UI.format.capital(a.player.options.source.type))+" through "+mistplayers[a.selectedPlayer].name+".")});d[0].removeChild(a)}};oa();g=$("<div>").append($("<h3>").text("Meta information"));
|
||||||
var R=$("<span>").text("Loading..");g.append(R);I.append(g);$.ajax({type:"GET",url:L+"json_"+G+".js",success:function(a){var c=a.meta;if(!c||!c.tracks)R.html("No meta information available.");else{a=[];a.push({label:"Type",type:"span",value:c.live?"Live":"Pre-recorded (VoD)"});"format"in c&&a.push({label:"Format",type:"span",value:c.format});c.live&&a.push({label:"Buffer window",type:"span",value:UI.format.addUnit(c.buffer_window,"ms")});var b={audio:{vheader:"Audio",labels:["Codec","Duration","Peak bitrate",
|
var S=$("<span>").text("Loading..");g.append(S);J.append(g);$.ajax({type:"GET",url:M+"json_"+H+".js",success:function(a){var c=a.meta;if(!c||!c.tracks)S.html("No meta information available.");else{a=[];a.push({label:"Type",type:"span",value:c.live?"Live":"Pre-recorded (VoD)"});"format"in c&&a.push({label:"Format",type:"span",value:c.format});c.live&&a.push({label:"Buffer window",type:"span",value:UI.format.addUnit(c.buffer_window,"ms")});var b={audio:{vheader:"Audio",labels:["Codec","Duration","Peak bitrate",
|
||||||
"Channels","Samplerate","Language"],content:[]},video:{vheader:"Video",labels:["Codec","Duration","Peak bitrate","Size","Framerate","Language"],content:[]},subtitle:{vheader:"Subtitles",labels:["Codec","Duration","Peak bitrate","Language"],content:[]}},d=Object.keys(c.tracks);d.sort(function(a,c){a=a.split("_").pop();c=c.split("_").pop();return a-c});for(var e in d){var g=d[e],f=c.tracks[g];switch(f.type){case "audio":b.audio.content.push({header:"Track "+g.split("_").pop(),body:[f.codec,UI.format.duration((f.lastms-
|
"Channels","Samplerate","Language"],content:[]},video:{vheader:"Video",labels:["Codec","Duration","Peak bitrate","Size","Framerate","Language"],content:[]},subtitle:{vheader:"Subtitles",labels:["Codec","Duration","Peak bitrate","Language"],content:[]}},d=Object.keys(c.tracks);d.sort(function(a,c){a=a.split("_").pop();c=c.split("_").pop();return a-c});for(var g in d){var e=d[g],f=c.tracks[e];switch(f.type){case "audio":b.audio.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"),"lang"in f?f.lang:"unknown"]});break;case "video":b.video.content.push({header:"Track "+g.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,
|
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"),"lang"in f?f.lang:"unknown"]});break;case "video":b.video.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"),"lang"in f?f.lang:"unknown"]});break;case "subtitle":b.subtitle.content.push({header:"Track "+g.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),"lang"in f?f.lang:"unknown"]})}}e=["audio","video","subtitle"];c=$("<div>").css({display:"flex",
|
1),UI.format.addUnit(f.width,"x ")+UI.format.addUnit(f.height,"px"),UI.format.addUnit(UI.format.number(f.fpks/1E3),"fps"),"lang"in f?f.lang:"unknown"]});break;case "subtitle":b.subtitle.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),"lang"in f?f.lang:"unknown"]})}}g=["audio","video","subtitle"];c=$("<div>").css({display:"flex",
|
||||||
"flex-flow":"row wrap","font-size":"0.9em"});for(g in e)b[e[g]].content.length&&c.append(UI.buildVheaderTable(b[e[g]]).css("width","auto"));a.push($("<span>").text("Tracks:"));a.push(c);R.html(UI.buildUI(a))}},error:function(){R.html("Error while retrieving stream info.")}});break;case "Embed":""==c&&UI.navTo("Streams");f="";-1==c.indexOf("+")&&(f=$("<button>").addClass("settings").text("Settings").click(function(){UI.navto("Edit",c)}));d.html($("<div>").addClass("bigbuttons").append(f).append($("<button>").text("Preview").addClass("preview").click(function(){UI.navto("Preview",
|
"flex-flow":"row wrap","font-size":"0.9em"});for(e in g)b[g[e]].content.length&&c.append(UI.buildVheaderTable(b[g[e]]).css("width","auto"));a.push($("<span>").text("Tracks:"));a.push(c);S.html(UI.buildUI(a))}},error:function(){S.html("Error while retrieving stream info.")}});break;case "Embed":""==c&&UI.navTo("Streams");f="";-1==c.indexOf("+")&&(f=$("<button>").addClass("settings").text("Settings").click(function(){UI.navto("Edit",c)}));d.html($("<div>").addClass("bigbuttons").append(f).append($("<button>").text("Preview").addClass("preview").click(function(){UI.navto("Preview",
|
||||||
c)})).append($("<button>").addClass("cancel").addClass("return").text("Return").click(function(){UI.navto("Streams")}))).append($("<h2>").text('Embed "'+c+'"'));var S=$("<span>");d.append(S);G=encodeURIComponent(c);f=parseURL(mist.user.host);e={"":{port:":8080"}};for(g in mist.data.config.protocols){b=mist.data.config.protocols[g];if("HTTP"==b.connector||"HTTP.exe"==b.connector)e[""].port=b.port?":"+b.port:":8080";if("HTTPS"==b.connector||"HTTPS.exe"==b.connector)e.s={},e.s.port=b.port?":"+b.port:
|
c)})).append($("<button>").addClass("cancel").addClass("return").text("Return").click(function(){UI.navto("Streams")}))).append($("<h2>").text('Embed "'+c+'"'));var T=$("<span>");d.append(T);H=encodeURIComponent(c);f=parseURL(mist.user.host);b={"":{port:":8080"}};for(g in mist.data.config.protocols){r=mist.data.config.protocols[g];if("HTTP"==r.connector||"HTTP.exe"==r.connector)b[""].port=r.port?":"+r.port:":8080";if("HTTPS"==r.connector||"HTTPS.exe"==r.connector)b.s={},b.s.port=r.port?":"+r.port:
|
||||||
":4433"}var H=L="http://"+f.host+e[""].port+"/";if(otherhost.host||otherhost.https)H=(otherhost.https&&"s"in e?"https://":"http://")+(otherhost.host?otherhost.host:f.host)+(otherhost.https&&"s"in e?e.s.port:e[""].port)+"/";var Z={forcePlayer:"",forceType:"",controls:!0,autoplay:!0,loop:!1,width:"",height:"",maxwidth:"",maxheight:"",poster:"",urlappend:"",setTracks:{}},o=$.extend({},Z);g=UI.stored.getOpts();"embedoptions"in g&&(o=$.extend(o,g.embedoptions,!0),"object"!=typeof o.setTracks&&(o.setTracks=
|
":4433"}var I=M="http://"+f.host+b[""].port+"/";if(otherhost.host||otherhost.https)I=(otherhost.https&&"s"in b?"https://":"http://")+(otherhost.host?otherhost.host:f.host)+(otherhost.https&&"s"in b?b.s.port:b[""].port)+"/";var aa={forcePlayer:"",forceType:"",controls:!0,autoplay:!0,loop:!1,width:"",height:"",maxwidth:"",maxheight:"",poster:"",urlappend:"",setTracks:{}},o=$.extend({},aa);g=UI.stored.getOpts();"embedoptions"in g&&(o=$.extend(o,g.embedoptions,!0),"object"!=typeof o.setTracks&&(o.setTracks=
|
||||||
{}));g={};switch(o.controls){case "stock":g.controls="stock";break;case !0:g.controls=1;break;case !1:g.controls=0}var v=function(){function a(c){switch(typeof c){case "string":return $.isNumeric(c)?c:'"'+c+'"';case "object":return JSON.stringify(c);default:return c}}UI.stored.saveOpt("embedoptions",o);for(var b=c+"_",d=12,e="";d--;){var g;g=Math.floor(Math.random()*62);g=g<10?g:g<36?String.fromCharCode(g+55):String.fromCharCode(g+61);e=e+g}var b=b+e,d=['target: document.getElementById("'+b+'")'],
|
{}));g={};switch(o.controls){case "stock":g.controls="stock";break;case !0:g.controls=1;break;case !1:g.controls=0}var v=function(){function a(c){switch(typeof c){case "string":return $.isNumeric(c)?c:'"'+c+'"';case "object":return JSON.stringify(c);default:return c}}UI.stored.saveOpt("embedoptions",o);for(var b=c+"_",d=12,g="";d--;){var f;f=Math.floor(Math.random()*62);f=f<10?f:f<36?String.fromCharCode(f+55):String.fromCharCode(f+61);g=g+f}var b=b+g,d=['target: document.getElementById("'+b+'")'],
|
||||||
f;for(f in o)o[f]!=Z[f]&&(typeof o[f]!="object"||JSON.stringify(o[f])!=JSON.stringify(Z[f]))&&d.push(f+": "+a(o[f]));f=[];f.push('<div class="mistvideo" id="'+b+'">');f.push(" <noscript>");f.push(' <a href="'+H+G+'.html" target="_blank">');f.push(" Click here to play this video");f.push(" </a>");f.push(" </noscript>");f.push(" <script>");f.push(" var a = function(){");f.push(' mistPlay("'+c+'",{');f.push(" "+d.join(",\n "));f.push(" });");f.push(" };");
|
e;for(e in o)o[e]!=aa[e]&&(typeof o[e]!="object"||JSON.stringify(o[e])!=JSON.stringify(aa[e]))&&d.push(e+": "+a(o[e]));e=[];e.push('<div class="mistvideo" id="'+b+'">');e.push(" <noscript>");e.push(' <a href="'+I+H+'.html" target="_blank">');e.push(" Click here to play this video");e.push(" </a>");e.push(" </noscript>");e.push(" <script>");e.push(" var a = function(){");e.push(' mistPlay("'+c+'",{');e.push(" "+d.join(",\n "));e.push(" });");e.push(" };");
|
||||||
f.push(" if (!window.mistplayers) {");f.push(' var p = document.createElement("script");');f.push(' p.src = "'+H+'player.js"');f.push(" document.head.appendChild(p);");f.push(" p.onload = a;");f.push(" }");f.push(" else { a(); }");f.push(" <\/script>");f.push("</div>");return f.join("\n")},aa=$("<span>").text("Loading.."),b=v(o),J=$("<div>").text("Loading..").css("display","flex"),oa="";"s"in e&&(oa=UI.buildUI([{label:"Use HTTPS",type:"checkbox","function":function(){if($(this).getval()!=
|
e.push(" if (!window.mistplayers) {");e.push(' var p = document.createElement("script");');e.push(' p.src = "'+I+'player.js"');e.push(" document.head.appendChild(p);");e.push(" p.onload = a;");e.push(" }");e.push(" else { a(); }");e.push(" <\/script>");e.push("</div>");return e.join("\n")},ba=$("<span>").text("Loading.."),r=v(o),K=$("<div>").text("Loading..").css("display","flex"),pa="";"s"in b&&(pa=UI.buildUI([{label:"Use HTTPS",type:"checkbox","function":function(){if($(this).getval()!=
|
||||||
otherhost.https){otherhost.https=$(this).getval();UI.navto("Embed",c)}},value:otherhost.https}]).find("label"));S.append($("<span>").addClass("input_container").append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Use a different host:")).append($("<span>").addClass("field_container").append($("<input>").attr("type","text").addClass("field").val(otherhost.host?otherhost.host:f.host)).append($("<span>").addClass("unit").append($("<button>").text("Apply").click(function(){otherhost.host=
|
otherhost.https){otherhost.https=$(this).getval();UI.navto("Embed",c)}},value:otherhost.https}]).find("label"));T.append($("<span>").addClass("input_container").append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Use a different host:")).append($("<span>").addClass("field_container").append($("<input>").attr("type","text").addClass("field").val(otherhost.host?otherhost.host:f.host)).append($("<span>").addClass("unit").append($("<button>").text("Apply").click(function(){otherhost.host=
|
||||||
$(this).closest("label").find("input").val();UI.navto("Embed",c)}))))).append(oa)).append(UI.buildUI([$("<h3>").text("Urls"),{label:"Stream info json",type:"str",value:H+"json_"+G+".js",readonly:!0,clipboard:!0,help:"Information about this stream as a json page."},{label:"Stream info script",type:"str",value:H+"info_"+G+".js",readonly:!0,clipboard:!0,help:"This script loads information about this stream into a mistvideo javascript object."},{label:"HTML page",type:"str",value:H+G+".html",readonly:!0,
|
$(this).closest("label").find("input").val();UI.navto("Embed",c)}))))).append(pa)).append(UI.buildUI([$("<h3>").text("Urls"),{label:"Stream info json",type:"str",value:I+"json_"+H+".js",readonly:!0,clipboard:!0,help:"Information about this stream as a json page."},{label:"Stream info script",type:"str",value:I+"info_"+H+".js",readonly:!0,clipboard:!0,help:"This script loads information about this stream into a mistvideo javascript object."},{label:"HTML page",type:"str",value:I+H+".html",readonly:!0,
|
||||||
qrcode:!0,clipboard:!0,help:"A basic html containing the embedded stream."},$("<h3>").text("Embed code"),{label:"Embed code",type:"textarea",value:b,rows:b.split("\n").length+3,readonly:!0,classes:["embed_code"],clipboard:!0,help:"Include this code on your webpage to embed the stream. The options below can be used to configure how your content is displayed."},$("<h4>").text("Embed code options (optional)").css("margin-top",0),{type:"help",help:"Use these controls to customise what this embedded video will look like.<br>Not all players have all of these options."},
|
qrcode:!0,clipboard:!0,help:"A basic html containing the embedded stream."},$("<h3>").text("Embed code"),{label:"Embed code",type:"textarea",value:r,rows:r.split("\n").length+3,readonly:!0,classes:["embed_code"],clipboard:!0,help:"Include this code on your webpage to embed the stream. The options below can be used to configure how your content is displayed."},$("<h4>").text("Embed code options (optional)").css("margin-top",0),{type:"help",help:"Use these controls to customise what this embedded video will look like.<br>Not all players have all of these options."},
|
||||||
{label:"Force player",type:"select",select:[["","Automatic"]],pointer:{main:o,index:"forcePlayer"},classes:["forcePlayer"],"function":function(){o.forcePlayer=$(this).getval();$(".embed_code").setval(v(o))},help:"Only use this particular player."},{label:"Force source",type:"select",select:[["","Automatic"]],pointer:{main:o,index:"forceType"},classes:["forceType"],"function":function(){o.forceType=$(this).getval();$(".embed_code").setval(v(o))},help:"Only use this particular source."},{label:"Controls",
|
{label:"Force player",type:"select",select:[["","Automatic"]],pointer:{main:o,index:"forcePlayer"},classes:["forcePlayer"],"function":function(){o.forcePlayer=$(this).getval();$(".embed_code").setval(v(o))},help:"Only use this particular player."},{label:"Force source",type:"select",select:[["","Automatic"]],pointer:{main:o,index:"forceType"},classes:["forceType"],"function":function(){o.forceType=$(this).getval();$(".embed_code").setval(v(o))},help:"Only use this particular source."},{label:"Controls",
|
||||||
type:"select",select:[["1","MistServer Controls"],["stock","Player controls"],["0","None"]],pointer:{main:g,index:"controls"},"function":function(){o.controls=$(this).getval()==1;switch($(this).getval()){case 0:o.controls=false;break;case 1:o.controls=true;break;case "stock":o.controls="stock"}$(".embed_code").setval(v(o))},help:"The type of controls that should be shown."},{label:"Autoplay",type:"checkbox",pointer:{main:o,index:"autoplay"},"function":function(){o.autoplay=$(this).getval();$(".embed_code").setval(v(o))},
|
type:"select",select:[["1","MistServer Controls"],["stock","Player controls"],["0","None"]],pointer:{main:g,index:"controls"},"function":function(){o.controls=$(this).getval()==1;switch($(this).getval()){case 0:o.controls=false;break;case 1:o.controls=true;break;case "stock":o.controls="stock"}$(".embed_code").setval(v(o))},help:"The type of controls that should be shown."},{label:"Autoplay",type:"checkbox",pointer:{main:o,index:"autoplay"},"function":function(){o.autoplay=$(this).getval();$(".embed_code").setval(v(o))},
|
||||||
help:"Whether or not the video should play as the page is loaded."},{label:"Loop",type:"checkbox",pointer:{main:o,index:"loop"},"function":function(){o.loop=$(this).getval();$(".embed_code").setval(v(o))},help:"If the video should restart when the end is reached."},{label:"Force width",type:"int",min:0,unit:"px",pointer:{main:o,index:"width"},"function":function(){o.width=$(this).getval();$(".embed_code").setval(v(o))},help:"Enforce a fixed width."},{label:"Force height",type:"int",min:0,unit:"px",
|
help:"Whether or not the video should play as the page is loaded."},{label:"Loop",type:"checkbox",pointer:{main:o,index:"loop"},"function":function(){o.loop=$(this).getval();$(".embed_code").setval(v(o))},help:"If the video should restart when the end is reached."},{label:"Force width",type:"int",min:0,unit:"px",pointer:{main:o,index:"width"},"function":function(){o.width=$(this).getval();$(".embed_code").setval(v(o))},help:"Enforce a fixed width."},{label:"Force height",type:"int",min:0,unit:"px",
|
||||||
pointer:{main:o,index:"height"},"function":function(){o.height=$(this).getval();$(".embed_code").setval(v(o))},help:"Enforce a fixed height."},{label:"Maximum width",type:"int",min:0,unit:"px",pointer:{main:o,index:"maxwidth"},"function":function(){o.maxwidth=$(this).getval();$(".embed_code").setval(v(o))},help:"The maximum width this video can use."},{label:"Maximum height",type:"int",min:0,unit:"px",pointer:{main:o,index:"maxheight"},"function":function(){o.maxheight=$(this).getval();$(".embed_code").setval(v(o))},
|
pointer:{main:o,index:"height"},"function":function(){o.height=$(this).getval();$(".embed_code").setval(v(o))},help:"Enforce a fixed height."},{label:"Maximum width",type:"int",min:0,unit:"px",pointer:{main:o,index:"maxwidth"},"function":function(){o.maxwidth=$(this).getval();$(".embed_code").setval(v(o))},help:"The maximum width this video can use."},{label:"Maximum height",type:"int",min:0,unit:"px",pointer:{main:o,index:"maxheight"},"function":function(){o.maxheight=$(this).getval();$(".embed_code").setval(v(o))},
|
||||||
help:"The maximum height this video can use."},{label:"Poster",type:"str",pointer:{main:o,index:"poster"},"function":function(){o.poster=$(this).getval();$(".embed_code").setval(v(o))},help:"URL to an image that is displayed when the video is not playing."},{label:"Video URL addition",type:"str",pointer:{main:o,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(){o.urlappend=
|
help:"The maximum height this video can use."},{label:"Poster",type:"str",pointer:{main:o,index:"poster"},"function":function(){o.poster=$(this).getval();$(".embed_code").setval(v(o))},help:"URL to an image that is displayed when the video is not playing."},{label:"Video URL addition",type:"str",pointer:{main:o,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(){o.urlappend=
|
||||||
$(this).getval();$(".embed_code").setval(v(o))}},{label:"Preselect tracks",type:"DOMfield",DOMfield:J,help:"Pre-select these tracks."},$("<h3>").text("Protocol stream urls"),aa]));$.ajax({type:"GET",url:H+"json_"+G+".js",success:function(a){var c=[],b=S.find(".forceType"),d;for(d in a.source){var e=a.source[d],f=UI.humanMime(e.type);c.push({label:f?f+" <span class=description>("+e.type+")</span>":UI.format.capital(e.type),type:"str",value:e.url,readonly:true,qrcode:true,clipboard:true});f=UI.humanMime(e.type);
|
$(this).getval();$(".embed_code").setval(v(o))}},{label:"Preselect tracks",type:"DOMfield",DOMfield:K,help:"Pre-select these tracks."},$("<h3>").text("Protocol stream urls"),ba]));$.ajax({type:"GET",url:I+"json_"+H+".js",success:function(a){var c=[],b=T.find(".forceType"),d;for(d in a.source){var g=a.source[d],e=UI.humanMime(g.type);c.push({label:e?e+" <span class=description>("+g.type+")</span>":UI.format.capital(g.type),type:"str",value:g.url,readonly:true,qrcode:true,clipboard:true});e=UI.humanMime(g.type);
|
||||||
b.append($("<option>").text(f?f+" ("+e.type+")":UI.format.capital(e.type)).val(e.type))}aa.html(UI.buildUI(c));J.html("");c={};for(d in a.meta.tracks){b=a.meta.tracks[d];b.type!="audio"&&b.type!="video"||(b.type in c?c[b.type].push([b.trackid,UI.format.capital(b.type)+" track "+(c[b.type].length+1)]):c[b.type]=[["",UI.format.capital(b.type)+" track 1"]])}if(Object.keys(c).length){J.closest("label").show();for(d in c){a=$("<select>").attr("data-type",d).css("flex-grow","1").change(function(){$(this).val()==
|
b.append($("<option>").text(e?e+" ("+g.type+")":UI.format.capital(g.type)).val(g.type))}ba.html(UI.buildUI(c));K.html("");c={};for(d in a.meta.tracks){b=a.meta.tracks[d];b.type!="audio"&&b.type!="video"||(b.type in c?c[b.type].push([b.trackid,UI.format.capital(b.type)+" track "+(c[b.type].length+1)]):c[b.type]=[["",UI.format.capital(b.type)+" track 1"]])}if(Object.keys(c).length){K.closest("label").show();for(d in c){a=$("<select>").attr("data-type",d).css("flex-grow","1").change(function(){$(this).val()==
|
||||||
""?delete o.setTracks[$(this).attr("data-type")]:o.setTracks[$(this).attr("data-type")]=$(this).val();$(".embed_code").setval(v(o))});J.append(a);c[d].push([-1,"No "+d]);for(var g in c[d])a.append($("<option>").val(c[d][g][0]).text(c[d][g][1]));if(d in o.setTracks){a.val(o.setTracks[d]);if(a.val()==null){a.val("");delete o.setTracks[d];$(".embed_code").setval(v(o))}}}}else J.closest("label").hide()},error:function(){aa.html("Error while retrieving stream info.");J.closest("label").hide();o.setTracks=
|
""?delete o.setTracks[$(this).attr("data-type")]:o.setTracks[$(this).attr("data-type")]=$(this).val();$(".embed_code").setval(v(o))});K.append(a);c[d].push([-1,"No "+d]);for(var f in c[d])a.append($("<option>").val(c[d][f][0]).text(c[d][f][1]));if(d in o.setTracks){a.val(o.setTracks[d]);if(a.val()==null){a.val("");delete o.setTracks[d];$(".embed_code").setval(v(o))}}}}else K.closest("label").hide()},error:function(){ba.html("Error while retrieving stream info.");K.closest("label").hide();o.setTracks=
|
||||||
{}}});g=document.createElement("script");g.src=L+"player.js";document.head.appendChild(g);g.onload=function(){var a=S.find(".forcePlayer"),c;for(c in mistplayers)a.append($("<option>").text(mistplayers[c].name).val(c));document.head.removeChild(this)};g.onerror=function(){document.head.removeChild(this)};break;case "Push":var B=$("<div>").text("Loading..");d.append(B);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=
|
{}}});g=document.createElement("script");g.src=M+"player.js";document.head.appendChild(g);g.onload=function(){var a=T.find(".forcePlayer"),c;for(c in mistplayers)a.append($("<option>").text(mistplayers[c].name).val(c));document.head.removeChild(this)};g.onerror=function(){document.head.removeChild(this)};break;case "Push":var B=$("<div>").text("Loading..");d.append(B);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(f,g){var h=$("<span>");f.length>=4&&f[2]!=f[3]?h.append($("<span>").text(f[2])).append($("<span>").html("»").addClass("unit").css("margin","0 0.5em")).append($("<span>").text(f[3])):h.append($("<span>").text(f[2]));var i=$("<td>").append($("<button>").text(g=="Automatic"?"Remove":"Stop").click(function(){if(confirm("Are you sure you want to "+
|
true,e;for(e in b.push_list)if(a.indexOf(b.push_list[e][0])>-1){d=false;break}}else d=true;if(d)for(e in a)g.find("tr[data-pushid="+a[e]+"]").remove();else c()},{push_list:1})},1E3)}function b(e,f){var h=$("<span>");e.length>=4&&e[2]!=e[3]?h.append($("<span>").text(e[2])).append($("<span>").html("»").addClass("unit").css("margin","0 0.5em")).append($("<span>").text(e[3])):h.append($("<span>").text(e[2]));var i=$("<td>").append($("<button>").text(f=="Automatic"?"Remove":"Stop").click(function(){if(confirm("Are you sure you want to "+
|
||||||
$(this).text().toLowerCase()+" this push?\n"+f[1]+" to "+f[2])){var a=$(this).closest("tr");a.html($("<td colspan=99>").html($("<span>").addClass("red").text(g=="Automatic"?"Removing..":"Stopping..")));g=="Automatic"?mist.send(function(){a.remove()},{push_auto_remove:{stream:f[1],target:f[2]}}):mist.send(function(){c([f[0]])},{push_stop:[f[0]]})}}));g=="Automatic"&&i.append($("<button>").text("Stop pushes").click(function(){if(confirm('Are you sure you want to stop all pushes matching \n"'+f[1]+" to "+
|
$(this).text().toLowerCase()+" this push?\n"+e[1]+" to "+e[2])){var a=$(this).closest("tr");a.html($("<td colspan=99>").html($("<span>").addClass("red").text(f=="Automatic"?"Removing..":"Stopping..")));f=="Automatic"?mist.send(function(){a.remove()},{push_auto_remove:{stream:e[1],target:e[2]}}):mist.send(function(){c([e[0]])},{push_stop:[e[0]]})}}));f=="Automatic"&&i.append($("<button>").text("Stop pushes").click(function(){if(confirm('Are you sure you want to stop all pushes matching \n"'+e[1]+" to "+
|
||||||
f[2]+'"?'+(d.wait!=0?"\n\nRetrying is enabled. You'll probably want to set that to 0.":""))){var b=$(this);b.text("Stopping pushes..");var g=[],h;for(h in a.push_list)if(f[1]==a.push_list[h][1]&&f[2]==a.push_list[h][2]){g.push(a.push_list[h][0]);e.find("tr[data-pushid="+a.push_list[h][0]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}mist.send(function(){b.text("Stop pushes");c(g)},{push_stop:g,push_settings:{wait:0}})}}));return $("<tr>").attr("data-pushid",
|
e[2]+'"?'+(d.wait!=0?"\n\nRetrying is enabled. You'll probably want to set that to 0.":""))){var b=$(this);b.text("Stopping pushes..");var f=[],h;for(h in a.push_list)if(e[1]==a.push_list[h][1]&&e[2]==a.push_list[h][2]){f.push(a.push_list[h][0]);g.find("tr[data-pushid="+a.push_list[h][0]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}mist.send(function(){b.text("Stop pushes");c(f)},{push_stop:f,push_settings:{wait:0}})}}));return $("<tr>").attr("data-pushid",
|
||||||
f[0]).append($("<td>").text(f[1])).append($("<td>").append(h.children())).append(i)}B.html("");var d=a.push_settings;d||(d={});B.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"},
|
e[0]).append($("<td>").text(e[1])).append($("<td>").append(h.children())).append(i)}B.html("");var d=a.push_settings;d||(d={});B.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();
|
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 g=$("<table>").append($("<tr>").append($("<th>").text("Stream")).append($("<th>").text("Target")).append($("<th>"))),e=g.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"));B.append($("<h3>").text("Automatic pushes")).append($("<button>").text("Add an automatic push").click(function(){UI.navto("Start Push","auto")}));f.find("tr").length==1?B.append($("<div>").text("No automatic pushes have been configured.").addClass("text").css("margin-top","0.5em")):B.append(f);
|
if("push_list"in a)for(var f in a.push_list)g.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"));B.append($("<h3>").text("Automatic pushes")).append($("<button>").text("Add an automatic push").click(function(){UI.navto("Start Push","auto")}));e.find("tr").length==1?B.append($("<div>").text("No automatic pushes have been configured.").addClass("text").css("margin-top","0.5em")):B.append(e);
|
||||||
B.append($("<h3>").text("Pushes")).append($("<button>").text("Start a push").click(function(){UI.navto("Start Push")}));if(e.find("tr").length==1)B.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]);
|
B.append($("<h3>").text("Pushes")).append($("<button>").text("Start a push").click(function(){UI.navto("Start Push")}));if(g.find("tr").length==1)B.append($("<div>").text("No pushes are active.").addClass("text").css("margin-top","0.5em"));else{var e=[],h=[],i=$("<select>").css("margin-left","0.5em").append($("<option>").text("Any stream").val("")),j=$("<select>").css("margin-left","0.5em").append($("<option>").text("Any target").val(""));for(f in a.push_list){e.indexOf(a.push_list[f][1])==-1&&e.push(a.push_list[f][1]);
|
||||||
h.indexOf(a.push_list[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]));B.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..")));
|
h.indexOf(a.push_list[f][2])==-1&&h.push(a.push_list[f][2])}e.sort();h.sort();for(f in e)i.append($("<option>").text(e[f]));for(f in h)j.append($("<option>").text(h[f]));B.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});g.find("tr:not(:first-child)").html($("<td colspan=99>").append($("<span>").addClass("red").text("Stopping..")));
|
||||||
$(this).remove()}})).append($("<label>").css("margin-left","1em").append($("<span>").text("Stop all pushes that match: ").css("font-size","0.9em")).append(i).append($("<span>").css("margin-left","0.5em").text("and").css("font-size","0.9em")).append(j).append($("<button>").css("margin-left","0.5em").text("Apply").click(function(){var 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==""||
|
$(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 e={},f;for(f 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});
|
a.push_list[f][1]==b)&&(d==""||a.push_list[f][2]==d))e[a.push_list[f][0]]=a.push_list[f];if(Object.keys(e).length==0)return alert("No matching pushes.");b="Are you sure you want to stop these pushes?\n\n";for(f in e)b=b+(e[f][1]+" to "+e[f][2]+"\n");if(confirm(b)){e=Object.keys(e);mist.send(function(){c(e)},{push_stop:e});for(f in e)g.find("tr[data-pushid="+e[f]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}}))).append(g)}},{push_settings:1,push_list:1,push_auto_list:1});
|
||||||
break;case "Start Push":if(!("capabilities"in mist.data)){d.append("Loading Mist capabilities..");mist.send(function(){UI.navto("Start Push",c)},{capabilities:1});return}var s,ba=function(){var a=[],b;for(b in mist.data.capabilities.connectors){var f=mist.data.capabilities.connectors[b];"push_urls"in f&&(a=a.concat(f.push_urls))}c=="auto"&&d.find("h2").text("Add automatic push");var e={};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>",
|
break;case "Start Push":if(!("capabilities"in mist.data)){d.append("Loading Mist capabilities..");mist.send(function(){UI.navto("Start Push",c)},{capabilities:1});return}var t,ca=function(){var a=[],b;for(b in mist.data.capabilities.connectors){var e=mist.data.capabilities.connectors[b];"push_urls"in e&&(a=a.concat(e.push_urls))}c=="auto"&&d.find("h2").text("Add automatic push");var g={};d.append(UI.buildUI([{label:"Stream name",type:"str",help:"This may either be a full stream name, a partial wildcard stream name, or a full wildcard stream name.<br>For example, given the stream <i>a</i> you can use:<ul><li><i>a</i>: the stream configured as <i>a</i></li><li><i>a+</i>: all streams configured as <i>a</i> with a wildcard behind it, but not <i>a</i> itself</li><li><i>a+b</i>: only the version of stream <i>a</i> that has wildcard <i>b</i></li></ul>",
|
||||||
pointer:{main:e,index:"stream"},validate:["required",function(a){a=a.split("+");a=a[0];return a in mist.data.streams?false:{msg:"'"+a+"' is not a stream name.",classes:["red"]}}],datalist:s,LTSonly:1},{label:"Target",type:"str",help:"Where the stream will be pushed to.<br>Valid formats:<ul><li>"+a.join("</li><li>")+"</li></ul> Valid text replacements:<ul><li>$stream - inserts the stream name used to push to MistServer</li><li>$day - inserts the current day number</li><li>$month - inserts the current month number</li><li>$year - inserts the current year number</li><li>$hour - inserts the hour timestamp when stream was received</li><li>$minute - inserts the minute timestamp the stream was received</li><li>$seconds - inserts the seconds timestamp when the stream was received</li><li>$datetime - inserts $year.$month.$day.$hour.$minute.$seconds timestamp when the stream was received</li>",
|
pointer:{main:g,index:"stream"},validate:["required",function(a){a=a.split("+");a=a[0];return a in mist.data.streams?false:{msg:"'"+a+"' is not a stream name.",classes:["red"]}}],datalist:t,LTSonly:1},{label:"Target",type:"str",help:"Where the stream will be pushed to.<br>Valid formats:<ul><li>"+a.join("</li><li>")+"</li></ul> Valid text replacements:<ul><li>$stream - inserts the stream name used to push to MistServer</li><li>$day - inserts the current day number</li><li>$month - inserts the current month number</li><li>$year - inserts the current year number</li><li>$hour - inserts the hour timestamp when stream was received</li><li>$minute - inserts the minute timestamp the stream was received</li><li>$seconds - inserts the seconds timestamp when the stream was received</li><li>$datetime - inserts $year.$month.$day.$hour.$minute.$seconds timestamp when the stream was received</li>",
|
||||||
pointer:{main:e,index:"target"},validate:["required",function(c){for(var b in a)if(mist.inputMatch(a[b],c))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"]=e;mist.send(function(){UI.navto("Push")},a)}}]}]))};mist.data.LTS?
|
pointer:{main:g,index:"target"},validate:["required",function(b){for(var c in a)if(mist.inputMatch(a[c],b))return false;return{msg:"Does not match a valid target.<br>Valid formats:<ul><li>"+a.join("</li><li>")+"</li></ul>",classes:["red"]}}],LTSonly:1},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Push")}},{type:"save",label:"Save","function":function(){var a={};a[c=="auto"?"push_auto_add":"push_start"]=g;mist.send(function(){UI.navto("Push")},a)}}]}]))};mist.data.LTS?
|
||||||
mist.send(function(a){(s=a.active_streams)||(s=[]);var a=[],c;for(c in s)s[c].indexOf("+")!=-1&&a.push(s[c].replace(/\+.*/,"")+"+");s=s.concat(a);var b=0,d=0;for(c in mist.data.streams){s.push(c);if(mist.inputMatch(UI.findInput("Folder").source_match,mist.data.streams[c].source)){s.push(c+"+");mist.send(function(a,c){var f=c.stream,e;for(e in a.browse.files)for(var g in mist.data.capabilities.inputs)g.indexOf("Buffer")>=0||(g.indexOf("Folder")>=0||g.indexOf("Buffer.exe")>=0||g.indexOf("Folder.exe")>=
|
mist.send(function(a){(t=a.active_streams)||(t=[]);var a=[],b;for(b in t)t[b].indexOf("+")!=-1&&a.push(t[b].replace(/\+.*/,"")+"+");t=t.concat(a);var c=0,d=0;for(b in mist.data.streams){t.push(b);if(mist.inputMatch(UI.findInput("Folder").source_match,mist.data.streams[b].source)){t.push(b+"+");mist.send(function(a,b){var e=b.stream,g;for(g in a.browse.files)for(var f in mist.data.capabilities.inputs)f.indexOf("Buffer")>=0||(f.indexOf("Folder")>=0||f.indexOf("Buffer.exe")>=0||f.indexOf("Folder.exe")>=
|
||||||
0)||mist.inputMatch(mist.data.capabilities.inputs[g].source_match,"/"+a.browse.files[e])&&s.push(f+"+"+a.browse.files[e]);d++;if(b==d){s=s.filter(function(a,c,b){return b.lastIndexOf(a)===c}).sort();ba()}},{browse:mist.data.streams[c].source},{stream:c});b++}}if(b==d){s=s.filter(function(a,c,b){return b.lastIndexOf(a)===c}).sort();ba()}},{active_streams:1}):(s=Object.keys(mist.data.streams),ba());break;case "Triggers":"triggers"in mist.data.config||(mist.data.config.triggers={});x=$("<tbody>");e=
|
0)||mist.inputMatch(mist.data.capabilities.inputs[f].source_match,"/"+a.browse.files[g])&&t.push(e+"+"+a.browse.files[g]);d++;if(c==d){t=t.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();ca()}},{browse:mist.data.streams[b].source},{stream:b});c++}}if(c==d){t=t.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();ca()}},{active_streams:1}):(t=Object.keys(mist.data.streams),ca());break;case "Triggers":"triggers"in mist.data.config||(mist.data.config.triggers={});x=$("<tbody>");b=
|
||||||
$("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Trigger on").attr("data-sort-type","string").addClass("sorting-asc")).append($("<th>").text("Applies to").attr("data-sort-type","string")).append($("<th>").text("Handler").attr("data-sort-type","string")).append($("<th>")))).append(x);d.append(UI.buildUI([{type:"help",help:"Triggers are a way to react to events that occur inside MistServer. These allow you to block specific users, redirect streams, keep tabs on what is being pushed where, etcetera. For full documentation, please refer to the developer documentation section on the MistServer website."}])).append($("<button>").text("New trigger").click(function(){UI.navto("Edit Trigger")})).append(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(x);d.append(UI.buildUI([{type:"help",help:"Triggers are a way to react to events that occur inside MistServer. These allow you to block specific users, redirect streams, keep tabs on what is being pushed where, etcetera. For full documentation, please refer to the developer documentation section on the MistServer website."}])).append($("<button>").text("New trigger").click(function(){UI.navto("Edit Trigger")})).append(b);
|
||||||
e.stupidtable();e=mist.data.config.triggers;for(g in e)for(f in e[g])b=triggerRewrite(e[g][f]),x.append($("<tr>").attr("data-index",g+","+f).append($("<td>").text(g)).append($("<td>").text("streams"in b?b.streams.join(", "):"")).append($("<td>").text(b.handler)).append($("<td>").html($("<button>").text("Edit").click(function(){UI.navto("Edit Trigger",$(this).closest("tr").attr("data-index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").attr("data-index").split(",");
|
b.stupidtable();b=mist.data.config.triggers;for(g in b)for(f in b[g])r=triggerRewrite(b[g][f]),x.append($("<tr>").attr("data-index",g+","+f).append($("<td>").text(g)).append($("<td>").text("streams"in r?r.streams.join(", "):"")).append($("<td>").text(r.handler)).append($("<td>").html($("<button>").text("Edit").click(function(){UI.navto("Edit Trigger",$(this).closest("tr").attr("data-index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").attr("data-index").split(",");
|
||||||
if(confirm("Are you sure you want to delete this "+a[0]+" trigger?")){mist.data.config.triggers[a[0]].splice(a[1],1);mist.data.config.triggers[a[0]].length==0&&delete mist.data.config.triggers[a[0]];mist.send(function(){UI.navto("Triggers")},{config:mist.data.config})}}))));break;case "Edit Trigger":"triggers"in mist.data.config||(mist.data.config.triggers={});c?(c=c.split(","),g=triggerRewrite(mist.data.config.triggers[c[0]][c[1]]),n={triggeron:c[0],appliesto:g.streams,url:g.handler,async:g.sync,
|
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(","),g=triggerRewrite(mist.data.config.triggers[c[0]][c[1]]),n={triggeron:c[0],appliesto:g.streams,url:g.handler,async:g.sync,
|
||||||
"default":g["default"],params:g.params}):(d.html($("<h2>").text("New Trigger")),n={});d.append(UI.buildUI([{label:"Trigger on",pointer:{main:n,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"],
|
"default":g["default"],params:g.params}):(d.html($("<h2>").text("New Trigger")),n={});d.append(UI.buildUI([{label:"Trigger on",pointer:{main:n,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"],
|
["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"],
|
||||||
|
@ -173,21 +173,21 @@ if(confirm("Are you sure you want to delete this "+a[0]+" trigger?")){mist.data.
|
||||||
$("[name=params]").closest(".UIelement").show();break;default:$("[name=appliesto]").closest(".UIelement").show();$("[name=params]").setval("").closest(".UIelement").hide()}}},{label:"Applies to",pointer:{main:n,index:"appliesto"},help:"For triggers that can apply to specific streams, this value decides what streams they are triggered for. (none checked = always triggered)",type:"checklist",checklist:Object.keys(mist.data.streams),LTSonly:!0},$("<br>"),{label:"Handler (URL or executable)",help:"This can be either an HTTP URL or a full path to an executable.",
|
$("[name=params]").closest(".UIelement").show();break;default:$("[name=appliesto]").closest(".UIelement").show();$("[name=params]").setval("").closest(".UIelement").hide()}}},{label:"Applies to",pointer:{main:n,index:"appliesto"},help:"For triggers that can apply to specific streams, this value decides what streams they are triggered for. (none checked = always triggered)",type:"checklist",checklist:Object.keys(mist.data.streams),LTSonly:!0},$("<br>"),{label:"Handler (URL or executable)",help:"This can be either an HTTP URL or a full path to an executable.",
|
||||||
pointer:{main:n,index:"url"},validate:["required"],type:"str",LTSonly:!0},{label:"Blocking",type:"checkbox",help:"If checked, pauses processing and uses the response of the handler. If the response does not start with 1, true, yes or cont, further processing is aborted. If unchecked, processing is never paused and the response is not checked.",pointer:{main:n,index:"async"},LTSonly:!0},{label:"Parameters",type:"str",help:"The extra data you want this trigger to use.",pointer:{main:n,index:"params"},
|
pointer:{main:n,index:"url"},validate:["required"],type:"str",LTSonly:!0},{label:"Blocking",type:"checkbox",help:"If checked, pauses processing and uses the response of the handler. If the response does not start with 1, true, yes or cont, further processing is aborted. If unchecked, processing is never paused and the response is not checked.",pointer:{main:n,index:"async"},LTSonly:!0},{label:"Parameters",type:"str",help:"The extra data you want this trigger to use.",pointer:{main:n,index:"params"},
|
||||||
LTSonly:!0},{label:"Default response",type:"str",help:"For blocking requests, the default response in case the handler cannot be executed for any reason.",pointer:{main:n,index:"default"},LTSonly:!0},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Triggers")}},{type:"save",label:"Save","function":function(){c&&mist.data.config.triggers[c[0]].splice(c[1],1);var a={handler:n.url,sync:n.async?true:false,streams:typeof n.appliesto=="undefined"?[]:n.appliesto,params:n.params,
|
LTSonly:!0},{label:"Default response",type:"str",help:"For blocking requests, the default response in case the handler cannot be executed for any reason.",pointer:{main:n,index:"default"},LTSonly:!0},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Triggers")}},{type:"save",label:"Save","function":function(){c&&mist.data.config.triggers[c[0]].splice(c[1],1);var a={handler:n.url,sync:n.async?true:false,streams:typeof n.appliesto=="undefined"?[]:n.appliesto,params:n.params,
|
||||||
"default":n["default"]};if(!("triggers"in mist.data.config))mist.data.config.triggers={};n.triggeron in mist.data.config.triggers||(mist.data.config.triggers[n.triggeron]=[]);mist.data.config.triggers[n.triggeron].push(a);mist.send(function(){UI.navto("Triggers")},{config:mist.data.config})}}]}]));$("[name=triggeron]").trigger("change");break;case "Logs":var pa=$("<button>").text("Refresh now").click(function(){$(this).text("Loading..");mist.send(function(){ca();pa.text("Refresh now")})}).css("padding",
|
"default":n["default"]};if(!("triggers"in mist.data.config))mist.data.config.triggers={};n.triggeron in mist.data.config.triggers||(mist.data.config.triggers[n.triggeron]=[]);mist.data.config.triggers[n.triggeron].push(a);mist.send(function(){UI.navto("Triggers")},{config:mist.data.config})}}]}]));$("[name=triggeron]").trigger("change");break;case "Logs":var qa=$("<button>").text("Refresh now").click(function(){$(this).text("Loading..");mist.send(function(){da();qa.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(){ca()})},$(this).val()*1E3)},help:"How often the table below should be updated."},
|
"0.2em 0.5em").css("flex-grow",0);d.append(UI.buildUI([{type:"help",help:"Here you have an overview of all edited settings within MistServer and possible warnings or errors MistServer has encountered. MistServer stores up to 100 logs at a time."},{label:"Refresh every",type:"select",select:[[10,"10 seconds"],[30,"30 seconds"],[60,"minute"],[300,"5 minutes"]],value:30,"function":function(){UI.interval.clear();UI.interval.set(function(){mist.send(function(){da()})},$(this).val()*1E3)},help:"How often the table below should be updated."},
|
||||||
{label:"..or",type:"DOMfield",DOMfield:pa,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})}));x=$("<tbody>").css("font-size","0.9em");d.append($("<table>").addClass("logs").append(x));var ra=function(a){var c=$("<span>").text(a);switch(a){case "WARN":c.addClass("orange");break;case "ERROR":case "FAIL":c.addClass("red")}return c},ca=function(){var a=mist.data.log;if(a){a.length>=
|
{label:"..or",type:"DOMfield",DOMfield:qa,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})}));x=$("<tbody>").css("font-size","0.9em");d.append($("<table>").addClass("logs").append(x));var sa=function(a){var b=$("<span>").text(a);switch(a){case "WARN":b.addClass("orange");break;case "ERROR":case "FAIL":b.addClass("red")}return b},da=function(){var a=mist.data.log;if(a){a.length>=
|
||||||
2&&a[0][0]<a[a.length-1][0]&&a.reverse();x.html("");for(var c in a){var b=$("<span>").addClass("content"),d=a[c][2].split("|"),f;for(f in d)b.append($("<span>").text(d[f]));x.append($("<tr>").html($("<td>").text(UI.format.dateTime(a[c][0],"long")).css("white-space","nowrap")).append($("<td>").html(ra(a[c][1])).css("text-align","center")).append($("<td>").html(b).css("text-align","left")))}}};ca();break;case "Statistics":var C=$("<span>").text("Loading..");d.append(C);var n={graph:"new"},w=mist.stored.get().graphs?
|
2&&a[0][0]<a[a.length-1][0]&&a.reverse();x.html("");for(var b in a){var c=$("<span>").addClass("content"),d=a[b][2].split("|"),e;for(e in d)c.append($("<span>").text(d[e]));x.append($("<tr>").html($("<td>").text(UI.format.dateTime(a[b][0],"long")).css("white-space","nowrap")).append($("<td>").html(sa(a[b][1])).css("text-align","center")).append($("<td>").html(c).css("text-align","left")))}}};da();break;case "Statistics":var C=$("<span>").text("Loading..");d.append(C);var n={graph:"new"},w=mist.stored.get().graphs?
|
||||||
$.extend(!0,{},mist.stored.get().graphs):{},O={};for(g in mist.data.streams)O[g]=!0;for(g in mist.data.active_streams)O[mist.data.active_streams[g]]=!0;var O=Object.keys(O).sort(),da=[];for(g in mist.data.config.protocols)da.push(mist.data.config.protocols[g].connector);da.sort();mist.send(function(){UI.plot.datatype.templates.cpuload.cores=0;for(var a in mist.data.capabilities.cpu)UI.plot.datatype.templates.cpuload.cores=UI.plot.datatype.templates.cpuload.cores+mist.data.capabilities.cpu[a].cores;
|
$.extend(!0,{},mist.stored.get().graphs):{},P={};for(g in mist.data.streams)P[g]=!0;for(g in mist.data.active_streams)P[mist.data.active_streams[g]]=!0;var P=Object.keys(P).sort(),ea=[];for(g in mist.data.config.protocols)ea.push(mist.data.config.protocols[g].connector);ea.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;
|
||||||
C.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:n,index:"graph"},classes:["graph_ids"],"function":function(){if($(this).val()){var a=C.find(".graph_xaxis"),c=C.find(".graph_id");if($(this).val()=="new"){a.children("option").prop("disabled",
|
C.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:n,index:"graph"},classes:["graph_ids"],"function":function(){if($(this).val()){var a=C.find(".graph_xaxis"),b=C.find(".graph_id");if($(this).val()=="new"){a.children("option").prop("disabled",
|
||||||
false);c.setval("Graph "+(Object.keys(w).length+1)).closest("label").show()}else{var b=w[$(this).val()].xaxis;a.children("option").prop("disabled",true).filter('[value="'+b+'"]').prop("disabled",false);c.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:n,index:"id"},classes:["graph_id"],validate:[function(a){return a in w?{msg:"This graph id has already been used. Please enter something else.",
|
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:n,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:n,index:"xaxis"},value:"time",classes:["graph_xaxis"],"function":function(){$s=C.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()+
|
classes:["red"]}:false}]},{label:"Axis type",type:"select",select:[["time","Time line"]],pointer:{main:n,index:"xaxis"},value:"time",classes:["graph_xaxis"],"function":function(){$s=C.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:n,index:"datatype"},classes:["graph_datatype"],"function":function(){$s=C.find(".graph_origin");switch($(this).getval()){case "cpuload":case "memload":$s.find("input[type=radio]").not('[value="total"]').prop("disabled",
|
'"]: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:n,index:"datatype"},classes:["graph_datatype"],"function":function(){$s=C.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:",O],["protocol","The protocol:",da]],pointer:{main:n,index:"origin"},value:["total"],classes:["graph_origin"]},{type:"buttons",buttons:[{label:"Add data set",type:"save","function":function(){var a;if(n.graph=="new"){a=UI.plot.addGraph(n,c);w[a.id]=a;C.find("input.graph_id").val("");
|
true);$s.find('input[type=radio][value="total"]').prop("checked",true);break;default:$s.find("input[type=radio]").prop("disabled",false)}}},{label:"Data origin",type:"radioselect",radioselect:[["total","All"],["stream","The stream:",P],["protocol","The protocol:",ea]],pointer:{main:n,index:"origin"},value:["total"],classes:["graph_origin"]},{type:"buttons",buttons:[{label:"Add data set",type:"save","function":function(){var a;if(n.graph=="new"){a=UI.plot.addGraph(n,b);w[a.id]=a;C.find("input.graph_id").val("");
|
||||||
C.find("select.graph_ids").append($("<option>").text(a.id)).val(a.id).trigger("change")}else a=w[n.graph];var b=UI.plot.datatype.getOptions({datatype:n.datatype,origin:n.origin});a.datasets.push(b);UI.plot.save(a);UI.plot.go(w)}}]}]));var c=$("<div>").addClass("graph_container");d.append(c);var b=C.find("select.graph_ids");for(a in w){var f=UI.plot.addGraph(w[a],c);b.append($("<option>").text(f.id)).val(f.id);var e=[],g;for(g in w[a].datasets){var h=UI.plot.datatype.getOptions({datatype:w[a].datasets[g].datatype,
|
C.find("select.graph_ids").append($("<option>").text(a.id)).val(a.id).trigger("change")}else a=w[n.graph];var c=UI.plot.datatype.getOptions({datatype:n.datatype,origin:n.origin});a.datasets.push(c);UI.plot.save(a);UI.plot.go(w)}}]}]));var b=$("<div>").addClass("graph_container");d.append(b);var c=C.find("select.graph_ids");for(a in w){var e=UI.plot.addGraph(w[a],b);c.append($("<option>").text(e.id)).val(e.id);var g=[],f;for(f in w[a].datasets){var h=UI.plot.datatype.getOptions({datatype:w[a].datasets[f].datatype,
|
||||||
origin:w[a].datasets[g].origin});e.push(h)}f.datasets=e;w[f.id]=f}b.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..");return}var ea=$("<table>"),E=$("<table>"),f={vheader:"CPUs",labels:["Model","Processor speed","Amount of cores","Amount of threads"],content:[]};for(g in mist.data.capabilities.cpu)e=
|
origin:w[a].datasets[f].origin});g.push(h)}e.datasets=g;w[e.id]=e}c.trigger("change");UI.plot.go(w);UI.interval.set(function(){UI.plot.go(w)},1E4)},{active_streams:!0,capabilities:!0});break;case "Server Stats":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});d.append("Loading..");return}var fa=$("<table>"),E=$("<table>"),f={vheader:"CPUs",labels:["Model","Processor speed","Amount of cores","Amount of threads"],content:[]};for(g in mist.data.capabilities.cpu)b=
|
||||||
mist.data.capabilities.cpu[g],f.content.push({header:"CPU #"+(Number(g)+1),body:[e.model,UI.format.addUnit(UI.format.number(e.mhz),"MHz"),e.cores,e.threads]});g=UI.buildVheaderTable(f);var qa=function(){var a=mist.data.capabilities.mem,c=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(c.memory,"%")+")",UI.format.bytes(a.cached*1048576),UI.format.bytes(a.free*
|
mist.data.capabilities.cpu[g],f.content.push({header:"CPU #"+(Number(g)+1),body:[b.model,UI.format.addUnit(UI.format.number(b.mhz),"MHz"),b.cores,b.threads]});g=UI.buildVheaderTable(f);var ra=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);ea.replaceWith(a);ea=a;c={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(c.one/100),UI.format.number(c.five/
|
1048576),UI.format.bytes(a.total*1048576)]},{header:"Swap memory",body:[UI.format.bytes((a.swaptotal-a.swapfree)*1048576),UI.format.addUnit("","N/A"),UI.format.bytes(a.swapfree*1048576),UI.format.bytes(a.swaptotal*1048576)]}]},a=UI.buildVheaderTable(a);fa.replaceWith(a);fa=a;b={vheader:"Load average",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(c.fifteen/100)]}]};c=UI.buildVheaderTable(c);E.replaceWith(c);E=c};qa();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(ea)).append($("<td>").append(E))).append($("<tr>").append($("<td>").append(g).attr("colspan",2))));UI.interval.set(function(){mist.send(function(){qa()},
|
100),UI.format.number(b.fifteen/100)]}]};b=UI.buildVheaderTable(b);E.replaceWith(b);E=b};ra();d.append(UI.buildUI([{type:"help",help:"You can find general server statistics here. Note that memory and CPU usage is for your entire machine, not just MistServer."}])).append($("<table>").css("width","auto").addClass("nolay").append($("<tr>").append($("<td>").append(fa)).append($("<td>").append(E))).append($("<tr>").append($("<td>").append(g).attr("colspan",2))));UI.interval.set(function(){mist.send(function(){ra()},
|
||||||
{capabilities:true})},3E4);break;case "Email for Help":g=$.extend({},mist.data);delete g.statistics;delete g.totals;delete g.clients;delete g.capabilities;g=JSON.stringify(g);g="Version: "+mist.data.config.version+"\n\nConfig:\n"+g;n={};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:n,index:"name"},
|
{capabilities:true})},3E4);break;case "Email for Help":g=$.extend({},mist.data);delete g.statistics;delete g.totals;delete g.clients;delete g.capabilities;g=JSON.stringify(g);g="Version: "+mist.data.config.version+"\n\nConfig:\n"+g;n={};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:n,index:"name"},
|
||||||
value:mist.user.name},{type:"email",label:"Your email address",validate:["required"],pointer:{main:n,index:"email"}},{type:"hidden",value:"Integrated Help",pointer:{main:n,index:"subject"}},{type:"hidden",value:"-",pointer:{main:n,index:"company"}},{type:"textarea",rows:20,label:"Your message",validate:["required"],pointer:{main:n,index:"message"}},{type:"textarea",rows:20,label:"Your config file",readonly:!0,value:g,pointer:{main:n,index:"configfile"}},{type:"buttons",buttons:[{type:"save",label:"Send",
|
value:mist.user.name},{type:"email",label:"Your email address",validate:["required"],pointer:{main:n,index:"email"}},{type:"hidden",value:"Integrated Help",pointer:{main:n,index:"subject"}},{type:"hidden",value:"-",pointer:{main:n,index:"company"}},{type:"textarea",rows:20,label:"Your message",validate:["required"],pointer:{main:n,index:"message"}},{type:"textarea",rows:20,label:"Your config file",readonly:!0,value:g,pointer:{main:n,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:n,success:function(a){a=$("<span>").html(a);a.find("script").remove();d.html(a[0].innerHTML)}})}}]}]));break;case "Disconnect":mist.user.password="";delete mist.user.authstring;delete mist.user.loggedin;sessionStorage.removeItem("mistLogin");UI.navto("Login");break;default:d.append($("<p>").text("This tab does not exist."))}d.find(".field").filter(function(){var a=$(this).getval();
|
"function":function(a){$(a).text("Sending..");$.ajax({type:"POST",url:"http://mistserver.org/contact?skin=plain",data:n,success:function(a){a=$("<span>").html(a);a.find("script").remove();d.html(a[0].innerHTML)}})}}]}]));break;case "Disconnect":mist.user.password="";delete mist.user.authstring;delete mist.user.loggedin;sessionStorage.removeItem("mistLogin");UI.navto("Login");break;default:d.append($("<p>").text("This tab does not exist."))}d.find(".field").filter(function(){var a=$(this).getval();
|
||||||
|
@ -196,9 +196,9 @@ position:"absolute",left:"-1000px"}))}}};"origin"in location||(location.origin=l
|
||||||
var mist={data:{},user:{name:"",password:"",host:host},send:function(a,c,d){var c=c||{},d=d||{},d=$.extend(true,{timeOut:3E4,sendData:c},d),b={authorize:{password:mist.user.authstring?MD5(mist.user.password+mist.user.authstring):"",username:mist.user.name}};$.extend(true,b,c);log("Send",$.extend(true,{},c));b={url:mist.user.host,type:"POST",data:{command:JSON.stringify(b)},dataType:"jsonp",crossDomain:true,timeout:d.timeout*1E3,async:true,error:function(b,e){delete mist.user.loggedin;if(!d.hide){switch(e){case "timeout":e=
|
var mist={data:{},user:{name:"",password:"",host:host},send:function(a,c,d){var c=c||{},d=d||{},d=$.extend(true,{timeOut:3E4,sendData:c},d),b={authorize:{password:mist.user.authstring?MD5(mist.user.password+mist.user.authstring):"",username:mist.user.name}};$.extend(true,b,c);log("Send",$.extend(true,{},c));b={url:mist.user.host,type:"POST",data:{command:JSON.stringify(b)},dataType:"jsonp",crossDomain:true,timeout:d.timeout*1E3,async:true,error:function(b,e){delete mist.user.loggedin;if(!d.hide){switch(e){case "timeout":e=
|
||||||
$("<i>").text("The connection timed out. ");break;case "abort":e=$("<i>").text("The connection was aborted. ");break;default:e=$("<i>").text(e+". ").css("text-transform","capitalize")}$("#message").addClass("red").text("An error occurred while attempting to communicate with MistServer:").append($("<br>")).append(e).append($("<a>").text("Send server request again").click(function(){mist.send(a,c,d)}))}UI.navto("Login")},success:function(b){log("Receive",$.extend(true,{},b),"as reply to",d.sendData);
|
$("<i>").text("The connection timed out. ");break;case "abort":e=$("<i>").text("The connection was aborted. ");break;default:e=$("<i>").text(e+". ").css("text-transform","capitalize")}$("#message").addClass("red").text("An error occurred while attempting to communicate with MistServer:").append($("<br>")).append(e).append($("<a>").text("Send server request again").click(function(){mist.send(a,c,d)}))}UI.navto("Login")},success:function(b){log("Receive",$.extend(true,{},b),"as reply to",d.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 e=$.extend({},b),h=["config","capabilities","ui_settings","LTS","active_streams","browse","log","totals"],q;for(q in e)h.indexOf(q)==-1&&delete e[q];$.extend(mist.data,e);mist.user.loggedin=true;UI.elements.connection.status.text("Connected").removeClass("red").addClass("green");
|
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 e=$.extend({},b),h=["config","capabilities","ui_settings","LTS","active_streams","browse","log","totals"],q;for(q in e)h.indexOf(q)==-1&&delete e[q];$.extend(mist.data,e);mist.user.loggedin=true;UI.elements.connection.status.text("Connected").removeClass("red").addClass("green");
|
||||||
UI.elements.connection.user_and_host.text(mist.user.name+" @ "+mist.user.host);UI.elements.connection.msg.removeClass("red").text("Last communication with the server at "+UI.format.time((new Date).getTime()/1E3));b.LTS&&UI.elements.menu.find(".LTSonly").removeClass("LTSonly");if(b.log){e=b.log[b.log.length-1];UI.elements.connection.msg.append($("<br>")).append("Last log entry: "+UI.format.time(e[0])+" ["+e[1]+"] "+e[2])}if("totals"in b){e=function(a,c,b){var d;d=function(){for(var a in b.fields)e[b.fields[a]].push([l,
|
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){e=b.log[b.log.length-1];UI.elements.connection.msg.append($("<br>")).append("Last log entry: "+UI.format.time(e[0])+" ["+e[1]+"] "+e[2])}if("totals"in b){e=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 b.fields)e[b.fields[g]]=[];var h=0,l;if(b.data){if(b.start>mist.data.config.time-600){l=(mist.data.config.time-600)*1E3;d();l=b.start*1E3;d()}else l=b.start*1E3;for(g in b.data){if(g==0){l=b.start*1E3;var q=0}else{l=l+b.interval[q][1]*1E3;b.interval[q][0]--;if(b.interval[q][0]<=0){q++;q<b.interval.length-1&&(h=h+2)}}if(h%2==1){d();h--}for(var x in b.data[g])e[b.fields[x]].push([l,b.data[g][x]]);if(h){d();h--}}if(mist.data.config.time-b.end>20){d();l=(mist.data.config.time-
|
0])};var e={},g;for(g in c.fields)e[c.fields[g]]=[];var h=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 q=0}else{l=l+c.interval[q][1]*1E3;c.interval[q][0]--;if(c.interval[q][0]<=0){q++;q<c.interval.length-1&&(h=h+2)}}if(h%2==1){d();h--}for(var x in c.data[g])e[c.fields[x]].push([l,c.data[g][x]]);if(h){d();h--}}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=c?c.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)e(c.totals.streams,c.totals.protocols,b.totals);else for(q in b.totals)e(c.totals[q].streams,c.totals[q].protocols,
|
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)e(c.totals.streams,c.totals.protocols,b.totals);else for(q in b.totals)e(c.totals[q].streams,c.totals[q].protocols,
|
||||||
b.totals[q])}a&&a(b,d);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,d);sessionStorage.setItem("mistLogin",JSON.stringify({host:mist.user.host,name:mist.user.name,password:mist.user.password}))}break;case "NOACC":UI.navto("Create a new account");
|
b.totals[q])}a&&a(b,d);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,d);sessionStorage.setItem("mistLogin",JSON.stringify({host:mist.user.host,name:mist.user.name,password:mist.user.password}))}break;case "NOACC":UI.navto("Create a new account");
|
||||||
break;case "ACC_MADE":delete c.authorize;mist.send(a,c,d);break;default:UI.navto("Login")}}};d.hide||UI.elements.connection.msg.removeClass("red").text("Data sent, waiting for a reply..").append($("<br>")).append($("<a>").text("Cancel request").click(function(){e.abort()}));var e=$.ajax(b)},inputMatch:function(a,c){if(typeof a=="undefined")return false;typeof a=="string"&&(a=[a]);for(var d in a){var b=a[d].replace(/[^\w\s]/g,"\\$&"),b=b.replace(/\\\*/g,".*");if(RegExp("^(?:[a-zA-Z]:)?"+b+"(?:\\?[^\\?]*)?$",
|
break;case "ACC_MADE":delete c.authorize;mist.send(a,c,d);break;default:UI.navto("Login")}}};d.hide||UI.elements.connection.msg.removeClass("red").text("Data sent, waiting for a reply..").append($("<br>")).append($("<a>").text("Cancel request").click(function(){e.abort()}));var e=$.ajax(b)},inputMatch:function(a,c){if(typeof a=="undefined")return false;typeof a=="string"&&(a=[a]);for(var d in a){var b=a[d].replace(/[^\w\s]/g,"\\$&"),b=b.replace(/\\\*/g,".*");if(RegExp("^(?:[a-zA-Z]:)?"+b+"(?:\\?[^\\?]*)?$",
|
||||||
"i").test(c))return true}return false},convertBuildOptions:function(a,c){var d=[],b=["required","optional"];"desc"in a&&d.push({type:"help",help:a.desc});for(var e in b)if(a[b[e]]){d.push($("<h4>").text(UI.format.capital(b[e])+" parameters"));for(var g in a[b[e]]){var l=a[b[e]][g],h={label:UI.format.capital(l.name),pointer:{main:c,index:g},validate:[]};b[e]=="required"&&(!("default"in l)||l["default"]=="")&&h.validate.push("required");if("default"in l)h.placeholder=l["default"];if("help"in l)h.help=
|
"i").test(c))return true}return false},convertBuildOptions:function(a,c){var d=[],b=["required","optional"];"desc"in a&&d.push({type:"help",help:a.desc});for(var e in b)if(a[b[e]]){d.push($("<h4>").text(UI.format.capital(b[e])+" parameters"));for(var g in a[b[e]]){var l=a[b[e]][g],h={label:UI.format.capital(l.name),pointer:{main:c,index:g},validate:[]};b[e]=="required"&&(!("default"in l)||l["default"]=="")&&h.validate.push("required");if("default"in l)h.placeholder=l["default"];if("help"in l)h.help=
|
||||||
|
|
38
lsp/mist.js
38
lsp/mist.js
|
@ -2051,6 +2051,12 @@ var UI = {
|
||||||
var $protocols_on = $('<span>');
|
var $protocols_on = $('<span>');
|
||||||
var $protocols_off = $('<span>');
|
var $protocols_off = $('<span>');
|
||||||
|
|
||||||
|
var s = {
|
||||||
|
serverid: mist.data.config.serverid,
|
||||||
|
debug: mist.data.config.debug
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
$main.append(UI.buildUI([
|
$main.append(UI.buildUI([
|
||||||
{
|
{
|
||||||
type: 'help',
|
type: 'help',
|
||||||
|
@ -2109,15 +2115,15 @@ var UI = {
|
||||||
type: 'str',
|
type: 'str',
|
||||||
label: 'Human readable name',
|
label: 'Human readable name',
|
||||||
pointer: {
|
pointer: {
|
||||||
main: mist.data.config,
|
main: s,
|
||||||
index: 'name'
|
index: 'serverid'
|
||||||
},
|
},
|
||||||
help: 'You can name your MistServer here for personal use. You\'ll still need to set host name within your network yourself.'
|
help: 'You can name your MistServer here for personal use. You\'ll still need to set host name within your network yourself.'
|
||||||
},{
|
},{
|
||||||
type: 'debug',
|
type: 'debug',
|
||||||
label: 'Debug level',
|
label: 'Debug level',
|
||||||
pointer: {
|
pointer: {
|
||||||
main: mist.data.config,
|
main: s,
|
||||||
index: 'debug'
|
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.'
|
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.'
|
||||||
|
@ -2125,7 +2131,7 @@ var UI = {
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
label: 'Force configurations save',
|
label: 'Force configurations save',
|
||||||
pointer: {
|
pointer: {
|
||||||
main: mist.data,
|
main: s,
|
||||||
index: 'save'
|
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.'
|
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.'
|
||||||
|
@ -2135,13 +2141,14 @@ var UI = {
|
||||||
type: 'save',
|
type: 'save',
|
||||||
label: 'Save',
|
label: 'Save',
|
||||||
'function': function(){
|
'function': function(){
|
||||||
var send = {config: mist.data.config};
|
var save = {config: s};
|
||||||
if (mist.data.save) {
|
if (s.save) {
|
||||||
send.save = mist.data.save;
|
save.save = s.save;
|
||||||
}
|
}
|
||||||
|
delete s.save;
|
||||||
mist.send(function(){
|
mist.send(function(){
|
||||||
UI.navto('Overview');
|
UI.navto('Overview');
|
||||||
},send)
|
},save)
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
@ -2170,7 +2177,9 @@ var UI = {
|
||||||
$versioncheck.text('Unknown, checking..');
|
$versioncheck.text('Unknown, checking..');
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
mist.send(function(d){
|
mist.send(function(d){
|
||||||
update_update(d);
|
if ("update" in d) {
|
||||||
|
update_update(d);
|
||||||
|
}
|
||||||
},{checkupdate:true});
|
},{checkupdate:true});
|
||||||
},5e3);
|
},5e3);
|
||||||
return;
|
return;
|
||||||
|
@ -4886,17 +4895,6 @@ var UI = {
|
||||||
mist.data.config.triggers[other[0]].splice(other[1],1);
|
mist.data.config.triggers[other[0]].splice(other[1],1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
var newtrigger = [
|
|
||||||
saveas.url,
|
|
||||||
(saveas.async ? true : false),
|
|
||||||
(typeof saveas.appliesto != 'undefined' ? saveas.appliesto : [])
|
|
||||||
];
|
|
||||||
if (typeof saveas['default'] != 'undefined') {
|
|
||||||
newtrigger.push(saveas['default']);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
var newtrigger = {
|
var newtrigger = {
|
||||||
handler: saveas.url,
|
handler: saveas.url,
|
||||||
sync: (saveas.async ? true : false),
|
sync: (saveas.async ? true : false),
|
||||||
|
|
Loading…
Add table
Reference in a new issue