-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwith.templates.html
92 lines (71 loc) · 2.82 KB
/
with.templates.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Using templates</title>
<link rel="icon" type="image/png" href="../logo-192x192.png">
<link rel="stylesheet" href="css/stylesheet.css">
<link rel="stylesheet" href="css/web-components.css">
<!-- Minified -->
<!--script type="module" src="lib/worldmap/world-map.min.js"></script>
<script type="module" src="lib/splitflap/split-flap-display.min.js"></script-->
<!-- Debug -->
<script type="module" src="widgets/worldmap/WorldMap.js"></script>
<script type="module" src="widgets/splitflap/SplitFlapDisplay.js"></script>
<!-- HTML imports are now obsolete -->
<link rel="import" id="import-01" href="templates/world.map.template.html">
<link rel="import" id="import-02" href="templates/split.flap.template.html">
<some-stuff att1="attribute-1" att2="attribute-2" id="uuid">Duh?</some-stuff>
<style>
html {
height: 100%;
width: 100%;
}
body {
color: gray;
font-family: "Helvetica Neue", Verdana, Arial, Helvetica, sans-serif;
/* background-image: linear-gradient(to bottom right, #4d4d4d, black); */
background: radial-gradient(at top, red -8%, orange 55%);
background-repeat: no-repeat;
background-size: 100% 100%;
}
.black-frame {
padding: 3px;
margin: 1px;
border-radius: 5px;
border: 1px solid silver;
box-shadow: 3px 3px #ccc;
}
.centered {
text-align: center;
}
</style>
</head>
<body>
<h1 class="black-frame">These are Web Components in HTML Templates</h1>
<h2 class="black-frame"><link rel="import"> is now deprecated and removed from most browsers. This might not work...</h2>
<div id="world-map-placeholder"></div>
<div id="split-flap-placeholder"></div>
<script>
// Check <some-stuff att1="attribute-1" att2="attribute-2">Duh?</some-stuff>
let a = document.querySelector('some-stuff[att1="attribute-1"][att2="attribute-2"]');
// debugger;
// var link = document.querySelector('link[rel="import"]'); // OK when there is only one...
// Simplify this, is [rel="import"] necessary?
// No. It can be 'link[id="import-01"]'
// or even just '#import-01', as there is an 'id' attribute.
// And document.getElementById('import-01') would do the job too.
let linkWM = document.querySelector('link[rel="import"][id="import-01"]');
let contentWM = linkWM.import;
let linkSF = document.querySelector('link[rel="import"][id="import-02"]');
let contentSF = linkSF.import;
// Grab DOMs from the templates.
let wm = contentWM.querySelector('#world-map-id');
document.getElementById("world-map-placeholder").appendChild(wm.cloneNode(true));
let sf = contentSF.querySelector('#split-flap-id');
document.getElementById("split-flap-placeholder").appendChild(sf.cloneNode(true));
</script>
<hr/>
<small>Take a look at the page source, it's really worth it.</small>
</body>
</html>