Skip to content

Commit 573f43a

Browse files
authored
Merge pull request #106 from easycoder/dev
Add the users module
2 parents 4713198 + 3f05e49 commit 573f43a

19 files changed

+671
-1245
lines changed

iwsy/README.md

Lines changed: 0 additions & 13 deletions
This file was deleted.

iwsy/demo.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<html>
2+
<head>
3+
<meta charset="UTF-8">
4+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
5+
<script src='iwsy.js?v=2.7.1'></script>
6+
<script src='iwsystart.js?v=2.7.1'></script>
7+
</head>
8+
9+
<body>
10+
11+
<div id="iwsy-container" style="text-align:center;width:100%">
12+
<b>JSON::Presenter</b><br>
13+
Click/Tap or key Space/RightArrow to start in manual mode<br>
14+
Click/Tap or key Space/RightArrow to advance<br>
15+
Key Enter to start in auto mode<br>
16+
Click/Tap to exit auto mode
17+
</div>
18+
<pre id="iwsy-script" style="display:none">resources/json/demo.json</pre>
19+
20+
</body>
21+
</html>

iwsy/index.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<head>
33
<meta charset="UTF-8">
44
<meta name="viewport" content="width=device-width, initial-scale=1.0">
5-
<script src='https://cdn.jsdelivr.net/gh/easycoder/easycoder.github.io/dist/easycoder.js?v=2.7.1'></script>
6-
<!--script src='dist/easycoder.js?v=2.7.1'></script-->
5+
<!--script src='https://cdn.jsdelivr.net/gh/easycoder/easycoder.github.io/dist/easycoder.js?v=2.7.1'></script-->
6+
<script src='dist/easycoder.js?v=2.7.1'></script>
77
</head>
88

99
<body>
@@ -15,7 +15,8 @@
1515
script Launcher
1616

1717
variable Script
18-
rest get Script from `/resources/ecs/main.txt?v=` cat now
18+
require js `dist/plugins/iwsy.js?v=` cat now
19+
rest get Script from `/resources/ecs/iwsy.txt?v=` cat now
1920
run Script
2021
</pre>
2122
</body>

iwsy/iwsy.js

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,46 @@ const IWSY = (player, text) => {
8383
}, step.duration * 1000);
8484
};
8585

86+
// Get the bounding rectangle of a block
87+
const getBlockRect = (block, r) => {
88+
const left = block.defaults.left;
89+
const top = block.defaults.top;
90+
const width = block.defaults.width;
91+
const height = block.defaults.height;
92+
if (isNaN(left) || isNaN(top) || isNaN(width) || isNaN(height)) {
93+
return rect;
94+
}
95+
const w = r.width / 1000;
96+
const h = r.height / 1000;
97+
const rect = {};
98+
rect.width = width * w;
99+
rect.height = height * h;
100+
rect.left = left * w;
101+
rect.top = top * h;
102+
return rect;
103+
};
104+
86105
// Create a block
87-
const createBlock = (block) => {
88-
const w = player.getBoundingClientRect().width / 1000;
89-
const h = player.getBoundingClientRect().height / 1000;
106+
const createBlock = block => {
107+
const r = player.getBoundingClientRect();
108+
let rect = {
109+
width: r.width,
110+
height: r.height,
111+
left: 0,
112+
top: 0
113+
}
114+
if (block.defaults.parent) {
115+
for (b of script.blocks) {
116+
if (b.defaults.name === block.defaults.parent) {
117+
rect = getBlockRect(b, rect);
118+
break;
119+
}
120+
}
121+
};
122+
const w = rect.width / 1000;
123+
const h = rect.height / 1000;
124+
const l = rect.left;
125+
const t = rect.top;
90126
const defaults = block.defaults;
91127
const element = document.createElement(`div`);
92128
player.appendChild(element);
@@ -97,15 +133,19 @@ const IWSY = (player, text) => {
97133
element.style.position = `absolute`;
98134
element.style.opacity = `0.0`;
99135
let val = defaults.left;
100-
if (!isNaN(val)) {
136+
if (isNaN(val)) {
137+
element.style.left = val;
138+
} else {
101139
val *= w;
140+
element.style.left = `calc(${l}px + ${val}px)`;
102141
}
103-
element.style.left = val;
104142
val = defaults.top;
105-
if (!isNaN(val)) {
143+
if (isNaN(val)) {
144+
element.style.left = val;
145+
} else {
106146
val *= h;
147+
element.style.top = `calc(${t}px + ${val}px)`;
107148
}
108-
element.style.top = val;
109149
val = defaults.width;
110150
if (!isNaN(val)) {
111151
val = `${val * w}px`;

iwsy/properties.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

iwsy/resources/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# IWannaShowYou resources
1+
# JSON::Presenter resources
22

33
These are all the resources - scripts, images and text files - called for by the website.

iwsy/resources/ecs/blocks.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
variable ParentBlock
2727
variable Defaults
2828
variable PropertyDefaults
29+
variable ParentDefaults
2930
variable PropertyNames
3031
variable PropertyName
3132
variable SelectedBlock
@@ -188,8 +189,8 @@ Restart:
188189
if M is not SelectedBlock
189190
begin
190191
put element M of Blocks into ParentBlock
191-
put property `defaults` of ParentBlock into Defaults
192-
json add property `name` of Defaults to BlockNames
192+
put property `defaults` of ParentBlock into ParentDefaults
193+
json add property `name` of ParentDefaults to BlockNames
193194
end
194195
add 1 to M
195196
end

0 commit comments

Comments
 (0)