Update 'frontend.js'

This commit is contained in:
Maxwell Drake 2024-04-07 21:46:41 +00:00
parent 58df23243e
commit fc9d73071d

View file

@ -4,8 +4,8 @@
// Functions for commonly used elements // Functions for commonly used elements
// get element by id // get element by id
function getElementById(el) { function getElementById(elementID) {
return document.getElementById(el) return document.getElementById(elementID)
} }
//Convert markdown to HTML and back //Convert markdown to HTML and back
@ -170,9 +170,9 @@ function createButton(elementID, text, attributes = {}) {
return elem; return elem;
} }
function changeAttributes(elem, attributes = {}) { function changeAttributes(element, attributes = {}) {
for (const [name, value] of Object.entries(attributes)) { for (const [name, value] of Object.entries(attributes)) {
elem.setAttribute(name, value); element.setAttribute(name, value);
} }
} }
@ -292,24 +292,24 @@ function addToList(listID, jsArray) {
// Gets the value of an attribute // Gets the value of an attribute
// Example: getAttribute(document.getElementById("link"), "href"); // Example: getAttribute(document.getElementById("link"), "href");
function getAttribute(el, att) { function getAttribute(element, attribute) {
let result = el.getAttribute(att); let result = element.getAttribute(attribute);
return result; return result;
} }
// Show/Hide Elements // Show/Hide Elements
// Example: hideShow(el) // Example: hideShow(element)
function hideShow(el) { function hideShow(element) {
if (el.style.display == 'none') { if (element.style.display == 'none') {
el.style.display = ''; element.style.display = '';
} else{ } else{
el.style.display = 'none'; element.style.display = 'none';
} }
} }
// Example: fadeOut(el, 1000) // Example: fadeOut(element, 1000)
function fadeOut(el, ms) { function fadeOut(element, ms) {
let elem = getElementById(el); let elem = getElementById(element);
ms = parseInt(ms); ms = parseInt(ms);
for (i = 0; i < (ms + 1); i++) { for (i = 0; i < (ms + 1); i++) {
elem.style.opacity -= (i / 100); elem.style.opacity -= (i / 100);
@ -317,9 +317,9 @@ function fadeOut(el, ms) {
} }
} }
// Example: fadeIn(el, 1000); // Example: fadeIn(element, 1000);
function fadeIn(el, ms) { function fadeIn(element, ms) {
elem = getElementById(el); elem = getElementById(element);
elem.style.opacity = 0; elem.style.opacity = 0;
ms = parseInt(ms); ms = parseInt(ms);
for (i = 0; i < (ms + 1); i++) { for (i = 0; i < (ms + 1); i++) {
@ -429,3 +429,4 @@ requir3("https://cdn.jsdelivr.net/npm/gun/gun.js") //Add Gun.JS support.
function initGun(relays = []) { function initGun(relays = []) {
return Gun(relays) return Gun(relays)
} }