-
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.
Merge pull request #1 from migtarx/dev
Dev
- Loading branch information
Showing
8 changed files
with
214 additions
and
28 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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
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 |
---|---|---|
@@ -1,39 +1,38 @@ | ||
let clockEl = document.getElementById("clockDiv"); | ||
let msg = document.getElementById("welcome-msg"); | ||
const langData = [['Nueva configuración','Buenos días','Buenas tardes','Buenas noches'],['Konfigurazio berria','Egun on','Arratsalde on','Gau on'],['New Configuration','Good morning','Good afternoon','Good evening']] | ||
var clockEl = document.getElementById("clockDiv"); | ||
var msg = document.getElementById("welcome-msg"); | ||
checkFirstTime() | ||
document.getElementById("lowerleft").textContent = langData[localStorage.getItem("lang")][0]; | ||
|
||
function getClockTime() { | ||
let date = new Date(); | ||
var date = new Date(); | ||
|
||
let hr = date.getHours(); | ||
let min = date.getMinutes(); | ||
var hr = date.getHours(); | ||
var min = date.getMinutes(); | ||
|
||
hr = ("0" + hr).slice(-2); | ||
min = ("0" + min).slice(-2); | ||
|
||
function getDayZone() { | ||
if (hr < 12) { | ||
return "morning"; | ||
return langData[localStorage.getItem("lang")][1]; | ||
} else if (hr < 18) { | ||
return "afternoon"; | ||
return langData[localStorage.getItem("lang")][2]; | ||
} else { | ||
return "evening"; | ||
return langData[localStorage.getItem("lang")][3]; | ||
} | ||
} | ||
|
||
async function postData(url = '', data = {}) { | ||
const response = await fetch(url, { | ||
method: 'POST', | ||
body: JSON.stringify(data) | ||
}); | ||
return response.json(); | ||
} | ||
|
||
clockEl.innerHTML = `${hr}:${min}`; | ||
postData("../config.json", { | ||
answer: 42 | ||
}) | ||
.then(data => { | ||
msg.innerHTML = `Good ${getDayZone()} ${data.name}` | ||
}); | ||
msg.innerHTML = `${getDayZone()} ${localStorage.getItem("username")}` | ||
} | ||
function checkFirstTime(){ | ||
if (typeof(Storage) !== "undefined") { | ||
if (localStorage.getItem("username") === null) { | ||
location.href = 'name.html'; | ||
} | ||
} else { | ||
document.getElementById("result").innerHTML = "Sorry, your browser does not support Web Storage..."; | ||
} | ||
} | ||
setInterval(getClockTime, 0); |
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,62 @@ | ||
var elementIsClicked = false; | ||
var inputSelectedLang = document.getElementById("selectedLang"); | ||
var selectedLang = -1; | ||
inputSelectedLang.disabled = true; | ||
|
||
|
||
// NAME SELECTION SCREEN | ||
function clickConfirm() { | ||
elementIsClicked = true; | ||
var input_name = document.getElementById("username"); | ||
if (input_name.value == "") { | ||
input_name.classList.add("error-shake"); | ||
setTimeout(function() { | ||
input_name.classList.remove("error-shake"); | ||
}, 1000); | ||
} else { | ||
localStorage.setItem("username", document.getElementById("username").value); | ||
document.getElementById("pick-username").style.display = "none"; | ||
document.getElementById("pick-username2").style.display = "block"; | ||
} | ||
} | ||
var element = document.getElementById("confirm"); | ||
element.addEventListener("click", clickConfirm); | ||
|
||
|
||
// LANG SELECTION SCREEN | ||
var langBtns = document.getElementsByClassName("lang"); | ||
for (var i = 0; i < langBtns.length; i++) { | ||
langBtns[i].addEventListener('click', function(event) { | ||
switch (event.target.innerHTML) { | ||
case "ES": | ||
inputSelectedLang.setAttribute('value', "Has selecionado Español"); | ||
selectedLang = 0; | ||
break; | ||
case "EU": | ||
inputSelectedLang.setAttribute('value', "Euskara hautatu duzu"); | ||
selectedLang = 1; | ||
break; | ||
default: | ||
inputSelectedLang.setAttribute('value', "You have selected English"); | ||
selectedLang = 2; | ||
break; | ||
} | ||
}) | ||
} | ||
|
||
function clickConfirmLang() { | ||
elementIsClicked = true; | ||
var inputLang = document.getElementById("selectedLang"); | ||
if (inputLang.value == "" || inputLang.value == "Select your prefered language") { | ||
inputLang.classList.add("error-shake"); | ||
inputSelectedLang.setAttribute('value', "Select your prefered language"); | ||
setTimeout(function() { | ||
inputLang.classList.remove("error-shake"); | ||
}, 1000); | ||
} else { | ||
localStorage.setItem("lang", selectedLang); | ||
location.href = "index.html"; | ||
} | ||
} | ||
var element = document.getElementById("confirmLang"); | ||
element.addEventListener("click", clickConfirmLang); |
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
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,29 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>New Tab- First set up</title> | ||
<link rel="stylesheet" href="css/main.css" /> | ||
</head> | ||
<body> | ||
<body> | ||
<h1>First set up</h1> | ||
<div id="pick-username"> | ||
<input id="username" type="text" class="ghost-input" placeholder="My name is..." required style="margin-top: 45%" /> | ||
<a class="btn btn-white" id="confirm">Confirm</a> | ||
</div> | ||
<div id="pick-username2" style="display: none"> | ||
<input id="selectedLang" type="text" class="ghost-input" placeholder="Select your prefered language" required style="margin-top: 45%"/> | ||
<a class="btn btn-white" id="confirmLang" style="float: right;">Confirm</a> | ||
<div class="lang"> | ||
<a class="btn btn-white" id="es">ES</a> | ||
<a class="btn btn-white" id="eu">EU</a> | ||
<a class="btn btn-white" id="en">EN</a> | ||
</div> | ||
</div> | ||
<script src="js/set-up.js"></script> | ||
</body> | ||
</body> | ||
</html> |