MeltwaterArchive / editor

GUI editor
MIT License
86 stars 45 forks source link

Brackets and braces are allowed on manual logic edit, but not in list of valid tokens #48

Closed timothykang closed 10 years ago

timothykang commented 10 years ago

Brackets and braces are valid keydowns: (jcsdl.gui.logic.js, line 932)

$input.keydown(function(ev) {
    var k = ev.which,
    s = ev.shiftKey;

    if (
...
        // allow open bracket
        || k == 219
...
        // allow close bracket
        || k == 221
...
    ) {
        return;
    } else {
        // disallow anything else
        ev.preventDefault();
    }

...but not valid tokens: (jcsdl.gui.logic.js, line 520):

tokensMap : {
    '(' : 'bracketOpen',
    ')' : 'bracketClose',
    '&' : 'operatorAnd',
    '|' : 'operatorOr',
    '!' : 'operatorNot',
    'filter' : 'filter'
},

...

if (this.tokensMap[t] === undefined) {
    throw 'Invalid character "' + token + '" in the logic!';
}

Looks like brackets and braces need to either be removed from the list of valid keydowns, or added to tokensMap.

michaldudek commented 10 years ago

Good spot ;) Fixed.