-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo.html
More file actions
137 lines (131 loc) · 6.16 KB
/
demo.html
File metadata and controls
137 lines (131 loc) · 6.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="shortcut icon" href="#" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="js-eden/js/lib/jquery-3.5.1.min.js"></script>
<script src="js-eden/js/lib/jquery-ui-1.12.1.min.js"></script>
<script src="js-eden/js/core/jseden.min.js"></script>
<script src="js-eden/plugins/jseden-plugins.min.js"></script>
<script src="js-eden/js/ui/jseden-ui.min.js"></script>
<!-- <script src="../node_modules/@fortawesome/fontawesome-free/js/fontawesome.js"></script>
<script src="../node_modules/@fortawesome/fontawesome-free/js/solid.js"></script> -->
<script src="document-eden/document-eden.js"></script>
<script>
URLUtil.prefix = "js-eden/";
window.allReadyResolve;
window.allReady = new Promise((resolve)=>{ window.allReadyResolve = resolve});
setTimeout(()=>{
window.edenProjectLoaded.then(window.allReadyResolve);
},1000);
</script>
<style>
body,button{
font-size: 2rem;
}
</style>
<link rel="stylesheet" type="text/css" href="js-eden/css/jquery-ui-1.12.1.min.css">
<link rel="stylesheet" type="text/css" href="js-eden/css/jseden.css">
<link rel="stylesheet" type="text/css" href="js-eden/plugins/jseden-plugins.min.css">
<!-- <link href="../node_modules/@fortawesome/fontawesome-free/css/fontawesome.css" rel="stylesheet">
<link href="../node_modules/@fortawesome/fontawesome-free/css/brands.css" rel="stylesheet">
<link href="../node_modules/@fortawesome/fontawesome-free/css/solid.css" rel="stylesheet"> -->
<link rel="stylesheet" type="text/css" href="js-eden/plugins/input-dialog/interpreter.css" />
<link rel="stylesheet" type="text/css" href="js-eden/plugins/input-dialog/details.css" />
<link rel="stylesheet" type="text/css" href="document-eden/document-eden.css" />
</head>
<body>
<h1>Basic Observables/Dependencies</h1>
<p>This is an example of a basic document using the document-eden library</p>
<p>We can define an observable £a = 6£.</p>
<p>Click the blue underlined value of a to change it</p>
<script type="text/jseden">
b is a * 10;
</script>
<p>Ten times that observable is £b£.</p>
<hr>
<h1>Changing attributes in HTML</h1>
<p>Observables can change the value of any HTML element, by changing the content or the attributes: £fontsize=40£</p>
<p>If you need to change the attribute, remember to add a <code>data-query</code> attribute to the tag.</p>
<p style="font-size:£fontsize£px" data-query>This is size £fontsize£px</p>
<hr>
<h1>Changing attributes in SVG</h1>
<p>You can change the values of the £colour=red£ square</p>
<p>Idea - add some UI for options for the colour instead of typing it - maybe even a colour picker?!</p>
<div>
<p>rx: £rx=50£, ry: £ry=50£</p>
<p>rWidth: £rWidth=50£, rHeight: £rHeight=50£</p>
</div>
<svg width="100%" height="200" xmlns="http://www.w3.org/2000/svg">
<rect width="£rWidth£" height="£rHeight£" x="£rx£" y="£ry£" fill="£colour£" data-query/>
</svg>
<hr>
<h1>JS-Eden Canvas</h1>
<p>Or you can use a JS-Eden style canvas (looks exactly the same, but added black border to definition just to show a difference!):</p>
<script type="text/jseden">
r is Rectangle(rx,ry,rWidth,rHeight,colour, "black");
picture is [r];
view_picture_height = 200;
view_picture_width = 400;
</script>
<div class="eden-picture" data-observable="picture">
</div>
<p>See the source of this page to set canvas size - <code>view_picture_height</code> and <code>view_picture_width</code>.</p>
<hr>
<h1>Actions</h1>
<p>Actions can be named (see the source code of this bit)</p>
<script type="text/jseden" data-action="changecolour">
action changeRectangle{
colour = nextColour;
}
nextColour is "red" if colour == "green" else "green";
</script>
<p>An action can contain an action (a tab in JS-Eden is an action).</p>
<p>Can link an action to a button like this (will change the above rectangle colour to £nextColour£):</p>
<button class="runAction" data-action="changecolour > changeRectangle">changeRectangle</button>
<p>Could also script it from JS as <code>DocumentEden.runAction(actionName);</code></p>
<hr>
<h1>Saving/Reloading State</h1>
<p>Might be appropriate to move between different 'phases' - allowing for definitions before and after a particular action has taken place</p>
<p>Could save lots of different states in a JS object, then reload particular ones</p>
<p>Message: £c£</p>
<script type="text/jseden" data-action="states">
c = "Before stateA";
action stateA{
c = "After stateA";
}
</script>
<script>
let savedState;
function stateDemo(){
savedState = DocumentEden.saveState();
}
function loadState(){
DocumentEden.loadState(savedState, 1);
}
</script>
<button onclick="stateDemo()">save state</button>
<button class="runAction" data-action="states > stateA">do state A</button>
<button onclick="loadState()">restore state</button>
<hr>
<h1>Using JSEden plugins</h1>
<p>Plugins can be embedded, e.g. a script view</p>
<script>
window.allReady.then(
()=>{
let scriptView = edenUI.createEmbedded("mysi", "ScriptInput", "script1", this);
root.lookup("view_mysi_tabs").assign(["> states"],root.scope,EdenSymbol.jsAgent);
root.lookup("view_mysi_current").assign(0,root.scope,EdenSymbol.jsAgent);
root.lookup("view_mysi_height").assign(300,root.scope,EdenSymbol.jsAgent);
root.lookup("view_mysi_width").assign(500,root.scope,EdenSymbol.jsAgent);
root.lookup("view_mysi_showtabs").assign(true,root.scope,EdenSymbol.jsAgent);
root.lookup("view_mysi_showbuttons").assign(true,root.scope,EdenSymbol.jsAgent);
document.getElementById("myscript").appendChild(scriptView.contents[0]);
}
);
</script>
<div id="myscript" style="position:relative; height: 300px">
</div>
</body>
</html>