Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic language selector menu #91

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,26 @@ <h2 id="header">typings</h2>
</div>
<div id="right-wing">WPM: XX / ACC: XX</div>
</div>
<div id="typing-area">
<div id="typing-area" class="center-area">
<div id="text-display"></div>
<div class="bar">
<input id="input-field" type="text" spellcheck="false" autocomplete="off" autocorrect="off" autocapitalize="off" tabindex="1"/>
<button id="redo-button" onclick="setText(event)" tabindex="2">redo</button>
</div>
</div>
</div>
<div id="language-center" class="hidden">
<div id="left-wing" onClick="hideLanguageCenter();">< back</div>
<div id="language-area" class="center-area"></div>
</div>
<div id="theme-center" class="hidden">
<div id="left-wing" onClick="hideThemeCenter();">< back</div>
<div id="theme-area"></div>
<div id="theme-area" class="center-area"></div>
</div>
<div id="footer">
<a href="https://github.com/briano1905/typings#typings" target="_blank" tabindex="3">user guide</a>/
<div id="show-themes"class="button" onClick="showThemeCenter();" tabindex="4">themes</div>
<div id="show-languages"class="button" onClick="showLanguageCenter();" tabindex="4">language</div>/
<div id="show-themes"class="button" onClick="showThemeCenter();" tabindex="5">themes</div>
</div>
<script src="main.js"></script>
</body>
Expand Down
41 changes: 41 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,11 @@ document.addEventListener('keydown', e => {
if (e.key === 'p') {
setPunctuation(inputField.value);
}
} else if (!document.querySelector('#language-center').classList.contains('hidden')) {
if (e.key === 'Escape'){
hideLanguageCenter();
inputField.focus();
}
} else if (!document.querySelector('#theme-center').classList.contains('hidden')) {
if (e.key === 'Escape'){
hideThemeCenter();
Expand Down Expand Up @@ -307,6 +312,7 @@ function setLanguage(_lang) {
}

setText();
hideLanguageCenter();
} else {
console.error(`language ${lang} is undefine`);
}
Expand Down Expand Up @@ -391,6 +397,29 @@ function getCookie(cname) {
return '';
}

showAllLanguages();
function showAllLanguages() {
fetch(`texts/random.json`)
.then(response => {
if (response.status === 200) {
response
.text()
.then(body => {
let languages = JSON.parse(body);
let keys = Object.keys(languages);
let i;
for (i = 0; i < keys.length; i++) {
let language = document.createElement('div');
language.setAttribute('class', 'language-button')
language.setAttribute('onClick', `setLanguage('${keys[i]}')`)
language.textContent = keys[i];
document.getElementById('language-area').appendChild(language);
}
})
}
})
}

showAllThemes();
function showAllThemes(){
fetch(`themes/theme-list.json`)
Expand Down Expand Up @@ -446,7 +475,19 @@ document.getElementById('show-themes').addEventListener('keydown', (e) => {
}
});

function showLanguageCenter() {
hideThemeCenter();
document.getElementById('language-center').classList.remove('hidden');
document.getElementById('command-center').classList.add('hidden');
}

function hideLanguageCenter() {
document.getElementById('language-center').classList.add('hidden');
document.getElementById('command-center').classList.remove('hidden');
}

function showThemeCenter() {
hideLanguageCenter();
document.getElementById('theme-center').classList.remove('hidden');
document.getElementById('command-center').classList.add('hidden');
}
Expand Down
14 changes: 5 additions & 9 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,14 @@ body {
transform: translateY(-2vh);
}

#theme-area{
.center-area {
margin-top: 1rem;
padding: 1.4rem 1rem;
border-radius: 0.4rem;
background: #eaeaea;
}

#theme-area, #language-area {
display: grid;
grid-gap: 1rem;
grid-template-columns: 1fr 1fr 1fr 1fr;
Expand Down Expand Up @@ -73,13 +76,6 @@ body {

/* #right-wing {} */

#typing-area {
margin-top: 1rem;
padding: 1.4rem 1rem;
border-radius: 0.4rem;
background: #eaeaea;
}

#text-display {
margin-bottom: 1rem;
overflow: hidden;
Expand Down Expand Up @@ -127,7 +123,7 @@ body {
display: none !important;
}

body, #header, #left-wing, #right-wing, #typing-area, #theme-area, #theme-center,
body, #header, #left-wing, #right-wing, .center-area, #theme-center,
#text-display, #redo-button, #footer, #highlight {
transition: all .4s ease-in-out 0s;

Expand Down
5 changes: 2 additions & 3 deletions themes/1976.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ body {
color: #ffffff;
}

#typing-area,
#theme-area {
.center-area {
background: #5b3217;
}

Expand All @@ -52,7 +51,7 @@ body {
color: #ffffff;
}

#text-display {
#text-display, #language-area {
color: #5dcfb8;
}

Expand Down
4 changes: 2 additions & 2 deletions themes/8008.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ body {
color: #f44c7f;
}

#typing-area, #theme-area{
.center-area{
background: #a2aebd;
}

#text-display {
#text-display, #language-area {
color: #3c4756;
}

