-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
87cfabd
commit 2db1ee7
Showing
1 changed file
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Pass Reformatter</title> | ||
<meta name="description" content="Reformats Passes or URIs to a shorter format for posting in chat."> | ||
<meta name="keywords" content="Pass, Passes, Reformat, Regex, String, Text"> | ||
<meta property="og:title" content="Pass Reformatter"> | ||
<meta property="og:type" content="website"> | ||
<meta property="og:url" content="https://mysterypancake.github.io/Fun/html/passreformatter"> | ||
<meta property="og:site_name" content="Pass Reformatter"> | ||
<meta property="og:description" content="Reformats Passes or URIs to a shorter format for posting in chat."> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<style> | ||
* { | ||
font-family: system-ui, Arial, Helvetica, sans-serif; | ||
} | ||
|
||
html, body { | ||
height: 100%; | ||
margin: 0; | ||
overflow-x: hidden; | ||
padding: 0; | ||
} | ||
|
||
h1 { | ||
display: inline-block; | ||
margin: .5rem 0; | ||
padding: 0; | ||
} | ||
|
||
.mainDiv { | ||
display: inline-block; | ||
box-sizing: border-box; | ||
float: left; | ||
width: 50%; | ||
height: 100%; | ||
padding: 0 1rem; | ||
} | ||
|
||
.checkboxDiv { | ||
display: flex; | ||
align-items: center; | ||
width: 100%; | ||
place-content: space-between; | ||
} | ||
|
||
textarea { | ||
width: 100%; | ||
height: 85%; | ||
} | ||
</style> | ||
<script> | ||
let passElem; | ||
let resultElem; | ||
let sortElem; | ||
|
||
function setup() { | ||
passElem = document.getElementById("passes"); | ||
resultElem = document.getElementById("result"); | ||
sortElem = document.getElementById("sort"); | ||
} | ||
|
||
function update() { | ||
let result = []; | ||
const parts = passElem.value.trim().split(/\s/g); | ||
for (let i = 0; i < parts.length; ++i) { | ||
const trimmed = parts[i].trim(); | ||
if (trimmed.length <= 0) continue; | ||
if (trimmed.indexOf("/") >= 0) { | ||
const bits = trimmed.split("/"); | ||
result.push(`${bits[bits.length - 1].split(".")[0]} (v${bits[bits.length - 2]})`); | ||
} else { | ||
const bits = trimmed.split(/[\.#]/g); | ||
result.push(`${bits[0]} (v${bits[bits.length - 1]})`); | ||
} | ||
} | ||
if (sortElem.checked) result = result.sort(); | ||
resultElem.textContent = result.join("\n"); | ||
} | ||
</script> | ||
</head> | ||
<body onload="setup();"> | ||
<div class="mainDiv"> | ||
<h1>Passes</h1> | ||
<textarea id="passes" oninput="update();"></textarea> | ||
</div> | ||
<div class="mainDiv"> | ||
<div class="checkboxDiv"> | ||
<h1>Reformatted</h1> | ||
<div> | ||
<input id="sort" type="checkbox" checked oninput="update();"> | ||
<label for="sort">Sort</label> | ||
</div> | ||
</div> | ||
<textarea id="result" readonly></textarea> | ||
</div> | ||
</body> | ||
</html> |