LSP: bugfix embed page

This commit is contained in:
Cat 2019-03-28 10:57:08 +01:00
parent 3a025c8a03
commit 5ee53f9cca
3 changed files with 18 additions and 18 deletions

View file

@ -12,9 +12,9 @@ elementIn () {
echo "Minimizing LSP..";
if elementIn "lsp/plugins/md5.js" "${CHANGES[@]}" || elementIn "lsp/plugins/cattablesort.js" "${CHANGES[@]}" || elementIn "lsp/mist.js" "${CHANGES[@]}" ; then
#if elementIn "lsp/plugins/md5.js" "${CHANGES[@]}" || elementIn "lsp/plugins/cattablesort.js" "${CHANGES[@]}" || elementIn "lsp/mist.js" "${CHANGES[@]}" ; then
echo " Generating minified.js.."
java -jar closure-compiler.jar --warning_level QUIET plugins/md5.js plugins/cattablesort.js mist.js > minified.js
fi
#fi
echo "Done.";

View file

@ -80,12 +80,12 @@ a.substring(1)},addUnit:function(a,c){var d=$("<span>").html(a);d.append($("<spa
(UI.elements.menu.find(".button.active").removeClass("active"),b.addClass("active"));MistVideoObject&&MistVideoObject.reference&&MistVideoObject.reference.unload();UI.interval.clear();d.html($("<h2>").text(a));switch(a){case "Login":if(mist.user.loggedin){UI.navto("Overview");return}document.title="MistServer MI";UI.elements.menu.addClass("hide");UI.elements.connection.status.text("Disconnected").removeClass("green").addClass("red");d.append(UI.buildUI([{type:"help",help:"Please provide your account details.<br>You were asked to set these when MistController was started for the first time. If you did not yet set any account details, log in with your desired credentials to create a new account."},
{label:"Host",help:"Url location of the MistServer API. Generally located at http://MistServerIP:4242/api","default":"http://localhost:4242/api",pointer:{main:mist.user,index:"host"}},{label:"Username",help:"Please enter your username here.",validate:["required"],pointer:{main:mist.user,index:"name"}},{label:"Password",type:"password",help:"Please enter your password here.",validate:["required"],pointer:{main:mist.user,index:"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");d.append($("<p>").text("No account has been created yet in the MistServer at ").append($("<i>").text(mist.user.host)).append("."));d.append(UI.buildUI([{type:"buttons",buttons:[{label:"Select other host",type:"cancel",css:{"float":"left"},"function":function(){UI.navto("Login")}}]},{type:"custom",custom:$("<br>")},{label:"Desired username",
type:"str",validate:["required"],help:"Enter your desired username. In the future, you will need this to access the Management Interface.",pointer:{main:mist.user,index:"name"}},{label:"Desired password",type:"password",validate:["required",function(a,b){$(".match_password").not($(b)).trigger("change");return false}],help:"Enter your desired password. In the future, you will need this to access the Management Interface.",pointer:{main:mist.user,index:"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");d.append($("<p>").text("Your account has been created succesfully.")).append(UI.buildUI([{type:"text",text:"Would you like to enable all (currently) available protocols with their default settings?"},{type:"buttons",buttons:[{label:"Enable protocols",type:"save","function":function(){if(mist.data.config.protocols)d.append("Unable to enable all protocols as protocol settings already exist.<br>");else{d.append("Retrieving available protocols..<br>");
mist.send(function(a){var b=[],c;for(c in a.capabilities.connectors)if(a.capabilities.connectors[c].required)d.append('Could not enable protocol "'+c+'" because it has required settings.<br>');else{b.push({connector:c});d.append('Enabled protocol "'+c+'".<br>')}d.append("Saving protocol settings..<br>");mist.send(function(){d.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":if("undefined"==typeof mist.data.bandwidth){mist.send(function(){UI.navto(a)},{bandwidth:!0});d.append("Loading..");return}var i=$("<span>").text("Loading.."),m=$("<span>"),h=$("<span>").addClass("logs"),f=$("<span>"),r=$("<span>"),j=$("<span>").text("Unknown"),l=$("<span>"),u=$("<span>"),g={serverid:mist.data.config.serverid,debug:mist.data.config.debug,accesslog:mist.data.config.accesslog,prometheus:mist.data.config.prometheus},e={};"bandwidth"in mist.data&&(e=mist.data.bandwidth,
null==e&&(e={}),e.limit||(e.limit=""));var k=$("<select>").html($("<option>").val(1).text("bytes/s")).append($("<option>").val(1024).text("KiB/s")).append($("<option>").val(1048576).text("MiB/s")).append($("<option>").val(1073741824).text("GiB/s")),b=parseURL(mist.user.host),b=b.protocol+b.host+b.port;d.append(UI.buildUI([{type:"help",help:"You can find most basic information about your MistServer here.<br>You can also set the debug level and force a save to the config.json file that MistServer uses to save your settings. "},
type:"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.field").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.field").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");d.append($("<p>").text("Your account has been created succesfully.")).append(UI.buildUI([{type:"text",text:"Would you like to enable all (currently) available protocols with their default settings?"},{type:"buttons",buttons:[{label:"Enable protocols",type:"save","function":function(){if(mist.data.config.protocols)d.append("Unable to enable all protocols as protocol settings already exist.<br>");
else{d.append("Retrieving available protocols..<br>");mist.send(function(a){var b=[],c;for(c in a.capabilities.connectors)if(a.capabilities.connectors[c].required)d.append('Could not enable protocol "'+c+'" because it has required settings.<br>');else{b.push({connector:c});d.append('Enabled protocol "'+c+'".<br>')}d.append("Saving protocol settings..<br>");mist.send(function(){d.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":if("undefined"==typeof mist.data.bandwidth){mist.send(function(){UI.navto(a)},{bandwidth:!0});d.append("Loading..");return}var i=$("<span>").text("Loading.."),m=$("<span>"),h=$("<span>").addClass("logs"),f=$("<span>"),r=$("<span>"),j=$("<span>").text("Unknown"),l=$("<span>"),u=$("<span>"),g={serverid:mist.data.config.serverid,debug:mist.data.config.debug,accesslog:mist.data.config.accesslog,prometheus:mist.data.config.prometheus},
e={};"bandwidth"in mist.data&&(e=mist.data.bandwidth,null==e&&(e={}),e.limit||(e.limit=""));var k=$("<select>").html($("<option>").val(1).text("bytes/s")).append($("<option>").val(1024).text("KiB/s")).append($("<option>").val(1048576).text("MiB/s")).append($("<option>").val(1073741824).text("GiB/s")),b=parseURL(mist.user.host),b=b.protocol+b.host+b.port;d.append(UI.buildUI([{type:"help",help:"You can find most basic information about your MistServer here.<br>You can also set the debug level and force a save to the config.json file that MistServer uses to save your settings. "},
{type:"span",label:"Version",pointer:{main:mist.data.config,index:"version"}},{type:"span",label:"Version check",value:i,LTSonly:!0},{type:"span",label:"Server time",value:r},{type:"span",label:"Licensed to",value:"license"in mist.data.config?mist.data.config.license.user:"",LTSonly:!0},{type:"span",label:"Active products",value:j,LTSonly:!0},{type:"span",label:"Configured streams",value:mist.data.streams?Object.keys(mist.data.streams).length:0},{type:"span",label:"Active streams",value:m},{type:"span",
label:"Current connections",value:f},{type:"span",label:"Enabled protocols",value:l},{type:"span",label:"Disabled protocols",value:u},{type:"span",label:"Recent problems",value:h},$("<br>"),{type:"str",label:"Human readable name",pointer:{main:g,index:"serverid"},help:"You can name your MistServer here for personal use. You'll still need to set host name within your network yourself."},{type:"debug",label:"Debug level",pointer:{main:g,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:"selectinput",label:"Access log",selectinput:[["","Do not track"],["LOG","Log to MistServer log"],[{type:"str",label:"Path",LTSonly:!0},"Log to file"]],pointer:{main:g,index:"accesslog"},help:"Enable access logs.",LTSonly:!0},{type:"selectinput",label:"Prometheus stats output",selectinput:[["","Disabled"],[{type:"str",label:"Passphrase",LTSonly:!0},"Enabled"]],pointer:{main:g,index:"prometheus"},help:"Make stats available in Prometheus format. These can be accessed via "+b+"/PASSPHRASE or "+
@ -160,10 +160,10 @@ $(this).getval()==1;switch($(this).getval()){case 0:q.controls=false;break;case
$(this).getval();$(".embed_code").setval(x(q))},help:"If the video should restart when the end is reached."},{label:"Start muted",type:"checkbox",pointer:{main:q,index:"muted"},"function":function(){q.muted=$(this).getval();$(".embed_code").setval(x(q))},help:"If the video should restart when the end is reached."},{label:"Fill available space",type:"checkbox",pointer:{main:q,index:"fillSpace"},"function":function(){q.fillSpace=$(this).getval();$(".embed_code").setval(x(q))},help:"The video will fit the available space in its container, even if the video stream has a smaller resolution."},
{label:"Poster",type:"str",pointer:{main:q,index:"poster"},"function":function(){q.poster=$(this).getval();$(".embed_code").setval(x(q))},help:"URL to an image that is displayed when the video is not playing."},{label:"Video URL addition",type:"str",pointer:{main:q,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(){q.urlappend=$(this).getval();$(".embed_code").setval(x(q))}},
{label:"Preselect tracks",type:"DOMfield",DOMfield:L,help:"Pre-select these tracks."},{label:"Monitoring action",type:"select",select:[["","Ask the viewer what to do"],["nextCombo","Try the next source / player combination"]],pointer:{main:q,index:"monitor_action"},"function":function(){q.monitor_action=$(this).getval();$(".embed_code").setval(x(q))},help:"What the player should do when playback is poor."},$("<h3>").text("Protocol stream urls"),ba]));$.ajax({type:"GET",url:H+"json_"+C+".js",success:function(a){var b=
[],c=O.find(".forceType"),d=O.find(".prioritize_type"),g;for(g in a.source){var e=a.source[g],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);if(c.children('option[value="'+e.type+'"]').length==0){c.append($("<option>").text(f?f+" ("+e.type+")":UI.format.capital(e.type)).val(e.type));d.append($("<option>").text(f?f+" ("+e.type+")":UI.format.capital(e.type)).val(e.type))}}c.val(q.forceType);
d.val(q.prioritize_type);ba.html(UI.buildUI(b));L.html("");b={};for(g in a.meta.tracks){c=a.meta.tracks[g];if(c.codec=="subtitle")c.type="subtitle";if(!(c.type!="audio"&&c.type!="video"&&c.type!="subtitle")){c.type in b||(b[c.type]=c.type=="subtitle"?[]:[["","Autoselect "+c.type]]);b[c.type].push([c.trackid,UI.format.capital(c.type)+" track "+(b[c.type].length+(c.type=="subtitle"?1:0))])}}if(Object.keys(b).length){L.closest("label").show();var a=["audio","video","subtitle"],h;for(h in a){g=a[h];if(b[g].length){c=
$("<select>").attr("data-type",g).css("flex-grow","1").change(function(){$(this).val()==""?delete q.setTracks[$(this).attr("data-type")]:q.setTracks[$(this).attr("data-type")]=$(this).val();$(".embed_code").setval(x(q))});L.append(c);g=="subtitle"?b[g].unshift(["","No "+g]):b[g].push([-1,"No "+g]);for(var i in b[g])c.append($("<option>").val(b[g][i][0]).text(b[g][i][1]));if(g in q.setTracks){c.val(q.setTracks[g]);if(c.val()==null){c.val("");delete q.setTracks[g];$(".embed_code").setval(x(q))}}}}}else L.closest("label").hide();
P=true},error:function(){ba.html("Error while retrieving stream info.");L.closest("label").hide();q.setTracks={}}});o=document.createElement("script");o.src=K+"player.js";document.head.appendChild(o);o.onload=function(){var a=O.find(".forcePlayer"),b;for(b in mistplayers)a.append($("<option>").text(mistplayers[b].name).val(b));document.head.removeChild(this)};o.onerror=function(){document.head.removeChild(this)};break;case "Push":var D=$("<div>").text("Loading..");d.append(D);mist.send(function(a){function b(a){setTimeout(function(){mist.send(function(c){var d=
[],c=O.find(".field.forceType"),d=O.find(".field.prioritize_type"),g;for(g in a.source){var e=a.source[g],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);if(c.children('option[value="'+e.type+'"]').length==0){c.append($("<option>").text(f?f+" ("+e.type+")":UI.format.capital(e.type)).val(e.type));d.append($("<option>").text(f?f+" ("+e.type+")":UI.format.capital(e.type)).val(e.type))}}c.val(q.forceType);
d.val(q.prioritize_type);ba.html(UI.buildUI(b));L.html("");b={};for(g in a.meta.tracks){c=a.meta.tracks[g];if(c.codec=="subtitle")c.type="subtitle";if(!(c.type!="audio"&&c.type!="video"&&c.type!="subtitle")){c.type in b||(b[c.type]=c.type=="subtitle"?[]:[["","Autoselect "+c.type]]);b[c.type].push([c.trackid,UI.format.capital(c.type)+" track "+(b[c.type].length+(c.type=="subtitle"?1:0))])}}if(Object.keys(b).length){L.closest("label").show();var a=["audio","video","subtitle"],h;for(h in a){g=a[h];if(b[g]&&
b[g].length){c=$("<select>").attr("data-type",g).css("flex-grow","1").change(function(){$(this).val()==""?delete q.setTracks[$(this).attr("data-type")]:q.setTracks[$(this).attr("data-type")]=$(this).val();$(".embed_code").setval(x(q))});L.append(c);g=="subtitle"?b[g].unshift(["","No "+g]):b[g].push([-1,"No "+g]);for(var i in b[g])c.append($("<option>").val(b[g][i][0]).text(b[g][i][1]));if(g in q.setTracks){c.val(q.setTracks[g]);if(c.val()==null){c.val("");delete q.setTracks[g];$(".embed_code").setval(x(q))}}}}}else L.closest("label").hide();
P=true},error:function(){ba.html("Error while retrieving stream info.");L.closest("label").hide();q.setTracks={}}});o=document.createElement("script");o.src=K+"player.js";document.head.appendChild(o);o.onload=function(){var a=O.find(".field.forcePlayer"),b;for(b in mistplayers)a.append($("<option>").text(mistplayers[b].name).val(b));document.head.removeChild(this)};o.onerror=function(){document.head.removeChild(this)};break;case "Push":var D=$("<div>").text("Loading..");d.append(D);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,e;for(e in c.push_list)if(a.indexOf(c.push_list[e][0])>-1){d=false;break}}else d=true;if(d)for(e in a)g.find("tr[data-pushid="+a[e]+"]").remove();else b()},{push_list:1})},1E3)}function c(e,f){var h=$("<span>");if(f=="Automatic"&&e.length>=4){h.append($("<span>").text(e[2]));e[3]&&h.append($("<span>").text(", schedule on "+(new Date(e[3]*1E3)).toLocaleString()));e.length>=5&&e[4]&&h.append($("<span>").text(", complete on "+(new Date(e[4]*
1E3)).toLocaleString()))}else e.length>=4&&e[2]!=e[3]?h.append($("<span>").text(e[2])).append($("<span>").html("&#187").addClass("unit").css("margin","0 0.5em")).append($("<span>").text(e[3])):h.append($("<span>").text(e[2]));var i=$("<td>").append($("<button>").text(f=="Automatic"?"Remove":"Stop").click(function(){if(confirm("Are you sure you want to "+$(this).text().toLowerCase()+" this push?\n"+e[1]+" to "+e[2])){var a=$(this).closest("tr");a.html($("<td colspan=99>").html($("<span>").addClass("red").text(f==
"Automatic"?"Removing..":"Stopping..")));if(f=="Automatic"){var c=e.slice(1);mist.send(function(){a.remove()},{push_auto_remove:[c]})}else mist.send(function(){b([e[0]])},{push_stop:[e[0]]})}}));if(f=="Automatic"){i.prepend($("<button>").text("Edit").click(function(){UI.navto("Start Push","auto_"+($(this).closest("tr").index()-1))}));i.append($("<button>").text("Stop pushes").click(function(){if(confirm('Are you sure you want to stop all pushes matching \n"'+e[1]+" to "+e[2]+'"?'+(d.wait!=0?"\n\nRetrying is enabled. You'll probably want to set that to 0.":

View file

@ -2234,7 +2234,7 @@ var UI = {
label: 'Desired password',
type: 'password',
validate: ['required',function(val,me){
$('.match_password').not($(me)).trigger('change');
$('.match_password.field').not($(me)).trigger('change');
return false;
}],
help: 'Enter your desired password. In the future, you will need this to access the Management Interface.',
@ -2247,7 +2247,7 @@ var UI = {
label: 'Repeat password',
type: 'password',
validate: ['required',function(val,me){
if (val != $('.match_password').not($(me)).val()) {
if (val != $('.match_password.field').not($(me)).val()) {
return {
msg:'The fields "Desired password" and "Repeat password" do not match.',
classes: ['red']
@ -4702,8 +4702,8 @@ var UI = {
success: function(d) {
var build = [];
var $s_forceType = $embedlinks.find('.forceType');
var $s_prioritizeType = $embedlinks.find('.prioritize_type');
var $s_forceType = $embedlinks.find('.field.forceType');
var $s_prioritizeType = $embedlinks.find('.field.prioritize_type');
for (var i in d.source) {
var source = d.source[i];
var human = UI.humanMime(source.type);
@ -4754,7 +4754,7 @@ var UI = {
var trackarray = ["audio","video","subtitle"];
for (var n in trackarray) {
var i = trackarray[n];
if (!tracks[i].length) { continue; }
if (!tracks[i] || !tracks[i].length) { continue; }
var $select = $('<select>').attr('data-type',i).css('flex-grow','1').change(function(){
if ($(this).val() == '') {
delete embedoptions.setTracks[$(this).attr('data-type')];
@ -4803,7 +4803,7 @@ var UI = {
script.src = embedbase+'player.js';
document.head.appendChild(script);
script.onload = function(){
var $s_forcePlayer = $embedlinks.find('.forcePlayer');
var $s_forcePlayer = $embedlinks.find('.field.forcePlayer');
for (var i in mistplayers) {
$s_forcePlayer.append(
$('<option>').text(mistplayers[i].name).val(i)