Expand Down
4 changes: 2 additions & 2 deletions themes/9009.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ body {
color: #2e2f33;
}

#typing-area, #theme-area {
.center-area {
background: #d9d2c8;
}

#text-display {
#text-display, #language-area {
color: #2e2f33;
}

Expand Down
5 changes: 2 additions & 3 deletions themes/Leviathan.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ body {
color: #BAEE75;
}

#typing-area,
#theme-area {
.center-area {
background: #BAEE75;
}

#text-display {
#text-display, #language-area {
color: #182031;
}

Expand Down
4 changes: 2 additions & 2 deletions themes/aurora.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ body {
color: #fafafa;
}

#typing-area, #theme-area {
.center-area {
background: rgba(250, 250, 250, 0.6);
backdrop-filter: blur(1rem);
}

#text-display {
#text-display, #language-area {
color: #1a1a1a;
}

Expand Down
4 changes: 2 additions & 2 deletions themes/burgundy.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ body {
color: #fafafa;
}

#typing-area, #theme-area {
.center-area {
background: #691f28;
}

#text-display {
#text-display, #language-area {
color: #fafafa;
}

Expand Down
4 changes: 2 additions & 2 deletions themes/carbon.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ body {
color: #ed6b21;
}

#typing-area, #theme-area {
.center-area {
background: #e3d9c6;
}

#text-display {
#text-display, #language-area {
color: #575d5e;
}

Expand Down
4 changes: 2 additions & 2 deletions themes/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ body {
color: #fafafa;
}

#typing-area, #theme-area {
.center-area {
background: #333333;
}

#text-display {
#text-display, #language-area {
color: #fafafa;
}

Expand Down
4 changes: 2 additions & 2 deletions themes/denim.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ body {
color: #e3d5b9;
}

#typing-area, #theme-area {
.center-area {
background: #687796;
}

#text-display {
#text-display, #language-area {
color: #e3d5b9;
}

Expand Down
4 changes: 2 additions & 2 deletions themes/dots.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ body {
color: #ffd751;
}

#typing-area, #theme-area {
.center-area {
background: #232533;
}

#text-display {
#text-display, #language-area {
color: #fafafa;
}

Expand Down
4 changes: 2 additions & 2 deletions themes/dracula.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ body {
color: #bd93f9;
}

#typing-area, #theme-area {
.center-area {
background: #44475a;
}

#text-display {
#text-display, #language-area {
color: #f8f8f2;
}

Expand Down
4 changes: 2 additions & 2 deletions themes/eclipse.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ body {
color: #abc6dc;
}

#typing-area, #theme-area {
.center-area {
background: #3a3a3a;
}

#text-display {
#text-display, #language-area {
color: #abc6dc;
}

Expand Down
5 changes: 2 additions & 3 deletions themes/godspeed.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ body {
color: #e5e8e6;
}

#typing-area,
#theme-area {
.center-area {
background: #eae3d5;
}

#text-display {
#text-display, #language-area {
color: #575d5e;
}

Expand Down
4 changes: 2 additions & 2 deletions themes/gruvbox.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ body {
color: #ebdbb2;
}

#typing-area, #theme-area {
.center-area {
background: #1d2021;
}

#text-display {
#text-display, #language-area {
color: #ebdbb2;
}

Expand Down
4 changes: 2 additions & 2 deletions themes/handarbeit.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ body {
color: #147d36;
}

#typing-area, #theme-area {
.center-area {
background: #bb2e17;
}

#text-display {
#text-display, #language-area {
color: #fafafa;
}

Expand Down
5 changes: 2 additions & 3 deletions themes/honeywell.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ body {
color: #e5e8e6;
}

#typing-area,
#theme-area {
.center-area {
background: #f7f7f7;
}

#text-display {
#text-display, #language-area {
color: #575d5e;
}

Expand Down
4 changes: 2 additions & 2 deletions themes/hyperfuse.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ body {
color: #25cdc5;
}

#typing-area, #theme-area {
.center-area {
background: #d4d4d4;
}

#text-display {
#text-display, #language-area {
color: #555761;
}

Expand Down
Loading