Skip to content

Commit

Permalink
Lesson 1
Browse files Browse the repository at this point in the history
  • Loading branch information
CosmonautKitten committed Jan 8, 2025
1 parent 691ec00 commit 55fd009
Show file tree
Hide file tree
Showing 9 changed files with 582 additions and 115 deletions.
24 changes: 12 additions & 12 deletions dictionary/index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!DOCTYPE html>
<html>
<head>
<noun>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta property="og:title" content="kawaba">
Expand All @@ -12,10 +12,10 @@
<link href="../style.css" rel="stylesheet">
<link href="dictionarystyle.css" rel="stylesheet">
<script src="search.js"></script>
</head>
</noun>
<body>
<div class="content">
<div class="header">
<div class="nouner">
<a href="/"><img class="image" src="/images/kawaba.svg" width="60px" height="60px"></a>
<div class="title">
<h1>kawaba</h1>
Expand Down Expand Up @@ -62,7 +62,7 @@ <h3>dictionary</h3>
<b>ba</b>
<div>
<i>verb</i><br>
<i>head</i><br>
<i>noun</i><br>
<i>modifier</i>
</div>
<div>
Expand All @@ -75,7 +75,7 @@ <h3>dictionary</h3>
<b>ban</b>
<div>
<i>verb</i><br>
<i>head</i><br>
<i>noun</i><br>
<i>modifier</i>
</div>
<div>
Expand All @@ -88,7 +88,7 @@ <h3>dictionary</h3>
<b>be</b>
<div>
<i>verb</i><br>
<i>head</i><br>
<i>noun</i><br>
<i>modifier</i>
</div>
<div>
Expand All @@ -101,7 +101,7 @@ <h3>dictionary</h3>
<b>ben</b>
<div>
<i>verb</i><br>
<i>head</i><br>
<i>noun</i><br>
<i>modifier</i>
</div>
<div>
Expand All @@ -114,7 +114,7 @@ <h3>dictionary</h3>
<b>bi</b>
<div>
<i>verb</i><br>
<i>head</i><br>
<i>noun</i><br>
<i>modifier</i>
</div>
<div>
Expand All @@ -127,7 +127,7 @@ <h3>dictionary</h3>
<b>bin</b>
<div>
<i>verb</i><br>
<i>head</i><br>
<i>noun</i><br>
<i>modifier</i>
</div>
<div>
Expand All @@ -140,7 +140,7 @@ <h3>dictionary</h3>
<b>bo</b>
<div>
<i>verb</i><br>
<i>head</i><br>
<i>noun</i><br>
<i>modifier</i>
</div>
<div>
Expand All @@ -153,7 +153,7 @@ <h3>dictionary</h3>
<b>bon</b>
<div>
<i>verb</i><br>
<i>head</i><br>
<i>noun</i><br>
<i>modifier</i>
</div>
<div>
Expand All @@ -166,7 +166,7 @@ <h3>dictionary</h3>
<b>bu</b>
<div>
<i>verb</i><br>
<i>head</i><br>
<i>noun</i><br>
<i>modifier</i>
</div>
<div>
Expand Down
18 changes: 10 additions & 8 deletions hovertranslate.css
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
/* original text */
.og {
font-weight: bold;
border-radius: 5px;
font-size: 18px;
}

