marlin-conf
Advanced tools
Comparing version 2.5.0 to 2.5.1
@@ -104,3 +104,3 @@ var fs = require('fs'); | ||
swig.setFilter('append', function (input,val) { return input+val; }) | ||
swig.setFilter('append', function (input,val) { return !val&&input||Array.isArray(input)&&input.concat(val)||(input+val); }) | ||
swig.setFilter('split', function (input,val) { return input.split(val); }) | ||
@@ -107,0 +107,0 @@ swig.setFilter('push', function (input,val) { input.push(val); return input; }) |
@@ -114,3 +114,3 @@ var express = require('express'); | ||
res.set('Content-Type', 'text/plain'); | ||
if (!/\/jes/.test(process.cwd())) | ||
if (1||!/\/jes/.test(process.cwd())) | ||
res.write(` | ||
@@ -117,0 +117,0 @@ ga('create', 'UA-99239389-1', 'auto'); |
{ | ||
"name": "marlin-conf", | ||
"version": "2.5.0", | ||
"version": "2.5.1", | ||
"description": "configuration tool for Marlin project", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -11,2 +11,4 @@ # marlin-config | ||
* show help for options | ||
* show help for G-codes | ||
* show allowed options/gcodes depends your configuration | ||
* reset configuration changes | ||
@@ -13,0 +15,0 @@ * switch between releases (available after reset) |
@@ -155,3 +155,6 @@ function _add(tmpl){ | ||
function toggleDef(name,state){ | ||
var inp=$('[data-def='+name+']') | ||
// var inp=$('.form-group[data-def='+name+']') | ||
//return; | ||
if (!uiDefs[name]) return; | ||
var inp=uiDefs[name] | ||
.toggleClass('disabled',!state) | ||
@@ -165,3 +168,4 @@ .find('input') | ||
function toggleRed(tag,name){ | ||
var inp=$('[data-def='+tag+'] .col-sm-5 a').each(function(i,a){ | ||
if (!uiDefs[tag]) return; | ||
var inp=uiDefs[tag].find('.col-sm-5 a').each(function(i,a){ | ||
if ($(a).text()==name) | ||
@@ -183,14 +187,18 @@ $(a).replaceWith( | ||
depsG[name].forEach(function(gcode){ | ||
var en=false; | ||
optsG[gcode].requires&&optsG[gcode].requires.forEach(function(def){ | ||
checkConditionG(gcode); | ||
}) | ||
} | ||
function checkConditionG(gcode){ | ||
var en=false; | ||
if(optsG[gcode]) | ||
if(optsG[gcode].requires){ | ||
optsG[gcode].requires.forEach(function(def){ | ||
if (opts[def]) | ||
en=en||!getVal(opts[def],'disabled'); | ||
else | ||
en=true; | ||
}); | ||
toggleDef(gcode,en); | ||
}) | ||
} | ||
} | ||
function checkConditionG(name,gcode){ | ||
// opts.name | ||
toggleDef(gcode,false); | ||
} | ||
function checkCondition(name){ | ||
@@ -203,4 +211,8 @@ function ENABLED(v){ return !getVal(opts[v],'disabled')} | ||
opts[name].condition.forEach(function(c){ | ||
var cond=eval(c.replace(/\)/g,'")').replace(/\(/g,'("')); | ||
res=res&&cond; | ||
try{ | ||
var cond=eval(c.replace(/\)/g,'")').replace(/\(/g,'("')); | ||
res=res&&cond; | ||
}catch(e){ | ||
//console.error(e) | ||
} | ||
}) | ||
@@ -212,2 +224,3 @@ toggleDef(name,res); | ||
var depsG={},optsG={}; | ||
var uiDefs={}; | ||
$(function(){ | ||
@@ -293,3 +306,4 @@ //uploader decoration | ||
var d=_add(sec.find('template._define')) | ||
d.attr('data-def',define); | ||
uiDefs[define]=d; | ||
// d.attr('data-def',define); | ||
var def=file.defs[define] | ||
@@ -301,6 +315,18 @@ opts[define]=file.defs[define]; | ||
var dis=d.find('.onoffswitch') | ||
var dv=(def.changed&&def.changed.value||def.value); | ||
if (def.type=='string') | ||
var p=d.find('.mct-splitter'); | ||
var val=d.find('input[type=text]'); | ||
if (def.value == undefined) | ||
val.remove(),p.remove(); | ||
else{ | ||
var dv=(def.changed&&def.changed.value||def.value); | ||
if (def.type=='string') | ||
dv=dv.slice(1,-1) | ||
var val=d.find('input[type=text]').val(dv); | ||
val.val(dv) | ||
.on('change',function(){ | ||
var dv=$(this).val(); | ||
if (def.type=='string') | ||
dv='"'+dv+'"'; | ||
processProp('value',dv); | ||
}) | ||
} | ||
function processProp(name,val){ | ||
@@ -312,13 +338,11 @@ saveProp('/set/'+file.file.name+'/'+define+'/'+name+'/'+val) | ||
} | ||
dis.find('input') | ||
.attr('checked',!getVal(def,'disabled')) | ||
.on('change',function(){ | ||
processProp('disabled',!$(this).prop('checked')); | ||
}) | ||
val.on('change',function(){ | ||
var dv=$(this).val(); | ||
if (def.type=='string') | ||
dv='"'+dv+'"'; | ||
processProp('value',dv); | ||
}) | ||
if (! def.disabled && def.value != undefined) | ||
dis.remove(),p.remove(); | ||
else{ | ||
dis.find('input') | ||
.attr('checked',!getVal(def,'disabled')) | ||
.on('change',function(){ | ||
processProp('disabled',!$(this).prop('checked')); | ||
}) | ||
} | ||
if (def.condition){ | ||
@@ -328,14 +352,10 @@ var title='( '+def.condition.join(') && (')+' )'; | ||
} | ||
var p=d.find('.mct-splitter'); | ||
var b=d.find('button'); | ||
if (/_adv$/.test(file.file.name)) | ||
if ( /_adv$/.test( file.file.name ) ) | ||
b.remove(); | ||
else | ||
b.on('click',function(){loadHint(define)}) | ||
if (def.value == undefined) | ||
val.remove(),p.remove(); | ||
if (! def.disabled && def.value != undefined) | ||
dis.remove(),p.remove(); | ||
if (def.hint == undefined) | ||
d.find('button').remove(); | ||
if ( def.hint == undefined ) | ||
b.remove(); | ||
else | ||
b.on('click',function(){ loadHint(define) }) | ||
}) | ||
@@ -351,3 +371,3 @@ sec.find('.card-header span.badge:eq(0)').text(cnt); | ||
}) | ||
$('.config-files a').eq(1).tab('show'); | ||
$('.config-files .nav-tabs a').eq(1).tab('show'); | ||
$('body').scrollspy({ target: '#navbar-sections' }) | ||
@@ -360,3 +380,3 @@ /* $(window).on('hashchange', function() { | ||
if (!$(href).is(':visible')){ | ||
$('.config-files a[href*=card]').eq(/adv/.test(href)?1:0).tab('show'); | ||
$('.config-files .nav-tabs a[href*=card]').eq(/adv/.test(href)?1:0).tab('show'); | ||
location.hash=''; | ||
@@ -370,3 +390,3 @@ ev.preventDefault(); | ||
if (!$(href).is(':visible')){ | ||
$('.config-files a[href$='+href.slice(1)+']').tab('show'); | ||
$('.config-files .nav-tabs a[href$='+href.slice(1)+']').tab('show'); | ||
} | ||
@@ -383,4 +403,4 @@ }) | ||
} | ||
var def=$('[data-def='+name+']'); | ||
if (def.length){ | ||
var def=uiDefs[name];//$('[data-def='+name+']'); | ||
if (def){ | ||
var pane=def.parents('.tab-pane') | ||
@@ -411,3 +431,4 @@ if(pane.is(':visible')) | ||
var d=_add(sec.find('template._gcode')) | ||
d.attr('data-def',tag); | ||
uiDefs[tag]=d; | ||
// d.attr('data-def',tag); | ||
var gcode=optsG[tag]=data.tags[tag]; // | ||
@@ -420,3 +441,3 @@ d.find('label').text(gcode.title); | ||
gcode.requires&&gcode.requires.forEach(function(req,i){ | ||
if(1) reqs.append('<br/>') | ||
if(i) reqs.append('<br/>') | ||
reqs.append($('<a>').attr('href','#') | ||
@@ -620,11 +641,15 @@ .text(req) | ||
(function(){ | ||
gcodes.then(function(g){ | ||
gcodes.then(function(gcodes){ | ||
defs.then(function(data){ | ||
var failG=$.extend(true,{},depsG) | ||
data.forEach(function(file){ | ||
$.each(file.defs,function(name){ | ||
updateConditions(name); | ||
$.each(file.defs,function(name,ob){ | ||
checkCondition(name); | ||
//updateConditions(name); | ||
delete failG[name] | ||
}) | ||
}) | ||
$.each(gcodes.tags,function(name,ob){ | ||
checkConditionG(name); | ||
}) | ||
$.each(failG,function(name,data){ | ||
@@ -631,0 +656,0 @@ data.forEach(function(gcode){ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
392933
2381
86
6