Skip to content

Commit

Permalink
fix: refine javascript codes for vertical reading
Browse files Browse the repository at this point in the history
  • Loading branch information
plateaukao committed Nov 30, 2024
1 parent 009113e commit 9ad9fd9
Showing 1 changed file with 1 addition and 29 deletions.
30 changes: 1 addition & 29 deletions app/src/main/assets/process_text_nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,39 +149,11 @@ function convertListLabel(node) {
});
}

// const ulLists = node.querySelectorAll("ul");
// ulLists.forEach((ul) => {
// const listStyleType = ul.style.listStyleType;
// const listItems = ul.querySelectorAll("li");
// listItems.forEach((li, index) => {
// const marker = convertLabel(listStyleType, index);
// li.setAttribute("data-marker", marker);
// });
// });

// Run the function on the document body
convertListLabel(document.body);

function changeOlToOlCjk(node) {
const olElements = node.querySelectorAll("ol");

olElements.forEach((ol) => {
const newOl = document.createElement("ol");
newOl.classList.add("cjk");

// Copy all attributes from old ol to new ol
for (let attr of ol.attributes) {
newOl.setAttribute(attr.name, attr.value);
}

// Move all children from old ol to new ol
while (ol.firstChild) {
newOl.appendChild(ol.firstChild);
}

// Replace old ol with new ol
ol.parentNode.replaceChild(newOl, ol);
});
node.querySelectorAll("ol").forEach((ol) => { ol.classList.add("cjk"); });
}

changeOlToOlCjk(document.body);
Expand Down

0 comments on commit 9ad9fd9

Please sign in to comment.