Skip to content

Commit

Permalink
Merge pull request #54 from VinayCheripally/swocIssue
Browse files Browse the repository at this point in the history
Changed the spelling
  • Loading branch information
jaysomani authored Jan 11, 2024
2 parents 8f455cc + a0c9f3d commit e60159a
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 91 deletions.
65 changes: 38 additions & 27 deletions pages/Filter/filter.html
Original file line number Diff line number Diff line change
@@ -1,35 +1,46 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Search and Filter</title>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500&display=swap" rel="stylesheet">
<link rel="stylesheet" href="filter.css">
</head>
<link
href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500&display=swap"
rel="stylesheet"
/>
<link rel="stylesheet" href="filter.css" />
</head>

<body>
<body>
<div class="wrapper">
<div id="search-container">
<input type="search" id="search-input" placeholder="Seacrh product name here..">
<button id="search">search</button>
</div>
<div id="buttons">
<button class="button-value" onclick="filterPlace('all')">All</button>
<button class="button-value" onclick="filterPlace('North')">North</button>
<button class="button-value" onclick="filterPlace('East')">East</button>
<button class="button-value" onclick="filterPlace('West')">West</button>
<button class="button-value" onclick="filterPlace('South')">South</button>
<button class="button-value" onclick="filterPlace('Center')">Center</button>
</div>
<div id="places"></div>
<!-- <ul id="places"> -->
<div id="search-container">
<input
type="search"
id="search-input"
placeholder="Search product name here.."
/>
<button id="search">search</button>
</div>
<div id="buttons">
<button class="button-value" onclick="filterPlace('all')">All</button>
<button class="button-value" onclick="filterPlace('North')">
North
</button>
<button class="button-value" onclick="filterPlace('East')">East</button>
<button class="button-value" onclick="filterPlace('West')">West</button>
<button class="button-value" onclick="filterPlace('South')">
South
</button>
<button class="button-value" onclick="filterPlace('Center')">
Center
</button>
</div>
<div id="places"></div>
<!-- <ul id="places"> -->

<!-- </ul> -->
<!-- </ul> -->
</div>
<script src=" filter.js "></script>
</body>

</html>
</body>
</html>
76 changes: 56 additions & 20 deletions pages/login/login.html
Original file line number Diff line number Diff line change
@@ -1,37 +1,73 @@
<!DOCTYPE html>
<!-- Created By CodingNepal -->
<html lang="en" dir="ltr">

<head>
<meta charset="utf-8">
<head>
<meta charset="utf-8" />
<title>Login and Registration Form in HTML | CodingNepal</title>
<!-- <link rel="stylesheet" href="./style.css"> -->
<link rel="stylesheet" href="../login/login.css">
<link rel="stylesheet" href="../login/login.css" />

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh"
crossorigin="anonymous"
/>

<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js"></script>

<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>

<body>
<body>
<!-- ///////////////////////////jayesh new work/////////////////////////// -->

<div class="mb-5">
<h3 class="mb-3">Tourist Login</h3>
<input type="text" placeholder="Username" id="userInp" class="form-control mb-3">
<input type="password" placeholder="Password" id="passInp" class="form-control mb-3">
<div class="custom-control custom-switch mb-3">
<input type="checkbox" class="custom-control-input" id="customSwitch1">
<label class="custom-control-label" for="customSwitch1">Keep me logged in</label>
</div>
<button type="text" id="sub_btn" class="btn w-100 btn-outline-primary mb-3">Sign In</button>
<a href="./index.html" class="badge badge-secondary py-1 w-100 mb-3"><br>Create a new account?<br></a>
<h3 class="mb-3">Tourist Login</h3>
<input
type="text"
placeholder="Username"
id="userInp"
class="form-control mb-3"
/>
<input
type="password"
placeholder="Password"
id="passInp"
class="form-control mb-3"
/>
<div class="custom-control custom-switch mb-3">
<input
type="checkbox"
class="custom-control-input"
id="customSwitch1"
/>
<label class="custom-control-label" for="customSwitch1"
>Keep me logged in</label
>
</div>
<button
type="text"
id="sub_btn"
class="btn w-100 btn-outline-primary mb-3"
>
Sign In
</button>
<a href="./index.html" class="badge badge-secondary py-1 w-100 mb-3"
><br />Create a new account?<br
/></a>
</div>

