Skip to content

Commit c17504f

Browse files
committed
Delete Cookies option
1 parent 2fc510a commit c17504f

4 files changed

Lines changed: 31 additions & 4 deletions

File tree

‎math-accents.html‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ <h1>Unicode-Math Accents Table</h1>
4444

4545
<details id="fontselector">
4646
<summary><b>Font Column Selection</b></summary>
47-
<p><button onclick="updateURL()">Update/Copy URL</button> <button onclick="updateCookies()">Save State (Cookies)</button></p>
47+
<p>
48+
<button onclick="updateURL()">Update/Copy URL</button>
49+
<button onclick="updateCookies()">Save State (Cookies)</button>
50+
<button onclick="deleteCookies()">Reset State (Delete Cookies)</button>
51+
</p>
4852

4953
</details>
5054

‎math-samples.html‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ <h1>Math Samples Font Test</h1>
4444

4545
<details id="fontselector">
4646
<summary><b>Font Column Selection</b></summary>
47-
<p><button onclick="updateURL()">Update/Copy URL</button> <button onclick="updateCookies()">Save State (Cookies)</button></p>
47+
<p>
48+
<button onclick="updateURL()">Update/Copy URL</button>
49+
<button onclick="updateCookies()">Save State (Cookies)</button>
50+
<button onclick="deleteCookies()">Reset State (Delete Cookies)</button>
51+
</p>
4852
</details>
4953

5054
<h3>MathML Font Display</h3>

‎math-test-expression.html‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,11 @@ <h3>Show a math expression in a range of math fonts</h3>
219219
<button onclick="updateMathML()">Update Display</button>
220220
<button onclick="reformatMathML()">Reformat MathML</button>
221221

222-
<p><button onclick="updateURL()">Update/Copy URL</button> <button onclick="updateCookies()">Save State (Cookies)</button></p>
222+
<p>
223+
<button onclick="updateURL()">Update/Copy URL</button>
224+
<button onclick="updateCookies()">Save State (Cookies)</button>
225+
<button onclick="deleteCookies()">Reset State (Delete Cookies)</button>
226+
</p>
223227

224228
<h3>MathML Font Display</h3>
225229

‎mathfont-table.js‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,17 @@ function updateCookies () {
101101
if(mml) createCookie("mathfonts-mml",LZString.compressToEncodedURIComponent(mml.value));
102102
}
103103

104+
function deleteCookies () {
105+
if(typeof minwin == 'object') deleteCookie("mathfonts-width");
106+
deleteCookie("mathfonts-fonts");
107+
const l= document.getElementById("ltxedit");
108+
const am = document.getElementById("asciimathedit");
109+
const mml = document.getElementById("mmledit");
110+
if(l) deleteCookie("mathfonts-ltx");
111+
if(am) deleteCookie("mathfonts-am");
112+
if(mml) deleteCookie("mathfonts-mml");
113+
}
114+
104115
document.addEventListener("DOMContentLoaded", () => {
105116

106117
let sty = document.createElement("style");
@@ -258,7 +269,11 @@ var createCookie = function(name, value) {
258269
else {
259270
expires = "";
260271
}
261-
document.cookie = name + "=" + value + expires + "; path=document.location.href;SameSite=Lax";
272+
document.cookie = name + "=" + value + expires + "; SameSite=Lax";
273+
}
274+
275+
var deleteCookie = function(name) {
276+
document.cookie = name + "=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT; SameSite=Lax";
262277
}
263278

264279
function getCookie(c_name) {

0 commit comments

Comments
 (0)