File size: 1,522 Bytes
d5bfab8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
function onloadRenderAllJsonDataImages() {
const imageDivs = document.querySelectorAll('[data-image]');
Array.from(imageDivs).forEach((imageDiv) => {
renderJsonDataImage(imageDiv);
});
}
function renderJsonDataImage(imageDiv) {
const datasetImageValue = imageDiv.dataset.image;
const divs = imageDiv.querySelectorAll('.json-data');
const div = divs[0];
const json = div.innerText;
const imageRows = JSON.parse(json);
const spanRowContainer = document.createElement('span');
spanRowContainer.className = 'themearc image rows';
imageRows.forEach((row, rowIndex) => {
const spanRow = document.createElement('span');
spanRow.className = 'themearc image row';
row.forEach((pixel, columnIndex) => {
const spanPixel = document.createElement('span');
spanPixel.className = `themearc symbol_${pixel}`;
spanPixel.textContent = pixel;
spanPixel.addEventListener('click', () => {
const host = window.location.href;
const url = `${host}/find-node-pixel?x=${columnIndex}&y=${rowIndex}&id=${datasetImageValue}`;
window.open(url, '_blank');
});
spanRow.appendChild(spanPixel);
});
spanRowContainer.appendChild(spanRow);
});
const divRowContainer = document.createElement('div');
divRowContainer.className = 'themearc image rows-container';
divRowContainer.appendChild(spanRowContainer);
imageDiv.appendChild(divRowContainer);
div.style.display = 'none';
}
|