diff options
| author | Mistivia <i@mistivia.com> | 2025-11-04 23:19:52 +0800 |
|---|---|---|
| committer | Mistivia <i@mistivia.com> | 2025-11-04 23:19:52 +0800 |
| commit | 8dbcdce76cbd4cd3b2ad2dcfce5bf828d91aa07c (patch) | |
| tree | cb0f93e5df84353fc1f1257f71b3792d42edb2d2 /irclog/view | |
| parent | 6c66b7c72013f8e335d93b28e743101883f30bb9 (diff) | |
better log
Diffstat (limited to 'irclog/view')
| -rw-r--r-- | irclog/view/index.html | 18 | ||||
| -rw-r--r-- | irclog/view/view7.js (renamed from irclog/view/view4.js) | 28 |
2 files changed, 37 insertions, 9 deletions
diff --git a/irclog/view/index.html b/irclog/view/index.html index 490e9c3..41c33da 100644 --- a/irclog/view/index.html +++ b/irclog/view/index.html @@ -40,6 +40,22 @@ #searchlink { visibility: hidden; } + .logline { + color: black; + text-decoration: none; + } + .logline:link { + color: black; + text-decoration: none; + } + .logline:hover { + color: black; + text-decoration: underline; + } + .logline:visited { + color: black; + text-decoration: none; + } </style> </head> <body> @@ -57,6 +73,6 @@ <div id="log-container"></div> <button onclick="setPreviousDay()">上一天</button> <button onclick="setNextDay()">下一天</button> - <script src="./view4.js"></script> + <script src="./view7.js"></script> </body> </html> diff --git a/irclog/view/view4.js b/irclog/view/view7.js index 1863f64..29eed6c 100644 --- a/irclog/view/view4.js +++ b/irclog/view/view7.js @@ -44,11 +44,15 @@ function setDateState(date) { month = String(date.getMonth() + 1).padStart(2, '0'); day = String(date.getDate()).padStart(2, '0'); dateInput.value = formatDate(getDate(year, month, day)); - window.history.replaceState(null, '', window.location.origin + window.location.pathname + + let newurl = window.location.origin + window.location.pathname + '?chan=' + chan + '&y=' + year + '&m=' + month + - '&d=' + day); + '&d=' + day; + if (hashtag !== '') { + newurl = newurl + '#' + hashtag; + } + window.history.replaceState(null, '', newurl); } setDateState(getDate(year, month, day)); @@ -79,20 +83,28 @@ function linkify(text) { }); } +function sethash(time) { + let newurl = window.location.pathname + window.location.search + '#' + time; + window.history.replaceState(null, '', newurl); +} + function insertTag(text) { let res = ''; let lines = text.split('\n'); let scrollToInserted = false; for (let line of lines) { let time = line.substring(1, 9); - if (!scrollToInserted && time == hashtag && time !== '') { - res += '<span id="scrollTo"></span>'; - scrollToInserted = true; - res += '<span style="color:red;">' + line + '</span>\n'; + if (time == hashtag && time !== '') { + if (!scrollToInserted) { + res += '<span id="scrollTo"></span>'; + scrollToInserted = true; + } + res += '<a class="logline" href="#' + time + '" style="color:red;">' + line + '</span>\n'; } else { - res += line + '\n'; + res += '<a class="logline" href="#' + time + '">' + line + '</a>\n'; } } + hashtag = ''; return res; } @@ -117,7 +129,7 @@ function loadLog() { logContainer.innerHTML = `<pre>${logProcess(text)}</pre>`; let scrollTo = document.getElementById('scrollTo'); if (scrollTo) { - scrollTo.scrollIntoView(); + scrollTo.scrollIntoView({behavior: 'smooth', block: 'center'}); } }) .catch(error => { |
