├── Custom Filterable Gallery ├── images │ ├── img1.jpg │ ├── img10.jpg │ ├── img11.jpg │ ├── img2.jpg │ ├── img3.jpg │ ├── img4.jpg │ ├── img5.jpg │ ├── img6.jpg │ ├── img7.jpg │ ├── img8.jpg │ └── img9.jpg ├── index.html ├── script.js └── style.css ├── Digital Clock with date ├── clock.js ├── index.html └── style.css ├── EMI Calculator ├── index.html ├── script.js └── style.css ├── Floating Placeholder ├── index.html └── style.css ├── LICENSE ├── Palindrome Checker ├── index.html ├── script.js └── style.css ├── README.md ├── Side bar open close └── sidebar.html ├── SliderJavaScript ├── images │ ├── 800px-Shakuzoji_Kuginuki_Jizo-3586.jpg │ ├── 800px-Stirling_Castle_Main_Gate.jpg │ ├── 829012.jpg │ └── Technology-Dekstop-Wallpapers.jpg ├── index.html ├── script.js └── style.css ├── Text-formatter ├── Version-1 │ ├── index.html │ ├── script.js │ └── style.css ├── Version-2 │ ├── index.html │ ├── script.js │ └── style.css └── readme.md ├── Word Counter ├── index.html ├── script.js └── style.css ├── ageCalculator ├── index.html ├── script.js └── style.css ├── digital clock ├── index.html └── pexels-photo-235986.jpeg ├── formValidation ├── using JavaScript │ ├── index.html │ ├── script.js │ └── style.css └── using html │ ├── inputType.html │ ├── requiredAttribute.html │ └── style.css ├── lengthConverter ├── index.html ├── script.js └── style.css ├── loginPage ├── index.html └── style.css ├── random password Generator ├── index.html ├── main.js └── style.css ├── searchable dropdown list ├── index.html ├── script.js └── style.css ├── stopwatch ├── index.html ├── main.js └── style.css └── tic tak toe game ├── index.html ├── tic.css └── tic.js /Custom Filterable Gallery/images/img1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachinsaini4278/JavaScript-Projects/13803488681577ac93d4ab73e14d7bbc4a3d23bb/Custom Filterable Gallery/images/img1.jpg -------------------------------------------------------------------------------- /Custom Filterable Gallery/images/img10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachinsaini4278/JavaScript-Projects/13803488681577ac93d4ab73e14d7bbc4a3d23bb/Custom Filterable Gallery/images/img10.jpg -------------------------------------------------------------------------------- /Custom Filterable Gallery/images/img11.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachinsaini4278/JavaScript-Projects/13803488681577ac93d4ab73e14d7bbc4a3d23bb/Custom Filterable Gallery/images/img11.jpg -------------------------------------------------------------------------------- /Custom Filterable Gallery/images/img2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachinsaini4278/JavaScript-Projects/13803488681577ac93d4ab73e14d7bbc4a3d23bb/Custom Filterable Gallery/images/img2.jpg -------------------------------------------------------------------------------- /Custom Filterable Gallery/images/img3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachinsaini4278/JavaScript-Projects/13803488681577ac93d4ab73e14d7bbc4a3d23bb/Custom Filterable Gallery/images/img3.jpg -------------------------------------------------------------------------------- /Custom Filterable Gallery/images/img4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachinsaini4278/JavaScript-Projects/13803488681577ac93d4ab73e14d7bbc4a3d23bb/Custom Filterable Gallery/images/img4.jpg -------------------------------------------------------------------------------- /Custom Filterable Gallery/images/img5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachinsaini4278/JavaScript-Projects/13803488681577ac93d4ab73e14d7bbc4a3d23bb/Custom Filterable Gallery/images/img5.jpg -------------------------------------------------------------------------------- /Custom Filterable Gallery/images/img6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachinsaini4278/JavaScript-Projects/13803488681577ac93d4ab73e14d7bbc4a3d23bb/Custom Filterable Gallery/images/img6.jpg -------------------------------------------------------------------------------- /Custom Filterable Gallery/images/img7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachinsaini4278/JavaScript-Projects/13803488681577ac93d4ab73e14d7bbc4a3d23bb/Custom Filterable Gallery/images/img7.jpg -------------------------------------------------------------------------------- /Custom Filterable Gallery/images/img8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachinsaini4278/JavaScript-Projects/13803488681577ac93d4ab73e14d7bbc4a3d23bb/Custom Filterable Gallery/images/img8.jpg -------------------------------------------------------------------------------- /Custom Filterable Gallery/images/img9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachinsaini4278/JavaScript-Projects/13803488681577ac93d4ab73e14d7bbc4a3d23bb/Custom Filterable Gallery/images/img9.jpg -------------------------------------------------------------------------------- /Custom Filterable Gallery/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | 11 |
12 | 19 | 24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /Custom Filterable Gallery/script.js: -------------------------------------------------------------------------------- 1 | //All images in a 2D array 2 | let image = [ 3 | ["img1.jpg","img2.jpg","img3.jpg"], 4 | ["img4.jpg","img5.jpg","img6.jpg"], 5 | ["img7.jpg","img8.jpg"], 6 | ["img9.jpg","img10.jpg","img11.jpg"] 7 | ]; 8 | 9 | // Get Filter Value 10 | document.querySelectorAll(".filter-item").forEach((element, elementIndex) => { 11 | element.addEventListener("click", () => { 12 | //console.log(elementIndex) 13 | if(elementIndex!=0) 14 | showImagesFiltered(elementIndex); 15 | else 16 | showAllImages(); 17 | }); 18 | }); 19 | 20 | // Function to show images according to filter selected 21 | function showImagesFiltered(index){ 22 | document.getElementById("gallery-image-container").innerHTML=""; 23 | removeOtherFilterSelectedCSS(); 24 | document.getElementsByClassName("filter-item")[index].classList.add("filter-selected"); 25 | for (let i = 0; i < image[index-1].length; i++) { 26 | let newElement = document.createElement("div"); 27 | newElement.className = "gallery-item"; 28 | let imageElement = document.createElement("img"); 29 | imageElement.src="images/" + image[index-1][i]; 30 | newElement.appendChild(imageElement); 31 | document.getElementById("gallery-image-container").appendChild(newElement); 32 | } 33 | } 34 | 35 | //Function to show all images 36 | function showAllImages(){ 37 | document.getElementById("gallery-image-container").innerHTML=""; 38 | removeOtherFilterSelectedCSS(); 39 | document.getElementsByClassName("filter-item")[0].classList.add("filter-selected"); 40 | 41 | for (let i = 0; i < image.length; i++) { 42 | for (let j = 0; j < image[i].length; j++) { 43 | let newElement = document.createElement("div"); 44 | newElement.className = "gallery-item"; 45 | let imageElement = document.createElement("img"); 46 | imageElement.src="images/" + image[i][j]; 47 | newElement.appendChild(imageElement); 48 | document.getElementById("gallery-image-container").appendChild(newElement); 49 | } 50 | } 51 | } 52 | function removeOtherFilterSelectedCSS(){ 53 | let allFilters = document.getElementsByClassName("filter-item"); 54 | for(let i=0;i 12) { 27 | hour -= 12; 28 | session = "PM"; 29 | } 30 | if (hour == 0) { 31 | hr = 12; 32 | session = "AM"; 33 | } 34 | 35 | hour = hour < 10 ? "0" + hour : hour; 36 | min = min < 10 ? "0" + min : min; 37 | sec = sec < 10 ? "0" + sec : sec; 38 | 39 | let currentTime = hour + ":" + min + ":" + sec + " "+ session; 40 | 41 | document.getElementById("clock").innerHTML = currentTime; 42 | } 43 | showCustomDayAndMonth(); -------------------------------------------------------------------------------- /Digital Clock with date/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Digital Clock 7 | 8 | 9 | 10 |
11 |
12 |

13 |

