forked from paperlesspaper/openintegration-xkcd
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrender.html
More file actions
118 lines (103 loc) · 2.69 KB
/
render.html
File metadata and controls
118 lines (103 loc) · 2.69 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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>GitHub Username</title>
<style>
:root {
color-scheme: light dark;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
font-family:
ui-sans-serif,
system-ui,
-apple-system,
BlinkMacSystemFont,
"Segoe UI",
sans-serif;
background: #fff;
color: #000;
}
.screen {
width: 100vw;
height: 100vh;
padding: 2em;
display: flex;
align-items: center;
justify-content: center;
}
.title {
font-size: 1rem;
font-weight: 600;
text-align: center;
width: 100%;
}
.status {
margin-top: 0.75rem;
font-size: clamp(0.95rem, 2vw, 1.25rem);
opacity: 0.8;
text-align: center;
}
</style>
</head>
<body>
<div id="website-has-loading-element"></div>
<main class="screen">
<section>
<div class="title" id="github-username">Loading…</div>
<div class="status" id="github-status">GitHub username</div>
</section>
</main>
<script>
const usernameEl = document.getElementById("github-username");
const statusEl = document.getElementById("github-status");
let paper = {
meta: {
pluginSettings: {
githubUsername: "",
},
},
};
function markLoaded() {
const existingMarker = document.getElementById("website-has-loaded");
if (existingMarker) {
return;
}
const loadedMarker = document.createElement("div");
loadedMarker.id = "website-has-loaded";
document.body.appendChild(loadedMarker);
}
function renderUsername() {
const username =
typeof paper.meta.pluginSettings?.githubUsername === "string"
? paper.meta.pluginSettings.githubUsername.trim()
: "";
usernameEl.textContent = username || "No username set";
statusEl.textContent = username
? "GitHub username"
: "Open settings to add a username";
markLoaded();
}
window.addEventListener("message", (event) => {
const message = event.data;
if (!message) {
return;
}
if (message.type === "INIT" || message.cmd === "message") {
paper = message.data;
renderUsername();
}
});
renderUsername();
</script>
</body>
</html>