Initial commit
This commit is contained in:
BIN
INFO-1272 (JS 1)/JavaScript.pdf
Normal file
BIN
INFO-1272 (JS 1)/JavaScript.pdf
Normal file
Binary file not shown.
BIN
INFO-1272 (JS 1)/Labs/Lab 1/Lab1.pdf
Normal file
BIN
INFO-1272 (JS 1)/Labs/Lab 1/Lab1.pdf
Normal file
Binary file not shown.
35
INFO-1272 (JS 1)/Labs/Lab 1/Levi_Lab1.html
Normal file
35
INFO-1272 (JS 1)/Labs/Lab 1/Levi_Lab1.html
Normal file
@@ -0,0 +1,35 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>Lab 2</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Lab 2</h1>
|
||||
<script>
|
||||
/*
|
||||
* Name: Levi McLean
|
||||
* Project: Lab 1
|
||||
* Submission date: September 18th, 2025
|
||||
*/
|
||||
|
||||
var studentName; //unassigned variable
|
||||
do {
|
||||
studentName = prompt("Enter the student's name: "); //prompt for name, assign variable with value
|
||||
if (studentName === null || studentName.trim() === "") {
|
||||
alert("Please enter a student name");
|
||||
}
|
||||
} while (studentName === null || studentName.trim() === "");
|
||||
alert("Thank you for your entry!"); //Pop up message alert
|
||||
sessionStorage.setItem("Student Name", studentName);
|
||||
|
||||
const welcomeText = "Welcome to INFO-1272 Fall 2025 "; //set const welcomeText
|
||||
const nameText = `You are ${sessionStorage.getItem("Student Name")}`;
|
||||
document.write(welcomeText); //write const welcomeText
|
||||
document.write("<br>");
|
||||
document.write(nameText);
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
BIN
INFO-1272 (JS 1)/Labs/Lab 1/Levi_Lab1.zip
Normal file
BIN
INFO-1272 (JS 1)/Labs/Lab 1/Levi_Lab1.zip
Normal file
Binary file not shown.
BIN
INFO-1272 (JS 1)/Labs/Lab 3/Lab 3.pdf
Normal file
BIN
INFO-1272 (JS 1)/Labs/Lab 3/Lab 3.pdf
Normal file
Binary file not shown.
61
INFO-1272 (JS 1)/Labs/Lab 3/Levi_Lab3.html
Normal file
61
INFO-1272 (JS 1)/Labs/Lab 3/Levi_Lab3.html
Normal file
@@ -0,0 +1,61 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Lab 3</title>
|
||||
<meta charset="UTF-8">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Lab 3</h1>
|
||||
<script>
|
||||
/*
|
||||
* I have decided to declare my fortune messages in order of
|
||||
* most-to-least positive
|
||||
*/
|
||||
var fortune1 = "You will have a great day";
|
||||
var fortune2 = "Success if around the corner";
|
||||
var fortune3 = "Happiness comes from within";
|
||||
var fortune4 = "Today will be okay";
|
||||
var fortune5 = "Keep an eye on the details";
|
||||
var fortune6 = "Patience will be tested";
|
||||
var fortune7 = "You will step on LEGO soon";
|
||||
var fortune8 = "Beware of pigeons, they have attitude";
|
||||
var fortune9 = "Your WIFI will mysteriously stop working";
|
||||
|
||||
// Prompt user for numCookies
|
||||
var numCookies = window.prompt("How many cookies do you want to open?");
|
||||
|
||||
// Loop starting at 1, stoping at numCookies
|
||||
for (var i = 1; i <=numCookies; i++) {
|
||||
|
||||
// Generate random number from 1 - 9 inclusive
|
||||
var randNum = Math.floor(Math.random() * 9) + 1;
|
||||
|
||||
// Assign messge and cateogry to blank for now
|
||||
var message = ""
|
||||
var category = ""
|
||||
|
||||
// Determine message and category from randNum
|
||||
if (randNum <= 3) {
|
||||
if (randNum === 1) message = fortune1;
|
||||
else if (randNum === 2) message = fortune2;
|
||||
else message = fortune3;
|
||||
category = "Positive"; // Positive if 1-3
|
||||
} else if (randNum <= 6) {
|
||||
if (randNum === 4) message = fortune4;
|
||||
else if (randNum === 5) message = fortune5;
|
||||
else message = fortune6;
|
||||
category = "Neutral"; // Neutral if 4-6
|
||||
} else {
|
||||
if (randNum === 7) message = fortune7;
|
||||
else if (randNum === 8) message = fortune8;
|
||||
else message = fortune9;
|
||||
category = "Funny" // Funny if 7-9
|
||||
}
|
||||
|
||||
// Display fortune cookie details
|
||||
console.log("Cookie #" + i + "\nMessage: " + message + "\nCategory: " + category);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
BIN
INFO-1272 (JS 1)/Labs/Lab 3/Levi_Lab3.zip
Normal file
BIN
INFO-1272 (JS 1)/Labs/Lab 3/Levi_Lab3.zip
Normal file
Binary file not shown.
34
INFO-1272 (JS 1)/Notes/Week 1/index.html
Normal file
34
INFO-1272 (JS 1)/Notes/Week 1/index.html
Normal file
@@ -0,0 +1,34 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Week 1 Class 1</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Javascript test</h1>
|
||||
<script>
|
||||
document.write("Hello Class, Welcome to JavaScript <br>");
|
||||
document.write("I love JavaScript");
|
||||
|
||||
document.write("Hello Class, Welcome to JavaScript")
|
||||
document.write("<br>");
|
||||
document.write("I love JavaScript <br>");
|
||||
|
||||
window.alert("ALERT ALERT ALERT ALERT");
|
||||
window.confirm("CONFIRM PLEASE CONFIRM PLEASE");
|
||||
window.prompt("PROMPT HERE PROMPT HERE");
|
||||
</script>
|
||||
<button type="submit" id="testButton" onclick="testButton()">
|
||||
<p>Press me!</p>
|
||||
</button>
|
||||
<p id="buttonLabel">Button pressed!</p>
|
||||
<hr>
|
||||
<h2>Form example</h2>
|
||||
<input type="text" id="firstName" placeholder="First name">
|
||||
<input type="text" id="lastName" placeholder="Last name">
|
||||
<input type="email" id="email" placeholder="Email">
|
||||
<input type="text" id="phone" placeholder="Phone number">
|
||||
<p id="formLabel">You entered: </p>
|
||||
<button type="submit" id="repeatButton" onclick="repeatInfo()">Repeat Info</button>
|
||||
<script src="index.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
19
INFO-1272 (JS 1)/Notes/Week 1/index.js
Normal file
19
INFO-1272 (JS 1)/Notes/Week 1/index.js
Normal file
@@ -0,0 +1,19 @@
|
||||
document.getElementById("buttonLabel").style.display = "none";
|
||||
|
||||
function testButton() {
|
||||
const buttonLabel = document.getElementById("buttonLabel");
|
||||
if (buttonLabel.style.display === "block") {
|
||||
buttonLabel.style.display = "none";
|
||||
} else {
|
||||
buttonLabel.style.display = "block";
|
||||
}
|
||||
}
|
||||
|
||||
function repeatInfo() {
|
||||
const formLabel = document.getElementById("formLabel");
|
||||
const firstName = document.getElementById("firstName").value;
|
||||
const lastName = document.getElementById("lastName").value;
|
||||
const email = document.getElementById("email").value;
|
||||
const phone = Number(document.getElementById("phone").value);
|
||||
formLabel.innerHTML += `${firstName} ${lastName}, ${email}, ${phone}`
|
||||
}
|
||||
18
INFO-1272 (JS 1)/Notes/Week 2/index.html
Normal file
18
INFO-1272 (JS 1)/Notes/Week 2/index.html
Normal file
@@ -0,0 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Week 3 Class 1</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Week 3 Class 1</h1>
|
||||
<p>Enter some details</p>
|
||||
<input id="firstNameBox" type="text" placeholder="First Name">
|
||||
<input id="lastNameBox" type="text" placeholder="Last Name">
|
||||
<input id="ageBox" type="number" placeholder="Age">
|
||||
<input id="passwordBox" type="password" placeholder="Password">
|
||||
<button type="submit" onclick="showDetails()">Submit</button>
|
||||
<p id="detailsLabel">Entered Details: </p>
|
||||
<script src="index.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
14
INFO-1272 (JS 1)/Notes/Week 2/index.js
Normal file
14
INFO-1272 (JS 1)/Notes/Week 2/index.js
Normal file
@@ -0,0 +1,14 @@
|
||||
function showDetails() {
|
||||
var firstName = document.getElementById("firstNameBox").value;
|
||||
var lastName = document.getElementById("lastNameBox").value;
|
||||
var age = Number(document.getElementById("ageBox").value);
|
||||
var password = document.getElementById("passwordBox").value;
|
||||
console.log(`You entered: ${firstName}, ${lastName}, ${age}, ${password}`);
|
||||
document.getElementById("detailsLabel").innerHTML += `${firstName}, ${lastName}, ${age}, ${password}`;
|
||||
|
||||
console.log(10 + 10);
|
||||
console.log(10 * 10);
|
||||
console.log(10 - 3);
|
||||
console.log(100 / 25);
|
||||
console.log(100 % 3);
|
||||
}
|
||||
Reference in New Issue
Block a user