14 |
15 |
16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /Digital Clock with date/style.css: -------------------------------------------------------------------------------- 1 | *{ 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | body{ 7 | background-color: black; 8 | } 9 | .container{ 10 | display: flex; 11 | justify-content: center; 12 | align-items: center; 13 | height: 100vh; 14 | } 15 | .clock-container{ 16 | padding:15px; 17 | border-radius: 10px; 18 | box-shadow: 0px 0px 10px rgb(168, 158, 158); 19 | } 20 | #clock{ 21 | color: rgb(95, 95, 180); 22 | font-size: 80px; 23 | } 24 | #date{ 25 | color:rgb(176, 176, 209); 26 | } -------------------------------------------------------------------------------- /EMI Calculator/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | EMI Calculator 5 | 6 | 7 | 8 |
9 |

EMI Calculator

10 |
11 | 12 | 13 |
14 |
15 | 16 | 17 |
18 |
19 | 20 | 21 |
22 | 23 | 24 |
25 |
26 |
27 | 28 |
29 | 30 |
31 |

Loan EMI

32 |

Total Interest Payable

33 |

Total Payment(Principal + Interest)

34 | 35 |
36 |
37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /EMI Calculator/script.js: -------------------------------------------------------------------------------- 1 | let loanAmount = document.getElementById("amount"); 2 | let interestRate=document.getElementById("interest"); 3 | let loanDuration = document.getElementById("loanTenure"); 4 | let submit = document.getElementById("calculate"); 5 | 6 | submit.addEventListener('click',(e)=>{ 7 | e.preventDefault(); 8 | calculateEMI(); 9 | }) 10 | 11 | function calculateEMI(){ 12 | // First calculate total number of months in loan tenure if selected year 13 | let isYear = document.getElementById("year").checked; 14 | let isMonth = document.getElementById("month").checked; 15 | let noOfMonths=0; 16 | if(isYear=="" && isMonth==""){ 17 | alert("Please select loan tenure type-> Month or year"); 18 | }else{ 19 | if(isYear==true){ 20 | noOfMonths=loanDuration.value * 12 ; 21 | }else{ 22 | noOfMonths=loanDuration.value; 23 | } 24 | let r = parseFloat(interestRate.value)/12/100; 25 | let P = loanAmount.value; 26 | let n = noOfMonths; 27 | //formula EMI= (P * r * (1 + r)^n ) / ((1+r)^n - 1) 28 | let EMI = (P*r* Math.pow((1+r),n)) / (Math.pow((1+r),n)-1); 29 | let totalInterest =(EMI * n) - P; 30 | let totalPayment = totalInterest + parseFloat(P); 31 | document.getElementById("emi").innerText = "₹" + Math.round(EMI); 32 | document.getElementById("totalInterest").innerText="₹" + Math.round(totalInterest); 33 | document.getElementById("totalPayment").innerText="₹" + Math.round(totalPayment) ; 34 | 35 | 36 | } 37 | } 38 | 39 | -------------------------------------------------------------------------------- /EMI Calculator/style.css: -------------------------------------------------------------------------------- 1 | *{ 2 | margin:0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | body{ 7 | display: flex; 8 | justify-content: center; 9 | align-items: center; 10 | min-height: 100vh; 11 | } 12 | .container{ 13 | width: 400px; 14 | /* height: 300px; */ 15 | border-radius: 10px; 16 | overflow: hidden; 17 | box-shadow: 0px 0px 10px 1px rgb(123, 114, 114); 18 | } 19 | .heading{ 20 | text-align: center; 21 | font-size: 30px; 22 | font-family:Cambria, Cochin, Georgia, Times, 'Times New Roman', serif; 23 | font-weight: bold; 24 | color:rgb(182, 53, 53); 25 | margin-top: 35px; 26 | } 27 | /* Style for all input containers */ 28 | .input-container{ 29 | display: flex; 30 | justify-content: space-between; 31 | align-items: center; 32 | margin: 10px 30px; 33 | } 34 | .input-container label{ 35 | font-size: larger; 36 | color:rgb(63, 71, 65); 37 | font-weight: bold; 38 | } 39 | .input-container input{ 40 | font-size: larger; 41 | border:none; 42 | box-shadow: 0px 0px 2px 1px rgb(152, 145, 145); 43 | padding: 4px 10px; 44 | border-radius: 5px; 45 | font-family: Cambria, Cochin, Georgia, Times, 'Times New Roman', serif; 46 | outline: none; 47 | width: 50%; 48 | } 49 | .input-container input:hover{ 50 | box-shadow: 0px 0px 2px 1px rgb(37, 34, 34); 51 | } 52 | 53 | /* submit button style */ 54 | .submit-container{ 55 | margin: 20px; 56 | display: flex; 57 | justify-content: center; 58 | } 59 | #calculate{ 60 | padding:4px 10px; 61 | font-size: larger; 62 | background-color: rgb(182, 53, 53); 63 | border-radius: 3px; 64 | color: white; 65 | border:none; 66 | outline: none; 67 | box-shadow: 2px 3px 4px rgb(55, 52, 52); 68 | transition: 0.4s; 69 | cursor: pointer; 70 | } 71 | #calculate:active{ 72 | box-shadow: none; 73 | font-size:large; 74 | } 75 | 76 | /* Loan duration style */ 77 | #loanTenure{ 78 | width: 58px; 79 | margin-left: 65px; 80 | margin-right: 0; 81 | /* background-color: aqua; */ 82 | border-top-right-radius: 0px; 83 | border-bottom-right-radius: 0px; 84 | } 85 | .radio-container{ 86 | display: flex; 87 | margin-left: 0; 88 | } 89 | .radio-container input[type="radio"]{ 90 | display: none; 91 | } 92 | .radio-container label{ 93 | background-color: rgb(236, 235, 234); 94 | padding: 3.7px 5px; 95 | box-shadow: 0px 0px 2px 1px rgb(152, 145, 145); 96 | cursor: pointer; 97 | transition: all 0.3s; 98 | 99 | } 100 | #month + label{ 101 | border-top-right-radius: 4px; 102 | border-bottom-right-radius: 4px; 103 | } 104 | .radio-container label:hover{ 105 | background-color: rgb(116, 101, 101); 106 | color:white; 107 | } 108 | .radio-container input[type="radio"]:checked+label{ 109 | background-color: rgb(116, 101, 101); 110 | color: white; 111 | } 112 | 113 | /* Output */ 114 | 115 | .output{ 116 | margin: 10px; 117 | /* box-shadow: 0px 0px 5px rgb(51, 48, 48); */ 118 | display: flex; 119 | flex-direction: column; 120 | /* display: none; */ 121 | 122 | } 123 | .output p{ 124 | font-size: 16px; 125 | border-radius: 4px; 126 | padding: 4px; 127 | margin:4px; 128 | width: 100%; 129 | box-shadow: 0px 0px 5px rgb(51, 48, 48); 130 | color:rgb(62, 58, 58); 131 | font-weight: 550; 132 | 133 | 134 | } 135 | .output p span{ 136 | float: right; 137 | word-wrap: break-word; 138 | color: rgb(101, 17, 41); 139 | font-weight: bolder; 140 | font-size: larger; 141 | } 142 | -------------------------------------------------------------------------------- /Floating Placeholder/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Floating Placeholder 1 8 | 9 | 10 | 11 |
12 |
13 | 14 | 15 |
16 |
17 | 18 | 19 |
20 |
21 | 22 | 23 |
24 |
25 | 26 | 27 |
28 |
29 | 30 | -------------------------------------------------------------------------------- /Floating Placeholder/style.css: -------------------------------------------------------------------------------- 1 | *{ 2 | margin:0; 3 | padding:0; 4 | box-sizing: border-box; 5 | } 6 | body{ 7 | display: flex; 8 | align-items: center; 9 | justify-content: center; 10 | min-height: 100vh; 11 | width: 100%; 12 | background-image: linear-gradient(to bottom,purple,rgb(238, 48, 238)); 13 | } 14 | .container{ 15 | width: 400px; 16 | height: 500px; 17 | display: flex; 18 | align-items: center; 19 | justify-content: space-evenly; 20 | flex-direction: column; 21 | box-shadow:0px 0px 20px 2px rgb(56, 52, 52); 22 | border-radius: 10px; 23 | background-color: white; 24 | } 25 | .input-container{ 26 | position: relative; 27 | } 28 | input{ 29 | height: 40px; 30 | width: 300px; 31 | border:none; 32 | outline: none; 33 | border-radius: 5px; 34 | padding:5px; 35 | box-shadow: 0px 0px 5px 1px rgb(121, 121, 121); 36 | } 37 | label{ 38 | position: absolute; 39 | left: 0; 40 | top:0; 41 | padding:10px; 42 | font-size: 15px; 43 | color: rgb(128, 132, 135); 44 | } 45 | 46 | /* TOP */ 47 | #top + label{ 48 | transition: 0.3s ease-out; 49 | } 50 | #top:focus + label, #top:valid + label{ 51 | top:-40px; 52 | left:-8px; 53 | color:purple; 54 | font-size: 20px; 55 | font-weight: bold; 56 | } 57 | 58 | /* left */ 59 | #left{ 60 | transition: 0.4s; 61 | } 62 | #left + label{ 63 | border-radius: 4px; 64 | transition: 0.5s ease-in-out transform; 65 | } 66 | #left:focus + label, #left:valid + label{ 67 | /* left:-30px; */ 68 | transform: translateX(-30px); 69 | top:-1.5px; 70 | font-size: 20px; 71 | padding:10px; 72 | background-color: purple; 73 | color:white; 74 | border-top-right-radius: 0; 75 | border-bottom-right-radius: 0; 76 | } 77 | #left:focus, #left:valid{ 78 | position: relative; 79 | left:20px; 80 | width: 250px; 81 | border-top-left-radius: 0; 82 | border-bottom-left-radius: 0; 83 | /* background-color: beige; */ 84 | } 85 | 86 | /* Right */ 87 | #right + label{ 88 | border-radius: 4px; 89 | transition: 0.3s ease transform; 90 | } 91 | #right:focus + label, #right:valid + label{ 92 | /* right:-33px; */ 93 | /* left:222px; */ 94 | top:-1.5px; 95 | transform: translateX(222px); 96 | font-size: 20px; 97 | padding:10px; 98 | background-color:purple; 99 | color:rgb(243, 235, 235); 100 | border-top-left-radius: 0; 101 | border-bottom-left-radius: 0; 102 | } 103 | #rigth:focus,#right:focus-within ,#right:valid{ 104 | position: relative; 105 | width: 250px; 106 | left:-28px; 107 | border-top-right-radius: 0; 108 | border-bottom-right-radius: 0; 109 | } 110 | 111 | /* bottom */ 112 | #bottom + label{ 113 | transition: 0.4s transform; 114 | } 115 | 116 | #bottom:focus + label,#bottom:valid + label{ 117 | padding:4px; 118 | width:100%; 119 | height: 20px; 120 | font-size: 14px; 121 | background-color: purple; 122 | color:white; 123 | border-radius: 5px; 124 | border-top-left-radius: 0; 125 | border-top-right-radius: 0; 126 | transform: translateY(30px); 127 | } 128 | #bottom:focus, #bottom:valid{ 129 | border-bottom-left-radius: 0; 130 | border-bottom-right-radius: 0; 131 | } 132 | 133 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /Palindrome Checker/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | 11 |
12 |

Check Palindrome

13 | 14 | 15 |
16 |
17 | 18 | 19 | -------------------------------------------------------------------------------- /Palindrome Checker/script.js: -------------------------------------------------------------------------------- 1 | function reverseString(str){ 2 | let splitString = str.split(""); 3 | let reverseArray = splitString.reverse(); 4 | let joinArray = reverseArray.join(""); 5 | return joinArray; 6 | //return str.split("").reverse().join(""); 7 | } 8 | function palindromeCheck(){ 9 | let msg = document.getElementById("msg").value; 10 | let ans = document.getElementById("answer"); 11 | if(msg=="") 12 | { 13 | alert("Please enter any string"); 14 | }else{ 15 | msg = msg.toLowerCase(); 16 | if(msg == reverseString(msg)){ 17 | ans.innerHTML = "It's Palindrome!"; 18 | }else{ 19 | ans.innerHTML = "It's not Palindrome!"; 20 | } 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /Palindrome Checker/style.css: -------------------------------------------------------------------------------- 1 | *{ 2 | margin:0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | body{ 7 | display: flex; 8 | justify-content: center; 9 | align-items: center; 10 | min-height: 100vh; 11 | } 12 | .container{ 13 | width:300px; 14 | height: 300px; 15 | display: flex; 16 | justify-content: center; 17 | align-items: center; 18 | flex-direction: column; 19 | padding: 10px; 20 | box-shadow: 0 0 10px 2px rgb(194, 167, 167); 21 | } 22 | .container p{ 23 | margin-bottom: 10px; 24 | font-weight: 600; 25 | color: rgb(101, 128, 129); 26 | } 27 | #msg{ 28 | height: 30px; 29 | width: 80%; 30 | outline: none; 31 | border: none; 32 | box-shadow: 0 0 2px 2px rgb(179, 171, 171); 33 | border-radius: 5px; 34 | padding: 4px; 35 | } 36 | .check{ 37 | width: 100px; 38 | height: 40px; 39 | margin-top: 10px; 40 | font-size: larger; 41 | font-family: 'Times New Roman', Times, serif; 42 | background-color: cadetblue; 43 | border:none; 44 | color:white; 45 | border-radius: 10px; 46 | box-shadow: 2px 2px rgb(91, 120, 121); 47 | transform: 1s; 48 | } 49 | .check:active{ 50 | box-shadow: none; 51 | } 52 | #answer{ 53 | margin-top: 30px; 54 | width:200px; 55 | height: 100px; 56 | display: flex; 57 | justify-content: center; 58 | align-items: center; 59 | color: rgb(76, 71, 71); 60 | font-size: 20px; 61 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JavaScript-Projects 2 | JavaScript projects for beginners. Complete Video tutorial available on Youtube in Hindi. 3 |

Complete JavaScript projects playlist in HINDI

Follow Computer Nerds YouTube

4 |
    5 |

  1. Random Password Generator
  2. 6 | Video Tutorial | 7 | Code
    8 | image 9 |

  3. Digital Clock
  4. 10 | Video Tutorial | 11 | Code
    12 |

  5. Digital Clock with Date
  6. 13 | Video Tutorial | 14 | Code
    15 | image 16 |

  7. Stopwatch
  8. 17 | Video Tutorial | 18 | Code
    19 | image 20 |

  9. Palindrome Checker
  10. 21 | Video Tutorial | 22 | Code
    23 | image 24 |

  11. Age Calculator
  12. 25 | Video Tutorial | 26 | Code
    27 | ageCalculator2 28 |

  13. Length Converter
  14. 29 | Video Tutorial | 30 | Code
    31 | image 32 |

  15. Quiz Application
  16. 33 | There are three part of this application. 34 | Video Tutorial | 35 | Code
    36 | image 37 |

  17. Animated Login Page
  18. 38 | Video Tutorial | 39 | Code
    40 | login add for fb 41 |

  19. Floating Placeholders
  20. 42 | Video Tutorial | 43 | Code
    44 | floating placeholder 45 |

  21. Registration Form Validation
  22. 46 | Video Tutorial | 47 | Code
    48 | image 49 |

  23. EMI Calculator
  24. 50 | Video Tutorial | 51 | Code
    52 | image 53 |

  25. Automatic Image Slider
  26. 54 | Video Tutorial | 55 | automatic image slider 56 |

  27. Filterable Image Gallery
  28. 57 | Video Tutorial | 58 | Code
    59 | image gallery 60 | 61 | 62 | 63 | 64 | 65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /Side bar open close/sidebar.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 68 | 69 | 70 | 71 | 78 | 79 |
80 | 81 |

Collapsed Sidebar

82 |

Click on the hamburger menu/bar icon to open the sidebar, and push this content to the right.

83 |
84 | 85 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /SliderJavaScript/images/800px-Shakuzoji_Kuginuki_Jizo-3586.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachinsaini4278/JavaScript-Projects/13803488681577ac93d4ab73e14d7bbc4a3d23bb/SliderJavaScript/images/800px-Shakuzoji_Kuginuki_Jizo-3586.jpg -------------------------------------------------------------------------------- /SliderJavaScript/images/800px-Stirling_Castle_Main_Gate.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachinsaini4278/JavaScript-Projects/13803488681577ac93d4ab73e14d7bbc4a3d23bb/SliderJavaScript/images/800px-Stirling_Castle_Main_Gate.jpg -------------------------------------------------------------------------------- /SliderJavaScript/images/829012.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachinsaini4278/JavaScript-Projects/13803488681577ac93d4ab73e14d7bbc4a3d23bb/SliderJavaScript/images/829012.jpg -------------------------------------------------------------------------------- /SliderJavaScript/images/Technology-Dekstop-Wallpapers.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachinsaini4278/JavaScript-Projects/13803488681577ac93d4ab73e14d7bbc4a3d23bb/SliderJavaScript/images/Technology-Dekstop-Wallpapers.jpg -------------------------------------------------------------------------------- /SliderJavaScript/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 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 | -------------------------------------------------------------------------------- /SliderJavaScript/script.js: -------------------------------------------------------------------------------- 1 | let slides = document.getElementsByClassName("slide"); 2 | let navlinks = document.getElementsByClassName("dot"); 3 | let currentSlide = 0; 4 | 5 | document.getElementById("button-next").addEventListener("click", () => { 6 | changeSlide(currentSlide + 1); 7 | }); 8 | document.getElementById("button-prev").addEventListener("click", () => { 9 | changeSlide(currentSlide - 1); 10 | }); 11 | 12 | function changeSlide(moveTo) { 13 | console.log("c",currentSlide); 14 | if (moveTo >= slides.length) { 15 | moveTo = 0; 16 | } 17 | if (moveTo < 0) { 18 | moveTo = slides.length - 1; 19 | } 20 | 21 | slides[currentSlide].classList.toggle("active"); 22 | navlinks[currentSlide].classList.toggle("activeDot"); 23 | slides[moveTo].classList.toggle("active"); 24 | navlinks[moveTo].classList.toggle("activeDot"); 25 | currentSlide = moveTo; 26 | } 27 | 28 | document.querySelectorAll(".dot").forEach((bullet, bulletIndex) => { 29 | bullet.addEventListener("click", () => { 30 | if (currentSlide !== bulletIndex) { 31 | changeSlide(bulletIndex); 32 | } 33 | }); 34 | }); 35 | -------------------------------------------------------------------------------- /SliderJavaScript/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | .container { 8 | width: 100%; 9 | height: 400px; 10 | background-color: aquamarine; 11 | position: relative; 12 | } 13 | .container img{ 14 | display: none; 15 | width: 100%; 16 | height: 400px; 17 | } 18 | .active img{ 19 | display: block; 20 | } 21 | .slider-button{ 22 | background: rgba(255, 255, 255, 0.55); 23 | cursor: pointer; 24 | border-radius: 50%; 25 | width: 30px; 26 | height: 30px; 27 | display: flex; 28 | justify-content: center; 29 | align-items: center; 30 | padding: 5px; 31 | box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.4); 32 | font-size: 25px; 33 | 34 | position: absolute; 35 | z-index: 10; 36 | top:50%; 37 | font-weight: 600; 38 | transition:0.6s; 39 | } 40 | #button-prev{ 41 | left:10px; 42 | 43 | } 44 | #button-next{ 45 | right:10px; 46 | } 47 | .slider-button:hover{ 48 | background-color: #717171; 49 | } 50 | .dots-container{ 51 | position: absolute; 52 | bottom: 10px; 53 | left:50%; 54 | } 55 | 56 | .dot { 57 | cursor:pointer; 58 | height: 13px; 59 | width: 13px; 60 | margin: 0 2px; 61 | background-color: #bbb; 62 | border-radius: 50%; 63 | display: inline-block; 64 | transition: background-color 0.6s; 65 | } 66 | .dot:hover { 67 | background-color: #b75d5d; 68 | } 69 | .dots-container .activeDot{ 70 | background-color: rgb(212, 102, 80); 71 | } 72 | -------------------------------------------------------------------------------- /Text-formatter/Version-1/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Text Formatter 8 | 9 | 10 | 11 |
12 |

Text Formatter

13 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 |
26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /Text-formatter/Version-1/script.js: -------------------------------------------------------------------------------- 1 | let txt = document.getElementById("inputBox"); 2 | document.getElementsByName('format-option').forEach(function(e,index) { 3 | e.addEventListener("click", ()=> { 4 | formatText(index); 5 | }); 6 | }); 7 | 8 | function formatText(index){ 9 | switch(index){ 10 | case 0: txt.value = txt.value.toUpperCase(); break; 11 | case 1: txt.value = txt.value.toLowerCase(); break; 12 | case 2: txt.value = capitalizeSentence(txt.value); break; 13 | case 3: txt.value = capitalizeWord(txt.value); break; 14 | } 15 | } 16 | 17 | function capitalizeWord(str){ 18 | let newString = removeExtraSpaces(str); 19 | let splitSentence = newString.split(" "); 20 | console.log(splitSentence) 21 | for (let i = 0; i < splitSentence.length; i++) { 22 | splitSentence[i] = splitSentence[i][0].toUpperCase()+splitSentence[i].slice(1); 23 | } 24 | console.log(splitSentence) 25 | splitSentence=splitSentence.join(" "); 26 | // console.log(splitSentence) 27 | return splitSentence; 28 | } 29 | function capitalizeSentence(str){ 30 | let newString = removeExtraSpaces(str); 31 | let splitSentence = newString.split(". "); 32 | // console.log(splitSentence) 33 | for (let i = 0; i < splitSentence.length; i++) { 34 | splitSentence[i] = splitSentence[i][0].toUpperCase()+splitSentence[i].slice(1); 35 | } 36 | // console.log(splitSentence) 37 | splitSentence=splitSentence.join(". "); 38 | // console.log(splitSentence) 39 | return splitSentence; 40 | } 41 | function removeExtraSpaces(str){ 42 | return str.replace(/\s+/g,' ').trim(); 43 | } -------------------------------------------------------------------------------- /Text-formatter/Version-1/style.css: -------------------------------------------------------------------------------- 1 | *{ 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | .container{ 7 | display: flex; 8 | flex-direction: column; 9 | align-items: center; 10 | padding-top: 20px; 11 | width: 100vw; 12 | height: 100vh; 13 | } 14 | .container textarea{ 15 | width: 70%; 16 | height: 40%; 17 | outline: none; 18 | border-radius: 10px; 19 | font-size: 20px; 20 | font-family: Cambria; 21 | max-width: 780px; 22 | resize:vertical; 23 | margin-top: 20px; 24 | padding: 4px; 25 | padding-top: 10px; 26 | transition: box-shadow .15s ease-in-out; 27 | } 28 | .container textarea:focus{ 29 | box-shadow: 0px 0px 2px 4px rgb(177, 217, 234); 30 | } 31 | .heading{ 32 | color:rgb(63, 95, 96); 33 | } 34 | .options{ 35 | display: flex; 36 | flex-direction: column; 37 | margin-top: 10px; 38 | } 39 | .label{ 40 | display: flex; 41 | justify-content:center; 42 | align-items: center; 43 | margin:4px; 44 | padding: 10px; 45 | width:300px; 46 | border-radius: 4px; 47 | box-shadow: 4px 4px 6px 1px rgb(99, 124, 125); 48 | font-size: 20px; 49 | color:rgb(63, 95, 96); 50 | transition: all 0.5s; 51 | } 52 | .options label:hover{ 53 | cursor: pointer; 54 | background-color: rgb(225, 239, 238); 55 | color:black; 56 | } 57 | .options input[type="radio"]{ 58 | display: none; 59 | } 60 | .options input[type="radio"]:checked+label{ 61 | background-color: rgb(82, 167, 161); 62 | color: white; 63 | box-shadow: 2px 1px 1px 1px rgb(99, 124, 125); 64 | } -------------------------------------------------------------------------------- /Text-formatter/Version-2/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Text Formatter 8 | 9 | 10 | 11 |
12 |

Text Formatter

13 | 15 |
16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
32 |
33 |
34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /Text-formatter/Version-2/script.js: -------------------------------------------------------------------------------- 1 | let txt = document.getElementById("inputBox"); 2 | document.getElementsByName('format-option').forEach(function(e,index) { 3 | e.addEventListener("click", ()=> { 4 | formatText(index); 5 | }); 6 | }); 7 | 8 | function formatText(index){ 9 | if(txt.value==""){ 10 | document.getElementsByName('format-option')[index].checked= false; 11 | } 12 | else{ 13 | switch(index){ 14 | case 0: txt.value = txt.value.toUpperCase(); break; 15 | case 1: txt.value = txt.value.toLowerCase(); break; 16 | case 2: txt.value = capitalizeSentence(txt.value); break; 17 | case 3: txt.value = capitalizeWord(txt.value); break; 18 | case 4: txt.value = removeNumber(txt.value); break; 19 | case 5: txt.value = removePunctuation(txt.value); break; 20 | } 21 | } 22 | } 23 | 24 | function capitalizeWord(str){ 25 | let newString = removeExtraSpaces(str); 26 | let splitSentence = newString.split(" "); 27 | for (let i = 0; i < splitSentence.length; i++) { 28 | splitSentence[i] = splitSentence[i][0].toUpperCase()+splitSentence[i].slice(1); 29 | } 30 | splitSentence=splitSentence.join(" "); 31 | return splitSentence; 32 | } 33 | function capitalizeSentence(str){ 34 | let newString = removeExtraSpaces(str); 35 | let splitSentence = newString.split(". "); 36 | for (let i = 0; i < splitSentence.length; i++) { 37 | splitSentence[i] = splitSentence[i][0].toUpperCase()+splitSentence[i].slice(1); 38 | } 39 | splitSentence=splitSentence.join(". "); 40 | return splitSentence; 41 | } 42 | function removeExtraSpaces(str){ 43 | let regex=/\s+/g; 44 | return str.replace(regex,' ').trim(); 45 | } 46 | function removePunctuation(str){ 47 | let regex = /[!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~]/g; 48 | return str.replace(regex, ''); 49 | //"Hi!!$% this i&*&^s Compu()terNerds{}" 50 | } 51 | function removeNumber(str){ 52 | return str.replace(/[0-9]/g, ''); 53 | } -------------------------------------------------------------------------------- /Text-formatter/Version-2/style.css: -------------------------------------------------------------------------------- 1 | *{ 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | .container{ 7 | display: flex; 8 | flex-direction: column; 9 | align-items: center; 10 | padding-top: 20px; 11 | width: 100vw; 12 | height: 100vh; 13 | } 14 | .container textarea{ 15 | width: 70%; 16 | height: 40%; 17 | outline: none; 18 | border-radius: 10px; 19 | font-size: 20px; 20 | font-family: Cambria; 21 | max-width: 780px; 22 | resize:vertical; 23 | margin-top: 20px; 24 | padding: 4px; 25 | padding-top: 10px; 26 | transition: box-shadow .15s ease-in-out; 27 | } 28 | .container textarea:focus{ 29 | box-shadow: 0px 0px 2px 4px rgb(177, 217, 234); 30 | } 31 | .heading{ 32 | color:rgb(63, 95, 96); 33 | } 34 | .options-container{ 35 | display: flex; 36 | } 37 | .options{ 38 | display: flex; 39 | flex-direction: column; 40 | margin: 10px; 41 | } 42 | .label{ 43 | display: flex; 44 | justify-content:center; 45 | align-items: center; 46 | margin:4px; 47 | padding: 10px; 48 | /* width:300px; */ 49 | border-radius: 4px; 50 | box-shadow: 4px 4px 6px 1px rgb(99, 124, 125); 51 | font-size: 20px; 52 | color:rgb(63, 95, 96); 53 | transition: all 0.5s; 54 | } 55 | .options label:hover{ 56 | cursor: pointer; 57 | background-color: rgb(141, 157, 156); 58 | color:black; 59 | } 60 | .options input[type="radio"]{ 61 | display: none; 62 | } 63 | .options input[type="radio"]:checked+label{ 64 | background-color: rgb(82, 167, 161); 65 | color: white; 66 | box-shadow: 2px 1px 1px 1px rgb(99, 124, 125); 67 | } -------------------------------------------------------------------------------- /Text-formatter/readme.md: -------------------------------------------------------------------------------- 1 |

Text Formatter Version 1


2 | It is the version 1 of the text formatter application. It is having follwing functionalities: 3 |
    4 |
  1. Text can be converted into Uppercase.
  2. 5 |
  3. Text can be converted into Lowercase.
  4. 6 |
  5. Capitalize every sentence's first letter.
  6. 7 |
  7. Capitalize every word's first letter.
  8. 8 |
9 | image 10 | 11 |

Text Formatter Version 2


12 | It is the version 2 of the text formatter application. It is having follwing functionalities: 13 |
    14 |
  1. Text can be converted into Uppercase.
  2. 15 |
  3. Text can be converted into Lowercase.
  4. 16 |
  5. Capitalize every sentence's first letter.
  6. 17 |
  7. Capitalize every word's first letter.
  8. 18 |
  9. Remove Numbers.
  10. 19 |
  11. Remove Punctuations.
  12. 20 |
21 | image 22 | -------------------------------------------------------------------------------- /Word Counter/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Words Counter 8 | 9 | 10 | 11 |
12 |

Words Counter

13 | 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 | -------------------------------------------------------------------------------- /Word Counter/script.js: -------------------------------------------------------------------------------- 1 | function getWordCount(str) { 2 | let splited=str.trim().split(/\s+/); 3 | console.log(splited); 4 | if(splited==''){ 5 | return 0; 6 | } 7 | return splited.length; 8 | } 9 | function counter(str){ 10 | let alphaCount=0; 11 | let numberCount=0; 12 | let charCount=0; 13 | for(let i=0;i='a'&&str[i]<='z') || (str[i]>='A' && str[i]<='Z')){ 18 | alphaCount++; 19 | } 20 | else if(str[i]>='0' && str[i]<='9'){ 21 | numberCount++; 22 | } 23 | } 24 | document.getElementById("chars").value = charCount; 25 | document.getElementById("numbers").value = numberCount; 26 | document.getElementById("alphabets").value = alphaCount; 27 | } 28 | function wordCounter() 29 | { 30 | let inputTxt = document.getElementById("inputBox"); 31 | let words = getWordCount(inputTxt.value); 32 | document.getElementById("words").value = words; 33 | counter(inputTxt.value); 34 | } -------------------------------------------------------------------------------- /Word Counter/style.css: -------------------------------------------------------------------------------- 1 | *{ 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | .container{ 7 | display: flex; 8 | flex-direction: column; 9 | align-items: center; 10 | padding-top: 20px; 11 | width: 100vw; 12 | height: 100vh; 13 | background-color: rgb(95, 94, 88); 14 | color:white; 15 | } 16 | .container textarea{ 17 | width: 70%; 18 | height: 40%; 19 | outline: none; 20 | border-radius: 10px; 21 | font-size: 20px; 22 | font-family: Cambria; 23 | max-width: 780px; 24 | resize:vertical; 25 | margin-top: 20px; 26 | padding: 4px; 27 | padding-top: 10px; 28 | transition: box-shadow .15s ease-in-out; 29 | } 30 | .container textarea:focus{ 31 | box-shadow: 0px 0px 2px 4px rgb(150, 148, 138); 32 | } 33 | .outputBox{ 34 | display: flex; 35 | flex-direction: column; 36 | margin-top: 10px; 37 | } 38 | .outputBox div{ 39 | display: flex; 40 | justify-content: space-between; 41 | align-items: center; 42 | padding: 4px; 43 | } 44 | .outputBox input{ 45 | width:90px; 46 | height: 40px; 47 | margin-left: 10px; 48 | box-shadow: 1px 1px 1px 1px rgb(91, 86, 86); 49 | border:none; 50 | border-radius: 4px; 51 | background-color:rgb(220, 222, 225); 52 | color: rgb(144, 50, 6); 53 | font-weight: bold; 54 | font-size: larger; 55 | } 56 | .outputBox label{ 57 | font-weight: bold; 58 | font-size: larger; 59 | /* color:rgb(33, 26, 26); */ 60 | } -------------------------------------------------------------------------------- /ageCalculator/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Age Calculator 8 | 9 | 10 | 11 |
12 |

Age Calculator

13 |
14 | 15 | 16 |
17 |
18 | 19 | 20 |
21 | 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /ageCalculator/script.js: -------------------------------------------------------------------------------- 1 | let dob = document.getElementById("birthDate"); 2 | let currentDate = document.getElementById("currentDate"); 3 | let output = document.getElementById("output"); 4 | 5 | document.getElementById("calculateBtn").addEventListener("click",()=>{ 6 | if(dob.value=="" || currentDate.value==""){ 7 | output.innerHTML = "Please select Date"; 8 | }else{ 9 | calculateAgeDifference(dob.value,currentDate.value); 10 | } 11 | 12 | }); 13 | 14 | function calculateAgeDifference(start,end){ 15 | console.log(start); 16 | let dobYear = parseInt(start.substring(0,4), 10); //Base 10 17 | let dobMonth = parseInt(start.substring(5,7), 10); 18 | let dobDate = parseInt(start.substring(8,10), 10); 19 | let currYear = parseInt(end.substring(0,4), 10); //Base 10 20 | let currMonth = parseInt(end.substring(5,7), 10); 21 | let currDate = parseInt(end.substring(8,10), 10); 22 | 23 | //year difference 24 | let yearAgeDiff = currYear - dobYear; 25 | 26 | //month difference 27 | let monthAgeDiff; 28 | if(currMonth >= dobMonth){ 29 | monthAgeDiff = currMonth - dobMonth; 30 | } 31 | else{ 32 | yearAgeDiff--; 33 | monthAgeDiff = 12 + currMonth - dobMonth; 34 | } 35 | 36 | //days difference 37 | let dateAgeDiff; 38 | if(currDate>=dobDate){ 39 | dateAgeDiff = currDate - dobDate; 40 | } 41 | else{ 42 | monthAgeDiff--; 43 | noOfDaysInDOB = daysInMonth(dobMonth,dobYear); 44 | dateAgeDiff = noOfDaysInDOB + currDate - dobDate; 45 | 46 | //case when monthAgeDiff goes negative 47 | if(monthAgeDiff<0){ 48 | monthAgeDiff=11; 49 | yearAgeDiff--; 50 | } 51 | } 52 | 53 | output.innerHTML = yearAgeDiff + " Years, " + monthAgeDiff + " Months, " + dateAgeDiff + " Days."; 54 | } 55 | 56 | function daysInMonth (month, year) { 57 | return new Date(year, month, 0).getDate(); 58 | } 59 | -------------------------------------------------------------------------------- /ageCalculator/style.css: -------------------------------------------------------------------------------- 1 | *{ 2 | margin:0; 3 | padding:0; 4 | box-sizing: border-box; 5 | } 6 | body{ 7 | display: flex; 8 | justify-content: center; 9 | align-items: center; 10 | min-height: 100vh; 11 | } 12 | .container{ 13 | box-shadow: 0 0 4px 1px rgb(179, 169, 169); 14 | width: 400px; 15 | height: 350px; 16 | border-radius: 10px; 17 | display: flex; 18 | /* justify-content: center; */ 19 | align-items: center; 20 | flex-direction: column; 21 | } 22 | .container p{ 23 | color: rgb(20, 94, 82); 24 | margin: 10px; 25 | font-size: 20px; 26 | font-weight: bolder; 27 | font-family: Cambria, Cochin, Georgia, Times, 'Times New Roman', serif; 28 | } 29 | .date-container label{ 30 | font-size: larger; 31 | margin-right:10px; 32 | } 33 | #birthDate,#currentDate{ 34 | width: 140px; 35 | height: 40px; 36 | border:none; 37 | box-shadow: 0 0 2px 1px rgb(210, 197, 197); 38 | border-radius: 10px; 39 | margin-top: 10px; 40 | padding: 4px; 41 | font-family: 'Times New Roman', Times, serif; 42 | color:rgb(149, 79, 79); 43 | font-size: larger; 44 | } 45 | #calculateBtn{ 46 | width: 100px; 47 | height: 50px; 48 | margin-top: 20px; 49 | font-size: larger; 50 | font-family: 'Times New Roman', Times, serif; 51 | /* background-color: rgb(198, 204, 198); 52 | color:white; */ 53 | border:none; 54 | outline: none; 55 | border-radius: 5px; 56 | box-shadow: 1px 3px 3px rgb(56, 84, 56); 57 | cursor: pointer; 58 | transition: 0.3s; 59 | } 60 | #calculateBtn:active{ 61 | box-shadow: 0 0 0 0; 62 | } -------------------------------------------------------------------------------- /digital clock/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Digital Clock 9 | 10 | 26 | 27 | 28 | 29 |
30 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /digital clock/pexels-photo-235986.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachinsaini4278/JavaScript-Projects/13803488681577ac93d4ab73e14d7bbc4a3d23bb/digital clock/pexels-photo-235986.jpeg -------------------------------------------------------------------------------- /formValidation/using JavaScript/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Form Validation JavaScript 8 | 9 | 10 | 11 |
12 |
13 |

Registration Form

14 |
15 |
16 |
17 | 18 | 19 | 20 | 21 | Error message 22 |
23 |
24 | 25 | 26 | 27 | 28 | Error message 29 |
30 |
31 | 32 | 33 | 34 | 35 | Error message 36 |
37 |
38 | 39 | 40 | 41 | 42 | Error message 43 |
44 | 45 |
46 |
47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /formValidation/using JavaScript/script.js: -------------------------------------------------------------------------------- 1 | let username=document.getElementById("name"); 2 | let emailId=document.getElementById("mail"); 3 | let password=document.getElementById("password"); 4 | let confirmPassword=document.getElementById("confirmPassword"); 5 | let submitButton = document.getElementById("btn"); 6 | 7 | // Input Handlers 8 | function nameHandler(){ 9 | if(username.value===""){ 10 | setErrorForInput(username,"Username can't be blank"); 11 | }else{ 12 | setSuccessForInput(username); 13 | } 14 | } 15 | function emailHandler(){ 16 | if(emailId.value===""){ 17 | setErrorForInput(emailId,"Email Id can't be blank"); 18 | } 19 | else if(!isEmail(emailId.value)){ 20 | setErrorForInput(emailId,"Enter a valid email address"); 21 | }else{ 22 | setSuccessForInput(emailId); 23 | } 24 | } 25 | function passwordHandler(){ 26 | if(password.value===''){ 27 | setErrorForInput(password,"Password can't be blank"); 28 | }else{ 29 | setSuccessForInput(password); 30 | } 31 | } 32 | function confirmPasswordHandler(){ 33 | if(confirmPassword.value===''){ 34 | setErrorForInput(confirmPassword,"Confirm Password can't be blank"); 35 | } 36 | else if(password.value !== confirmPassword.value){ 37 | setErrorForInput(confirmPassword,"Enter Same password") 38 | }else{ 39 | setSuccessForInput(confirmPassword); 40 | } 41 | } 42 | 43 | function checkAll(){ 44 | nameHandler(); 45 | emailHandler(); 46 | passwordHandler(); 47 | confirmPasswordHandler(); 48 | } 49 | function inputHandler(field){ 50 | switch(field){ 51 | case "name": 52 | nameHandler(); 53 | break; 54 | case "email": 55 | emailHandler(); 56 | break; 57 | case "password": 58 | passwordHandler(); 59 | break; 60 | case "confirmPassword": 61 | confirmPasswordHandler(); 62 | break; 63 | case "submit": 64 | checkAll(); 65 | } 66 | } 67 | 68 | submitButton.addEventListener('click',(e)=>{ 69 | e.preventDefault(); 70 | inputHandler("submit"); 71 | }); 72 | 73 | function setSuccessForInput(field){ 74 | const formHandle = field.parentElement; 75 | formHandle.className = 'input-container success'; 76 | } 77 | function setErrorForInput(field,message){ 78 | const formHandle = field.parentElement; 79 | formHandle.className = 'input-container error'; 80 | const small = formHandle.querySelector('small'); 81 | small.innerText = message; 82 | } 83 | 84 | function isEmail(email) { 85 | const res = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; 86 | return res.test(String(email).toLowerCase()); 87 | } -------------------------------------------------------------------------------- /formValidation/using JavaScript/style.css: -------------------------------------------------------------------------------- 1 | *{ 2 | margin:0; 3 | padding:0; 4 | box-sizing: border-box; 5 | } 6 | body{ 7 | display: flex; 8 | align-items: center; 9 | justify-content: center; 10 | min-height: 100vh; 11 | width: 100%; 12 | background-image: linear-gradient(to bottom,purple,rgb(238, 48, 238)); 13 | } 14 | .container{ 15 | box-shadow:0px 0px 20px 2px rgb(56, 52, 52); 16 | border-radius: 10px; 17 | background-color: white; 18 | overflow: hidden; 19 | width: 400px; 20 | max-width: 100%; 21 | } 22 | .header{ 23 | background-color: #f7f7f7; 24 | padding: 20px 40px; 25 | box-shadow: 3px 2px 4px 1px rgb(121, 117, 113); 26 | color:purple 27 | } 28 | form{ 29 | padding:30px 50px; 30 | } 31 | .input-container{ 32 | margin-bottom: 10px; 33 | padding-bottom: 20px; 34 | position: relative; 35 | } 36 | .input-container label{ 37 | display: inline-block; 38 | margin-bottom: 5px; 39 | color:purple; 40 | font-weight: bold; 41 | font-family: 'Times New Roman', Times, serif; 42 | } 43 | .input-container input{ 44 | width: 100%; 45 | border: 2px solid #f0f0f0; 46 | border-radius: 5px; 47 | box-shadow: 0px 0px 3px 1px rgb(121, 121, 121); 48 | padding:10px; 49 | display: block; 50 | font-size: 15px; 51 | } 52 | .input-container input:focus{ 53 | border-color: rgb(137, 130, 130) ; 54 | outline: none; 55 | } 56 | .input-container.success input{ 57 | border-color: #3ba562; 58 | } 59 | .input-container.error input{ 60 | border-color: rgb(208, 95, 87); 61 | } 62 | .input-container i{ 63 | position: absolute; 64 | top:37px; 65 | right: 10px; 66 | visibility: hidden; 67 | } 68 | .input-container.success i.fa-check-circle{ 69 | color:#24673d; 70 | visibility: visible; 71 | } 72 | .input-container.error i.fa-exclamation-circle{ 73 | color: #f14431; 74 | visibility: visible; 75 | } 76 | .input-container small{ 77 | color:#f14431; 78 | position: absolute; 79 | bottom:0; 80 | left:0; 81 | visibility: hidden; 82 | } 83 | .input-container.error small{ 84 | visibility: visible; 85 | } 86 | #btn{ 87 | width: 100px; 88 | height: 40px; 89 | box-shadow: 4px 4px 5px 1px rgb(57, 53, 53); 90 | font-size: larger; 91 | font-family: 'Times New Roman', Times, serif; 92 | transition: 0.5s; 93 | display: block; 94 | margin: auto; 95 | background-color: purple; 96 | border:none; 97 | outline: none; 98 | border-radius: 5px; 99 | color:white; 100 | } 101 | #btn:active{ 102 | box-shadow: none; 103 | } 104 | -------------------------------------------------------------------------------- /formValidation/using html/inputType.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | 11 |
12 |
13 | Email: 14 |
15 |
16 | Phone: 17 |
18 |
19 | 20 | Website: 21 |
22 |
23 | Range: 24 |
25 |
26 | Password: 27 |
28 | 29 |
30 | 31 | -------------------------------------------------------------------------------- /formValidation/using html/requiredAttribute.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | 11 |
12 |
13 | 14 | 15 |
16 | 17 |
18 | 19 | 20 | -------------------------------------------------------------------------------- /formValidation/using html/style.css: -------------------------------------------------------------------------------- 1 | *{ 2 | margin:0; 3 | padding:0; 4 | box-sizing: border-box; 5 | } 6 | body{ 7 | display: flex; 8 | justify-content: center; 9 | align-items: center; 10 | min-height: 100vh; 11 | } 12 | form{ 13 | display: flex; 14 | flex-direction: column; 15 | align-items: center; 16 | justify-content: center; 17 | box-shadow: 0px 0px 10px 1px rgb(100, 97, 97); 18 | width:400px; 19 | height: 400px; 20 | border-radius: 10px; 21 | background-color: rgb(243, 237, 231); 22 | } 23 | 24 | input{ 25 | margin:10px; 26 | border:none; 27 | box-shadow: 0px 0px 3px 1px rgb(135, 129, 129); 28 | border-radius: 5px; 29 | height: 30px; 30 | padding:10px; 31 | 32 | } 33 | #submit{ 34 | width: 100px; 35 | height: 50px; 36 | margin-top: 20px; 37 | font-size: larger; 38 | font-family: 'Times New Roman', Times, serif; 39 | border:none; 40 | outline: none; 41 | border-radius: 5px; 42 | box-shadow: 1px 3px 3px rgb(56, 84, 56); 43 | cursor: pointer; 44 | } -------------------------------------------------------------------------------- /lengthConverter/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | length coverter 8 | 9 | 10 | 11 |

Type a value in any of the fields to convert between Length measurements:

12 |
13 |

Length Converter

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 | -------------------------------------------------------------------------------- /lengthConverter/script.js: -------------------------------------------------------------------------------- 1 | let feet =document.getElementById("feet"); 2 | let meter =document.getElementById("meter"); 3 | let inch =document.getElementById("inches"); 4 | let cm =document.getElementById("cm"); 5 | let yard =document.getElementById("yards"); 6 | let km =document.getElementById("km"); 7 | let mile =document.getElementById("miles"); 8 | 9 | function feetToOther(val){ 10 | meter.value = val/3.2808; 11 | inch.value = val*12; 12 | cm.value = val/0.032808; 13 | yard.value = val*0.33333; 14 | km.value = val/3280.8; 15 | mile.value = val*0.00018939; 16 | } 17 | function meterToOther(val){ 18 | feet.value = val*3.2808; 19 | inch.value = val*39.370; 20 | cm.value = val/0.01; 21 | yard.value = val*1.0936; 22 | km.value = val/1000; 23 | mile.value = val*0.00062137; 24 | } 25 | function inchesToOther(val){ 26 | feet.value = val*0.083333; 27 | meter.value = val/39.370; 28 | cm.value = val/0.39370; 29 | yard.value = val*0.027778; 30 | km.value = val/39370; 31 | mile.value = val*0.000015783; 32 | } 33 | function cmToOther(val){ 34 | feet.value = val*0.032808; 35 | meter.value = val/100; 36 | inch.value = val*0.39370; 37 | yard.value = val*0.010936; 38 | km.value = val/100000 ; 39 | mile.value = val*0.0000062137; 40 | } 41 | function yardsToOther(val){ 42 | feet.value = val*3; 43 | inch.value = val*36; 44 | cm.value = val/0.010936; 45 | meter.value = val/1.0936; 46 | km.value = val/1093.6; 47 | mile.value = val*0.00056818; 48 | } 49 | function kmToOther(val){ 50 | feet.value = val*3280.8; 51 | inch.value = val*39370; 52 | cm.value = val*100000; 53 | yard.value = val*1093.6; 54 | meter.value = val*1000; 55 | mile.value = val*0.62137; 56 | } 57 | function milesToOther(val){ 58 | feet.value = val*5280; 59 | inch.value = val*63360; 60 | cm.value = val/0.0000062137; 61 | yard.value = val*1760; 62 | km.value = val/0.62137; 63 | meter.value = val/0.00062137; 64 | 65 | } 66 | // *********************// 67 | 68 | 69 | 70 | function convertToOthers(convertFrom,value){ 71 | switch(convertFrom){ 72 | case "feet" : feetToOther (parseFloat(value)); break; 73 | case "meter": meterToOther(parseFloat(value)); break; 74 | case "inch" : inchesToOther(parseFloat(value)); break; 75 | case "cm" : cmToOther(parseFloat(value)); break; 76 | case "yard" : yardsToOther (parseFloat(value)); break; 77 | case "km" : kmToOther (parseFloat(value)); break; 78 | case "mile" : milesToOther(parseFloat(value)); break; 79 | } 80 | } -------------------------------------------------------------------------------- /lengthConverter/style.css: -------------------------------------------------------------------------------- 1 | *{ 2 | margin:0; 3 | padding:0; 4 | box-sizing: border-box; 5 | } 6 | body{ 7 | display: flex; 8 | justify-content: center; 9 | align-items: center; 10 | min-height: 100vh; 11 | flex-direction: column; 12 | } 13 | .top-txt{ 14 | margin-bottom: 15px; 15 | } 16 | .container{ 17 | box-shadow: 0 0 4px 1px rgb(179, 169, 169); 18 | width: 400px; 19 | height: 350px; 20 | border-radius: 10px; 21 | display: flex; 22 | /* justify-content: center; */ 23 | align-items: center; 24 | flex-direction: column; 25 | } 26 | .container p{ 27 | color: rgb(20, 94, 82); 28 | margin: 10px; 29 | font-size: 20px; 30 | font-weight: bolder; 31 | font-family: Cambria, Cochin, Georgia, Times, 'Times New Roman', serif; 32 | } 33 | .inputContainer{ 34 | margin:5px; 35 | display: flex; 36 | justify-content: space-between; 37 | width:80%; 38 | } 39 | .inputContainer label{ 40 | font-size: larger; 41 | } 42 | .inputContainer input{ 43 | border:none; 44 | outline: none; 45 | box-shadow: 0.1px 1px 2px 1px rgb(145, 140, 140); 46 | padding:4px; 47 | font-size: large; 48 | border-radius: 2px; 49 | font-family: 'Times New Roman', Times, serif; 50 | } -------------------------------------------------------------------------------- /loginPage/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Login Page 8 | 9 | 10 | 11 |
12 | 13 | 20 | 26 |
27 | 28 | -------------------------------------------------------------------------------- /loginPage/style.css: -------------------------------------------------------------------------------- 1 | *{ 2 | margin:0; 3 | padding:0; 4 | box-sizing: border-box; 5 | } 6 | body{ 7 | display: flex; 8 | align-items: center; 9 | justify-content: center; 10 | min-height: 100vh; 11 | width: 100%; 12 | } 13 | 14 | .container { 15 | display: flex; 16 | align-items: center; 17 | flex-direction: column; 18 | height: 400px; 19 | width: 400px; 20 | background-color: white; 21 | border-radius: 15px; 22 | box-shadow: 2px 2px 10px 1px rgb(102, 3, 102); 23 | overflow: hidden; 24 | padding: 10px; 25 | position: relative; 26 | } 27 | #switch{ 28 | display: none; 29 | } 30 | .signup{ 31 | display: flex; 32 | align-items: center; 33 | flex-direction: column; 34 | width: 100%; 35 | } 36 | 37 | input{ 38 | width: 60%; 39 | height: 20px; 40 | background: #e0dede; 41 | border:none; 42 | outline: none; 43 | margin:10px; 44 | height: 30px; 45 | padding:20px; 46 | border-radius: 10px; 47 | } 48 | .login{ 49 | display: flex; 50 | align-items: center; 51 | flex-direction: column; 52 | position: absolute; 53 | top:320px; 54 | background-image: linear-gradient(to bottom,purple,rgb(238, 48, 238)); 55 | width: 100%; 56 | height: 460px; 57 | transition: 0.8s ease-in-out; 58 | border-radius: 60%/10%; 59 | /* border-top-left-radius: 60% 10%; 60 | border-top-right-radius: 60% 10%; 61 | border-bottom-right-radius: 60% 10%; 62 | border-bottom-left-radius: 60% 10%; */ 63 | } 64 | label{ 65 | font-size: 2rem; 66 | margin:20px; 67 | font-weight: bolder; 68 | transition: .5s ease-in-out; 69 | cursor: pointer; 70 | } 71 | .login label{ 72 | color:white; 73 | transform: scale(0.6); 74 | } 75 | #submit-button{ 76 | padding:10px; 77 | border:none; 78 | background-color: purple; 79 | color:white; 80 | border-radius: 5px; 81 | box-shadow: 3px 3px 2px 1px rgb(236, 208, 208); 82 | font-size: large; 83 | font-family:Cambria, Cochin, Georgia, Times, 'Times New Roman', serif; 84 | transition: 0.2s; 85 | } 86 | #submit-button:active{ 87 | box-shadow:none; 88 | } 89 | #switch:checked ~ .login{ 90 | top:80px; 91 | } 92 | #switch:checked ~ .login label{ 93 | transform: scale(1); 94 | } 95 | #switch:checked ~ .signup label{ 96 | transform: scale(0.6); 97 | } -------------------------------------------------------------------------------- /random password Generator/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | 11 |
12 |
13 |

Password Generator

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 | -------------------------------------------------------------------------------- /random password Generator/main.js: -------------------------------------------------------------------------------- 1 | const keys = { 2 | upperCase: "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 3 | lowerCase: "abcdefghijklmnopqrstuvwxyz", 4 | number: "0123456789", 5 | symbol: "!@#$%^&*()_+~\\`|}{[]:;?><,./-=" 6 | } 7 | const getKey = [ 8 | function upperCase() { 9 | return keys.upperCase[Math.floor(Math.random() * keys.upperCase.length)]; 10 | }, 11 | function lowerCase() { 12 | return keys.lowerCase[Math.floor(Math.random() * keys.lowerCase.length)]; 13 | }, 14 | function number() { 15 | return keys.number[Math.floor(Math.random() * keys.number.length)]; 16 | }, 17 | function symbol() { 18 | return keys.symbol[Math.floor(Math.random() * keys.symbol.length)]; 19 | } 20 | ]; 21 | function generatePassword(){ 22 | // alert("called"); 23 | let passwordBox = document.getElementById("password"); 24 | let length = document.getElementById("length").value; 25 | let symbol = document.getElementById("symbol").checked; 26 | let number = document.getElementById("number").checked; 27 | let upperCase = document.getElementById("upperCase").checked; 28 | let lowerCase = document.getElementById("lowerCase").checked; 29 | if(!length) 30 | { 31 | alert("Please Select lenght"); 32 | return; 33 | } 34 | if(!symbol && !number && !upperCase && !lowerCase){ 35 | alert("Please check atleast one box!"); 36 | return; 37 | } 38 | let password = ""; 39 | while (length > password.length) { 40 | let keyToAdd = getKey[Math.floor(Math.random() * getKey.length)]; 41 | let isChecked = document.getElementById(keyToAdd.name).checked; 42 | if (isChecked) { 43 | password += keyToAdd(); 44 | } 45 | } 46 | passwordBox.innerHTML = password; 47 | 48 | } 49 | function copyPassword() { 50 | const password = document.getElementById("password").innerText; 51 | if (!password) { return; } 52 | navigator.clipboard.writeText(password); 53 | alert('Password copied to clipboard'); 54 | } -------------------------------------------------------------------------------- /random password Generator/style.css: -------------------------------------------------------------------------------- 1 | *{ 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | .container{ 7 | display: flex; 8 | justify-content: center; 9 | align-items: center; 10 | height: 100vh; 11 | } 12 | .passwordBox{ 13 | box-shadow: 0px 0px 6px #af4646; 14 | display: flex; 15 | justify-content: center; 16 | flex-direction: column; 17 | width: 350px; 18 | 19 | } 20 | .passwordBox h3{ 21 | margin-top: 10px; 22 | text-align: center; 23 | } 24 | .password-value-container{ 25 | background-color: rgb(228, 200, 200); 26 | display: flex; 27 | justify-content: space-between; 28 | align-items: center; 29 | margin:30px; 30 | border-radius:10px; 31 | } 32 | .password-value-container p{ 33 | padding:10px; 34 | font-size: larger; 35 | height: 50px; 36 | } 37 | .password-value-container i{ 38 | margin-right: 10px; 39 | font-size: larger; 40 | } 41 | 42 | .option-container{ 43 | display: flex; 44 | flex-direction: column; 45 | justify-content: center; 46 | margin: 10px; 47 | } 48 | .option{ 49 | display: flex; 50 | justify-content: space-between; 51 | align-items: center; 52 | margin:2px; 53 | box-shadow: 0px 0px 6px rgb(182, 171, 171); 54 | padding:5px; 55 | } 56 | .option label{ 57 | font-size: larger; 58 | padding-left: 10px; 59 | } 60 | .option input[type="checkbox"]{ 61 | width: 20px; 62 | height: 20px; 63 | } 64 | .button-container{ 65 | display: flex; 66 | justify-content: center; 67 | margin:20px; 68 | } 69 | #generatePassword{ 70 | padding: 20px; 71 | background-color: #af4646; 72 | border:none; 73 | border-radius: 10px; 74 | color: white; 75 | font-size: larger; 76 | box-shadow: 5px 5px 1px rgba(0,0,0,0.5); 77 | transition: all 0.5s; 78 | } 79 | #generatePassword:hover{ 80 | cursor: pointer; 81 | } 82 | #generatePassword:active{ 83 | box-shadow: none; 84 | transition: all 0.5; 85 | } -------------------------------------------------------------------------------- /searchable dropdown list/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | 11 | 12 |
13 |
14 | Select Country 15 | 16 |
17 |
18 | 22 |
    23 |
  • Country 1
  • 24 |
  • Country 2
  • 25 |
  • Country 3
  • 26 |
27 |
28 |
29 | 30 | 31 | -------------------------------------------------------------------------------- /searchable dropdown list/script.js: -------------------------------------------------------------------------------- 1 | let countries = ["Afghanistan", "Algeria", "Argentina", "Australia", "Bangladesh", "Belgium", "Bhutan", 2 | "Brazil", "Canada", "China", "Denmark", "Ethiopia", "Finland", "France", "Germany", 3 | "Hungary", "Iceland", "India", "Indonesia", "Iran", "Italy", "Japan", "Malaysia", 4 | "Maldives", "Mexico", "Morocco", "Nepal", "Netherlands", "Nigeria", "Norway", "Pakistan", 5 | "Peru", "Russia", "Romania", "South Africa", "Spain", "Sri Lanka", "Sweden", "Switzerland", 6 | "Thailand", "Turkey", "Uganda", "Ukraine", "United States", "United Kingdom", "Vietnam"]; 7 | 8 | let container = document.querySelector('.container'); 9 | let selectBtn = container.querySelector('.select-option'); 10 | let dropDownList = container.querySelector('.list-search-container'); 11 | let searchInput = container.querySelector("#search"); 12 | let lists = dropDownList.querySelector('.list'); 13 | 14 | selectBtn.addEventListener('click',()=>{ 15 | container.classList.toggle('active'); 16 | }) 17 | 18 | function addCountry(selectedCountry){ 19 | lists.innerHTML = ""; 20 | countries.forEach((country)=>{ 21 | let isSelected = selectedCountry==country?"selected":""; 22 | let listItem = '
  • ' + country + '
  • '; 23 | lists.insertAdjacentHTML('beforeend',listItem); 24 | }) 25 | addClickEventToLi(); 26 | } 27 | addCountry(); 28 | 29 | function addClickEventToLi(){ 30 | lists.querySelectorAll('li').forEach(listItem=>{ 31 | listItem.addEventListener('click',()=>{ 32 | updateSelectCountry(listItem); 33 | }) 34 | }) 35 | } 36 | 37 | 38 | function updateSelectCountry(listItem){ 39 | searchInput.value = ""; 40 | selectBtn.firstElementChild.innerHTML = listItem.innerHTML; 41 | container.classList.remove('active'); 42 | addCountry(listItem.innerHTML); 43 | } 44 | 45 | searchInput.addEventListener('keyup',()=>{ 46 | let searchInpVal = searchInput.value.toLowerCase(); 47 | let filteredCountries = countries.filter(country=>{ 48 | return country.toLocaleLowerCase().startsWith(searchInpVal); 49 | }).map(country=>{ 50 | return '
  • ' + country + '
  • '; 51 | }).join(""); 52 | lists.innerHTML = filteredCountries; 53 | addClickEventToLi(); 54 | }) -------------------------------------------------------------------------------- /searchable dropdown list/style.css: -------------------------------------------------------------------------------- 1 | *{ 2 | margin:0; 3 | padding:0; 4 | box-sizing: border-box; 5 | } 6 | body{ 7 | background: #44aabc; 8 | } 9 | .container{ 10 | width: 300px; 11 | margin: 100px auto 0; /*Top: 100px, right-left: auto, bottom:0px*/ 12 | } 13 | .select-option{ 14 | display: flex; 15 | justify-content: space-between; 16 | background-color: white; 17 | height: 50px; 18 | border-radius: 10px; 19 | box-shadow: 0px 10px 20px rgba(0,0,0,0.3); 20 | align-items: center; 21 | padding: 0 18px; 22 | font-size: 20px; 23 | } 24 | .select-option i{ 25 | font-size: 25px; 26 | transition: transform 0.3s linear; 27 | } 28 | .container.active .select-option i{ 29 | transform: rotate(-180deg); 30 | } 31 | .list-search-container{ 32 | background-color: white; 33 | margin-top: 15px; 34 | padding: 20px; 35 | border-radius: 10px; 36 | box-shadow: 0px 10px 20px rgba(0,0,0,0.3); 37 | display: none; 38 | } 39 | .container.active .list-search-container{ 40 | display: block; 41 | } 42 | .search-box{ 43 | position: relative; 44 | } 45 | .search-box i{ 46 | position: absolute; 47 | top:50%; left:15px; 48 | transform: translateY(-50%); 49 | font-size: 20px; 50 | color:#3c6d76 51 | } 52 | .search-box input{ 53 | height: 50px; 54 | width: 100%; 55 | outline: none; 56 | font-size: 17px; 57 | padding-left: 45px; 58 | border-radius: 5px; 59 | border: 1px solid #d3cbcb; 60 | } 61 | .search-box input:focus{ 62 | border: 2px solid #44aabc; 63 | } 64 | .list{ 65 | margin-top: 10px; 66 | max-height: 250px; 67 | overflow: auto; 68 | padding-right: 7px; 69 | } 70 | .list li{ 71 | font-size: 21px; 72 | height: 50px; 73 | padding: 10px 15px; 74 | } 75 | .list li:hover, li.selected{ 76 | border-radius: 5px; 77 | background: #f2f2f2; 78 | } -------------------------------------------------------------------------------- /stopwatch/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | 11 |
    12 |
    13 | 00:00:00 14 |
    15 |
    16 | 17 | 18 | 19 |
    20 |
    21 | 22 | 23 | -------------------------------------------------------------------------------- /stopwatch/main.js: -------------------------------------------------------------------------------- 1 | const timer = document.getElementById("stopwatch"); 2 | var hr = 0; 3 | var min = 0; 4 | var sec = 0; 5 | var stoptime = true; 6 | 7 | function startTimer() { 8 | if (stoptime == true) { 9 | stoptime = false; 10 | timerCycle(); 11 | } 12 | } 13 | function stopTimer() { 14 | if (stoptime == false) { 15 | stoptime = true; 16 | } 17 | } 18 | 19 | function timerCycle() { 20 | if (stoptime == false) { 21 | sec = parseInt(sec); 22 | min = parseInt(min); 23 | hr = parseInt(hr); 24 | 25 | sec = sec + 1; 26 | 27 | if (sec == 60) { 28 | min = min + 1; 29 | sec = 0; 30 | } 31 | if (min == 60) { 32 | hr = hr + 1; 33 | min = 0; 34 | sec = 0; 35 | } 36 | 37 | if (sec < 10 ) { 38 | sec = "0" + sec; 39 | } 40 | if (min < 10 ) { 41 | min = "0" + min; 42 | } 43 | if (hr < 10 ) { 44 | hr = "0" + hr; 45 | } 46 | 47 | timer.innerHTML = hr + ":" + min + ":" + sec; 48 | 49 | setTimeout("timerCycle()", 1000); 50 | } 51 | } 52 | function resetTimer() { 53 | timer.innerHTML = "00:00:00"; 54 | stoptime = true; 55 | hr = 0; 56 | sec = 0; 57 | min = 0; 58 | } 59 | -------------------------------------------------------------------------------- /stopwatch/style.css: -------------------------------------------------------------------------------- 1 | *{ 2 | margin: 0; 3 | padding: 0; 4 | } 5 | .container { 6 | background: #202020; 7 | display: flex; 8 | justify-content: center; 9 | align-items: center; 10 | height: 100vh; 11 | flex-direction: column; 12 | } 13 | #stopwatch{ 14 | font-size: 100px; 15 | box-shadow: 0px 0px 10px black; 16 | padding: 10px; 17 | color: white; 18 | border-radius: 10px; 19 | margin-bottom: 10px; 20 | } 21 | #buttons{ 22 | display: flex; 23 | } 24 | button{ 25 | padding: 20px; 26 | background-color: #694343; 27 | border:none; 28 | border-radius: 10px; 29 | color: white; 30 | font-size: larger; 31 | margin: 10px; 32 | width:100px; 33 | box-shadow: 5px 5px 1px rgba(56, 51, 51, 0.5); 34 | transition: all 0.5s; 35 | } 36 | button:hover{ 37 | cursor:pointer; 38 | } 39 | button:active{ 40 | box-shadow: none; 41 | transition: all 0.5; 42 | } -------------------------------------------------------------------------------- /tic tak toe game/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 12 | 13 | 14 | 15 |
    16 |

    TIC TAC TOE

    17 | 18 | 19 |

    Game starts by just Tap on box 20 |

    First Player starts as 21 | Player X
    And
    Second 22 | Player as Player 0 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 | 53 | 54 |

    55 | 56 |

    57 | 58 |
    59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /tic tak toe game/tic.css: -------------------------------------------------------------------------------- 1 | /* CSS Code */ 2 | /* Heading */ 3 | h1 { 4 | color: rgb(122, 42, 12); 5 | font-size: 45px; 6 | } 7 | 8 | /* 3*3 Grid */ 9 | #b1, #b2, #b3, #b4, #b5, 10 | #b6, #b7, #b8, #b9 { 11 | width: 80px; 12 | height: 52px; 13 | margin: auto; 14 | border: 1px solid gray; 15 | border-radius: 6px; 16 | font-size: 30px; 17 | text-align: center; 18 | } 19 | 20 | /* Reset Button */ 21 | #but { 22 | box-sizing: border-box; 23 | width: 95px; 24 | height: 40px; 25 | border: 1px solid dodgerblue; 26 | margin: auto; 27 | border-radius: 4px; 28 | font-family: Verdana, 29 | Geneva, Tahoma, sans-serif; 30 | 31 | background-color: dodgerblue; 32 | color: white; 33 | font-size: 20px; 34 | cursor: pointer; 35 | } 36 | 37 | /* Player turn space */ 38 | #print { 39 | font-family: Verdana, 40 | Geneva, Tahoma, sans-serif; 41 | 42 | color: dodgerblue; 43 | font-size: 20px; 44 | } 45 | 46 | /* Main Contianer */ 47 | #main { 48 | text-align: center; 49 | } 50 | 51 | /* Game Instruction Text */ 52 | #ins { 53 | font-family: Verdana, 54 | Geneva, Tahoma, sans-serif; 55 | 56 | color: rgb(41, 44, 48); 57 | font-size: 17px; 58 | } 59 | -------------------------------------------------------------------------------- /tic tak toe game/tic.js: -------------------------------------------------------------------------------- 1 | // Function called whenever user tab on any box 2 | function myfunc() { 3 | 4 | // Setting DOM to all boxes or input field 5 | var b1, b1, b3, b4, b5, b6, b7, b8, b9; 6 | var arr= new Array(9); 7 | for(let i=1;i<=9;i++) 8 | { 9 | arr[i-1] = document.getElementById("b" + i).value; 10 | } 11 | b1 =arr[0]// document.getElementById("b1").value; 12 | b2 =arr[1]// document.getElementById("b2").value; 13 | b3 =arr[2]// document.getElementById("b3").value; 14 | b4 =arr[3]// document.getElementById("b4").value; 15 | b5 =arr[4]// document.getElementById("b5").value; 16 | b6 =arr[5]// document.getElementById("b6").value; 17 | b7 =arr[6]// document.getElementById("b7").value; 18 | b8 =arr[7]// document.getElementById("b8").value; 19 | b9 =arr[8]// document.getElementById("b9").value; 20 | 21 | // Checking if Player X won or not and after 22 | // that disabled all the other fields 23 | let lower, upper; 24 | if ((b1 == 'x' || b1 == 'X') && (b2 == 'x' || 25 | b2 == 'X') && (b3 == 'x' || b3 == 'X')) { 26 | document.getElementById('print').innerHTML = "Player X won"; 27 | lower = 4; upper = 8; 28 | for(let i=lower;i<=upper;i++) 29 | { 30 | document.getElementById("b"+i).disabled = true; 31 | } 32 | //document.getElementById("b4").disabled = true; 33 | //document.getElementById("b5").disabled = true; 34 | //document.getElementById("b6").disabled = true; 35 | //document.getElementById("b7").disabled = true; 36 | //document.getElementById("b8").disabled = true; 37 | //document.getElementById("b9").disabled = true; 38 | window.alert('Player X won'); 39 | } 40 | else if ((b1 == 'x' || b1 == 'X') && (b4 == 'x' || 41 | b4 == 'X') && (b7 == 'x' || b7 == 'X')) { 42 | document.getElementById('print') 43 | .innerHTML = "Player X won"; 44 | document.getElementById("b2").disabled = true; 45 | document.getElementById("b3").disabled = true; 46 | document.getElementById("b5").disabled = true; 47 | document.getElementById("b6").disabled = true; 48 | document.getElementById("b8").disabled = true; 49 | document.getElementById("b9").disabled = true; 50 | 51 | window.alert('Player X won'); 52 | } 53 | else if ((b7 == 'x' || b7 == 'X') && (b8 == 'x' || 54 | b8 == 'X') && (b9 == 'x' || b9 == 'X')) { 55 | document.getElementById('print') 56 | .innerHTML = "Player X won"; 57 | document.getElementById("b1").disabled = true; 58 | document.getElementById("b2").disabled = true; 59 | document.getElementById("b3").disabled = true; 60 | document.getElementById("b4").disabled = true; 61 | document.getElementById("b5").disabled = true; 62 | document.getElementById("b6").disabled = true; 63 | window.alert('Player X won'); 64 | } 65 | else if ((b3 == 'x' || b3 == 'X') && (b6 == 'x' || 66 | b6 == 'X') && (b9 == 'x' || b9 == 'X')) { 67 | document.getElementById('print') 68 | .innerHTML = "Player X won"; 69 | document.getElementById("b1").disabled = true; 70 | document.getElementById("b2").disabled = true; 71 | document.getElementById("b4").disabled = true; 72 | document.getElementById("b5").disabled = true; 73 | document.getElementById("b7").disabled = true; 74 | document.getElementById("b8").disabled = true; 75 | window.alert('Player X won'); 76 | } 77 | else if ((b1 == 'x' || b1 == 'X') && (b5 == 'x' || 78 | b5 == 'X') && (b9 == 'x' || b9 == 'X')) { 79 | document.getElementById('print') 80 | .innerHTML = "Player X won"; 81 | document.getElementById("b2").disabled = true; 82 | document.getElementById("b3").disabled = true; 83 | document.getElementById("b4").disabled = true; 84 | document.getElementById("b6").disabled = true; 85 | document.getElementById("b7").disabled = true; 86 | document.getElementById("b8").disabled = true; 87 | window.alert('Player X won'); 88 | } 89 | else if ((b3 == 'x' || b3 == 'X') && (b5 == 'x' || 90 | b5 == 'X') && (b7 == 'x' || b7 == 'X')) { 91 | document.getElementById('print') 92 | .innerHTML = "Player X won"; 93 | document.getElementById("b1").disabled = true; 94 | document.getElementById("b2").disabled = true; 95 | document.getElementById("b4").disabled = true; 96 | document.getElementById("b6").disabled = true; 97 | document.getElementById("b8").disabled = true; 98 | document.getElementById("b9").disabled = true; 99 | window.alert('Player X won'); 100 | } 101 | else if ((b2 == 'x' || b2 == 'X') && (b5 == 'x' || 102 | b5 == 'X') && (b8 == 'x' || b8 == 'X')) { 103 | document.getElementById('print') 104 | .innerHTML = "Player X won"; 105 | document.getElementById("b1").disabled = true; 106 | document.getElementById("b3").disabled = true; 107 | document.getElementById("b4").disabled = true; 108 | document.getElementById("b6").disabled = true; 109 | document.getElementById("b7").disabled = true; 110 | document.getElementById("b9").disabled = true; 111 | window.alert('Player X won'); 112 | } 113 | else if ((b4 == 'x' || b4 == 'X') && (b5 == 'x' || 114 | b5 == 'X') && (b6 == 'x' || b6 == 'X')) { 115 | document.getElementById('print') 116 | .innerHTML = "Player X won"; 117 | document.getElementById("b1").disabled = true; 118 | document.getElementById("b2").disabled = true; 119 | document.getElementById("b3").disabled = true; 120 | document.getElementById("b7").disabled = true; 121 | document.getElementById("b8").disabled = true; 122 | document.getElementById("b9").disabled = true; 123 | window.alert('Player X won'); 124 | } 125 | 126 | // Checking of Player X finsh 127 | // Checking for Player 0 starts, Is player 0 won or 128 | // not and after that disabled all the other fields 129 | else if ((b1 == '0' || b1 == '0') && (b2 == '0' || 130 | b2 == '0') && (b3 == '0' || b3 == '0')) { 131 | document.getElementById('print') 132 | .innerHTML = "Player 0 won"; 133 | document.getElementById("b4").disabled = true; 134 | document.getElementById("b5").disabled = true; 135 | document.getElementById("b6").disabled = true; 136 | document.getElementById("b7").disabled = true; 137 | document.getElementById("b8").disabled = true; 138 | document.getElementById("b9").disabled = true; 139 | window.alert('Player 0 won'); 140 | } 141 | else if ((b1 == '0' || b1 == '0') && (b4 == '0' || 142 | b4 == '0') && (b7 == '0' || b7 == '0')) { 143 | document.getElementById('print') 144 | .innerHTML = "Player 0 won"; 145 | document.getElementById("b2").disabled = true; 146 | document.getElementById("b3").disabled = true; 147 | document.getElementById("b5").disabled = true; 148 | document.getElementById("b6").disabled = true; 149 | document.getElementById("b8").disabled = true; 150 | document.getElementById("b9").disabled = true; 151 | window.alert('Player 0 won'); 152 | } 153 | else if ((b7 == '0' || b7 == '0') && (b8 == '0' || 154 | b8 == '0') && (b9 == '0' || b9 == '0')) { 155 | document.getElementById('print') 156 | .innerHTML = "Player 0 won"; 157 | document.getElementById("b1").disabled = true; 158 | document.getElementById("b2").disabled = true; 159 | document.getElementById("b3").disabled = true; 160 | document.getElementById("b4").disabled = true; 161 | document.getElementById("b5").disabled = true; 162 | document.getElementById("b6").disabled = true; 163 | window.alert('Player 0 won'); 164 | } 165 | else if ((b3 == '0' || b3 == '0') && (b6 == '0' || 166 | b6 == '0') && (b9 == '0' || b9 == '0')) { 167 | document.getElementById('print') 168 | .innerHTML = "Player 0 won"; 169 | document.getElementById("b1").disabled = true; 170 | document.getElementById("b2").disabled = true; 171 | document.getElementById("b4").disabled = true; 172 | document.getElementById("b5").disabled = true; 173 | document.getElementById("b7").disabled = true; 174 | document.getElementById("b8").disabled = true; 175 | window.alert('Player 0 won'); 176 | } 177 | else if ((b1 == '0' || b1 == '0') && (b5 == '0' || 178 | b5 == '0') && (b9 == '0' || b9 == '0')) { 179 | document.getElementById('print') 180 | .innerHTML = "Player 0 won"; 181 | document.getElementById("b2").disabled = true; 182 | document.getElementById("b3").disabled = true; 183 | document.getElementById("b4").disabled = true; 184 | document.getElementById("b6").disabled = true; 185 | document.getElementById("b7").disabled = true; 186 | document.getElementById("b8").disabled = true; 187 | window.alert('Player 0 won'); 188 | } 189 | else if ((b3 == '0' || b3 == '0') && (b5 == '0' || 190 | b5 == '0') && (b7 == '0' || b7 == '0')) { 191 | document.getElementById('print') 192 | .innerHTML = "Player 0 won"; 193 | document.getElementById("b1").disabled = true; 194 | document.getElementById("b2").disabled = true; 195 | document.getElementById("b4").disabled = true; 196 | document.getElementById("b6").disabled = true; 197 | document.getElementById("b8").disabled = true; 198 | document.getElementById("b9").disabled = true; 199 | window.alert('Player 0 won'); 200 | } 201 | else if ((b2 == '0' || b2 == '0') && (b5 == '0' || 202 | b5 == '0') && (b8 == '0' || b8 == '0')) { 203 | document.getElementById('print') 204 | .innerHTML = "Player 0 won"; 205 | document.getElementById("b1").disabled = true; 206 | document.getElementById("b3").disabled = true; 207 | document.getElementById("b4").disabled = true; 208 | document.getElementById("b6").disabled = true; 209 | document.getElementById("b7").disabled = true; 210 | document.getElementById("b9").disabled = true; 211 | window.alert('Player 0 won'); 212 | } 213 | else if ((b4 == '0' || b4 == '0') && (b5 == '0' || 214 | b5 == '0') && (b6 == '0' || b6 == '0')) { 215 | document.getElementById('print') 216 | .innerHTML = "Player 0 won"; 217 | document.getElementById("b1").disabled = true; 218 | document.getElementById("b2").disabled = true; 219 | document.getElementById("b3").disabled = true; 220 | document.getElementById("b7").disabled = true; 221 | document.getElementById("b8").disabled = true; 222 | document.getElementById("b9").disabled = true; 223 | window.alert('Player 0 won'); 224 | } 225 | 226 | // Checking of Player 0 finsh 227 | // Here, Checking about Tie 228 | else if ((b1 == 'X' || b1 == '0') && (b2 == 'X'|| b2 == '0') && (b3 == 'X' || b3 == '0') && 229 | (b4 == 'X' || b4 == '0') && (b5 == 'X' ||b5 == '0') && (b6 == 'X' || b6 == '0') && 230 | (b7 == 'X' || b7 == '0') && (b8 == 'X' ||b8 == '0') && (b9 == 'X' || b9 == '0')) { 231 | document.getElementById('print') 232 | .innerHTML = "Match Tie"; 233 | window.alert('Match Tie'); 234 | } 235 | else { 236 | 237 | // Here, Printing Result 238 | if (flag == 1) { 239 | document.getElementById('print') 240 | .innerHTML = "Player X Turn"; 241 | } 242 | else { 243 | document.getElementById('print') 244 | .innerHTML = "Player 0 Turn"; 245 | } 246 | } 247 | } 248 | 249 | // Function to reset game 250 | function myfunc_2() { 251 | location.reload(); 252 | document.getElementById('b1').value = ''; 253 | document.getElementById("b2").value = ''; 254 | document.getElementById("b3").value = ''; 255 | document.getElementById("b4").value = ''; 256 | document.getElementById("b5").value = ''; 257 | document.getElementById("b6").value = ''; 258 | document.getElementById("b7").value = ''; 259 | document.getElementById("b8").value = ''; 260 | document.getElementById("b9").value = ''; 261 | 262 | } 263 | 264 | // Here onwards, functions check turn of the player 265 | // and put accordingly value X or 0 266 | flag = 1; 267 | function myfunc_3() { 268 | if (flag == 1) { 269 | document.getElementById("b1").value = "X"; 270 | document.getElementById("b1").disabled = true; 271 | flag = 0; 272 | } 273 | else { 274 | document.getElementById("b1").value = "0"; 275 | document.getElementById("b1").disabled = true; 276 | flag = 1; 277 | } 278 | } 279 | 280 | function myfunc_4() { 281 | if (flag == 1) { 282 | document.getElementById("b2").value = "X"; 283 | document.getElementById("b2").disabled = true; 284 | flag = 0; 285 | } 286 | else { 287 | document.getElementById("b2").value = "0"; 288 | document.getElementById("b2").disabled = true; 289 | flag = 1; 290 | } 291 | } 292 | 293 | function myfunc_5() { 294 | if (flag == 1) { 295 | document.getElementById("b3").value = "X"; 296 | document.getElementById("b3").disabled = true; 297 | flag = 0; 298 | } 299 | else { 300 | document.getElementById("b3").value = "0"; 301 | document.getElementById("b3").disabled = true; 302 | flag = 1; 303 | } 304 | } 305 | 306 | function myfunc_6() { 307 | if (flag == 1) { 308 | document.getElementById("b4").value = "X"; 309 | document.getElementById("b4").disabled = true; 310 | flag = 0; 311 | } 312 | else { 313 | document.getElementById("b4").value = "0"; 314 | document.getElementById("b4").disabled = true; 315 | flag = 1; 316 | } 317 | } 318 | 319 | function myfunc_7() { 320 | if (flag == 1) { 321 | document.getElementById("b5").value = "X"; 322 | document.getElementById("b5").disabled = true; 323 | flag = 0; 324 | } 325 | else { 326 | document.getElementById("b5").value = "0"; 327 | document.getElementById("b5").disabled = true; 328 | flag = 1; 329 | } 330 | } 331 | 332 | function myfunc_8() { 333 | if (flag == 1) { 334 | document.getElementById("b6").value = "X"; 335 | document.getElementById("b6").disabled = true; 336 | flag = 0; 337 | } 338 | else { 339 | document.getElementById("b6").value = "0"; 340 | document.getElementById("b6").disabled = true; 341 | flag = 1; 342 | } 343 | } 344 | 345 | function myfunc_9() { 346 | if (flag == 1) { 347 | document.getElementById("b7").value = "X"; 348 | document.getElementById("b7").disabled = true; 349 | flag = 0; 350 | } 351 | else { 352 | document.getElementById("b7").value = "0"; 353 | document.getElementById("b7").disabled = true; 354 | flag = 1; 355 | } 356 | } 357 | 358 | function myfunc_10() { 359 | if (flag == 1) { 360 | document.getElementById("b8").value = "X"; 361 | document.getElementById("b8").disabled = true; 362 | flag = 0; 363 | } 364 | else { 365 | document.getElementById("b8").value = "0"; 366 | document.getElementById("b8").disabled = true; 367 | flag = 1; 368 | } 369 | } 370 | 371 | function myfunc_11() { 372 | if (flag == 1) { 373 | document.getElementById("b9").value = "X"; 374 | document.getElementById("b9").disabled = true; 375 | flag = 0; 376 | } 377 | else { 378 | document.getElementById("b9").value = "0"; 379 | document.getElementById("b9").disabled = true; 380 | flag = 1; 381 | } 382 | } 383 | --------------------------------------------------------------------------------