-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
184 lines (184 loc) · 9.59 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
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<meta content="ie=edge" http-equiv="X-UA-Compatible">
<meta content="a0b07b3cc690645dbabf" name="gc:client-id">
<meta content="a4a40aa396ad8bddc1b1796f9bf452ea71d8f32f" name="gc:client-secret">
<title>AIwaffle</title>
<link href="/assets/favicon.ico" rel="shortcut icon">
<link href="https://fonts.googleapis.com/css?family=Nunito:400,700&display=swap" rel="stylesheet">
<link as="style" defer href="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.css" onload="this.onload=null;this.rel='stylesheet'" rel="preload">
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.js"></script>
<script defer src="https://cdn.jsdelivr.net/npm/markdown-it@10.0.0/dist/markdown-it.min.js"></script>
<link as="style" defer href="https://cdn.jsdelivr.net/npm/markdown-it-texmath@0.6.0/css/texmath.min.css" onload="this.onload=null;this.rel='stylesheet'" rel="preload">
<script defer src="https://cdn.jsdelivr.net/npm/markdown-it-texmath@0.6.0/texmath.min.js"></script>
<link as="style" defer href="https://cdn.jsdelivr.net/npm/highlightjs@9.16.2/styles/solarized-light.css" onload="this.onload=null;this.rel='stylesheet'" rel="preload">
<script defer onload="hljs.initHighlightingOnLoad" src="/dist/highlight.js"></script>
<!-- loadCSS asynchronously: https://github.com/filamentgroup/loadCSS/blob/master/src/cssrelpreload.js -->
<script>
!function(t){"use strict";t.loadCSS||(t.loadCSS=function(){});var e=loadCSS.relpreload={};if(e.support=function(){var e;try{e=t.document.createElement("link").relList.supports("preload")}catch(t){e=!1}return function(){return e}}(),e.bindMediaToggle=function(t){var e=t.media||"all";function a(){t.addEventListener?t.removeEventListener("load",a):t.attachEvent&&t.detachEvent("onload",a),t.setAttribute("onload",null),t.media=e}t.addEventListener?t.addEventListener("load",a):t.attachEvent&&t.attachEvent("onload",a),setTimeout(function(){t.rel="stylesheet",t.media="only x"}),setTimeout(a,3e3)},e.poly=function(){if(!e.support())for(var a=t.document.getElementsByTagName("link"),n=0;n<a.length;n++){var o=a[n];"preload"!==o.rel||"style"!==o.getAttribute("as")||o.getAttribute("data-loadcss")||(o.setAttribute("data-loadcss",!0),e.bindMediaToggle(o))}},!e.support()){e.poly();var a=t.setInterval(e.poly,500);t.addEventListener?t.addEventListener("load",function(){e.poly(),t.clearInterval(a)}):t.attachEvent&&t.attachEvent("onload",function(){e.poly(),t.clearInterval(a)})}"undefined"!=typeof exports?exports.loadCSS=loadCSS:t.loadCSS=loadCSS}("undefined"!=typeof global?global:this);
</script>
<!-- These scripts link to the Vega/Vega-Lite runtime -->
<script defer src="https://cdn.jsdelivr.net/npm/vega@5"></script>
<script defer src="https://cdn.jsdelivr.net/npm/vega-lite@4"></script>
<script defer src="https://cdn.jsdelivr.net/npm/vega-embed@6"></script>
<style>
img {
width: 100%;
}
.inline-logo img {
width: 1.2em;
margin-right: .5em;
}
p {
line-height: 1.2em;
}
html {
--scrollbarBG: white;
--thumbBG: rgba(204,204,204,1);
}
.content {
white-space: pre-wrap;
font-size: 0.8em;
padding-right: 0.8em;
margin: auto;
}
@media (min-width: 860px) {
.content-scroll::-webkit-scrollbar {
width: 15px;
}
.content-scroll {
scrollbar-color: var(--thumbBG) var(--scrollbarBG);
max-height: calc(100vh - 20px);
overflow-x: auto;
overflow-y: scroll;
}
.content-scroll::-webkit-scrollbar-track {
background: var(--scrollbarBG);
}
.content-scroll::-webkit-scrollbar-thumb {
background-color: var(--thumbBG) ;
border-radius: 6px;
border: 3px solid var(--scrollbarBG);
}
}
/* style github cards */
iframe[id^="ghcard"] {
margin: auto;
margin-top: 10px;
margin-bottom: 10px;
}
</style>
<script defer src="/dist/main.js"></script>
</head>
<body>
<div id="app"></div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const username = sessionStorage.getItem('aiwaffle-username');
console.log("username: ", username);
var app = Elm.Main.init({
node: document.getElementById("app"),
flags: username
});
window.addEventListener('beforeunload', function() {
app.ports.getUsername.send(null);
});
app.ports.setUsername.subscribe(function(username) {
console.log("setting username");
if (username === "") {
sessionStorage.removeItem('aiwaffle-username');
} else {
sessionStorage.setItem('aiwaffle-username', username);
}
});
const md_content_ids =
[ "intro-to-machine-learning"
, "intro-to-deep-learning"
, "intro-to-logistic-regression"
];
app.ports.renderContent.subscribe(
function(contentId) {
const contentNode = document.getElementsByClassName("content")[0];
if (!md_content_ids.includes(contentId)) {
contentNode.style.width = "100%";
contentNode.style.maxWidth = "100%";
contentNode.style.height = "80vh";
contentNode.innerHTML = `\<iframe src="https://nbviewer.jupyter.org/github/AIwaffle/AIwaffle/blob/master/Courses/${contentId}.ipynb" style="width: 100%; height: 100%"\>\</iframe\>`;
} else {
contentNode.style.width = "100%";
contentNode.style.maxWidth = "700px";
contentNode.style.height = "100%";
fetch('/dist/contents/' + contentId + '.md')
.then(response => response.text())
.then((contentText) => {
const tm = texmath.use(katex);
const md = window.markdownit({
highlight: function (str, lang) {
if (lang && hljs.getLanguage(lang)) {
try {
return hljs.highlight(lang, str).value;
} catch (__) {}
}
return '';
}
}).use(tm,{delimiters:'dollars'});
contentNode.innerHTML = md.render(contentText);
})
}
}
);
app.ports.resetContent.subscribe(
function() {
const contentNode = document.getElementsByClassName("content")[0];
if (contentNode !== undefined) {
while (contentNode.firstChild) {
contentNode.removeChild(contentNode.firstChild);
}
contentNode.style.width = "100%";
contentNode.style.height = "100%";
}
}
);
// This function grabs the specification from Elm (here called specs).
app.ports.elmToJs.subscribe(
function(namedSpecs) {
console.log(namedSpecs)
for (let name of Object.keys(namedSpecs)) {
vegaEmbed(`#${name}`, namedSpecs[name], {
actions: false,
logLevel: vega.Warn
}).catch(console.warn);
}
}
);
app.ports.scrollToTop.subscribe(
function() {
window.scrollTo(0, 0);
}
)
app.ports.renderGithubCards.subscribe(function() {
function waitForElementToDisplay(selector, time) {
if(document.querySelector(selector)!=null) {
console.log("renderGithubCards...");
(function(m){function g(b,c){return b.getAttribute("data-"+c)}function D(b){window.addEventListener&&window.addEventListener("message",function(c){b.id===c.data.sender&&(b.height=c.data.height)},!1)}function q(b,c){c=c||r;if(!c){var h=g(b,"theme")||t||"default";c=u+"cards/"+h+".html"}var e=g(b,"user");h=g(b,"repo");var k=g(b,"github");k&&(k=k.split("/"),k.length&&!e&&(e=k[0],h=h||k[1]));if(e){v+=1;k=g(b,"width");var w=g(b,"height"),x=g(b,"target"),z=g(b,"client-id")||y,B=g(b,"client-secret")||A,C=
"ghcard-"+e+"-"+v,f=m.createElement("iframe");f.setAttribute("id",C);f.setAttribute("frameborder",0);f.setAttribute("scrolling",0);f.setAttribute("allowtransparency",!0);e=c+"?user="+e+"&identity="+C;h&&(e+="&repo="+h);x&&(e+="&target="+x);z&&B&&(e+="&client_id="+z+"&client_secret="+B);f.src=e;f.width=k||Math.min(b.parentNode.clientWidth||400,400);w&&(f.height=w);D(f);b.parentNode.replaceChild(f,b);return f}}var u="//lab.lepture.com/github-cards/",d,v=0,l=m.getElementsByTagName("meta"),r,y,A,t;for(d=
0;d<l.length;d++){var n=l[d].getAttribute("name"),p=l[d].getAttribute("content");"gc:url"===n?r=p:"gc:base"===n?u=p:"gc:client-id"===n?y=p:"gc:client-secret"===n?A=p:"gc:theme"===n&&(t=p)}l=function(b){if(m.querySelectorAll)return m.querySelectorAll("."+b);var c=m.getElementsByTagName("div"),h=[];for(d=0;d<c.length;d++)~c[d].className.split(" ").indexOf(b)&&h.push(c[d]);return h}("github-card");for(d=0;d<l.length;d++)q(l[d]);window.a&&(window.a.b=q)})(document);
return;
}
else {
setTimeout(function() {
waitForElementToDisplay(selector, time);
}, time);
}
}
waitForElementToDisplay(".github-card", 100);
});
});
</script>
</body>
</html
</body>
</html>>