-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding separate Latin Macronizer page.
- Loading branch information
1 parent
359d17e
commit 6caf967
Showing
4 changed files
with
231 additions
and
1 deletion.
There are no files selected for viewing
Binary file not shown.
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,229 @@ | ||
<!doctype html> | ||
|
||
|
||
<html lang=""> | ||
<head> | ||
<meta charset="UTF-8"/> | ||
|
||
<link as="style" href="https://cdn.jsdelivr.net/gh/yegor256/tacit@gh-pages/tacit-css-1.7.1.min.css" | ||
onload="this.onload=null;this.rel='stylesheet'" | ||
rel="preload"> | ||
<noscript> | ||
<link href="https://cdn.jsdelivr.net/gh/yegor256/tacit@gh-pages/tacit-css-1.7.1.min.css" rel="stylesheet"> | ||
</noscript> | ||
|
||
|
||
<link as="style" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" | ||
onload="this.onload=null;this.rel='stylesheet'" rel="preload"> | ||
<noscript> | ||
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" | ||
rel="stylesheet"> | ||
</noscript> | ||
|
||
|
||
<style> | ||
#output { | ||
|
||
text-align: justify; | ||
margin-left: auto; | ||
margin-right: auto; | ||
max-width: 55%; | ||
font-size: 20pt; | ||
font-family: "EB Garamond", serif; | ||
} | ||
|
||
|
||
</style> | ||
<script type="module"> | ||
import {macronize} from "./scripts/utils.js"; | ||
import {toPdf} from "./scripts/pdf_export.js"; | ||
|
||
function fillOutput(text) { | ||
const table = document.querySelector('#output') | ||
table.innerHTML = text.replace(/\n/g, '<br />'); | ||
|
||
if (document.querySelector('#result')){ | ||
document.querySelector('#result').remove() | ||
} | ||
// for PDF export function | ||
const hiddenTable = document.createElement('table') | ||
hiddenTable.setAttribute('id', 'result') | ||
hiddenTable.setAttribute('style','display:none') | ||
const lines = text.split('\n') | ||
lines.forEach(line => { | ||
const row = document.createElement('tr'); | ||
const words = line.split(' '); | ||
words.forEach(word => { | ||
const cell = document.createElement('div'); | ||
cell.classList.add('cell'); | ||
cell.innerHTML = word+' '; | ||
row.appendChild(cell); | ||
}); | ||
hiddenTable.appendChild(row); | ||
}); | ||
document.body.appendChild(hiddenTable) | ||
} | ||
|
||
function macronizeText() { | ||
const inputText = document.querySelector('#text_to_macronize').value | ||
const macronizedText = macronize(inputText); | ||
fillOutput(macronizedText) | ||
} | ||
|
||
function demacronize(text) { | ||
return text.replace(/ō/g, 'o').replace(/ā/g, 'a').replace(/ū/g, 'u').replace(/ī/g, 'i').replace(/ē/g, 'e').replace(/ȳ/g, 'y') | ||
.replace(/Ō/g, 'O').replace(/Ā/g, 'A').replace(/Ū/g, 'U').replace(/Ī/g, 'I').replace(/Ē/g, 'E').replace(/Ȳ/g, 'Y') | ||
} | ||
|
||
function deMacronizeText() { | ||
const inputText = document.querySelector('#text_to_macronize').value | ||
const demacronizedText = demacronize(inputText) | ||
fillOutput(demacronizedText) | ||
|
||
} | ||
|
||
document.getElementById("macronize").addEventListener("click", macronizeText); | ||
document.getElementById("demacronize").addEventListener("click", deMacronizeText); | ||
const isDarkMode = () => document.body.classList.contains("dark_mode"); | ||
|
||
async function pdfExport(event) { | ||
const buttonElement = event.currentTarget; | ||
const iconElement = buttonElement.querySelector("i"); | ||
|
||
buttonElement.disabled = true; | ||
const oldIconClass = iconElement.className; | ||
iconElement.className = "fa fa-spinner fa-spin"; | ||
|
||
await toPdf( | ||
"default", | ||
isDarkMode(), | ||
"latin", | ||
); | ||
|
||
iconElement.className = oldIconClass; | ||
buttonElement.disabled = false; | ||
} | ||
|
||
document.getElementById("export_pdf").addEventListener("click", pdfExport); | ||
|
||
function toggleDarkMode() { | ||
console.log("setting dark"); | ||
if (document.body.classList.contains("dark_mode")) { | ||
console.log("dark already setting light"); | ||
toggleLightMode(); | ||
} else { | ||
document.body.classList.add("dark_mode"); | ||
document.querySelector("#header > a > i").className = "fa fa-sun-o"; | ||
} | ||
} | ||
|
||
function toggleLightMode() { | ||
document.querySelector("#header>a>i").className = "fa fa-moon-o"; | ||
document.body.classList.remove("dark_mode"); | ||
} | ||
|
||
document.getElementById("dark_mode").addEventListener("click", toggleDarkMode); | ||
</script> | ||
|
||
|
||
<title>Latin Macronizer</title> | ||
<meta charset="UTF-8"> | ||
<meta content="width=device-width, initial-scale=1" name="viewport"> | ||
<meta content="" name="Keywords"/> | ||
<meta content="Adding macrons to latin texts, based on predefined dictionary of unambiguous macronized words." | ||
name="description"> | ||
|
||
|
||
<link href="https://fonts.googleapis.com" rel="preconnect"/> | ||
<link crossorigin href="https://fonts.gstatic.com" rel="preconnect"/> | ||
<link href="favicon.ico" rel="shortcut icon" type="image/x-icon"/> | ||
<link href="css/style.css" rel="stylesheet" type="text/css"> | ||
|
||
|
||
</head> | ||
<body> | ||
<div id="content"> | ||
<br/> | ||
<div id="header"> | ||
<p style="visibility: hidden"> | ||
<i class="fa fa-moon-o"></i> | ||
</p> | ||
<h1 style="flex: 1;">Latin Macronizer</h1> | ||
<a href="#" id="dark_mode" onclick="toggleDarkMode()"> | ||
<i class="fa fa-moon-o"></i> | ||
</a> | ||
</div> | ||
<hr> | ||
|
||
|
||
<form id="frm1" onsubmit="return false"> | ||
<div class="form-group"> | ||
<div id="form_top"> | ||
<textarea | ||
autofocus="" | ||
id="text_to_macronize" | ||
name="text_to_macronize" | ||
required="" | ||
>Omnium provinciarum populi Romani quibus finitimae fuerunt gentes quae non parerent imperio nostro fines auxi. </textarea> | ||
<div id="clear_button_group"> | ||
<button id="clear_button" type="button">Clear form</button> | ||
|
||
|
||
</div> | ||
</div> | ||
<div class="btn-group btn-block" id="form_bottom" role="group"> | ||
<button | ||
autocomplete="off" | ||
class="btn btn-primary btn-block" | ||
id="macronize" | ||
name="macronize" | ||
type="button" | ||
> | ||
Macronize | ||
</button> | ||
<button | ||
autocomplete="off" | ||
class="btn btn-primary btn-block" | ||
id="demacronize" | ||
name="demacronize" | ||
type="button" | ||
> | ||
De-macronize | ||
</button> | ||
|
||
</div> | ||
</div> | ||
</form> | ||
<hr> | ||
<table> | ||
<tbody id="output"> | ||
<tr> | ||
<td> | ||
<div class="cell"> | ||
</div> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
|
||
<button | ||
autocomplete="off" | ||
class="btn btn-primary btn-block" | ||
id="export_pdf" | ||
name="submit" | ||
type="button" | ||
value="" | ||
>Export as PDF | ||
<i class="fa fa-file-pdf-o" style="font-size: 30px;color: #c11313;"></i> | ||
</button> | ||
</div> | ||
<hr> | ||
<div id="footer"> | ||
<a href="https://github.com/hellpanderrr/hellpanderrr.github.io/tree/main/wiktionary_pron" style="color: black;"><i | ||
class="fa fa-github" style="font-size:36px"></i></a> | ||
|
||
</div> | ||
|
||
<a href="https://hits.seeyoufarm.com" style="display:none;"><img | ||
src="https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fhellpanderrr.github.io%2Fwiktionary_pron%2Findex.html&count_bg=%23414141&title_bg=%236E2424&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false"/></a> | ||
|
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
Large diffs are not rendered by default.
Oops, something went wrong.