-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
137 lines (120 loc) · 3.99 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
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>EntitifyIt</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="Simple tool for cleaning code with character entities" />
<link rel="shortcut icon" href="favicon.png" />
<style>
* {padding: 0; margin: 0;}
body {
font: 100%/1.2 "Century Gothic", "Gill Sans", "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
color: #FFF;
background-color: #2C3E50;
padding-bottom: 4rem;
margin: 5vh 5%;
}
body::after {
display: block;
position: fixed;
bottom: 0;
left: 0;
width: 100%;
height: 90px;
content: "";
background: #2C3E50 url(backgd.svg) bottom repeat-x;
}
h1 {font-size: 3vmax; margin-bottom: 2rem;}
p {font-size: 1.3em;}
label {display: block; margin-bottom: 0.5em;}
p + p {margin-top: 2rem;}
button {
font: 100%/1.2 "Century Gothic", "Gill Sans", "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
background: rgba(255,255,255,0);
border: none;
cursor: pointer;
}
#container {text-align: center; margin: 0 auto;}
#the-submit {
color: #FFF;
background-color: #B51100;
padding: 0.5em 1em;
border-radius: 0.3em;
}
button[data-clipboard-action="copy"] {
display: block;
width: 100%;
text-align: center;
font-size: 80%;
text-transform: uppercase;
color: #FFF;
padding: 0.5em 0;
}
textarea {width: 90%;}
#container form p:nth-child(2) {position: relative;}
#container form p:nth-child(2)::after {
display: block;
position: absolute;
bottom: -10px;
left: 50%;
width: 20px;
height: 20px;
content: "";
background-color: #B51100;
margin-left: -10px;
transform: rotate(45deg);
transition: all 1s;
}
@media screen and (min-width: 1500px) {
#container form {
display: flex;
justify-content: space-around;
align-items: center;
}
#container form p:nth-child(1), #container form p:nth-child(3) {flex: 1 0 45%;}
#container form p:nth-child(2)::after {
top: 50%;
right: -10px;
bottom: auto;
left: auto;
margin-left: 0;
margin-top: -10px;
}
textarea {height: 40vh;}
}
</style>
</head>
<body>
<div id="container">
<h1>EntitifyIt</h1>
<form method="post" action="#">
<p><label for="the-input">Original code</label> <textarea id="the-input" rows="15" cols="50"></textarea></p>
<p><button type="button" id="the-submit">Entitify it!</button></p>
<p><label for="the-output">Entitified Code</label> <textarea id="the-output" rows="15" cols="50" disabled="disabled"></textarea>
<button type="button" class="c2c" data-clipboard-action="copy" data-clipboard-target="#the-output">[Copy]</button></p>
</form>
</div>
</body>
<script src="clipboard.min.js"></script>
<script>
var clipboard = new Clipboard('.c2c');
let charArray = ["<", ">", "{", "}", "\"", " & ", "\'", "\`"];
let entArray = ["<", ">", "{", "}", """, "&", "'", "`"];
let zInput = document.getElementById('the-input');
let zOutput = document.getElementById('the-output');
let zSubmit = document.getElementById('the-submit');
var theString;
var newString;
zSubmit.addEventListener('click', function() {
theString = zInput.value;
for(i = 0; i < charArray.length; i++) {
var pp = new RegExp(charArray[i], 'g');
theString = theString.replace(pp,entArray[i]);
console.log(theString);
}
zOutput.removeAttribute('disabled');
zOutput.value = theString;
});
</script>
</html>