-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwith.cal.and.svg.templates.html
63 lines (47 loc) · 2.38 KB
/
with.cal.and.svg.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
<!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">
<link rel="stylesheet" href="css/css.01.css">
<!-- Debug versions -->
<script type="module" src="widgets/calendar/CalendarDisplay.js"></script>
<script type="module" src="widgets/splitflap/SplitFlapDisplay.js"></script>
<!-- HTML imports are now obsolete -->
<link rel="import" id="import-01" href="templates/calendar.template.html">
<link rel="import" id="import-02" href="templates/split.flap.template.html">
<link rel="import" id="import-03" href="templates/svg.clock.template.html">
</head>
<body class="bg-img">
<h1 class="black-frame outline">These are Web Components in HTML Templates</h1>
<h2 class="black-frame outline"><link rel="import"> is now deprecated and removed from most browsers. This might not work...</h2>
<div style="display: grid; grid-template-areas: 'left right' 'bottom bottom'; grid-gap: 10px;">
<div id="calendar-placeholder" style="grid-area: left; vertical-align: top; text-align: center; padding-top: 55px;"></div>
<div id="svg-clock-placeholder" style="grid-area: right; vertical-align: top;"></div>
<div id="split-flap-placeholder" style="grid-area: bottom;"></div>
</div>
<script>
let linkCal = document.querySelector('link[rel="import"][id="import-01"]'); // Simplify this, is [rel="import"] necessary?
let contentCal = linkCal.import;
let linkSF = document.querySelector('link[rel="import"][id="import-02"]');
let contentSF = linkSF.import;
let linkClk = document.querySelector('link[rel="import"][id="import-03"]');
let contentClk = linkClk.import;
// Grab DOMs from the templates.
let cal = contentCal.querySelector('#calendar-id').content;
document.getElementById("calendar-placeholder").appendChild(cal.cloneNode(true));
let sf = contentSF.querySelector('#split-flap-id');
document.getElementById("split-flap-placeholder").appendChild(sf.cloneNode(true));
let sc = contentClk.querySelector('#svg-clock-id');
document.getElementById("svg-clock-placeholder").appendChild(sc.cloneNode(true));
window.onload = () => {
updateCalendar(); // Set to current date. Defined in the template.
};
</script>
<hr/>
<small>Take a look at the page source, it's really worth it.</small>
</body>
</html>