@@ -49,6 +49,30 @@ const ltxP=urlP.get("ltx");
4949const amP = urlP . get ( "am" ) ;
5050const 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 + "<x=" + 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+
5276document . 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 ;
0 commit comments