Changeset 2136853
- Timestamp:
- 08/09/2019 09:08:36 AM (7 years ago)
- Location:
- easycoder/trunk
- Files:
-
- 7 edited
-
easycoder-min.js (modified) (3 diffs)
-
easycoder.js (modified) (6 diffs)
-
easycoder.php (modified) (2 diffs)
-
plugins/browser.js (modified) (12 diffs)
-
plugins/gmap.js (modified) (3 diffs)
-
readme.txt (modified) (1 diff)
-
rest.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
easycoder/trunk/easycoder-min.js
r2128094 r2136853 11 11 $jscomp.stringPadding=function(d,k){d=void 0!==d?String(d):" ";return 0<k&&d?d.repeat(Math.ceil(k/d.length)).substring(0,k):""};$jscomp.polyfill("String.prototype.padStart",function(d){return d?d:function(d,h){var f=$jscomp.checkStringArgs(this,null,"padStart");return $jscomp.stringPadding(h,d-f.length)+f}},"es8","es3");$jscomp.polyfill("Number.isFinite",function(d){return d?d:function(d){return"number"!==typeof d?!1:!isNaN(d)&&Infinity!==d&&-Infinity!==d}},"es6","es3"); 12 12 $jscomp.polyfill("Number.isInteger",function(d){return d?d:function(d){return Number.isFinite(d)?d===Math.floor(d):!1}},"es6","es3"); 13 (function(){function d(k,h,f){function c(b,q){if(!h[b]){if(!k[b]){var e="function"==typeof require&&require;if(!q&&e)return e(b,!0);if(a)return a(b,!0);q=Error("Cannot find module '"+b+"'");throw q.code="MODULE_NOT_FOUND",q;}q=h[b]={exports:{}};k[b][0].call(q.exports,function(a){return c(k[b][1][a]||a)},q,q.exports,d,k,h,f)}return h[b].exports}for(var a="function"==typeof require&&require,b=0;b<f.length;b++)c(f[b]);return c}return d})()({1:[function(d,k,h){var f=d("./easycoder/Main");f.version="2.4. 5";13 (function(){function d(k,h,f){function c(b,q){if(!h[b]){if(!k[b]){var e="function"==typeof require&&require;if(!q&&e)return e(b,!0);if(a)return a(b,!0);q=Error("Cannot find module '"+b+"'");throw q.code="MODULE_NOT_FOUND",q;}q=h[b]={exports:{}};k[b][0].call(q.exports,function(a){return c(k[b][1][a]||a)},q,q.exports,d,k,h,f)}return h[b].exports}for(var a="function"==typeof require&&require,b=0;b<f.length;b++)c(f[b]);return c}return d})()({1:[function(d,k,h){var f=d("./easycoder/Main");f.version="2.4.6"; 14 14 f.timestamp=Date.now();console.log("EasyCoder loaded; waiting for page");window.onload=function(){console.log(Date.now()-f.timestamp+" ms: Page loaded; reset timer & start EasyCoder");f.timestamp=Date.now();f.scripts={};window.EasyCoder=f;var c=document.getElementById("easycoder-script");if(c){c.style.display="none";try{f.start(c.innerText)}catch(a){f.reportError(a)}}}},{"./easycoder/Main":6}],2:[function(d,k,h){k.exports=function(d,c,a){c=d.value.evaluate(d,c);d=d.value.evaluate(d,a);a=c.content; 15 15 var b=d.content;a&&c.numeric?d.numeric||(b="undefined"===typeof b?0:parseInt(b)):(b&&d.numeric&&(b=b.toString()),"undefined"===typeof a&&(a=""),"undefined"===typeof b&&(b=""));return a>b?1:a<b?-1:0}},{}],3:[function(d,k,h){var f=Object.assign||function(a){for(var b=1;b<arguments.length;b++){var c=arguments[b],d;for(d in c)Object.prototype.hasOwnProperty.call(c,d)&&(a[d]=c[d])}return a},c=this,a={getTokens:function(){return c.tokens},addWarning:function(a){c.warnings.push(a)},warning:function(b){a.addWarning(b)}, … … 48 48 e;break;case "restore":a.onRestore=e;break;case "message":a.onMessage=e;break;case "error":a.onError=e;break;default:var c=a.getSymbolRecord(b.action);if(c)c.cb=e;else return a.runtimeError(b.lino,"Unknown action '"+b.action+"'"),0}return b.pc+1}},Print:{compile:function(a){var b=a.getLino();a.next();var e=a.getValue();a.addCommand({domain:"core",keyword:"print",lino:b,value:e});return!0},run:function(a){var b=a[a.pc];a=a.getFormattedValue(b.value);console.log("-> "+a);return b.pc+1}},Put:{compile:function(a){var b= 49 49 a.getLino(),e=a.getNextValue();if(a.tokenIs("into")){if(a.nextIsSymbol()){var c=a.getToken();a.next();a.addCommand({domain:"core",keyword:"put",lino:b,value:e,target:c});return!0}a.warning("core:put: No such variable: '"+a.getToken()+"'")}return!1},run:function(a){var b=a[a.pc],e=a.getSymbolRecord(b.target);e.isValueHolder||a.variableDoesNotHoldAValueError(b.lino,e.name);a=a.evaluate(b.value);e.value[e.index]={type:a.type,numeric:a.numeric,content:a.content};e.imported&&(e=e.exporter.getSymbolRecord(e.exportedName), 50 e.value[e.index]=a);return b.pc+1}},Replace:{compile:function(a){var b=a.getLino(),e=a.getNextValue();if(a.tokenIs("with")){var c=a.getNextValue();if(a.tokenIs("in")&&a.nextIsSymbol()){var d=a.getSymbolRecord(); a.next();if(d.isValueHolder)returna.addCommand({domain:"core",keyword:"replace",lino:b,original:e,replacement:c,target:d.name}),!0;throw Error("'"+d.name+"' does not hold a value");}}return!1},run:function(a){var b=a[a.pc],e=a.getValue(b.original),c=a.getValue(b.replacement),d=a.getSymbolRecord(b.target);50 e.value[e.index]=a);return b.pc+1}},Replace:{compile:function(a){var b=a.getLino(),e=a.getNextValue();if(a.tokenIs("with")){var c=a.getNextValue();if(a.tokenIs("in")&&a.nextIsSymbol()){var d=a.getSymbolRecord();if(d.isValueHolder)return a.next(),a.addCommand({domain:"core",keyword:"replace",lino:b,original:e,replacement:c,target:d.name}),!0;throw Error("'"+d.name+"' does not hold a value");}}return!1},run:function(a){var b=a[a.pc],e=a.getValue(b.original),c=a.getValue(b.replacement),d=a.getSymbolRecord(b.target); 51 51 a=a.getValue(d.value[d.index]).split(e).join(c);d.value[d.index]={type:"constant",numeric:!1,content:a};return b.pc+1}},Require:{compile:function(a){var b=a.getLino(),e=a.nextToken();if(["css","js"].includes(e)){var c=a.getNextValue();a.addCommand({domain:"core",keyword:"require",lino:b,type:e,url:c});return!0}throw Error("File type must be 'css' or 'js'");},run:function(a){var b=a[a.pc];a.require(b.type,a.getValue(b.url),function(){a.run(b.pc+1)});return 0}},Return:{compile:function(a){var b=a.getLino(); 52 52 a.next();a.addCommand({domain:"core",keyword:"return",lino:b});return!0},run:function(a){return a.stack.pop()}},Run:{compile:function(a){var b=a.getLino(),e=a.getNextValue(),c=[];if(a.tokenIs("with"))for(;;)if(a.nextIsSymbol(!0)){var d=a.getSymbolRecord();d.exporter=a.getProgram();c.push(d);a.next();if(!a.tokenIs("and"))break}if(a.tokenIs("as")&&a.nextIsSymbol(!0)){var l=a.getSymbolRecord();a.next();if("module"!==l.keyword)throw Error("'"+l.name+"' is not a module");l=l.name}var n=!1;a.tokenIs("nowait")&& … … 75 75 type:b,value:a};if("element"===b)return b=a.getNextValue(),a.tokenIs("of")&&a.nextIsSymbol()&&(c=a.getSymbolRecord(),a.next(),"variable"===c.keyword)?{domain:"core",type:"element",element:b,symbol:c.name}:null;if("property"===b)return b=a.getNextValue(),a.tokenIs("of")&&a.nextIsSymbol()&&(c=a.getSymbolRecord(),a.next(),"variable"===c.keyword)?{domain:"core",type:"property",property:b,symbol:c.name}:null;if("arg"===b&&(b=a.getNextValue(),a.tokenIs("of")&&a.nextIsSymbol()))return c=a.getSymbolRecord(), 76 76 a.next(),{domain:"core",type:"arg",value:b,target:c.name};a.tokenIs("the")&&a.next();b=a.getToken();switch(b){case "elements":if(a.nextTokenIs("of")&&a.nextIsSymbol())return c=a.getToken(),a.next(),{domain:"core",type:b,name:c};break;case "index":if(a.nextTokenIs("of")){if(a.nextIsSymbol()){if("in"===a.peek())return b=a.getValue(),a=a.getNextValue(),{domain:"core",type:"indexOf",value1:b,value2:a};c=a.getToken();a.next();return{domain:"core",type:b,name:c}}b=a.getValue();if(a.tokenIs("in"))return a= 77 a.getNextValue(),{domain:"core",type:"indexOf",value1:b,value2:a}}break;case "value":if(a.nextTokenIs("of"))return a.next(),{domain:"core",type:"valueOf",value:a.getValue()};break;case "length":if(a.nextTokenIs("of"))return a.next(),{domain:"core",type:"lengthOf",value:a.getValue()};break;case "left":case "right": c=a.getNextValue();if(a.tokenIs("of"))return a=a.getNextValue(),{domain:"core",type:b,count:c,value:a};break;case "from":c=a.getNextValue();var d=a.tokenIs("to")?a.getNextValue():null;if(a.tokenIs("of"))return a=78 a.getNextValue(),{domain:"core",type:b,from:c,to:d,value:a};break;case "position":if(a.nextTokenIs("of")&&(b=!1,a.nextTokenIs("the")&&a.nextTokenIs("last")&&(a.next(),b=!0),c=a.getValue(),a.tokenIs("in")))return a=a.getNextValue(),{domain:"core",type:"position",needle:c,haystack:a,last:b};break;case "payload":if(a.nextTokenIs("of")&&a.nextIsSymbol()&&(b=a.getSymbolRecord(),"callback"===b.keyword))return a.next(),{domain:"core",type:"payload",callback:b.name};break;case "message":case "error":return a.next(), 79 {domain:"core",type:b}}return null},get:function(a,b){switch(b.type){case "boolean":return{type:"boolean",numeric:!1,content:b.content};case "elements":return{type:"constant",numeric:!0,content:a.getSymbolRecord(b.name).elements};case "index":return{type:"constant",numeric:!0,content:a.getSymbolRecord(b.name).index};case "random":return a=a.evaluate(b.range),{type:"constant",numeric:!0,content:Math.floor(Math.random()*a.content)};case "cos":var c=a.getValue(b.angle_c);a=a.getValue(b.radius_c);return{type:"constant", 80 numeric:!0,content:parseInt(Math.cos(.01745329*parseFloat(c))*a,10)};case "sin":return c=a.getValue(b.angle_s),a=a.getValue(b.radius_s),{type:"constant",numeric:!0,content:parseInt(Math.sin(.01745329*parseFloat(c))*a,10)};case "tan":return c=a.getValue(b.angle_t),a=a.getValue(b.radius_t),{type:"constant",numeric:!0,content:parseInt(Math.tan(.01745329*parseFloat(c))*a,10)};case "valueOf":return a=parseInt(a.getValue(b.value)),{type:"constant",numeric:!0,content:a?a:0};case "lengthOf":return{type:"constant",81 numeric:!0,content:a.getValue(b.value).length};case "left":return{type:"constant",numeric:!1,content:a.getValue(b.value).substr(0,a.getValue(b.count))};case "right":return c=a.getValue(b.value),{type:"constant",numeric:!1,content:c.substr(c.length-a.getValue(b.count))};case "from":c=a.getValue(b.from);var d=b.to?a.getValue(b.to):null;a=a.getValue(b.value);return{type:"constant",numeric:!1,content:d?a.substr(c,d):a.substr(c)};case "position":return c=a.getValue(b.needle),a=a.getValue(b.haystack),{type:"constant", 82 numeric:!0,content:b.last?a.lastIndexOf(c):a.indexOf(c)};case "payload":return{type:"constant",numeric:!1,content:a.getSymbolRecord(b.callback).payload};case "modulo":return c=a.getSymbolRecord(b.name),a=a.evaluate(b.value),{type:"constant",numeric:!0,content:c.value[c.index].content%a.content};case "format":c=a.getSymbolRecord(b.name);c=1E3*a.getValue(c.value[c.index]);try{switch(d=JSON.parse(a.getValue(b.value)),d.mode){case "time":return{type:"constant",numeric:!0,content:(new Date(c)).toLocaleTimeString(d.locale,83 d.options)};default:return{type:"constant",numeric:!0,content:(new Date(c)).toLocaleDateString(d.locale,d.options)}}}catch(g){a.runtimeError(a[a.pc].lino,"Can't parse "+b.value);break}case "empty":return{type:"constant",numeric:!1,content:""};case "now":return{type:"constant",numeric:!0,content:Math.floor(Date.now()/1E3)};case "today":return a=new Date,a.setHours(0,0,0,0),{type:"constant",numeric:!0,content:Math.floor(a.getTime()/1E3)};case "date":return{type:"constant",numeric:!0,content:Date.parse(a.getValue(b.value))/ 84 1E3};case "newline":return{type:"constant",numeric:!1,content:"\n"};case "break":return{type:"constant",numeric:!1,content:"<br />"};case "encode":return{type:"constant",numeric:!1,content:a.encode(a.getValue(b.value))};case "decode":return{type:"constant",numeric:!1,content:a.decode(a.getValue(b.value))};case "lowercase":return{type:"constant",numeric:!1,content:a.getValue(b.value).toLowerCase()};case "hash":a=a.getValue(b.value);b=0;if(0===a.length)return b;for(c=0;c<a.length;c++)d=a.charCodeAt(c), 85 b=(b<<5)-b+d;return{type:"constant",numeric:!0,content:b};case "element":c=a.getValue(b.element);b=a.getSymbolRecord(b.symbol);d="";try{d=JSON.parse(a.getValue(b.value[b.index]))[c]}catch(g){a.runtimeError(a[a.pc].lino,"Can't parse JSON");break}return{type:"constant",numeric:!1,content:"object"===typeof d?JSON.stringify(d):d};case "property":d=a.getValue(b.property);b=a.getSymbolRecord(b.symbol);a=a.getValue(b.value[b.index]);c="";if(d&&a)if("object"===typeof a)c=a[d];else if("{"===a.charAt(0))try{c= 86 JSON.parse(a)[d]}catch(g){console.log("Can't parse '"+a+"': "+g.message)}return{type:"constant",numeric:!isNaN(c),content:"object"===typeof c?JSON.stringify(c):c};case "module":return{type:"boolean",numeric:!1,content:a.getSymbolRecord(b.name).program};case "message":return c=a.message,{type:"constant",numeric:!1,content:c};case "error":return c=a.errorMessage,{type:"constant",numeric:!1,content:c};case "indexOf":d=a.getValue(b.value1);b=a.getValue(b.value2);try{return c=JSON.parse(b).indexOf(d), 87 {type:"constant",numeric:!0,content:c}}catch(g){a.runtimeError(a[a.pc].lino,"Can't parse "+b)}break;case "arg":return c=a.getValue(b.value),c=a.getSymbolRecord(b.target)[c],{type:"constant",numeric:!isNaN(c),content:c}}return null},put:function(a,b){a.value[a.index]=b}},condition:{compile:function(a){if(a.isSymbol()){var b=a.getSymbolRecord();if("module"===b.keyword){if(a.nextTokenIs("is")){var d=!0;a.nextTokenIs("not")&&(a.next(),d=!1);if(a.tokenIs("running"))return a.next(),{domain:"core",type:"moduleRunning", 88 name:b.name,sense:d}}return null}}if(a.tokenIs("not"))return{domain:"core",type:"not",value:a.getNextValue()};try{if(d=a.getValue(),"is"===a.getToken()){a.next();var f=c.isNegate(a);switch(a.getToken()){case "numeric":return a.next(),{domain:"core",type:"numeric",value1:d};case "even":return a.next(),{domain:"core",type:"even",value1:d};case "odd":return a.next(),{domain:"core",type:"odd",value1:d};case "greater":a.next();if(a.tokenIs("than")){a.next();var g=a.getValue();return{domain:"core",type:"greater", 89 value1:d,value2:g,negate:f}}break;case "less":a.next();if(a.tokenIs("than")){a.next();var l=a.getValue();return{domain:"core",type:"less",value1:d,value2:l,negate:f}}break;default:var n=a.getValue();return{domain:"core",type:"is",value1:d,value2:n,negate:f}}}else if(d)return{domain:"core",type:"boolean",value:d}}catch(p){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":return!isNaN(a.getValue(b.value1));90 case " even":return 0===a.getValue(b.value1)%2;case "odd":return 1===a.getValue(b.value1)%2;case "is":return a=a.compare(a,b.value1,b.value2),b.negate?0!==a:0===a;case "greater":return a=a.compare(a,b.value1,b.value2),b.negate?0>=a:0<a;case "less":return a=a.compare(a,b.value1,b.value2),b.negate?0<=a:0>a;case "not":return!a.getValue(b.value);case "moduleRunning":return a=a.getSymbolRecord(b.name).program,b.sense?a:!a}return!1}}};k.exports=c},{}],6:[function(d,k,h){var f=this,c=d("./Compile"),a=d("./Run"),91 b=d("./Value"),e=d("./Condition"),q=d("./Compare"),g={domain:{core:d("./Core")},runtimeError:function(a,b){this.lino=a;this.reportError({message:"Line "+(0<=a?a:"")+": "+b},g.program);g.program.aborted=!0},nonNumericValueError:function(a){this.runtimeError(a,"Non-numeric value")},variableDoesNotHoldAValueError:function(a,b){this.runtimeError(a,"Variable '"+b+"' does not hold a value")},reportError:function(a,b,d){if(a.message)if(this.compiling||b){d=d?d:b.source;var e=d.tokens;d=d.scriptLines;e=this.compiling?92 e[c.getIndex()].lino:b[b.pc].lino;b=this.compiling?"Compile error":"Runtime error in '"+b.script+"'";b+=":\n";var l=e-5;for(l=0>l?0:l;l<e;l++){var n=(""+(l+1)).padStart(4," ");b+=n+" "+d[l].line.split("\\s").join(" ")+"\n"}b+=a.message+"\n";a=c.getWarnings();if(a.length)for(b+="Warnings:\n",a=$jscomp.makeIterator(a),d=a.next();!d.done;d=a.next())b+=d.value+"\n";console.log(b);alert(b)}else a="Error: "+a.message,alert(a),console.log(a);else console.log("An error occurred - origin was "+a.path[0])}, 93 getSymbolRecord:function(a){a=this[this.symbols[a].pc];return a.alias?this.getSymbolRecord(a.alias):a.exporter&&a.exporter!=this?a.exporter.getSymbolRecord(a.exportedName):a},verifySymbol:function(a){return this.symbols.hasOwnProperty(a)},encode:function(a){return b.encode(a,this.encoding)},decode:function(a){return b.decode(a,this.encoding)},evaluate:function(a){return b.evaluate(this,a)},getValue:function(a){return b.getValue(this,a)},getFormattedValue:function(a){a=b.evaluate(this,a);if(a.numeric)return a.content; 94 if("boolean"===a.type)return a.content?"true":"false";if('{"'===a.content.substr(0,2)||"["===a.content[0])try{var c=JSON.parse(a.content);return JSON.stringify(c,null,2)}catch(p){return this.reportError(p),"{}"}return a.content},getSimpleValue:function(a){return!0===a||!1===a?{type:"boolean",content:a}:{type:"constant",numeric:Number.isInteger(a),content:a}},run:function(b){b&&(g.program=this,a.run(this,b))},exit:function(){a.exit(this)},register:function(a){g.program=a},require:function(a,b,c){var d=95 document.createElement("css"===a?"link":"script");switch(a){case "css":d.type="text/css";d.href=b;d.rel="stylesheet";break;case "js":d.type="text/javascript";d.src=b;break;default:return}d.onload=function(){console.log(Date.now()-g.timestamp+" ms: Library "+b+" loaded");c()};document.head.appendChild(d)},isUndefined:function(a){return"undefined"===typeof a},runScript:function(a){var b=a[a.pc],c=a.getValue(b.script),d=b.imports,e=b.module?a.getSymbolRecord(b.module):null;try{g.tokeniseAndCompile(c.split("\n"), 96 d,e,this,b.then)}catch(v){this.reportError(v,g.program,a.source);a.onError?a.run(a.onError):a.parent&&a.parent.onError&&a.parent.run(a.parent.onError);return}b.nowait&&this.run(a.nextPc)},close:function(){},compileScript:function(a,d,f,h){var l=a.tokens;this.compiling=!0;c.value=b;c.condition=e;c.domain=g.domain;c.imports=d;d=c.compile(l);this.compiling=!1;d.EasyCoder=g;d.value=b;d.condition=e;d.compare=q;d.source=a;d.run=this.run;d.exit=this.exit;d.runScript=this.runScript;d.evaluate=this.evaluate; 97 d.getValue=this.getValue;d.getFormattedValue=this.getFormattedValue;d.getSimpleValue=this.getSimpleValue;d.encode=this.encode;d.decode=this.decode;d.domain=this.domain;d.require=this.require;d.isUndefined=this.isUndefined;d.checkPlugin=this.checkPlugin;d.getPlugin=this.getPlugin;d.addLocalPlugin=this.addLocalPlugin;d.getPluginsPath=this.getPluginsPath;d.getSymbolRecord=this.getSymbolRecord;d.verifySymbol=this.verifySymbol;d.runtimeError=this.runtimeError;d.nonNumericValueError=this.nonNumericValueError; 98 d.variableDoesNotHoldAValueError=this.variableDoesNotHoldAValueError;d.reportError=this.reportError;d.register=this.register;d.symbols=c.getSymbols();d.encoding="ec";d.popups=[];d.stack=[];d.queue=[0];d.module=f;d.parent=h;f&&(f.program=d);return d},tokeniseFile:function(a){var b=[],c=[],d=0;a.forEach(function(a,e){b.push({lino:e+1,line:a});for(var l=a.length,f="",g=!0,h=0;h<l;h++){var k=a[h];if(0==k.trim().length)g||(c.push({index:d,lino:e+1,token:f}),d++,f="",g=!0);else if(g=!1,"`"===k){for(m=h;++h< 99 a.length&&"`"!==a[h];);f=a.substr(m,h-m+1)}else if("!"==k)break;else f+=k}0<f.length&&c.push({index:d,lino:e+1,token:f})});return{scriptLines:b,tokens:c}},tokeniseAndCompile:function(b,c,d,e,f){var l=null,h=Date.now();b=g.tokeniseFile(b);try{l=g.compileScript(b,c,d,e);var k=Date.now();console.log(k-g.timestamp+" ms: "+("Compiled "+b.scriptLines.length+" lines ("+b.tokens.length+" tokens) in ")+(k-h+" ms"))}catch(r){"stop"!==r.message&&(c=g.program,this.reportError(r,c,b),c.onError&&c.run(c.onError))}l&&100 (l.onExit=f,a.run(l,0))},tokenise:function(a){var b=a.split("\n");if(!f.tokenising){try{g.tokeniseAndCompile(b)}catch(p){g.reportError(p,null,a)}f.tokenising=!0}},setPluginCount:function(a){f.plugins=[];f.pluginCount=a},checkPlugin:function(a){return g.domain[a]},getPlugin:function(a,b,c){g.domain[a]?c():(a=document.createElement("script"),a.type="text/javascript",a.src=b+"?ver="+g.version,a.onload=function(){console.log(Date.now()-g.timestamp+" ms: Plugin "+b+" loaded");c()},document.head.appendChild(a))},101 addGlobalPlugin:function(a,b){f.plugins.push({name:a,handler:b});f.plugins.length===f.pluginCount&&(f.plugins.forEach(function(a){g.domain[a.name]=a.handler}),g.tokenise(f.source))},addLocalPlugin:function(a,b,c){g.domain[a]=b;c()},getPluginsPath:function(){return g.pluginsPath},loadPluginJs:function(a){console.log(Date.now()-g.timestamp+" ms: Load "+a+"/easycoder/plugins.js");var b=document.createElement("script");b.src=""+window.location.origin+a+"/easycoder/plugins.js?ver="+g.version;b.type="text/javascript"; 102 b.onload=function(){EasyCoder_Plugins.getGlobalPlugins(g.timestamp,a,g.setPluginCount,g.getPlugin,g.addGlobalPlugin)};b.onerror=function(){a?g.loadPluginJs(a.slice(0,a.lastIndexOf("/"))):g.reportError({message:"Can't load plugins.js"},g.program,f.source)};document.head.appendChild(b);g.pluginsPath=a},start:function(a){f.source=a;a=window.location.pathname;a=a.endsWith("/")?a.slice(0,-1):"";g.loadPluginJs(a)}};k.exports=g},{"./Compare":2,"./Compile":3,"./Condition":4,"./Core":5,"./Run":7,"./Value":8}],103 7:[function(d,k,h){var f={run:function(c,a){var b=[],d=function(a){var b=9999;a.forEach(function(a){a=a.line;for(var c=0;c<a.length&&" "===a[c];)c++;0<c&&c<b&&(b=c)});return 0};if(b.length)b.push(a);else for(c.register(c),b.push(a);0<b.length;)for(c.pc=b.shift(),c.watchdog=0,a={};;){if(1E6<c.watchdog){c.lino=c[c.pc].lino;c.reportError(Error("Program runaway intercepted.\nHave you forgotten to increment a loop counter?",c),c);break}c.watchdog++;var h=c[c.pc].domain;c.debugStep&&console.log(c.script+ 104 ": Line "+c[c.pc].lino+": PC: "+c.pc+" "+h+":"+c[c.pc].keyword);var g=c.domain[h];if(!g){c.runtimeError(c[c.pc].lino,"Unknown domain '"+h+"'");break}c.pc=g.run(c);if(!c.pc)break;if(c.stop){c.tracing=!1;break}if(c.tracing){h=c[c.pc];g=c.source.scriptLines;var k=d(g),n=document.getElementById("easycoder-tracer");if(!n){c.runtimeError(h.lino,"Element 'easycoder-tracer' was not found");return}n.style.display="block";n.style.visibility="visible";var p="";if(c.tracer){if(n=document.getElementById("easycoder-tracer-content")){c.tracer.variables.forEach(function(a, 105 b,d){var e=c.getSymbolRecord(a);if(1<e.elements)for(p+=a+": "+e.index+"/"+e.elements+": ",a=0;a<e.elements;a++){var f=e.value[a];p=f?p+(f.content+" "):p+"undefined "}else p=(e=e.value[e.index])?p+(a+": "+e.content):p+(a+": undefined");switch(c.tracer.alignment){case "horizontal":b<d.length-1&&(p+=", ");break;case "vertical":p+="<br>"}});p+="<hr>";for(var u="",t=5;0<t;t--){if(h.lino){var v=g[h.lino-t].line.substr(k);u+='<input type="text" name="'+t+'"'+('value="'+(h.lino-t+1)+": "+v.split("\\s").join(" ")+ 106 '"')+'style="width:100%;border:none;enabled:false">'}u+="<br>"}n.innerHTML=p+" "+u;n.style.display="block";a.run=document.getElementById("easycoder-run-button");a.step=document.getElementById("easycoder-step-button");a.run.onclick=function(a){return function(){a.run.blur();c.tracing=!1;document.getElementById("easycoder-tracer-content").style.display="none";try{f.run(c,c.resume)}catch(r){var b="Error in run handler: "+r.message;console.log(b);alert(b)}}}(a);a.step.onclick=function(a){return function(){console.log("step"); 107 a.step.blur();c.tracing=!0;document.getElementById("easycoder-tracer-content").style.display="block";try{c.run(c.resume)}catch(r){var b="Error in step handler: "+r.message;console.log(b);alert(b)}}}(a)}c.resume=c.pc;c.pc=0}break}a={run:a.run,step:a.step}}},exit:function(c){c.onExit&&(c.parent.run(c.onExit),c.module.program=null)}};k.exports=f},{}],8:[function(d,k,h){var f={getItem:function(c){var a=c.getToken();if(!a)return null;if("true"===a)return c.next(),{type:"boolean",content:!0};if("false"===108 a)return c.next(),{type:"boolean",content:!1};if("`"===a.charAt(0))return c.next(),{type:"constant",numeric:!1,content:a.substring(1,a.length-1)};if(a.charAt(0).match(/[0-9-]/)){var b=eval(a);if(Number.isInteger(b))return c.next(),{type:"constant",numeric:!0,content:b};throw Error("'"+a+"' is not an integer");}a=c.getIndex();b=$jscomp.makeIterator(Object.keys(c.domain));for(var d=b.next();!d.done;d=b.next())if(d=d.value,c.rewindTo(a),d=c.domain[d].value.compile(c))return d;return null},compile:function(c){var a=109 c.getToken(),b=f.getItem(c);if(!b)throw Error("Undefined value: '"+a+"'");if("cat"===c.getToken()){for(a={type:"cat",numeric:!1,parts:[b]};c.tokenIs("cat");)c.next(),a.parts.push(c.value.getItem(c));return a}return b},doValue:function(c,a){if("undefined"===typeof a.type)return c.runtimeError(c[c.pc].lino,"Undefined value (variable not initialized?)"),null;switch(a.type){case "cat":return{type:"constant",numeric:!1,content:a.parts.reduce(function(a,b){return a+f.doValue(c,b).content},"")};case "boolean":case "constant":return a; 110 case "symbol":var b=c.getSymbolRecord(a.name);if(b.isValueHolder){if(a=b.value[b.index]){b=a.content;if(null===b||"undefined"===typeof b)a.content=a.numeric?0:"";return a}return null}return c.domain[b.domain].value.get(c,a)}return c.domain[a.domain].value.get(c,a)},constant:function(c,a){return{type:"constant",numeric:a,content:c}},evaluate:function(c,a){if(!a)return{type:"constant",numeric:!1,content:""};var b=f.doValue(c,a);if(b)return b;c.runtimeError(c[c.pc].lino,"Can't decode value: "+a)},getValue:function(c,111 a){return f.evaluate(c,a).content},encode:function(c,a){if(c)switch(a){case "ec":return c.replace(/'/g,"~sq~").replace(/"/g,"~dq~").replace(/\n/g,"%0a").replace(/\r/g,"%0d");case "url":return encodeURIComponent(c.replace(/\s/g,"+"));case "sanitize":return c.normalize("NFD").replace(/[\u0300-\u036f]/g,"")}return c},decode:function(c,a){if(c)switch(a){case "ec":return c.replace(/~dq~/g,'"').replace(/~sq~/g,"'").replace(/%0a/g,"\n").replace(/%0d/g,"\r");case "url":return decodeURIComponent(c).replace(/\+/g,112 " ")}return c}};k.exports=f},{}]},{},[1]);77 a.getNextValue(),{domain:"core",type:"indexOf",value1:b,value2:a}}break;case "value":if(a.nextTokenIs("of"))return a.next(),{domain:"core",type:"valueOf",value:a.getValue()};break;case "length":if(a.nextTokenIs("of"))return a.next(),{domain:"core",type:"lengthOf",value:a.getValue()};break;case "left":case "right":try{if(c=a.getNextValue(),a.tokenIs("of")){var d=a.getNextValue();return{domain:"core",type:b,count:c,value:d}}}catch(g){}break;case "from":c=a.getNextValue();d=a.tokenIs("to")?a.getNextValue(): 78 null;if(a.tokenIs("of"))return a=a.getNextValue(),{domain:"core",type:b,from:c,to:d,value:a};break;case "position":if(a.nextTokenIs("of")&&(b=!1,a.nextTokenIs("the")&&a.nextTokenIs("last")&&(a.next(),b=!0),c=a.getValue(),a.tokenIs("in")))return a=a.getNextValue(),{domain:"core",type:"position",needle:c,haystack:a,last:b};break;case "payload":if(a.nextTokenIs("of")&&a.nextIsSymbol()&&(b=a.getSymbolRecord(),"callback"===b.keyword))return a.next(),{domain:"core",type:"payload",callback:b.name};break; 79 case "message":case "error":return a.next(),{domain:"core",type:b}}return null},get:function(a,b){switch(b.type){case "boolean":return{type:"boolean",numeric:!1,content:b.content};case "elements":return{type:"constant",numeric:!0,content:a.getSymbolRecord(b.name).elements};case "index":return{type:"constant",numeric:!0,content:a.getSymbolRecord(b.name).index};case "random":return a=a.evaluate(b.range),{type:"constant",numeric:!0,content:Math.floor(Math.random()*a.content)};case "cos":var c=a.getValue(b.angle_c); 80 a=a.getValue(b.radius_c);return{type:"constant",numeric:!0,content:parseInt(Math.cos(.01745329*parseFloat(c))*a,10)};case "sin":return c=a.getValue(b.angle_s),a=a.getValue(b.radius_s),{type:"constant",numeric:!0,content:parseInt(Math.sin(.01745329*parseFloat(c))*a,10)};case "tan":return c=a.getValue(b.angle_t),a=a.getValue(b.radius_t),{type:"constant",numeric:!0,content:parseInt(Math.tan(.01745329*parseFloat(c))*a,10)};case "valueOf":return a=parseInt(a.getValue(b.value)),{type:"constant",numeric:!0, 81 content:a?a:0};case "lengthOf":return{type:"constant",numeric:!0,content:a.getValue(b.value).length};case "left":return{type:"constant",numeric:!1,content:a.getValue(b.value).substr(0,a.getValue(b.count))};case "right":return c=a.getValue(b.value),{type:"constant",numeric:!1,content:c.substr(c.length-a.getValue(b.count))};case "from":c=a.getValue(b.from);var d=b.to?a.getValue(b.to):null;a=a.getValue(b.value);return{type:"constant",numeric:!1,content:d?a.substr(c,d):a.substr(c)};case "position":return c= 82 a.getValue(b.needle),a=a.getValue(b.haystack),{type:"constant",numeric:!0,content:b.last?a.lastIndexOf(c):a.indexOf(c)};case "payload":return{type:"constant",numeric:!1,content:a.getSymbolRecord(b.callback).payload};case "modulo":return c=a.getSymbolRecord(b.name),a=a.evaluate(b.value),{type:"constant",numeric:!0,content:c.value[c.index].content%a.content};case "format":c=a.getSymbolRecord(b.name);c=1E3*a.getValue(c.value[c.index]);try{switch(d=JSON.parse(a.getValue(b.value)),d.mode){case "time":return{type:"constant", 83 numeric:!0,content:(new Date(c)).toLocaleTimeString(d.locale,d.options)};default:return{type:"constant",numeric:!0,content:(new Date(c)).toLocaleDateString(d.locale,d.options)}}}catch(g){a.runtimeError(a[a.pc].lino,"Can't parse "+b.value);break}case "empty":return{type:"constant",numeric:!1,content:""};case "now":return{type:"constant",numeric:!0,content:Math.floor(Date.now()/1E3)};case "today":return a=new Date,a.setHours(0,0,0,0),{type:"constant",numeric:!0,content:Math.floor(a.getTime()/1E3)}; 84 case "date":return{type:"constant",numeric:!0,content:Date.parse(a.getValue(b.value))/1E3};case "newline":return{type:"constant",numeric:!1,content:"\n"};case "break":return{type:"constant",numeric:!1,content:"<br />"};case "encode":return{type:"constant",numeric:!1,content:a.encode(a.getValue(b.value))};case "decode":return{type:"constant",numeric:!1,content:a.decode(a.getValue(b.value))};case "lowercase":return{type:"constant",numeric:!1,content:a.getValue(b.value).toLowerCase()};case "hash":a= 85 a.getValue(b.value);b=0;if(0===a.length)return b;for(c=0;c<a.length;c++)d=a.charCodeAt(c),b=(b<<5)-b+d;return{type:"constant",numeric:!0,content:b};case "element":c=a.getValue(b.element);b=a.getSymbolRecord(b.symbol);d="";try{d=JSON.parse(a.getValue(b.value[b.index]))[c]}catch(g){a.runtimeError(a[a.pc].lino,"Can't parse JSON");break}return{type:"constant",numeric:!1,content:"object"===typeof d?JSON.stringify(d):d};case "property":d=a.getValue(b.property);b=a.getSymbolRecord(b.symbol);a=a.getValue(b.value[b.index]); 86 c="";if(d&&a)if("object"===typeof a)c=a[d];else if("{"===a.charAt(0))try{c=JSON.parse(a)[d]}catch(g){console.log("Can't parse '"+a+"': "+g.message)}return{type:"constant",numeric:!isNaN(c),content:"object"===typeof c?JSON.stringify(c):c};case "module":return{type:"boolean",numeric:!1,content:a.getSymbolRecord(b.name).program};case "message":return c=a.message,{type:"constant",numeric:!1,content:c};case "error":return c=a.errorMessage,{type:"constant",numeric:!1,content:c};case "indexOf":d=a.getValue(b.value1); 87 b=a.getValue(b.value2);try{return c=JSON.parse(b).indexOf(d),{type:"constant",numeric:!0,content:c}}catch(g){a.runtimeError(a[a.pc].lino,"Can't parse "+b)}break;case "arg":return c=a.getValue(b.value),c=a.getSymbolRecord(b.target)[c],{type:"constant",numeric:!isNaN(c),content:c}}return null},put:function(a,b){a.value[a.index]=b}},condition:{compile:function(a){if(a.isSymbol()){var b=a.getSymbolRecord();if("module"===b.keyword){if(a.nextTokenIs("is")){var d=!0;a.nextTokenIs("not")&&(a.next(),d=!1); 88 if(a.tokenIs("running"))return a.next(),{domain:"core",type:"moduleRunning",name:b.name,sense:d}}return null}}if(a.tokenIs("not"))return{domain:"core",type:"not",value:a.getNextValue()};try{if(d=a.getValue(),"is"===a.getToken()){a.next();var f=c.isNegate(a);switch(a.getToken()){case "numeric":return a.next(),{domain:"core",type:"numeric",value1:d};case "even":return a.next(),{domain:"core",type:"even",value1:d};case "odd":return a.next(),{domain:"core",type:"odd",value1:d};case "greater":a.next(); 89 if(a.tokenIs("than")){a.next();var g=a.getValue();return{domain:"core",type:"greater",value1:d,value2:g,negate:f}}break;case "less":a.next();if(a.tokenIs("than")){a.next();var l=a.getValue();return{domain:"core",type:"less",value1:d,value2:l,negate:f}}break;default:var n=a.getValue();return{domain:"core",type:"is",value1:d,value2:n,negate:f}}}else if(d)return{domain:"core",type:"boolean",value:d}}catch(p){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); 90 case "numeric":return!isNaN(a.getValue(b.value1));case "even":return 0===a.getValue(b.value1)%2;case "odd":return 1===a.getValue(b.value1)%2;case "is":return a=a.compare(a,b.value1,b.value2),b.negate?0!==a:0===a;case "greater":return a=a.compare(a,b.value1,b.value2),b.negate?0>=a:0<a;case "less":return a=a.compare(a,b.value1,b.value2),b.negate?0<=a:0>a;case "not":return!a.getValue(b.value);case "moduleRunning":return a=a.getSymbolRecord(b.name).program,b.sense?a:!a}return!1}}};k.exports=c},{}],6:[function(d, 91 k,h){var f=this,c=d("./Compile"),a=d("./Run"),b=d("./Value"),e=d("./Condition"),q=d("./Compare"),g={domain:{core:d("./Core")},runtimeError:function(a,b){this.lino=a;this.reportError({message:"Line "+(0<=a?a:"")+": "+b},g.program);g.program.aborted=!0},nonNumericValueError:function(a){this.runtimeError(a,"Non-numeric value")},variableDoesNotHoldAValueError:function(a,b){this.runtimeError(a,"Variable '"+b+"' does not hold a value")},reportError:function(a,b,d){if(a.message)if(this.compiling||b){d=d? 92 d:b.source;var e=d.tokens;d=d.scriptLines;e=this.compiling?e[c.getIndex()].lino:b[b.pc].lino;b=this.compiling?"Compile error":"Runtime error in '"+b.script+"'";b+=":\n";var l=e-5;for(l=0>l?0:l;l<e;l++){var n=(""+(l+1)).padStart(4," ");b+=n+" "+d[l].line.split("\\s").join(" ")+"\n"}b+=a.message+"\n";a=c.getWarnings();if(a.length)for(b+="Warnings:\n",a=$jscomp.makeIterator(a),d=a.next();!d.done;d=a.next())b+=d.value+"\n";console.log(b);alert(b)}else a="Error: "+a.message,alert(a),console.log(a);else console.log("An error occurred - origin was "+ 93 a.path[0])},getSymbolRecord:function(a){a=this[this.symbols[a].pc];return a.alias?this.getSymbolRecord(a.alias):a.exporter&&a.exporter!=this?a.exporter.getSymbolRecord(a.exportedName):a},verifySymbol:function(a){return this.symbols.hasOwnProperty(a)},encode:function(a){return b.encode(a,this.encoding)},decode:function(a){return b.decode(a,this.encoding)},evaluate:function(a){return b.evaluate(this,a)},getValue:function(a){return b.getValue(this,a)},getFormattedValue:function(a){a=b.evaluate(this, 94 a);if(a.numeric)return a.content;if("boolean"===a.type)return a.content?"true":"false";if('{"'===a.content.substr(0,2)||"["===a.content[0])try{var c=JSON.parse(a.content);return JSON.stringify(c,null,2)}catch(p){return this.reportError(p),"{}"}return a.content},getSimpleValue:function(a){return!0===a||!1===a?{type:"boolean",content:a}:{type:"constant",numeric:Number.isInteger(a),content:a}},run:function(b){b&&(g.program=this,a.run(this,b))},exit:function(){a.exit(this)},register:function(a){g.program= 95 a},require:function(a,b,c){var d=document.createElement("css"===a?"link":"script");switch(a){case "css":d.type="text/css";d.href=b;d.rel="stylesheet";break;case "js":d.type="text/javascript";d.src=b;break;default:return}d.onload=function(){console.log(Date.now()-g.timestamp+" ms: Library "+b+" loaded");c()};document.head.appendChild(d)},isUndefined:function(a){return"undefined"===typeof a},runScript:function(a){var b=a[a.pc],c=a.getValue(b.script),d=b.imports,e=b.module?a.getSymbolRecord(b.module): 96 null;try{g.tokeniseAndCompile(c.split("\n"),d,e,this,b.then)}catch(v){this.reportError(v,g.program,a.source);a.onError?a.run(a.onError):a.parent&&a.parent.onError&&a.parent.run(a.parent.onError);return}b.nowait&&this.run(a.nextPc)},close:function(){},compileScript:function(a,d,f,h){var l=a.tokens;this.compiling=!0;c.value=b;c.condition=e;c.domain=g.domain;c.imports=d;d=c.compile(l);this.compiling=!1;d.EasyCoder=g;d.value=b;d.condition=e;d.compare=q;d.source=a;d.run=this.run;d.exit=this.exit;d.runScript= 97 this.runScript;d.evaluate=this.evaluate;d.getValue=this.getValue;d.getFormattedValue=this.getFormattedValue;d.getSimpleValue=this.getSimpleValue;d.encode=this.encode;d.decode=this.decode;d.domain=this.domain;d.require=this.require;d.isUndefined=this.isUndefined;d.checkPlugin=this.checkPlugin;d.getPlugin=this.getPlugin;d.addLocalPlugin=this.addLocalPlugin;d.getPluginsPath=this.getPluginsPath;d.getSymbolRecord=this.getSymbolRecord;d.verifySymbol=this.verifySymbol;d.runtimeError=this.runtimeError;d.nonNumericValueError= 98 this.nonNumericValueError;d.variableDoesNotHoldAValueError=this.variableDoesNotHoldAValueError;d.reportError=this.reportError;d.register=this.register;d.symbols=c.getSymbols();d.encoding="ec";d.popups=[];d.stack=[];d.queue=[0];d.module=f;d.parent=h;f&&(f.program=d);return d},tokeniseFile:function(a){var b=[],c=[],d=0;a.forEach(function(a,e){b.push({lino:e+1,line:a});for(var l=a.length,f="",g=!0,h=0;h<l;h++){var k=a[h];if(0==k.trim().length)g||(c.push({index:d,lino:e+1,token:f}),d++,f="",g=!0);else if(g= 99 !1,"`"===k){for(m=h;++h<a.length&&"`"!==a[h];);f=a.substr(m,h-m+1)}else if("!"==k)break;else f+=k}0<f.length&&c.push({index:d,lino:e+1,token:f})});return{scriptLines:b,tokens:c}},tokeniseAndCompile:function(b,c,d,e,f){var l=null,h=Date.now();b=g.tokeniseFile(b);try{l=g.compileScript(b,c,d,e);var k=Date.now();console.log(k-g.timestamp+" ms: "+("Compiled "+b.scriptLines.length+" lines ("+b.tokens.length+" tokens) in ")+(k-h+" ms"))}catch(r){"stop"!==r.message&&(c=g.program,this.reportError(r,c,b),c.onError&& 100 c.run(c.onError))}l&&(l.onExit=f,a.run(l,0))},tokenise:function(a){var b=a.split("\n");if(!f.tokenising){try{g.tokeniseAndCompile(b)}catch(p){g.reportError(p,null,a)}f.tokenising=!0}},setPluginCount:function(a){f.plugins=[];f.pluginCount=a},checkPlugin:function(a){return g.domain[a]},getPlugin:function(a,b,c){g.domain[a]?c():(a=document.createElement("script"),a.type="text/javascript",a.src=b+"?ver="+g.version,a.onload=function(){console.log(Date.now()-g.timestamp+" ms: Plugin "+b+" loaded");c()}, 101 document.head.appendChild(a))},addGlobalPlugin:function(a,b){f.plugins.push({name:a,handler:b});f.plugins.length===f.pluginCount&&(f.plugins.forEach(function(a){g.domain[a.name]=a.handler}),g.tokenise(f.source))},addLocalPlugin:function(a,b,c){g.domain[a]=b;c()},getPluginsPath:function(){return g.pluginsPath},loadPluginJs:function(a){console.log(Date.now()-g.timestamp+" ms: Load "+a+"/easycoder/plugins.js");var b=document.createElement("script");b.src=""+window.location.origin+a+"/easycoder/plugins.js?ver="+ 102 g.version;b.type="text/javascript";b.onload=function(){EasyCoder_Plugins.getGlobalPlugins(g.timestamp,a,g.setPluginCount,g.getPlugin,g.addGlobalPlugin)};b.onerror=function(){a?g.loadPluginJs(a.slice(0,a.lastIndexOf("/"))):g.reportError({message:"Can't load plugins.js"},g.program,f.source)};document.head.appendChild(b);g.pluginsPath=a},start:function(a){f.source=a;a=window.location.pathname;a=a.endsWith("/")?a.slice(0,-1):"";g.loadPluginJs(a)}};k.exports=g},{"./Compare":2,"./Compile":3,"./Condition":4, 103 "./Core":5,"./Run":7,"./Value":8}],7:[function(d,k,h){var f={run:function(c,a){var b=[],d=function(a){var b=9999;a.forEach(function(a){a=a.line;for(var c=0;c<a.length&&" "===a[c];)c++;0<c&&c<b&&(b=c)});return 0};if(b.length)b.push(a);else for(c.register(c),b.push(a);0<b.length;)for(c.pc=b.shift(),c.watchdog=0,a={};;){if(1E6<c.watchdog){c.lino=c[c.pc].lino;c.reportError(Error("Program runaway intercepted.\nHave you forgotten to increment a loop counter?",c),c);break}c.watchdog++;var h=c[c.pc].domain; 104 c.debugStep&&console.log(c.script+": Line "+c[c.pc].lino+": PC: "+c.pc+" "+h+":"+c[c.pc].keyword);var g=c.domain[h];if(!g){c.runtimeError(c[c.pc].lino,"Unknown domain '"+h+"'");break}c.pc=g.run(c);if(!c.pc)break;if(c.stop){c.tracing=!1;break}if(c.tracing){h=c[c.pc];g=c.source.scriptLines;var k=d(g),n=document.getElementById("easycoder-tracer");if(!n){c.runtimeError(h.lino,"Element 'easycoder-tracer' was not found");return}n.style.display="block";n.style.visibility="visible";var p="";if(c.tracer){if(n= 105 document.getElementById("easycoder-tracer-content")){c.tracer.variables.forEach(function(a,b,d){var e=c.getSymbolRecord(a);if(1<e.elements)for(p+=a+": "+e.index+"/"+e.elements+": ",a=0;a<e.elements;a++){var f=e.value[a];p=f?p+(f.content+" "):p+"undefined "}else p=(e=e.value[e.index])?p+(a+": "+e.content):p+(a+": undefined");switch(c.tracer.alignment){case "horizontal":b<d.length-1&&(p+=", ");break;case "vertical":p+="<br>"}});p+="<hr>";for(var u="",t=5;0<t;t--){if(h.lino){var v=g[h.lino-t].line.substr(k); 106 u+='<input type="text" name="'+t+'"'+('value="'+(h.lino-t+1)+": "+v.split("\\s").join(" ")+'"')+'style="width:100%;border:none;enabled:false">'}u+="<br>"}n.innerHTML=p+" "+u;n.style.display="block";a.run=document.getElementById("easycoder-run-button");a.step=document.getElementById("easycoder-step-button");a.run.onclick=function(a){return function(){a.run.blur();c.tracing=!1;document.getElementById("easycoder-tracer-content").style.display="none";try{f.run(c,c.resume)}catch(r){var b="Error in run handler: "+ 107 r.message;console.log(b);alert(b)}}}(a);a.step.onclick=function(a){return function(){console.log("step");a.step.blur();c.tracing=!0;document.getElementById("easycoder-tracer-content").style.display="block";try{c.run(c.resume)}catch(r){var b="Error in step handler: "+r.message;console.log(b);alert(b)}}}(a)}c.resume=c.pc;c.pc=0}break}a={run:a.run,step:a.step}}},exit:function(c){c.onExit&&(c.parent.run(c.onExit),c.module.program=null)}};k.exports=f},{}],8:[function(d,k,h){var f={getItem:function(c){var a= 108 c.getToken();if(!a)return null;if("true"===a)return c.next(),{type:"boolean",content:!0};if("false"===a)return c.next(),{type:"boolean",content:!1};if("`"===a.charAt(0))return c.next(),{type:"constant",numeric:!1,content:a.substring(1,a.length-1)};if(a.charAt(0).match(/[0-9-]/)){var b=eval(a);if(Number.isInteger(b))return c.next(),{type:"constant",numeric:!0,content:b};throw Error("'"+a+"' is not an integer");}a=c.getIndex();b=$jscomp.makeIterator(Object.keys(c.domain));for(var d=b.next();!d.done;d= 109 b.next())if(d=d.value,c.rewindTo(a),d=c.domain[d].value.compile(c))return d;return null},compile:function(c){var a=c.getToken(),b=f.getItem(c);if(!b)throw Error("Undefined value: '"+a+"'");if("cat"===c.getToken()){for(a={type:"cat",numeric:!1,parts:[b]};c.tokenIs("cat");)c.next(),a.parts.push(c.value.getItem(c));return a}return b},doValue:function(c,a){if("undefined"===typeof a.type)return c.runtimeError(c[c.pc].lino,"Undefined value (variable not initialized?)"),null;switch(a.type){case "cat":return{type:"constant", 110 numeric:!1,content:a.parts.reduce(function(a,b){return a+f.doValue(c,b).content},"")};case "boolean":case "constant":return a;case "symbol":var b=c.getSymbolRecord(a.name);if(b.isValueHolder){if(a=b.value[b.index]){b=a.content;if(null===b||"undefined"===typeof b)a.content=a.numeric?0:"";return a}return null}return c.domain[b.domain].value.get(c,a)}return c.domain[a.domain].value.get(c,a)},constant:function(c,a){return{type:"constant",numeric:a,content:c}},evaluate:function(c,a){if(!a)return{type:"constant", 111 numeric:!1,content:""};var b=f.doValue(c,a);if(b)return b;c.runtimeError(c[c.pc].lino,"Can't decode value: "+a)},getValue:function(c,a){return f.evaluate(c,a).content},encode:function(c,a){if(c)switch(a){case "ec":return c.replace(/'/g,"~sq~").replace(/"/g,"~dq~").replace(/\n/g,"%0a").replace(/\r/g,"%0d");case "url":return encodeURIComponent(c.replace(/\s/g,"+"));case "sanitize":return c.normalize("NFD").replace(/[\u0300-\u036f]/g,"")}return c},decode:function(c,a){if(c)switch(a){case "ec":return c.replace(/~dq~/g, 112 '"').replace(/~sq~/g,"'").replace(/%0a/g,"\n").replace(/%0d/g,"\r");case "url":return decodeURIComponent(c).replace(/\+/g," ")}return c}};k.exports=f},{}]},{},[1]); -
easycoder/trunk/easycoder.js
r2128094 r2136853 4 4 const EasyCoder = require(`./easycoder/Main`); 5 5 6 EasyCoder.version = `2.4. 5`;6 EasyCoder.version = `2.4.6`; 7 7 EasyCoder.timestamp = Date.now(); 8 8 console.log(`EasyCoder loaded; waiting for page`); … … 1573 1573 if (compiler.nextIsSymbol()) { 1574 1574 const targetRecord = compiler.getSymbolRecord(); 1575 compiler.next();1576 1575 if (targetRecord.isValueHolder) { 1576 compiler.next(); 1577 1577 compiler.addCommand({ 1578 1578 domain: `core`, … … 1598 1598 const command = program[program.pc]; 1599 1599 const original = program.getValue(command.original); 1600 // const org = original.split(`\\r`).join(`\r`).split(`\\n`).join(`\n`);1601 1600 const replacement = program.getValue(command.replacement); 1602 1601 const target = program.getSymbolRecord(command.target); … … 2787 2786 case `left`: 2788 2787 case `right`: 2789 const count = compiler.getNextValue(); 2790 if (compiler.tokenIs(`of`)) { 2791 const value = compiler.getNextValue(); 2792 return { 2793 domain: `core`, 2794 type, 2795 count, 2796 value 2797 }; 2788 try { 2789 const count = compiler.getNextValue(); 2790 if (compiler.tokenIs(`of`)) { 2791 const value = compiler.getNextValue(); 2792 return { 2793 domain: `core`, 2794 type, 2795 count, 2796 value 2797 }; 2798 } 2799 } catch (err) { 2800 return null; 2798 2801 } 2799 2802 break; … … 3609 3612 let program = null; 3610 3613 const startCompile = Date.now(); 3611 // const source = EasyCoder_Tokenise.tokenise(file);3612 3614 const source = EasyCoder.tokeniseFile(file); 3613 3615 try { … … 3730 3732 3731 3733 const minIndent = scriptLines => { 3732 varcount = 9999;3734 let count = 9999; 3733 3735 scriptLines.forEach(function (element) { 3734 3736 const item = element.line; 3735 varn = 0;3737 let n = 0; 3736 3738 while (n < item.length) { 3737 3739 if (item[n] !== ` `) { -
easycoder/trunk/easycoder.php
r2128094 r2136853 4 4 * Plugin URI: https://easycoder.software 5 5 * Description: Control the appearance and behavior of your posts and pages by embedding simple English-like scripts, without the need to learn JavaScript. 6 * Version: 2.4. 56 * Version: 2.4.6 7 7 * Author: EasyCoder Software 8 8 * Author URI: https://easycoder.software … … 17 17 function easycoder_enqueue_script() { 18 18 wp_enqueue_script('easycoder_script', plugin_dir_url( __FILE__ ) 19 . 'easycoder-min.js', array(), '2.4. 5');19 . 'easycoder-min.js', array(), '2.4.6'); 20 20 } 21 21 -
easycoder/trunk/plugins/browser.js
r2126294 r2136853 1370 1370 }, 1371 1371 1372 Request: { 1373 1374 compile: (compiler) => { 1375 const lino = compiler.getLino(); 1376 if (compiler.nextToken() === `fullscreen`) { 1377 let option = ``; 1378 if (compiler.nextToken() === `exit`) { 1379 option = `exit`; 1380 compiler.next(); 1381 } 1382 compiler.addCommand({ 1383 domain: `browser`, 1384 keyword: `request`, 1385 lino, 1386 option 1387 }); 1388 return true; 1389 } 1390 return false; 1391 }, 1392 1393 run: (program) => { 1394 const command = program[program.pc]; 1395 if (command.option === `exit`) { 1396 document.exitFullscreen(); 1397 } else { 1398 document.documentElement.requestFullscreen(); 1399 } 1400 return command.pc + 1; 1401 } 1402 }, 1403 1372 1404 SELECT: { 1373 1405 … … 1784 1816 select.selectedIndex = itemArray.indexOf(display); 1785 1817 } else { 1786 select.selectedIndex = -1;1818 select.selectedIndex = -1; 1787 1819 } 1788 1820 break; … … 2077 2109 const command = program[program.pc]; 2078 2110 const fileSpec = program.getSymbolRecord(command.file); 2079 // const path = program.getValue(command.path).replace(/~/g, `/`);2080 2111 const path = program.getValue(command.path); 2081 2112 const progressSpec = program.getSymbolRecord(command.progress); … … 2183 2214 case `form`: 2184 2215 return EasyCoder_Browser.FORM; 2216 case `fullscreen`: 2217 return EasyCoder_Browser.FullScreen; 2185 2218 case `get`: 2186 2219 return EasyCoder_Browser.Get; … … 2235 2268 case `remove`: 2236 2269 return EasyCoder_Browser.Remove; 2270 case `request`: 2271 return EasyCoder_Browser.Request; 2237 2272 case `select`: 2238 2273 return EasyCoder_Browser.SELECT; … … 2416 2451 return null; 2417 2452 } 2418 if ([` width`, `height`].includes(type)) {2453 if ([`top`, `bottom`, `left`, `right`, `width`, `height`].includes(type)) { 2419 2454 if (compiler.nextTokenIs(`of`)) { 2420 2455 if (compiler.nextIsSymbol()) { … … 2424 2459 return { 2425 2460 domain: `browser`, 2426 type : type === `width` ? `widthOf` : `heightOf`,2461 type, 2427 2462 symbol: symbol.name 2428 2463 }; … … 2433 2468 } 2434 2469 switch (type) { 2470 case `screen`: 2471 const attribute = compiler.nextToken(); 2472 if ([`width`, `height`].includes(attribute)) { 2473 compiler.next(); 2474 return { 2475 domain: `browser`, 2476 type, 2477 attribute 2478 }; 2479 } 2480 break; 2435 2481 case `scroll`: 2436 2482 if (compiler.nextTokenIs(`position`)) { … … 2583 2629 content: target.options[target.selectedIndex].text 2584 2630 }; 2585 case ` widthOf`:2631 case `top`: 2586 2632 symbolRecord = program.getSymbolRecord(value.symbol); 2587 content = symbolRecord.element[symbolRecord.index]. offsetWidth;2633 content = symbolRecord.element[symbolRecord.index].getBoundingClientRect().top; 2588 2634 return { 2589 2635 type: `constant`, … … 2591 2637 content 2592 2638 }; 2593 case ` heightOf`:2639 case `bottom`: 2594 2640 symbolRecord = program.getSymbolRecord(value.symbol); 2595 content = symbolRecord.element[symbolRecord.index]. offsetHeight;2641 content = symbolRecord.element[symbolRecord.index].getBoundingClientRect().bottom; 2596 2642 return { 2597 2643 type: `constant`, … … 2599 2645 content 2600 2646 }; 2647 case `left`: 2648 symbolRecord = program.getSymbolRecord(value.symbol); 2649 content = symbolRecord.element[symbolRecord.index].getBoundingClientRect().left; 2650 return { 2651 type: `constant`, 2652 numeric: true, 2653 content 2654 }; 2655 case `right`: 2656 symbolRecord = program.getSymbolRecord(value.symbol); 2657 content = symbolRecord.element[symbolRecord.index].getBoundingClientRect().right; 2658 return { 2659 type: `constant`, 2660 numeric: true, 2661 content 2662 }; 2663 case `width`: 2664 symbolRecord = program.getSymbolRecord(value.symbol); 2665 content = symbolRecord.element[symbolRecord.index].getBoundingClientRect().width; 2666 return { 2667 type: `constant`, 2668 numeric: true, 2669 content 2670 }; 2671 case `height`: 2672 symbolRecord = program.getSymbolRecord(value.symbol); 2673 content = symbolRecord.element[symbolRecord.index].getBoundingClientRect().height; 2674 return { 2675 type: `constant`, 2676 numeric: true, 2677 content 2678 }; 2601 2679 case `color`: 2602 2680 const styleValue = program.value.evaluate(program, value.value).content; … … 2654 2732 numeric: false, 2655 2733 content: location.hostname 2734 }; 2735 case `screen`: 2736 return { 2737 type: `constant`, 2738 numeric: true, 2739 content: screen[value.attribute] 2656 2740 }; 2657 2741 } -
easycoder/trunk/plugins/gmap.js
r2086338 r2136853 228 228 } 229 229 } 230 } else if ([` title`, `position`, `color`].includes(attribute)) {230 } else if ([`label`, `title`, `position`, `color`].includes(attribute)) { 231 231 if (compiler.nextTokenIs(`of`)) { 232 232 if (compiler.nextIsSymbol()) { … … 268 268 if ([`key`, `latitude`, `longitude`, `type`, `zoom`].includes(command.attribute)) { 269 269 symbolRecord[command.attribute] = program.getValue(command.value); 270 } else if (command.attribute === `label`) { 271 symbolRecord.label = program.getValue(command.value); 272 const marker = symbolRecord.element[symbolRecord.index]; 273 marker.setLabel(symbolRecord.label); 270 274 } else if (command.attribute === `title`) { 271 275 symbolRecord.title = program.getValue(command.value); … … 276 280 const marker = symbolRecord.element[symbolRecord.index]; 277 281 marker.setIcon(pinSymbol(symbolRecord.color)); 278 marker.setLabel(symbolRecord.title.charAt(0));279 282 } else if (command.attribute === `position`) { 280 283 const value = JSON.parse(program.getValue(command.value)); -
easycoder/trunk/readme.txt
r2128094 r2136853 53 53 54 54 == Changelog == 55 56 = 2.4.6 09-aug-2019 = 57 * Minor updates to gmap and others 55 58 56 59 = 2.4.5 24-jul-2019 = -
easycoder/trunk/rest.php
r2118094 r2136853 224 224 $path = "../../../$upload/" . str_replace('~', '/', $pathsegs[1]); 225 225 mkdir($path, 0777, true); 226 $fileName = $_FILES['source']['name'];226 $fileName = str_replace(' ', '-', $_FILES['source']['name']); 227 227 $tempName = $_FILES['source']['tmp_name']; 228 228 $fileType = $_FILES['source']['type']; … … 243 243 } 244 244 exit; 245 //case '_thumb':246 //// Endpoint: {site root}/wp-content/plugins/easycoder/rest.php/_thumb247 //header("Content-Type: application/json");248 //$value = stripslashes(file_get_contents("php://input"));249 //$json = json_decode($value);250 // $source = $json->source;251 // $dest = $json->dest;252 // system("convert $source -resize 100x100^ -gravity Center -crop 100x100+0+0 +repage $dest");253 // chmod("$dest", 0666);254 //exit;245 case '_thumb': 246 // Endpoint: {site root}/wp-content/plugins/easycoder/rest.php/_thumb 247 header("Content-Type: application/json"); 248 $value = stripslashes(file_get_contents("php://input")); 249 $json = json_decode($value); 250 $source = "../../../$resources/" . str_replace('~', '/', $json->source); 251 $dest = "../../../$resources/" . str_replace('~', '/', $json->dest); 252 mkdir(substr($dest, 0, strrpos($dest, '/')), 0777, true); 253 system("convert $source -resize 100x100^ -gravity Center -crop 100x100+0+0 +repage $dest"); 254 exit; 255 255 case '_delete': 256 256 // Endpoint: {site root}/wp-content/plugins/easycoder/rest.php/_delete/{path} … … 292 292 copy($path, $backup); 293 293 file_put_contents($path, $content); 294 logger("Saved $path"); 294 295 exit; 295 296 case '_ecsave': … … 319 320 } 320 321 break; 322 case 'OPTIONS': 323 include '../../../easycoder/rest-local.php'; 324 options_local($conn, $request); 321 325 } 322 326 … … 510 514 switch ($request[1]) { 511 515 case 'id': 512 // Endpoint: {site root}/wp-content/plugins/easycoder/rest.php/ {table}/id/{id}516 // Endpoint: {site root}/wp-content/plugins/easycoder/rest.php/set/{table}/id/{id} 513 517 // Set by id. The record must already exist 514 518 header("Content-Type: application/text"); … … 532 536 533 537 case 'name': 534 // Endpoint: {site root}/wp-content/plugins/easycoder/rest.php/ {table}/name/{name}538 // Endpoint: {site root}/wp-content/plugins/easycoder/rest.php/set/{table}/name/{name} 535 539 // Set by name. If the record does not exist, add it 536 540 header("Content-Type: application/text");
Note: See TracChangeset
for help on using the changeset viewer.