-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjavascript.js
90 lines (75 loc) · 2.38 KB
/
javascript.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
javascript.js
*/
//Top Script
//Get the button
var mybutton = document.getElementById("myBtn");
// When the user scrolls down 1000px from the top of the document, show the button
window.onscroll = function () { scrollFunction() };
function scrollFunction() {
if (document.body.scrollTop > 1000 || document.documentElement.scrollTop > 1000) {
mybutton.style.display = "block";
} else {
mybutton.style.display = "none";
}
}
// When the user clicks on the button, scroll to the top of the document
function topFunction() {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
}
//Settings Script
/* When the user clicks on the button,
toggle between hiding and showing the dropdown content */
function myFunction() {
document.getElementById("myDropdown").classList.toggle("show");
}
// Close the dropdown if the user clicks outside of it
window.onclick = function (event) {
if (!event.target.matches('.setting')) {
var dropdowns = document.getElementsByClassName("setting-content");
var i;
for (i = 0; i < dropdowns.length; i++) {
var openDropdown = dropdowns[i];
if (openDropdown.classList.contains('show')) {
openDropdown.classList.remove('show');
}
}
}
}
function invertcolorFunction() {
var element = document.body;
element.classList.toggle("invert-color");
}
//Esami Universitari
function ANNOSCOLASTICO(evt, cityName) {
var i, tabcontent, tablinks;
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
document.getElementById(cityName).style.display = "block";
evt.currentTarget.className += " active";
}
// COUNTER VIEW
var counterContainer = document.querySelector(".website-counter");
var visitCount = localStorage.getItem("page_views");
// Check if page_view entry is present
if (visitCount) {
visitCount = Number(visitCount) + 1;
localStorage.setItem("page_views", visitCount);
}
else {
visitCount = 1;
localStorage.setItem("page_views", 1);
}
if (visitCount == 1) {
counterContainer.innerHTML = visitCount + " TIME";
}
else {
counterContainer.innerHTML = visitCount + " TIMES";
}