fixed adding multiple links but discovered deeper issue with section design. fixed container css and finally finished settings menu init
This commit is contained in:
+136
-208
@@ -27,7 +27,7 @@
|
|||||||
position: fixed;
|
position: fixed;
|
||||||
}
|
}
|
||||||
|
|
||||||
#mainContainer {
|
.container {
|
||||||
z-index: 998;
|
z-index: 998;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -43,6 +43,9 @@
|
|||||||
background-color: rgba(173, 165, 165, 0.8);
|
background-color: rgba(173, 165, 165, 0.8);
|
||||||
z-index: 999;
|
z-index: 999;
|
||||||
|
|
||||||
|
user-select: none;
|
||||||
|
|
||||||
|
|
||||||
border: solid black 2px;
|
border: solid black 2px;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
@@ -52,7 +55,8 @@
|
|||||||
top: 2rem;
|
top: 2rem;
|
||||||
align-self: flex-end;
|
align-self: flex-end;
|
||||||
|
|
||||||
overflow: auto;
|
height: 25rem;
|
||||||
|
overflow: scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -180,9 +184,7 @@
|
|||||||
|
|
||||||
<div id="settingsContainer" class="movable settingsContainer hidden">
|
<div id="settingsContainer" class="movable settingsContainer hidden">
|
||||||
<div id="tabList">
|
<div id="tabList">
|
||||||
<span class="tab" id="bookmarkTab">bookmarks</span>
|
|
||||||
<span class="tab" id="addContainerTab">containers / layers</span>
|
<span class="tab" id="addContainerTab">containers / layers</span>
|
||||||
<span class="tab" id="containerCustomizationTab">container</span>
|
|
||||||
<span class="tab" id="imageAndWallpaperTab">images + wallpaper</span>
|
<span class="tab" id="imageAndWallpaperTab">images + wallpaper</span>
|
||||||
<span class="tab" id="audioTab">audio</span>
|
<span class="tab" id="audioTab">audio</span>
|
||||||
<span class="tab" id="globalSettingsTab">global settings</span>
|
<span class="tab" id="globalSettingsTab">global settings</span>
|
||||||
@@ -248,12 +250,6 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form id="bookmarkForm" onsubmit="return false">
|
|
||||||
|
|
||||||
<br />
|
|
||||||
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<form id="addContainerForm" onsubmit="return false">
|
<form id="addContainerForm" onsubmit="return false">
|
||||||
<div class="formTitle">add new containers / layers</div>
|
<div class="formTitle">add new containers / layers</div>
|
||||||
<input
|
<input
|
||||||
@@ -266,9 +262,6 @@
|
|||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<form id="containerCustomizationForm" onsubmit="return false">
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<form id="imageAndWallpaperForm" onsubmit="return false">
|
<form id="imageAndWallpaperForm" onsubmit="return false">
|
||||||
<div class="formTitle">edit images</div>
|
<div class="formTitle">edit images</div>
|
||||||
<div>
|
<div>
|
||||||
@@ -373,7 +366,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
// cookie holder for coordinates + size of settings menu
|
// cookie holder for coordinates + size of settings menu
|
||||||
let settingsMenuData;
|
let settingsMenuData = {};
|
||||||
|
|
||||||
// cookie holder for coordinates + size of containers
|
// cookie holder for coordinates + size of containers
|
||||||
let containerDataMap = new Map(); // key: element.id | values: {x:, y:, width:, height:, containerSettings}
|
let containerDataMap = new Map(); // key: element.id | values: {x:, y:, width:, height:, containerSettings}
|
||||||
@@ -538,7 +531,7 @@
|
|||||||
document.body.insertAdjacentHTML(
|
document.body.insertAdjacentHTML(
|
||||||
"beforeend",
|
"beforeend",
|
||||||
`
|
`
|
||||||
<div class="movable" id=${this.id}>
|
<div class="movable container" id=${this.id}>
|
||||||
<div style="margin: auto">
|
<div style="margin: auto">
|
||||||
<div id=${this.id + "-clock"}>
|
<div id=${this.id + "-clock"}>
|
||||||
<span id=${this.id + "-date"}></span>
|
<span id=${this.id + "-date"}></span>
|
||||||
@@ -624,7 +617,7 @@
|
|||||||
document.body.insertAdjacentHTML(
|
document.body.insertAdjacentHTML(
|
||||||
"beforeend",
|
"beforeend",
|
||||||
`
|
`
|
||||||
<div class="movable" id=${this.id}>
|
<div class="movable container" id=${this.id}>
|
||||||
<div style="margin: auto">
|
<div style="margin: auto">
|
||||||
<div id=${this.id + "-clock"}>
|
<div id=${this.id + "-clock"}>
|
||||||
<span id=${this.id + "-date"}></span>
|
<span id=${this.id + "-date"}></span>
|
||||||
@@ -871,8 +864,6 @@
|
|||||||
* applies saved cosmetic customizations to container
|
* applies saved cosmetic customizations to container
|
||||||
*/
|
*/
|
||||||
applyContainerSettings() {
|
applyContainerSettings() {
|
||||||
console.log(this.containerSettings);
|
|
||||||
|
|
||||||
/** set options relevant to both image and text containers */
|
/** set options relevant to both image and text containers */
|
||||||
/** POSITION */
|
/** POSITION */
|
||||||
document.getElementById(this.id).style.top = this.y;
|
document.getElementById(this.id).style.top = this.y;
|
||||||
@@ -1184,25 +1175,45 @@
|
|||||||
* [re]loads saved bookmark sections + links for container
|
* [re]loads saved bookmark sections + links for container
|
||||||
*/
|
*/
|
||||||
loadBookmarks() {
|
loadBookmarks() {
|
||||||
if (this.sections == undefined) {
|
if (Object.keys(this.sections).length == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
console.log(this.sections);
|
||||||
let containerSettings = this.containerSettings;
|
let containerSettings = this.containerSettings;
|
||||||
let linkContainer = document.getElementById(this.id + "-sections");
|
let linkContainer = document.getElementById(this.id + "-sections");
|
||||||
linkContainer.innerHTML = "";
|
linkContainer.innerHTML = "";
|
||||||
|
|
||||||
// ensure uncategorized links (if any) stay at top
|
// ensure uncategorized links (if any) stay at top
|
||||||
const noneSectionIndex = Object.keys(this.sections).indexOf("none");
|
this.sections.none.order = 0;
|
||||||
|
|
||||||
|
/** const noneSectionIndex = Object.keys(this.sections).indexOf("none");
|
||||||
if (noneSectionIndex != -1 && noneSectionIndex != 0) {
|
if (noneSectionIndex != -1 && noneSectionIndex != 0) {
|
||||||
this.sections.splice(noneSectionIndex, 1);
|
this.sections.splice(noneSectionIndex, 1);
|
||||||
this.sections.unshift("none");
|
this.sections.unshift("none");
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
// organize sections into proper order
|
||||||
|
let sectionNames = Object.keys(this.sections);
|
||||||
|
let sectionData = Object.values(this.sections);
|
||||||
|
let orderedSectionNames = [];
|
||||||
|
let orderedSectionData = [];
|
||||||
|
|
||||||
|
for (let i = 0; i < sectionNames.length; i++) {
|
||||||
|
for(let j = 0; j < sectionNames.length; j++) {
|
||||||
|
if (sectionData[j].order == i) {
|
||||||
|
orderedSectionNames.push(sectionNames[i]);
|
||||||
|
orderedSectionData.push(sectionData[i]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// render the sections
|
// render the sections
|
||||||
let sectionNames = Object.keys(this.sections);
|
|
||||||
let weight = containerSettings.sectionBold ? "bold" : "normal";
|
let weight = containerSettings.sectionBold ? "bold" : "normal";
|
||||||
let italic = containerSettings.sectionItalic ? "italic" : "normal";
|
let italic = containerSettings.sectionItalic ? "italic" : "normal";
|
||||||
for (let i = 0; i < sectionNames.length; i++) {
|
for (let i = 0; i < orderedSectionNames.length; i++) {
|
||||||
linkContainer.insertAdjacentHTML(
|
linkContainer.insertAdjacentHTML(
|
||||||
"beforeend",
|
"beforeend",
|
||||||
`
|
`
|
||||||
@@ -1242,17 +1253,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// and then render the links
|
// and then render the links
|
||||||
let sections = Object.values(this.sections);
|
for (let s = 0; s < orderedSectionNames.length; s++) {
|
||||||
for (let s = 0; s < sections.length; s++) {
|
for (let l = 0; l < orderedSectionData[s].links.length; l++) {
|
||||||
for (let l = 0; l < sections[s].length; l++) {
|
|
||||||
let targetSection = document.getElementById(
|
let targetSection = document.getElementById(
|
||||||
this.id + "-section-" + sectionNames[s]
|
this.id + "-section-" + orderedSectionNames[s]
|
||||||
);
|
);
|
||||||
|
|
||||||
targetSection.insertAdjacentHTML(
|
targetSection.insertAdjacentHTML(
|
||||||
"beforeend",
|
"beforeend",
|
||||||
`
|
`
|
||||||
<div id="${this.id}-${sectionNames[s]}-${l}" >
|
<div id="${this.id}-${orderedSectionNames[s]}-${l}" >
|
||||||
<span
|
<span
|
||||||
class="hiddenButton bookmark ${editing ? "" : "hidden"}"
|
class="hiddenButton bookmark ${editing ? "" : "hidden"}"
|
||||||
onClick="deleteLink(this)"
|
onClick="deleteLink(this)"
|
||||||
@@ -1262,9 +1272,9 @@
|
|||||||
|
|
||||||
<a
|
<a
|
||||||
class="${this.id}-link"
|
class="${this.id}-link"
|
||||||
href="${sections[s][l].url}"
|
href="${orderedSectionData[s].links[l].url}"
|
||||||
>
|
>
|
||||||
${sections[s][l].label}
|
${orderedSectionData[s].links[l].label}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
@@ -1360,21 +1370,8 @@
|
|||||||
.addEventListener("change", toggleWallpaperRepeat, false);
|
.addEventListener("change", toggleWallpaperRepeat, false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
OLD INIT
|
OLD INIT
|
||||||
|
|
||||||
/** load bookmark cookies *
|
|
||||||
sections = JSON.parse(localStorage.getItem("sections")) || [];
|
|
||||||
links = JSON.parse(localStorage.getItem("links")) || [];
|
|
||||||
|
|
||||||
/** load + apply saved (or default) container customization settings *
|
|
||||||
containerSettings =
|
|
||||||
JSON.parse(localStorage.getItem("containerSettings")) ||
|
|
||||||
defaultTextContainerSettings;
|
|
||||||
applyContainerSettings();
|
|
||||||
// render links + sections
|
|
||||||
loadSections();
|
|
||||||
|
|
||||||
/** load image data cookies *
|
/** load image data cookies *
|
||||||
let imageValues =
|
let imageValues =
|
||||||
JSON.parse(localStorage.getItem("imageMapValues")) || [];
|
JSON.parse(localStorage.getItem("imageMapValues")) || [];
|
||||||
@@ -1395,13 +1392,13 @@
|
|||||||
width: "",
|
width: "",
|
||||||
height: "",
|
height: "",
|
||||||
};
|
};
|
||||||
|
setupSettingsMenu();
|
||||||
|
|
||||||
/** load container data */
|
/** load container data */
|
||||||
let containerMapValues =
|
let containerMapValues =
|
||||||
JSON.parse(localStorage.getItem("containerMapValues")) || [];
|
JSON.parse(localStorage.getItem("containerMapValues")) || [];
|
||||||
for (let i = 0; i < containerMapValues.length; i++) {
|
for (let i = 0; i < containerMapValues.length; i++) {
|
||||||
// containerDataMap.set(containerMapValues[i].id, containerMapValues[i]);
|
// containerDataMap.set(containerMapValues[i].id, containerMapValues[i]);
|
||||||
console.log(containerMapValues[i].containerSettings);
|
|
||||||
if (containerMapValues[i].id != "settingsContainer") {
|
if (containerMapValues[i].id != "settingsContainer") {
|
||||||
containerDataMap.set(containerMapValues[i].id, new Container(
|
containerDataMap.set(containerMapValues[i].id, new Container(
|
||||||
containerMapValues[i].id,
|
containerMapValues[i].id,
|
||||||
@@ -1417,10 +1414,6 @@
|
|||||||
}
|
}
|
||||||
numberOfContainers = containerDataMap.length;
|
numberOfContainers = containerDataMap.length;
|
||||||
|
|
||||||
/** apply saved positions + sizes */
|
|
||||||
// NEEDED TO SETUP SETTINGS CONTAINER.. REWORK
|
|
||||||
setupMovableElements();
|
|
||||||
|
|
||||||
/** load last active settings tab user was on */
|
/** load last active settings tab user was on */
|
||||||
activeTabId =
|
activeTabId =
|
||||||
JSON.parse(localStorage.getItem("activeTabId")) || "instructionsTab";
|
JSON.parse(localStorage.getItem("activeTabId")) || "instructionsTab";
|
||||||
@@ -1439,49 +1432,26 @@
|
|||||||
/**************************
|
/**************************
|
||||||
* INITIALIZATION HELPERS *
|
* INITIALIZATION HELPERS *
|
||||||
**************************/
|
**************************/
|
||||||
function setupMovableElements() {
|
function setupSettingsMenu() {
|
||||||
// if user has any floating images saved, put them in the DOM
|
let settingsContainer = document.getElementById("settingsContainer");
|
||||||
// initializeSavedImages();
|
|
||||||
|
|
||||||
// I think this whole function is going to be changed.
|
/* set at the last saved location */
|
||||||
// we're no longer going through a map of stuff and setting
|
settingsContainer.style.top = settingsMenuData.y;
|
||||||
// things manually. we have helpers in the Container class
|
settingsContainer.style.left = settingsMenuData.x;
|
||||||
// to handle this kinda ish for us.
|
settingsContainer.style.width = settingsMenuData.width + "px";
|
||||||
|
settingsContainer.style.height = settingsMenuData.height + "px";
|
||||||
|
|
||||||
// send in the saved container data into the Container Constructor
|
/* add event listeners */
|
||||||
// and let it handle the rest
|
|
||||||
|
|
||||||
// however, this requires that the map of containers is being
|
// moving / resizing
|
||||||
// saved properly. make sure the ToggleEdit function is saving
|
settingsContainer.addEventListener(
|
||||||
// all of the Container fields properly. we may need to make an
|
|
||||||
// Container.export() function for easier JSON-ification to
|
|
||||||
// be stored in localStorage.
|
|
||||||
|
|
||||||
// then, set movable elements' saved data
|
|
||||||
let movableElements = document.getElementsByClassName("movable");
|
|
||||||
for (let i = 0; i < movableElements.length; i++) {
|
|
||||||
let element = movableElements[i];
|
|
||||||
let data = containerDataMap.get(element.id);
|
|
||||||
|
|
||||||
// set respective element at the last saved location
|
|
||||||
if (containerDataMap.has(element.id)) {
|
|
||||||
element.style.top = data.y;
|
|
||||||
element.style.left = data.x;
|
|
||||||
element.style.width = data.width + "px";
|
|
||||||
element.style.height = data.height + "px";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// finally, add event listeners
|
|
||||||
for (let i = 0; i < movableElements.length; i++) {
|
|
||||||
// make element movable + resizable
|
|
||||||
movableElements[i].addEventListener(
|
|
||||||
"mousedown",
|
"mousedown",
|
||||||
mouseDownMovableElement,
|
mouseDownMovableElement,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
// prevent context menu when resizing
|
// prevent context menu when resizing
|
||||||
movableElements[i].addEventListener("contextmenu", (e) => {
|
settingsContainer.addEventListener("contextmenu", (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1494,121 +1464,6 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* NOW FOUND IN CONTAINER CLASS
|
|
||||||
function addSettingsEventListeners() {
|
|
||||||
/** tab-switching listeners *
|
|
||||||
let tabs = document.getElementsByClassName("tab");
|
|
||||||
for (let i = 0; i < tabs.length; i++) {
|
|
||||||
tabs[i].addEventListener("click", changeActiveTab, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** local state setting inputs *
|
|
||||||
document
|
|
||||||
.getElementById("imageRatioToggle")
|
|
||||||
.addEventListener("change", toggleImageRatio, false);
|
|
||||||
document
|
|
||||||
.getElementById("imageRemovalToggle")
|
|
||||||
.addEventListener("change", toggleImageRemoval, false);
|
|
||||||
document
|
|
||||||
.getElementById("autoplayAudioToggle")
|
|
||||||
.addEventListener("change", toggleAutoplayAudio, false);
|
|
||||||
|
|
||||||
/** cookie / persistent setting inputs *
|
|
||||||
// container color setting listeners
|
|
||||||
document
|
|
||||||
.getElementById("containerColorPicker")
|
|
||||||
.addEventListener("input", changeContainerBackground, false);
|
|
||||||
document
|
|
||||||
.getElementById("containerAlpha")
|
|
||||||
.addEventListener("input", changeContainerBackground, false);
|
|
||||||
// container border setting listeners
|
|
||||||
document
|
|
||||||
.getElementById("borderWidth")
|
|
||||||
.addEventListener("input", changeContainerBorderWidth, false);
|
|
||||||
document
|
|
||||||
.getElementById("borderRadius")
|
|
||||||
.addEventListener("input", changeContainerBorderRadius, false);
|
|
||||||
document
|
|
||||||
.getElementById("borderColorPicker")
|
|
||||||
.addEventListener("input", changeContainerBorderColor, false);
|
|
||||||
// bookmark setting listeners
|
|
||||||
document
|
|
||||||
.getElementById("linkColorPicker")
|
|
||||||
.addEventListener("input", changeLinkColor, false);
|
|
||||||
document
|
|
||||||
.getElementById("linkSize")
|
|
||||||
.addEventListener("input", changeLinkSize, false);
|
|
||||||
// bookmark section setting listeners
|
|
||||||
document
|
|
||||||
.getElementById("sectionColorPicker")
|
|
||||||
.addEventListener("input", changeSectionColor, false);
|
|
||||||
document
|
|
||||||
.getElementById("sectionSize")
|
|
||||||
.addEventListener("input", changeSectionSize, false);
|
|
||||||
document
|
|
||||||
.getElementById("sectionBoldToggle")
|
|
||||||
.addEventListener("change", toggleSectionBold, false);
|
|
||||||
document
|
|
||||||
.getElementById("sectionItalicToggle")
|
|
||||||
.addEventListener("change", toggleSectionItalic, false);
|
|
||||||
// clock setting listeners
|
|
||||||
document
|
|
||||||
.getElementById("clockColorPicker")
|
|
||||||
.addEventListener("input", changeClockColor, false);
|
|
||||||
document
|
|
||||||
.getElementById("clockSize")
|
|
||||||
.addEventListener("input", changeClockSize, false);
|
|
||||||
document
|
|
||||||
.getElementById("clockBoldToggle")
|
|
||||||
.addEventListener("change", toggleClockBold, false);
|
|
||||||
document
|
|
||||||
.getElementById("clockItalicToggle")
|
|
||||||
.addEventListener("change", toggleClockItalic, false);
|
|
||||||
// container divider setting listeners
|
|
||||||
document
|
|
||||||
.getElementById("dividerToggle")
|
|
||||||
.addEventListener("change", disableDivider, false);
|
|
||||||
document
|
|
||||||
.getElementById("dividerColorPicker")
|
|
||||||
.addEventListener("input", changeDividerColor, false);
|
|
||||||
// container text setting listeners
|
|
||||||
document
|
|
||||||
.getElementById("setLeftAlign")
|
|
||||||
.addEventListener("change", changeContainerAlignment, false);
|
|
||||||
document
|
|
||||||
.getElementById("setCenterAlign")
|
|
||||||
.addEventListener("change", changeContainerAlignment, false);
|
|
||||||
document
|
|
||||||
.getElementById("setFontButton")
|
|
||||||
.addEventListener("click", changeFont, false);
|
|
||||||
// container shadow setting listeners
|
|
||||||
document
|
|
||||||
.getElementById("shadowX")
|
|
||||||
.addEventListener("input", changeContainerShadow, false);
|
|
||||||
document
|
|
||||||
.getElementById("shadowY")
|
|
||||||
.addEventListener("input", changeContainerShadow, false);
|
|
||||||
document
|
|
||||||
.getElementById("shadowBlur")
|
|
||||||
.addEventListener("input", changeContainerShadow, false);
|
|
||||||
document
|
|
||||||
.getElementById("shadowColorPicker")
|
|
||||||
.addEventListener("input", changeContainerShadow, false);
|
|
||||||
document
|
|
||||||
.getElementById("shadowAlpha")
|
|
||||||
.addEventListener("input", changeContainerShadow, false);
|
|
||||||
|
|
||||||
// page wallpaper
|
|
||||||
document
|
|
||||||
.getElementById("wallpaperColorPicker")
|
|
||||||
.addEventListener("input", changeWallpaper, false);
|
|
||||||
document
|
|
||||||
.getElementById("wallpaperRepeatToggle")
|
|
||||||
.addEventListener("change", toggleWallpaperRepeat, false);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** inserts saved images in their saved order (postioning done upon return)
|
/** inserts saved images in their saved order (postioning done upon return)
|
||||||
function initializeSavedImages() {
|
function initializeSavedImages() {
|
||||||
@@ -1668,7 +1523,6 @@
|
|||||||
let valueArray = [];
|
let valueArray = [];
|
||||||
containerDataMap.values().forEach((value) => {
|
containerDataMap.values().forEach((value) => {
|
||||||
valueArray.push(value);
|
valueArray.push(value);
|
||||||
console.log(value);
|
|
||||||
});
|
});
|
||||||
localStorage.setItem("containerMapValues", JSON.stringify(valueArray));
|
localStorage.setItem("containerMapValues", JSON.stringify(valueArray));
|
||||||
|
|
||||||
@@ -1848,8 +1702,13 @@
|
|||||||
function storeElementData() {
|
function storeElementData() {
|
||||||
let borderWidth = changingElement.style.borderWidth.slice(0, -2) * 2; // slice to remove "px"
|
let borderWidth = changingElement.style.borderWidth.slice(0, -2) * 2; // slice to remove "px"
|
||||||
let element = document.getElementById(changingElement.id);
|
let element = document.getElementById(changingElement.id);
|
||||||
if (changingElement.id == "settingsContainer") {
|
|
||||||
|
|
||||||
|
if (changingElement.id == "settingsContainer") {
|
||||||
|
console.log("saving settings cont");
|
||||||
|
settingsMenuData.x = element.style.left;
|
||||||
|
settingsMenuData.y = element.style.top;
|
||||||
|
settingsMenuData.width = element.offsetWidth;
|
||||||
|
settingsMenuData.height = element.offsetHeight;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let container = containerDataMap.get(element.id);
|
let container = containerDataMap.get(element.id);
|
||||||
@@ -2053,8 +1912,8 @@
|
|||||||
|
|
||||||
// save link (and if new, the section)
|
// save link (and if new, the section)
|
||||||
let tempIndex = Object.keys(container.sections).indexOf(section);
|
let tempIndex = Object.keys(container.sections).indexOf(section);
|
||||||
if (tempIndex =! -1) {
|
if (tempIndex != -1) {
|
||||||
let tempSectionLinks = Object.values(container.sections)[tempIndex];
|
let tempSectionLinks = Object.values(container.sections)[tempIndex].links;
|
||||||
tempSectionLinks.push({
|
tempSectionLinks.push({
|
||||||
label: label,
|
label: label,
|
||||||
url: url
|
url: url
|
||||||
@@ -2066,9 +1925,10 @@
|
|||||||
label: label,
|
label: label,
|
||||||
url: url
|
url: url
|
||||||
});
|
});
|
||||||
container.sections[section] = tempSectionLinks;
|
container.sections[section] = {}
|
||||||
|
container.sections[section].links = tempSectionLinks;
|
||||||
|
container.sections[section].order = Object.keys(container.sections).length + 1;
|
||||||
}
|
}
|
||||||
console.log(container.sections);
|
|
||||||
|
|
||||||
// reset inputs + render
|
// reset inputs + render
|
||||||
document.getElementById(containerId + "-url-input").value = "";
|
document.getElementById(containerId + "-url-input").value = "";
|
||||||
@@ -2077,16 +1937,84 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function reorderSection(buttonPressed, direction) {
|
function reorderSection(buttonPressed, direction) {
|
||||||
const section = buttonPressed.parentElement.id;
|
/*
|
||||||
const sectionIndex = sections.indexOf(section);
|
|
||||||
|
|
||||||
// cut out section and re-insert into array
|
|
||||||
sections.splice(sectionIndex, 1);
|
|
||||||
|
|
||||||
|
|
||||||
|
i need to redo container section structure from:
|
||||||
|
|
||||||
|
sections: {
|
||||||
|
label1 : {links:[], order:num},
|
||||||
|
label2 : {links:[], order:num},
|
||||||
|
...
|
||||||
|
}
|
||||||
|
|
||||||
|
to:
|
||||||
|
|
||||||
|
sections: {
|
||||||
|
0 : {label:"none", links:[]},
|
||||||
|
1 : {label:"example", links:[]},
|
||||||
|
...
|
||||||
|
}
|
||||||
|
|
||||||
|
that seems kinda obvious in hindsight... oh well
|
||||||
|
|
||||||
|
i will need to redo how the rendering works,
|
||||||
|
but i think that it will make reordering so much easier:
|
||||||
|
|
||||||
|
|
||||||
|
let copy = sections[currentIndex];
|
||||||
|
|
||||||
|
if move up,
|
||||||
|
sections[currentIndex] = sections[currentIndex+1];
|
||||||
|
sections[currentIndex+1] = copy;
|
||||||
|
if move down,
|
||||||
|
sections[currentIndex] = sections[currentIndex-1];
|
||||||
|
sections[currentIndex-1] = copy;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
i will need to revisit any area that checks for
|
||||||
|
section id via a split() call too, as i'm going
|
||||||
|
to be changing the section element id convention
|
||||||
|
from:
|
||||||
|
"container-section-label"
|
||||||
|
"container-section-0"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
let temp = buttonPressed.parentElement.id.split("-");
|
||||||
|
let sectionId = temp[temp.length - 1];
|
||||||
|
let containerId = temp[0];
|
||||||
|
|
||||||
|
let container = containerDataMap.get(containerId);
|
||||||
|
let containerIndex = container.sections.order;
|
||||||
|
|
||||||
|
// first, increment section
|
||||||
|
let numberOfSections = Object.keys(container.sections).length;
|
||||||
|
for (let i = 0; i < numberOfSections; i++) {
|
||||||
|
if (direction == "up" && sectionIndex != 0) {
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (direction == "down" && sectionIndex != numberOfSections - 1) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* cut out section and re-insert into array
|
||||||
|
container.sections.splice(sectionIndex, 1);
|
||||||
if (direction == "up" && sectionIndex != 0) {
|
if (direction == "up" && sectionIndex != 0) {
|
||||||
sections.splice(sectionIndex - 1, 0, section);
|
sections.splice(sectionIndex - 1, 0, section);
|
||||||
} else if (direction == "down" && sectionIndex != sections.length) {
|
} else if (direction == "down" && sectionIndex != sections.length) {
|
||||||
sections.splice(sectionIndex + 1, 0, section);
|
sections.splice(sectionIndex + 1, 0, section);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
// localStorage.setItem("sections", JSON.stringify(sections));
|
// localStorage.setItem("sections", JSON.stringify(sections));
|
||||||
loadSections();
|
loadSections();
|
||||||
|
|||||||
Reference in New Issue
Block a user