1
mirror of git://git.acid.vegas/irc2html.git synced 2024-11-27 09:46:43 +00:00

Initial commit

This commit is contained in:
Dionysus 2019-06-24 22:47:59 -04:00
commit 3748504e1f
No known key found for this signature in database
GPG Key ID: 05114B46832BDBDB
3 changed files with 216 additions and 0 deletions

116
data/script.js Normal file
View File

@ -0,0 +1,116 @@
function formReset() {
document.getElementById('showcase').innerHTML = "<span class=\"placeholder\">*HTML view will appear here*</span>";
}
function toggle(bool) {
if (bool == true) {
return false;
}
else {
return true;
}
}
function convert() {
if (document.getElementById('text').value == "") {
return false;
}
document.getElementById('html').value = null;
document.getElementById('showcase').innerHTML = null;
lines = document.getElementById('text').value.split("\n");
reg = new RegExp("(([0-9]{1,2})?((?:,([0-9]{1,2}))?))|(||||)");
var showcase = "";
for (var i = 0, all=lines.length; i < all; i++) {
var line = lines[i];
line = line.replace(new RegExp('<','g'),'&lt;');
line = line.replace(new RegExp('>','g'),'&gt;');
var match, lastf = "1", lastb = "0";
var bold, italic, underline, reverse = false;
var first = true;
while ((match = reg.exec(line)) != null) {
var f, b, span;
if (match[2] != null) {
f = Number(match[2])
if (f > 15) { f = f-16; }
f = f.toString();
if (match[4] != null) {
b = Number(match[4])
if (b > 15) { b = b-16; }
b = b.toString();
}
else {
b = lastb;
}
}
else if (match[2] == null && (match[5] == null || match[5] == '')) {
if (match[5] == null) {
f = "1"; b = "0";
}
else {
f = "1"; b = "0";
bold = false;
italic = false;
underline = false;
reverse = false;
}
}
else {
f = lastf, b = lastb;
if (match[5] == '') {
bold = toggle(bold);
}
else if (match[5] == '') {
italic = toggle(italic);
}
else if (match[5] == '') {
underline = toggle(underline);
}
else if (match[5] == '') {
reverse = toggle(reverse);
}
}
if (reverse == false) {
span = 'f'+f+' b'+b;
}
else {
span = 'f'+b+' b'+f;
}
if (bold == true) { span += ' _b'; }
if (italic == true) { span += ' _i'; }
if (underline == true) { span += ' _u'; }
if (first == false) {
line = line.replace(match[0],'</span><span class="'+span+'">');
}
else {
line = line.replace(match[0],'<span class="'+span+'">');
first = false;
}
lastf = f; lastb = b;
}
if (first == false) {
showcase += (line+"</span>\n");
}
else {
showcase += (line+"\n");
}
}
showcase = showcase.replace(new RegExp("\<span class=\"(?:[a-zA-Z0-9_ ]+\")>\<\/span>","g"),"");
document.getElementById('showcase').innerHTML = ("<pre>\n"+showcase+"</pre>");
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";
document.getElementById('html').value += document.getElementById('showcase').innerHTML;
document.getElementById('html').value += "\n</body>\n</html>";
return false;
}
function Submit() {
if (document.getElementById('text').value != "" && document.getElementById('text').value != null) {
return true;
}
return false;
}
function Download() {
document.location='data:text/html,'+encodeURIComponent(document.getElementById('html').value);
}
window.onload = convert;

50
data/style.css Normal file
View File

@ -0,0 +1,50 @@
@charset "utf-8";
._b{font-weight:bold;}
._i{font-style:italic;}
._u{text-decoration:underline;}
.f0{color:#ffffff;}
.f1{color:#000000;}
.f2{color:#00007f;}
.f3{color:#009300;}
.f4{color:#ff0000;}
.f5{color:#7f0000;}
.f6{color:#9c009c;}
.f7{color:#fc7f00;}
.f8{color:#ffff00;}
.f9{color:#00fc00;}
.f10{color:#009393;}
.f11{color:#00ffff;}
.f12{color:#0000fc;}
.f13{color:#ff00ff;}
.f14{color:#7f7f7f;}
.f15{color:#d2d2d2;}
.b0{background-color:#ffffff;}
.b1{background-color:#000000;}
.b2{background-color:#00007f;}
.b3{background-color:#009300;}
.b4{background-color:#ff0000;}
.b5{background-color:#7f0000;}
.b6{background-color:#9c009c;}
.b7{background-color:#fc7f00;}
.b8{background-color:#ffff00;}
.b9{background-color:#00fc00;}
.b10{background-color:#009393;}
.b11{background-color:#00ffff;}
.b12{background-color:#0000fc;}
.b13{background-color:#ff00ff;}
.b14{background-color:#7f7f7f;}
.b15{background-color:#d2d2d2;}
html, body, p{font-family:segoe ui, trebuchet MS,Lucida Sans Unicode, Lucida Sans, Sans-Serif;}
h1{font-size:1.5em;text-align:center;}
h2{font-size:1em;font-weight:700;}
h6{font-size:1em;text-align:center;}
pre{font-family:Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, monospace, serif;margin:0;}
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%;}
.butt{width:150px;}
.container{margin:0;width:100%;}
.hidden{display:none;}
.placeholder{color:gray;}
.showcase{border:solid 1px #ddd;display:block;font-size:0.9em;padding:1%;}

50
index.html Normal file
View File

@ -0,0 +1,50 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>IRC2HTML</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="data/style.css" type="text/css">
<script type="text/javascript" src="data/script.js"></script>
</head>
<body>
<div id="script" class="hidden">
<form id="form" accept-charset="UTF-8">
<table width="100%">
<tr>
<td rowspan="3" width="45%">
<textarea width="100%" id="text" name="text" placeholder="*Enter ASCII here*"></textarea>
</td>
<td align="center" height="33%" valign="top">
<b>IRC2HTML</b>
<br><small><i>(<a href="https://acid.vegas/irc2html">source</a>)</i></small>
</td>
<td rowspan="3" width="45%">
<textarea width="100%" id="html" name="html" placeholder="*HTML code will appear here*" readonly></textarea>
</td>
</tr>
<tr>
<td height="33%" width="10%">
<input class="butt" type="submit" name="submit" value="Convert" onclick="return convert();"/>
<br><br><input class="butt" type="reset" name="reset" value="Reset" onclick="formReset();"/>
<br><br><input class="butt" type="button" name="download" value="Download" onclick="Download();"/>
</td>
</tr>
<tr>
<td align="center" height="33%" valign="bottom">
<b>View</b>
</td>
</tr>
</table>
</form>
<div id="showcase" class="showcase">
<span class="placeholder">*HTML view will appear here*</span>
</div>
</div>
<script type="text/javascript">
document.getElementById("script").style.display = "block";
</script>
<noscript>
Javascript is required to use this tool.
</noscript>
</body>
</html>