mirror of
https://github.com/huhu/rust-search-extension
synced 2024-11-16 00:17:57 +00:00
Merge pull request #54 from shwin0901/master
Only count the last week history statistics
This commit is contained in:
commit
4fb9fd228c
3 changed files with 11 additions and 5 deletions
|
@ -1,5 +1,5 @@
|
|||
.main {
|
||||
padding: 2rem;
|
||||
padding: 2.2rem;
|
||||
}
|
||||
|
||||
.toast {
|
||||
|
@ -103,7 +103,7 @@ input:checked + .slider:before {
|
|||
|
||||
.stats-link {
|
||||
color:#121212;
|
||||
font-size: 15px;
|
||||
font-size: 14px;
|
||||
border-radius: 5px;
|
||||
padding: 0;
|
||||
text-decoration: none;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
body {
|
||||
scroll-behavior: smooth;
|
||||
overflow-x: hidden;
|
||||
width: 280px;
|
||||
width: 300px;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
@ -61,7 +61,7 @@
|
|||
</div>
|
||||
<div class="statistics-page">
|
||||
<a href="../stats/index.html" target="_blank" class="stats-link">
|
||||
<b id="stats-week-count">0</b> searchings this week >
|
||||
<b id="stats-week-count">0</b> searchings in the last week >
|
||||
</a>
|
||||
</div>
|
||||
<div style="margin-top: 30px; font-size: 11px;text-align: center">
|
||||
|
|
|
@ -81,6 +81,12 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||
let history = JSON.parse(localStorage.getItem("history"));
|
||||
let statsPage = document.querySelector(".statistics-page");
|
||||
let statsWeekCount = statsPage.querySelector("#stats-week-count");
|
||||
let now = new Date();
|
||||
let weekAgo = now.setDate(now.getDate() - 7);
|
||||
history = history.filter(({time}) => {
|
||||
return weekAgo <= time;
|
||||
});
|
||||
|
||||
if(history) {
|
||||
statsWeekCount.textContent = `${history.length}`
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue