reformat and cleanup js code

git-svn-id: svn+ssh://atelier.inf.usi.ch/home/bevilj/group-1@221 a672b425-5310-4d7a-af5c-997e18724b81
This commit is contained in:
bevilj 2018-11-15 20:54:09 +00:00
parent 2351af8a62
commit ff4d47d64c
2 changed files with 113 additions and 100 deletions

View File

@ -60,7 +60,9 @@
}); });
}); });
var sentence =["<span class='NotoSansLight'>t", "h", "e</span>", "<span class='NotoSansBold'>s", "h", "e", "l", "l</span>"]; // Animated logo
var sentence = ["<span class='NotoSansLight'>t", "h", "e</span>",
"<span class='NotoSansBold'>s", "h", "e", "l", "l</span>"];
var shell = ""; var shell = "";
var counter = 0; var counter = 0;
@ -71,26 +73,27 @@
} else { } else {
document.getElementById("blikli").classList.add("bli"); document.getElementById("blikli").classList.add("bli");
} }
} }
setInterval( setInterval(typing_shell, 200);
typing_shell
, 200);
function write(position){ function write(position){
shell = shell + sentence[position]; shell = shell + sentence[position];
document.getElementById("title-home").innerHTML = shell; document.getElementById("title-home").innerHTML = shell;
} }
var isChrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor); var isChrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor);
if (!isChrome) { if (!isChrome) {
document.getElementById('foolChrome').remove(); document.getElementById('foolChrome').remove();
// Mute and play
var homeVideo = document.getElementById('videoHome'); var homeVideo = document.getElementById('videoHome');
// Try and see if we can play with audio, otherwise mute the video
try {
homeVideo.play(); homeVideo.play();
} catch (err) {
homeVideo.muted = true;
homeVideo.play();
}
} }
</script> </script>

View File

@ -31,39 +31,49 @@
}); });
}); });
var bdy = document.getElementById("bdy");
document.addEventListener("keypress", function(event) { document.addEventListener("keypress", function(event) {
if(event.key == "w" || event.key == "k"){ switch (event.key) {
case "w":
case "k":
window.scrollTo (0,0); window.scrollTo (0,0);
}else if(event.key == "~"){ break;
location.href = "{{ site.baseurl }}/"; case "a":
}else if(event.key == "a" || event.key == "h"){ case "h":
var previous = "{{ site.baseurl }}/{{ page.previous-page }}"; var previous = "{{ page.previous-page }}";
if (previous) { if (previous) {
location.href = previous; location.href = "{{ site.baseurl }}/" + previous;
} }
}else if(event.key == "d" || event.key == "l"){ break;
var next = "{{ site.baseurl }}/{{ page.next-page }}"; case "d":
case "l":
var next = "{{ page.next-page }}";
if (next) { if (next) {
location.href = next; location.href = "{{ site.baseurl }}/" + next;
} }
}else if(event.key == "s" || event.key == "j"){ break;
var topic; case "s":
switch("{{ page.category-page }}"){ case "j":
var topicPage;
var topic = "{{ page.category-page }}";
switch (topic) {
case "basic": case "basic":
topic = "{{ site.baseurl }}/pages/topic/cmd/basic.html";
case "intermediate": case "intermediate":
topic = "{{ site.baseurl }}/pages/topic/cmd/intermediate.html";
case "advanced": case "advanced":
topic = "{{ site.baseurl }}/pages/topic/cmd/advanced.html"; topicPage = "{{ site.baseurl }}/pages/topic/cmd/" + topic + ".html";
break;
case "fs": case "fs":
topic = "{{ site.baseurl }}/pages/topic/fs.html";
case "scripts": case "scripts":
topic = "{{ site.baseurl }}/pages/topic/scripts.html"; topicPage = "{{ site.baseurl }}/pages/topic/" + topic + ".html";
}; break;
if (topic){
location.href = topic;
} }
if (topicPage) {
location.href = topicPage;
}
break;
case "~":
location.href = "{{ site.baseurl }}/";
break;
} }
}); });
</script> </script>