-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
155 lines (130 loc) · 3.63 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Doc Scratch Reaction GIF Generator</title>
<script src="lib/jquery.js"></script>
<script src="lib/gif.js/gif.js"></script>
<script src="scratch.js"></script>
<style>
body {
text-align: center;
background: #EEE;
color: black;
}
@font-face {
font-family: fontstuck;
src: url('font/FontStuck-Extended.ttf');
/* TODO: other formats like woff for Firefox etc. */
}
* {
font-family: fontstuck;
}
#inputs>* {
font-size: 30px;
}
#log {
text-align: start;
}
#log * {
vertical-align: middle;
}
img {
margin: 15px;
}
.save {
padding: 3px;
margin: 10px;
}
.save.recording {
opacity: 0.5;
cursor: wait;
background: rgba(255, 0, 0, 0.3);
}
.save.rendering {
opacity: 0.5;
cursor: progress;
background: yellow;
}
.save.done {
background: lime;
}
</style>
<script>
$(function () {
function react(text) {
var $div = $("<div>").appendTo("#log");
// TODO: progress bar instead of just colored icon button with hover text
// Note: alt='' not alt='save' because the info is provided via title on the link
var $toGIF = $("<a class='save recording'><img src='img/save.png' width=16 height=16 alt=''/></a>").appendTo($div);
var $reaction = $DocScratchReaction(text).appendTo($div);
var gif = new GIF({
workerScript: "lib/gif.js/gif.worker.js",
workers: 2,
quality: 10,
background: "#EEE"
});
var f = 0;
var title = "Save as animated GIF";
$reaction.on("frame", function (e, canvas, interval) {
gif.addFrame(canvas, { delay: interval, copy: true });
$toGIF.attr("title", title + " (Recording frames: " + (++f) + "/100)");
});
$reaction.on("animation-complete", function (e) {
$toGIF.removeClass("recording");
gif.on("finished", function (blob) {
$toGIF.removeClass("rendering");
$toGIF.addClass("done");
$toGIF.attr("href", URL.createObjectURL(blob));
$toGIF.attr("download", text.toUpperCase()
.replace(/[\W_]/g, "-")
.replace(/-+/g, "-")
.replace(/(^-+)|(-+$)/g, "")
+ ".GIF"
);
$toGIF.attr("title", title);
});
gif.on("progress", function (p) {
$toGIF.attr("title", title + " (Rendering GIF: " + (~~(p * 100)) + "%)");
});
// TODO: accept mouseover earlier and maybe click as well.. really just change it entirely
$toGIF.one("mouseover", function () {
gif.render();
$toGIF.addClass("rendering")
});
});
}
react("She has what?");
function go() {
if ($("input").val()) {
react($("input").val());
$("input").val("");
}
}
$("input").on("keydown", function (e) {
if (e.keyCode === 13) go();
});
$("#pester").on("click", go);
});
</script>
</head>
<body>
<h1>
<span style="color:#2ed73a">D<span style="color:#e0e0e0">o</span>c Scratch</span> Reaction GIF Generator
</h1>
<div id="log"></div>
<div id="inputs">
<input autofocus type="text" />
<button id="pester">PESTER!!!!!!!</button>
</div>
<img src="img/scratch.gif" width="650" height="450" alt="Lightning eminates from Doc Scratch because he's all angry" />
<p style="color:white">SECRET TEXT omg...</p>
<p style="color:transparent">SECRETER TEXT OMGOMG.....</p>
<p style="color:transparent;opacity:0">MEGA s3CR3t TEXT OMGOMG......</p>
<p style="display:none">ULTRA SECRET TEXT OMGOMGOMG...</p>
<!-- ULTIMATE SECRET TEXT OMGWTFBBQ -->
<footer>
<p>Source code <a href="https://github.com/1j01/she-has-what?">on GitHub</a>, MIT licensed. --<a href="https://1j01.github.io/">io</a></p>
</footer>
</body>
</html>