Skip to content

Commit eeac928

Browse files
committed
set columns from url (accent table)
1 parent 2dee17d commit eeac928

3 files changed

Lines changed: 66 additions & 52 deletions

File tree

‎math-accents.html‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
p.breadcrumb {font-size: .9rem; border-bottom: solid thin black;}
3636
p.breadcrumb a {text-decoration:none; color:blue;}
3737
#fontdragr {display:none;}
38-
th.FontDrop,td.FontDrop {display:none;}
3938
</style>
4039
</head>
4140
<body>
@@ -45,6 +44,8 @@ <h1>Unicode-Math Accents Table</h1>
4544

4645
<details id="fontselector">
4746
<summary><b>Font Column Selection</b></summary>
47+
<p><button onclick="updateURL()">Update/Copy URL</button></p>
48+
4849
</details>
4950

5051
<h3>Table of Accents</h3>

‎mathfont-table.js‎

Lines changed: 64 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,30 @@ const ltxP=urlP.get("ltx");
4949
const amP=urlP.get("am");
5050
const mmlP=urlP.get("mml");
5151

52+
function updateURL () {
53+
let newl="?";
54+
if(typeof minwin == 'string') newl=newl+"w=" + minwin.value + "&";
55+
newl=newl+"fonts=";
56+
for (let value in mathfont_list) {
57+
newl=newl +(document.getElementById("select"+value).checked ?"Y" :"N");
58+
}
59+
const l= document.getElementById("ltxedit");
60+
const am = document.getElementById("asciimathedit");
61+
const mml = document.getElementById("mmledit");
62+
if(l) newl=newl + "&ltx=" + LZString.compressToEncodedURIComponent(l.value);
63+
if(am) newl=newl + "&am=" + LZString.compressToEncodedURIComponent(am.value);
64+
if(mml) newl=newl + "&mml=" + LZString.compressToEncodedURIComponent(mml.value);
65+
// copy to clipboard
66+
var nn=document.createElement("textarea");
67+
nn.value=document.location.protocol + "//" + document.location.host + document.location.pathname + newl;
68+
document.body.appendChild(nn);
69+
nn.select();
70+
document.execCommand("copy");
71+
document.body.removeChild(nn);
72+
// update
73+
document.location.search = newl;
74+
}
75+
5276
document.addEventListener("DOMContentLoaded", () => {
5377

5478
let sty = document.createElement("style");
@@ -76,7 +100,7 @@ document.addEventListener("DOMContentLoaded", () => {
76100

77101
const hdtr = document.getElementById('hdtr');
78102
const flow = document.getElementById('flow');
79-
103+
80104
if(flow) {
81105
let mmlex="<math display=\"block\"><mfrac><mn>1</mn><mi>x</mi></mfrac><mo>+</mo><msqrt><mi>y</mi></msqrt></math>";
82106
if(mmlP) mmlex=LZString.decompressFromEncodedURIComponent(mmlP);
@@ -93,36 +117,46 @@ document.addEventListener("DOMContentLoaded", () => {
93117
i=i+1;
94118
}
95119
}
96-
120+
97121
if (hdtr) {
98-
for (let value in mathfont_list) {
99-
let th = document.createElement("th");
100-
th.setAttribute("class",value);
101-
th.textContent=mathfont_list[value];
102-
hdtr.appendChild(th);
103-
}
104-
105-
const rows = Array.from(table.querySelectorAll('tbody tr'));
106-
rows.forEach(row => {
107-
const cells = Array.from(row.querySelectorAll('td'));
108-
// if there are fewer than 4 cells, skip
109-
if (cells.length < 4) return;
110-
// content to replicate - assume the 4th cell holds the sample
111-
const templateHTML = cells[3].innerHTML;
112-
113-
// remove any cells from index 3 onward (we'll recreate them)
114-
for (let i = cells.length - 1; i >= 3; i--) {
115-
cells[i].remove();
116-
}
117-
118-
// append a td for each header class (in order)
119-
for (let value in mathfont_list) {
120-
const td = document.createElement('td');
121-
td.className = value;
122-
td.innerHTML = templateHTML;
123-
row.appendChild(td);
124-
};
125-
});
122+
let i = 0;
123+
for (let value in mathfont_list) {
124+
let th = document.createElement("th");
125+
th.setAttribute("class",value);
126+
th.textContent=mathfont_list[value];
127+
if ((fontsP && fontsP.charAt(i)!="Y") || ((!fontsP && value=="FontDrop"))) {
128+
th.style.display="none";
129+
}
130+
hdtr.appendChild(th);
131+
i=i+1;
132+
}
133+
134+
const rows = Array.from(table.querySelectorAll('tbody tr'));
135+
rows.forEach(row => {
136+
const cells = Array.from(row.querySelectorAll('td'));
137+
// if there are fewer than 4 cells, skip
138+
if (cells.length < 4) return;
139+
// content to replicate - assume the 4th cell holds the sample
140+
const templateHTML = cells[3].innerHTML;
141+
142+
// remove any cells from index 3 onward (we'll recreate them)
143+
for (let i = cells.length - 1; i >= 3; i--) {
144+
cells[i].remove();
145+
}
146+
147+
// append a td for each header class (in order)
148+
let i=0;
149+
for (let value in mathfont_list) {
150+
const td = document.createElement('td');
151+
td.className = value;
152+
if ((fontsP && fontsP.charAt(i)!="Y") || ((!fontsP && value=="FontDrop"))) {
153+
td.style.display="none";
154+
}
155+
td.innerHTML = templateHTML;
156+
row.appendChild(td);
157+
i=i+1;
158+
};
159+
});
126160
}
127161
const fontsel=document.getElementById("fontselector");
128162
let i = 0;

‎mathml-table2.html‎

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -164,27 +164,6 @@
164164
return s;
165165
}
166166

167-
function updateURL () {
168-
var newl="?w=" + minwin.value + "&fonts=";
169-
for (let value in mathfont_list) {
170-
newl=newl +(document.getElementById("select"+value).checked ?"Y" :"N");
171-
}
172-
const l= document.getElementById("ltxedit").value
173-
const am = document.getElementById("asciimathedit").value;
174-
const mml = document.getElementById("mmledit").value;
175-
if(l) newl=newl + "&ltx=" + LZString.compressToEncodedURIComponent(l);
176-
if(am) newl=newl + "&am=" + LZString.compressToEncodedURIComponent(am);
177-
if(mml) newl=newl + "&mml=" + LZString.compressToEncodedURIComponent(mml);
178-
// copy to clipboard
179-
var nn=document.createElement("textarea");
180-
nn.value=document.location.protocol + "//" + document.location.host + document.location.pathname + newl;
181-
document.body.appendChild(nn);
182-
nn.select();
183-
document.execCommand("copy");
184-
document.body.removeChild(nn);
185-
// update
186-
document.location.search = newl;
187-
}
188167
</script>
189168
<script src="asciimath2ml.js"></script>
190169
<script src="Temml-0.12.01/dist/temml.min.js"></script>

0 commit comments

Comments
 (0)