←︎ irc2html :: 3748504


1
commit 3748504e1f449eb6bada4290fe579f38f89f0f94 (HEAD -> master)
2
Author: acidvegas <acid.vegas@acid.vegas>
3
Date:   Mon Jun 24 22:47:59 2019 -0400
4
5
    Initial commit
6
---
7
 data/script.js | 116 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
8
 data/style.css |  50 +++++++++++++++++++++++++
9
 index.html     |  50 +++++++++++++++++++++++++
10
 3 files changed, 216 insertions(+)
11
12
diff --git a/data/script.js b/data/script.js
13
new file mode 100644
14
index 0000000..7858d13
15
--- /dev/null
16
+++ b/data/script.js
17
@@ -0,0 +1,116 @@
18
+function formReset() {
19
+	document.getElementById('showcase').innerHTML = "<span class=\"placeholder\">*HTML view will appear here*</span>";
20
+}
21
+
22
+function toggle(bool) {
23
+	if (bool == true) {
24
+		return false;
25
+	}
26
+	else {
27
+		return true;
28
+	}
29
+}
30
+
31
+function convert() {
32
+	if (document.getElementById('text').value == "") {
33
+		return false;
34
+	}
35
+	document.getElementById('html').value = null;
36
+	document.getElementById('showcase').innerHTML = null;
37
+	lines = document.getElementById('text').value.split("\n");
38
+	reg = new RegExp("(([0-9]{1,2})?((?:,([0-9]{1,2}))?))|(||||)");
39
+	var showcase = "";
40
+	for (var i = 0, all=lines.length; i < all; i++) {
41
+		var line = lines[i];
42
+		line = line.replace(new RegExp('<','g'),'&lt;');
43
+		line = line.replace(new RegExp('>','g'),'&gt;');
44
+		var match, lastf = "1", lastb = "0";
45
+		var bold, italic, underline, reverse = false;
46
+		var first = true;
47
+		while ((match = reg.exec(line)) != null) {
48
+			var f, b, span;
49
+			if (match[2] != null) {
50
+				f = Number(match[2])
51
+				if (f > 15) { f = f-16; }
52
+				f = f.toString();
53
+				if (match[4] != null) {
54
+					b =  Number(match[4])
55
+					if (b > 15) { b = b-16; }
56
+					b = b.toString();
57
+				}
58
+				else {
59
+					b = lastb;
60
+				}
61
+			}
62
+			else if (match[2] == null && (match[5] == null || match[5] == '')) {
63
+				if (match[5] == null) {
64
+					f = "1"; b = "0";
65
+				}
66
+				else {
67
+					f = "1"; b = "0";
68
+					bold = false;
69
+					italic = false;
70
+					underline = false;
71
+					reverse = false;
72
+				}
73
+			}
74
+			else {
75
+				f = lastf, b = lastb;
76
+				if (match[5] == '') {
77
+					bold = toggle(bold);
78
+				}
79
+				else if (match[5] == '') {
80
+					italic = toggle(italic);
81
+				}
82
+				else if (match[5] == '') {
83
+					underline = toggle(underline);
84
+				}
85
+				else if (match[5] == '') {
86
+					reverse = toggle(reverse);
87
+				}
88
+			}
89
+			if (reverse == false) {
90
+				span = 'f'+f+' b'+b;
91
+			}
92
+			else {
93
+				span = 'f'+b+' b'+f;
94
+			}
95
+			if (bold == true) { span += ' _b'; }
96
+			if (italic == true) { span += ' _i'; }
97
+			if (underline == true) { span += ' _u'; }
98
+			if (first == false) {
99
+				line = line.replace(match[0],'</span><span class="'+span+'">');
100
+			}
101
+			else {
102
+				line = line.replace(match[0],'<span class="'+span+'">');
103
+				first = false;
104
+			}
105
+			lastf = f; lastb = b;
106
+		}
107
+		if (first == false) {
108
+			showcase += (line+"</span>\n");
109
+		}
110
+		else {
111
+			showcase += (line+"\n");
112
+		}
113
+	}
114
+	showcase = showcase.replace(new RegExp("\<span class=\"(?:[a-zA-Z0-9_ ]+\")>\<\/span>","g"),"");
115
+	document.getElementById('showcase').innerHTML = ("<pre>\n"+showcase+"</pre>");
116
+	document.getElementById('html').value = "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"UTF-8\">\n<title>IRC2HTML - https://git.supernets.org/acidvegas/irc2html</title>\n<style type=\"text/css\">\n.f0 { color: #ffffff; }\n.b0 { background-color: #ffffff; }\n.f1 { color: #000000; }\n.b1 { background-color: #000000; }\n.f2 { color: #00007f; }\n.b2 { background-color: #00007f; }\n.f3 { color: #009300; }\n.b3 { background-color: #009300; }\n.f4 { color: #ff0000; }\n.b4 { background-color: #ff0000; }\n.f5 { color: #7f0000; }\n.b5 { background-color: #7f0000; }\n.f6 { color: #9c009c; }\n.b6 { background-color: #9c009c; }\n.f7 { color: #fc7f00; }\n.b7 { background-color: #fc7f00; }\n.f8 { color: #ffff00; }\n.b8 { background-color: #ffff00; }\n.f9 { color: #00fc00; }\n.b9 { background-color: #00fc00; }\n.f10 { color: #009393; }\n.b10 { background-color: #009393; }\n.f11 { color: #00ffff; }\n.b11 { background-color: #00ffff; }\n.f12 { color: #0000fc; }\n.b12 { background-color: #0000fc; }\n.f13 { color: #ff00ff; }\n.b13 { background-color: #ff00ff; }\n.f14 { color: #7f7f7f; }\n.b14 { background-color: #7f7f7f; }\n.f15 { color: #d2d2d2; }\n.b15 { background-color: #d2d2d2; }\n._b { font-weight: bold; }\n._i { font-style: italic; }\n._u { text-decoration: underline; }\npre { margin: 0; font-family: Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, monospace, serif; font-size: 0.9em; }\n</style>\n</head>\n<body>\n";
117
+	document.getElementById('html').value += document.getElementById('showcase').innerHTML;
118
+	document.getElementById('html').value += "\n</body>\n</html>";
119
+	return false;
120
+}
121
+
122
+function Submit() {
123
+	if (document.getElementById('text').value != "" && document.getElementById('text').value != null) {
124
+		return true;
125
+	}
126
+	return false;
127
+}
128
+
129
+function Download() {
130
+	document.location='data:text/html,'+encodeURIComponent(document.getElementById('html').value);
131
+}
132
+
133
+window.onload = convert;
134
diff --git a/data/style.css b/data/style.css
135
new file mode 100644
136
index 0000000..bd62933
137
--- /dev/null
138
+++ b/data/style.css
139
@@ -0,0 +1,50 @@
140
+@charset "utf-8";
141
+
142
+._b{font-weight:bold;}
143
+._i{font-style:italic;}
144
+._u{text-decoration:underline;}
145
+.f0{color:#ffffff;}
146
+.f1{color:#000000;}
147
+.f2{color:#00007f;}
148
+.f3{color:#009300;}
149
+.f4{color:#ff0000;}
150
+.f5{color:#7f0000;}
151
+.f6{color:#9c009c;}
152
+.f7{color:#fc7f00;}
153
+.f8{color:#ffff00;}
154
+.f9{color:#00fc00;}
155
+.f10{color:#009393;}
156
+.f11{color:#00ffff;}
157
+.f12{color:#0000fc;}
158
+.f13{color:#ff00ff;}
159
+.f14{color:#7f7f7f;}
160
+.f15{color:#d2d2d2;}
161
+.b0{background-color:#ffffff;}
162
+.b1{background-color:#000000;}
163
+.b2{background-color:#00007f;}
164
+.b3{background-color:#009300;}
165
+.b4{background-color:#ff0000;}
166
+.b5{background-color:#7f0000;}
167
+.b6{background-color:#9c009c;}
168
+.b7{background-color:#fc7f00;}
169
+.b8{background-color:#ffff00;}
170
+.b9{background-color:#00fc00;}
171
+.b10{background-color:#009393;}
172
+.b11{background-color:#00ffff;}
173
+.b12{background-color:#0000fc;}
174
+.b13{background-color:#ff00ff;}
175
+.b14{background-color:#7f7f7f;}
176
+.b15{background-color:#d2d2d2;}
177
+
178
+html, body, p{font-family:segoe ui, trebuchet MS,Lucida Sans Unicode, Lucida Sans, Sans-Serif;}
179
+h1{font-size:1.5em;text-align:center;}
180
+h2{font-size:1em;font-weight:700;}
181
+h6{font-size:1em;text-align:center;}
182
+pre{font-family:Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, monospace, serif;margin:0;}
183
+textarea{background-color:#F8F8F8;border:solid 1px #ddd;display:block;font-family:Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, monospace, serif;font-size:0.9em;height:36em;padding:1%;resize:none;width:97%;}
184
+
185
+.butt{width:150px;}
186
+.container{margin:0;width:100%;}
187
+.hidden{display:none;}
188
+.placeholder{color:gray;}
189
+.showcase{border:solid 1px #ddd;display:block;font-size:0.9em;padding:1%;}
190
diff --git a/index.html b/index.html
191
new file mode 100644
192
index 0000000..cbd6e3c
193
--- /dev/null
194
+++ b/index.html
195
@@ -0,0 +1,50 @@
196
+<!DOCTYPE html>
197
+<html lang="en">
198
+	<head>
199
+		<title>IRC2HTML</title>
200
+		<meta charset="UTF-8">
201
+		<link rel="stylesheet" href="data/style.css" type="text/css">
202
+		<script type="text/javascript" src="data/script.js"></script>
203
+	</head>
204
+	<body>
205
+		<div id="script" class="hidden">
206
+			<form id="form" accept-charset="UTF-8">
207
+				<table width="100%">
208
+					<tr>
209
+						<td rowspan="3" width="45%">
210
+							<textarea width="100%" id="text" name="text" placeholder="*Enter ASCII here*"></textarea>
211
+						</td>
212
+						<td align="center" height="33%" valign="top">
213
+							<b>IRC2HTML</b>
214
+							<br><small><i>(<a href="https://acid.vegas/irc2html">source</a>)</i></small>
215
+						</td>
216
+						<td rowspan="3" width="45%">
217
+							<textarea width="100%" id="html" name="html" placeholder="*HTML code will appear here*" readonly></textarea>
218
+						</td>
219
+					</tr>
220
+					<tr>
221
+						<td height="33%" width="10%">
222
+							<input class="butt" type="submit" name="submit" value="Convert" onclick="return convert();"/>
223
+							<br><br><input class="butt" type="reset" name="reset" value="Reset" onclick="formReset();"/>
224
+							<br><br><input class="butt" type="button" name="download" value="Download" onclick="Download();"/>
225
+						</td>
226
+					</tr>
227
+					<tr>
228
+						<td align="center" height="33%" valign="bottom">
229
+							<b>View</b>
230
+						</td>
231
+					</tr>
232
+				</table>
233
+			</form>
234
+		<div id="showcase" class="showcase">
235
+			<span class="placeholder">*HTML view will appear here*</span>
236
+		</div>
237
+	</div>
238
+	<script type="text/javascript">
239
+		document.getElementById("script").style.display = "block";
240
+	</script>
241
+	<noscript>
242
+		Javascript is required to use this tool.
243
+	</noscript>
244
+	</body>
245
+</html>