forked from ItsNickBarry/hyperbolic-canvas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.html
50 lines (46 loc) · 1.63 KB
/
example.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
<!DOCTYPE html>
<html>
<head>
<title>Hyperbolic Canvas Example</title>
<meta charset="utf-8"/>
<link rel="stylesheet" type="text/css" href="css/example.css">
<link rel="icon" type="image/png" href="images/favicon.png">
</head>
<body>
<div id="hyperbolic-canvas"></div>
<script type="application/javascript" src="dist/hyperbolic_canvas.js"></script>
<script type="text/javascript">
var getQueryVariable = function (variable) {
// https://css-tricks.com/snippets/javascript/get-url-variables/
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if(pair[0] == variable){return pair[1];}
}
return(false);
};
var ready = function (fn) {
if (document.readyState != 'loading'){
fn();
} else {
document.addEventListener('DOMContentLoaded', fn);
}
};
ready(function () {
var scriptName = getQueryVariable('script');
var script = document.createElement('script');
script.onload = function () {
var canvas = HyperbolicCanvas.create('#hyperbolic-canvas', scriptName);
HyperbolicCanvas.scripts[scriptName](canvas);
};
script.onerror = function () {
var canvas = HyperbolicCanvas.create('#hyperbolic-canvas', scriptName);
alert('No script found with the name "' + scriptName + '".');
};
script.src = 'scripts/' + scriptName + '.js';
document.body.appendChild(script);
});
</script>
</body>
</html>