front end work; added search

This commit is contained in:
ana 2023-07-27 06:06:08 +00:00
parent 525ab410a6
commit 511d340c45
5 changed files with 226 additions and 150 deletions

View file

@ -1,13 +1,15 @@
.nav { .nav {
position: absolute; display: flex;
top: -130px; justify-content: space-between;
right: 0; left: 0;
padding-bottom: 10px;
} }
.nav ul { .nav ul {
margin: 0; margin: 0;
list-style: none; list-style: none;
text-align: center; text-align: left;
padding-inline-start: 0px;
} }
.nav li { .nav li {
@ -19,6 +21,23 @@
line-height: 40px; line-height: 40px;
} }
#search {
padding: 6px 12px;
background: rgb(31, 32, 35);
border: 1px solid rgb(60, 63, 68);
border-radius: 4px;
font-size: 13px;
color: rgb(247, 248, 248);
appearance: none;
transition: border 0.15s ease 0s;
:focus{
outline: none;
box-shadow: none;
border-color: rgb(100, 153, 255);
}
}
.nav a { .nav a {
display: block; display: block;
color: inherit; color: inherit;
@ -30,7 +49,7 @@
} }
.nav button { .nav button {
height: 40px; height: 14px;
} }
.nav button:hover { .nav button:hover {
@ -72,7 +91,7 @@
} }
#dropArea { #dropArea {
border: 2px dashed #ccc; border: 2px dashed #cccccc4f;
border-radius: 20px; border-radius: 20px;
width: 100%; width: 100%;
font-family: sans-serif; font-family: sans-serif;
@ -159,3 +178,7 @@ label {
left: 50%; left: 50%;
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
} }
.main {
padding-top: 10px;
}

View file

@ -41,6 +41,24 @@ body {
display: none; display: none;
} }
@keyframes slideaway {
0% { transform: translateY(0); opacity: 1; }
100% { transform: translateY(40px); opacity: 0; }
}
.hide {
animation: slideaway 200ms forwards;
}
@keyframes slideback {
0% { transform: translateY(40px); opacity: 0; }
100% { transform: translateY(0); opacity: 1; }
}
.show {
animation: slideback 200ms forwards;
}
.embedderapp { .embedderapp {
background: #121212; background: #121212;
margin: 130px 0 40px 0; margin: 130px 0 40px 0;
@ -99,7 +117,7 @@ body {
} }
.new-embedder { .new-embedder {
padding: 16px 16px 16px 60px; padding: 16px 16px 16px 16px;
height: 65px; height: 65px;
border: none; border: none;
background: rgba(0, 0, 0, 0.003); background: rgba(0, 0, 0, 0.003);
@ -212,7 +230,7 @@ body {
.embedder-list li label { .embedder-list li label {
word-break: break-all; word-break: break-all;
padding: 15px 15px 15px 60px; padding: 15px 15px 15px 15px;
display: block; display: block;
line-height: 1.2; line-height: 1.2;
transition: color 0.4s; transition: color 0.4s;

View file

@ -160,11 +160,32 @@ function openFullSize(imageUrl) {
document.body.appendChild(modal); document.body.appendChild(modal);
// Add an event listener to close the modal when the user clicks on it // Add an event listener to close the modal when the user clicks on it
modal.addEventListener('click', function() { modal.addEventListener("click", function() {
modal.remove(); modal.remove();
}); });
} }
function extension(string) { let searchInput = document.getElementById("search");
return string.slice((string.lastIndexOf(".") - 2 >>> 0) + 2);
} searchInput.addEventListener("input", () => {
let searchValue = searchInput.value;
let mediaList = document.querySelectorAll("ul.embedder-list li");
mediaList.forEach((li) => {
if (!li.id.toLowerCase().includes(searchValue)) { //make lowercase to allow case insensitivity
li.classList.add("hide");
li.classList.remove("show");
li.addEventListener("animationend", function() {
if (searchInput.value !== "") {
this.style.display = "none";
}
}, {once: true}); // The {once: true} option automatically removes the event listener after it has been called
} else {
li.style.display = "";
li.classList.remove("hide");
if (searchValue === "" && !li.classList.contains("show")) {
li.classList.add("show");
}
}
});
});

View file

@ -46,6 +46,19 @@ export function updateDatabase(oldVersion: number, newVersion: number){
} }
} }
/**Searches the database and returns images with partial or exact keysearches */
export function searchImages(imagename: string, partial: boolean) {
return new Promise((resolve, reject) => {
console.log(`searching for ${imagename}`);
});
}
export function updateImageName(oldimagename: string, newname:string) {
return new Promise((resolve, reject) => {
console.log(`updating ${oldimagename} to ${newname}`);
});
}
/**Inserts a new user to the database */ /**Inserts a new user to the database */
export function createUser(username: string, password: string) { export function createUser(username: string, password: string) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {

View file

@ -19,23 +19,25 @@
</head> </head>
<body> <body>
<section class="embedderapp"> <section class="embedderapp">
<header class="header">
<h1>Embedder</h1>
<nav class="nav"> <nav class="nav">
<ul> <ul class="left-ul">
<li class="user"><%= user.name || user.username %></li> <li class="user"><%= user.name || user.username %></li>
<li> <li>
<form action="/logout" method="post"> <form action="/logout" method="post">
<button class="logout" type="submit">Sign out</button> <button class="logout" type="submit"></button>
</form> </form>
</li> </li>
<% if (user.name == "admin" || user.username == "admin") { %> <% if (user.name == "admin" || user.username == "admin") { %>
<li> <li>
<button class="adduser" onclick="location.href='/adduser';">Add user</a></button> <button class="adduser" onclick="location.href='/adduser';"></a></button>
</li> </li>
<% } %> <% } %>
</ul> </ul>
<input type="text" id="search" name="search" placeholder="Search" value=""/>
</nav> </nav>
<header class="header"> </header>
<h1>Embedder</h1>
<form action="/" method="post" encType="multipart/form-data"> <form action="/" method="post" encType="multipart/form-data">
<div id="dropArea"> <div id="dropArea">
<p class="dragregion">Upload a file, copy paste, or drag n' drop into the dashed region</p> <p class="dragregion">Upload a file, copy paste, or drag n' drop into the dashed region</p>
@ -60,12 +62,11 @@
<p class="dragregion">Click the file to copy the url</p> <p class="dragregion">Click the file to copy the url</p>
</div> </div>
</form> </form>
</header>
<% if (Count > 0) { %> <% if (Count > 0) { %>
<section class="main"> <section class="main">
<ul class="embedder-list"> <ul class="embedder-list">
<% files.forEach(function(file) { %> <% files.forEach(function(file) { %>
<li> <li id="<%= file.path %>" class="show">
<form action="<%= file.url %>" method="post"> <form action="<%= file.url %>" method="post">
<div class="view"> <div class="view">
<% if (extension(file.path) == ".mp4" || extension(file.path) == ".mov" || extension(file.path) == "webp") { %> <% if (extension(file.path) == ".mp4" || extension(file.path) == ".mov" || extension(file.path) == "webp") { %>