Skip to content
This repository was archived by the owner on Jan 3, 2023. It is now read-only.

Deniz-JavaScript2-Week3 #74

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion Week-3/Homework/mandatory/1-alarmclock/alarmclock.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,45 @@
function setAlarm() {}

function setAlarm() {
//Selectors
let inputValue=document.getElementById("alarmSet");
let timer=inputValue.value;
let timeRemaining=document.querySelector("#timeRemaining");


let stopButton=document.querySelector("#stop");
//eventListener


let clock =setInterval(countDown,1000);

function countDown(){


if (timer<0){
inputValue.value="";
playAlarm();
}
else {
if (timer>=10){
timeRemaining.textContent=`time Remaining: 00:${timer}`;
timer--;

}
else{
timeRemaining.textContent=`time Remaining: 00:0${timer}`;
timer--;
}
}
}

stopButton.addEventListener("click", () => {
clearInterval(clock);
pauseAlarm();
});



}

// DO NOT EDIT BELOW HERE

Expand Down
2 changes: 1 addition & 1 deletion Week-3/Homework/mandatory/1-alarmclock/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<title>Alarm Clock</title>
<script src="alarmclock.js"></script>
<script defer src="alarmclock.js"></script>
<link
rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
Expand Down
11 changes: 10 additions & 1 deletion Week-3/Homework/mandatory/2-quotegenerator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<title>Quote Generator</title>
<script src="quotes.js"></script>
<script defer src="quotes.js"></script>
<link
rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
Expand All @@ -13,5 +13,14 @@
</head>
<body>
<!-- Write your HTML in here -->
<div>
<h1 id="myH1">
test quote </h1>
<p id="myP"> test autor</p>
<button id="myButton">
Next Quote
</button>
</div>

</body>
</html>
11 changes: 11 additions & 0 deletions Week-3/Homework/mandatory/2-quotegenerator/quotes.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@

let h1E1=document.getElementById("myH1");
let pE1=document.getElementById("myP");
let buttonE1=document.getElementById("myButton");

buttonE1.addEventListener("click", () => {
const number = Math.floor(Math.random()* quotes.length);
h1E1.textContent = quotes[number].quote;
pE1.textContent= quotes[number].author;

});
// DO NOT EDIT BELOW HERE

// A function which will return one item, at
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 9 additions & 2 deletions Week-3/Homework/mandatory/3-slideshow/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<title>Slideshow</title>
<script src="slideshow.js"></script>
<script defer src="slideshow.js"></script>
<link
rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
Expand All @@ -12,6 +12,13 @@
<link rel="stylesheet" href="style.css" />
</head>
<body>
<!-- Write your HTML in here -->
<div id="imgSlider">
<img id= "images" src="images/cat1.jpg" width="400px" height ="400px">
<button id ="autoRev">Auto Reverse</button>
<button id= "back">Back</button>
<button id= "stop">Stop</button>
<button id = "forward">Forward</button>
<button id = "autoFor">Auto Forward</button>
</div>
</body>
</html>
28 changes: 27 additions & 1 deletion Week-3/Homework/mandatory/3-slideshow/slideshow.js
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
// Write your code here
let catIndex1 = 4;
let catIndex2 = 0;
let catRevCount = 4;
let catForCount = 0;
let catReverse;
let catForward;
let catArray = ["images/cat1.jpg", "images/cat2.jpg", "images/cat3.jpg", "images/cat4.jpg"];
let autoRev = document.getElementById("autoRev");
autoRev.addEventListener("click", function () {
catReverse = setInterval(() => {
document.getElementById("images").src = catArray[catIndex1];
catIndex1--;
if(catIndex1 === catArray.length-4) {
catIndex1 = 4;
}
}, 2000);
})
let autoFor = document.getElementById("autoFor");
autoFor.addEventListener("click", function () {
catForward = setInterval(() => {
document.getElementById("images").src = catArray[catIndex2];
catIndex2++;
if (catIndex2 === 4) {
catIndex2 = 0;
}
}, 2000);
})