|
31 | 31 |
|
32 | 32 | <script>
|
33 | 33 | document.addEventListener('DOMContentLoaded', function() {
|
| 34 | + console.log('DOM Content Loaded - Initializing vote comment storage'); |
| 35 | + |
34 | 36 | const commentField = document.getElementById('vote-comment');
|
| 37 | + console.log('Comment field found:', commentField); |
| 38 | + |
35 | 39 | const paperId = commentField.dataset.paperId;
|
| 40 | + console.log('Paper ID:', paperId); |
| 41 | + |
36 | 42 | const storageKey = `vote_comment_${paperId}`;
|
| 43 | + console.log('Storage key:', storageKey); |
37 | 44 |
|
38 | 45 | // Load saved comment if it exists
|
39 | 46 | const savedComment = localStorage.getItem(storageKey);
|
| 47 | + console.log('Saved comment from storage:', savedComment); |
| 48 | + |
40 | 49 | if (savedComment) {
|
41 | 50 | commentField.value = savedComment;
|
| 51 | + console.log('Restored comment from storage'); |
42 | 52 | }
|
43 | 53 |
|
44 | 54 | // Save comment on input
|
45 | 55 | commentField.addEventListener('input', function() {
|
| 56 | + console.log('Input detected, saving comment:', this.value); |
46 | 57 | localStorage.setItem(storageKey, this.value);
|
47 | 58 | });
|
48 | 59 |
|
49 | 60 | // Clear storage when form is submitted
|
50 | 61 | const form = commentField.closest('form');
|
51 | 62 | form.addEventListener('submit', function() {
|
| 63 | + console.log('Form submitted, clearing storage'); |
52 | 64 | localStorage.removeItem(storageKey);
|
53 | 65 | });
|
54 | 66 | });
|
|
0 commit comments