|
@ -125,7 +125,7 @@ var configuratorApp = (function(){ |
|
|
complete: function() { |
|
|
complete: function() { |
|
|
ajax_count++; |
|
|
ajax_count++; |
|
|
if (ajax_count >= 3) { |
|
|
if (ajax_count >= 3) { |
|
|
$.each(config_files, function(i,fname){ if (typeof loaded_items[fname] != 'undefined') loaded_items[fname](); }); |
|
|
$.each(config_files, function(i,fname){ if (loaded_items[fname] !== undefined) loaded_items[fname](); }); |
|
|
self.refreshConfigForm(); |
|
|
self.refreshConfigForm(); |
|
|
if (success_count < ajax_count) |
|
|
if (success_count < ajax_count) |
|
|
self.setMessage('Unable to load configurations. Use the upload field instead.', 'error'); |
|
|
self.setMessage('Unable to load configurations. Use the upload field instead.', 'error'); |
|
@ -137,7 +137,7 @@ var configuratorApp = (function(){ |
|
|
|
|
|
|
|
|
setMessage: function(msg,type) { |
|
|
setMessage: function(msg,type) { |
|
|
if (msg) { |
|
|
if (msg) { |
|
|
if (typeof type == 'undefined') type = 'message'; |
|
|
if (type === undefined) type = 'message'; |
|
|
var $err = $('<p class="'+type+'">'+msg+'</p>'), err = $err[0]; |
|
|
var $err = $('<p class="'+type+'">'+msg+'</p>'), err = $err[0]; |
|
|
$('#message').prepend($err); |
|
|
$('#message').prepend($err); |
|
|
var baseColor = $err.css('color').replace(/rgba?\(([^),]+,[^),]+,[^),]+).*/, 'rgba($1,'); |
|
|
var baseColor = $err.css('color').replace(/rgba?\(([^),]+,[^),]+,[^),]+).*/, 'rgba($1,'); |
|
@ -155,7 +155,7 @@ var configuratorApp = (function(){ |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
$('#message p.error, #message p.warning').each(function() { |
|
|
$('#message p.error, #message p.warning').each(function() { |
|
|
if (typeof this.pulser != 'undefined' && this.pulser) |
|
|
if (this.pulser !== undefined && this.pulser) |
|
|
clearInterval(this.pulser); |
|
|
clearInterval(this.pulser); |
|
|
$(this).remove(); |
|
|
$(this).remove(); |
|
|
}); |
|
|
}); |
|
@ -440,30 +440,16 @@ var configuratorApp = (function(){ |
|
|
switch(inf.type) { |
|
|
switch(inf.type) { |
|
|
case 'switch': |
|
|
case 'switch': |
|
|
var slash = val ? '' : '//'; |
|
|
var slash = val ? '' : '//'; |
|
|
newline = (inf.pre + slash + inf.define + inf.post); |
|
|
newline = inf.line.replace(inf.repl, '$1'+slash+'$3'); |
|
|
break; |
|
|
break; |
|
|
case 'quoted': |
|
|
case 'quoted': |
|
|
if (isCheck) { |
|
|
|
|
|
this.log(name + ' should not be a checkbox', 1); |
|
|
|
|
|
var slash = val ? '' : '//'; |
|
|
|
|
|
newline = (inf.pre + slash + inf.define + '"'+val+'"' + inf.post); |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
newline = inf.pre + inf.define + '"'+val+'"' + inf.post; |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
case 'plain': |
|
|
case 'plain': |
|
|
if (isCheck) { |
|
|
if (isCheck) |
|
|
this.log(name + ' should not be a checkbox', 1); |
|
|
this.setMessage(name + ' should not be a checkbox!', 'error'); |
|
|
var slash = val ? '' : '//'; |
|
|
else |
|
|
newline = (inf.pre + slash + inf.define + val + inf.post); |
|
|
newline = inf.line.replace(inf.repl, '$1'+val.replace('$','\\$')+'$3'); |
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
newline = inf.pre + inf.define + val + inf.post; |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.setDefineLine(name, newline); |
|
|
this.setDefineLine(name, newline); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
@ -536,7 +522,7 @@ var configuratorApp = (function(){ |
|
|
* Purge #define information for one of the config files |
|
|
* Purge #define information for one of the config files |
|
|
*/ |
|
|
*/ |
|
|
purgeDefineInfo: function(adv) { |
|
|
purgeDefineInfo: function(adv) { |
|
|
if (typeof adv == 'undefined') adv = false; |
|
|
if (adv === undefined) adv = false; |
|
|
$('[defineInfo]').each(function() { |
|
|
$('[defineInfo]').each(function() { |
|
|
if (adv === this.defineInfo.adv) $(this).removeProp('defineInfo'); |
|
|
if (adv === this.defineInfo.adv) $(this).removeProp('defineInfo'); |
|
|
}); |
|
|
}); |
|
@ -546,7 +532,7 @@ var configuratorApp = (function(){ |
|
|
* Update #define information for one of the config files |
|
|
* Update #define information for one of the config files |
|
|
*/ |
|
|
*/ |
|
|
refreshDefineInfo: function(adv) { |
|
|
refreshDefineInfo: function(adv) { |
|
|
if (typeof adv == 'undefined') adv = false; |
|
|
if (adv === undefined) adv = false; |
|
|
$('[defineInfo]').each(function() { |
|
|
$('[defineInfo]').each(function() { |
|
|
if (adv == this.defineInfo.adv) this.defineInfo = self.getDefineInfo(this.id, adv); |
|
|
if (adv == this.defineInfo.adv) this.defineInfo = self.getDefineInfo(this.id, adv); |
|
|
}); |
|
|
}); |
|
@ -561,7 +547,7 @@ var configuratorApp = (function(){ |
|
|
* Determine the line number of the #define so it can be scrolled to. |
|
|
* Determine the line number of the #define so it can be scrolled to. |
|
|
*/ |
|
|
*/ |
|
|
getDefineInfo: function(name, adv) { |
|
|
getDefineInfo: function(name, adv) { |
|
|
if (typeof adv == 'undefined') adv = false; |
|
|
if (adv === undefined) adv = false; |
|
|
this.log('getDefineInfo:'+name,4); |
|
|
this.log('getDefineInfo:'+name,4); |
|
|
var $elm = $('#'+name), elm = $elm[0]; |
|
|
var $elm = $('#'+name), elm = $elm[0]; |
|
|
var $c = adv ? $config_adv : $config; |
|
|
var $c = adv ? $config_adv : $config; |
|
@ -569,63 +555,66 @@ var configuratorApp = (function(){ |
|
|
// a switch line with no value
|
|
|
// a switch line with no value
|
|
|
var findDef = new RegExp('^(.*//)?(.*#define[ \\t]+' + elm.id + ')([ \\t]*/[*/].*)?$', 'm'); |
|
|
var findDef = new RegExp('^(.*//)?(.*#define[ \\t]+' + elm.id + ')([ \\t]*/[*/].*)?$', 'm'); |
|
|
var result = findDef.exec($c.text()); |
|
|
var result = findDef.exec($c.text()); |
|
|
|
|
|
var info = { type:0, adv:adv, field:$c[0], val_i: 2 }; |
|
|
if (result !== null) { |
|
|
if (result !== null) { |
|
|
var info = { |
|
|
$.extend(info, { |
|
|
type:'switch', adv:adv, field:$c[0], val_i: 1, |
|
|
val_i: 1, |
|
|
line: result[0], // whole line
|
|
|
type: 'switch', |
|
|
pre: result[1] === undefined ? '' : result[1].replace('//',''), |
|
|
line: result[0], // whole line
|
|
|
|
|
|
pre: result[1] === undefined ? '' : result[1].replace('//',''), |
|
|
define: result[2], |
|
|
define: result[2], |
|
|
post: result[3] === undefined ? '' : result[3] |
|
|
post: result[3] === undefined ? '' : result[3] |
|
|
}; |
|
|
}); |
|
|
info.repl = info.regex = new RegExp('(.*//)?(.*' + info.define.regEsc() + info.post.regEsc() + ')', 'm'); |
|
|
info.regex = new RegExp('( *//)?( *' + info.define.regEsc() + info.post.regEsc() + ')', 'm'); |
|
|
info.lineNum = this.getLineInText(info.line, $c.text()); |
|
|
info.repl = new RegExp('( *)(\/\/)?( *' + info.define.regEsc() + info.post.regEsc() + ')', 'm'); |
|
|
this.log(info,2); |
|
|
|
|
|
return info; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
else { |
|
|
// a define with quotes
|
|
|
// a define with quotes
|
|
|
findDef = new RegExp('^(.*//)?(.*#define[ \\t]+' + elm.id + '[ \\t]+)("[^"]*")([ \\t]*/[*/].*)?$', 'm'); |
|
|
findDef = new RegExp('^(.*//)?(.*#define[ \\t]+' + elm.id + '[ \\t]+)("[^"]*")([ \\t]*/[*/].*)?$', 'm'); |
|
|
result = findDef.exec($c.text()); |
|
|
result = findDef.exec($c.text()); |
|
|
if (result !== null) { |
|
|
if (result !== null) { |
|
|
var info = { |
|
|
$.extend(info, { |
|
|
type:'quoted', adv:adv, field:$c[0], val_i: 2, |
|
|
type: 'quoted', |
|
|
line: result[0], |
|
|
line: result[0], |
|
|
pre: result[1] === undefined ? '' : result[1].replace('//',''), |
|
|
pre: result[1] === undefined ? '' : result[1].replace('//',''), |
|
|
define: result[2], |
|
|
define: result[2], |
|
|
post: result[4] === undefined ? '' : result[4] |
|
|
post: result[4] === undefined ? '' : result[4] |
|
|
}; |
|
|
}); |
|
|
info.regex = new RegExp('(.*//)?.*' + info.define.regEsc() + '"([^"]*)"' + info.post.regEsc(), 'm'); |
|
|
info.regex = new RegExp('( *//)? *' + info.define.regEsc() + '"([^"]*)"' + info.post.regEsc(), 'm'); |
|
|
info.repl = new RegExp('((.*//)?.*' + info.define.regEsc() + '")[^"]*("' + info.post.regEsc() + ')', 'm'); |
|
|
info.repl = new RegExp('(( *//)? *' + info.define.regEsc() + '")[^"]*("' + info.post.regEsc() + ')', 'm'); |
|
|
info.lineNum = this.getLineInText(info.line, $c.text()); |
|
|
} |
|
|
this.log(info,2); |
|
|
else { |
|
|
return info; |
|
|
// a define with no quotes
|
|
|
|
|
|
findDef = new RegExp('^( *//)?( *#define[ \\t]+' + elm.id + '[ \\t]+)(\\S*)([ \\t]*/[*/].*)?$', 'm'); |
|
|
|
|
|
result = findDef.exec($c.text()); |
|
|
|
|
|
if (result !== null) { |
|
|
|
|
|
$.extend(info, { |
|
|
|
|
|
type: 'plain', |
|
|
|
|
|
line: result[0], |
|
|
|
|
|
pre: result[1] === undefined ? '' : result[1].replace('//',''), |
|
|
|
|
|
define: result[2], |
|
|
|
|
|
post: result[4] === undefined ? '' : result[4] |
|
|
|
|
|
}); |
|
|
|
|
|
info.regex = new RegExp('( *//)? *' + info.define.regEsc() + '(\\S*)' + info.post.regEsc(), 'm'); |
|
|
|
|
|
info.repl = new RegExp('(( *//)? *' + info.define.regEsc() + ')\\S*(' + info.post.regEsc() + ')', 'm'); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// a define with no quotes
|
|
|
if (info.type) { |
|
|
findDef = new RegExp('^(.*//)?(.*#define[ \\t]+' + elm.id + '[ \\t]+)(\\S*)([ \\t]*/[*/].*)?$', 'm'); |
|
|
info.lineNum = this.getLineNumberOfText(info.line, $c.text()); |
|
|
result = findDef.exec($c.text()); |
|
|
|
|
|
if (result !== null) { |
|
|
|
|
|
var info = { |
|
|
|
|
|
type:'plain', adv:adv, field:$c[0], val_i: 2, |
|
|
|
|
|
line: result[0], |
|
|
|
|
|
pre: result[1] === undefined ? '' : result[1].replace('//',''), |
|
|
|
|
|
define: result[2], |
|
|
|
|
|
post: result[4] === undefined ? '' : result[4] |
|
|
|
|
|
}; |
|
|
|
|
|
info.regex = new RegExp('(.*//)?.*' + info.define.regEsc() + '(\\S*)' + info.post.regEsc(), 'm'); |
|
|
|
|
|
info.repl = new RegExp('((.*//)?.*' + info.define.regEsc() + ')\\S*(' + info.post.regEsc() + ')', 'm'); |
|
|
|
|
|
info.lineNum = this.getLineInText(info.line, $c.text()); |
|
|
|
|
|
this.log(info,2); |
|
|
this.log(info,2); |
|
|
return info; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
info = null; |
|
|
|
|
|
|
|
|
return null; |
|
|
return info; |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Count the number of lines before a match, return -1 on fail |
|
|
* Count the number of lines before a match, return -1 on fail |
|
|
*/ |
|
|
*/ |
|
|
getLineInText: function(line, txt) { |
|
|
getLineNumberOfText: function(line, txt) { |
|
|
var pos = txt.indexOf(line); |
|
|
var pos = txt.indexOf(line); |
|
|
return (pos < 0) ? pos : txt.substr(0, pos).lineCount(); |
|
|
return (pos < 0) ? pos : txt.substr(0, pos).lineCount(); |
|
|
}, |
|
|
}, |
|
@ -636,7 +625,7 @@ var configuratorApp = (function(){ |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
logOnce: function(o) { |
|
|
logOnce: function(o) { |
|
|
if (typeof o.didLogThisObject === 'undefined') { |
|
|
if (o.didLogThisObject === undefined) { |
|
|
this.log(o); |
|
|
this.log(o); |
|
|
o.didLogThisObject = true; |
|
|
o.didLogThisObject = true; |
|
|
} |
|
|
} |
|
|