-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
100 lines (90 loc) · 2.97 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
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Shadertoy To Flixel</title>
<style>
html {
background: url('https://www.shadertoy.com/img/themes/classic/background.jpg') no-repeat center center fixed;
background-size: cover;
height: 100%;
overflow: hidden;
}
.buttons {
width: 37.25%;
font-size:30px;
}
</style>
</head>
<body>
<div style="font-family:verdana;text-align:center;">
<h1>Shadertoy to Flixel
<a href="https://github.com/TheLeerName/ShadertoyToFlixel">
<img style="width:28px;height:28px;" src="assets/images/github-mark.png"/>
</a>
</h1>
<p>
<input id="coolinputfile" type="file" accept=".frag"/>
</p>
<textarea id="cooltextarea" style="font-size:12px;width:75%;height:50%;"></textarea>
<div>
<input id="coolbuttonstart" class="buttons" type="button" value="Start converting">
<input id="coolbuttondownload" class="buttons" type="button" value="Download">
</div>
<h3><a style="text-decoration: none;" href="https://i.imgur.com/LCGvaTd.png">How to use?</a></h3>
<h4>Do Ctrl+Shift+I and open Console tab to see logs!</h4>
</div>
</body>
<script type="text/javascript" src="assets/ShadertoyToFlixel.js"></script>
<script>
var cbs = document.getElementById('coolbuttonstart');
var cbd = document.getElementById('coolbuttondownload');
var cta = document.getElementById('cooltextarea');
var cif = document.getElementById('coolinputfile');
cta.placeholder = 'Paste shader content from shadertoy here...\nOr upload .frag file above';
console.log(`[TRACE] Good ${getdaypart()}, user! Paste shader content, click start converting and download the shader as always`)
cif.onchange = function() {
console.log("[TRACE] Getting data from " + this.files[0].name + "...")
var fr = new FileReader();
fr.onload = function() {
cta.value = fr.result;
}
fr.readAsText(this.files[0]);
}
cbs.onclick = function() {
cbs.setAttribute('disabled', '');
cbs.value = 'Successfully converted!';
cta.value = doThing(cta.value);
console.log("[TRACE] Successfully converted!")
setTimeout(() => {
cbs.removeAttribute('disabled');
cbs.value = 'Start converting';
}, 2000);
}
cbd.onclick = function() {
download(cta.value, 'shader.frag', 'text/plain')
console.log("[TRACE] Successfully saved as shader.frag!")
}
function getdaypart() {
var hours = new Date().getHours();
if (hours >= 18)
return 'evening';
else if (hours >= 6)
return 'morning';
else if (hours >= 11)
return 'day';
return 'night';
}
function download(content, filename, contentType) {
if(!contentType) contentType = 'application/octet-stream';
var url = window.URL.createObjectURL(new Blob([content], {'type':contentType}));
var a = document.createElement('a');
a.style.setProperty("display", "none");
document.body.appendChild(a);
a.href = url;
a.download = filename;
a.click();
window.URL.revokeObjectURL(url);
a.remove();
}
</script>
</html>