Skip to content

Commit 7fe2b51

Browse files
committed
Example updates
1 parent 2029d36 commit 7fe2b51

File tree

13 files changed

+722
-104
lines changed

13 files changed

+722
-104
lines changed

easycoder/easycoder-min.js

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

easycoder/easycoder.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,7 +2087,7 @@ const EasyCoder_Core = {
20872087
if (symbol.elements > oldCount) {
20882088
for (var n = oldCount; n < symbol.elements; n++) {
20892089
symbol.value.push({});
2090-
symbol.element.push({});
2090+
symbol.element.push(null);
20912091
}
20922092
} else {
20932093
symbol.value = symbol.value.slice(0, symbol.elements);
@@ -2841,7 +2841,7 @@ const EasyCoder_Core = {
28412841
const type = compiler.getToken();
28422842
switch (type) {
28432843
case `elements`:
2844-
if (compiler.nextTokenIs(`of`)) {
2844+
if ([`of`, `in`].includes(compiler.nextToken())) {
28452845
if (compiler.nextIsSymbol()) {
28462846
const name = compiler.getToken();
28472847
compiler.next();
@@ -3953,7 +3953,7 @@ const EasyCoder = {
39533953
pathname = ``;
39543954
}
39553955
if (typeof EasyCoder_Plugins === `undefined`) {
3956-
this.loadPluginJs(`${window.location.href}`);
3956+
this.loadPluginJs(`${window.location.host}`);
39573957
} else {
39583958
this.pluginsPath = pathname;
39593959
EasyCoder_Plugins.getGlobalPlugins(

easycoder/easycoder.zip

358 Bytes
Binary file not shown.

js/easycoder/Core.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1691,7 +1691,7 @@ const EasyCoder_Core = {
16911691
if (symbol.elements > oldCount) {
16921692
for (var n = oldCount; n < symbol.elements; n++) {
16931693
symbol.value.push({});
1694-
symbol.element.push({});
1694+
symbol.element.push(null);
16951695
}
16961696
} else {
16971697
symbol.value = symbol.value.slice(0, symbol.elements);
@@ -2445,7 +2445,7 @@ const EasyCoder_Core = {
24452445
const type = compiler.getToken();
24462446
switch (type) {
24472447
case `elements`:
2448-
if (compiler.nextTokenIs(`of`)) {
2448+
if ([`of`, `in`].includes(compiler.nextToken())) {
24492449
if (compiler.nextIsSymbol()) {
24502450
const name = compiler.getToken();
24512451
compiler.next();

js/easycoder/Main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ const EasyCoder = {
462462
pathname = ``;
463463
}
464464
if (typeof EasyCoder_Plugins === `undefined`) {
465-
this.loadPluginJs(`${window.location.href}`);
465+
this.loadPluginJs(`${window.location.host}`);
466466
} else {
467467
this.pluginsPath = pathname;
468468
EasyCoder_Plugins.getGlobalPlugins(

js/plugins/browser.js

Lines changed: 59 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,54 +1165,61 @@ const EasyCoder_Browser = {
11651165
},
11661166

11671167
run: (program) => {
1168+
let targetRecord;
11681169
const command = program[program.pc];
11691170
switch (command.action) {
11701171
case `change`:
11711172
targetRecord = program.getSymbolRecord(command.symbol);
11721173
targetRecord.program = program.script;
11731174
targetRecord.element.forEach(function (target, index) {
1174-
target.targetRecord = targetRecord;
1175-
target.targetIndex = index;
1176-
target.targetPc = command.pc + 2;
1177-
target.addEventListener(`change`, (event) => {
1178-
event.stopPropagation();
1179-
if (program.length > 0) {
1180-
const eventTarget = event.target;
1181-
if (typeof eventTarget.targetRecord !== `undefined`) {
1182-
eventTarget.targetRecord.index = eventTarget.targetIndex;
1183-
setTimeout(function () {
1184-
EasyCoder.timestamp = Date.now();
1185-
let p = EasyCoder.scripts[eventTarget.targetRecord.program];
1186-
p.run(eventTarget.targetPc);
1187-
}, 1);
1175+
if (target) {
1176+
target.targetRecord = targetRecord;
1177+
target.targetIndex = index;
1178+
target.targetPc = command.pc + 2;
1179+
target.addEventListener(`change`, (event) => {
1180+
event.stopPropagation();
1181+
if (program.length > 0) {
1182+
const eventTarget = event.target;
1183+
if (typeof eventTarget.targetRecord !== `undefined`) {
1184+
eventTarget.targetRecord.index = eventTarget.targetIndex;
1185+
setTimeout(function () {
1186+
EasyCoder.timestamp = Date.now();
1187+
let p = EasyCoder.scripts[eventTarget.targetRecord.program];
1188+
p.run(eventTarget.targetPc);
1189+
}, 1);
1190+
}
11881191
}
1189-
}
1190-
});
1192+
});
1193+
}
11911194
});
11921195
break;
11931196
case `click`:
11941197
targetRecord = program.getSymbolRecord(command.symbol);
11951198
targetRecord.program = program.script;
11961199
targetRecord.element.forEach(function (target, index) {
1197-
target.targetRecord = targetRecord;
1198-
target.targetIndex = index;
1199-
target.targetPc = command.pc + 2;
1200-
target.onclick = function (event) {
1201-
event.stopPropagation();
1202-
if (program.length > 0) {
1203-
const eventTarget = event.target;
1204-
eventTarget.blur();
1205-
if (typeof eventTarget.targetRecord !== `undefined`) {
1206-
eventTarget.targetRecord.index = eventTarget.targetIndex;
1207-
setTimeout(function () {
1208-
EasyCoder.timestamp = Date.now();
1209-
let p = EasyCoder.scripts[eventTarget.targetRecord.program];
1210-
p.run(eventTarget.targetPc);
1211-
}, 1);
1200+
if (target) {
1201+
target.targetRecord = targetRecord;
1202+
target.targetIndex = index;
1203+
target.targetPc = command.pc + 2;
1204+
target.onclick = function (event) {
1205+
event.stopPropagation();
1206+
if (program.length > 0) {
1207+
const eventTarget = event.target;
1208+
if (eventTarget.type != `radio`) {
1209+
eventTarget.blur();
1210+
}
1211+
if (typeof eventTarget.targetRecord !== `undefined`) {
1212+
eventTarget.targetRecord.index = eventTarget.targetIndex;
1213+
setTimeout(function () {
1214+
EasyCoder.timestamp = Date.now();
1215+
let p = EasyCoder.scripts[eventTarget.targetRecord.program];
1216+
p.run(eventTarget.targetPc);
1217+
}, 1);
1218+
}
12121219
}
1213-
}
1214-
return false;
1215-
};
1220+
return false;
1221+
};
1222+
}
12161223
});
12171224
break;
12181225
case `clickDocument`:
@@ -1606,7 +1613,9 @@ const EasyCoder_Browser = {
16061613
case `removeElement`:
16071614
const elementRecord = program.getSymbolRecord(command.element);
16081615
const element = elementRecord.element[elementRecord.index];
1609-
element.parentElement.removeChild(element);
1616+
if (element) {
1617+
element.parentElement.removeChild(element);
1618+
}
16101619
break;
16111620
case `removeStorage`:
16121621
const key = program.getValue(command.key);
@@ -2869,6 +2878,15 @@ const EasyCoder_Browser = {
28692878
};
28702879
}
28712880
return null;
2881+
case `storage`:
2882+
if (compiler.nextTokenIs(`keys`)) {
2883+
compiler.next();
2884+
return {
2885+
domain: `browser`,
2886+
type: `storageKeys`
2887+
};
2888+
}
2889+
return null;
28722890
case `parent`:
28732891
switch (compiler.nextToken()) {
28742892
case `name`:
@@ -3146,6 +3164,12 @@ const EasyCoder_Browser = {
31463164
numeric: false,
31473165
content: program.docPath
31483166
};
3167+
case `storageKeys`:
3168+
return {
3169+
type: `constant`,
3170+
numeric: false,
3171+
content: JSON.stringify(Object.keys(localStorage))
3172+
};
31493173
case `location`:
31503174
return {
31513175
type: `constant`,

0 commit comments

Comments
 (0)