35 | //
36 | //

37 | //
38 | //
`
39 |
40 |
41 | const imageWrapper= document.createElement('div')
42 | imageWrapper.classList.add("col")
43 | const image = document.createElement('img')
44 | image.src= result.urls.small
45 | image.alt= result.alt_description
46 | const imageLink = document.createElement('a')
47 | imageLink.href=result.links.html
48 | imageLink.target="_blank"
49 | imageLink.textContent= result.alt_description
50 |
51 | imageWrapper.appendChild(image)
52 | imageWrapper.appendChild(imageLink)
53 | searchResults.appendChild(imageWrapper)
54 |
55 |
56 |
57 | })
58 |
59 | page++
60 | if(page>1){
61 | showMoreBtn.style.display="block"
62 | }
63 | }
64 |
65 | form.addEventListener('submit',(e)=>{
66 |
67 | e.preventDefault()
68 | page=1
69 | searchImages()
70 | inputSearch.value=""
71 |
72 |
73 |
74 |
75 | })
76 | showMoreBtn.addEventListener('click',(e)=>{
77 |
78 |
79 |
80 | searchImages()
81 | console.log("click")
82 |
83 | })
84 |
--------------------------------------------------------------------------------
/API-project1/style.css:
--------------------------------------------------------------------------------
1 |
2 | @import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,300;0,400;1,200;1,300;1,400&display=swap');
3 |
4 | *{
5 | margin: 0;
6 | padding: 0;
7 | box-sizing: border-box;
8 | font-family: 'Poppins', sans-serif;
9 |
10 | }
11 |
12 | body{
13 | line-height: 1.6;
14 |
15 | }
16 | h1{
17 | font-size: 36px;
18 | font-weight: bold;
19 | text-align: center;
20 | margin: 40px 0 60px 0;
21 | }
22 | form{
23 | width: 100% ;
24 | display: flex;
25 | align-items: center;
26 | justify-content: space-between;
27 | background: #edeef0;
28 | border-radius: 30px;
29 | max-width: 500px;
30 | padding-left: 20px;
31 | margin-bottom: 25px;
32 | position: relative;
33 | transform: translate(-50%,-50%);
34 | top: 10%;
35 | left: 50%;
36 |
37 |
38 | }
39 | input{
40 | flex: 1;
41 | border: none;
42 | outline: none;
43 | background: transparent;
44 | padding:10px ;
45 |
46 | }
47 | button{
48 | border: none;
49 | outline: none;
50 | padding: 16px 50px;
51 | background:#ff5945;
52 | color:#fff;
53 | font-size: 16px;
54 | cursor: pointer;
55 | border-radius: 40px;
56 |
57 | }
58 | .search-results{
59 |
60 |
61 | display: flex;
62 | justify-content: space-between;
63 |
64 |
65 | }
66 |
67 |
68 | .col {
69 |
70 | width: 100px;
71 | height: 100px;
72 | flex: 1;
73 |
74 | display: flex;
75 | flex-direction: column;
76 |
77 |
78 |
79 | padding: 10px;
80 | margin-bottom: 50px;
81 | transition: all 1s ease-in-out .1s;
82 |
83 | }
84 |
85 | .col img{
86 | width: 100%;
87 | }
88 |
89 |
90 |
91 | .search-result h4{
92 | font-size: 20px;
93 |
94 | display: block;
95 | padding: 10px;
96 | text-transform: capitalize;
97 |
98 | }
99 | .search-result h4 a{
100 | text-decoration: none;
101 | color: #ff5945;
102 | }
103 | #show-more-btn{
104 | display: none;
105 | position: relative;
106 | left: 45%;
107 |
108 |
109 |
110 | }
111 |
112 |
113 |
--------------------------------------------------------------------------------
/AdvanceThemePicker/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
Theme Picker
7 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
ColorCode:
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/AdvanceThemePicker/script.js:
--------------------------------------------------------------------------------
1 | const start = document.querySelector('#start')
2 | const stop = document.querySelector('#stop')
3 | const clrCode = document.querySelector('#clrCode')
4 | const container = document.querySelector(".container")
5 | const body = document.querySelector("body")
6 |
7 | let color;
8 | let intervelId;
9 |
10 | const randomColor = ()=>{
11 | // let hex ="0123456789ABCDEF"
12 | color = "#"
13 | for (let i = 0; i < 6; i++) {
14 | color = color+ Math.floor(Math.random()*9)
15 | }
16 | // console.log(Math.floor(Math.random()*9))
17 | // console.log(color)
18 | return color
19 | }
20 | randomColor()
21 |
22 | const bgChanger=()=>{
23 | body.style.backgroundColor= randomColor();
24 | clrCode.innerHTML= color
25 | }
26 |
27 | start.addEventListener('click',()=>{
28 | intervelId= setInterval(bgChanger,2000)
29 |
30 |
31 | })
32 | // console.log(stop)
33 | stop.addEventListener('click',()=>{
34 | clearInterval(intervelId)
35 | })
36 |
37 |
--------------------------------------------------------------------------------
/BMI calculator/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
Fully function BMI calculator
7 |
17 |
18 |
19 |
20 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/BMI calculator/script.js:
--------------------------------------------------------------------------------
1 |
2 |
3 | const form = document.querySelector('form')
4 |
5 | form.addEventListener('submit', (e)=>{
6 | e.preventDefault()
7 | const height = parseInt(document.querySelector('#height').value)
8 | const weight =parseInt(document.querySelector('#weight').value)
9 |
10 | const calculate = document.querySelector('#calculate')
11 |
12 | // console.log(height)
13 | // console.log(typeof height)
14 |
15 | if(height==="" || isNaN(height) || height<=0){
16 | alert("invalid height")
17 | }
18 | else if(weight==="" || isNaN(weight) || weight<=0){
19 | alert("invalid Weight")
20 | }
21 | else{
22 | const bmi = (weight /((height*height/10000))).toFixed(3)
23 | console.log(bmi)
24 | const result = document.querySelector('#result')
25 | result.innerHTML = bmi
26 |
27 |
28 |
29 |
30 | }
31 |
32 |
33 | })
--------------------------------------------------------------------------------
/Dom-project3/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
KeyBoard press
7 |
23 |
24 |
25 |
26 |
press any key of keyboard
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/Dom-project3/script.js:
--------------------------------------------------------------------------------
1 | const insert = document.querySelector('.insert')
2 |
3 | window.addEventListener('keydown',(e)=>{
4 | insert.innerHTML= `
11 |
12 | Key |
13 | KeyCode |
14 | Code |
15 |
16 |
17 | ${e.key === ' '?"space":e.key} |
18 | ${e.keyCode} |
19 | ${e.code} |
20 |
21 |
22 |
`
23 | })
--------------------------------------------------------------------------------
/To-Do-List/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "liveServer.settings.port": 5503
3 | }
--------------------------------------------------------------------------------
/To-Do-List/images/checked.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Noman-Nom/My_javaScript/92c6aafcf515aeba5e643116da952411236dab36/To-Do-List/images/checked.png
--------------------------------------------------------------------------------
/To-Do-List/images/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Noman-Nom/My_javaScript/92c6aafcf515aeba5e643116da952411236dab36/To-Do-List/images/icon.png
--------------------------------------------------------------------------------
/To-Do-List/images/unchecked.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Noman-Nom/My_javaScript/92c6aafcf515aeba5e643116da952411236dab36/To-Do-List/images/unchecked.png
--------------------------------------------------------------------------------
/To-Do-List/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
To-Do-List
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
To-Do List
17 |
18 |
19 |
20 |
21 |
22 |
23 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/To-Do-List/script.js:
--------------------------------------------------------------------------------
1 | const input = document.querySelector("#input-box")
2 | const list = document.querySelector('#list-container')
3 |
4 | const btn = document.querySelector("#addTask")
5 |
6 | const addTask=()=>{
7 | if(input.value===""){
8 | alert("please write some task...")
9 | }
10 | else{
11 | let li = document.createElement("li")
12 | li.innerHTML = input.value
13 | list.appendChild(li);
14 |
15 | let span = document.createElement("span")
16 | span.innerHTML = "\u00d7"
17 | li.appendChild(span)
18 |
19 | }
20 | input.value = ""
21 | }
22 |
23 |
24 | list.addEventListener('click', (e)=>{
25 | // console.log(e.target)
26 | if(e.target.tagName==="LI"){
27 | e.target.classList.toggle("checked")
28 | }
29 | else if(e.target.tagName==="SPAN"){
30 | e.target.parentElement.remove()
31 | }
32 | })
33 |
--------------------------------------------------------------------------------
/To-Do-List/style.css:
--------------------------------------------------------------------------------
1 | *{
2 | margin:0;
3 | padding:0;
4 | box-sizing: border-box;
5 | }
6 |
7 |
8 | .container{
9 | width: 100%;
10 | min-height:100vh;
11 | background: linear-gradient(to right, #1488cc, #2b32b2);
12 |
13 | }
14 | .todo-app{
15 | width: 100%;
16 | max-width: 540px;
17 | background: #fff;
18 | margin: 100px auto 20px;
19 | top:20% ;
20 | left: 50%;
21 | transform: translate(-50%,-50%);
22 |
23 | position: absolute;
24 |
25 | padding: 40px 30px 70px;
26 | border-radius: 10px;
27 | }
28 | .todo-app h2{
29 | color: #002765;
30 | display:flex ;
31 | align-items: center;
32 | margin-bottom: 20px;
33 |
34 |
35 | }
36 | .todo-app h2 img{
37 | width: 30px;
38 | margin-left: 10px;
39 | }
40 | .row{
41 | display: flex;
42 | align-items: center;
43 | justify-content: space-between;
44 | background: #edeef0;
45 | border-radius: 30px;
46 | padding-left: 20px;
47 | margin-bottom: 25px;
48 | width: 100% ;
49 | }
50 | input{
51 | flex: 1;
52 | border: none;
53 | outline: none;
54 | background: transparent;
55 | padding:10px ;
56 |
57 | }
58 | button{
59 | border: none;
60 | outline: none;
61 | padding: 16px 50px;
62 | background:#ff5945;
63 | color:#fff;
64 | font-size: 16px;
65 | cursor: pointer;
66 | border-radius: 40px;
67 |
68 | }
69 | /* ul{
70 | position: absolute;
71 | } */
72 | ul li{
73 | list-style: none;
74 | font-size: 17px;
75 | padding: 12px 8px 12px 50px;
76 | user-select: none;
77 | cursor: pointer;
78 | position: relative;
79 |
80 | }
81 |
82 | ul li::before{
83 | content: "";
84 | position: absolute;
85 | height: 25px;
86 | width: 25px;
87 | border-radius: 50%;
88 | background-image: url(images/unchecked.png);
89 | background-size: cover;
90 | background-position: center;
91 | top: 12px;
92 | left: 8px;
93 | }
94 | ul li.checked{
95 | color: #555;
96 | text-decoration: line-through;
97 | }
98 | ul li.checked::before{
99 |
100 | background-image: url(images/checked.png);
101 | }
102 | ul li span{
103 | position: absolute;
104 | right: 0%;
105 | top: 5px;
106 | width: 40px;
107 | height: 40px;
108 | font-size: 22px;
109 | color: #555;
110 | line-height: 40px;
111 | text-align: center;
112 | }
113 | ul li span:hover{
114 | background: #edeef0;
115 | border-radius: 50%;
116 | }
--------------------------------------------------------------------------------
/chatbot.txt:
--------------------------------------------------------------------------------
1 | .containerIcons{
2 | display: flex;
3 | flex-direction: row;
4 | justify-content:flex-start;
5 | align-items: flex-start;
6 | gap: 0px;
7 | /* border: 1px solid red; */
8 |
9 |
10 | }
11 | .icons{
12 | width:80px;
13 | height: 100%;
14 | display: flex;
15 | justify-content: center;
16 | align-items: center;
17 | margin-top: 22px;
18 | gap: 2px;
19 | margin-bottom: 22px;
20 | /* border: 1px solid white; */
21 | }
22 | .icons label{
23 | display: flex;
24 | flex-direction:column;
25 | gap: 2px;
26 | justify-content: center;
27 | text-align: center;
28 | color: white;
29 | font-size: 10px;
30 | font-family:Verdana, Geneva, Tahoma, sans-serif;
31 |
32 | }
33 | .icons label i{
34 | color: white;
35 | font-size: 12px;
36 |
37 | }
38 |
39 |
40 |
69 |
--------------------------------------------------------------------------------
/colorPicker/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
Color Picker Project
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/colorPicker/script.js:
--------------------------------------------------------------------------------
1 | // Get references to the color picker and body elements
2 | const colorPicker = document.getElementById('colorPicker');
3 | const body = document.body;
4 |
5 | // Add an event listener to the color picker
6 | colorPicker.addEventListener('input', () => {
7 | // Get the selected color from the color picker
8 | const selectedColor = colorPicker.value;
9 |
10 | // Update the background color of the body
11 | body.style.backgroundColor = selectedColor;
12 | });
13 |
--------------------------------------------------------------------------------
/dom-project2/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "liveServer.settings.port": 5501
3 | }
--------------------------------------------------------------------------------
/dom-project2/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
BMI CALCULATOR
10 |
11 |
12 |
13 |
14 |
15 |
BMI CALCULATOR
16 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/dom-project2/script.js:
--------------------------------------------------------------------------------
1 | const form = document.querySelector('form')
2 |
3 | // console.log(form)
4 | form.addEventListener('submit', (e)=>{
5 | e.preventDefault()
6 |
7 | const weight= parseInt(document.querySelector('#weight').value)
8 | const height= parseInt(document.querySelector('#height').value)
9 | const result = document.querySelector('#result')
10 |
11 |
12 | // console.log(weight)
13 | // console.log(height)
14 |
15 | if(height=== '' || height<= 0 || isNaN(height)){
16 | console.log(`plese enter a valid height`)
17 | alert(`plese enter a valid height !! ${height} is not valid`)
18 | }
19 | else if(weight=== '' || weight<= 0 || isNaN(weight)){
20 |
21 | console.log(`plese enter a valid height`)
22 | alert(`plese enter a valid weight !! ${weight} is not valid`)
23 | }else{
24 | const bmi =(weight /((height*height/10000)).toFixed(3))
25 | result.innerHTML= `
${bmi}`
26 | }
27 |
28 |
29 | })
--------------------------------------------------------------------------------
/dom-project2/style.css:
--------------------------------------------------------------------------------
1 | *{
2 | margin: 0;
3 | padding: 0;
4 | box-sizing: border-box;
5 |
6 |
7 |
8 |
9 | }
10 | body{
11 | background-image:linear-gradient(rgba(0,0,50,0.5),rgba(0,0,50,0.5)),url('https://images.pexels.com/photos/2261477/pexels-photo-2261477.jpeg');
12 | background-size: cover;
13 | background-position: center;
14 | background-attachment: fixed;
15 | }
16 | .container{
17 | width: 100%;
18 | height: 100%;
19 |
20 | position: relative;
21 |
22 |
23 | }
24 | .container__box{
25 | width: 90%;
26 | max-width: 400px;
27 | position: absolute;
28 | top: 50%;
29 | left: 50%;
30 | transform: translate(-50% ,50%);
31 | background: white;
32 | padding: 50px 50px 20px;
33 | text-align: center;
34 |
35 | }
36 | .container__box h1{
37 | font-size: 30px;
38 | margin-bottom: 30px;
39 | color: #3c00a0;
40 | position: relative;
41 | }
42 | .container__box h1::after{
43 | content: "";
44 | width: 100px;
45 | height: 4px;
46 | border-radius: 3px;
47 | background: #3c00a0;
48 | position: absolute;
49 | bottom: -12px;
50 | left: 50%;
51 | transform: translateX(-50%);
52 | }
53 | .input-field{
54 | background: #eaeaea;
55 | margin: 15px 0;
56 | border-radius: 3px;
57 | display: flex;
58 | align-items: center;
59 | }
60 | input{
61 | width: 100%;
62 | background: transparent;
63 | border: 0;
64 | outline: 0;
65 | padding: 18px 15px;
66 | color: #3c00a0;
67 | font-size: 18px;
68 | }
69 | #result{
70 | width: 100%;
71 | height: 49px;
72 | background: transparent;
73 | border: 0;
74 | outline: 0;
75 | padding: 18px 15px;
76 | color: #3c00a0;
77 | font-size: 18px;
78 | }
79 | .input-field i{
80 | margin-left: 15px;
81 | color: #0a0909;
82 | }
83 | .btn-field{
84 | width: 100%;
85 | display: flex;
86 | justify-content: center;
87 | }
88 | .btn-field button{
89 | flex-basis: 38%;
90 | background: #3c00a0;
91 | color: white;
92 | height: 40px;
93 | border-radius: 20px;
94 | border: 0;
95 | outline: 0;
96 | cursor: pointer;
97 | font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
98 | font-size: 18px;
99 |
100 | }
101 | .input-group{
102 | height: 280px;
103 | }
104 |
--------------------------------------------------------------------------------
/dom-project4/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "liveServer.settings.port": 5501
3 | }
--------------------------------------------------------------------------------
/dom-project4/DOom-project-1/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
Bg color Changer
7 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
Blue
60 |
Red
61 |
Green
62 |
Black
63 |
brown
64 |
skyblue
65 |
violet
66 |
purple
67 |
68 |
69 |
72 |
73 |
--------------------------------------------------------------------------------
/dom-project4/DOom-project-1/script.js:
--------------------------------------------------------------------------------
1 |
2 | // method 1
3 | const div = document.querySelectorAll(".colors");
4 | // console.log(div)
5 | const body = document.querySelector("body");
6 |
7 | div.forEach((div) => {
8 | // console.log(div)
9 | div.addEventListener("click", (e) => {
10 | // console.log(e.target.id)
11 | if (e.target.id === "red") body.style.backgroundColor = "#e46161";
12 | if (e.target.id === "blue") body.style.backgroundColor = "#2F80ED";
13 | if (e.target.id === "black") body.style.backgroundColor = "#20002c";
14 | if (e.target.id === "green") body.style.backgroundColor = "#0f9b0f";
15 | if (e.target.id === "violet") body.style.backgroundColor = e.target.id;
16 | if (e.target.id === "brown") body.style.backgroundColor = e.target.id;
17 | if (e.target.id === "purple") body.style.backgroundColor = e.target.id;
18 | if (e.target.id === "skyblue") body.style.backgroundColor = e.target.id;
19 | });
20 | });
21 |
22 |
23 | // method 2
24 |
25 | // const div = document.querySelectorAll('.colors')
26 | // const div = document.getElementById('blue')
27 | // console.log(div)
28 |
29 |
--------------------------------------------------------------------------------
/dom-project4/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
To Do List
7 |
26 |
27 |
28 |
29 |
My To-do App
30 |
31 |
32 |
33 |
34 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/dom-project4/script.js:
--------------------------------------------------------------------------------
1 | const inputBox = document.querySelector("#inputBox");
2 | const addTask = document.querySelector("#addTask")
3 | const tasks = document.querySelector("#tasks")
4 |
5 |
6 | const todoTask = ()=>{
7 | const li = document.createElement("li")
8 | li.innerHTML=`${inputBox.value}
`
9 | tasks.appendChild(li)
10 | inputBox.value=""
11 | const deleteBtn = document.querySelector('#deleteBtn')
12 | deleteBtn.addEventListener('click',(e)=>{
13 | console.log(e.target.parentNode)
14 | removeIt = e.target.parentNode
15 | removeIt.remove()
16 |
17 | })
18 | }
19 |
20 |
21 |
22 |
23 | addTask.addEventListener("click", ()=>{
24 | if(inputBox.value===""){
25 | alert("please add some task")
26 | }
27 | else{
28 | todoTask()
29 | }
30 | console.log(inputBox.value)
31 |
32 | })
33 |
34 | window.addEventListener('keydown',(e)=>{
35 | if(e.key==="Enter"){
36 | if(inputBox.value===""){
37 | alert("please add some task")
38 | }
39 | else{
40 | todoTask()
41 |
42 | }
43 |
44 | }
45 |
46 | })
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/dom-project5/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
Bgclr Changer
7 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/dom-project5/script.js:
--------------------------------------------------------------------------------
1 | const bgChanger= document.querySelector('#bgChanger')
2 | const body = document.querySelector('body')
3 |
4 | bgChanger.addEventListener('input',()=>{
5 |
6 | // console.log("changed")
7 | const chngeBgClr = bgChanger.value
8 | body.style.backgroundColor = chngeBgClr
9 |
10 | })
--------------------------------------------------------------------------------
/img glry/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "liveServer.settings.port": 5501
3 | }
--------------------------------------------------------------------------------
/img glry/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
Image Gallery
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/img glry/script.js:
--------------------------------------------------------------------------------
1 | // Sample image data (you can replace this with your own images and categories)
2 | const images = [
3 | { src: 'image1.jpg', category: 'nature' },
4 | { src: 'image2.jpg', category: 'architecture' },
5 | // Add more image data
6 | ];
7 |
8 | // References to DOM elements
9 | const imageGallery = document.querySelector('.image-gallery');
10 | const categories = document.querySelector('.categories');
11 | const lightbox = document.querySelector('.lightbox');
12 |
13 | // Function to display images in the gallery
14 | function displayImages(category) {
15 | // Clear the gallery
16 | imageGallery.innerHTML = '';
17 |
18 | // Filter images by category
19 | const filteredImages = category
20 | ? images.filter(img => img.category === category)
21 | : images;
22 |
23 | // Create image cards and add them to the gallery
24 | filteredImages.forEach(imgData => {
25 | const imageCard = document.createElement('div');
26 | imageCard.classList.add('image-card');
27 | imageCard.innerHTML = `

