Skip to content
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
13 changes: 0 additions & 13 deletions iwsy/README.md

This file was deleted.

21 changes: 21 additions & 0 deletions iwsy/demo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src='iwsy.js?v=2.7.1'></script>
<script src='iwsystart.js?v=2.7.1'></script>
</head>

<body>

<div id="iwsy-container" style="text-align:center;width:100%">
<b>JSON::Presenter</b><br>
Click/Tap or key Space/RightArrow to start in manual mode<br>
Click/Tap or key Space/RightArrow to advance<br>
Key Enter to start in auto mode<br>
Click/Tap to exit auto mode
</div>
<pre id="iwsy-script" style="display:none">resources/json/demo.json</pre>

</body>
</html>
7 changes: 4 additions & 3 deletions iwsy/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src='https://cdn.jsdelivr.net/gh/easycoder/easycoder.github.io/dist/easycoder.js?v=2.7.1'></script>
<!--script src='dist/easycoder.js?v=2.7.1'></script-->
<!--script src='https://cdn.jsdelivr.net/gh/easycoder/easycoder.github.io/dist/easycoder.js?v=2.7.1'></script-->
<script src='dist/easycoder.js?v=2.7.1'></script>
</head>

<body>
Expand All @@ -15,7 +15,8 @@
script Launcher

variable Script
rest get Script from `/resources/ecs/main.txt?v=` cat now
require js `dist/plugins/iwsy.js?v=` cat now
rest get Script from `/resources/ecs/iwsy.txt?v=` cat now
run Script
</pre>
</body>
Expand Down
54 changes: 47 additions & 7 deletions iwsy/iwsy.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,46 @@ const IWSY = (player, text) => {
}, step.duration * 1000);
};

// Get the bounding rectangle of a block
const getBlockRect = (block, r) => {
const left = block.defaults.left;
const top = block.defaults.top;
const width = block.defaults.width;
const height = block.defaults.height;
if (isNaN(left) || isNaN(top) || isNaN(width) || isNaN(height)) {
return rect;
}
const w = r.width / 1000;
const h = r.height / 1000;
const rect = {};
rect.width = width * w;
rect.height = height * h;
rect.left = left * w;
rect.top = top * h;
return rect;
};

// Create a block
const createBlock = (block) => {
const w = player.getBoundingClientRect().width / 1000;
const h = player.getBoundingClientRect().height / 1000;
const createBlock = block => {
const r = player.getBoundingClientRect();
let rect = {
width: r.width,
height: r.height,
left: 0,
top: 0
}
if (block.defaults.parent) {
for (b of script.blocks) {
if (b.defaults.name === block.defaults.parent) {
rect = getBlockRect(b, rect);
break;
}
}
};
const w = rect.width / 1000;
const h = rect.height / 1000;
const l = rect.left;
const t = rect.top;
const defaults = block.defaults;
const element = document.createElement(`div`);
player.appendChild(element);
Expand All @@ -97,15 +133,19 @@ const IWSY = (player, text) => {
element.style.position = `absolute`;
element.style.opacity = `0.0`;
let val = defaults.left;
if (!isNaN(val)) {
if (isNaN(val)) {
element.style.left = val;
} else {
val *= w;
element.style.left = `calc(${l}px + ${val}px)`;
}
element.style.left = val;
val = defaults.top;
if (!isNaN(val)) {
if (isNaN(val)) {
element.style.left = val;
} else {
val *= h;
element.style.top = `calc(${t}px + ${val}px)`;
}
element.style.top = val;
val = defaults.width;
if (!isNaN(val)) {
val = `${val * w}px`;
Expand Down
1 change: 0 additions & 1 deletion iwsy/properties.txt

This file was deleted.

2 changes: 1 addition & 1 deletion iwsy/resources/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# IWannaShowYou resources
# JSON::Presenter resources

These are all the resources - scripts, images and text files - called for by the website.
5 changes: 3 additions & 2 deletions iwsy/resources/ecs/blocks.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
variable ParentBlock
variable Defaults
variable PropertyDefaults
variable ParentDefaults
variable PropertyNames
variable PropertyName
variable SelectedBlock
Expand Down Expand Up @@ -188,8 +189,8 @@ Restart:
if M is not SelectedBlock
begin
put element M of Blocks into ParentBlock
put property `defaults` of ParentBlock into Defaults
json add property `name` of Defaults to BlockNames
put property `defaults` of ParentBlock into ParentDefaults
json add property `name` of ParentDefaults to BlockNames
end
add 1 to M
end
Expand Down
Loading