LSP: threw out some useless code that actually only breaks stuff

This commit is contained in:
Cat 2023-03-09 16:34:20 +01:00
parent 98316bb11a
commit 472ab810a5
2 changed files with 8 additions and 18 deletions

View file

@ -119,14 +119,13 @@ $("<div>").addClass("button_container").css("text-align","right").html($("<butto
b.append($("<tr>").addClass("uploader").attr("data-name",c).html($("<td>").text(d[0])).append($("<td>").html($("<code>").html(d[1]))).append($("<td>").text(d[2]?d[2].join(", "):"none").addClass("desc")).append($("<td>").html($("<button>").text("Edit").click(function(){var a=$(this).closest("tr").attr("data-name");UI.navto("Edit external writer",a)})).append($("<button>").text("Remove").click(function(){var a=$(this).closest("tr").attr("data-name");confirm("Are you sure you want to remove the Uploader '"+
a+"'?")&&mist.send(function(){UI.showTab("General")},{external_writer_remove:a})}))))}}else na.html("None configured.")},{external_writer_list:!0});break;case "Edit external writer":var z=!1;""!=b&&(z=!0);var Ia=function(){z?c.html($("<h2>").text("Edit external writer '"+b+"'")):c.html($("<h2>").text("New external writer"));var a={};if(mist.data.external_writer_list&&b in mist.data.external_writer_list){var d=mist.data.external_writer_list[b];a.name=d[0];a.cmdline=d[1];a.protocols=d[2]}c.append(UI.buildUI([{type:"str",
label:"Human readable name",help:"A human readable name for the external writer.",validate:["required"],pointer:{main:a,index:"name"}},{type:"str",label:"Command line",help:"Command line for a local command (with optional arguments) which will write media data to the target.",validate:["required"],pointer:{main:a,index:"cmdline"}},{type:"inputlist",label:"URI protocols handled",help:"URI protocols which the external writer will be handling.",validate:["required",function(a){for(var b in a){var c=
a[b];if(c.match(/^([a-z\d\+\-\.])+?$/)===null)return{classes:["red"],msg:"There was a problem with the protocol URI '"+$("<div>").text(c).html()+"':<br>A protocol URI may only contain lower case letters, digits, and the following special characters . + and -"}}}],input:{type:"str",unit:"://",validate:[function(a){if(a.indexOf("://")!=-1)return{classes:["red"],msg:"Don't include '://' here.","break":true}}]},pointer:{main:a,index:"protocols"}},{type:"buttons",buttons:[{type:"cancel",label:"Cancel",
"function":function(){UI.navto("General")}},{type:"save",label:"Save","function":function(){var c={external_writer_add:a};if(a.name!=b)c.external_writer_remove=b;mist.send(function(){UI.navto("General")},c)}}]}]))};"external_writer_list"in mist.data?Ia():mist.send(function(){Ia()},{external_writer_list:!0});break;case "Edit variable":z=!1;""!=b&&(z=!0);var Fa=function(a,d){z?c.html($("<h2>").text('Edit Variable "$'+b+'"')):c.html($("<h2>").text("New Variable"));var f=$("<div>");c.append(UI.buildUI([{type:"str",
maxlength:31,label:"Variable name",prefix:"$",help:"What should the variable be called? A dollar sign will automatically be prepended.",pointer:{main:a,index:"name"},validate:["required",function(a){if(a.length&&a[0]=="$")return{msg:"The dollar sign will automatically be prepended. You don't need to type it here.",classes:["red"]};if(a.indexOf("{")!==-1||a.indexOf("}")!==-1||a.indexOf("$")!==-1)return{msg:'The following symbols are not permitted: "$ { }".',classes:["red"]}}]},{type:"select",label:"Type",
help:"What kind of variable is this? It can either be a static value that you can enter below, or a dynamic one that is returned by a command.",select:[["value","Static value"],["command","Dynamic through command"]],value:"value",pointer:{main:d,index:"type"},"function":function(){var a=[$("Invalid variable type")];switch($(this).val()){case "value":a=[{type:"str",label:"Value",pointer:{main:d,index:"value"},help:"The static value that this variable should be replaced with. There is a character limit of 63 characters.",
validate:["required"]}];break;case "command":a=[{type:"str",label:"Command",help:"The command that should be executed to retrieve the value for this variable.<br>For example:<br><code>/usr/bin/date +%A</code><br>There is a character limit of 511 characters.",validate:["required"],pointer:{main:d,index:"target"}},{type:"int",min:0,max:4294967295,"default":0,label:"Checking interval",unit:"s",help:"At what interval, in seconds, MistServer should execute the command and update the value.<br>To execute the command once when MistServer starts up (and then never update), set the interval to 0.",
pointer:{main:d,index:"interval"}},{type:"int",min:0,max:4294967295,"default":1,label:"Wait time",unit:"s",help:"Specifies the maximum time, in seconds, MistServer should wait for data when executing the variable target. If set to 0 this variable takes on the same value as the interval.<br>MistServer only updates one variable at a time, so setting this value too high can block other variables from updating.",pointer:{main:d,index:"waitTime"}}]}f.html(UI.buildUI(a))}},f,{type:"buttons",buttons:[{type:"cancel",
label:"Cancel","function":function(){UI.navto("General")}},{type:"save",label:"Save","function":function(){var c={variable_add:a};switch(d.type){case "value":a.value=d.value;break;case "command":a.target=d.target;a.interval=d.interval;a.waitTime=d.waitTime}if(a.name!=b)c.variable_remove=b;mist.send(function(){UI.navto("General")},c)}}]}]))};c.html("Loading..");z?mist.send(function(a){if(b in a.variable_list){a=a.variable_list[b];Fa({name:b},typeof a=="string"?{value:a,type:"value"}:{target:a[0],interval:a[1],
waitTime:a[4],type:"command"})}else c.append('Variable "$'+b+'" does not exist.')},{variable_list:!0}):Fa({},{});break;case "Protocols":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});c.append("Loading..");return}var F=$("<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=
a[b];if(c.match(/^([a-z\d\+\-\.])+?$/)===null)return{classes:["red"],msg:"There was a problem with the protocol URI '"+$("<div>").text(c).html()+"':<br>A protocol URI may only contain lower case letters, digits, and the following special characters . + and -"}}}],input:{type:"str",unit:"://"},pointer:{main:a,index:"protocols"}},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("General")}},{type:"save",label:"Save","function":function(){var c={external_writer_add:a};
if(a.name!=b)c.external_writer_remove=b;mist.send(function(){UI.navto("General")},c)}}]}]))};"external_writer_list"in mist.data?Ia():mist.send(function(){Ia()},{external_writer_list:!0});break;case "Edit variable":z=!1;""!=b&&(z=!0);var Fa=function(a,d){z?c.html($("<h2>").text('Edit Variable "$'+b+'"')):c.html($("<h2>").text("New Variable"));var f=$("<div>");c.append(UI.buildUI([{type:"str",maxlength:31,label:"Variable name",prefix:"$",help:"What should the variable be called? A dollar sign will automatically be prepended.",
pointer:{main:a,index:"name"},validate:["required",function(a){if(a.length&&a[0]=="$")return{msg:"The dollar sign will automatically be prepended. You don't need to type it here.",classes:["red"]};if(a.indexOf("{")!==-1||a.indexOf("}")!==-1||a.indexOf("$")!==-1)return{msg:'The following symbols are not permitted: "$ { }".',classes:["red"]}}]},{type:"select",label:"Type",help:"What kind of variable is this? It can either be a static value that you can enter below, or a dynamic one that is returned by a command.",
select:[["value","Static value"],["command","Dynamic through command"]],value:"value",pointer:{main:d,index:"type"},"function":function(){var a=[$("Invalid variable type")];switch($(this).val()){case "value":a=[{type:"str",label:"Value",pointer:{main:d,index:"value"},help:"The static value that this variable should be replaced with. There is a character limit of 63 characters.",validate:["required"]}];break;case "command":a=[{type:"str",label:"Command",help:"The command that should be executed to retrieve the value for this variable.<br>For example:<br><code>/usr/bin/date +%A</code><br>There is a character limit of 511 characters.",
validate:["required"],pointer:{main:d,index:"target"}},{type:"int",min:0,max:4294967295,"default":0,label:"Checking interval",unit:"s",help:"At what interval, in seconds, MistServer should execute the command and update the value.<br>To execute the command once when MistServer starts up (and then never update), set the interval to 0.",pointer:{main:d,index:"interval"}},{type:"int",min:0,max:4294967295,"default":1,label:"Wait time",unit:"s",help:"Specifies the maximum time, in seconds, MistServer should wait for data when executing the variable target. If set to 0 this variable takes on the same value as the interval.<br>MistServer only updates one variable at a time, so setting this value too high can block other variables from updating.",
pointer:{main:d,index:"waitTime"}}]}f.html(UI.buildUI(a))}},f,{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("General")}},{type:"save",label:"Save","function":function(){var c={variable_add:a};switch(d.type){case "value":a.value=d.value;break;case "command":a.target=d.target;a.interval=d.interval;a.waitTime=d.waitTime}if(a.name!=b)c.variable_remove=b;mist.send(function(){UI.navto("General")},c)}}]}]))};c.html("Loading..");z?mist.send(function(a){if(b in a.variable_list){a=
a.variable_list[b];Fa({name:b},typeof a=="string"?{value:a,type:"value"}:{target:a[0],interval:a[1],waitTime:a[4],type:"command"})}else c.append('Variable "$'+b+'" does not exist.')},{variable_list:!0}):Fa({},{});break;case "Protocols":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});c.append("Loading..");return}var F=$("<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){if(mist.data.config.protocols===null)mist.data.config.protocols=[];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(F));var Ha=function(){function a(b){var c=mist.data.capabilities.connectors[b.connector];if(!c)return"";var d=[],f=["required","optional"],w;for(w in f)for(var g in c[f[w]])b[g]&&b[g]!=""?d.push(g+": "+b[g]):c[f[w]][g]["default"]&&d.push(g+": "+c[f[w]][g]["default"]);return $("<span>").addClass("description").text(d.join(", "))}

View file

@ -3291,16 +3291,7 @@ var UI = {
}],
input: {
type: "str",
unit: "://",
validate: [function(v){//cijfers lowercase letters az + - .
if (v.indexOf("://") != -1) {
return {
classes: ["red"],
msg: "Don't include '://' here.",
"break": true
};
}
}]
unit: "://"
},
pointer: {
main: saveas,