You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
170 lines
4.8 KiB
170 lines
4.8 KiB
<html> |
|
|
|
<head> |
|
<meta charset="ISO-8859-1"> |
|
<script> |
|
var to64 = false; |
|
var txtInput = 'txt64'; |
|
var txtOutput = 'txtjp'; |
|
|
|
var butts = ''; |
|
|
|
function utf8_to_b64(str) { |
|
return window.btoa(unescape(encodeURIComponent(str))); |
|
} |
|
|
|
function b64_to_utf8(str) { |
|
return decodeURIComponent(escape(window.atob(str))); |
|
} |
|
|
|
function fixtext() { |
|
try { |
|
document.getElementById('msg').innerText = ''; |
|
var txt = document.getElementById(txtInput).value; |
|
|
|
if (to64) { |
|
// txt = txt.replace(/"/g, '""').replace(/\\\//g, '/'); |
|
txt = utf8_to_b64(txt); |
|
} else { |
|
// txt = txt.replace(/""/g, '"').replace(/\//g, '\\\/'); |
|
txt = b64_to_utf8(txt); |
|
} |
|
|
|
document.getElementById(txtOutput).value = txt; |
|
document.getElementById('txtcopy').value = txt; |
|
|
|
document.getElementById('msg').innerText = "Text converted!"; |
|
} catch (e) { |
|
document.getElementById('msg').innerText = e; |
|
} |
|
} |
|
|
|
async function transtext(str) { |
|
if (str != '') { |
|
document.getElementById('msg').innerText = "Translating..."; |
|
const res = await fetch("https://translate.mentality.rip/translate", { |
|
method: "POST", |
|
body: JSON.stringify({ |
|
q: str, |
|
source: "ja", |
|
target: "en" |
|
}), |
|
headers: { |
|
"Content-Type": "application/json" |
|
} |
|
}); |
|
|
|
document.getElementById('msg').innerText = "Text translated!"; |
|
|
|
// console.log(await res.json()); |
|
jres = await res.json(); |
|
document.getElementById('txten').value = jres.translatedText; |
|
document.getElementById('txtcopy').value = jres.translatedText; |
|
} |
|
} |
|
|
|
function copytext() { |
|
try { |
|
var txtcopy = document.getElementById('txtcopy'); |
|
txtcopy.select(); |
|
txtcopy.setSelectionRange(0, 99999); |
|
document.execCommand("copy"); |
|
document.getElementById('msg').innerText = 'Copied to clipboard!'; |
|
} catch (e) { |
|
document.getElementById('msg').innerText = e; |
|
} |
|
} |
|
</script> |
|
<style> |
|
BODY, |
|
INPUT { |
|
font-family: 'Perspective Sans', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; |
|
} |
|
|
|
HR { |
|
clear: both; |
|
border: none; |
|
border-bottom: 1px dashed #6a6a6a; |
|
} |
|
|
|
H4 { |
|
margin: 0.5em 0; |
|
} |
|
|
|
TEXTAREA { |
|
clear: both; |
|
width: 100%; |
|
max-width: 300px; |
|
height: calc(50% - 3em); |
|
min-height: 25px; |
|
max-height: 100px; |
|
} |
|
|
|
TEXTAREA { |
|
background-color: #333; |
|
color: #fff; |
|
} |
|
|
|
#buttons, |
|
#direction, |
|
#msg { |
|
float: left; |
|
margin-bottom: 0.5em; |
|
} |
|
|
|
#buttons { |
|
margin-right: 0.5em; |
|
} |
|
|
|
#buttons INPUT { |
|
height: 2.2em; |
|
font-size: .8em; |
|
} |
|
|
|
#buttons INPUT[name="flip"] { |
|
padding-bottom: 3px; |
|
} |
|
|
|
#direction { |
|
margin-bottom: 0; |
|
line-height: 1.5em; |
|
font-size: 1.25em; |
|
} |
|
|
|
#msg { |
|
margin-left: 1em; |
|
font-size: .9em; |
|
line-height: 2em; |
|
color: #0ba82d; |
|
} |
|
|
|
#txtcopy { |
|
min-height: 0px; |
|
height: 0px; |
|
border: none; |
|
opacity: 0; |
|
} |
|
</style> |
|
</head> |
|
|
|
<body> |
|
<form accept-charset="utf-8"> |
|
<h4>Base64</h4> |
|
<textarea id="txt64" onkeyup="fixtext();"></textarea> |
|
<hr/> |
|
<div id="buttons"> |
|
<input type="button" name="submit" onclick="fixtext();" value="Format"> |
|
<input type="button" name="translate" onclick="transtext(document.getElementById('txtjp').value);" value="Translate"> |
|
<input type="button" name="copy" onclick="copytext();" value="Copy Result"> |
|
</div> |
|
<div id="msg"></div> |
|
<hr/> |
|
<h4>Japanese</h4> |
|
<textarea id="txtjp" disabled="disabled" onkeyup="fixtext();"></textarea> |
|
<h4>English</h4> |
|
<textarea id="txten" disabled="disabled"></textarea> |
|
<textarea id="txtcopy"></textarea> |
|
</form> |
|
</body> |
|
|
|
</html> |