Created
June 21, 2019 02:26
-
-
Save sunsetsonwheels/8784aa5b790c79714031cdc3853a67d4 to your computer and use it in GitHub Desktop.
[KaiOS] I can't navigate the option menu!
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1"> | |
<title>Runner</title> | |
<link rel="stylesheet" href="/css/window.css"/> | |
<link rel="stylesheet" href="/css/home.css"/> | |
<link rel="manifest" href="/manifest.webapp"/> | |
<link rel="localization" href="/locales/runner.{locale}.properties"/> | |
<script src="/js/lib/l10n.js" charset="utf-8"></script> | |
<head> | |
<body> | |
<header class="header"> | |
<div class="header-textbox"> | |
<h1 data-l10n-id="app-header" class="header-text">L10N_ERROR</h1> | |
</div> | |
</header> | |
<section class="middle"> | |
<h3 data-l10n-id="label-date" class="label-date">Date:</h3> | |
<section class="container-indicator-distance"> | |
<h1 class="indicator-statistics-distance">000</h1> | |
<h3 class="indicator-unit-distance">km</h3> | |
</section> | |
<section class="container-indicator-speed"> | |
<h1 class="indicator-statistics-speed">00</h1> | |
<h3 class="indicator-unit-speed">km/h</h3> | |
</section> | |
<h5 class="label-gps">GPS accuracy: 5m</h5> | |
</section> | |
<div id="optionMenu" class="kui-option-menu"> | |
<h2 data-l10n-id="home-options-title" class="kui-pri kui-option-title">Option Menu</h2> | |
<ul class="kui-options"> | |
<li data-l10n-id="home-options-maps" id="option-0">Option 1</li> | |
<li data-l10n-id="home-options-settings" id="option-1">Option 2</li> | |
<li data-l10n-id="home-options-exit" id="option-2">Option 3</li> | |
<li data-l10n-id="home-options-donate" id="option-3">Option 4</li> | |
</ul> | |
</div> | |
<footer class="softkeys"> | |
<div id="softkey-left" data-l10n-id="home-softkey-history" class="softkey-left">ERR</div> | |
<div id="softkey-center" data-l10n-id="home-softkey-track" class="softkey-center">ERROR</div> | |
<div id="softkey-right"data-l10n-id="home-softkey-options" class="softkey-right">ERR</div> | |
</footer> | |
</body> | |
<script src="/js/home/home.js"></script> | |
</html> |
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
var optionMenuOpen = false; | |
var optionMenuIndex = 0; | |
document.addEventListener("DOMContentLoaded", () => { | |
}); | |
function navOptionMenu(direction) { | |
if(optionMenuOpen) { | |
for(i = 0; i < 4; i++) { | |
document.getElementById("option"+i).blur(); | |
} | |
switch(direction) { | |
case 'up': | |
if (optionMenuIndex < 0) { | |
optionMenuIndex = 3 | |
} | |
break; | |
case 'down': | |
if (optionMenuIndex > 3) { | |
optionMenuIndex = 0 | |
} | |
break; | |
} | |
document.getElementById("option"+optionMenuIndex).focus(); | |
} else { | |
console.log("Option menu not open!") | |
} | |
} | |
document.addEventListener("keydown", (e) => { | |
switch(e.key) { | |
case 'SoftLeft': | |
break; | |
case 'SoftRight': | |
if(!optionMenuOpen) { | |
document.getElementById("optionMenu").style.display = "inline"; | |
document.getElementById("softkey-left").textContent = ""; | |
navigator.mozL10n.setAttributes(document.getElementById("softkey-center"), | |
'global-softkey-select'); | |
document.getElementById("softkey-right").textContent = ""; | |
document.getElementById("option-0").focus(); | |
optionMenuOpen = true; | |
} | |
break; | |
case 'Up': | |
optionMenuIndex--; | |
if(optionMenuOpen) { | |
navOptionMenu('up'); | |
} | |
console.log(optionMenuIndex); | |
break; | |
case 'Down': | |
optionMenuIndex++; | |
if(optionMenuOpen) { | |
navOptionMenu('down'); | |
} | |
console.log(optionMenuIndex); | |
break; | |
case 'Backspace': | |
e.preventDefault(); | |
if(optionMenuOpen) { | |
document.getElementById("optionMenu").style.display = "none"; | |
navigator.mozL10n.setAttributes(document.getElementById("softkey-left"), | |
'home-softkey-history'); | |
navigator.mozL10n.setAttributes(document.getElementById("softkey-center"), | |
'home-softkey-track'); | |
navigator.mozL10n.setAttributes(document.getElementById("softkey-right"), | |
'home-softkey-options'); | |
optionMenuOpen = false; | |
optionMenuIndex = 0; | |
} else { | |
window.close(); | |
} | |
} | |
}); |
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
* { | |
box-sizing: border-box; | |
margin: 0; | |
padding: 0; | |
} | |
/* Header (a.k.a title bar of the application) */ | |
.header{ | |
height: 54px; | |
width: 100%; | |
background-color: #1E90FF; | |
} | |
.header-textbox { | |
position: relative; | |
top: 27px; | |
} | |
.header-text { | |
font-size: 17px; | |
color: #ffffff; | |
font-family: "Open Sans"; | |
font-weight: 300; | |
text-align: center; | |
} | |
/* This section adapted from Luxferre's OmniJB app. */ | |
/* Thanks a lot Luxferre! :) */ | |
.softkeys { | |
position: fixed; | |
bottom: 0; left: 0; | |
width: 100%; | |
height: 30px; | |
background: #dadada; | |
padding: 3px 5px; | |
} | |
.softkeys > * { | |
display: inline-block; | |
font-family: "Open Sans"; | |
width: 72px; | |
padding: 0 5px; | |
color: #323232; | |
} | |
.softkey-left, .softkey-right { | |
font-weight: 600; | |
font-size: 14px; | |
} | |
.softkey-left { | |
text-align: left; | |
} | |
.softkey-right { | |
text-align: right; | |
} | |
.softkey-center { | |
font-size: 16px; | |
font-weight: 700; | |
text-align: center; | |
} | |
.middle { | |
position: relative; | |
} | |
/* This section taken and adapted from KaiUI. */ | |
/* Thanks a bunch nadim1992! :) */ | |
.kui-option-menu { | |
width: 100%; | |
position: absolute; | |
overflow: hidden; | |
bottom: 30px; | |
display: none; | |
z-index: 1; | |
} | |
.kui-pri { | |
font-size: 17px; | |
font-weight: 400; | |
font-family: "Open Sans" | |
} | |
.kui-option-menu .kui-option-title { | |
margin: 0; | |
color: #323232; | |
text-align: center; | |
background-color: #d8d8d8; | |
height: 28px; | |
line-height: 28px; | |
} | |
.kui-options { | |
list-style: none; | |
margin: 0; | |
padding: 0; | |
overflow: hidden; | |
} | |
.kui-options li { | |
height: 50px; | |
line-height: 50px; | |
padding-left: 10px; | |
background-color: #fff; | |
font-family: "Open Sans" | |
} | |
.kui-options li:focus { | |
outline: 0; | |
color: #fff; | |
background-color: #1E90FF; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment