Add Entry List with Functionality

This commit is contained in:
Modo 2023-10-20 22:13:41 +05:30
parent a260428f84
commit 464820aacf
8 changed files with 179 additions and 53 deletions

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50" width="50px" height="50px" fill="grey"><path d="M 21 4 C 11.082241 4 3 12.082241 3 22 C 3 31.917759 11.082241 40 21 40 C 24.62177 40 27.99231 38.91393 30.820312 37.0625 L 43.378906 49.621094 L 47.621094 45.378906 L 35.224609 32.982422 C 37.581469 29.938384 39 26.13473 39 22 C 39 12.082241 30.917759 4 21 4 z M 21 8 C 28.756241 8 35 14.243759 35 22 C 35 29.756241 28.756241 36 21 36 C 13.243759 36 7 29.756241 7 22 C 7 14.243759 13.243759 8 21 8 z"/></svg>

After

Width:  |  Height:  |  Size: 517 B

View File

@ -14,7 +14,7 @@
<div class="searchbar"> <div class="searchbar">
<input type="text" id="search"> <input type="text" id="search">
<img src="../assets/search.svg"> <button></button>
</div> </div>
<div class="objcontainer"> <div class="objcontainer">

View File

@ -8,6 +8,7 @@
<link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Pixelify+Sans:wght@500&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Pixelify+Sans:wght@500&display=swap" rel="stylesheet">
<style></style>
<head> <head>
<body> <body>
<div class="wrapper"> <div class="wrapper">
@ -41,7 +42,7 @@
</div> </div>
</div> </div>
<script src="../scripts/index.js"></script> <script defer src="../scripts/index.js"></script>
</body> </body>
<footer><p>© 2023 Password Manager</p></footer> <footer><p>© 2023 Password Manager</p></footer>

View File

@ -30,7 +30,7 @@
</div> </div>
</div> </div>
<script src="../scripts/register.js"></script> <script defer src="../scripts/register.js"></script>
</body> </body>
<footer><p>© 2023 Password Manager</p></footer> <footer><p>© 2023 Password Manager</p></footer>

View File

