Skip to content

Commit

Permalink
Merge pull request #1 from migtarx/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
migtarx authored Mar 18, 2022
2 parents 6e3d0e2 + 633bc7b commit bc9c6f2
Show file tree
Hide file tree
Showing 8 changed files with 214 additions and 28 deletions.
3 changes: 0 additions & 3 deletions config.json

This file was deleted.

101 changes: 100 additions & 1 deletion css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,103 @@ body {
font-family: monospace;
text-align: center;
margin-top: 57vh;
}
}

/* Space out content a bit */
body {
color: white;
background-color: black;
width: 800px;
margin: 0 auto;
font-family: monospace;
}
.ghost-input {
border-bottom:1px solid rgb(255, 255, 255) !important;
display: block;
font-weight:300;
width: 100%;
font-size: 25px;
border:0px;
outline: none;
width: 100%;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
color: #fcfcfc;
background: rgb(0, 0, 0);
font-family: monospace;
padding: 10px 15px;
margin: 30px 0px;
}
h1{
font-family: Open 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
font-size: 40px;
text-align: center;
}
/*BUTTONS */
.btn, input[type="submit"]{
cursor: pointer;
border-radius: 0px;
text-decoration: none;
padding: 12px 18px;
font-size: 12px;
line-height: 19px;
text-transform: uppercase;
font-family: monospace;
letter-spacing: 3px;
-webkit-transition: all .4s ease-in-out;
-moz-transition: all .4s ease-in-out;
-ms-transition: all .4s ease-in-out;
-o-transition: all .4s ease-in-out;
transition: all .4s ease-in-out;
}
.btn-white{
border:solid 2px #fff;
background: transparent;
color: #fff !important;
}
.btn-white:hover{
border:solid 2px #fff;
background: #fff;
color: #1f1f1f !important;
}

.error-shake{
animation: shake 0.82s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
10%, 90% {
transform: translate3d(-1px, 0, 0);
}

20%, 80% {
transform: translate3d(2px, 0, 0);
}

30%, 50%, 70% {
transform: translate3d(-4px, 0, 0);
}

40%, 60% {
transform: translate3d(4px, 0, 0);
}
}

#lowerleft
{
text-decoration: none;
font-size: 16px;
position: absolute;
bottom: 10px;
left: 10px;
}

.center {
margin: 0;
position: absolute;
top: 50%;
left: 50%;
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
Binary file added fonts/metropolis.semi-bold.otf
Binary file not shown.
2 changes: 1 addition & 1 deletion new-tab.html → index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<body>
<div id="clockDiv"></div>
<h1 id="welcome-msg"></h1>
<a href="name.html" id="lowerleft" style="color: white;"></a>
<script src="js/main.js"></script>
<script src="config.json"></script>
</body>
</html>
43 changes: 21 additions & 22 deletions js/main.js
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);
62 changes: 62 additions & 0 deletions js/set-up.js
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);
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "1",
"incognito": "split",
"chrome_url_overrides": {
"newtab": "new-tab.html"
"newtab": "index.html"
},
"manifest_version": 2
}
29 changes: 29 additions & 0 deletions name.html
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>

0 comments on commit bc9c6f2

Please sign in to comment.