diff --git a/dist/easycoder-min.js b/dist/easycoder-min.js index 2647c29..ff87200 100644 --- a/dist/easycoder-min.js +++ b/dist/easycoder-min.js @@ -87,8 +87,8 @@ a=a.getValue(b.value[b.index]);c="";if(d&&a)if("object"===typeof a)c=a[d];else i b}},condition:{compile:function(a){if(a.isSymbol()){var b=a.getSymbolRecord();if("module"===b.keyword){if(a.nextTokenIs("is")){var c=!0;a.nextTokenIs("not")&&(a.next(),c=!1);if(a.tokenIs("running"))return a.next(),{domain:"core",type:"moduleRunning",name:b.name,sense:c}}return null}}if(a.tokenIs("not"))return{domain:"core",type:"not",value:a.getNextValue()};try{c=a.getValue();var d=a.getToken();if("includes"===d){var e=a.getNextValue();return{domain:"core",type:"includes",value1:c,value2:e}}if("is"=== d){a.next();var f=EasyCoder_Core.isNegate(a);switch(a.getToken()){case "numeric":return a.next(),{domain:"core",type:"numeric",value1:c,negate:f};case "even":return a.next(),{domain:"core",type:"even",value1:c};case "odd":return a.next(),{domain:"core",type:"odd",value1:c};case "greater":a.next();if(a.tokenIs("than")){a.next();var h=a.getValue();return{domain:"core",type:"greater",value1:c,value2:h,negate:f}}break;case "less":a.next();if(a.tokenIs("than")){a.next();var g=a.getValue();return{domain:"core", type:"less",value1:c,value2:g,negate:f}}break;default:var k=a.getValue();return{domain:"core",type:"is",value1:c,value2:k,negate:f}}}else if(c)return{domain:"core",type:"boolean",value:c}}catch(l){return a.warning("Can't get a value"),0}return null},test:function(a,b){switch(b.type){case "boolean":return a.getValue(b.value);case "numeric":var c=a.getValue(b.value1);c=" "===c||isNaN(c);return b.negate?c:!c;case "even":return 0===a.getValue(b.value1)%2;case "odd":return 1===a.getValue(b.value1)%2;case "is":return c= -a.compare(a,b.value1,b.value2),b.negate?0!==c:0===c;case "greater":return c=a.compare(a,b.value1,b.value2),b.negate?0>=c:0c;case "not":return!a.getValue(b.value);case "moduleRunning":return c=a.getSymbolRecord(b.name),EasyCoder.scripts.hasOwnProperty(c.program)?(c=EasyCoder.scripts[c.program],b.sense?c.running:!c.running):!b.sense;case "includes":return c=JSON.parse(a.getValue(b.value1)),b=a.getValue(b.value2),c.includes(b)}return!1}}}, -EasyCoder_Browser={name:"EasyCoder_Browser",A:{compile:function(a){a.compileVariable("browser","a",!1,"dom");return!0},run:function(a){return a[a.pc].pc+1}},Alert:{compile:function(a){var b=a.getLino(),c=a.getNextValue();a.addCommand({domain:"browser",keyword:"alert",lino:b,value:c});return!0},run:function(a){var b=a[a.pc];a=a.getFormattedValue(b.value);alert(a);return b.pc+1}},Attach:{compile:function(a){var b=a.getLino();a.next();if(a.isSymbol()){var c=a.getSymbolRecord(),d=c.keyword;switch(d){case "a":case "blockquote":case "button":case "canvas":case "div":case "fieldset":case "file":case "form":case "h1":case "h2":case "h3":case "h4":case "h5":case "h6":case "image":case "img":case "input":case "label":case "legend":case "li":case "option":case "p":case "pre":case "select":case "span":case "table":case "td":case "text":case "textarea":case "tr":case "ul":a.next(); +a.compare(a,b.value1,b.value2),b.negate?0!==c:0===c;case "greater":return c=a.compare(a,b.value1,b.value2),b.negate?0>=c:0c;case "not":return!a.getValue(b.value);case "moduleRunning":return c=a.getSymbolRecord(b.name),EasyCoder.scripts.hasOwnProperty(c.program)?(c=EasyCoder.scripts[c.program],b.sense?c.running:!c.running):!b.sense;case "includes":return c=a.getValue(b.value1),b=a.getValue(b.value2),c.includes(b)}return!1}}},EasyCoder_Browser= +{name:"EasyCoder_Browser",A:{compile:function(a){a.compileVariable("browser","a",!1,"dom");return!0},run:function(a){return a[a.pc].pc+1}},Alert:{compile:function(a){var b=a.getLino(),c=a.getNextValue();a.addCommand({domain:"browser",keyword:"alert",lino:b,value:c});return!0},run:function(a){var b=a[a.pc];a=a.getFormattedValue(b.value);alert(a);return b.pc+1}},Attach:{compile:function(a){var b=a.getLino();a.next();if(a.isSymbol()){var c=a.getSymbolRecord(),d=c.keyword;switch(d){case "a":case "blockquote":case "button":case "canvas":case "div":case "fieldset":case "file":case "form":case "h1":case "h2":case "h3":case "h4":case "h5":case "h6":case "image":case "img":case "input":case "label":case "legend":case "li":case "option":case "p":case "pre":case "select":case "span":case "table":case "td":case "text":case "textarea":case "tr":case "ul":a.next(); if(a.tokenIs("to")){if(a.nextTokenIs("body"))if("div"===d)cssId="body",a.next();else throw Error("Body variable must be a div");else cssId=a.getValue();var e=0;a.tokenIs("or")&&(a.next(),e=a.getPc()+1,a.completeHandler());a.addCommand({domain:"browser",keyword:"attach",lino:b,type:d,symbol:c.name,cssId:cssId,onError:e});return!0}break;default:return a.addWarning("type '"+c.keyword+"' not recognized in browser 'attach'"),!1}}a.addWarning("Unrecognised syntax in 'attach'");return!1},run:function(a){var b= a[a.pc],c=null,d=null;"body"===b.cssId?d=document.body:(c=a.value.evaluate(a,b.cssId).content,d=document.getElementById(c));if(!d)return b.onError?a.run(b.onError):a.runtimeError(b.lino,"No such element: '"+c+"'"),0;var e=a.getSymbolRecord(b.symbol);e.element[e.index]=d;e.value[e.index]={type:"constant",numeric:!1,content:c};"popup"===b.type&&(a.popups.push(d.id),window.onclick=function(b){a.popups.includes(b.target.id)&&(b.target.style.display="none")});return b.pc+1}},Audioclip:{compile:function(a){a.compileVariable("browser", "audioclip");return!0},run:function(a){return a[a.pc].pc+1}},BLOCKQUOTE:{compile:function(a){a.compileVariable("browser","blockquote",!1,"dom");return!0},run:function(a){return a[a.pc].pc+1}},BUTTON:{compile:function(a){a.compileVariable("browser","button",!1,"dom");return!0},run:function(a){return a[a.pc].pc+1}},CANVAS:{compile:function(a){a.compileVariable("browser","canvas",!1,"dom");return!0},run:function(a){return a[a.pc].pc+1}},Click:{compile:function(a){var b=a.getLino();if(a.nextIsSymbol()){var c= diff --git a/dist/easycoder.js b/dist/easycoder.js index aba597d..27a9d0b 100644 --- a/dist/easycoder.js +++ b/dist/easycoder.js @@ -3064,7 +3064,7 @@ const EasyCoder_Core = { } return !condition.sense; case `includes`: - const value1 = JSON.parse(program.getValue(condition.value1)); + const value1 = program.getValue(condition.value1); const value2 = program.getValue(condition.value2); return value1.includes(value2); } diff --git a/js/easycoder/Core.js b/js/easycoder/Core.js index d9b0fdb..4077b2e 100644 --- a/js/easycoder/Core.js +++ b/js/easycoder/Core.js @@ -3064,7 +3064,7 @@ const EasyCoder_Core = { } return !condition.sense; case `includes`: - const value1 = JSON.parse(program.getValue(condition.value1)); + const value1 = program.getValue(condition.value1); const value2 = program.getValue(condition.value2); return value1.includes(value2); }