`;
28 |
29 | // Add a click event listener to open the image in the lightbox
30 | imageCard.addEventListener('click', () => {
31 | const lightboxContent = `

`;
32 | lightbox.innerHTML = lightboxContent;
33 | lightbox.style.display = 'block';
34 | });
35 |
36 | imageGallery.appendChild(imageCard);
37 | });
38 | }
39 |
40 | // Function to handle category button clicks
41 | function handleCategoryClick(event) {
42 | const selectedCategory = event.target.dataset.category;
43 | displayImages(selectedCategory);
44 | }
45 |
46 | // Add event listeners to category buttons
47 | categories.addEventListener('click', handleCategoryClick);
48 |
49 | // Display all images initially
50 | displayImages(null);
51 |
--------------------------------------------------------------------------------
/jsm projects/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
Document
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/jsm projects/script.js:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Noman-Nom/My_javaScript/92c6aafcf515aeba5e643116da952411236dab36/jsm projects/script.js
--------------------------------------------------------------------------------
/jsm projects/style.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Noman-Nom/My_javaScript/92c6aafcf515aeba5e643116da952411236dab36/jsm projects/style.css
--------------------------------------------------------------------------------
/projects/project-2_converter/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
Foot to meter Converter
7 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
=
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/projects/project-2_converter/script.js:
--------------------------------------------------------------------------------
1 | const foot = document.getElementById("foot");
2 | const meter = document.getElementById("meter");
3 |
4 | foot.addEventListener(
5 | "input",
6 | function () {
7 | // console.log('changed');
8 | const f = this.value;
9 | // console.log(f)
10 |
11 | // this formula convert # of foot into meters
12 | const m = f * 0.304;
13 | // this expression display the value in meter input
14 | meter.value = m.toFixed(5);
15 | },
16 | false
17 | );
18 |
19 | meter.addEventListener(
20 | "input",
21 | function () {
22 | // console.log('changed');
23 | const m = this.value;
24 | // console.log(m)
25 |
26 | const f = m * 3.28;
27 | foot.value= f.toFixed(5);
28 | },
29 | false
30 | );
31 |
--------------------------------------------------------------------------------
/projects/project-3_colorChanger/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "liveServer.settings.port": 5501
3 | }
--------------------------------------------------------------------------------
/projects/project-3_colorChanger/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
Background Color Changer
7 |
17 |
18 |
19 |
20 |
21 | Red
22 |
23 |
24 |
25 |
29 |
30 |
--------------------------------------------------------------------------------
/projects/project-3_colorChanger/script.js:
--------------------------------------------------------------------------------
1 | const clrChnger = document.getElementById('red');
2 | console.log(clrChnger);
3 | const body = document.querySelector('body');
4 |
5 | clrChnger.addEventListener('click', function(){
6 | body.style.backgroundColor ="red";
7 | })
--------------------------------------------------------------------------------
/promises&Api/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
Promises & Api
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/promises&Api/script.js:
--------------------------------------------------------------------------------
1 | // promises
2 |
3 | // const promis1 = new Promise((resolve,reject)=>{
4 | // setTimeout(()=>{
5 | // console.log("promise 1 ")
6 | // },1000)
7 | // })
8 |
9 | // promis1.then(()=>{
10 | // console.log("promise is resolved")
11 | // })
12 |
13 | const promis1 = new Promise((resolve, reject) => {
14 | setTimeout(() => {
15 | // console.log("promise 1 ")
16 | resolve();
17 | }, 1000);
18 | });
19 |
20 | promis1.then(() => {
21 | // console.log("promise is resolved")
22 | });
23 |
24 | // promise 2
25 |
26 | new Promise((resolve, reject) => {
27 | setTimeout(() => {
28 | // console.log("promise 1 ")
29 | resolve();
30 | }, 1000);
31 | }).then(() => {
32 | // console.log("promise is resolved")
33 | });
34 |
35 | // promise 3
36 | const promis3 = new Promise((resolve, reject) => {
37 | setTimeout(() => {
38 | // resolve({user:"noman", gmail: "abc@gmail.com"})
39 | }, 1000);
40 | });
41 |
42 | promis3.then((data) => {
43 | // console.log(data)
44 | });
45 |
46 | // promise 4
47 |
48 | const promise4 = new Promise((resolve, reject) => {
49 | setTimeout(() => {
50 | resolve({ user: "noman", gmail: "abc@gmail.com" });
51 | }, 1000);
52 | });
53 |
54 | promise4.then((data) => {
55 | // console.log(data);
56 | return data.user;
57 | })
58 | .then((user)=>{
59 | // console.log(user)
60 |
61 | })
62 |
63 |
64 | //
65 | const promise5 = new Promise((resolve,reject)=>{
66 | setTimeout(()=>{
67 | // let error = true;
68 | let error = false;
69 | if(!error){
70 | resolve({userName:"noman",pass:123})
71 | }else{
72 | reject("Error: something went wrong")
73 | }
74 | },1000)
75 | })
76 | promise5.then((user)=>{
77 | // console.log(user)
78 | })
79 | .catch((error)=>{
80 | // console.log(error)
81 | })
82 | .finally(()=>{
83 | // console.log("Apun BAP he")
84 | })
85 |
86 | //
87 | const promise6 = new Promise((resolve,reject)=>{
88 | setTimeout(()=>{
89 | // let error = true;
90 | let error = false;
91 | if(!error){
92 | resolve({userName:"noman",pass:12367887})
93 | }else{
94 | reject("Error: something went wrong")
95 | }
96 | },1000)
97 | })
98 |
99 | async function comsumePrmise6(){
100 | try {
101 | const response = await promise6
102 | // console.log(response)
103 |
104 | } catch (error) {
105 | // console.log(error)
106 | }
107 | }
108 | comsumePrmise6()
109 |
110 | // with Api
111 |
112 |
113 |
114 | const getUser = async ()=>{
115 | const response = await fetch("https://newsapi.org/v2/everything?q=tesla&from=2023-08-18&sortBy=publishedAt&apiKey=bcd2aeba084a4b89b74f151b9d2bd920")
116 | const data = await response.json()
117 | console.log(data)
118 | console.log(data.articles)
119 |
120 | }
121 |
122 | getUser()
123 |
124 |
125 |
126 |
--------------------------------------------------------------------------------
/promises/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
promises in js
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/promises/script.js:
--------------------------------------------------------------------------------
1 | // promises
2 |
3 | // const prom1 = new Promise((resolve,reject)=>{
4 | // setTimeout(()=>{
5 | // console.log("Aysnc task is completed....!")
6 |
7 |
8 | // },1000)
9 |
10 | // })
11 |
12 | // prom1.then(()=>{
13 | // console.log("promise is consumed")
14 | // })
15 |
16 |
17 | // with resolve
18 | const prom1 = new Promise((resolve,reject)=>{
19 | setTimeout(()=>{
20 | // console.log("Aysnc task is completed....!")
21 | resolve()
22 |
23 |
24 | },1000)
25 |
26 | })
27 |
28 | prom1.then(()=>{
29 | // console.log("promise is consumed")
30 | })
31 |
32 |
33 | // promise 2
34 |
35 | new Promise((resolve,reject)=>{
36 | setTimeout(()=>{
37 | // console.log("promise Aysnc task 2")
38 | resolve()
39 | },1000)
40 |
41 | }).then(()=>{
42 | // console.log("aync 2 resolved")
43 | })
44 |
45 |
46 | // promise 3 handling with data
47 |
48 | const prom3 = new Promise((resolve,reject)=>{
49 | setTimeout(()=>{
50 | resolve({user:"M.Noman", UserEmail:"noman5456318@gmail.com"})
51 |
52 | },1000)
53 |
54 | })
55 |
56 | prom3.then((user)=>{
57 | // console.log(user)
58 | })
59 |
60 | const promise4 = new Promise((resolve,reject)=>{
61 | setTimeout(()=>{
62 | let error = false
63 | // let error = true
64 | if(!error){
65 | resolve({userName:"noman",pass:123})
66 | }else{
67 | reject("Error: something went wrong")
68 | }
69 | },1000)
70 |
71 |
72 | })
73 |
74 | promise4.then((user)=>{
75 | // console.log(user)
76 | return user.userName
77 | })
78 | .then((userName)=>{
79 | // console.log(userName)
80 | })
81 | .catch((error)=>{
82 | // console.log(error)
83 | })
84 | .finally(()=>{
85 | // console.log("The promise is either resolved or rejected")
86 | })
87 |
88 | // promise 5
89 |
90 | const promise5 = new Promise((resolve,reject)=>{
91 | setTimeout(()=>{
92 | // let error = false
93 | let error = true
94 | if(!error){
95 | resolve({language:"javascript",pass:123})
96 | }else{
97 | reject("Error: something went wrong")
98 | }
99 | },1000)
100 | })
101 |
102 | async function consumePromiseFive(){
103 | try {
104 | const response = await promise5
105 | // console.log(response)
106 |
107 | } catch (error) {
108 | // console.log(error)
109 |
110 | }
111 | }
112 |
113 | // without try and cathc
114 | // async function consumePromiseFive(){
115 | // const response = await promise5
116 | // console.log(response)
117 | // }
118 | consumePromiseFive()
119 |
120 |
121 | // with API
122 |
123 |
124 | // async function getUser(){
125 | // const response = await fetch('https://jsonplaceholder.typicode.com/users')
126 |
127 | // const data = await response.json()
128 | // console.log(data)
129 | // }
130 |
131 | async function getUser(){
132 | try {
133 | const response = await fetch('https://jsonplaceholder.typicode.com/users')
134 |
135 | const data = await response.json()
136 | // console.log(data)
137 | } catch (error) {
138 | // console.log("E: eror")
139 | }
140 | }
141 |
142 | getUser()
143 |
144 | // with then and catch
145 |
146 | fetch('https://jsonplaceholder.typicode.com/users')
147 | .then((response)=>{
148 | return response.json()
149 |
150 | })
151 | .then((data)=>{
152 | console.log(data)
153 |
154 | })
155 | .catch((error)=>{
156 | console.log(error)
157 | })
--------------------------------------------------------------------------------
/test.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Noman-Nom/My_javaScript/92c6aafcf515aeba5e643116da952411236dab36/test.txt
--------------------------------------------------------------------------------
/test/script.js:
--------------------------------------------------------------------------------
1 | console.log("hello world")
--------------------------------------------------------------------------------