Skip to content

Commit f38f756

Browse files
authored
Merge pull request #129 from easycoder/dev
Dev
2 parents c8f74a4 + 736ef4b commit f38f756

File tree

11 files changed

+184
-64
lines changed

11 files changed

+184
-64
lines changed

dist/easycoder-min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/easycoder.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4535,7 +4535,7 @@ const EasyCoder_Browser = {
45354535
document.onKeyListeners.push(program);
45364536
}
45374537
program.onKeyPc = command.pc + 2;
4538-
document.onkeypress = function (event) {
4538+
document.onkeydown = function (event) {
45394539
for (const program of document.onKeyListeners) {
45404540
program.key = event.key;
45414541
try {

dist/plugins/iwsy.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,22 @@ const EasyCoder_IWSY = {
8383
return true;
8484
case `run`:
8585
const pc = compiler.getPc();
86-
let mode = {
87-
type: `constant`,
88-
numeric: false,
89-
content: `normal`
90-
};
91-
if (compiler.nextToken() !== `then`) {
92-
mode = compiler.getValue();
86+
let mode = `normal`;
87+
let startMode = `wait`;
88+
if (compiler.nextToken() === `fullscreen`) {
89+
mode = compiler.getToken();
90+
if ([`auto`, `manual`].includes(compiler.nextToken())) {
91+
startMode = compiler.getToken();
92+
compiler.next();
93+
}
9394
}
9495
compiler.addCommand({
9596
domain: `iwsy`,
9697
keyword: `iwsy`,
9798
lino,
9899
action,
99100
mode,
101+
startMode,
100102
then: 0
101103
});
102104
// Get the 'then' code, if any
@@ -188,7 +190,7 @@ const EasyCoder_IWSY = {
188190
break;
189191
case `run`:
190192
if (EasyCoder.iwsyFunctions) {
191-
EasyCoder.iwsyFunctions.run(program.getValue(command.mode), () => {
193+
EasyCoder.iwsyFunctions.run(command.mode, command.startMode, () => {
192194
program.run(command.then);
193195
});
194196
return 0;

iwsy/iwsy.js

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -225,14 +225,18 @@ const IWSY = (playerElement, text) => {
225225
const ratio = 0.5 - Math.cos(Math.PI * animStep / animSteps) / 2;
226226
for (const block of stepBlocks)
227227
{
228-
block.element.style.opacity = upDown ? ratio : 1.0 - ratio;
228+
if (block.element) {
229+
block.element.style.opacity = upDown ? ratio : 1.0 - ratio;
230+
}
229231
}
230232
animStep++;
231233
} else {
232234
for (const block of stepBlocks)
233235
{
234-
block.element.style.opacity = upDown ? 1 : 0;
235-
block.element.style.display = upDown ? `block` :`none`;
236+
if (block.element) {
237+
block.element.style.opacity = upDown ? 1 : 0;
238+
block.element.style.display = upDown ? `block` :`none`;
239+
}
236240
}
237241
clearInterval(interval);
238242
if (!continueFlag) {
@@ -762,7 +766,7 @@ const IWSY = (playerElement, text) => {
762766
removeStyles();
763767
for (const block of script.blocks) {
764768
const element = block.element;
765-
if (typeof element !== `undefined`) {
769+
if (element != null && typeof element !== `undefined`) {
766770
removeElement(element);
767771
block.element = null;
768772
}
@@ -818,6 +822,9 @@ const IWSY = (playerElement, text) => {
818822

819823
// Process a single step
820824
const doStep = step => {
825+
if (!step) {
826+
return;
827+
}
821828
if (step.title) {
822829
console.log(`Step ${step.index}: ${step.title}`);
823830
} else {
@@ -923,7 +930,7 @@ const IWSY = (playerElement, text) => {
923930
};
924931

925932
// Run the presentation
926-
const run = (mode, then) => {
933+
const run = (mode, startMode, then) => {
927934
script.then = then;
928935
initScript();
929936
if (mode === `fullscreen`) {
@@ -934,10 +941,24 @@ const IWSY = (playerElement, text) => {
934941
document.onfullscreenchange = () => {
935942
if (document.fullscreenElement) {
936943
player = document.fullscreenElement;
937-
script.runMode = `manual`;
938-
enterManualMode(null);
944+
script.nextStep = script.steps[0];
945+
switch (startMode) {
946+
case `auto`:
947+
script.runMode = `auto`;
948+
release();
949+
break;
950+
case `manual`:
951+
script.runMode = `manual`;
952+
release();
953+
break;
954+
case `wait`:
955+
script.runMode = `manual`;
956+
enterManualMode(null);
957+
break;
958+
}
939959
} else {
940960
player = playerElement;
961+
script.stop = true;
941962
}
942963
};
943964
}

0 commit comments

Comments
 (0)