Skip to content

Set up demo files #153

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 1 commit into from
Jun 29, 2020
Merged
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
Set up demo files
  • Loading branch information
graham-trott committed Jun 29, 2020
commit e383323edb86bdf9a79db1cfea03f95a118a84d6
124 changes: 62 additions & 62 deletions iwsy/iwsystart.js
Original file line number Diff line number Diff line change
@@ -1,75 +1,75 @@
window.onload = () => {
const createCORSRequest = (url) => {
let xhr = new XMLHttpRequest();
if (`withCredentials` in xhr) {
const createCORSRequest = (url) => {
let xhr = new XMLHttpRequest();
if (`withCredentials` in xhr) {

// Check if the XMLHttpRequest object has a "withCredentials" property.
// "withCredentials" only exists on XMLHTTPRequest2 objects.
xhr.open(`GET`, url, true);
// Check if the XMLHttpRequest object has a "withCredentials" property.
// "withCredentials" only exists on XMLHTTPRequest2 objects.
xhr.open(`GET`, url, true);

} else if (typeof XDomainRequest != `undefined`) {
} else if (typeof XDomainRequest != `undefined`) {

// Otherwise, check if XDomainRequest.
// XDomainRequest only exists in IE, and is IE's way of making CORS requests.
xhr = new XDomainRequest();
xhr.open(`GET`, url);
// Otherwise, check if XDomainRequest.
// XDomainRequest only exists in IE, and is IE's way of making CORS requests.
xhr = new XDomainRequest();
xhr.open(`GET`, url);

} else {
} else {

// Otherwise, CORS is not supported by the browser.
xhr = null;
// Otherwise, CORS is not supported by the browser.
xhr = null;

}
return xhr;
};
}
return xhr;
};

const start = mode => {
const container = document.getElementById(`iwsy-container`);
const scriptElement = document.getElementById(`iwsy-script`);
const path = scriptElement.innerText;
if (scriptElement) {
const request = createCORSRequest(`${path}?v=${Math.floor(Date.now())}`);
if (!request) {
throw Error(`Unable to access the JSON script`);
}
const start = mode => {
const container = document.getElementById(`iwsy-container`);
const scriptElement = document.getElementById(`iwsy-script`);
const path = scriptElement.innerText;
if (scriptElement) {
const request = createCORSRequest(`${path}?v=${Math.floor(Date.now())}`);
if (!request) {
throw Error(`Unable to access the JSON script`);
}

request.onload = () => {
if (200 <= request.status && request.status < 400) {
const script = JSON.parse(request.responseText);
const iwsy = IWSY(container, script);
const slash = path.lastIndexOf(`/`);
iwsy.setPath(path.slice(0, slash + 1));
iwsy.onStep(index => {
});
iwsy.run(`normal`, mode, () => {
console.log(`All done`);
});
} else {
throw Error(`Unable to access the JSON script`);
}
};
request.onload = () => {
if (200 <= request.status && request.status < 400) {
const script = JSON.parse(request.responseText);
const iwsy = IWSY(container, script);
const slash = path.lastIndexOf(`/`);
iwsy.setPath(path.slice(0, slash + 1));
iwsy.onStep(() => {
});
iwsy.run(`normal`, mode, () => {
console.log(`All done`);
});
} else {
throw Error(`Unable to access the JSON script`);
}
};

request.onerror = () => {
throw Error(`Unable to access the JSON script`);
};
request.onerror = () => {
throw Error(`Unable to access the JSON script`);
};

request.send();
}
};
request.send();
}
};

// Wait for a click/tap or a keypress to start
document.addEventListener(`click`, () => {
document.removeEventListener(`click`);
start(`auto`);
});
document.onkeydown = event => {
document.onkeydown = null;
if (event.code === `Enter`) {
start(`auto`);
}
else {
start(`manual`);
}
return true;
};
// Wait for a click/tap or a keypress to start
const listener = document.addEventListener(`click`, () => {
document.removeEventListener(`click`, listener);
start(`auto`);
});
document.onkeydown = event => {
document.onkeydown = null;
if (event.code === `Enter`) {
start(`auto`);
}
else {
start(`manual`);
}
return true;
};
};
2 changes: 1 addition & 1 deletion iwsy/resources/scripts/demo.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
"top": 0,
"width": 1000,
"height": 1000,
"background": "url('resources/img/quickstart/SemoigoDawn.jpg')",
"background": "url('resources/users/2020/160/1/images/SemoigoDawn.jpg')",
"border": "",
"borderRadius": "",
"fontFamily": "",
Expand Down
Loading