Skip to content

Commit 0e3d18d

Browse files
authored
Merge pull request #48 from easycoder/dev
Dev
2 parents 65d0b05 + 7c10c19 commit 0e3d18d

File tree

6 files changed

+124
-478
lines changed

6 files changed

+124
-478
lines changed

dist/easycoder-min.js

Lines changed: 50 additions & 49 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/easycoder.js

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2692,7 +2692,7 @@ const EasyCoder_Core = {
26922692
: date.toLocaleDateString(spec.locale, spec.options);
26932693
return {
26942694
type: `constant`,
2695-
numeric: true,
2695+
numeric: false,
26962696
content
26972697
};
26982698
}
@@ -3264,6 +3264,35 @@ const EasyCoder_Browser = {
32643264
}
32653265
},
32663266

3267+
Click: {
3268+
3269+
compile: (compiler) => {
3270+
const lino = compiler.getLino();
3271+
if (compiler.nextIsSymbol()) {
3272+
const targetRecord = compiler.getSymbolRecord();
3273+
if (targetRecord.keyword === `select`) {
3274+
compiler.next();
3275+
compiler.addCommand({
3276+
domain: `browser`,
3277+
keyword: `click`,
3278+
lino,
3279+
target: targetRecord.name
3280+
});
3281+
return true;
3282+
}
3283+
}
3284+
return false;
3285+
},
3286+
3287+
run: (program) => {
3288+
const command = program[program.pc];
3289+
const targetRecord = program.getSymbolRecord(command.target);
3290+
const element = targetRecord.element[targetRecord.index];
3291+
element.dispatchEvent(new Event('click'));
3292+
return command.pc + 1;
3293+
}
3294+
},
3295+
32673296
Clear: {
32683297

32693298
compile: (compiler) => {
@@ -5649,6 +5678,8 @@ const EasyCoder_Browser = {
56495678
return EasyCoder_Browser.CANVAS;
56505679
case `clear`:
56515680
return EasyCoder_Browser.Clear;
5681+
case `click`:
5682+
return EasyCoder_Browser.Click;
56525683
case `convert`:
56535684
return EasyCoder_Browser.Convert;
56545685
case `create`:
@@ -5831,7 +5862,7 @@ const EasyCoder_Browser = {
58315862
throw new Error(`'${compiler.getToken()}' is not a symbol`);
58325863
}
58335864
return null;
5834-
case `selected`:
5865+
case `selected`:
58355866
let arg = compiler.nextToken();
58365867
if ([`index`, `item`].includes(arg)) {
58375868
if ([`in`, `of`].includes(compiler.nextToken())) {
@@ -5850,7 +5881,7 @@ const EasyCoder_Browser = {
58505881
}
58515882
}
58525883
return null;
5853-
case `color`:
5884+
case `color`:
58545885
compiler.next();
58555886
const value = compiler.getValue();
58565887
return {
@@ -7041,7 +7072,7 @@ const EasyCoder_Rest = {
70417072
if (url[0] == `/`) {
70427073
path = url.substr(1);
70437074
} else {
7044-
path = `${window.location.origin}${rest}/${url}`;
7075+
path = `${rest}/${url}`;
70457076
}
70467077
}
70477078

@@ -7187,10 +7218,7 @@ const EasyCoder_Condition = {
71877218
const domain = compiler.domain[domainName];
71887219
const code = domain.condition.compile(compiler);
71897220
if (code) {
7190-
return {
7191-
domain: name,
7192-
...code
7193-
};
7221+
return code;
71947222
}
71957223
compiler.rewind();
71967224
}
@@ -7748,11 +7776,8 @@ const EasyCoder_Compiler = {
77487776
},
77497777

77507778
addCommand: function(item) {
7751-
const pc = this.program.length;
7752-
this.program.push({
7753-
pc,
7754-
...item
7755-
});
7779+
item.pc = this.program.length;
7780+
this.program.push(item);
77567781
},
77577782

77587783
addSymbol: function(name, pc) {

js/easycoder/Browser.js

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,35 @@ const EasyCoder_Browser = {
203203
}
204204
},
205205

206+
Click: {
207+
208+
compile: (compiler) => {
209+
const lino = compiler.getLino();
210+
if (compiler.nextIsSymbol()) {
211+
const targetRecord = compiler.getSymbolRecord();
212+
if (targetRecord.keyword === `select`) {
213+
compiler.next();
214+
compiler.addCommand({
215+
domain: `browser`,
216+
keyword: `click`,
217+
lino,
218+
target: targetRecord.name
219+
});
220+
return true;
221+
}
222+
}
223+
return false;
224+
},
225+
226+
run: (program) => {
227+
const command = program[program.pc];
228+
const targetRecord = program.getSymbolRecord(command.target);
229+
const element = targetRecord.element[targetRecord.index];
230+
element.dispatchEvent(new Event('click'));
231+
return command.pc + 1;
232+
}
233+
},
234+
206235
Clear: {
207236

208237
compile: (compiler) => {
@@ -2588,6 +2617,8 @@ const EasyCoder_Browser = {
25882617
return EasyCoder_Browser.CANVAS;
25892618
case `clear`:
25902619
return EasyCoder_Browser.Clear;
2620+
case `click`:
2621+
return EasyCoder_Browser.Click;
25912622
case `convert`:
25922623
return EasyCoder_Browser.Convert;
25932624
case `create`:
@@ -2770,7 +2801,7 @@ const EasyCoder_Browser = {
27702801
throw new Error(`'${compiler.getToken()}' is not a symbol`);
27712802
}
27722803
return null;
2773-
case `selected`:
2804+
case `selected`:
27742805
let arg = compiler.nextToken();
27752806
if ([`index`, `item`].includes(arg)) {
27762807
if ([`in`, `of`].includes(compiler.nextToken())) {
@@ -2789,7 +2820,7 @@ const EasyCoder_Browser = {
27892820
}
27902821
}
27912822
return null;
2792-
case `color`:
2823+
case `color`:
27932824
compiler.next();
27942825
const value = compiler.getValue();
27952826
return {

js/easycoder/Core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2692,7 +2692,7 @@ const EasyCoder_Core = {
26922692
: date.toLocaleDateString(spec.locale, spec.options);
26932693
return {
26942694
type: `constant`,
2695-
numeric: true,
2695+
numeric: false,
26962696
content
26972697
};
26982698
}

js/easycoder/Rest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ const EasyCoder_Rest = {
121121
if (url[0] == `/`) {
122122
path = url.substr(1);
123123
} else {
124-
path = `${window.location.origin}${rest}/${url}`;
124+
path = `${rest}/${url}`;
125125
}
126126
}
127127

0 commit comments

Comments
 (0)