<script type="module" src="login.js"></script>
<script>
document.getElementById("sub_btn").addEventListener("click", function () {
var username = document.getElementById("userInp").value;
var password = document.getElementById("passInp").value;

</body>

</html>
if (username === "" || password === "") {
alert("Please enter both username and password!");
}
});
</script>
</body>
</html>
89 changes: 45 additions & 44 deletions pages/login/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,54 @@ import { initializeApp } from "https://www.gstatic.com/firebasejs/9.6.11/firebas
// import { initializeApp } from "firebase";

const firebaseConfig = {
apiKey: "AIzaSyAHLP7isomKx1zKwle0PpydCYdhHA1ctM4",
authDomain: "firstspot-b7b7b.firebaseapp.com",
databaseURL: "https://firstspot-b7b7b-default-rtdb.firebaseio.com",
projectId: "firstspot-b7b7b",
storageBucket: "firstspot-b7b7b.appspot.com",
messagingSenderId: "781962837914",
appId: "1:781962837914:web:6662ae66f885e764e2c423"
apiKey: "AIzaSyAHLP7isomKx1zKwle0PpydCYdhHA1ctM4",
authDomain: "firstspot-b7b7b.firebaseapp.com",
databaseURL: "https://firstspot-b7b7b-default-rtdb.firebaseio.com",
projectId: "firstspot-b7b7b",
storageBucket: "firstspot-b7b7b.appspot.com",
messagingSenderId: "781962837914",
appId: "1:781962837914:web:6662ae66f885e764e2c423",
};

// Initialize Firebase
//const app = initializeApp(firebaseConfig);
const app = initializeApp(firebaseConfig);

import { getDatabase, ref, set, child, get }
from "https://www.gstatic.com/firebasejs/9.6.11/firebase-database.js";
import {
getDatabase,
ref,
set,
child,
get,
} from "https://www.gstatic.com/firebasejs/9.6.11/firebase-database.js";
// import { validation } from "uuid";
const db = getDatabase();
// ////////The refrences////////////////////////////////////////////////


const username = document.getElementById("userInp");
const pass = document.getElementById("passInp");
const submit = document.getElementById("sub_btn");

//////////////////

function AuthenticateUser() {
const dbref = ref(db);
console.log(username.value);
get(child(dbref, "UsersList/" + username.value)).then((snapshot) => {
// console.log(snapshot.val());
if (snapshot.exists()) {
// let dbpass = decPass(snapshot.val().password);
// console.log(dbpass, pass.value, "here");
let dbpass = snapshot.val().password;
if (dbpass == pass.value) {
login(username.value);
} else {
alert("user does not exist");
}
} else {

alert("username or password is invalid");
}

});
const dbref = ref(db);
console.log(username.value);
get(child(dbref, "UsersList/" + username.value)).then((snapshot) => {
// console.log(snapshot.val());
if (snapshot.exists()) {
// let dbpass = decPass(snapshot.val().password);
// console.log(dbpass, pass.value, "here");
let dbpass = snapshot.val().password;
if (dbpass == pass.value) {
login(username.value);
} else {
alert("user does not exist");
}
} else {
alert("username or password is invalid");
}
});
}

// ////////////decript process
Expand All @@ -59,22 +61,21 @@ function AuthenticateUser() {
//////////////////login

function login(user) {
// let keepLoggedIn = document.getElementById("customSwitch1").checked;
// if (!keepLoggedIn) {
// sessionStorage.setItem("user", user);
// window.location = "../home.html";
// // console.log(sessionStorage.getItem("user"));
// } else {
// localStorage.setItem("keepLoggedIn", "yes");
// localStorage.setItem("user", user);
// window.location = "../home.html";
// // console.log(localStorage.getItem("user"));
// }

sessionStorage.setItem("user", user);
window.location = "../../index.html";
// let keepLoggedIn = document.getElementById("customSwitch1").checked;
// if (!keepLoggedIn) {
// sessionStorage.setItem("user", user);
// window.location = "../home.html";
// // console.log(sessionStorage.getItem("user"));
// } else {
// localStorage.setItem("keepLoggedIn", "yes");
// localStorage.setItem("user", user);
// window.location = "../home.html";r;
// // console.log(localStorage.getItem("user"));
// }

sessionStorage.setItem("user", user);
window.location = "../../index.html";
}
// ////////////////////submit

submit.addEventListener("click", AuthenticateUser);
submit.addEventListener("click", AuthenticateUser);

0 comments on commit e60159a

Please sign in to comment.