diff --git a/startpage.html b/startpage.html index 3f55bef..acb0b01 100644 --- a/startpage.html +++ b/startpage.html @@ -300,17 +300,18 @@ create new layer -

or

+ + +
` @@ -944,7 +954,7 @@ `
-

- ${this.name}

+

[${zIndexMap.get(this.id)}]: ${this.name}

+ ${this.name}: color + shape options

@@ -973,7 +983,17 @@
- +
+
+ + + + +
+
+ +
+
` @@ -1444,12 +1464,15 @@ .addEventListener("input", changeWallpaper, false); document - /** load container data - let occupiedIndexMapValues = - JSON.parse(localStorage.getItem("occupiedIndexMapValues")) || []; - for (let i = 0; i < occupiedIndexMapValues.length; i++) { - occupiedIndices.set(occupiedIndexMapValues[i], true); - }*/ + /** load container data */ + let zIndexMapData = JSON.parse(localStorage.getItem("zIndexMapData")) || []; + let zIndexMapKeys = Object.keys(zIndexMapData) || []; + for (let i = 0; i < zIndexMapKeys.length; i++) { + zIndexMap.set( + zIndexMapKeys[i], + zIndexMapData[zIndexMapKeys[i]] + ); + } let containerMapValues = JSON.parse(localStorage.getItem("containerMapValues")) || []; @@ -1599,13 +1622,12 @@ }); localStorage.setItem("containerMapValues", JSON.stringify(valueArray)); - /* save the states of occupied ID indice - valueArray = []; - occupiedIndices.keys().forEach((value) => { - valueArray.push(value); + /* save z-indexes */ + let temp = {}; + zIndexMap.keys().forEach((key) => { + temp[key] = zIndexMap.get(key); }); - localStorage.setItem("occupiedIndexMapValues", JSON.stringify(valueArray)); - */ + localStorage.setItem("zIndexMapData", JSON.stringify(temp)); // save wallpaper info localStorage.setItem("wallpaper", JSON.stringify(wallpaper)); @@ -1801,6 +1823,51 @@ ); } + function reorderContainer(buttonPressed, direction) { + let containerId = buttonPressed.id.split("--")[0]; + let container = document.getElementById(containerId); + let currentIndex = zindexmap.get(containerId); + let tempContainer; + let start; + + // TODO if only using mapKeys for length, just sum the numberOf..Containers + let mapKeys = []; + zIndexMap.keys().forEach(key => { + mapKeys.push(key); + }); + + // move indicated container + if (direction == "up") { + start = currentIndex + 1; + + + // TODO can't access with index dummy. gotta be id. figure out how to get the id of the necessary indices... + + + tempContainer = zIndexMap.get(// currentIndex + 1); + } + else if (direction == "down") { + start = currentIndex - 1; + tempContainer = zIndexMap.get(// currentIndex - 1); + } + else if (direction == "top") { + start = mapKeys.length; + tempContainer = zIndexMap.get(// mapKeys.length); + } + else if (direction == "bottom") { + start = 1; + tempContainer = zIndexMap.get(// 1); + } + + for (let i = start; i < mapKeys.length; i++) { + zIndexMap.set(containerDataMap(i).id, i); + document.getElementById(containerDataMap(i)).style.zIndex = i; + } + zindexMap.set(tempContainer, currentIndex); + // consider a redraw function for menu listings + } + + function deleteContainer(buttonPressed) { let containerId = buttonPressed.id.split("--")[0]; let container = containerDataMap.get(containerId);