/* translated text */
.tl {
font-weight: normal;
display: none; /* its hidden by default */
position:absolute;
-webkit-transform: translateY(25px);
transform: translateY(25px);
transform: translateY(32px);
z-index: 1;
color: black;
background: #f7e5a4;
Expand All @@ -22,9 +21,12 @@
/* format the background of the original text */
/* this class is the comtainer for the og and tl classes */
.tlt {
color: black;
background: #f7e5a4;
height: 14pt;
border-radius: 5px;;
padding: 4px;
height: 22px;
padding: 10px;
text-align: center;
background-color: #0c3a66;
color: #ffffff;
overflow: hidden;
border-radius: 10px;
text-align: center;
}
82 changes: 49 additions & 33 deletions hovertranslate.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,64 @@
//on page load change all the tlt spans to be formatted for reading
// On page load, change all the tlt spans to be formatted for reading
document.addEventListener("DOMContentLoaded", () => {
let tlts = document.querySelectorAll("span.tlt");
for (let i = 0; i < tlts.length; i++) {
let input = tlts[i].innerHTML;
let output = "";
let words = input.split("} {");
for (let i = 0; i < words.length; i++) {
let word = words[i];
word = word.replace("{", "");
word = word.replace("}", "");
let wordt = word.split("|");
output += "<span class='og'>";
output += wordt[0];
output += "<span class='tl'>";
output += wordt[1];
output += "</span></span>";

// Match all substrings enclosed in braces, preserving spaces
let matches = input.match(/{[^}]*}|[^{}]+/g);

if (matches) {
matches.forEach((match) => {
if (match.startsWith("{") && match.endsWith("}")) {
// Handle word with translation
let word = match.replace(/{|}/g, "");
let wordt = word.split("|");
output += "<span class='og'>";
output += wordt[0]; // Original word
output += "<span class='tl'>";
output += wordt[1] || ""; // Translation
output += "</span></span>";
} else {
// Handle plain text (spaces or non-brace content)
output += match;
}
});
}
tlts[i].innerHTML = output;

//read the document and find all the spans with class og and their corresponding tl
let translateables = document.querySelectorAll("span.og");
let translations = document.querySelectorAll("span.tl");
for (let i = 0; i < translateables.length; i++) {
//add mouselistener to each og that shows the tl
translateables[i].addEventListener("mouseenter", () => {
translations[i].style.display = "inherit";
translateables[i].style.background = "rgba(0,0,0,0.2)";

tlts[i].innerHTML = output; // Update the content

// Get translateables and their corresponding translations within this `tlt`
let translateables = tlts[i].querySelectorAll("span.og");
let translations = tlts[i].querySelectorAll("span.tl");

for (let j = 0; j < translateables.length; j++) {
let og = translateables[j];
let tl = translations[j];

// Add mouse listener to each og that shows the tl
og.addEventListener("mouseenter", () => {
tl.style.display = "inherit";
og.style.background = "rgba(0,0,0,0.2)";
});
translateables[i].addEventListener("click", () => {
translations[i].style.display = "inherit";
translateables[i].style.background = "rgba(0,0,0,0.2)";

og.addEventListener("click", () => {
tl.style.display = "inherit";
og.style.background = "rgba(0,0,0,0.2)";
});

//when the mouse leaves it, hide the tl
// When the mouse leaves it, hide the tl
window.addEventListener("click", (event) => {
if (!translateables[i].contains(event.target)) {
translations[i].style.display = "none";
translateables[i].style.background = "";
if (!og.contains(event.target)) {
tl.style.display = "none";
og.style.background = "";
}
});
translateables[i].addEventListener("mouseleave", () => {
translations[i].style.display = "none";
translateables[i].style.background = "";

og.addEventListener("mouseleave", () => {
tl.style.display = "none";
og.style.background = "";
});
}
}
});
});
21 changes: 16 additions & 5 deletions lessons/0.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
<meta property="og:image" content="https://kawaba.gay/images/kawaba.svg">
<meta property="og:url" content="https://kawaba.gay">
<title>kawaba</title>
<link rel="icon" href="/favicon.ico">
<link rel="icon" href="../favicon.ico">
<link href="../style.css" rel="stylesheet">
<link href="dictionarystyle.css" rel="stylesheet">
<script src="search.js"></script>
<link href="../hovertranslate.css" rel="stylesheet">
<script src="../hovertranslate.js"></script>
</head>
<body>
<div class="content">
Expand All @@ -31,6 +31,14 @@ <h3>the language of parts</h3>
<div class="title-box">
<h3>lesson 0 - spelling and pronunciation</h3>
</div>
<p>
Before you dive into Kawaba, it's essential to start with the basics: how to spell and
pronounce the language correctly. Kawaba's minimalist design extends to its sound system,
offering a clean and intuitive structure that's easy to learn and speak.
</p>
<div class="title-box">
<h3>alphabet</h3>
</div>
<p>There are 16 letters in the Kawaba alphabet, which have the same pronunciation as in the International Phonetic Alphabet.</p>
<div class="buttons" style="justify-content: center">
<audio id="a" src="../audio/a.ogg" preload="auto"></audio>
Expand Down Expand Up @@ -88,11 +96,14 @@ <h3>consonants</h3>
<div class="title-box">
<h3>syllables</h3>
</div>
<p>A syllable in Kawaba consists of at least a vowel, which may be preceded by a consonant or followed by an <b>n</b>. Stress always falls on the first syllable of a word, and any syllable following a hyphen.</p>
<p>
A syllable in Kawaba consists of at least a vowel, which may be preceded by a consonant or followed by an <b>n</b>. Stress always falls on the first syllable of a word, as well as any syllable following a hyphen.
A stressed syllable is pronounced with a higher pitch and volume than the surrounding syllables.
</p>
<div class="buttons">
<a class="button" href="/lessons"><h3>previous</h3></button>
<a class="button" href="/lessons"><h3>lessons</h3></button>
<a class="button" href="/lessons/2"><h3>next</h3></button>
<a class="button" href="/lessons/1"><h3>next</h3></button>
</div>
</div>
</body>
Expand Down
Loading

0 comments on commit 55fd009

Please sign in to comment.