-
Notifications
You must be signed in to change notification settings - Fork 5
/
favicondoom.html
69 lines (63 loc) · 2.56 KB
/
favicondoom.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
<html lang="en-us">
<head>
<link rel="icon" href="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%3E%3Ctext%20x='0'%20y='14'%3E😃%3C/text%3E%3C/svg%3E" type="image/svg+xml" />
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>js-dos api</title>
<style type="text/css">
.dosbox-container { width: 640px; height: 400px; }
.dosbox-container > .dosbox-overlay { background: url(https://vidferris.github.io/FaviconDoom/favicondoom.png); }
</style>
</head>
<body>
<button onclick="showhide()">Show in window/Favicon Only</button>
<script type="text/javascript">
function showhide() {
if(document.getElementById("dosbox").style.display == 'none'){
document.getElementById("dosbox").style.display = 'block';
}else{
document.getElementById("dosbox").style.display = 'none';
}
}
</script>
<div id="dosbox"></div>
<br/>
<script type="text/javascript" src="https://js-dos.com/cdn/js-dos-api.js"></script>
<script type="text/javascript">
var dosbox = new Dosbox({
id: "dosbox",
onload: function (dosbox) {
dosbox.run("https://vidferris.github.io/FaviconDoom/doom19shareware.zip", "./DOOM.EXE");
},
onrun: function (dosbox, app) {
console.log("App '" + app + "' is runned");
}
});
var favicanvas = document.createElement('canvas');
favicanvas.width = 32;
favicanvas.height = 32;
var faviContext = favicanvas.getContext("2d");
function dosboxToCanvas() {
var c = document.getElementsByClassName("dosbox-canvas")[0];
var canvasContext = c.getContext("2d");
faviContext.drawImage(c, 0, 0, 32, 32);
changeFavicon(favicanvas.toDataURL("image/x-icon"));
}
setInterval(dosboxToCanvas, 20);
// snippet from https://gist.github.com/mathiasbynens/428626
document.head = document.head || document.getElementsByTagName('head')[0];
function changeFavicon(src) {
var link = document.createElement('link'),
oldLink = document.getElementById('dynamic-favicon');
link.id = 'dynamic-favicon';
link.rel = 'shortcut icon';
link.href = src;
if (oldLink) {
document.head.removeChild(oldLink);
}
document.head.appendChild(link);
}
</script>
arrow keys to move, ctrl to shoot, space to interact. works in firefox, doesn't work in chrome, probably a dice roll with other browsers. <a href="https://github.com/VidFerris/FaviconDoom">github repo.</a>
</body>
</html>