From 816896b7b9f6cd7e905e82680125df3b6cfecdb8 Mon Sep 17 00:00:00 2001 From: Cat Date: Mon, 23 Oct 2017 10:11:03 +0200 Subject: [PATCH] LSP: added connector option type flag --- lsp/minified.js | 2 +- lsp/mist.js | 41 +++++++++++++++++++++++------------------ 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/lsp/minified.js b/lsp/minified.js index 492a1e05..0307dd07 100644 --- a/lsp/minified.js +++ b/lsp/minified.js @@ -207,7 +207,7 @@ UI.elements.connection.user_and_host.text(mist.user.name+" @ "+mist.user.host);U b.totals[q])}a&&a(b,d);break;case "CHALL":if(b.authorize.challenge==mist.user.authstring){mist.user.password!=""&&UI.elements.connection.msg.text("The credentials you provided are incorrect.").addClass("red");UI.navto("Login")}else if(mist.user.password=="")UI.navto("Login");else{mist.user.authstring=b.authorize.challenge;mist.send(a,c,d);sessionStorage.setItem("mistLogin",JSON.stringify({host:mist.user.host,name:mist.user.name,password:mist.user.password}))}break;case "NOACC":UI.navto("Create a new account"); break;case "ACC_MADE":delete c.authorize;mist.send(a,c,d);break;default:UI.navto("Login")}}};d.hide||UI.elements.connection.msg.removeClass("red").text("Data sent, waiting for a reply..").append($("
")).append($("").text("Cancel request").click(function(){e.abort()}));var e=$.ajax(b)},inputMatch:function(a,c){if(typeof a=="undefined")return false;typeof a=="string"&&(a=[a]);for(var d in a){var b=a[d].replace(/[^\w\s]/g,"\\$&"),b=b.replace(/\\\*/g,".*");if(RegExp("^(?:[a-zA-Z]:)?"+b+"(?:\\?[^\\?]*)?$", "i").test(c))return true}return false},convertBuildOptions:function(a,c){var d=[],b=["required","optional"];"desc"in a&&d.push({type:"help",help:a.desc});for(var e in b)if(a[b[e]]){d.push($("

").text(UI.format.capital(b[e])+" parameters"));for(var f in a[b[e]]){var m=a[b[e]][f],h={label:UI.format.capital(m.name),pointer:{main:c,index:f},validate:[]};b[e]=="required"&&(!("default"in m)||m["default"]=="")&&h.validate.push("required");if("default"in m)h.placeholder=m["default"];if("help"in m)h.help= -m.help;if("unit"in m)h.unit=m.unit;switch(m.type){case "int":h.type="int";break;case "uint":h.type="int";h.min=0;break;case "debug":h.type="debug";break;case "select":h.type="select";h.select=m.select;break;default:h.type="str"}d.push(h)}}return d},stored:{get:function(){return mist.data.ui_settings||{}},set:function(a,c){var d=this.get();d[a]=c;mist.send(function(){},{ui_settings:d})},del:function(a){delete mist.data.ui_settings[a];mist.send(function(){},{ui_settings:mist.data.ui_settings})}}}; +m.help;if("unit"in m)h.unit=m.unit;if("type"in m)switch(m.type){case "int":h.type="int";break;case "uint":h.type="int";h.min=0;break;case "debug":h.type="debug";break;case "select":h.type="select";h.select=m.select;break;default:h.type="str"}else h.type="checkbox";d.push(h)}}return d},stored:{get:function(){return mist.data.ui_settings||{}},set:function(a,c){var d=this.get();d[a]=c;mist.send(function(){},{ui_settings:d})},del:function(a){delete mist.data.ui_settings[a];mist.send(function(){},{ui_settings:mist.data.ui_settings})}}}; function log(){try{UI.debug&&[].push.call(arguments,Error().stack);[].unshift.call(arguments,"["+UI.format.time((new Date).getTime()/1E3)+"]");console.log.apply(console,arguments)}catch(a){}} $.fn.getval=function(){var a=$(this).data("opts"),c=$(this).val();if(a&&"type"in a)switch(a.type){case "span":c=$(this).html();break;case "checkbox":c=$(this).prop("checked");break;case "radioselect":a=$(this).find("label > input[type=radio]:checked").parent();if(a.length){c=[];c.push(a.children("input[type=radio]").val());a=a.children("select");a.length&&c.push(a.val())}else c="";break;case "checklist":c=[];$(this).find(".checklist input[type=checkbox]:checked").each(function(){c.push($(this).attr("name"))}); break;case "unix":c!=""&&(c=Math.round(new Date($(this).val())/1E3))}return c}; diff --git a/lsp/mist.js b/lsp/mist.js index 1bc7f35e..8beca2d3 100644 --- a/lsp/mist.js +++ b/lsp/mist.js @@ -5938,24 +5938,29 @@ var mist = { if ('unit' in ele) { obj.unit = ele.unit; } - switch (ele.type) { - case 'int': - obj.type = 'int'; - break; - case 'uint': - obj.type = 'int'; - obj.min = 0; - break; - case 'debug': - obj.type = 'debug'; - break; - case 'select': - obj.type = 'select'; - obj.select = ele.select; - break; - case 'str': - default: - obj.type = 'str'; + if ("type" in ele) { + switch (ele.type) { + case 'int': + obj.type = 'int'; + break; + case 'uint': + obj.type = 'int'; + obj.min = 0; + break; + case 'debug': + obj.type = 'debug'; + break; + case 'select': + obj.type = 'select'; + obj.select = ele.select; + break; + case 'str': + default: + obj.type = 'str'; + } + } + else { + obj.type = "checkbox"; } build.push(obj); }