This repository has been archived by the owner on Dec 18, 2024. It is now read-only.
generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 41
NW6| Bakhat Begum | MODULE-JS2| Js2 slideshow/week 4 | Week-4 #219
Open
BakhatBegum
wants to merge
11
commits into
CodeYourFuture:main
Choose a base branch
from
BakhatBegum:JS2-slideshow/week-4
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e399c06
final sweep of module js2
BakhatBegum ed6c355
added some function and title name
BakhatBegum 0a9b393
removed codes
BakhatBegum f805b56
removed codes
BakhatBegum e0fe1c8
added function on javascipt and also made changies on html and css
BakhatBegum 2e4ffaa
I removed unnecessary codes from file
BakhatBegum 115acf4
I removed unnecessary codes from js file
BakhatBegum 6aaceae
removed let img_list from code
BakhatBegum e254847
remove commented lines
BakhatBegum 27f05e7
added style i.e. fonst size, background colour and media screen
BakhatBegum 347b164
added padding left
BakhatBegum File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
// Fix this implementation | ||
// Start by running the tests for this function | ||
// If you're in the week-1 directory, you can run npm test -- fix to run the tests in the fix directory | ||
//Fix this implementation | ||
//Start by running the tests for this function | ||
//If you're in the week-1 directory, you can run npm test -- fix to run the tests in the fix directory | ||
|
||
function calculateMedian(list) { | ||
const middleIndex = Math.floor(list.length / 2); | ||
const median = list.splice(middleIndex, 1)[0]; | ||
return median; | ||
} | ||
|
||
module.exports = calculateMedian; | ||
//calculateMedian( 3, 3, 4, 5) | ||
//module.exports = calculateMedian; | ||
|
||
// console.log(calculateMedian( 3, 3, 4, 5)) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,93 @@ | ||
const images = [ | ||
"./assets/cute-cat-a.png", | ||
"./assets/cute-cat-b.jpg", | ||
"./assets/cute-cat-c.jpg", | ||
]; | ||
|
||
|
||
// Write your code here | ||
let element_image = document.getElementById('image'); | ||
let img_list = [ | ||
"./assets/cute-cat-a.png", | ||
"./assets/cute-cat-b.jpg", | ||
"./assets/cute-cat-c.jpg", | ||
"./assets/cute-cat-d.png" | ||
]; | ||
element_image.setAttribute("src", img_list[0]); | ||
|
||
function add_carousel(){ | ||
let element_imageI = document.getElementById('image'); | ||
element_imageI.setAttribute("src", img_list.slice(-1)[0]); | ||
} | ||
|
||
function carousel(){ | ||
if(img_list) { | ||
let element_imageJ = document.getElementsById('image'); | ||
element_imageJ.setAttribute("src", img_list[0]); | ||
}else{ | ||
let element_imageK = document.getElementById('image'); | ||
element_imageK.setAttribute("src", img_list.slice(-1)[0]) | ||
} | ||
} | ||
|
||
function add_image() { | ||
add_carousel(); | ||
carousel(); | ||
} | ||
|
||
document.getElementById('previous').addEventListener('click', (event) => { | ||
img_list.unshift(img_list.pop()); | ||
add_image(); | ||
|
||
}); | ||
|
||
document.getElementById('next').addEventListener('click', (event) => { | ||
img_list.push(img_list.shift()); | ||
add_image(); | ||
|
||
}); | ||
|
||
|
||
const buttonClick = document.getElementById("autoBack"); | ||
const autoPlay = document.getElementById("status"); | ||
|
||
let autoBackEnabled = false; | ||
|
||
setInterval(() => { | ||
if (autoBackEnabled) { | ||
img_list.unshift(img_list.pop()); | ||
add_image(); | ||
} | ||
}, 5000); | ||
|
||
buttonClick.addEventListener("click", function () { | ||
autoBackEnabled = !autoBackEnabled; | ||
if (autoBackEnabled) { | ||
autoPlay.textContent = "auto-Backword ON"; | ||
} else { | ||
autoPlay.textContent = ""; | ||
} | ||
}); | ||
|
||
const forwordButton = document.getElementById("autoForward"); | ||
|
||
let autoForwardButton = false; | ||
setInterval(() => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You already have a set interval, consider refactoring this code into the same place. |
||
if (autoForwardButton) { | ||
img_list.push(img_list.shift()); | ||
add_image(); | ||
} | ||
}, 5000); | ||
|
||
forwordButton.addEventListener("click", function () { | ||
autoForwardButton= !autoForwardButton; | ||
if (autoForwardButton) { | ||
autoPlay.textContent = "auto-Forword ON"; | ||
} else { | ||
autoPlay.textContent = ""; | ||
} | ||
}); | ||
|
||
const stopButton = document.getElementById("stopButton"); | ||
stopButton.addEventListener("click", stop); | ||
|
||
function stop(){ | ||
autoForwardButton = false; | ||
autoBackEnabled = false; | ||
autoPlay.textContent = ""; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,50 @@ | ||
/** Write your CSS in here **/ | ||
body{ | ||
background-color: rgb(74, 149, 149); | ||
|
||
} | ||
|
||
#carousel{ | ||
margin-top: 100px; | ||
margin-left: 400px; | ||
} | ||
h2{ | ||
margin-left: 100px; | ||
font-size: 2em; | ||
} | ||
|
||
#image{ | ||
width: 40%; | ||
border: 10px solid palevioletred; | ||
border-radius: 9px; | ||
margin-left: 100px; | ||
} | ||
button{ | ||
display: inline; | ||
margin: 15px; | ||
padding: 15px 15px; | ||
border-radius: 12px; | ||
border: 5px solid palevioletred; | ||
} | ||
.hr{ | ||
border: 1px solid rgb(63, 56, 56); | ||
width: 100%; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
@media screen and (max-width: 598px){ | ||
body{ | ||
background-color: rgb(109, 103, 95); | ||
} | ||
#carousel{ | ||
margin-left: 0px; | ||
} | ||
#image{ | ||
width: 60%; | ||
margin: 0px; | ||
} | ||
|
||
h2{ | ||
margin: 0px; | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an interesting use of array methods to access the image and add it to the document. Consider simplifying by accessing the desired element in the array with bracket notation