Web Dev Solutions

Catalin Mititiuc

aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/index.js6
-rw-r--r--src/radial.js18
2 files changed, 16 insertions, 8 deletions
diff --git a/src/index.js b/src/index.js
index 24e017d..2ab35fa 100644
--- a/src/index.js
+++ b/src/index.js
@@ -249,6 +249,12 @@ document.querySelectorAll('[name="select-elevation"]').forEach(el => {
});
});
+document.querySelector('#toggle-grid-vis input').addEventListener('change', function () {
+ const svg = document.querySelector('object').contentDocument.querySelector('svg');
+ svg.querySelector('.grid').style.display = this.checked ? 'inline' : 'none';
+ svg.querySelector('#dots').style.display = this.checked ? 'inline' : 'none';
+});
+
contentVisToggleEl.addEventListener('input', toggleContentVis);
contentVisToggleEl.checked = (localStorage.getItem('content-visibility') !== 'false');
toggleContentVis();
diff --git a/src/radial.js b/src/radial.js
index 046b608..c6e52a6 100644
--- a/src/radial.js
+++ b/src/radial.js
@@ -413,7 +413,7 @@ function addElevationClass(element) {
return el => element.classList.add(elevationClass(el));
}
-function drawBuildings(buildings, container, { q: pq, r: pr, s: ps }, furniture) {
+function drawBuildings(buildings, container, { q: pq, r: pr, s: ps }, features) {
return buildings.reduce((acc, building) => {
const buildingContainer = document.createElementNS(xmlns, 'g');
buildingContainer.classList.add(`building`);
@@ -465,17 +465,19 @@ function drawBuildings(buildings, container, { q: pq, r: pr, s: ps }, furniture)
if ((use.classList.contains('doors') || use.classList.contains('door-edges')) && !use.classList.contains('exits'))
building.elevationLevels.slice(0, -1).forEach(addElevationClass(use));
- if (use.classList.contains('furniture'))
- building.elevationLevels.slice(0, -1).forEach(addElevationClass(use));
-
buildingStructure.appendChild(use);
}
- const furnitureEl = furniture && furniture.querySelector(`.${building.type} .furniture`);
+ const featuresEl = features && features.querySelector(`.${building.type}`);
+
+ for (let child of [...featuresEl.children]) {
+ if (child.classList.contains('furniture'))
+ building.elevationLevels.slice(0, -1).forEach(addElevationClass(child));
+
+ if (child.classList.contains('stairs'))
+ building.elevationLevels.forEach(addElevationClass(child));
- if (furnitureEl) {
- building.elevationLevels.slice(0, -1).forEach(addElevationClass(furnitureEl));
- buildingStructure.appendChild(furnitureEl);
+ buildingStructure.appendChild(child);
}
return acc;