diff --git a/assets/main/main.js b/assets/main/main.js index a98047f..98cc4d8 100644 --- a/assets/main/main.js +++ b/assets/main/main.js @@ -70,6 +70,25 @@ function generateToc() { }) } +function commentRemember(name, elName) { + let value = ""; + let nameEQ = name + "="; + let cookies = document.cookie.split(';'); + for (let i = 0; i < cookies.length; i++) { + let cookie = cookies[i]; + while (cookie.charAt(0) == ' ') { + cookie = cookie.substring(1, cookie.length); + } + if (cookie.includes(nameEQ)) { + value = cookie.substring(nameEQ.length, cookie.length); + } + } + if (value == "" || !value.includes('=')) { + return false; + } + document.getElementById(elName).value = decodeURIComponent(value.split('=')[1]) +} + window.addEventListener('DOMContentLoaded', function () { generateToc(); hljs.highlightAll(); @@ -83,4 +102,7 @@ window.addEventListener('DOMContentLoaded', function () { tablegroups.forEach(function (tbody) { tbody.classList.add('table-group-divider'); }); + commentRemember("remember_author", "author") + commentRemember("remember_mail", "mail") + commentRemember("remember_url", "url") }) \ No newline at end of file diff --git a/template-parts/comments.php b/template-parts/comments.php index 7902795..17b397b 100644 --- a/template-parts/comments.php +++ b/template-parts/comments.php @@ -20,20 +20,18 @@