WordMord/transformations.html
2022-01-13 07:57:57 -06:00

93 lines
2.3 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>
</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div >
<table>
<tr class='trans_table'>
<div>
<iframe src="https://pad.vvvvvvaria.org/%CE%B3%CE%BF%CF%85%CE%BF%CF%81%CE%BD%CF%84%CE%BC%CE%BF%CF%81%CE%BD%CF%84"></iframe>
</div>
<tr class='trans_table' ><div id="distorted">
<button type="button" onclick="no_spaces()">no spaces</button>
<br><br>
<div id="no_spaces"></div>
<br><br>
<button type="button" onclick="blind_spots()">blind spots</button>
<br><br>
<div id="blind_spots"></div>
</div>
</div>
</tr>
</table>
<script>
var clicked1 = 0;
var clicked2 = 0;
function no_spaces() {
var distorted = httpGet('https://pad.vvvvvvaria.org/%CE%B3%CE%BF%CF%85%CE%BF%CF%81%CE%BD%CF%84%CE%BC%CE%BF%CF%81%CE%BD%CF%84/export/txt');
if (clicked1 == 0) {
document.getElementById("no_spaces").innerHTML = distorted.replace(/\s+/g, '');
clicked1 = 1;
} else {
document.getElementById("no_spaces").innerHTML = "";
clicked1 = 0;
}
}
function blind_spots() {
var distorted = httpGet('https://pad.vvvvvvaria.org/%CE%B3%CE%BF%CF%85%CE%BF%CF%81%CE%BD%CF%84%CE%BC%CE%BF%CF%81%CE%BD%CF%84/export/txt');
if (clicked2 == 0) {
var keep=['γλώσσα','ΓΛΩΣΣΑ','Κώδικα','κώδικα','code', 'Mord'];
console.log(keep);
var repl_char = '|||||||||';
// extracting words
var temp = distorted.split(" ");
for (idx in temp){
var ele = temp[idx];
console.log(temp[idx])
if (!keep.includes(ele)){
temp[idx] = repl_char;
}
};
// joining result
var distorted = temp.join("");
document.getElementById("blind_spots").innerHTML = distorted;
clicked2 = 1;
} else {
document.getElementById("blind_spots").innerHTML = "";
clicked2 = 0;
}
}
function httpGet(theUrl) {
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", theUrl, false); // false for synchronous request
xmlHttp.send(null);
return xmlHttp.responseText;
}
</script>
</body>
</html>