-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
223 lines (197 loc) · 10.2 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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
<html>
<head>
<title>RunJavaScriptOnKeyPress</title>
<link rel="shortcut icon" href="30968.png" type="image/png">
<link rel="stylesheet" href="index.css">
</head>
<body>
<script src="index.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<div id="externalJScustom" style="width: 100%; height: 100%; background-color: rgba(70, 70, 70, 0.384); position: fixed; z-index: 3; display: none;">
<div style="position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);">
<p style="text-align: center; font-size: 2vw;">Enter link to js file</p>
<input style="outline: none;" type="text" name="externalJScustomLink" id="externalJScustomLink" value="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js">
<button onclick="externalJScustomLink();">Add external js file</button>
<button onclick="externalJScustomLinkClose();">Cancel</button>
</div>
</div>
<div style="width: 100%; text-align: center;">
<h1>RunJavaScriptOnKeyPress<img src="30968.png" alt="" height="37px"></h1>
</div>
<div style="border: solid; width: 100%; text-align: center;">
<h2>Put your JS here</h2>
<div style="text-align: left; padding: 8px;">
<div style="text-align: left; background-color: lightgray;">
<button id="addButton">+</button>
</div>
<div id="div1" style="border: solid; text-align: left;">
<p id='keyCodeu1' contenteditable='true' onclick='changeDiv(1)' style='outline: none'>alert('hello world');</p>
</div>
<br>
</div>
<h2>Input key you want to trigger JS (matched up with the number above)</h2>
<div style="text-align: left; padding: 8px;">
<div style="text-align: left; background-color: lightgray;">
<button id="addButton1">+</button>
</div>
<div id="divl1" style="border: solid; text-align: left;">
<input type="text" size="20" maxlength="1" style="width: 100%;" onclick='changeDivl(1)' onkeypress="keyCode(event);">
</div>
<br>
</div>
<div onselectstart="return false" ondragstart="return false" id="externalJS" style="width: fit-content; border: solid; margin: 8px; padding: 3px;">
<p style="cursor: default;">Add external JavaScript</p>
<div id="externalJS2" style="border-top: solid; width: 100%; transform-origin: top;">
<p onclick="externalJSq(1)">jQuery</p>
<p onclick="externalJSq(2)">Howler.js</p>
<p onclick="externalJSq(3)">Enter-Full-Screen.js</p>
<p onclick="externalJScustom()">Custom</p>
<p onclick="externalJSq(4)">Remove</p>
</div>
</div>
<br>
<div style="text-align: left; margin: 8px;"><button onclick="keyCodel();">Generate JS</button></div>
<!--xmp-->
<div id="outputJS1" style="text-align: left;">
<pre id="p1"><span id="externalJSl"></span>
<script>
window.onkeypress = function(event) {
if (event.keyCode == <span id="keyCode1"></span>) {
<span id="keyCodel1"></span>
}
}
</pre>
</div>
<div style="text-align: left;">
<span id="outputJSB" style="font-family: monospace;"></script></span>
</div>
<br>
<footer>
<p>The CSS was partially generated with <b><a target="_blank" style="color: #008a96;" href="https://nighteye.app/dark-css-generator/">Night Eye<img src="logo-512x512.webp" alt="Night Eye logo" height="17px"></a></b></p>
</footer>
</div>
<script>
var i = 1;
var u = 1;
var t = 1;
$("#addButton").click(function() {
$("#addButton").before("<button id='button" + i + "' onclick='changeDiv(" + i + ");btnColor(e)'>" + i + "</button>");
$("#div1").after("<div id='div" + i + "' style='border: solid; text-align: left; display: none;'><p id='keyCodeu" + i + "' contenteditable='true' onclick='changeDiv(" + i + ")' style='outline: none'>alert('hello world');</p></div>");
$("#outputJSB").before(`
<div id="outputJS` + i + `" style="text-align: left;">
<pre id="p1"><span id="externalJSl"></span>
window.onkeypress = function(event) {
if (event.keyCode == <span id="keyCode` + i + `"></span>) {
<span id="keyCodel` + i + `"></span>
}
}</pre></div>`);
i++;
$("#addButton1").before("<button id='buttonl" + u + "' onclick='changeDivl(" + u + ")'>" + u + "</button>");
$("#divl1").after("<div id='divl" + u + "' style='border: solid; text-align: left; display: none;'><input type='text' size='20' maxlength='1' style='width: 100%;' onclick='changeDivl(" + u + ")' onkeypress='keyCode(event)'></div>");
u++;
});
function removeBtn() {
if (i > 2) {
i--;
u--;
document.getElementById("button" + i).remove();
document.getElementById("div" + i).remove();
document.getElementById("buttonl" + u).remove();
document.getElementById("divl" + u).remove();
document.getElementById("outputJS" + i).remove();
}
}
$(document).ready(function() {
$("#addButton").before("<button class='curent' id='button" + i + "' onclick='changeDiv(" + i + ")'>" + i + "</button>");
$("#addButton").after("<button id='removeButton' onclick='removeBtn();'>x</button>")
i++;
$("#addButton1").before("<button class='curent' id='buttonl" + u + "' onclick='changeDivl(" + u + ")'>" + u + "</button>");
$("#addButton1").after("<button id='removeButton' onclick='removeBtn();'>x</button>")
u++;
});
function changeDiv(z) {
p = 1;
t = z;
var dev = document.getElementById("div" + z);
do {
document.getElementById("div" + p).style.display = "none";
document.getElementById("button" + p).classList.remove('curent');
p++
dev.style.display = "block";
document.getElementById("button" + z).classList.add('curent');
}
while (p <= i);
}
$("#addButton1").click(function() {
$("#addButton1").before("<button id='buttonl" + u + "' onclick='changeDivl(" + u + ")'>" + u + "</button>");
$("#divl1").after("<div id='divl" + u + "' style='border: solid; text-align: left; display: none;'><input type='text' size='20' maxlength='1' style='width: 100%;' onclick='changeDivl(" + u + ")' onkeypress='keyCode(event)'></div>");
u++;
$("#addButton").before("<button id='button" + i + "' onclick='changeDiv(" + i + ");btnColor(e)'>" + i + "</button>");
$("#div1").after("<div id='div" + i + "' style='border: solid; text-align: left; display: none;'><p id='keyCodeu" + i + "' contenteditable='true' onclick='changeDiv(" + i + ")' style='outline: none'>alert('hello world');</p></div>");
$("#outputJSB").before(`
<div id="outputJS` + i + `" style="text-align: left;">
<pre id="p1"><span id="externalJSl"></span>
window.onkeypress = function(event) {
if (event.keyCode == <span id="keyCode` + i + `"></span>) {
<span id="keyCodel` + i + `"></span>
}
}</pre></div>`);
i++;
});
function btnColor(e) {
e.classList.add('curent');
}
function changeDivl(z) {
p = 1;
t = z;
var dev = document.getElementById("divl" + z);
do {
document.getElementById("divl" + p).style.display = "none";
document.getElementById("buttonl" + p).classList.remove('curent');
p++
dev.style.display = "block";
document.getElementById("buttonl" + z).classList.add('curent');
}
while (p <= u);
}
function externalJSq(e) {
if (e == 1) {
document.getElementById("externalJSl").innerHTML = '<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>';
} else if (e == 2) {
document.getElementById("externalJSl").innerHTML = '<script src="https://cdnjs.cloudflare.com/ajax/libs/howler/2.1.2/howler.js"></script>';
} else if (e == 3) {
document.getElementById("externalJSl").innerHTML = '<script src="https://soaringgecko.github.io/Enter-Full-Screen.js/enter-full-screen.js"></script>';
} else if (e == 4) {
document.getElementById("externalJSl").innerHTML = '';
}
}
function externalJScustom() {
document.getElementById('externalJScustom').style.display = "block";
document.documentElement.style.backgroundColor = "rgb(46 46 46)";
}
function externalJScustomLink() {
var m = document.getElementById('externalJScustomLink').value;
document.getElementById("externalJSl").innerHTML = '<script src="' + m + '"></script>';
document.getElementById('externalJScustom').style.display = "none";
document.documentElement.style.backgroundColor = "rgb(31, 31, 31)";
}
function externalJScustomLinkClose() {
document.getElementById('externalJScustom').style.display = "none";
document.documentElement.style.backgroundColor = "rgb(31, 31, 31)";
}
function keyCode(event) {
var x = event.which || event.keyCode;
document.getElementById("keyCode" + t).innerHTML = x;
}
function keyCodel() {
p = 1;
do {
var x = document.getElementById("keyCodeu" + p).innerHTML;
document.getElementById("keyCodel" + p).innerHTML = x;
p++
}
while (p <= u);
}
</script>
</body>
</html>