-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhyperlinkeditor.html
363 lines (301 loc) · 10.3 KB
/
hyperlinkeditor.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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<!--
HYPERLINK
All Code and ideas CC0 Public Domain
-->
<link href="data:image/x-icon;base64,AAABAAEAEBAQAAEABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAA/wAAAAD//wAA/wAAAAD/AP8A/wAApv8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFUAAARGAAIxFVUABEYAAjMRFQAARGYiIjMRAABERmZiIzEAAARERGZiMwAAAARERGYiAAAAAABERiL4PwAA+78AAPu/AAD33wAA9V8AAPVfAAD1XwAA998AAOADAADhAAAA4AAAAPAAAADwAAAA+AAAAP4AAAD/wAAA" rel="icon" type="image/x-icon" />
<title>TRASH MAGIC MEDIA</title>
<!--Stop Google:-->
<META NAME="robots" CONTENT="noindex,nofollow">
<script src = "https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js"></script>
<script src = "jscode/hyperlink.js"></script>
</head>
<body>
<h1><a href = "index.html">HOME</a></h1>
<img id = "mainimage"/>
<div id = "qrcode"></div>
<h3><a id= "serverlink"></a></h3>
<table>
<tr>
<td>Server URL(http://[your ip address]/):</td>
<td><input id = "serverurlinput"/></td>
</tr>
<tr>
<td>image URL:</td>
<td><input id = "srcinput"/></td>
</tr>
<tr>
<td>image alt text:</td>
<td><input id = "altinput"/></td>
</tr>
</table>
<table id = "linktable"></table>
<ul id = "linklist">
</ul>
<div id ="importbutton" class = "button">IMPORT</div>
<textarea id = "textio"></textarea>
<script>
codesquaresize = 200;
document.getElementById("qrcode").style.width = codesquaresize.toString() + "px";
qrcode = new QRCode(document.getElementById("qrcode"), {
text: hyperlink.url,
width: codesquaresize,
height: codesquaresize,
colorDark : "#000000",
colorLight : "#ffffff",
correctLevel : QRCode.CorrectLevel.H
});
loadserver();
loadimage();
document.getElementById("serverurlinput").onchange = function(){
hyperlink.url = this.value;
loadserver();
savejson();
}
document.getElementById("srcinput").onchange = function(){
hyperlink.src = this.value;
loadimage();
savejson()
}
document.getElementById("altinput").onchange = function(){
hyperlink.alt = this.value;
loadimage();
savejson()
}
function loadserver(){
document.getElementById("serverlink").href = hyperlink.url;
document.getElementById("serverlink").innerHTML = hyperlink.url;
document.getElementById("serverurlinput").value = hyperlink.url;
qrcode.makeCode(hyperlink.url);
}
function loadimage(){
document.getElementById("mainimage").src = hyperlink.src;
document.getElementById("srcinput").value = hyperlink.src;
document.getElementById("altinput").value = hyperlink.alt;
document.getElementById("mainimage").alt = hyperlink.alt;
}
loadlinks();
function loadlinks(){
document.getElementById("linklist").innerHTML = "";
for(var index = 0;index < hyperlink.list.length;index++){
var newli = document.createElement("LI");
document.getElementById("linklist").appendChild(newli);
var newa = document.createElement("A");
newli.appendChild(newa);
newa.href = hyperlink.list[index].href;
newa.innerHTML = hyperlink.list[index].text;
var newbutt = document.createElement("SPAN");
newbutt.className = "button";
newbutt.innerHTML = "UP";
newbutt.id = "up" + index.toString();
newli.appendChild(newbutt);
newbutt.onclick = function(){
var localindex = parseInt(this.id.substring(2));
if(localindex != 0){
var temparray = [];
for(var tempindex = 0;tempindex < localindex - 1;tempindex++){
temparray.push(hyperlink.list[tempindex]);
}
temparray.push(hyperlink.list[localindex]);
temparray.push(hyperlink.list[localindex - 1]);
for(var tempindex = localindex + 1;tempindex < hyperlink.list.length;tempindex++){
temparray.push(hyperlink.list[tempindex]);
}
hyperlink.list = temparray;
savejson();
loadlinks();
}
else{
var temparray = [];
for(var tempindex = 1;tempindex < hyperlink.list.length;tempindex++){
temparray.push(hyperlink.list[tempindex]);
}
temparray.push(hyperlink.list[0]);
hyperlink.list = temparray;
savejson();
loadlinks();
}
}
var newbutt = document.createElement("SPAN");
newbutt.className = "button";
newbutt.innerHTML = "DOWN";
newbutt.id = "down" + index.toString();
newli.appendChild(newbutt);
newbutt.onclick = function(){
var localindex = parseInt(this.id.substring(4));
if(localindex != hyperlink.list.length-1){
var temparray = [];
for(var tempindex = 0;tempindex < localindex;tempindex++){
temparray.push(hyperlink.list[tempindex]);
}
temparray.push(hyperlink.list[localindex + 1]);
temparray.push(hyperlink.list[localindex]);
for(var tempindex = localindex + 2;tempindex < hyperlink.list.length;tempindex++){
temparray.push(hyperlink.list[tempindex]);
}
hyperlink.list = temparray;
savejson();
loadlinks();
}
else{
var temparray = [];
temparray.push(hyperlink.list[hyperlink.list.length - 1]);
for(var tempindex = 1;tempindex < hyperlink.list.length - 1;tempindex++){
temparray.push(hyperlink.list[tempindex]);
}
hyperlink.list = temparray;
savejson();
loadlinks();
}
}
var newbutt = document.createElement("SPAN");
//reusing the same variable name is a form of recycling;#dealwithit
newbutt.className = "button";
newbutt.innerHTML = "DELETE";
newbutt.id = "delete" + index.toString();
newli.appendChild(newbutt);
newbutt.onclick = function(){
var localindex = parseInt(this.id.substring(6));
if(hyperlink.list.length > 1){
var temparray = [];
for(var tempindex = 0;tempindex < hyperlink.list.length;tempindex++){
if(tempindex != localindex){
temparray.push(hyperlink.list[tempindex]);
}
}
hyperlink.list = temparray;
savejson();
loadlinks();
}
}
var newbutt = document.createElement("SPAN");
newbutt.className = "button";
newbutt.innerHTML = "COPY";
newli.appendChild(newbutt);
newbutt.id = "copy" + index.toString();
newbutt.onclick = function(){
var localindex = parseInt(this.id.substring(4));
var thiselement = JSON.parse(JSON.stringify(hyperlink.list[localindex]));
hyperlink.list.unshift(thiselement);
savejson();
loadlinks();
}
var newt = document.createElement("TABLE");
newli.appendChild(newt);
var newtr = document.createElement("TR");
newt.appendChild(newtr);
var newtd = document.createElement("TD");
newtd.innerHTML = "text:";
newtr.appendChild(newtd);
var newtd = document.createElement("TD");
newtr.appendChild(newtd);
var newi = document.createElement("INPUT");
newi.value = hyperlink.list[index].text;
newi.id = "text" + index.toString();
newtd.appendChild(newi);
newi.onchange = function(){
var localindex = parseInt(this.id.substring(4));
hyperlink.list[localindex].text = this.value;
savejson();
loadlinks();
}
var newtd = document.createElement("TD");
newtd.innerHTML = "href:";
newtr.appendChild(newtd);
var newtd = document.createElement("TD");
newtr.appendChild(newtd);
var newi = document.createElement("INPUT");
newi.value = hyperlink.list[index].href;
newi.id = "href" + index.toString();
newtd.appendChild(newi);
newi.onchange = function(){
var localindex = parseInt(this.id.substring(4));
hyperlink.list[localindex].href = this.value;
savejson();
loadlinks();
}
}
}
function savejson(){
var httpc = new XMLHttpRequest();
var url = "filesaver.php";
httpc.open("POST", url, true);
httpc.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
httpc.send("data="+encodeURIComponent("hyperlink = " + JSON.stringify(hyperlink,null," ") + ";")+"&filename=jscode/hyperlink.js");//send text to filesaver.ph
}
document.getElementById("textio").value = JSON.stringify(hyperlink,null," ");
document.getElementById("importbutton").onclick = function(){
hyperlink = JSON.parse(document.getElementById("textio").value);
loadimage();
loadserver();
loadlinks();
savejson();
}
</script>
<style>
#importbutton{
width:6em;
}
input,textarea{
background-color:black;
color:#00ff00;
font-family:courier;
border-color:#00ff00;
width:40em;
}
table{
font-family:courier;
font-size:14px;
display:block;
margin:auto;
border:solid;
border-color:#00ff00;
}
td{
text-align:right;
}
body{
font-size:2em;
padding:0em 4em 4em 4em;
overflow:scroll;
background-color:black;
color:#00ff00;
}
#mainimage{
max-width:90%;
display:block;
margin:auto;
background-color:#808080;
}
#qrcode{
border:solid;
border-width:10px;
border-color:#808080;
margin:auto;
margin-top:1em;
margin-bottom:1em;
}
h1,h2,h3{
text-align:center;
}
a{
color:#ff2cb4;
}
.button{
border:solid;
font-family:courier;
border-color:#00ff00;
cursor:pointer;
}
.button:hover{
background-color:#00ff0080;
}
.button:active{
background-color:yellow;
}
</style>
</body>
</html>