This commit is contained in:
Turtle committed 2025-12-22 13:26:45 +01:00
1 parent e49ce13dc7
commit 322c62ec80
7 files changed
+387 -23

No files matched your search

+17 -1
View File
@@ -77,7 +77,7 @@ overlay {
backdrop-filter: blur(10px);
border-radius: var(--border-radius);
padding: 15px;
text-align: center;
text-align: left;
overflow-x: hidden;
overflow-y: auto;
box-shadow: var(--def-shadow);
@@ -168,4 +168,20 @@ content {
top: 0;
border-radius: 0;
}
}
/* ----------- custom ----------- */
.add_button {
width: 45px;
height: 45px;
border-radius: 50%;
padding: 0;
font-size: 25px;
background-color: white;
border: 1px solid black;
}
.add_button:hover {
border: 2px solid grey;
background-color: lightgray;
}
+98 -1
View File
@@ -1,18 +1,48 @@
const getId = (id) => document.getElementById(id);
function getOverlay(id) {
const elms = document.getElementsByName(id);
if (elms.length == 0) return null;
return elms[0];
}
function showOverlay(id) {
const elm = getId(id);
if (!elm) return;
const overlay = document.createElement("div");
const computedStyles = getComputedStyle(elm);
const defaultStyles = getDefaultComputedStyle(elm);
let styleString = "";
for (let style of computedStyles) {
if (style == "display") continue;
const computedValue = computedStyles.getPropertyValue(style);
const defaultValue = defaultStyles.getPropertyValue(style);
if (computedValue == defaultValue) continue;
styleString += `${style}: ${computedValue}; `;
}
overlay.classList.add("overlay");
overlay.setAttribute("name", id);
overlay.innerHTML = `
<div onclick="_onOverlayDestroy(this.parentElement);"></div>
<div>
<div class="${id}" style="${styleString}">
<button class="close" onclick="_onOverlayDestroy(this.parentElement.parentElement);">x</button>
${elm.innerHTML}
</div>
`;
document.body.appendChild(overlay);
const cb = elm.getAttribute("onopen");
if (typeof cb == "string") {
try {
eval(
`const overlay = document.getElementsByClassName("${id}")[0]; ` +
cb
);
} catch (err) {
console.error(err);
}
}
}
function _onOverlayDestroy(elm) {
const ori_elm = getId(elm.getAttribute("name"));
@@ -253,4 +283,71 @@ class CouchDB {
};
}
}
async delete(id) {
try {
var existingDoc = null;
try {
existingDoc = await this._get_db_data(id);
} catch (err) {}
if (!existingDoc) return {
type: "error",
message: "Not found!",
};
const res = await this._send_db_request(
"DELETE",
`${id}?rev=${existingDoc._rev}`
);
return {
type: "success",
message: res,
};
} catch (err) {
console.error(err);
return {
type: "error",
message: err,
};
}
}
}
//getuser
function getURLArgsMap() {
let spl = location.href.split("?");
if (spl.length != 2) return {};
let _1 = spl[1].split(",");
const res = {};
for (var i of _1) {
let _2 = i.split("=");
if (_2.length == 2) {
res[_2[0]] = _2[1];
} else {
res[i] = null;
}
}
return res;
}
async function getUserData(couchDB) {
const username = getURLArgsMap()["user"];
if (!username) return null;
const res = await couchDB.get("users");
if (!res) return null;
const data = res[username];
return !data ? null : {
...data,
"name": username
};
}
var userData = null;
async function setUserData(couchDB) {
const res = await getUserData(couchDB);
if (res == null) {
location.href = "../login.html";
return false;
}
userData = res;
return true;
}