207 lines
108 KiB
JavaScript
207 lines
108 KiB
JavaScript
var MD5=function(a){function b(a,b){var c,d,g,e,h;g=a&2147483648;e=b&2147483648;c=a&1073741824;d=b&1073741824;h=(a&1073741823)+(b&1073741823);return c&d?h^2147483648^g^e:c|d?h&1073741824?h^3221225472^g^e:h^1073741824^g^e:h^g^e}function c(a,c,d,g,e,h,i){a=b(a,b(b(c&d|~c&g,e),i));return b(a<<h|a>>>32-h,c)}function d(a,c,d,g,e,h,i){a=b(a,b(b(c&g|d&~g,e),i));return b(a<<h|a>>>32-h,c)}function e(a,c,d,g,e,h,i){a=b(a,b(b(c^d^g,e),i));return b(a<<h|a>>>32-h,c)}function g(a,c,d,g,e,h,i){a=b(a,b(b(d^(c|~g),
|
|
e),i));return b(a<<h|a>>>32-h,c)}function m(a){var b="",c="",d;for(d=0;3>=d;d++)c=a>>>8*d&255,c="0"+c.toString(16),b+=c.substr(c.length-2,2);return b}var f=[],q,p,l,u,h,i,k,j,f=a.replace(/\r\n/g,"\n"),a="";for(q=0;q<f.length;q++)p=f.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));f=a;a=f.length;q=a+8;p=16*((q-q%64)/64+1);l=Array(p-1);for(h=u=0;h<a;)q=
|
|
(h-h%4)/4,u=8*(h%4),l[q]|=f.charCodeAt(h)<<u,h++;q=(h-h%4)/4;l[q]|=128<<8*(h%4);l[p-2]=a<<3;l[p-1]=a>>>29;f=l;h=1732584193;i=4023233417;k=2562383102;j=271733878;for(a=0;a<f.length;a+=16)q=h,p=i,l=k,u=j,h=c(h,i,k,j,f[a+0],7,3614090360),j=c(j,h,i,k,f[a+1],12,3905402710),k=c(k,j,h,i,f[a+2],17,606105819),i=c(i,k,j,h,f[a+3],22,3250441966),h=c(h,i,k,j,f[a+4],7,4118548399),j=c(j,h,i,k,f[a+5],12,1200080426),k=c(k,j,h,i,f[a+6],17,2821735955),i=c(i,k,j,h,f[a+7],22,4249261313),h=c(h,i,k,j,f[a+8],7,1770035416),
|
|
j=c(j,h,i,k,f[a+9],12,2336552879),k=c(k,j,h,i,f[a+10],17,4294925233),i=c(i,k,j,h,f[a+11],22,2304563134),h=c(h,i,k,j,f[a+12],7,1804603682),j=c(j,h,i,k,f[a+13],12,4254626195),k=c(k,j,h,i,f[a+14],17,2792965006),i=c(i,k,j,h,f[a+15],22,1236535329),h=d(h,i,k,j,f[a+1],5,4129170786),j=d(j,h,i,k,f[a+6],9,3225465664),k=d(k,j,h,i,f[a+11],14,643717713),i=d(i,k,j,h,f[a+0],20,3921069994),h=d(h,i,k,j,f[a+5],5,3593408605),j=d(j,h,i,k,f[a+10],9,38016083),k=d(k,j,h,i,f[a+15],14,3634488961),i=d(i,k,j,h,f[a+4],20,3889429448),
|
|
h=d(h,i,k,j,f[a+9],5,568446438),j=d(j,h,i,k,f[a+14],9,3275163606),k=d(k,j,h,i,f[a+3],14,4107603335),i=d(i,k,j,h,f[a+8],20,1163531501),h=d(h,i,k,j,f[a+13],5,2850285829),j=d(j,h,i,k,f[a+2],9,4243563512),k=d(k,j,h,i,f[a+7],14,1735328473),i=d(i,k,j,h,f[a+12],20,2368359562),h=e(h,i,k,j,f[a+5],4,4294588738),j=e(j,h,i,k,f[a+8],11,2272392833),k=e(k,j,h,i,f[a+11],16,1839030562),i=e(i,k,j,h,f[a+14],23,4259657740),h=e(h,i,k,j,f[a+1],4,2763975236),j=e(j,h,i,k,f[a+4],11,1272893353),k=e(k,j,h,i,f[a+7],16,4139469664),
|
|
i=e(i,k,j,h,f[a+10],23,3200236656),h=e(h,i,k,j,f[a+13],4,681279174),j=e(j,h,i,k,f[a+0],11,3936430074),k=e(k,j,h,i,f[a+3],16,3572445317),i=e(i,k,j,h,f[a+6],23,76029189),h=e(h,i,k,j,f[a+9],4,3654602809),j=e(j,h,i,k,f[a+12],11,3873151461),k=e(k,j,h,i,f[a+15],16,530742520),i=e(i,k,j,h,f[a+2],23,3299628645),h=g(h,i,k,j,f[a+0],6,4096336452),j=g(j,h,i,k,f[a+7],10,1126891415),k=g(k,j,h,i,f[a+14],15,2878612391),i=g(i,k,j,h,f[a+5],21,4237533241),h=g(h,i,k,j,f[a+12],6,1700485571),j=g(j,h,i,k,f[a+3],10,2399980690),
|
|
k=g(k,j,h,i,f[a+10],15,4293915773),i=g(i,k,j,h,f[a+1],21,2240044497),h=g(h,i,k,j,f[a+8],6,1873313359),j=g(j,h,i,k,f[a+15],10,4264355552),k=g(k,j,h,i,f[a+6],15,2734768916),i=g(i,k,j,h,f[a+13],21,1309151649),h=g(h,i,k,j,f[a+4],6,4149444226),j=g(j,h,i,k,f[a+11],10,3174756917),k=g(k,j,h,i,f[a+2],15,718787259),i=g(i,k,j,h,f[a+9],21,3951481745),h=b(h,q),i=b(i,p),k=b(k,l),j=b(j,u);return(m(h)+m(i)+m(k)+m(j)).toLowerCase()};(function(a){a.fn.stupidtable=function(){a(this).on("click","thead th",function(){a(this).stupidsort()})};a.fn.stupidsort=function(){function b(b){var c=0,d;a(b).children("td,th").each(function(){if(c==q)return d=a(this),!1;var b=a(this).attr("colspan");c+=b?Number(b):1});b="undefined"!=typeof d.data("sort-value")?d.data("sort-value"):"undefined"!=typeof d.attr("data-sort-value")?d.attr("data-sort-value"):d.text();switch(m){case "string":case "string-ins":b=String(b).toLowerCase();break;case "int":b=
|
|
parseInt(Number(b));break;case "float":b=Number(b)}return b}var c=a(this),d=c.closest("table"),e=d.children("tbody"),g=e.children("tr"),m=c.attr("data-sort-type");if(m){var f=!0;c.hasClass("sorting-asc")&&(f=!1);var q=0;c.prevAll().each(function(){var b=a(this).attr("colspan");q+=b?Number(b):1});g.sort(function(a,c){var d=f?1:-1,a=b(a),c=b(c);return a>c?1*d:a<c?-1*d:0});e.append(g);d.find("thead th").removeClass("sorting-asc").removeClass("sorting-desc");c.addClass(f?"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(b){}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 c=0;$("body > div.filler").on("scroll",function(){var a=$(this).scrollLeft();a!=c&&UI.elements.header.css("margin-right",-1*a+"px");c=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,b){this.vars[a]=b;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,b){this.opts&&log("[interval]","Set called on interval, but an interval is already active.");
|
|
this.opts={delay:b,callback:a};this.opts.id=setInterval(a,b)}},returnTab:["Overview"],countrylist:{AF:"Afghanistan",AX:"Åland Islands",AL:"Albania",DZ:"Algeria",AS:"American Samoa",AD:"Andorra",AO:"Angola",AI:"Anguilla",AQ:"Antarctica",AG:"Antigua and Barbuda",AR:"Argentina",AM:"Armenia",AW:"Aruba",AU:"Australia",AT:"Austria",AZ:"Azerbaijan",BS:"Bahamas",BH:"Bahrain",BD:"Bangladesh",BB:"Barbados",BY:"Belarus",BE:"Belgium",BZ:"Belize",BJ:"Benin",BM:"Bermuda",BT:"Bhutan",BO:"Bolivia, Plurinational State of",
|
|
BQ:"Bonaire, Sint Eustatius and Saba",BA:"Bosnia and Herzegovina",BW:"Botswana",BV:"Bouvet Island",BR:"Brazil",IO:"British Indian Ocean Territory",BN:"Brunei Darussalam",BG:"Bulgaria",BF:"Burkina Faso",BI:"Burundi",KH:"Cambodia",CM:"Cameroon",CA:"Canada",CV:"Cape Verde",KY:"Cayman Islands",CF:"Central African Republic",TD:"Chad",CL:"Chile",CN:"China",CX:"Christmas Island",CC:"Cocos (Keeling) Islands",CO:"Colombia",KM:"Comoros",CG:"Congo",CD:"Congo, the Democratic Republic of the",CK:"Cook Islands",
|
|
CR:"Costa Rica",CI:"Côte d'Ivoire",HR:"Croatia",CU:"Cuba",CW:"Curaçao",CY:"Cyprus",CZ:"Czech Republic",DK:"Denmark",DJ:"Djibouti",DM:"Dominica",DO:"Dominican Republic",EC:"Ecuador",EG:"Egypt",SV:"El Salvador",GQ:"Equatorial Guinea",ER:"Eritrea",EE:"Estonia",ET:"Ethiopia",FK:"Falkland Islands (Malvinas)",FO:"Faroe Islands",FJ:"Fiji",FI:"Finland",FR:"France",GF:"French Guiana",PF:"French Polynesia",TF:"French Southern Territories",GA:"Gabon",GM:"Gambia",GE:"Georgia",DE:"Germany",GH:"Ghana",
|
|
GI:"Gibraltar",GR:"Greece",GL:"Greenland",GD:"Grenada",GP:"Guadeloupe",GU:"Guam",GT:"Guatemala",GG:"Guernsey",GN:"Guinea",GW:"Guinea-Bissau",GY:"Guyana",HT:"Haiti",HM:"Heard Island and McDonald Islands",VA:"Holy See (Vatican City State)",HN:"Honduras",HK:"Hong Kong",HU:"Hungary",IS:"Iceland",IN:"India",ID:"Indonesia",IR:"Iran, Islamic Republic of",IQ:"Iraq",IE:"Ireland",IM:"Isle of Man",IL:"Israel",IT:"Italy",JM:"Jamaica",JP:"Japan",JE:"Jersey",JO:"Jordan",KZ:"Kazakhstan",KE:"Kenya",KI:"Kiribati",
|
|
KP:"Korea, Democratic People's Republic of",KR:"Korea, Republic of",KW:"Kuwait",KG:"Kyrgyzstan",LA:"Lao People's Democratic Republic",LV:"Latvia",LB:"Lebanon",LS:"Lesotho",LR:"Liberia",LY:"Libya",LI:"Liechtenstein",LT:"Lithuania",LU:"Luxembourg",MO:"Macao",MK:"Macedonia, the former Yugoslav Republic of",MG:"Madagascar",MW:"Malawi",MY:"Malaysia",MV:"Maldives",ML:"Mali",MT:"Malta",MH:"Marshall Islands",MQ:"Martinique",MR:"Mauritania",MU:"Mauritius",YT:"Mayotte",MX:"Mexico",FM:"Micronesia, Federated States of",
|
|
MD:"Moldova, Republic of",MC:"Monaco",MN:"Mongolia",ME:"Montenegro",MS:"Montserrat",MA:"Morocco",MZ:"Mozambique",MM:"Myanmar",NA:"Namibia",NR:"Nauru",NP:"Nepal",NL:"Netherlands",NC:"New Caledonia",NZ:"New Zealand",NI:"Nicaragua",NE:"Niger",NG:"Nigeria",NU:"Niue",NF:"Norfolk Island",MP:"Northern Mariana Islands",NO:"Norway",OM:"Oman",PK:"Pakistan",PW:"Palau",PS:"Palestine, State of",PA:"Panama",PG:"Papua New Guinea",PY:"Paraguay",PE:"Peru",PH:"Philippines",PN:"Pitcairn",PL:"Poland",PT:"Portugal",PR:"Puerto Rico",
|
|
QA:"Qatar",RE:"Réunion",RO:"Romania",RU:"Russian Federation",RW:"Rwanda",BL:"Saint Barthélemy",SH:"Saint Helena, Ascension and Tristan da Cunha",KN:"Saint Kitts and Nevis",LC:"Saint Lucia",MF:"Saint Martin (French part)",PM:"Saint Pierre and Miquelon",VC:"Saint Vincent and the Grenadines",WS:"Samoa",SM:"San Marino",ST:"Sao Tome and Principe",SA:"Saudi Arabia",SN:"Senegal",RS:"Serbia",SC:"Seychelles",SL:"Sierra Leone",SG:"Singapore",SX:"Sint Maarten (Dutch part)",SK:"Slovakia",SI:"Slovenia",
|
|
SB:"Solomon Islands",SO:"Somalia",ZA:"South Africa",GS:"South Georgia and the South Sandwich Islands",SS:"South Sudan",ES:"Spain",LK:"Sri Lanka",SD:"Sudan",SR:"Suriname",SJ:"Svalbard and Jan Mayen",SZ:"Swaziland",SE:"Sweden",CH:"Switzerland",SY:"Syrian Arab Republic",TW:"Taiwan, Province of China",TJ:"Tajikistan",TZ:"Tanzania, United Republic of",TH:"Thailand",TL:"Timor-Leste",TG:"Togo",TK:"Tokelau",TO:"Tonga",TT:"Trinidad and Tobago",TN:"Tunisia",TR:"Turkey",TM:"Turkmenistan",TC:"Turks and Caicos Islands",
|
|
TV:"Tuvalu",UG:"Uganda",UA:"Ukraine",AE:"United Arab Emirates",GB:"United Kingdom",US:"United States",UM:"United States Minor Outlying Islands",UY:"Uruguay",UZ:"Uzbekistan",VU:"Vanuatu",VE:"Venezuela, Bolivarian Republic of",VN:"Viet Nam",VG:"Virgin Islands, British",VI:"Virgin Islands, U.S.",WF:"Wallis and Futuna",EH:"Western Sahara",YE:"Yemen",ZM:"Zambia",ZW:"Zimbabwe"},tooltip:{show:function(a,b){$tooltip=this.element;$.contains(document.body,$tooltip[0])||$("body").append($tooltip);$tooltip.html(b);
|
|
clearTimeout(this.hiding);delete this.hiding;var c=$(document).height()-$tooltip.outerHeight(),d=$(document).width()-$tooltip.outerWidth();$tooltip.css("left",Math.min(a.pageX+10,d-10));$tooltip.css("top",Math.min(a.pageY+25,c-10));$tooltip.show().addClass("show")},hide:function(){$tooltip=this.element;$tooltip.removeClass("show");this.hiding=setTimeout(function(){$tooltip.hide()},500)},element:$("<div>").attr("id","tooltip")},humanMime:function(a){var b=!1;switch(a){case "html5/application/vnd.apple.mpegurl":b=
|
|
"HLS";break;case "html5/video/mp4":b="MP4";break;case "dash/video/mp4":b="DASH";break;case "flash/11":b="HDS";break;case "flash/10":b="RTMP";break;case "flash/7":b="Progressive";break;case "html5/audio/mp3":b="MP3";break;case "html5/video/mp2t":b="TS";break;case "html5/application/vnd.ms-ss":b="Smooth";break;case "html5/text/vtt":b="VTT Subtitles";break;case "html5/text/plain":b="SRT Subtitles";break;case "html5/text/javascript":b="JSON Subtitles"}return b},popup:{element:null,show:function(a){this.element=
|
|
$("<div>").attr("id","popup").append($("<button>").text("Close").addClass("close").click(function(){UI.popup.element.fadeOut("fast",function(){UI.popup.element.remove();UI.popup.element=null})})).append(a);$("body").append(this.element)}},menu:[{Overview:{},Protocols:{},Streams:{hiddenmenu:{Edit:{},Preview:{},Embed:{}}},Push:{LTSonly:!0},Triggers:{LTSonly:!1},Logs:{},Statistics:{},"Server Stats":{}},{Disconnect:{classes:["red"]}},{Guides:{link:"http://mistserver.org/documentation#Userdocs"},Tools:{submenu:{"Release notes":{link:"http://mistserver.org/documentation#Devdocs"},
|
|
"Mist Shop":{link:"http://mistserver.org/products"},"Email for Help":{},ToS:{link:"http://mistserver.org/documentation#Legal"}}}}],buildMenu:function(){function a(a,b){var c=$("<a>").addClass("button");c.html($("<span>").addClass("plain").text(a)).append($("<span>").addClass("highlighted").text(a));for(var d in b.classes)c.addClass(b.classes[d]);"LTSonly"in b&&c.addClass("LTSonly");"link"in b?c.attr("href",b.link).attr("target","_blank"):"submenu"in b||c.click(function(b){$(this).closest(".menu").hasClass("hide")||
|
|
(UI.navto(a),b.stopPropagation())});return c}var b=UI.elements.menu,c;for(c in UI.menu){0<c&&b.append($("<br>"));for(var d in UI.menu[c]){var e=UI.menu[c][d],g=a(d,e);b.append(g);if("submenu"in e){var m=$("<span>").addClass("submenu");g.addClass("arrowdown").append(m);for(var f in e.submenu)m.append(a(f,e.submenu[f]))}else if("hiddenmenu"in e)for(f in m=$("<span>").addClass("hiddenmenu"),g.append(m),e.hiddenmenu)m.append(a(f,e.hiddenmenu[f]))}}c=$("<div>").attr("id","ih_button").text("?").click(function(){$("body").toggleClass("helpme");
|
|
UI.stored.saveOpt("helpme",$("body").hasClass("helpme"))}).attr("title","Click to toggle the display of integrated help");UI.stored.getOpts().helpme&&$("body").addClass("helpme");b.after(c).after($("<div>").addClass("separator"))},findInput:function(a){return this.findInOutput("inputs",a)},findOutput:function(a){return this.findInOutput("connectors",a)},findInOutput:function(a,b){if("capabilities"in mist.data){var c=mist.data.capabilities[a];return b in c?c[b]:b+".exe"in c?c[b+".exe"]:!1}throw"Request capabilities first";
|
|
},buildUI:function(a){var b=$("<div>").addClass("input_container"),c;for(c in a){var d=a[c];if(d instanceof jQuery)b.append(d);else if("help"==d.type){var e=$("<span>").addClass("text_container").append($("<span>").addClass("description").append(d.help));b.append(e);if("classes"in d)for(var g in d.classes)e.addClass(d.classes[g])}else if("text"==d.type)b.append($("<span>").addClass("text_container").append($("<span>").addClass("text").append(d.text)));else if("custom"==d.type)b.append(d.custom);else if("buttons"==
|
|
d.type)for(g in e=$("<span>").addClass("button_container").on("keydown",function(a){a.stopPropagation()}),"css"in d&&e.css(d.css),b.append(e),d.buttons){var m=d.buttons[g],f=$("<button>").text(m.label).data("opts",m);"css"in m&&f.css(m.css);if("classes"in m)for(var q in m.classes)f.addClass(m.classes[q]);e.append(f);switch(m.type){case "cancel":f.addClass("cancel").click(m["function"]);break;case "save":f.addClass("save").click(function(){var a=$(this).closest(".input_container"),b=!1;a.find(".hasValidate").each(function(){if(b=
|
|
$(this).data("validate")(this,!0))return!1});b||(a.find(".isSetting").each(function(){var a=$(this).getval(),b=$(this).data("pointer");if(""==a)if("default"in $(this).data("opts"))a=$(this).data("opts")["default"];else return delete b.main[b.index],!0;b.main[b.index]=a}),(a=$(this).data("opts")["function"])&&a(this))});break;default:f.click(m["function"])}}else{m=$("<label>").addClass("UIelement");b.append(m);"css"in d&&m.css(d.css);m.append($("<span>").addClass("label").html("label"in d?d.label+
|
|
":":""));f=$("<span>").addClass("field_container");m.append(f);switch(d.type){case "password":e=$("<input>").attr("type","password");break;case "int":e=$("<input>").attr("type","number");"min"in d&&e.attr("min",d.min);"max"in d&&e.attr("max",d.min);"validate"in d?d.validate.push("int"):d.validate=["int"];break;case "span":e=$("<span>");break;case "debug":d.select=[["","Default"],[0,"0 - All debugging messages disabled"],[1,"1 - Messages about failed operations"],[2,"2 - Previous level, and error messages"],
|
|
[3,"3 - Previous level, and warning messages"],[4,"4 - Previous level, and status messages for development"],[5,"5 - Previous level, and more status messages for development"],[6,"6 - Previous level, and verbose debugging messages"],[7,"7 - Previous level, and very verbose debugging messages"],[8,"8 - Report everything in extreme detail"],[9,"9 - Report everything in insane detail"],[10,"10 - All messages enabled"]];case "select":e=$("<select>");for(g in d.select){var p=$("<option>");"string"==typeof d.select[g]?
|
|
p.text(d.select[g]):p.val(d.select[g][0]).text(d.select[g][1]);e.append(p)}break;case "textarea":e=$("<textarea>").on("keydown",function(a){a.stopPropagation()});break;case "checkbox":e=$("<input>").attr("type","checkbox");break;case "hidden":e=$("<input>").attr("type","hidden");m.hide();break;case "email":e=$("<input>").attr("type","email").attr("autocomplete","on").attr("required","");break;case "browse":e=$("<input>").attr("type","text");"filetypes"in d&&e.data("filetypes",d.filetypes);break;case "geolimited":case "hostlimited":e=
|
|
$("<input>").attr("type","hidden");break;case "radioselect":e=$("<div>").addClass("radioselect");for(c in d.radioselect){var l=$("<input>").attr("type","radio").val(d.radioselect[c][0]).attr("name",d.label);("LTSonly"in d&&!mist.data.LTS||d.readonly)&&l.prop("disabled",!0);p=$("<label>").append(l).append($("<span>").html(d.radioselect[c][1]));e.append(p);if(2<d.radioselect[c].length)for(g in l=$("<select>").change(function(){$(this).parent().find("input[type=radio]:enabled").prop("checked","true")}),
|
|
p.append(l),("LTSonly"in d&&!mist.data.LTS||d.readonly)&&l.prop("disabled",!0),d.radioselect[c][2])p=$("<option>"),l.append(p),d.radioselect[c][2][g]instanceof Array?p.val(d.radioselect[c][2][g][0]).html(d.radioselect[c][2][g][1]):p.html(d.radioselect[c][2][g])}break;case "checklist":e=$("<div>").addClass("checkcontainer");$controls=$("<div>").addClass("controls");$checklist=$("<div>").addClass("checklist");e.append($checklist);for(c in d.checklist)"string"==typeof d.checklist[c]&&(d.checklist[c]=
|
|
[d.checklist[c],d.checklist[c]]),$checklist.append($("<label>").text(d.checklist[c][1]).prepend($("<input>").attr("type","checkbox").attr("name",d.checklist[c][0])));break;case "DOMfield":e=d.DOMfield;break;default:e=$("<input>").attr("type","text")}e.addClass("field").data("opts",d);"pointer"in d&&e.attr("name",d.pointer.index);f.append(e);if("classes"in d)for(g in d.classes)e.addClass(d.classes[g]);"placeholder"in d&&e.attr("placeholder",d.placeholder);"default"in d&&e.attr("placeholder",d["default"]);
|
|
"unit"in d&&f.append($("<span>").addClass("unit").html(d.unit));"readonly"in d&&(e.attr("readonly","readonly"),e.click(function(){$(this).select()}));"qrcode"in d&&f.append($("<span>").addClass("unit").html($("<button>").text("QR").on("keydown",function(a){a.stopPropagation()}).click(function(){var a=String($(this).closest(".field_container").find(".field").getval()),b=$("<div>").addClass("qrcode");UI.popup.show($("<span>").addClass("qr_container").append($("<p>").text(a)).append(b));b.qrcode({text:a,
|
|
size:Math.min(b.width(),b.height())})})));"clipboard"in d&&document.queryCommandSupported("copy")&&f.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()),b=document.createElement("textarea");b.value=a;document.body.appendChild(b);b.select();var c=false;try{c=document.execCommand("copy")}catch(d){}if(c){$(this).text("Copied to clipboard!");document.body.removeChild(b);
|
|
var g=$(this);setTimeout(function(){g.text("Copy")},5E3)}else{document.body.removeChild(b);alert("Failed to copy:\n"+a)}})));"rows"in d&&e.attr("rows",d.rows);"LTSonly"in d&&!mist.data.LTS&&(f.addClass("LTSonly"),e.prop("disabled",!0));switch(d.type){case "browse":l=$("<div>").addClass("grouper").append(m);b.append(l);l=$("<button>").text("Browse").on("keydown",function(a){a.stopPropagation()});f.append(l);l.click(function(){function a(b){m.text("Loading..");mist.send(function(a){f.text(a.browse.path[0]);
|
|
mist.data.LTS&&d.setval(a.browse.path[0]+"/");m.html(l.clone(true).text("..").attr("title","Folder up"));if(a.browse.subdirectories){a.browse.subdirectories.sort();for(var b in a.browse.subdirectories){var e=a.browse.subdirectories[b];m.append(l.clone(true).attr("title",f.text()+q+e).text(e))}}if(a.browse.files){a.browse.files.sort();for(b in a.browse.files){var e=a.browse.files[b],h=f.text()+q+e,e=$("<a>").text(e).addClass("file").attr("title",h);m.append(e);if(p){var n=true,u;for(u in p)if(typeof p[u]!=
|
|
"undefined"&&mist.inputMatch(p[u],h)){n=false;break}n&&e.hide()}e.click(function(){var a=$(this).attr("title");d.setval(a).removeAttr("readonly").css("opacity",1);g.show();c.remove()})}}},{browse:b})}var b=$(this).closest(".grouper"),c=$("<div>").addClass("browse_container"),d=b.find(".field").attr("readonly","readonly").css("opacity",0.5),g=$(this),e=$("<button>").text("Stop browsing").click(function(){g.show();c.remove();d.removeAttr("readonly").css("opacity",1)}),f=$("<span>").addClass("field"),
|
|
m=$("<div>").addClass("browse_contents"),l=$("<a>").addClass("folder"),p=d.data("filetypes");b.append(c);c.append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Current folder:")).append($("<span>").addClass("field_container").append(f).append(e))).append(m);var q="/";mist.data.config.version.indexOf("indows")>-1&&(q="\\");l.click(function(){var b=f.text()+q+$(this).text();a(b)});b=d.getval();e=b.split("://");e.length>1&&(b=e[0]=="file"?e[1]:"");b=b.split(q);b.pop();
|
|
b=b.join(q);g.hide();a(b)});break;case "geolimited":case "hostlimited":l={field:e};l.blackwhite=$("<select>").append($("<option>").val("-").text("Blacklist")).append($("<option>").val("+").text("Whitelist"));l.values=$("<span>").addClass("limit_value_list");switch(d.type){case "geolimited":l.prototype=$("<select>").append($("<option>").val("").text("[Select a country]"));for(c in UI.countrylist)l.prototype.append($("<option>").val(c).html(UI.countrylist[c]));break;case "hostlimited":l.prototype=$("<input>").attr("type",
|
|
"text").attr("placeholder","type a host")}l.prototype.on("change keyup",function(){$(this).closest(".field_container").data("subUI").blackwhite.trigger("change")});l.blackwhite.change(function(){var a=$(this).closest(".field_container").data("subUI"),b=[],c=false;a.values.children().each(function(){c=$(this).val();c!=""?b.push(c):$(this).remove()});a.values.append(a.prototype.clone(true));b.length>0?a.field.val($(this).val()+b.join(" ")):a.field.val("");a.field.trigger("change")});"LTSonly"in d&&
|
|
!mist.data.LTS&&(l.blackwhite.prop("disabled",!0),l.prototype.prop("disabled",!0));l.values.append(l.prototype.clone(!0));f.data("subUI",l).addClass("limit_list").append(l.blackwhite).append(l.values)}"pointer"in d&&(e.data("pointer",d.pointer).addClass("isSetting"),l=d.pointer.main[d.pointer.index],"undefined"!=l&&e.setval(l));"value"in d&&e.setval(d.value);if("datalist"in d)for(c in l="datalist_"+c+MD5(e[0].outerHTML),e.attr("list",l),l=$("<datalist>").attr("id",l),f.append(l),d.datalist)l.append($("<option>").val(d.datalist[c]));
|
|
f=$("<span>").addClass("help_container");m.append(f);"help"in d&&(f.append($("<span>").addClass("ih_balloon").html(d.help)),e.on("focus mouseover",function(){$(this).closest("label").addClass("active")}).on("blur mouseout",function(){$(this).closest("label").removeClass("active")}));if("validate"in d){m=[];for(g in d.validate){l=d.validate[g];if("function"!=typeof l)switch(l){case "required":l=function(a){return a==""||a==null?{msg:"This is a required field.",classes:["red"]}:false};break;case "int":l=
|
|
function(a,b){var c=$(b).data("opts");if(!$(b)[0].validity.valid){var d=[];"min"in c&&d.push(" greater than or equal to "+c.min);"max"in c&&d.push(" smaller than or equal to "+c.max);return{msg:"Please enter an integer"+d.join(" and")+".",classes:["red"]}}if(parseInt(Number(a))!=a)return{msg:"Please enter an integer.",classes:["red"]}};break;case "streamname":l=function(a,b){if(!isNaN(a.charAt(0)))return{msg:"The first character may not be a number.",classes:["red"]};if(a.toLowerCase()!=a)return{msg:"Uppercase letters are not allowed.",
|
|
classes:["red"]};if(a.replace(/[^\da-z_]/g,"")!=a)return{msg:"Special characters (except for underscores) are not allowed.",classes:["red"]};if("streams"in mist.data&&a in mist.data.streams&&$(b).data("pointer").main.name!=a)return{msg:"This streamname already exists.<br>If you want to edit an existing stream, please click edit on the the streams tab.",classes:["red"]}};break;default:l=function(){}}m.push(l)}e.data("validate_functions",m).data("help_container",f).data("validate",function(a,b){var c=
|
|
$(a).getval(),d=$(a).data("validate_functions"),e=$(a).data("help_container");e.find(".err_balloon").remove();for(var g in d){var f=d[g](c,a);if(f){$err=$("<span>").addClass("err_balloon").html(f.msg);for(var m in f.classes)$err.addClass(f.classes[m]);e.prepend($err);b&&$(a).focus();return true}}return false}).addClass("hasValidate").on("change keyup",function(){$(this).data("validate")($(this))});""!=e.getval()&&e.trigger("change")}"function"in d&&(e.on("change keyup",d["function"]),e.trigger("change"))}}b.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 b},buildVheaderTable:function(a){var b=$("<table>").css("margin","0.2em"),c=$("<tr>").addClass("header").append($("<td>").addClass("vheader").attr("rowspan",a.labels.length+1).append($("<span>").text(a.vheader))),d=[];c.append($("<td>"));for(var e in a.labels)d.push($("<tr>").append($("<td>").html(""==a.labels[e]?" ":a.labels[e]+
|
|
":")));for(var g in a.content)for(e in c.append($("<td>").html(a.content[g].header)),a.content[g].body)d[e].append($("<td>").html(a.content[g].body[e]));b.append($("<tbody>").append(c).append(d));return b},plot:{addGraph:function(a,b){var c={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(c.elements.legend);c.elements.cont.append(c.elements.plot).append(c.elements.legend);
|
|
b.append(c.elements.cont);return c},go:function(a){if(!(1>Object.keys(a).length)){var b={totals:[],clients:[]},c;for(c in a)for(var d in a[c].datasets){var e=a[c].datasets[d];switch(e.datatype){case "clients":case "upbps":case "downbps":switch(e.origin[0]){case "total":b.totals.push({fields:[e.datatype],end:-15});break;case "stream":b.totals.push({fields:[e.datatype],streams:[e.origin[1]],end:-15});break;case "protocol":b.totals.push({fields:[e.datatype],protocols:[e.origin[1]],end:-15})}break;case "cpuload":case "memload":b.capabilities=
|
|
{}}}0==b.totals.length&&delete b.totals;0==b.clients.length&&delete b.clients;mist.send(function(){for(var b in a){var c=a[b];if(1>c.datasets.length){c.elements.plot.html("");c.elements.legend.html("");break}switch(c.xaxis){case "time":var d=[];c.yaxes={};var e=[],p;for(p in c.datasets){var l=c.datasets[p];l.display&&(l.getdata(),l.yaxistype in c.yaxes||(d.push(UI.plot.yaxes[l.yaxistype]),c.yaxes[l.yaxistype]=d.length),l.yaxis=c.yaxes[l.yaxistype],e.push(l))}d[0]&&(d[0].color=0);c.plot=$.plot(c.elements.plot,
|
|
e,{legend:{show:!1},xaxis:UI.plot.xaxes[c.xaxis],yaxes:d,grid:{hoverable:!0,borderWidth:{top:0,right:0,bottom:1,left:1},color:"black",backgroundColor:{colors:["rgba(0,0,0,0)","rgba(0,0,0,0.025)"]}},crosshair:{mode:"x"}});d=$("<table>").addClass("legend-list").addClass("nolay").html($("<tr>").html($("<td>").html($("<h3>").text(c.id))).append($("<td>").css("padding-right","2em").css("text-align","right").html($("<span>").addClass("value")).append($("<button>").data("opts",c).text("X").addClass("close").click(function(){var b=
|
|
$(this).data("opts");if(confirm("Are you sure you want to remove "+b.id+"?")){b.elements.cont.remove();var c=$(".graph_ids option:contains("+b.id+")"),d=c.parent();c.remove();UI.plot.del(b.id);delete a[b.id];d.trigger("change");UI.plot.go(a)}}))));c.elements.legend.html(d);var u=function(a){var b=c.elements.legend.find(".value"),d=1;if(typeof a=="undefined")b.eq(0).html("Latest:");else{var e=c.plot.getXAxes()[0],a=Math.min(e.max,a),a=Math.max(e.min,a);b.eq(0).html(UI.format.time(a/1E3))}for(var g in c.datasets){var f=
|
|
" ";if(c.datasets[g].display){var e=UI.plot.yaxes[c.datasets[g].yaxistype].tickFormatter,h=c.datasets[g].data;if(a)for(var l in h){if(h[l][0]==a){f=e(h[l][1]);break}if(h[l][0]>a){if(l!=0){f=h[l];h=h[l-1];f=e(f[1]+(a-f[0])*(h[1]-f[1])/(h[0]-f[0]))}break}}else f=e(c.datasets[g].data[c.datasets[g].data.length-1][1])}b.eq(d).html(f);d++}};c.plot.getOptions();for(p in c.datasets)e=$("<input>").attr("type","checkbox").data("index",p).data("graph",c).click(function(){var a=$(this).data("graph");$(this).is(":checked")?
|
|
a.datasets[$(this).data("index")].display=true:a.datasets[$(this).data("index")].display=false;var b={};b[a.id]=a;UI.plot.go(b)}),c.datasets[p].display&&e.attr("checked","checked"),d.append($("<tr>").html($("<td>").html($("<label>").html(e).append($("<div>").addClass("series-color").css("background-color",c.datasets[p].color)).append(c.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",c).click(function(){var b=$(this).data("index"),c=$(this).data("graph");if(confirm("Are you sure you want to remove "+c.datasets[b].label+" from "+c.id+"?")){c.datasets.splice(b,1);if(c.datasets.length==0){c.elements.cont.remove();var b=$(".graph_ids option:contains("+c.id+")"),d=b.parent();b.remove();d.trigger("change");UI.plot.del(c.id);delete a[c.id];UI.plot.go(a)}else{UI.plot.save(c);b={};b[c.id]=c;UI.plot.go(b)}}}))));u();var h=!1;c.elements.plot.on("plothover",function(a,b,c){if(b.x!=
|
|
h){u(b.x);h=b.x}if(c){a=$("<span>").append($("<h3>").text(c.series.label).prepend($("<div>").addClass("series-color").css("background-color",c.series.color))).append($("<table>").addClass("nolay").html($("<tr>").html($("<td>").text("Time:")).append($("<td>").html(UI.format.dateTime(c.datapoint[0]/1E3,"long")))).append($("<tr>").html($("<td>").text("Value:")).append($("<td>").html(c.series.yaxis.tickFormatter(c.datapoint[1],c.series.yaxis)))));UI.tooltip.show(b,a.children())}else UI.tooltip.hide()}).on("mouseout",
|
|
function(){u()})}}},b)}},save:function(a){var b={id:a.id,xaxis:a.xaxis,datasets:[]},c;for(c in a.datasets)b.datasets.push({origin:a.datasets[c].origin,datatype:a.datasets[c].datatype});a=mist.stored.get().graphs||{};a[b.id]=b;mist.stored.set("graphs",a)},del:function(a){var b=mist.stored.get().graphs||{};delete b[a];mist.stored.set("graphs",b)},datatype:{getOptions:function(a){var b=$.extend(!0,{},UI.plot.datatype.templates.general),c=$.extend(!0,{},UI.plot.datatype.templates[a.datatype]),a=$.extend(!0,
|
|
c,a),a=$.extend(!0,b,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 b=[],d;for(d in a.basecolor)c=a.basecolor[d],c+=50*(0.5-Math.random()),c=Math.round(c),c=Math.min(255,Math.max(0,c)),b.push(c);a.color="rgb("+b.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,b;for(b in this.data)this.data[b][0]<1E3*(mist.data.config.time-600)&&(a=b);!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,b;for(b in this.data)this.data[b][0]<1E3*(mist.data.config.time-600)&&(a=b);!1!==a&&this.data.splice(0,Number(a)+1);this.data.push([1E3*mist.data.config.time,mist.data.capabilities.load.memory]);return this.data}},clients:{label:"Connections",basecolor:[203,75,75]},upbps:{label:"Bandwidth up",yaxistype:"bytespersec",basecolor:[77,167,77]},downbps:{label:"Bandwidth down",yaxistype:"bytespersec",basecolor:[148,64,237]}}},yaxes:{percentage:{name:"percentage",
|
|
color:"black",tickColor:0,tickDecimals:0,tickFormatter:function(a){return UI.format.addUnit(UI.format.number(a),"%")},tickLength:0,min:0,max:100},amount:{name:"amount",color:"black",tickColor:0,tickDecimals:0,tickFormatter:function(a){return UI.format.number(a)},tickLength:0,min:0},bytespersec:{name:"bytespersec",color:"black",tickColor:0,tickDecimals:1,tickFormatter:function(a){return UI.format.bytes(a,!0)},tickLength:0,ticks:function(a){var b=0.3*Math.sqrt($(".graph").first().height()),b=(a.max-
|
|
a.min)/b,c=Math.floor(Math.log(Math.abs(b))/Math.log(1024)),d=b/Math.pow(1024,c),e=-Math.floor(Math.log(d)/Math.LN10),g=a.tickDecimals;null!=g&&e>g&&(e=g);var m=Math.pow(10,-e),d=d/m,f;if(1.5>d)f=1;else if(3>d){if(f=2,2.25<d&&(null==g||e+1<=g))f=2.5,++e}else f=7.5>d?5:10;f=f*m*Math.pow(1024,c);null!=a.minTickSize&&f<a.minTickSize&&(f=a.minTickSize);a.delta=b;a.tickDecimals=Math.max(0,null!=g?g:e);a.tickSize=f;b=[];c=a.tickSize*Math.floor(a.min/a.tickSize);e=0;g=Number.NaN;do m=g,g=c+e*a.tickSize,
|
|
b.push(g),++e;while(g<a.max&&g!=m);return b},min:0}},xaxes:{time:{name:"time",mode:"time",timezone:"browser",ticks:5}}},draggable:function(a){a.attr("draggable",!0);a.on("dragstart",function(a){$(this).css("opacity",0.4).data("dragstart",{click:{x:a.originalEvent.pageX,y:a.originalEvent.pageY},ele:{x:this.offsetLeft,y:this.offsetTop}})}).on("dragend",function(a){var c=$(this).data("dragstart"),d=c.ele.x-c.click.x+a.originalEvent.pageX,a=c.ele.y-c.click.y+a.originalEvent.pageY;$(this).css({opacity:1,
|
|
top:a,left:d,right:"auto",bottom:"auto"})});a.parent().on("dragleave",function(){})},format:{time:function(a,b){var c=new Date(1E3*a),d=[];d.push(("0"+c.getHours()).slice(-2));d.push(("0"+c.getMinutes()).slice(-2));"short"!=b&&d.push(("0"+c.getSeconds()).slice(-2));return d.join(":")},date:function(a,b){var c=new Date(1E3*a),d="Sun Mon Tue Wed Thu Fri Sat".split(" "),e=[];"long"==b&&e.push(d[c.getDay()]);e.push(("0"+c.getDate()).slice(-2));e.push("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" ")[c.getMonth()]);
|
|
"short"!=b&&e.push(c.getFullYear());return e.join(" ")},dateTime:function(a,b){return UI.format.date(a,b)+", "+UI.format.time(a,b)},duration:function(a){var b=[0.001,1E3,60,60,24,7,1E9],c="ms sec min hr day week".split(" "),d={},e;for(e in c){var a=a/b[e],g=Math.round(a%b[Number(e)+1]);d[c[e]]=g;a-=g}var m;for(e=c.length-1;0<=e;e--)if(0<d[c[e]]){m=c[e];break}b=$("<span>");switch(m){case "week":b.append(UI.format.addUnit(d.week,"wks, ")).append(UI.format.addUnit(d.day,"days"));break;case "day":b.append(UI.format.addUnit(d.day,
|
|
"days, ")).append(UI.format.addUnit(d.hr,"hrs"));break;default:b.append([("0"+d.hr).slice(-2),("0"+d.min).slice(-2),("0"+d.sec).slice(-2)+(d.ms?"."+d.ms:"")].join(":"))}return b[0].innerHTML},number:function(a){if(isNaN(Number(a))||0==a)return a;var b=Math.pow(10,3-Math.floor(Math.log(a)/Math.LN10)-1),a=Math.round(a*b)/b;if(1E4<a){number=a.toString().split(".");for(a=/(\d+)(\d{3})/;a.test(number[0]);)number[0]=number[0].replace(a,"$1 $2");a=number.join(".")}return a},status:function(a){var b=$("<span>");
|
|
if("undefined"==typeof a.online)return b.text("Unknown, checking.."),"undefined"!=typeof a.error&&b.text(a.error),b;switch(a.online){case -1:b.text("Enabling");break;case 0:b.text("Unavailable").addClass("red");break;case 1:b.text("Active").addClass("green");break;case 2:b.text("Standby").addClass("orange");break;default:b.text(a.online)}"error"in a&&b.text(a.error);return b},capital:function(a){return a.charAt(0).toUpperCase()+a.substring(1)},addUnit:function(a,b){var c=$("<span>").html(a);c.append($("<span>").addClass("unit").html(b));
|
|
return c[0].innerHTML},bytes:function(a,b){var c="bytes KiB MiB GiB TiB PiB".split(" ");if(0==a)unit=c[0];else{var d=Math.floor(Math.log(Math.abs(a))/Math.log(1024));0>d?unit=c[0]:(a/=Math.pow(1024,d),unit=c[d])}return UI.format.addUnit(UI.format.number(a),unit+(b?"/s":""))}},navto:function(a,b){var c=location.hash,d=c.split("@");d[0]=[mist.user.name,mist.user.host].join("&");d[1]=[a,b].join("&");"undefined"!=typeof screenlog&&screenlog.navto(d[1]);location.hash=d.join("@");location.hash==c&&$(window).trigger("hashchange")},
|
|
showTab:function(a,b){var c=UI.elements.main;if(mist.user.loggedin&&!("ui_settings"in mist.data))c.html("Loading.."),mist.send(function(){UI.showTab(a,b)},{ui_settings:!0});else{var d=UI.elements.menu.removeClass("hide").find('.plain:contains("'+a+'")').closest(".button");0<d.length&&(UI.elements.menu.find(".button.active").removeClass("active"),d.addClass("active"));if("undefined"!=typeof mistvideo)for(var e in mistvideo)if("embedded"in mistvideo[e])for(var g in mistvideo[e].embedded)try{mistvideo[e].embedded[g].player.unload(),
|
|
delete mistvideo[e].embedded[g]}catch(m){}UI.interval.clear();c.html($("<h2>").text(a));switch(a){case "Login":if(mist.user.loggedin){UI.navto("Overview");return}UI.elements.menu.addClass("hide");UI.elements.connection.status.text("Disconnected").removeClass("green").addClass("red");c.append(UI.buildUI([{type:"help",help:"Please provide your account details.<br>You were asked to set these when MistController was started for the first time. If you did not yet set any account details, log in with your desired credentials to create a new account."},
|
|
{label:"Host",help:"Url location of the MistServer API. Generally located at http://MistServerIP:4242/api","default":"http://localhost:4242/api",pointer:{main:mist.user,index:"host"}},{label:"Username",help:"Please enter your username here.",validate:["required"],pointer:{main:mist.user,index:"name"}},{label:"Password",type:"password",help:"Please enter your password here.",validate:["required"],pointer:{main:mist.user,index:"rawpassword"}},{type:"buttons",buttons:[{label:"Login",type:"save","function":function(){mist.user.password=
|
|
MD5(mist.user.rawpassword);delete mist.user.rawpassword;mist.send(function(){UI.navto("Overview")})}}]}]));break;case "Create a new account":UI.elements.menu.addClass("hide");c.append($("<p>").text("No account has been created yet in the MistServer at ").append($("<i>").text(mist.user.host)).append("."));c.append(UI.buildUI([{type:"buttons",buttons:[{label:"Select other host",type:"cancel",css:{"float":"left"},"function":function(){UI.navto("Login")}}]},{type:"custom",custom:$("<br>")},{label:"Desired username",
|
|
type:"str",validate:["required"],help:"Enter your desired username. In the future, you will need this to access the Management Interface.",pointer:{main:mist.user,index:"name"}},{label:"Desired password",type:"password",validate:["required",function(a,b){$(".match_password").not($(b)).trigger("change");return false}],help:"Enter your desired password. In the future, you will need this to access the Management Interface.",pointer:{main:mist.user,index:"rawpassword"},classes:["match_password"]},{label:"Repeat password",
|
|
type:"password",validate:["required",function(a,b){return a!=$(".match_password").not($(b)).val()?{msg:'The fields "Desired password" and "Repeat password" do not match.',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");c.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)c.append("Unable to enable all protocols as protocol settings already exist.<br>");else{c.append("Retrieving available protocols..<br>");
|
|
mist.send(function(a){var b=[],d;for(d in a.capabilities.connectors)if(a.capabilities.connectors[d].required)c.append('Could not enable protocol "'+d+'" because it has required settings.<br>');else{b.push({connector:d});c.append('Enabled protocol "'+d+'".<br>')}c.append("Saving protocol settings..<br>");mist.send(function(){c.append("Protocols enabled. Redirecting..");setTimeout(function(){UI.navto("Overview")},5E3)},{config:{protocols:b}})},{capabilities:true})}}},{label:"Skip",type:"cancel","function":function(){UI.navto("Overview")}}]}]));
|
|
break;case "Overview":var f=$("<span>").text("Loading.."),q=$("<span>"),p=$("<span>").addClass("logs"),l=$("<span>"),u=$("<span>"),h=$("<span>"),i=$("<span>");c.append(UI.buildUI([{type:"help",help:"You can find most basic information about your MistServer here.<br>You can also set the debug level and force a save to the config.json file that MistServer uses to save your settings. "},{type:"span",label:"Version",pointer:{main:mist.data.config,index:"version"}},{type:"span",label:"Version check",value:f,
|
|
LTSonly:!0},{type:"span",label:"Server time",value:u},{type:"span",label:"Licensed to","default":"unknown",pointer:{main:mist.data.config.license,index:"user"},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:l},{type:"span",label:"Enabled protocols",value:h},{type:"span",label:"Disabled protocols",value:i},{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."},{type:"checkbox",
|
|
label:"Force configurations save",pointer:{main:mist.data,index:"save"},help:"Tick the box in order to force an immediate save to the config.json MistServer uses to save your settings. Saving will otherwise happen upon closing MistServer. Don't forget to press save after ticking the box."},{type:"buttons",buttons:[{type:"save",label:"Save","function":function(){var a={config:mist.data.config};if(mist.data.save)a.save=mist.data.save;mist.send(function(){UI.navto("Overview")},a)}}]}]));if(mist.data.LTS){var k=
|
|
function(a){"uptodate"in a?a.error?f.addClass("red").text(a.error):a.uptodate?f.text("Your version is up to date.").addClass("green"):f.addClass("red").text("Version outdated!").append($("<button>").text("Update").css({"font-size":"1em","margin-left":"1em"}).click(function(){if(confirm("Are you sure you want to execute a rolling update?")){f.addClass("orange").removeClass("red").text("Rolling update command sent..");mist.stored.del("update");mist.send(function(){UI.navto("Overview")},{autoupdate:true})}})):
|
|
f.text("Unknown")};if(!mist.stored.get().update||36E5<(new Date).getTime()-mist.stored.get().update.lastchecked){var j={};j.lastchecked=(new Date).getTime();mist.send(function(a){mist.stored.set("update",j);k(a.update)},{checkupdate:!0})}else mist.send(function(a){k(a.update)},{update:!0})}else f.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..";l.text(a);u.text(UI.format.dateTime(mist.data.config.time,"long"));p.html("");var a=0,b;for(b in mist.data.log){var c=mist.data.log[b];if(["FAIL","ERROR"].indexOf(c[1])>-1){a++;var d=$("<span>").addClass("content").addClass("red"),e=c[2].split("|");
|
|
for(b in e)d.append($("<span>").text(e[b]));p.append($("<div>").append($("<span>").append(UI.format.time(c[0]))).append(d));if(a==5)break}}a==0&&p.html("None.");a=[];c=[];for(b in mist.data.config.protocols){d=mist.data.config.protocols[b];a.indexOf(d.connector)>-1||a.push(d.connector)}h.text(a.length?a.join(", "):"None.");if("capabilities"in mist.data){for(b in mist.data.capabilities.connectors)a.indexOf(b)==-1&&c.push(b);i.text(c.length?c.join(", "):"None.")}else i.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});c.append("Loading..");return}var z=$("<tbody>");c.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),b;for(b in mist.data.config.protocols){var c=a.indexOf(mist.data.config.protocols[b].connector);c>-1&&a.splice(c,1)}var d=[];for(b in a)(!("required"in mist.data.capabilities.connectors[a[b]])||Object.keys(mist.data.capabilities.connectors[a[b]].required).length==0)&&d.push(a[b]);c="Click OK to enable disabled protocols with their default settings:\n ";
|
|
c=d.length?c+d.join(", "):c+"None.";if(d.length!=a.length){a=a.filter(function(a){return d.indexOf(a)<0});c=c+("\n\nThe following protocols can only be set manually:\n "+a.join(", "))}if(confirm(c)&&d.length){for(b in d)mist.data.config.protocols.push({connector:d[b]});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(z));
|
|
var K=function(){function a(b){var c=mist.data.capabilities.connectors[b.connector];if(!c)return"";var d=[],e=["required","optional"],g;for(g in e)for(var t in c[e[g]])b[t]&&b[t]!=""?d.push(t+": "+b[t]):c[e[g]][t]["default"]&&d.push(t+": "+c[e[g]][t]["default"]);return $("<span>").addClass("description").text(d.join(", "))}z.html("");for(var b in mist.data.config.protocols){var c=mist.data.config.protocols[b];z.append($("<tr>").data("index",b).append($("<td>").text(c.connector)).append($("<td>").html(UI.format.status(c))).append($("<td>").html(a(c))).append($("<td>").css("text-align",
|
|
"right").html($("<button>").text("Edit").click(function(){UI.navto("Edit Protocol",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the protocol "'+mist.data.config.protocols[a].connector+'"?')){mist.data.config.protocols.splice(a,1);mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}}))))}};K();UI.interval.set(function(){mist.send(function(){K()})},
|
|
3E4);break;case "Edit Protocol":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,b)},{capabilities:!0});c.append("Loading..");return}var H=!1;""!=b&&0<=b&&(H=!0);var L={};for(g in mist.data.config.protocols)L[mist.data.config.protocols[g].connector]=1;var ha=function(a){var c=mist.data.capabilities.connectors[a],d=mist.convertBuildOptions(c,n);d.push({type:"hidden",pointer:{main:n,index:"connector"},value:a});d.push({type:"buttons",buttons:[{type:"save",label:"Save",
|
|
"function":function(){if(H)mist.data.config.protocols[b]=n;else{if(!mist.data.config.protocols)mist.data.config.protocols=[];mist.data.config.protocols.push(n)}mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}},{type:"cancel",label:"Cancel","function":function(){UI.navto("Protocols")}}]});if("deps"in c&&c.deps!=""){$t=$("<span>").text("Dependencies:");$ul=$("<ul>");$t.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 L[c.deps[e]]!="undefined"||typeof L[c.deps[e]+".exe"]!="undefined"?a.append($("<span>").addClass("green").text("(Configured)")):a.append($("<span>").addClass("red").text("(Not yet configured)"))}d.unshift({type:"text",text:$t[0].innerHTML})}return UI.buildUI(d)},L={};for(g in mist.data.config.protocols)L[mist.data.config.protocols[g].connector]=1;if(H)n=d=mist.data.config.protocols[b],c.find("h2").append(' "'+d.connector+'"'),c.append(ha(d.connector));else{c.html($("<h2>").text("New Protocol"));
|
|
var n={},s=[["",""]];for(g in mist.data.capabilities.connectors)s.push([g,g]);var I=$("<span>");c.append(UI.buildUI([{label:"Protocol",type:"select",select:s,"function":function(){$(this).getval()!=""&&I.html(ha($(this).getval()))}}])).append(I)}break;case "Streams":if(!("capabilities"in mist.data)){c.html("Loading..");mist.send(function(){UI.navto(a)},{capabilities:!0});return}g=$("<button>");var D=$("<span>").text("Loading..");c.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(D);""==b&&(e=mist.stored.get(),"viewmode"in e&&(b=e.viewmode));g.text("Switch to "+("thumbnails"==b?"list":"thumbnail")+" view").click(function(){mist.stored.set("viewmode",b=="thumbnails"?"list":"thumbnails");UI.navto("Streams",b=="thumbnails"?"list":"thumbnails")});var y=$.extend(!0,{},mist.data.streams),U=function(a,
|
|
b){var c=$.extend({},b);delete c.meta;delete c.error;c.online=2;c.name=a;c.ischild=true;return c},V=function(b,d,e){D.remove();switch(b){case "thumbnails":var g=$("<div>").addClass("preview_icons"),f;f=e||[];d.sort();d.unshift("");D.remove();c.append($("<h2>").text(a)).append(UI.buildUI([{label:"Filter the streams",type:"datalist",datalist:d,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();$(this).attr("data-stream").indexOf(a)>-1&&$(this).show()})}}]));d.shift();c.append($("<span>").addClass("description").text("Choose a stream below.")).append(g);for(var h in d){var b=d[h],i="",k=$("<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 b={};mist.data.LTS?b.deletestream=[a]:b.streams=mist.data.streams;
|
|
mist.send(function(){UI.navto("Streams")},b)}}),j=$("<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"))}),m=$("<button>").text("Embed").click(function(){UI.navto("Embed",$(this).closest("div").attr("data-stream"))}),l=$("<span>").addClass("image");if(b.indexOf("+")>-1){i=b.split("+");i=mist.data.streams[i[0]].source+i[1];j=k="";l.addClass("wildcard")}else{i=
|
|
mist.data.streams[b].source;if(f.indexOf(b)>-1){m=e="";l.addClass("folder")}}g.append($("<div>").append($("<span>").addClass("streamname").text(b)).append(l).append($("<span>").addClass("description").text(i)).append($("<span>").addClass("button_container").append(j).append(k).append(e).append(m)).attr("title",b).attr("data-stream",b))}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.append(h);h.stupidtable();var o=function(){var a=[],b;for(b in mist.data.active_streams)a.push({streams:[mist.data.active_streams[b]],fields:["clients"],start:-2});mist.send(function(){$.extend(true,
|
|
y,mist.data.streams);var a=0;n.html("");d.sort();for(var b in d){var c=d[b],e;e=c in mist.data.streams?mist.data.streams[c]:y[c];var g=$("<td>").css("text-align","right").html($("<span>").addClass("description").text("Loading..")),t=0;if(typeof mist.data.totals!="undefined"&&typeof mist.data.totals[c]!="undefined"){var f=mist.data.totals[c].all_protocols.clients,t=0;if(f.length){for(a in f)t=t+f[a][1];t=Math.round(t/f.length)}}g.html(UI.format.number(t));if(t==0&&e.online==1)e.online=2;t=$("<td>").css("text-align",
|
|
"right").css("white-space","nowrap");(!("ischild"in e)||!e.ischild)&&t.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 b={};mist.data.LTS?b.deletestream=[a]:b.streams=mist.data.streams;mist.send(function(){UI.navto("Streams")},b)}}));f=$("<span>").text(c);
|
|
e.ischild&&f.css("padding-left","1em");var h=UI.format.status(e),i=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("tr").data("index"))}),k=$("<button>").text("Embed").click(function(){UI.navto("Embed",$(this).closest("tr").data("index"))});if("filesfound"in y[c]){h.html("");i="";g.html("");k=""}n.append($("<tr>").data("index",c).html($("<td>").html(f).attr("title",c).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(k)).append(t));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||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,b){var c=b.stream,d;for(d in a.browse.files)for(var e in mist.data.capabilities.inputs)if(!(e.indexOf("Buffer")>=
|
|
0||e.indexOf("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=c+"+"+a.browse.files[d];y[g]=U(g,mist.data.streams[c]);y[g].source=mist.data.streams[c].source+a.browse.files[d]}"files"in a.browse&&a.browse.files.length?y[c].filesfound=true:mist.data.streams[c].filesfound=false;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()},5E3)}}};if(mist.data.LTS){var W=0,ia=0,s={},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,c){var d=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||mist.inputMatch(mist.data.capabilities.inputs[g].source_match,"/"+a.browse.files[e])&&(s[d+"+"+a.browse.files[e]]=true);ia++;W==ia&&mist.send(function(){for(var a in mist.data.active_streams){var c=mist.data.active_streams[a].split("+");if(c.length>1&&c[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[c[0]])}}s=Object.keys(s);s=s.concat(Object.keys(mist.data.streams));s.sort();V(b,
|
|
s,ja)},{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 c=mist.data.active_streams[a].split("+");if(c.length>1&&c[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[c[0]])}}s=Object.keys(s);mist.data.streams&&(s=s.concat(Object.keys(mist.data.streams)));s.sort();V(b,s)},{active_streams:!0})}else V(b,Object.keys(mist.data.streams));
|
|
break;case "Edit":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,b)},{capabilities:!0});c.append("Loading..");return}H=!1;""!=b&&(H=!0);if(H){var r=b,n=mist.data.streams[r];c.find("h2").append(' "'+r+'"')}else c.html($("<h2>").text("New Stream")),n={};r=[];for(g in mist.data.capabilities.inputs)r.push(mist.data.capabilities.inputs[g].source_match);var P=$("<div>"),ka=function(a){if(!mist.data.streams)mist.data.streams={};mist.data.streams[n.name]=n;b!=n.name&&delete mist.data.streams[b];
|
|
var c={};if(mist.data.LTS){c.addstream={};c.addstream[n.name]=n;if(b!=n.name)c.deletestream=[b]}else c.streams=mist.data.streams;if(n.stop_sessions&&b!=""){c.stop_sessions=b;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:"")},c)},la=$("<style>").text("button.saveandpreview { display: none; }"),E=$("<span>"),X=function(){var a=c.find("[name=name]").val();if(a){var b=parseURL(mist.user.host),d=
|
|
c.find("[name=source]").val().match(/@.*/);d&&(d=d[0].substring(1));var e=c.find("[name=source]").val().replace(/(?:.+?):\/\//,""),e=e.split("/"),e=e[0],e=e.split(":"),e=e[0],g={},f=["RTMP","RTSP","TS","RTMP.exe","RTSP.exe","TS.exe"],h;for(h in f)f[h]in mist.data.capabilities.connectors&&(g[f[h]]=mist.data.capabilities.connectors[f[h]].optional.port["default"]);var f={RTMP:1935,"RTMP.exe":1935,RTSP:554,"RTSP.exe":554,TS:-1,"TS.exe":-1},i;for(i in g){for(h in mist.data.config.protocols){var k=mist.data.config.protocols[h];
|
|
if(k.connector==i){if("port"in k)g[i]=k.port;break}}g[i]=g[i]==f[i]?"":":"+g[i]}E.find(".field").closest("label").hide();for(h in g){var j;switch(h){case "RTMP":case "RTMP.exe":j="rtmp://"+b.host+g[h]+"/"+(d?d:"live")+"/";E.find(".field.RTMPurl").setval(j).closest("label").show();E.find(".field.RTMPkey").setval(a==""?"STREAMNAME":a).closest("label").show();j=j+(a==""?"STREAMNAME":a);break;case "RTSP":case "RTSP.exe":j="rtsp://"+b.host+g[h]+"/"+(a==""?"STREAMNAME":a)+(d?"?pass="+d:"");break;case "TS":case "TS.exe":j=
|
|
"udp://"+(e==""?b.host:e)+g[h]+"/"}E.find(".field."+h.replace(".exe","")).setval(j).closest("label").show()}}};c.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:r,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>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><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></table>",
|
|
"function":function(){var a=$(this).val();la.remove();E.html("");if(a!=""){var b=null,d;for(d in mist.data.capabilities.inputs)if(typeof mist.data.capabilities.inputs[d].source_match!="undefined"&&mist.inputMatch(mist.data.capabilities.inputs[d].source_match,a)){b=d;break}if(b===null)P.html($("<h3>").text("Unrecognized input").addClass("red")).append($("<span>").text("Please edit the stream source.").addClass("red"));else{b=mist.data.capabilities.inputs[b];P.html($("<h3>").text(b.name+" Input options"));
|
|
var e=mist.convertBuildOptions(b,n);"always_match"in mist.data.capabilities.inputs[d]&&mist.inputMatch(mist.data.capabilities.inputs[d].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(b.name=="Folder")c.append(la);else if(["Buffer","Buffer.exe","TS","TS.exe"].indexOf(b.name)>-1){a=[$("<span>").text("Configure your source to push to:")];switch(b.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"]});
|
|
break;case "TS":case "TS.exe":a.push({label:"TS",type:"span",clipboard:true,readonly:true,classes:["TS"]})}E.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"}},E,$("<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."},
|
|
{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")}},
|
|
{type:"save",label:"Save and Preview","function":function(){ka("Preview")},classes:["saveandpreview"]}]}]));c.find("[name=name]").keyup(function(){X()});X();break;case "Preview":""==b&&UI.navto("Streams");e=":8080";for(g in mist.data.config.protocols)if(d=mist.data.config.protocols[g],"HTTP"==d.connector||"HTTP.exe"==d.connector)e=d.port?":"+d.port:":8080";var r=parseURL(mist.user.host),Q=r.protocol+r.host+e+"/",I=$("<div>").css({display:"flex","flex-flow":"row wrap"}),r="";-1==b.indexOf("+")&&(r=
|
|
$("<button>").text("Settings").addClass("settings").click(function(){UI.navto("Edit",b)}));c.html($("<div>").addClass("bigbuttons").append(r).append($("<button>").text("Embed").addClass("embed").click(function(){UI.navto("Embed",b)})).append($("<button>").addClass("cancel").addClass("return").text("Return").click(function(){UI.navto("Streams")}))).append($("<h2>").text('Preview of "'+b+'"')).append(I);var F=encodeURIComponent(b);g=$("<div>");I.append(g);var Y=$("<div>"),R=$("<select>").append($("<option>").text("Automatic").val("")).change(function(){Z()}),
|
|
M=$("<select>").append($("<option>").text("Automatic").val("")).change(function(){Z()}),r=UI.buildUI([{label:"Use player",type:"DOMfield",DOMfield:R,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(Y).append(r);var Z=function(){A.html("");if(typeof mistvideo!="undefined")for(var a in mistvideo)if("embedded"in mistvideo[a])for(var c in mistvideo[a].embedded)try{mistvideo[a].embedded[c].player.unload()}catch(d){}a=
|
|
{target:N[0],maxheight:window.innerHeight-$("header").height(),maxwidth:window.innerWidth-UI.elements.menu.width()-100,loop:true};if(R.val()!="")a.forcePlayer=R.val();if(M.val()!="")a.forceSource=M.val();mistPlay(b,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 b=false;A.height()+A.scrollTop()==A[0].scrollHeight&&(b=true);var c=a.type+a.originalEvent.message,d="["+UI.format.time((new Date).getTime()/
|
|
1E3)+"]";if(ma==c){var a=A.children().last(),b=a.children("[data-amount]"),e=b.attr("data-amount");e++;b.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":""));b&&A.scrollTop(A[0].scrollHeight)}ma=c});var na=function(){Y.text("");
|
|
var a=document.createElement("script");c.append(a);a.src=Q+"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 d in mistplayers)R.append($("<option>").text(mistplayers[d].name).val(d));Z();N.on("initialized",function(){if(M.children().length<=1)for(var a in mistvideo[b].source){var c=mistvideo[b].source[a],d=UI.humanMime(c.type);M.append($("<option>").val(a).text(d?d+" @ "+
|
|
c.url.substring(c.url.length-c.relurl.length,0):UI.format.capital(c.type)+" @ "+c.url.substring(c.url.length-c.relurl.length,0)))}a=mistvideo[b].embedded[mistvideo[b].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+".")});c[0].removeChild(a)}};na();g=$("<div>").append($("<h3>").text("Meta information"));
|
|
var S=$("<span>").text("Loading..");g.append(S);I.append(g);$.ajax({type:"GET",url:Q+"json_"+F+".js",success:function(a){var b=a.meta;if(!b||!b.tracks)S.html("No meta information available.");else{a=[];a.push({label:"Type",type:"span",value:b.live?"Live":"Pre-recorded (VoD)"});"format"in b&&a.push({label:"Format",type:"span",value:b.format});b.live&&a.push({label:"Buffer window",type:"span",value:UI.format.addUnit(b.buffer_window,"ms")});var c={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(b.tracks);d.sort(function(a,b){a=a.split("_").pop();b=b.split("_").pop();return a-b});for(var e in d){var g=d[e],f=b.tracks[g];switch(f.type){case "audio":c.audio.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),f.channels,UI.format.addUnit(UI.format.number(f.rate),"Hz"),"lang"in f?f.lang:"unknown"]});break;case "video":c.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,
|
|
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":c.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"];b=$("<div>").css({display:"flex",
|
|
"flex-flow":"row wrap","font-size":"0.9em"});for(g in e)c[e[g]].content.length&&b.append(UI.buildVheaderTable(c[e[g]]).css("width","auto"));a.push($("<span>").text("Tracks:"));a.push(b);S.html(UI.buildUI(a))}},error:function(){S.html("Error while retrieving stream info.")}});break;case "Embed":""==b&&UI.navTo("Streams");r="";-1==b.indexOf("+")&&(r=$("<button>").addClass("settings").text("Settings").click(function(){UI.navto("Edit",b)}));c.html($("<div>").addClass("bigbuttons").append(r).append($("<button>").text("Preview").addClass("preview").click(function(){UI.navto("Preview",
|
|
b)})).append($("<button>").addClass("cancel").addClass("return").text("Return").click(function(){UI.navto("Streams")}))).append($("<h2>").text('Embed "'+b+'"'));var T=$("<span>");c.append(T);F=encodeURIComponent(b);r=parseURL(mist.user.host);e={"":{port:":8080"}};for(g in mist.data.config.protocols){d=mist.data.config.protocols[g];if("HTTP"==d.connector||"HTTP.exe"==d.connector)e[""].port=d.port?":"+d.port:":8080";if("HTTPS"==d.connector||"HTTPS.exe"==d.connector)e.s={},e.s.port=d.port?":"+d.port:
|
|
":4433"}var G=Q="http://"+r.host+e[""].port+"/";if(otherhost.host||otherhost.https)G=(otherhost.https&&"s"in e?"https://":"http://")+(otherhost.host?otherhost.host:r.host)+(otherhost.https&&"s"in e?e.s.port:e[""].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 w=function(){function a(b){switch(typeof b){case "string":return $.isNumeric(b)?b:'"'+b+'"';case "object":return JSON.stringify(b);default:return b}}UI.stored.saveOpt("embedoptions",o);for(var c=b+"_",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 c=c+e,d=['target: document.getElementById("'+c+'")'],
|
|
f;for(f in o)o[f]!=aa[f]&&(typeof o[f]!="object"||JSON.stringify(o[f])!=JSON.stringify(aa[f]))&&d.push(f+": "+a(o[f]));f=[];f.push('<div class="mistvideo" id="'+c+'">');f.push(" <noscript>");f.push(' <a href="'+G+F+'.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("'+b+'",{');f.push(" "+d.join(",\n "));f.push(" });");f.push(" };");
|
|
f.push(" if (!window.mistplayers) {");f.push(' var p = document.createElement("script");');f.push(' p.src = "'+G+'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")},ba=$("<span>").text("Loading.."),d=w(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()!=
|
|
otherhost.https){otherhost.https=$(this).getval();UI.navto("Embed",b)}},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:r.host)).append($("<span>").addClass("unit").append($("<button>").text("Apply").click(function(){otherhost.host=
|
|
$(this).closest("label").find("input").val();UI.navto("Embed",b)}))))).append(oa)).append(UI.buildUI([$("<h3>").text("Urls"),{label:"Stream info json",type:"str",value:G+"json_"+F+".js",readonly:!0,clipboard:!0,help:"Information about this stream as a json page."},{label:"Stream info script",type:"str",value:G+"info_"+F+".js",readonly:!0,clipboard:!0,help:"This script loads information about this stream into a mistvideo javascript object."},{label:"HTML page",type:"str",value:G+F+".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:d,rows:d.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(w(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(w(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(w(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(w(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(w(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(w(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(w(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(w(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(w(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(w(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(w(o))}},{label:"Preselect tracks",type:"DOMfield",DOMfield:J,help:"Pre-select these tracks."},$("<h3>").text("Protocol stream urls"),ba]));$.ajax({type:"GET",url:G+"json_"+F+".js",success:function(a){var b=[],c=T.find(".forceType"),d;for(d in a.source){var e=a.source[d],f=UI.humanMime(e.type);b.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);
|
|
c.append($("<option>").text(f?f+" ("+e.type+")":UI.format.capital(e.type)).val(e.type))}ba.html(UI.buildUI(b));J.html("");b={};for(d in a.meta.tracks){c=a.meta.tracks[d];c.type!="audio"&&c.type!="video"||(c.type in b?b[c.type].push([c.trackid,UI.format.capital(c.type)+" track "+(b[c.type].length+1)]):b[c.type]=[["",UI.format.capital(c.type)+" track 1"]])}if(Object.keys(b).length){J.closest("label").show();for(d in b){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(w(o))});J.append(a);b[d].push([-1,"No "+d]);for(var g in b[d])a.append($("<option>").val(b[d][g][0]).text(b[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(w(o))}}}}else J.closest("label").hide()},error:function(){ba.html("Error while retrieving stream info.");J.closest("label").hide();o.setTracks=
|
|
{}}});g=document.createElement("script");g.src=Q+"player.js";document.head.appendChild(g);g.onload=function(){var a=T.find(".forcePlayer"),b;for(b in mistplayers)a.append($("<option>").text(mistplayers[b].name).val(b));document.head.removeChild(this)};g.onerror=function(){document.head.removeChild(this)};break;case "Push":var B=$("<div>").text("Loading..");c.append(B);mist.send(function(a){function b(a){setTimeout(function(){mist.send(function(c){var d=false;if("push_list"in c&&c.push_list&&c.push_list.length){var d=
|
|
true,f;for(f in c.push_list)if(a.indexOf(c.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 b()},{push_list:1})},1E3)}function c(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 "+
|
|
$(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(){b([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 "+
|
|
f[2]+'"?'+(d.wait!=0?"\n\nRetrying is enabled. You'll probably want to set that to 0.":""))){var c=$(this);c.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(){c.text("Stop pushes");b(g)},{push_stop:g,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"},
|
|
LTSonly:1},{label:"Maximum retries",unit:"/s",type:"int",min:0,help:"The maximum amount of retries per second (for all automatic pushes).<br>If set to 0, there is no limit.","default":0,pointer:{main:d,index:"maxspeed"},LTSonly:1},{type:"buttons",buttons:[{type:"save",label:"Save","function":function(){mist.send(function(){UI.navto("Push")},{push_settings:d})}}]}]));var e=$("<table>").append($("<tr>").append($("<th>").text("Stream")).append($("<th>").text("Target")).append($("<th>"))),f=e.clone();
|
|
if("push_list"in a)for(var g in a.push_list)e.append(c(a.push_list[g],"Manual"));if("push_auto_list"in a)for(g in a.push_auto_list)f.append(c([-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);
|
|
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]);
|
|
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 c=[],d;for(d in a.push_list)c.push(a.push_list[d][0]);if(c.length!=0&&confirm("Are you sure you want to stop all pushes?")){mist.send(function(){b(c)},{push_stop:c});e.find("tr:not(:first-child)").html($("<td colspan=99>").append($("<span>").addClass("red").text("Stopping..")));
|
|
$(this).remove()}})).append($("<label>").css("margin-left","1em").append($("<span>").text("Stop all pushes that match: ").css("font-size","0.9em")).append(i).append($("<span>").css("margin-left","0.5em").text("and").css("font-size","0.9em")).append(j).append($("<button>").css("margin-left","0.5em").text("Apply").click(function(){var c=i.val(),d=j.val();if(c==""&&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((c==""||
|
|
a.push_list[g][1]==c)&&(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.");c="Are you sure you want to stop these pushes?\n\n";for(g in f)c=c+(f[g][1]+" to "+f[g][2]+"\n");if(confirm(c)){f=Object.keys(f);mist.send(function(){b(f)},{push_stop:f});for(g in f)e.find("tr[data-pushid="+f[g]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}}))).append(e)}},{push_settings:1,push_list:1,push_auto_list:1});
|
|
break;case "Start Push":if(!("capabilities"in mist.data)){c.append("Loading Mist capabilities..");mist.send(function(){UI.navto("Start Push",b)},{capabilities:1});return}var v,ca=function(){var a=[],d;for(d in mist.data.capabilities.connectors){var f=mist.data.capabilities.connectors[d];"push_urls"in f&&(a=a.concat(f.push_urls))}b=="auto"&&c.find("h2").text("Add automatic push");var e={};c.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:v,LTSonly:1},{label:"Target",type:"str",help:"Where the stream will be pushed to.<br>Valid formats:<ul><li>"+a.join("</li><li>")+"</li></ul> Valid text replacements:<ul><li>$stream - inserts the stream name used to push to MistServer</li><li>$day - inserts the current day number</li><li>$month - inserts the current month number</li><li>$year - inserts the current year number</li><li>$hour - inserts the hour timestamp when stream was received</li><li>$minute - inserts the minute timestamp the stream was received</li><li>$seconds - inserts the seconds timestamp when the stream was received</li><li>$datetime - inserts $year.$month.$day.$hour.$minute.$seconds timestamp when the stream was received</li>",
|
|
pointer:{main:e,index:"target"},validate:["required",function(b){for(var c in a)if(mist.inputMatch(a[c],b))return false;return{msg:"Does not match a valid target.<br>Valid formats:<ul><li>"+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[b=="auto"?"push_auto_add":"push_start"]=e;mist.send(function(){UI.navto("Push")},a)}}]}]))};mist.data.LTS?
|
|
mist.send(function(a){(v=a.active_streams)||(v=[]);var a=[],b;for(b in v)v[b].indexOf("+")!=-1&&a.push(v[b].replace(/\+.*/,"")+"+");v=v.concat(a);var c=0,d=0;for(b in mist.data.streams){v.push(b);if(mist.inputMatch(UI.findInput("Folder").source_match,mist.data.streams[b].source)){v.push(b+"+");mist.send(function(a,b){var f=b.stream,e;for(e in a.browse.files)for(var g in mist.data.capabilities.inputs)g.indexOf("Buffer")>=0||(g.indexOf("Folder")>=0||g.indexOf("Buffer.exe")>=0||g.indexOf("Folder.exe")>=
|
|
0)||mist.inputMatch(mist.data.capabilities.inputs[g].source_match,"/"+a.browse.files[e])&&v.push(f+"+"+a.browse.files[e]);d++;if(c==d){v=v.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();ca()}},{browse:mist.data.streams[b].source},{stream:b});c++}}if(c==d){v=v.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();ca()}},{active_streams:1}):(v=Object.keys(mist.data.streams),ca());break;case "Triggers":"triggers"in mist.data.config||(mist.data.config.triggers={});z=$("<tbody>");e=
|
|
$("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Trigger on").attr("data-sort-type","string").addClass("sorting-asc")).append($("<th>").text("Applies to").attr("data-sort-type","string")).append($("<th>").text("Handler").attr("data-sort-type","string")).append($("<th>")))).append(z);c.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);
|
|
e.stupidtable();e=mist.data.config.triggers;for(g in e)for(r in e[g])d=triggerRewrite(e[g][r]),z.append($("<tr>").attr("data-index",g+","+r).append($("<td>").text(g)).append($("<td>").text("streams"in d?d.streams.join(", "):"")).append($("<td>").text(d.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={});b?(b=b.split(","),g=triggerRewrite(mist.data.config.triggers[b[0]][b[1]]),n={triggeron:b[0],appliesto:g.streams,url:g.handler,async:g.sync,
|
|
"default":g["default"],params:g.params}):(c.html($("<h2>").text("New Trigger")),n={});c.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"],
|
|
["STREAM_UNLOAD","STREAM_UNLOAD: right before the stream input is removed from memory"],["STREAM_PUSH","STREAM_PUSH: right before an incoming push is accepted"],["STREAM_TRACK_ADD","STREAM_TRACK_ADD: right before a track will be added to a stream; e.g.: additional push received"],["STREAM_TRACK_REMOVE","STREAM_TRACK_REMOVE: right before a track will be removed track from a stream; e.g.: push timeout"],["STREAM_BUFFER","STREAM_BUFFER: when a buffer changes between mostly full or mostly empty"],["RTMP_PUSH_REWRITE",
|
|
"RTMP_PUSH_REWRITE: allows rewriting of RTMP push URLs from external to internal representation before further parsing"],["PUSH_OUT_START","PUSH_OUT_START: before recording/pushing, allow target changes."],["RECORDING_END","RECORDING_END: after a recording finishes."],["CONN_OPEN","CONN_OPEN: right after a new incoming connection has been received"],["CONN_CLOSE","CONN_CLOSE: right after a connection has been closed"],["CONN_PLAY","CONN_PLAY: right before a stream playback of a connection"],["USER_NEW",
|
|
"USER_NEW: a new user connects that hasn't been allowed or denied access before"],["LIVE_BANDWIDTH","LIVE_BANDWIDTH: when the value specified as param is surpassed"]],LTSonly:!0,validate:["required"],"function":function(){switch($(this).getval()){case "SYSTEM_START":case "SYSTEM_STOP":case "SYSTEM_CONFIG":case "OUTPUT_START":case "OUTPUT_STOP":case "RTMP_PUSH_REWRITE":$("[name=appliesto]").setval([]).closest(".UIelement").hide();$("[name=params]").setval("").closest(".UIelement").hide();break;case "LIVE_BANDWIDTH":$("[name=appliesto]").closest(".UIelement").show();
|
|
$("[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"},
|
|
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(){b&&mist.data.config.triggers[b[0]].splice(b[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"]};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(){da();pa.text("Refresh now")})}).css("padding","0.2em 0.5em").css("flex-grow",0);c.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."}]));c.append($("<button>").text("Purge logs").click(function(){mist.send(function(){mist.data.log=[];UI.navto("Logs")},{clearstatlogs:true})}));z=$("<tbody>").css("font-size","0.9em");c.append($("<table>").addClass("logs").append(z));var ra=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();z.html("");for(var b in a){var c=$("<span>").addClass("content"),d=a[b][2].split("|"),f;for(f in d)c.append($("<span>").text(d[f]));z.append($("<tr>").html($("<td>").text(UI.format.dateTime(a[b][0],"long")).css("white-space","nowrap")).append($("<td>").html(ra(a[b][1])).css("text-align","center")).append($("<td>").html(c).css("text-align","left")))}}};da();break;case "Statistics":var C=$("<span>").text("Loading..");c.append(C);var n={graph:"new"},x=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(),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"),b=C.find(".graph_id");if($(this).val()=="new"){a.children("option").prop("disabled",false);b.setval("Graph "+(Object.keys(x).length+
|
|
1)).closest("label").show()}else{var c=x[$(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 x?{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()+'"]: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:",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);x[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=
|
|
x[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(x)}}]}]));var b=$("<div>").addClass("graph_container");c.append(b);var d=C.find("select.graph_ids");for(a in x){var f=UI.plot.addGraph(x[a],b);d.append($("<option>").text(f.id)).val(f.id);var e=[],g;for(g in x[a].datasets){var h=UI.plot.datatype.getOptions({datatype:x[a].datasets[g].datatype,origin:x[a].datasets[g].origin});e.push(h)}f.datasets=e;x[f.id]=f}d.trigger("change");
|
|
UI.plot.go(x);UI.interval.set(function(){UI.plot.go(x)},1E4)},{active_streams:!0,capabilities:!0});break;case "Server Stats":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});c.append("Loading..");return}var fa=$("<table>"),D=$("<table>"),r={vheader:"CPUs",labels:["Model","Processor speed","Amount of cores","Amount of threads"],content:[]};for(g in mist.data.capabilities.cpu)e=mist.data.capabilities.cpu[g],r.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(r);var qa=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);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(b.fifteen/100)]}]};b=UI.buildVheaderTable(b);D.replaceWith(b);D=
|
|
b};qa();c.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(D))).append($("<tr>").append($("<td>").append(g).attr("colspan",2))));UI.interval.set(function(){mist.send(function(){qa()},{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={};c.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","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();c.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:c.append($("<p>").text("This tab does not exist."))}c.find(".field").filter(function(){var a=$(this).getval();return a==""||a==null?true:false}).each(function(){var a=[];$(this).is("input, select, textarea")?a.push($(this)):
|
|
a=$(this).find("input, select, textarea");if(a.length){$(a[0]).focus();return false}})}}};"origin"in location||(location.origin=location.protocol+"//");var host;host="file://"==location.origin?"http://localhost:4242/api":location.origin+location.pathname.replace(/\/+$/,"")+"/api";
|
|
var mist={data:{},user:{name:"",password:"",host:host},send:function(a,b,c){var b=b||{},c=c||{},c=$.extend(true,{timeOut:3E4,sendData:b},c),d={authorize:{password:mist.user.authstring?MD5(mist.user.password+mist.user.authstring):"",username:mist.user.name}};$.extend(true,d,b);log("Send",$.extend(true,{},b));d={url:mist.user.host,type:"POST",data:{command:JSON.stringify(d)},dataType:"jsonp",crossDomain:true,timeout:c.timeout*1E3,async:true,error:function(d,e){delete mist.user.loggedin;if(!c.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,b,c)}))}UI.navto("Login")},success:function(d){log("Receive",$.extend(true,{},d),"as reply to",c.sendData);
|
|
delete mist.user.loggedin;switch(d.authorize.status){case "OK":if("streams"in d)if(d.streams)if("incomplete list"in d.streams){delete d.streams["incomplete list"];$.extend(mist.data.streams,d.streams)}else mist.data.streams=d.streams;else mist.data.streams={};var e=$.extend({},d),f=["config","capabilities","ui_settings","LTS","active_streams","browse","log","totals"],q;for(q in e)f.indexOf(q)==-1&&delete e[q];$.extend(true,mist.data,e);mist.user.loggedin=true;UI.elements.connection.status.text("Connected").removeClass("red").addClass("green");
|
|
UI.elements.connection.user_and_host.text(mist.user.name+" @ "+mist.user.host);UI.elements.connection.msg.removeClass("red").text("Last communication with the server at "+UI.format.time((new Date).getTime()/1E3));d.LTS&&UI.elements.menu.find(".LTSonly").removeClass("LTSonly");if(d.log){e=d.log[d.log.length-1];UI.elements.connection.msg.append($("<br>")).append("Last log entry: "+UI.format.time(e[0])+" ["+e[1]+"] "+e[2])}if("totals"in d){e=function(a,b,c){var d;d=function(){for(var a in c.fields)e[c.fields[a]].push([m,
|
|
0])};var e={},f;for(f in c.fields)e[c.fields[f]]=[];var g=0,m;if(c.data){if(c.start>mist.data.config.time-600){m=(mist.data.config.time-600)*1E3;d();m=c.start*1E3;d()}else m=c.start*1E3;for(f in c.data){if(f==0){m=c.start*1E3;var q=0}else{m=m+c.interval[q][1]*1E3;c.interval[q][0]--;if(c.interval[q][0]<=0){q++;q<c.interval.length-1&&(g=g+2)}}if(g%2==1){d();g--}for(var K in c.data[f])e[c.fields[K]].push([m,c.data[f][K]]);if(g){d();g--}}if(mist.data.config.time-c.end>20){d();m=(mist.data.config.time-
|
|
15)*1E3;d()}}else{m=(mist.data.config.time-600)*1E3;d();m=(mist.data.config.time-15)*1E3;d()}d=e;stream=a?a.join(" "):"all_streams";protocol=b?b.join("_"):"all_protocols";stream in mist.data.totals||(mist.data.totals[stream]={});protocol in mist.data.totals[stream]||(mist.data.totals[stream][protocol]={});$.extend(mist.data.totals[stream][protocol],d)};mist.data.totals={};if("fields"in d.totals)e(b.totals.streams,b.totals.protocols,d.totals);else for(q in d.totals)e(b.totals[q].streams,b.totals[q].protocols,
|
|
d.totals[q])}a&&a(d,c);break;case "CHALL":if(d.authorize.challenge==mist.user.authstring){mist.user.password!=""&&UI.elements.connection.msg.text("The credentials you provided are incorrect.").addClass("red");UI.navto("Login")}else if(mist.user.password=="")UI.navto("Login");else{mist.user.authstring=d.authorize.challenge;mist.send(a,b,c);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 b.authorize;mist.send(a,b,c);break;default:UI.navto("Login")}}};c.hide||UI.elements.connection.msg.removeClass("red").text("Data sent, waiting for a reply..").append($("<br>")).append($("<a>").text("Cancel request").click(function(){e.abort()}));var e=$.ajax(d)},inputMatch:function(a,b){if(typeof a=="undefined")return false;typeof a=="string"&&(a=[a]);for(var c in a){var d=a[c].replace(/[^\w\s]/g,"\\$&"),d=d.replace(/\\\?/g,".").replace(/\\\*/g,"(?:.)*");if(RegExp("^(?:[a-zA-Z]:)?"+
|
|
d+"$","i").test(b))return true}return false},convertBuildOptions:function(a,b){var c=[],d=["required","optional"];"desc"in a&&c.push({type:"help",help:a.desc});for(var e in d)if(a[d[e]]){c.push($("<h4>").text(UI.format.capital(d[e])+" parameters"));for(var g in a[d[e]]){var m=a[d[e]][g],f={label:UI.format.capital(m.name),pointer:{main:b,index:g},validate:[]};d[e]=="required"&&(!("default"in m)||m["default"]=="")&&f.validate.push("required");if("default"in m)f.placeholder=m["default"];if("help"in m)f.help=
|
|
m.help;if("unit"in m)f.unit=m.unit;switch(m.type){case "int":f.type="int";break;case "uint":f.type="int";f.min=0;break;case "debug":f.type="debug";break;case "select":f.type="select";f.select=m.select;break;default:f.type="str"}c.push(f)}}return c},stored:{get:function(){return mist.data.ui_settings||{}},set:function(a,b){var c=this.get();c[a]=b;mist.send(function(){},{ui_settings:c})},del:function(a){delete mist.data.ui_settings[a];mist.send(function(){},{ui_settings:mist.data.ui_settings})}}};
|
|
function log(){try{UI.debug&&[].push.call(arguments,Error().stack);[].unshift.call(arguments,"["+UI.format.time((new Date).getTime()/1E3)+"]");console.log.apply(console,arguments)}catch(a){}}
|
|
$.fn.getval=function(){var a=$(this).data("opts"),b=$(this).val();if(a&&"type"in a)switch(a.type){case "span":b=$(this).html();break;case "checkbox":b=$(this).prop("checked");break;case "radioselect":a=$(this).find("label > input[type=radio]:checked").parent();if(a.length){b=[];b.push(a.children("input[type=radio]").val());a=a.children("select");a.length&&b.push(a.val())}else b="";break;case "checklist":b=[];$(this).find(".checklist input[type=checkbox]:checked").each(function(){b.push($(this).attr("name"))})}return b};
|
|
$.fn.setval=function(a){var b=$(this).data("opts");$(this).val(a);if(b&&"type"in b)switch(b.type){case "span":$(this).html(a);break;case "checkbox":$(this).prop("checked",a);break;case "geolimited":case "hostlimited":b=$(this).closest(".field_container").data("subUI");if(typeof a=="undefined"||a.length==0)a="-";b.blackwhite.val(a.charAt(0));var a=a.substr(1).split(" "),c;for(c in a)b.values.append(b.prototype.clone(true).val(a[c]));b.blackwhite.trigger("change");break;case "radioselect":if(typeof a==
|
|
"undefined")return $(this);c=$(this).find('label > input[type=radio][value="'+a[0]+'"]').prop("checked",true).parent();a.length>1&&c.children("select").val(a[1]);break;case "checklist":b=$(this).find(".checklist input[type=checkbox]").prop("checked",false);for(c in a)b.filter('[name="'+a[c]+'"]').prop("checked",true)}$(this).trigger("change");return $(this)};function parseURL(a){var b=document.createElement("a");b.href=a;return{protocol:b.protocol+"//",host:b.hostname,port:b.port?":"+b.port:""}}
|
|
function triggerRewrite(a){return typeof a=="object"&&typeof a.length=="undefined"?a:obj={handler:a[0],sync:a[1],streams:a[2],"default":a[3]}};
|