This repository was archived by the owner on Aug 15, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.html
More file actions
179 lines (176 loc) · 6.28 KB
/
Copy pathindex.html
File metadata and controls
179 lines (176 loc) · 6.28 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<!DOCTYPE html>
<html>
<!--
Copyright 2021-2022 Jens Hofschröer <structogramview@nigjo.de>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<head>
<meta charset="utf-8" />
<title>Struktogram Viewer</title>
<meta name="viewport" content="width=50em" />
<link rel="icon" href="logo16.png" sizes="16x16">
<link rel="stylesheet" href="structoview.css">
<script src="structoview.js"></script>
<link rel="stylesheet" href="structoedit.css">
<link rel="sample" id="samplesource" href="sample1.sc">
<script src="structoedit.js"></script>
<script src="structosvg.js"></script>
<script id="sampleinit">
(()=>{
let filename=document.getElementById('samplesource')?.href;
if(!filename){
//fallback directly to "fallbacksample"
document.addEventListener('DOMContentLoaded',()=>{
let sourceid = document.querySelector('[data-structcode-id]')?.dataset.structcodeId;
let fallback = document.getElementById('fallbacksample').content.querySelector("pre");
document.getElementById(sourceid).textContent = fallback.textContent;
var view=document.querySelector(".structview[data-structcode-id='"+sourceid+"']");
updateView(view);
});
return;
}
Promise.all([
fetch(filename).then(r=>{
if(r.ok){
return r.text();
}
throw r;
}),
new Promise(ok=>{
document.addEventListener('readystatechange',()=>{
if(document.readyState==='interactive'){
//select the first view
let sourceid = document.querySelector('.structview[data-structcode-id]')?.dataset.structcodeId;
ok(sourceid);
}
});
})
])
.then(args=>{
document.getElementById(args[1]).textContent = args[0];
var view=document.querySelector(".structview[data-structcode-id='"+args[1]+"']");
updateView(view);
}).catch(e=>{
//select the first view
let sourceid = document.querySelector('.structview[data-structcode-id]')?.dataset.structcodeId;
if(sourceid){
if(e instanceof Response){
document.getElementById(sourceid).textContent =
e.status+': '+e.statusText;
}else{
let fallback = document.getElementById('fallbacksample').content.querySelector("pre");
document.getElementById(sourceid).textContent = fallback.textContent;
}
var view=document.querySelector(".structview[data-structcode-id='"+sourceid+"']");
updateView(view);
}
});
})();
</script><script id="theming">
document.addEventListener('readystatechange', (e)=>{
if(document.readyState==='interactive'){
let storedTheme = sessionStorage.getItem('structoedit.theme');
if(storedTheme){
setTheme(storedTheme);
}
}
});
function updateTheme(event){
setTheme(event.target.value);
}
function setTheme(theme){
let them = theme==='light'?'dark':'light';
document.body.classList.remove("structoview-"+them);
document.body.classList.remove("structoedit-"+them);
if(document.body.classList.contains("structoview-"+theme)){
document.body.classList.remove("structoview-"+theme);
document.body.classList.remove("structoedit-"+theme);
document.getElementById('theme_light').checked = false;
document.getElementById('theme_dark').checked = false;
sessionStorage.removeItem('structoedit.theme');
}else{
document.body.classList.add("structoview-"+theme);
document.body.classList.add("structoedit-"+theme);
document.getElementById('theme_'+theme).checked = true;
sessionStorage.setItem('structoedit.theme', theme);
}
}
</script>
<!--<style>.badge{display:block;transform:translate(-25%,0)rotate(45deg)translate(50%,0%);}</style>-->
</head>
<body>
<input type="radio" name="viewOption" tabindex="2" checked id="showHTML">
<header>
<h1>Structogram Editor</h1>
</header>
<nav>
<ul title="View Options">
<li><ul class="buttons">
<li data-position="100"><label class="menuitem" for="showHTML">HTML</label></li>
<li data-position="9000"><select class="menuitem" name="locale" onchange="generateViews()">
<option>default
<option value="en">english
<option value="de">deutsch
</select></li>
</ul></li><li><ul class="options">
<li><label><input id="usecompactselect" type="checkbox" onchange="updateContent('sample1', event)"> Vertical 'Select'</label></li>
<li>Theme:
<input type="radio" name="theme" onclick="updateTheme(event)" id="theme_light" value="light">
<label title="Light Theme" for="theme_light">⬜</label>
<input type="radio" name="theme" onclick="updateTheme(event)" id="theme_dark" value="dark">
<label title="Dark Theme" for="theme_dark">⬛</label>
</li>
</ul></li>
</ul>
<ul title="Actions">
<li><ul class="buttons">
</ul></li>
<li><ul class="options">
</ul></li>
</ul>
</nav>
<main>
<figure id="source"><div class="scroller">
<div id="sample1marks" class="structcodemarks"></div>
<textarea tabindex="1" id="sample1" class="structcode" data-erroritem="source" data-marks="sample1marks" data-caption="Sample 1" onkeyup="checkCurrentContent(this,event)">
</textarea><template id="fallbacksample"><pre>
IF: external sources exist?
open source file
select all
copy to clipboard
select the textarea
select all
paste your sources from clipboard
ELSE:
select the textarea
select all
delete all
write your code
ENDIF:
export as SVG
</pre></template>
</div>
<figcaption>Sourcecode<span class="chars"> ≔ 🡐 ≠ ≤ ≥</span></figcaption>
</figure>
<figure id="diagram">
<div class="structview" id="diagramView"
data-structcode-id="sample1" data-structcode-xml="xmlview" data-structcode-svg="svgdiagram"></div>
<noscript><p>This Page does not work without JavaScript.</p></noscript>
<figcaption>Nassi–Shneiderman diagram</figcaption>
</figure>
</main>
<footer>
<div id="githublink">
<a tabindex="0" href="https://github.com/nigjo/structogramview/">Fork me on GitHub</a>
</div>
</footer>
</body>
</html>