Skip to content

Commit

Permalink
Reduce JS queries
Browse files Browse the repository at this point in the history
  • Loading branch information
agatemosu committed Jul 22, 2024
1 parent 539027e commit 7adfb47
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ const defaultColors = [
let scrollable = true;
let drake;

const mainContainer = document.querySelector("main");
const imagesBar = document.querySelector("#images-bar");
const dynamicStyles = document.querySelector("#dynamic-styles");

document.querySelectorAll(".tooltip").forEach((tooltip, index) => {
const defaultColor = defaultColors[index];
const colorPicker = tooltip.querySelector(".color-picker");
Expand Down Expand Up @@ -63,7 +67,6 @@ function createColorPicker(colorPicker, onChange, defaultColor) {
}

function addRow(tierName = "New tier", defaultColor = "#778899") {
const mainContainer = document.querySelector("main");
const newRow = document.createElement("div");
newRow.className = "row";

Expand Down Expand Up @@ -184,8 +187,6 @@ function selectImages() {
}

function uploadImages(files) {
const imagesBar = document.querySelector("#images-bar");

for (const file of files) {
const image = document.createElement("img");
image.src = URL.createObjectURL(file);
Expand Down Expand Up @@ -219,11 +220,9 @@ function initializeDragula() {
}

function dynamicStyle(checkbox, css) {
const style = document.querySelector("#dynamic-styles");

if (checkbox.checked) {
style.innerHTML += css;
dynamicStyles.innerHTML += css;
} else {
style.innerHTML = style.innerHTML.replace(css, "");
dynamicStyles.innerHTML = dynamicStyles.innerHTML.replace(css, "");
}
}

0 comments on commit 7adfb47

Please sign in to comment.