Skip to content

Dev #129

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 2 commits into from
Jun 16, 2020
Merged

Dev #129

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
2 changes: 1 addition & 1 deletion dist/easycoder-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/easycoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -4535,7 +4535,7 @@ const EasyCoder_Browser = {
document.onKeyListeners.push(program);
}
program.onKeyPc = command.pc + 2;
document.onkeypress = function (event) {
document.onkeydown = function (event) {
for (const program of document.onKeyListeners) {
program.key = event.key;
try {
Expand Down
18 changes: 10 additions & 8 deletions dist/plugins/iwsy.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,22 @@ const EasyCoder_IWSY = {
return true;
case `run`:
const pc = compiler.getPc();
let mode = {
type: `constant`,
numeric: false,
content: `normal`
};
if (compiler.nextToken() !== `then`) {
mode = compiler.getValue();
let mode = `normal`;
let startMode = `wait`;
if (compiler.nextToken() === `fullscreen`) {
mode = compiler.getToken();
if ([`auto`, `manual`].includes(compiler.nextToken())) {
startMode = compiler.getToken();
compiler.next();
}
}
compiler.addCommand({
domain: `iwsy`,
keyword: `iwsy`,
lino,
action,
mode,
startMode,
then: 0
});
// Get the 'then' code, if any
Expand Down Expand Up @@ -188,7 +190,7 @@ const EasyCoder_IWSY = {
break;
case `run`:
if (EasyCoder.iwsyFunctions) {
EasyCoder.iwsyFunctions.run(program.getValue(command.mode), () => {
EasyCoder.iwsyFunctions.run(command.mode, command.startMode, () => {
program.run(command.then);
});
return 0;
Expand Down
35 changes: 28 additions & 7 deletions iwsy/iwsy.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,18 @@ const IWSY = (playerElement, text) => {
const ratio = 0.5 - Math.cos(Math.PI * animStep / animSteps) / 2;
for (const block of stepBlocks)
{
block.element.style.opacity = upDown ? ratio : 1.0 - ratio;
if (block.element) {
block.element.style.opacity = upDown ? ratio : 1.0 - ratio;
}
}
animStep++;
} else {
for (const block of stepBlocks)
{
block.element.style.opacity = upDown ? 1 : 0;
block.element.style.display = upDown ? `block` :`none`;
if (block.element) {
block.element.style.opacity = upDown ? 1 : 0;
block.element.style.display = upDown ? `block` :`none`;
}
}
clearInterval(interval);
if (!continueFlag) {
Expand Down Expand Up @@ -762,7 +766,7 @@ const IWSY = (playerElement, text) => {
removeStyles();
for (const block of script.blocks) {
const element = block.element;
if (typeof element !== `undefined`) {
if (element != null && typeof element !== `undefined`) {
removeElement(element);
block.element = null;
}
Expand Down Expand Up @@ -818,6 +822,9 @@ const IWSY = (playerElement, text) => {

// Process a single step
const doStep = step => {
if (!step) {
return;
}
if (step.title) {
console.log(`Step ${step.index}: ${step.title}`);
} else {
Expand Down Expand Up @@ -923,7 +930,7 @@ const IWSY = (playerElement, text) => {
};

// Run the presentation
const run = (mode, then) => {
const run = (mode, startMode, then) => {
script.then = then;
initScript();
if (mode === `fullscreen`) {
Expand All @@ -934,10 +941,24 @@ const IWSY = (playerElement, text) => {
document.onfullscreenchange = () => {
if (document.fullscreenElement) {
player = document.fullscreenElement;
script.runMode = `manual`;
enterManualMode(null);
script.nextStep = script.steps[0];
switch (startMode) {
case `auto`:
script.runMode = `auto`;
release();
break;
case `manual`:
script.runMode = `manual`;
release();
break;
case `wait`:
script.runMode = `manual`;
enterManualMode(null);
break;
}
} else {
player = playerElement;
script.stop = true;
}
};
}
Expand Down
Loading