-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
155 lines (140 loc) · 3.91 KB
/
script.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/* var x = 5;
var y = 7;
var z = x + y;
console.log(z);
var A = 'Hello';
var B = ' world!';
var C = A + B;
console.log(C);
function SumNPrint(x1, x2) {
var x3 = x1 + x2;
console.log(x3);
}
SumNPrint(x,y);
SumNPrint(A,B);
if (C.length > z) {
console.log(C);
} else if (z > C.length) {
console.log(z);
} else {
console.log("good job!");
}
var L1 = ["Watermelon", "Pineapple", "Pear", "Banana"];
var L2 = ["Apple", "Banana", "Kiwi", "Orange"];
function findTheBanana(array) {
for (let index = 0; index < array.length; index++) {
const element = array[index];
if (element === "Banana") {
alert("found the Banana in " + index);
}
}
}
findTheBanana(L1);
findTheBanana(L2);
L1.forEach(element => {
if (element === "Banana") {
alert("We found a banana in the first array");
}
});
L2.forEach(element => {
if (element === "Banana") {
alert("We found a banana in the second array");
}
});
function greetingFunc() {
var d = new Date();
var h = d.getHours();
if (h >= 5 && h < 12) {
console.log("Good morning!");
} else if (h >= 12 && h < 18) {
console.log("Good afternoon!");
} else if (h >= 18 && h < 20) {
console.log("Good evening");
} else if (h >= 20 && h < 24 || h < 5) {
console.log("Good night!");
}
}
greetingFunc(); */
function greetingFunc() {
var d = new Date();
var h = d.getHours();
var E = document.getElementById("greeting");
if (h >= 5 && h < 12) {
E.innerHTML = "Good morning, I am Opally";
} else if (h >= 12 && h < 18) {
E.innerHTML = "Good afternoon, I am Opally";
} else if (h >= 18 && h < 20) {
E.innerHTML = "Good evening, I am Opally";
} else if (h >= 20 && h < 24 || h < 5) {
E.innerHTML = "Good night, I am Opally";
}
}
function addYear() {
var d= new Date();
var y = d.getFullYear();
var E = document.getElementById("copyYear");
E.innerHTML+= y;
}
/*
function showList() {
document.getElementById("FavList").style.display = "block";
document.getElementById("SeeMoreBTN").style.display = "none";
}
*/
$("#readLess").click(function(){
$("#longIntro").hide();
$("#readLess").hide();
$("#readMore").show();
});
$("#readMore").click(function(){
$("#longIntro").show();
$("#readLess").show();
$("#readMore").hide();
});
function validate() {
var userName = document.getElementById("name");
var userEmail = document.getElementById("email");
var userText = document.getElementById("comment");
var msg = document.getElementById("ValidateMsg");
if (!userName.checkValidity() || !userEmail.checkValidity() || !userText.checkValidity()) {
msg.innerHTML = "Please fill out the form correctly so I can get back to you :)";
}
}
/*
// Initialize and add the map
let map;
async function initMap() {
// The location of CMU
const position = { lat:40.44327551447266, lng:-79.94288336448541 };
// Request needed libraries.
//@ts-ignore
const { Map } = await google.maps.importLibrary("maps");
const { AdvancedMarkerElement } = await google.maps.importLibrary("marker");
// The map, centered at CMU
map = new Map(document.getElementById("map"), {
zoom: 12,
center: position,
mapId: "DEMO_MAP_ID",
});
// The marker, positioned at CMU
const marker = new AdvancedMarkerElement({
map: map,
position: position,
title: "CMU",
});
}
*/
/* Run only for specific page */
var L = window.location.href;
console.log(L);
if (L.includes("index.html")) {
greetingFunc();
}
function activeNav() {
var x = document.getElementById("myTopnav");
if (x.className === "topnav") {
x.className += " responsive";
} else {
x.className = "topnav";
}
}