Skip to content

Commit 5eaad3b

Browse files
committed
Bug fixes
1 parent 5accc8e commit 5eaad3b

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

easycoder/plugins/browser.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,34 @@ const EasyCoder_Browser = {
510510
}
511511
},
512512

513+
Focus: {
514+
515+
compile: (compiler) => {
516+
const lino = compiler.getLino();
517+
if (compiler.nextIsSymbol()) {
518+
const symbol = compiler.getToken();
519+
compiler.next();
520+
compiler.addCommand({
521+
domain: `browser`,
522+
keyword: `focus`,
523+
lino,
524+
symbol
525+
});
526+
return true;
527+
}
528+
compiler.addWarning(`Unrecognised syntax in 'focus'`);
529+
return false;
530+
},
531+
532+
run: (program) => {
533+
const command = program[program.pc];
534+
const symbol = program.getSymbolRecord(command.symbol);
535+
const element = symbol.element[symbol.index];
536+
element.focus();
537+
return command.pc + 1;
538+
}
539+
},
540+
513541
FORM: {
514542

515543
compile: (compiler) => {
@@ -1691,6 +1719,26 @@ const EasyCoder_Browser = {
16911719
}
16921720
throw new Error(`'${compiler.getToken()}' is not a symbol`);
16931721
}
1722+
} else if (token === `class`) {
1723+
if (compiler.nextTokenIs(`of`)) {
1724+
if (compiler.nextIsSymbol()) {
1725+
const symbol = compiler.getSymbolRecord();
1726+
if (symbol.extra === `dom`) {
1727+
if (compiler.nextTokenIs(`to`)) {
1728+
const value = compiler.getNextValue();
1729+
compiler.addCommand({
1730+
domain: `browser`,
1731+
keyword: `set`,
1732+
lino,
1733+
type: `setClass`,
1734+
symbolName: symbol.name,
1735+
value
1736+
});
1737+
return true;
1738+
}
1739+
}
1740+
}
1741+
}
16941742
} else if (token === `id`) {
16951743
if (compiler.nextTokenIs(`of`)) {
16961744
if (compiler.nextIsSymbol()) {
@@ -1952,6 +2000,15 @@ const EasyCoder_Browser = {
19522000
select.selectedIndex = -1;
19532001
}
19542002
break;
2003+
case `setClass`:
2004+
symbol = program.getSymbolRecord(command.symbolName);
2005+
target = symbol.element[symbol.index];
2006+
if (!target) {
2007+
targetId = program.getValue(symbol.value[symbol.index]);
2008+
target = document.getElementById(targetId);
2009+
}
2010+
target.classList.add(program.getValue(command.value));
2011+
break;
19552012
case `setId`:
19562013
symbol = program.getSymbolRecord(command.symbolName);
19572014
target = symbol.element[symbol.index];
@@ -2347,6 +2404,8 @@ const EasyCoder_Browser = {
23472404
return EasyCoder_Browser.FIELDSET;
23482405
case `file`:
23492406
return EasyCoder_Browser.FILE;
2407+
case `focus`:
2408+
return EasyCoder_Browser.Focus;
23502409
case `form`:
23512410
return EasyCoder_Browser.FORM;
23522411
case `fullscreen`:

easycoder/plugins/rest.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ const EasyCoder_Rest = {
140140
if (command.onError) {
141141
program.errorMessage = `Exception trapped: ${error}`;
142142
program.run(command.onError);
143-
program.run(command.pc + 1);
144143
} else {
145144
program.runtimeError(command.lino, `Error: ${error}`);
146145
}

0 commit comments

Comments
 (0)