Delete cl.js
Browse files
cl.js
DELETED
@@ -1,261 +0,0 @@
|
|
1 |
-
(function() {
|
2 |
-
var s;
|
3 |
-
if (!document.querySelector('style.EVALDOTJSSTYLETHING')) {
|
4 |
-
s=document.createElement("style");
|
5 |
-
s.className="EVALDOTJSSTYLETHING";
|
6 |
-
s.innerHTML=`
|
7 |
-
evalcontainer {
|
8 |
-
display: block;
|
9 |
-
position: fixed;
|
10 |
-
width: 500px;
|
11 |
-
height: 350px;
|
12 |
-
background: rgba(0,0,0,0.8);
|
13 |
-
top: 0;
|
14 |
-
left: 0;
|
15 |
-
right: 0;
|
16 |
-
margin: 50px auto;
|
17 |
-
font-size: 0;
|
18 |
-
z-index: 100000;
|
19 |
-
cursor: move; /* ドラッグカーソルを追加 */
|
20 |
-
}
|
21 |
-
evalcontainer > textarea.EVALTEXTAREA {
|
22 |
-
width: 500px;
|
23 |
-
border: none;
|
24 |
-
box-sizing: border-box;
|
25 |
-
font-family: monospace;
|
26 |
-
font-size: 12px;
|
27 |
-
height: 200px;
|
28 |
-
padding: 5px;
|
29 |
-
resize: none;
|
30 |
-
position: absolute;
|
31 |
-
bottom: 0;
|
32 |
-
background: rgba(0,0,0,0.8);
|
33 |
-
color: white;
|
34 |
-
}
|
35 |
-
evalcontainer > evaloutput {
|
36 |
-
display: block;
|
37 |
-
width: 500px;
|
38 |
-
max-height: 150px;
|
39 |
-
font-size: 12px;
|
40 |
-
font-family: monospace;
|
41 |
-
overflow-y: auto;
|
42 |
-
color: white;
|
43 |
-
box-sizing: border-box;
|
44 |
-
padding: 5px;
|
45 |
-
position: absolute;
|
46 |
-
bottom: 200px;
|
47 |
-
}
|
48 |
-
evalcontainer > evaloutput > evaloutputentry {
|
49 |
-
display: block;
|
50 |
-
white-space: pre;
|
51 |
-
}
|
52 |
-
evalcontainer > evaloutput > evaloutputentry::before {
|
53 |
-
content: ">\\00a0";
|
54 |
-
color: rgba(255,255,255,0.5);
|
55 |
-
}
|
56 |
-
evalcontainer > evaloutput > evaloutputentry.EVALRESULT {
|
57 |
-
border-bottom: 1px solid rgba(255,255,255,0.1);
|
58 |
-
}
|
59 |
-
evalcontainer > evaloutput > evaloutputentry.EVALRESULT::before {
|
60 |
-
content: "<\\00a0";
|
61 |
-
font-style: normal;
|
62 |
-
}
|
63 |
-
evalcontainer > evaloutput > evaloutputentry.EVALWARN {
|
64 |
-
background: #FFEB3B;
|
65 |
-
color: black;
|
66 |
-
}
|
67 |
-
evalcontainer > evaloutput > evaloutputentry.EVALSTRING {
|
68 |
-
color: #FFEB3B;
|
69 |
-
}
|
70 |
-
evalcontainer > evaloutput > evaloutputentry.EVALNUMBER {
|
71 |
-
color: #2196F3;
|
72 |
-
}
|
73 |
-
evalcontainer > evaloutput > evaloutputentry.EVALFUNCTION {
|
74 |
-
font-style: italic;
|
75 |
-
}
|
76 |
-
evalcontainer > evaloutput > evaloutputentry.EVALUNDEFINED {
|
77 |
-
color: #9E9E9E;
|
78 |
-
}
|
79 |
-
evalcontainer > evaloutput > evaloutputentry.EVALERROR {
|
80 |
-
background: #f44336;
|
81 |
-
}
|
82 |
-
evalcontainer > evaloutput > evaloutputentry.EVALWARN.EVALSTRING {
|
83 |
-
color: black;
|
84 |
-
}
|
85 |
-
.close-button {
|
86 |
-
position: absolute;
|
87 |
-
top: 5px;
|
88 |
-
right: 5px;
|
89 |
-
background: rgba(255, 0, 0, 0.8);
|
90 |
-
color: white;
|
91 |
-
border: none;
|
92 |
-
padding: 5px;
|
93 |
-
cursor: pointer;
|
94 |
-
}
|
95 |
-
`;
|
96 |
-
document.head.appendChild(s);
|
97 |
-
}
|
98 |
-
if (!document.querySelector('evalcontainer')) {
|
99 |
-
s=document.createElement("evalcontainer");
|
100 |
-
s.setAttribute("draggable", "true"); // draggable属性を追加
|
101 |
-
|
102 |
-
// 右上の「×」ボタンを追加
|
103 |
-
var closeButton = document.createElement("button");
|
104 |
-
closeButton.className = "close-button";
|
105 |
-
closeButton.innerText = "×";
|
106 |
-
closeButton.onclick = function() {
|
107 |
-
evaljs.close();
|
108 |
-
};
|
109 |
-
s.appendChild(closeButton);
|
110 |
-
|
111 |
-
var output=document.createElement("evaloutput");
|
112 |
-
function createOutputEntry(words) {
|
113 |
-
var t=document.createElement("evaloutputentry");
|
114 |
-
t.innerHTML=words;
|
115 |
-
t.className='EVALLOG';
|
116 |
-
output.appendChild(t);
|
117 |
-
}
|
118 |
-
createOutputEntry('To close this window, do evaljs.close();');
|
119 |
-
createOutputEntry('To clear, do evaljs.clear();');
|
120 |
-
s.appendChild(output);
|
121 |
-
|
122 |
-
var textarea=document.createElement("textarea");
|
123 |
-
textarea.className='EVALTEXTAREA';
|
124 |
-
textarea.focus();
|
125 |
-
textarea.onkeypress=e=>{
|
126 |
-
if (e.keyCode===13&&!e.shiftKey) {
|
127 |
-
var t=document.createElement("evaloutputentry"),
|
128 |
-
evaloutput;
|
129 |
-
t.textContent=textarea.value;
|
130 |
-
output.appendChild(t);
|
131 |
-
t=document.createElement("evaloutputentry");
|
132 |
-
t.classList.add('EVALRESULT');
|
133 |
-
try {
|
134 |
-
evaloutput=eval(textarea.value);
|
135 |
-
switch (typeof evaloutput) {
|
136 |
-
case 'object':
|
137 |
-
evaloutput=JSON.stringify(evaloutput);
|
138 |
-
t.classList.add('EVALFUNCTION');
|
139 |
-
break;
|
140 |
-
case 'string':
|
141 |
-
evaloutput=`"${evaloutput}"`;
|
142 |
-
t.classList.add('EVALSTRING');
|
143 |
-
break;
|
144 |
-
case 'number':
|
145 |
-
case 'boolean':
|
146 |
-
t.classList.add('EVALNUMBER');
|
147 |
-
break;
|
148 |
-
case 'function':
|
149 |
-
evaloutput=evaloutput.toString();
|
150 |
-
t.classList.add('EVALFUNCTION');
|
151 |
-
break;
|
152 |
-
case 'undefined':
|
153 |
-
t.classList.add('EVALUNDEFINED');
|
154 |
-
break;
|
155 |
-
case 'symbol':
|
156 |
-
evaloutput=evaloutput.toString();
|
157 |
-
t.classList.add('EVALSTRING');
|
158 |
-
break;
|
159 |
-
}
|
160 |
-
} catch(e) {
|
161 |
-
evaloutput=e;
|
162 |
-
t.classList.add('EVALERROR');
|
163 |
-
}
|
164 |
-
t.textContent=evaloutput+'';
|
165 |
-
output.appendChild(t);
|
166 |
-
output.scrollTop=output.scrollHeight;
|
167 |
-
textarea.value='';
|
168 |
-
e.preventDefault();
|
169 |
-
return false;
|
170 |
-
}
|
171 |
-
};
|
172 |
-
s.appendChild(textarea);
|
173 |
-
document.body.appendChild(s);
|
174 |
-
evaljs={
|
175 |
-
window:s,
|
176 |
-
clear() {
|
177 |
-
while (output.hasChildNodes()) output.removeChild(output.lastChild);
|
178 |
-
},
|
179 |
-
close() {
|
180 |
-
document.body.removeChild(this.window);
|
181 |
-
}
|
182 |
-
};
|
183 |
-
|
184 |
-
// ドラッグ機能を実装
|
185 |
-
let offsetX, offsetY;
|
186 |
-
|
187 |
-
s.ondragstart = function(e) {
|
188 |
-
offsetX = e.clientX - s.getBoundingClientRect().left;
|
189 |
-
offsetY = e.clientY - s.getBoundingClientRect().top;
|
190 |
-
e.dataTransfer.setData('text/plain', null); // Firefox用にデータをセット
|
191 |
-
};
|
192 |
-
|
193 |
-
document.ondragover = function(e) {
|
194 |
-
e.preventDefault(); // ドロップを許可
|
195 |
-
};
|
196 |
-
|
197 |
-
document.ondrop = function(e) {
|
198 |
-
e.preventDefault();
|
199 |
-
s.style.left = (e.clientX - offsetX) + 'px';
|
200 |
-
s.style.top = (e.clientY - offsetY) + 'px';
|
201 |
-
};
|
202 |
-
|
203 |
-
function merp(u,t) {
|
204 |
-
switch (typeof u) {
|
205 |
-
case 'object':
|
206 |
-
u=JSON.stringify(u);
|
207 |
-
t.classList.add('EVALFUNCTION');
|
208 |
-
break;
|
209 |
-
case 'string':
|
210 |
-
u=`"${u}"`;
|
211 |
-
t.classList.add('EVALSTRING');
|
212 |
-
break;
|
213 |
-
case 'number':
|
214 |
-
case 'boolean':
|
215 |
-
t.classList.add('EVALNUMBER');
|
216 |
-
break;
|
217 |
-
case 'function':
|
218 |
-
u=u.toString();
|
219 |
-
t.classList.add('EVALFUNCTION');
|
220 |
-
break;
|
221 |
-
case 'undefined':
|
222 |
-
t.classList.add('EVALUNDEFINED');
|
223 |
-
break;
|
224 |
-
case 'symbol':
|
225 |
-
u=u.toString();
|
226 |
-
t.classList.add('EVALSTRING');
|
227 |
-
break;
|
228 |
-
}
|
229 |
-
return u;
|
230 |
-
}
|
231 |
-
console.log=function(){
|
232 |
-
for (var i=0;i<arguments.length;i++) {
|
233 |
-
var t=document.createElement("evaloutputentry"),u=arguments[i];
|
234 |
-
t.classList.add('EVALLOG');
|
235 |
-
u=merp(u,t);
|
236 |
-
t.textContent=(u+'').replace(/\s/g,'\\u00a0');
|
237 |
-
output.appendChild(t);
|
238 |
-
}
|
239 |
-
};
|
240 |
-
console.warn=function(){
|
241 |
-
for (var i=0;i<arguments.length;i++) {
|
242 |
-
var t=document.createElement("evaloutputentry"),u=arguments[i];
|
243 |
-
t.classList.add('EVALLOG');
|
244 |
-
t.classList.add('EVALWARN');
|
245 |
-
u=merp(u,t);
|
246 |
-
t.textContent=(u+'').replace(/\s/g,'\\u00a0');
|
247 |
-
output.appendChild(t);
|
248 |
-
}
|
249 |
-
};
|
250 |
-
console.error=function(){
|
251 |
-
for (var i=0;i<arguments.length;i++) {
|
252 |
-
var t=document.createElement("evaloutputentry"),u=arguments[i];
|
253 |
-
t.classList.add('EVALLOG');
|
254 |
-
t.classList.add('EVALERROR');
|
255 |
-
u=merp(u,t);
|
256 |
-
t.textContent=(u+'').replace(/\s/g,'\\u00a0');
|
257 |
-
output.appendChild(t);
|
258 |
-
}
|
259 |
-
};
|
260 |
-
}
|
261 |
-
}());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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