-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
86 lines (79 loc) · 2.38 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ruby.wasm quickstart</title>
<script src="browser.script.iife.js"></script>
<style>
body {
background: #212121;
font-size: 30px;
color: whitesmoke;
padding: 20px;
}
a, a:link, a:visited {
color: #FF0000;
}
.examples a, .examples a:link, .examples a:visited {
display: block;
color: #FF0000;
margin: 20px;
}
.spinner {
border: 4px solid rgba(0, 0, 0, 0.1);
width: 40px;
height: 40px;
border-radius: 50%;
border-left-color: #09f;
animation: spin 1s ease infinite;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
</style>
</head>
<body>
<h1>Ruby.wasm Quickstart</h1>
<div id="spinner" class="spinner"></div>
<script type="text/ruby" data-eval="async">
require 'kramdown'
$window = JS.global
$d = $window.document
$d.getElementById("spinner").style.display = "none"
$d.createElement("h2").tap {|e|
e.innerText = "Examples"
$d.body.appendChild(e)
}
examplesDiv = $d.createElement("div").tap {|div|
div.classList.add("examples")
$d.body.appendChild(div)
}
examples = %w(run-code shoppingList require canvas heartbeat kramdown)
examples.each do |example|
$d.createElement("a").tap {|link|
link.href = "#{example}.html"
link.innerText = example
examplesDiv.appendChild(link)
}
end
readmeUrl = "README.md"
response = JS.global.fetch(readmeUrl).await
if response.status.to_i == 200
readmeMarkdown = response.text.await.to_s
end
if readmeMarkdown
$d.createElement("div").tap {|e|
e.classList.add("explanation")
e.innerHTML = Kramdown::Document.new(readmeMarkdown).to_html
$d.body.appendChild(e)
}
end
</script>
</body>
</html>