Skip to content

Commit 0546344

Browse files
author
Basu Jindal
committed
stats update
1 parent d75b93d commit 0546344

4 files changed

Lines changed: 80 additions & 50 deletions

File tree

css/stats.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@
129129
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
130130
}
131131

132+
.stats-grid-2 {
133+
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
134+
max-width: 600px;
135+
}
136+
132137
/* Stat Cards */
133138
.stat-card {
134139
background: var(--card-bg);
@@ -748,6 +753,11 @@
748753
grid-template-columns: repeat(2, 1fr);
749754
}
750755

756+
.stats-grid-2 {
757+
grid-template-columns: repeat(2, 1fr);
758+
max-width: none;
759+
}
760+
751761
.stat-card {
752762
padding: 1rem;
753763
}
@@ -787,6 +797,7 @@
787797

788798
@media (max-width: 480px) {
789799
.stats-grid,
800+
.stats-grid-2,
790801
.stats-grid-3,
791802
.stats-grid-4,
792803
.stats-grid-5 {

html/stats.html

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ <h2>Owner Access Required</h2>
4747
<div id="stats-content" class="stats-content hidden">
4848
<!-- Overview Cards -->
4949
<section class="stats-section fade-in">
50-
<h2 class="section-title">Overview</h2>
50+
<h2 class="section-title">Visits by Page Type</h2>
5151
<div class="stats-grid stats-grid-5">
5252
<div class="stat-card accent-orange" data-stat="total_visits">
5353
<div class="stat-icon">
@@ -58,59 +58,59 @@ <h2 class="section-title">Overview</h2>
5858
</div>
5959
<div class="stat-info">
6060
<span class="stat-value" id="stat-total-visits">-</span>
61-
<span class="stat-label">Total Visits</span>
61+
<span class="stat-label">Total</span>
6262
</div>
6363
</div>
64-
<div class="stat-card" data-stat="posts">
64+
<div class="stat-card" data-stat="blog_visits">
6565
<div class="stat-icon">
6666
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
67-
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>
67+
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
68+
<polyline points="14 2 14 8 20 8"/>
69+
<line x1="16" y1="13" x2="8" y2="13"/>
70+
<line x1="16" y1="17" x2="8" y2="17"/>
6871
</svg>
6972
</div>
7073
<div class="stat-info">
71-
<span class="stat-value" id="stat-posts">-</span>
72-
<span class="stat-label">Thoughts</span>
74+
<span class="stat-value" id="stat-blog-visits">-</span>
75+
<span class="stat-label">Blogs</span>
7376
</div>
7477
</div>
75-
<div class="stat-card" data-stat="blog_posts">
78+
<div class="stat-card" data-stat="thoughts_visits">
7679
<div class="stat-icon">
7780
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
78-
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
79-
<polyline points="14 2 14 8 20 8"/>
80-
<line x1="16" y1="13" x2="8" y2="13"/>
81-
<line x1="16" y1="17" x2="8" y2="17"/>
81+
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>
8282
</svg>
8383
</div>
8484
<div class="stat-info">
85-
<span class="stat-value" id="stat-blog-posts">-</span>
86-
<span class="stat-label">Blog Posts</span>
85+
<span class="stat-value" id="stat-thoughts-visits">-</span>
86+
<span class="stat-label">Thoughts</span>
8787
</div>
8888
</div>
89-
<div class="stat-card" data-stat="unique_users">
89+
<div class="stat-card" data-stat="diffchecker_visits">
9090
<div class="stat-icon">
9191
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
92-
<path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/>
93-
<circle cx="9" cy="7" r="4"/>
94-
<path d="M23 21v-2a4 4 0 0 0-3-3.87"/>
95-
<path d="M16 3.13a4 4 0 0 1 0 7.75"/>
92+
<path d="M16 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8z"/>
93+
<polyline points="16 3 16 8 21 8"/>
94+
<line x1="8" y1="12" x2="16" y2="12"/>
95+
<line x1="8" y1="16" x2="16" y2="16"/>
9696
</svg>
9797
</div>
9898
<div class="stat-info">
99-
<span class="stat-value" id="stat-unique-users">-</span>
100-
<span class="stat-label">Unique Users</span>
99+
<span class="stat-value" id="stat-diffchecker-visits">-</span>
100+
<span class="stat-label">Diff Checker</span>
101101
</div>
102102
</div>
103-
<div class="stat-card" data-stat="total_logins">
103+
<div class="stat-card" data-stat="other_visits">
104104
<div class="stat-icon">
105105
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
106-
<path d="M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4"/>
107-
<polyline points="10 17 15 12 10 7"/>
108-
<line x1="15" y1="12" x2="3" y2="12"/>
106+
<circle cx="12" cy="12" r="10"/>
107+
<line x1="12" y1="8" x2="12" y2="12"/>
108+
<line x1="12" y1="16" x2="12.01" y2="16"/>
109109
</svg>
110110
</div>
111111
<div class="stat-info">
112-
<span class="stat-value" id="stat-total-logins">-</span>
113-
<span class="stat-label">Total Logins</span>
112+
<span class="stat-value" id="stat-other-visits">-</span>
113+
<span class="stat-label">Other</span>
114114
</div>
115115
</div>
116116
</div>

js/post.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,9 @@
6767
if (toc) {
6868
const tocSidebar = document.createElement('aside');
6969
tocSidebar.className = 'toc-sidebar';
70-
tocSidebar.innerHTML = toc + '<div id="mapmyvisitors-container" style="margin-top: 20px; text-align: center;"></div>';
70+
tocSidebar.innerHTML = toc;
7171
document.body.appendChild(tocSidebar);
7272

73-
// Load MapMyVisitors
74-
const mapContainer = document.getElementById('mapmyvisitors-container');
75-
if (mapContainer) {
76-
const script = document.createElement('script');
77-
script.type = 'text/javascript';
78-
script.id = 'mapmyvisitors';
79-
script.src = '//mapmyvisitors.com/map.js?d=LUhlD2Iz8BXSBnyy03hiL6D4dAgpWL8TXVMoAiF7lyQ&cl=ffffff&w=a';
80-
mapContainer.appendChild(script);
81-
}
82-
8373
const mobileTocBtn = document.createElement('button');
8474
mobileTocBtn.className = 'mobile-toc-btn';
8575
mobileTocBtn.setAttribute('aria-label', 'Table of Contents');

js/stats.js

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,15 @@
103103
}
104104

105105
function renderStats(data) {
106-
// Render totals
107-
document.getElementById('stat-total-visits').textContent = formatNumber(data.totals.total_visits);
108-
document.getElementById('stat-posts').textContent = formatNumber(data.totals.posts);
109-
document.getElementById('stat-blog-posts').textContent = formatNumber(data.totals.blog_posts);
110-
document.getElementById('stat-unique-users').textContent = formatNumber(data.totals.unique_users);
111-
document.getElementById('stat-total-logins').textContent = formatNumber(data.totals.total_logins);
106+
// Calculate visits by page type from visit_locations
107+
const visitsByType = calculateVisitsByType(data.visit_locations);
108+
109+
// Render visits by page type
110+
document.getElementById('stat-total-visits').textContent = formatNumber(visitsByType.total);
111+
document.getElementById('stat-blog-visits').textContent = formatNumber(visitsByType.blogs);
112+
document.getElementById('stat-thoughts-visits').textContent = formatNumber(visitsByType.thoughts);
113+
document.getElementById('stat-diffchecker-visits').textContent = formatNumber(visitsByType.diffchecker);
114+
document.getElementById('stat-other-visits').textContent = formatNumber(visitsByType.other);
112115

113116
// Render visitor details table
114117
renderVisitorDetails(data.visit_locations);
@@ -126,6 +129,37 @@
126129
renderBlogTable(data.blog_stats);
127130
}
128131

132+
function calculateVisitsByType(locations) {
133+
const result = {
134+
total: 0,
135+
blogs: 0,
136+
thoughts: 0,
137+
diffchecker: 0,
138+
other: 0
139+
};
140+
141+
if (!locations || locations.length === 0) {
142+
return result;
143+
}
144+
145+
locations.forEach(visit => {
146+
result.total++;
147+
const page = (visit.page || '').toLowerCase();
148+
149+
if (page.includes('section=blogs') || page.includes('/blogs')) {
150+
result.blogs++;
151+
} else if (page.includes('section=posts') || page.includes('/posts') || page.includes('section=thoughts') || page.includes('/thoughts')) {
152+
result.thoughts++;
153+
} else if (page.includes('diff') || page.includes('diffchecker')) {
154+
result.diffchecker++;
155+
} else {
156+
result.other++;
157+
}
158+
});
159+
160+
return result;
161+
}
162+
129163
function renderVisitsChart(visitsByDay) {
130164
const ctx = document.getElementById('activity-chart').getContext('2d');
131165

@@ -292,13 +326,8 @@
292326
`);
293327
});
294328

295-
// Fit bounds if we have locations
296-
if (Object.keys(locationGroups).length > 0) {
297-
const bounds = Object.values(locationGroups).map(g => [g.lat, g.lng]);
298-
if (bounds.length > 1) {
299-
visitorMap.fitBounds(bounds, { padding: [50, 50] });
300-
}
301-
}
329+
// Always show world view (markers will be placed on it)
330+
visitorMap.setView([20, 0], 2);
302331

303332
// Fix map rendering issues
304333
setTimeout(() => {

0 commit comments

Comments
 (0)