Skip to content

Commit 6a63a3c

Browse files
authored
Merge pull request #153 from easycoder/dev
Set up demo files
2 parents ea16eda + e383323 commit 6a63a3c

File tree

3 files changed

+171
-91
lines changed

3 files changed

+171
-91
lines changed

iwsy/iwsystart.js

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,75 @@
11
window.onload = () => {
2-
const createCORSRequest = (url) => {
3-
let xhr = new XMLHttpRequest();
4-
if (`withCredentials` in xhr) {
2+
const createCORSRequest = (url) => {
3+
let xhr = new XMLHttpRequest();
4+
if (`withCredentials` in xhr) {
55

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

10-
} else if (typeof XDomainRequest != `undefined`) {
10+
} else if (typeof XDomainRequest != `undefined`) {
1111

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

17-
} else {
17+
} else {
1818

19-
// Otherwise, CORS is not supported by the browser.
20-
xhr = null;
19+
// Otherwise, CORS is not supported by the browser.
20+
xhr = null;
2121

22-
}
23-
return xhr;
24-
};
22+
}
23+
return xhr;
24+
};
2525

26-
const start = mode => {
27-
const container = document.getElementById(`iwsy-container`);
28-
const scriptElement = document.getElementById(`iwsy-script`);
29-
const path = scriptElement.innerText;
30-
if (scriptElement) {
31-
const request = createCORSRequest(`${path}?v=${Math.floor(Date.now())}`);
32-
if (!request) {
33-
throw Error(`Unable to access the JSON script`);
34-
}
26+
const start = mode => {
27+
const container = document.getElementById(`iwsy-container`);
28+
const scriptElement = document.getElementById(`iwsy-script`);
29+
const path = scriptElement.innerText;
30+
if (scriptElement) {
31+
const request = createCORSRequest(`${path}?v=${Math.floor(Date.now())}`);
32+
if (!request) {
33+
throw Error(`Unable to access the JSON script`);
34+
}
3535

36-
request.onload = () => {
37-
if (200 <= request.status && request.status < 400) {
38-
const script = JSON.parse(request.responseText);
39-
const iwsy = IWSY(container, script);
40-
const slash = path.lastIndexOf(`/`);
41-
iwsy.setPath(path.slice(0, slash + 1));
42-
iwsy.onStep(index => {
43-
});
44-
iwsy.run(`normal`, mode, () => {
45-
console.log(`All done`);
46-
});
47-
} else {
48-
throw Error(`Unable to access the JSON script`);
49-
}
50-
};
36+
request.onload = () => {
37+
if (200 <= request.status && request.status < 400) {
38+
const script = JSON.parse(request.responseText);
39+
const iwsy = IWSY(container, script);
40+
const slash = path.lastIndexOf(`/`);
41+
iwsy.setPath(path.slice(0, slash + 1));
42+
iwsy.onStep(() => {
43+
});
44+
iwsy.run(`normal`, mode, () => {
45+
console.log(`All done`);
46+
});
47+
} else {
48+
throw Error(`Unable to access the JSON script`);
49+
}
50+
};
5151

52-
request.onerror = () => {
53-
throw Error(`Unable to access the JSON script`);
54-
};
52+
request.onerror = () => {
53+
throw Error(`Unable to access the JSON script`);
54+
};
5555

56-
request.send();
57-
}
58-
};
56+
request.send();
57+
}
58+
};
5959

60-
// Wait for a click/tap or a keypress to start
61-
document.addEventListener(`click`, () => {
62-
document.removeEventListener(`click`);
63-
start(`auto`);
64-
});
65-
document.onkeydown = event => {
66-
document.onkeydown = null;
67-
if (event.code === `Enter`) {
68-
start(`auto`);
69-
}
70-
else {
71-
start(`manual`);
72-
}
73-
return true;
74-
};
60+
// Wait for a click/tap or a keypress to start
61+
const listener = document.addEventListener(`click`, () => {
62+
document.removeEventListener(`click`, listener);
63+
start(`auto`);
64+
});
65+
document.onkeydown = event => {
66+
document.onkeydown = null;
67+
if (event.code === `Enter`) {
68+
start(`auto`);
69+
}
70+
else {
71+
start(`manual`);
72+
}
73+
return true;
74+
};
7575
};

iwsy/resources/scripts/demo.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@
170170
"top": 0,
171171
"width": 1000,
172172
"height": 1000,
173-
"background": "url('resources/img/quickstart/SemoigoDawn.jpg')",
173+
"background": "url('resources/users/2020/160/1/images/SemoigoDawn.jpg')",
174174
"border": "",
175175
"borderRadius": "",
176176
"fontFamily": "",

0 commit comments

Comments
 (0)