@ -1,17 +1,7 @@
const search = document.getElementById('search'); //-----------------------------------------------------------------------------------------(Getting Data)
let globaldata; let globaldata;
search.addEventListener('keyup', function() {
let result = search.value;
if(result == ""){
updatelist(globaldata)
} else {
console.log(result);
updatelist(globaldata)
}
});
async function getData() { async function getData() {
try { try {
let response = await fetch('/get_data', { let response = await fetch('/get_data', {
@ -23,9 +13,9 @@ async function getData() {
if(response.ok) { if(response.ok) {
let userdata = await response.json(); let userdata = await response.json();
console.log(userdata) //console.log(userdata)
globaldata = userdata globaldata = userdata
updatelist(userdata); getFieldName(userdata)
} else if(!response.ok) { } else if(!response.ok) {
const errorMessage = await response.text(); const errorMessage = await response.text();
throw new Error(errorMessage); throw new Error(errorMessage);
@ -35,40 +25,110 @@ async function getData() {
} }
} }
//-----------------------------------------------------------------------------------------(Adds Values to Content Box)
// function addlist(userdata) {
// let masterdata = [];
// for (let field in userdata){
// masterdata.push(userdata[field])
// }
// console.log(...masterdata)
// updatelist(masterdata)
// }
const contentbox = document.querySelector('.objcontainer') const contentbox = document.querySelector('.objcontainer')
function updatelist(userdata) { function updateListGui(field) {
contentbox.innerHTML = '' let content = contentbox.innerHTML.concat(
for(let field in userdata){ `
let fields = userdata[field]; <div>
for (let data in fields) { <img src="${field["url"]}">
if (fields.hasOwnProperty(data)) { <p>${field["fieldname"]}</p>
let value = fields[data]; <button id="${field["fieldname"]}" class="entrybutton"> Show </button>
updategui(field, data, value) </div>
console.log(field, data, value) `
} )
}
}
}
function updategui(title, key, value) {
console.log(`${title},${key},${value}`)
let content = contentbox.innerHTML.concat(`<div>${title},${key},${value}</div>`)
contentbox.innerHTML = content; contentbox.innerHTML = content;
let btns = document.querySelectorAll('.entrybutton')
btns.forEach(btn => {
btn.addEventListener('click', () => {
updateInfoGui(btn.id);
});
});
} }
// const data = {
// Amazon: {
// url: "https://www.amazon.com",
// Name: "Yash",
// Password: "123"
// },
// Google: {
// url: "https://www.google.com",
// Name: "XYZ",
// Password: "Secret"
// }
// }
function getFieldName(data) { //Gets All Field Values
let fieldnamearray = []
for(let field in data){
let fieldname = field
fieldnamearray.push(fieldname)
}
getDisplayList(fieldnamearray,data);
//console.log(fieldnamearray)
}
function getFaviconUrl(fieldname,data) {
let fielddata = data[fieldname]
let url = fielddata["url"]
url = url.replace("https://",'')
faviconlink = `http://www.google.com/s2/favicons?domain=${url}`
return faviconlink
}
function getDisplayList(fieldnames,userdata){
contentbox.innerHTML = ''
for(let i in fieldnames){
let faviconurl = getFaviconUrl(fieldnames[i],userdata)
let guidata = {
fieldname: fieldnames[i],
url: faviconurl
}
updateListGui(guidata)
}
}
//-----------------------------------------------------------------------------------------
const search = document.getElementById('search');
search.addEventListener('keyup', function() {
let result = search.value;
if(result == ""){
getData()
} else {
getFilterList(result,globaldata)
//console.log(result);
}
});
function getFilterList(keyword,data) { //Gets Filtered Field Values
let filterarray = []
for(let field in data){
if(field.toLowerCase().indexOf(keyword) !== -1){
let fieldname = field
filterarray.push(fieldname)
}
}
getDisplayList(filterarray,data);
//console.log(filterarray)
}
//-----------------------------------------------------------------------------------------
function updateInfoGui(call) {
console.log(call)
}
//-----------------------------------------------------------------------------------------
window.onload = function() { window.onload = function() {
getData(); getData();
}; };

View File

@ -51,7 +51,7 @@ console.log(formData)
}); });
if(response.ok) { if(response.ok) {
window.location.href = "dashboard.html"; window.location.href = "../html/dashboard.html";
} else if(!response.ok) { } else if(!response.ok) {
const errorMessage = await response.text(); const errorMessage = await response.text();
document.getElementById("errlabel").innerHTML = errorMessage; document.getElementById("errlabel").innerHTML = errorMessage;

View File

@ -29,8 +29,9 @@ body {
background-color: rgb(0, 255, 255,0.2); background-color: rgb(0, 255, 255,0.2);
backdrop-filter: blur(15px); backdrop-filter: blur(15px);
border-radius: 30px; border-radius: 30px;
width: 90vw; position: relative;
height: 80vh; width: 1100px;
height: 600px;
box-shadow: 0px 0px 30px rgba(0, 0, 0, 0.8); box-shadow: 0px 0px 30px rgba(0, 0, 0, 0.8);
overflow: hidden; overflow: hidden;
} }
@ -56,6 +57,8 @@ footer p{
border-radius: 20px; border-radius: 20px;
height: 85%; height: 85%;
width: 40%; width: 40%;
/* height: 70vh;
width: 40vw; */
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
@ -84,12 +87,35 @@ footer p{
padding-right: 40px; padding-right: 40px;
} }
.searchbar img { .searchbar button {
display: block; background-image: url("../assets/search.svg");
background-size: cover;
background-position: center;
display: inline-block;
position: absolute; position: absolute;
top: 24%; top: 20%;
right: 25px; right: 25px;
width: 25px; width: 30px;
height: 30px;
border: none;
background-color: transparent;
cursor: pointer;
}
.searchbar button:hover {
background-image: url(../assets/search2.svg);
}
.searchbar button:not(:hover) {
background-image: url(../assets/search.svg);
}
.searchbar:hover{
box-shadow: 0, 0, 5px;
}
.searchbar:not(:hover){
box-shadow: none;
} }
.objcontainer { .objcontainer {
@ -109,14 +135,16 @@ footer p{
} }
.objcontainer div{ .objcontainer div{
display: flex;
padding: 20px; padding: 20px;
width: 90%; width: 90%;
height: 200px; height: 50px;
background-color: rgb(255, 255, 255, 0.5); background-color: rgb(255, 255, 255, 0.5);
text-align: center; text-align: left;
box-shadow: 0 0 10px black; box-shadow: 0 0 10px black;
border: rgba(0, 255, 255, 0.5) 1px solid; border: rgba(0, 255, 255, 0.5) 1px solid;
overflow: hidden; overflow: hidden;
align-items: center;
} }
.objcontainer div:hover { .objcontainer div:hover {
@ -127,6 +155,35 @@ footer p{
background-color: rgb(255, 255, 255, 0.5); background-color: rgb(255, 255, 255, 0.5);
} }
.objcontainer div button{
position: absolute;
right: 40px;
background-color: hsl(0, 0%, 100%, 0.5);
border-radius: 10px;
padding: 5px;
font-weight: bold;
box-shadow: 0 0 5px;
cursor: pointer;
}
.objcontainer div button:hover{
background-color: rgb(128, 128, 128, 0.7);
}
.objcontainer div button:not(:hover){
background-color: hsl(0, 0%, 100%, 0.5);
}
.objcontainer div img{
width: 30px;
}
.objcontainer div p{
padding-left: 20px;
font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
font-weight: bold;
}
.querybox { .querybox {
display: flex; display: flex;
justify-content: center; justify-content: center;
@ -172,3 +229,11 @@ footer p{
::-webkit-scrollbar-thumb:hover { ::-webkit-scrollbar-thumb:hover {
background: hsl(0, 0%, 33%); background: hsl(0, 0%, 33%);
} }
@media (max-width: 860px) {
.container{
position: fixed;
width: 774px;
}
}

View File

@ -119,7 +119,6 @@ body {
} }
.help div{ .help div{
display: flex; display: flex;
width: 50%; width: 50%;