This repository was archived by the owner on Jan 9, 2026. It is now read-only.
forked from jaandrle/dollar_dom_component
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexamples.html
More file actions
66 lines (63 loc) · 2.75 KB
/
examples.html
File metadata and controls
66 lines (63 loc) · 2.75 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<title>gulp_place("app.name", "variable") — Examples</title>
<script type="text/javascript" src="$dom_component.js?v=gulp_place('app.version', 'variable')"></script>
<style>
gulp_place("examples.css", "file_once")
</style>
</head>
<body>
<article>
<h1>gulp_place("app.name", "variable") — Examples</h1>
<a href="https://github.com/jaandrle/dollar_dom_component">⇠ Go back to GitHub repository</a>
<h2 id="heading_content">Content</h2>
<ul class="content"></ul>
<script>
function onKeyup(script, id){
const el= document.getElementById(id);
$dom.empty(el);
eval(script.textContent);
}
</script>
gulp_place("app._BUILD_= { example_el_id: 1 }", "eval");
gulp_place("/example_\wh2.sub.html", "glob_once");
<script>
document.addEventListener("paste", function enableInScriptTags(ev){
ev.preventDefault();
document.execCommand('insertText', false, ev.clipboardData.getData('text/plain'));
});
document.addEventListener("keydown", function enableInScriptTags(ev){
if(ev.target.tagName!=="SCRIPT"&&ev.target.tagName!=="STYLE") return false;
const { keyCode }= ev;
if(keyCode!==9&&keyCode!==13) return false;
ev.preventDefault();
document.execCommand('insertText', false, keyCode===9 ? " " : "\n ");
});
let h2_counter= 0;
const content_ul= document.getElementsByClassName('content')[0];
[ ...document.getElementsByTagName('h2') ].forEach(function(el){
const textContent= el.textContent;
if(textContent==="Content") return false;
const id= "heading_"+h2_counter++;
contentH2({ textContent, id }).mount(el, "replace");
contentLI({ textContent, id }).mount(content_ul);
});
function contentLI({ textContent, id }){
const href= "#"+id;
const { add, share }= $dom.component("LI", null);
add("A", { textContent, href });
return share;
}
function contentH2({ textContent, id }){
const { add, share }= $dom.component("H2", { id });
add("A", { textContent: "⇡", href: "#heading_content" });
add("SPAN", { textContent: " "+textContent }, -1);
return share;
}
</script>
</article>
</body>
</html>