Skip to content

Dev #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 21, 2020
Merged

Dev #48

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 50 additions & 49 deletions dist/easycoder-min.js

Large diffs are not rendered by default.

51 changes: 38 additions & 13 deletions dist/easycoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -2692,7 +2692,7 @@ const EasyCoder_Core = {
: date.toLocaleDateString(spec.locale, spec.options);
return {
type: `constant`,
numeric: true,
numeric: false,
content
};
}
Expand Down Expand Up @@ -3264,6 +3264,35 @@ const EasyCoder_Browser = {
}
},

Click: {

compile: (compiler) => {
const lino = compiler.getLino();
if (compiler.nextIsSymbol()) {
const targetRecord = compiler.getSymbolRecord();
if (targetRecord.keyword === `select`) {
compiler.next();
compiler.addCommand({
domain: `browser`,
keyword: `click`,
lino,
target: targetRecord.name
});
return true;
}
}
return false;
},

run: (program) => {
const command = program[program.pc];
const targetRecord = program.getSymbolRecord(command.target);
const element = targetRecord.element[targetRecord.index];
element.dispatchEvent(new Event('click'));
return command.pc + 1;
}
},

Clear: {

compile: (compiler) => {
Expand Down Expand Up @@ -5649,6 +5678,8 @@ const EasyCoder_Browser = {
return EasyCoder_Browser.CANVAS;
case `clear`:
return EasyCoder_Browser.Clear;
case `click`:
return EasyCoder_Browser.Click;
case `convert`:
return EasyCoder_Browser.Convert;
case `create`:
Expand Down Expand Up @@ -5831,7 +5862,7 @@ const EasyCoder_Browser = {
throw new Error(`'${compiler.getToken()}' is not a symbol`);
}
return null;
case `selected`:
case `selected`:
let arg = compiler.nextToken();
if ([`index`, `item`].includes(arg)) {
if ([`in`, `of`].includes(compiler.nextToken())) {
Expand All @@ -5850,7 +5881,7 @@ const EasyCoder_Browser = {
}
}
return null;
case `color`:
case `color`:
compiler.next();
const value = compiler.getValue();
return {
Expand Down Expand Up @@ -7041,7 +7072,7 @@ const EasyCoder_Rest = {
if (url[0] == `/`) {
path = url.substr(1);
} else {
path = `${window.location.origin}${rest}/${url}`;
path = `${rest}/${url}`;
}
}

Expand Down Expand Up @@ -7187,10 +7218,7 @@ const EasyCoder_Condition = {
const domain = compiler.domain[domainName];
const code = domain.condition.compile(compiler);
if (code) {
return {
domain: name,
...code
};
return code;
}
compiler.rewind();
}
Expand Down Expand Up @@ -7748,11 +7776,8 @@ const EasyCoder_Compiler = {
},

addCommand: function(item) {
const pc = this.program.length;
this.program.push({
pc,
...item
});
item.pc = this.program.length;
this.program.push(item);
},

addSymbol: function(name, pc) {
Expand Down
35 changes: 33 additions & 2 deletions js/easycoder/Browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,35 @@ const EasyCoder_Browser = {
}
},

Click: {

compile: (compiler) => {
const lino = compiler.getLino();
if (compiler.nextIsSymbol()) {
const targetRecord = compiler.getSymbolRecord();
if (targetRecord.keyword === `select`) {
compiler.next();
compiler.addCommand({
domain: `browser`,
keyword: `click`,
lino,
target: targetRecord.name
});
return true;
}
}
return false;
},

run: (program) => {
const command = program[program.pc];
const targetRecord = program.getSymbolRecord(command.target);
const element = targetRecord.element[targetRecord.index];
element.dispatchEvent(new Event('click'));
return command.pc + 1;
}
},

Clear: {

compile: (compiler) => {
Expand Down Expand Up @@ -2588,6 +2617,8 @@ const EasyCoder_Browser = {
return EasyCoder_Browser.CANVAS;
case `clear`:
return EasyCoder_Browser.Clear;
case `click`:
return EasyCoder_Browser.Click;
case `convert`:
return EasyCoder_Browser.Convert;
case `create`:
Expand Down Expand Up @@ -2770,7 +2801,7 @@ const EasyCoder_Browser = {
throw new Error(`'${compiler.getToken()}' is not a symbol`);
}
return null;
case `selected`:
case `selected`:
let arg = compiler.nextToken();
if ([`index`, `item`].includes(arg)) {
if ([`in`, `of`].includes(compiler.nextToken())) {
Expand All @@ -2789,7 +2820,7 @@ const EasyCoder_Browser = {
}
}
return null;
case `color`:
case `color`:
compiler.next();
const value = compiler.getValue();
return {
Expand Down
2 changes: 1 addition & 1 deletion js/easycoder/Core.js
Original file line number Diff line number Diff line change
Expand Up @@ -2692,7 +2692,7 @@ const EasyCoder_Core = {
: date.toLocaleDateString(spec.locale, spec.options);
return {
type: `constant`,
numeric: true,
numeric: false,
content
};
}
Expand Down
2 changes: 1 addition & 1 deletion js/easycoder/Rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const EasyCoder_Rest = {
if (url[0] == `/`) {
path = url.substr(1);
} else {
path = `${window.location.origin}${rest}/${url}`;
path = `${rest}/${url}`;
}
}

Expand Down
Loading