Skip to content

Commit

Permalink
V3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
liaocp666 committed Jan 9, 2025
1 parent 20291e6 commit 6ca78c3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
22 changes: 22 additions & 0 deletions assets/main/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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")
})
4 changes: 1 addition & 3 deletions template-parts/comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,18 @@
<?php else: ?>
<div class="col-md-4">
<input type="text" class="form-control" placeholder="昵称" name="author" id="author"
value="<?php $this->remember('author'); ?>" required
required
/>
</div>
<div class="col-md-4">
<input type="email" class="form-control" placeholder="邮箱"
name="mail" id="mail"
value="<?php $this->remember('mail'); ?>"
<?php if ($this->options->commentsRequireMail): ?>required<?php endif; ?>
/>
</div>
<div class="col-md-4">
<input type="url" class="form-control"
name="url" id="url"
value="<?php $this->remember('url'); ?>"
<?php if ($this->options->commentsRequireUrl): ?>required<?php endif; ?>
placeholder="网址<?php if (!$this->options->commentsRequireUrl): ?><?php _e('(选填)'); ?><?php endif; ?>"
/>
Expand Down

0 comments on commit 6ca78c3

Please sign in to comment.