Skip to content

Commit 48bf5fd

Browse files
committed
Fixed empty PV issue.
1 parent d56b71f commit 48bf5fd

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

assets/js/_utils/pageviews.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ function countUp(min, max, destId) {
2626
function countPV(path, rows) {
2727
var count = 0;
2828

29-
for (var i = 0; i < rows.length; ++i) {
30-
var gaPath = rows[i][0];
31-
if (gaPath == path) { /* path format see: site.permalink */
32-
count += parseInt(rows[i][1]);
33-
break;
29+
if (rows !== undefined ) {
30+
for (var i = 0; i < rows.length; ++i) {
31+
var gaPath = rows[i][0];
32+
if (gaPath == path) { /* path format see: site.permalink */
33+
count += parseInt(rows[i][1]);
34+
break;
35+
}
3436
}
3537
}
3638

@@ -59,7 +61,7 @@ function displayPageviews(data) {
5961
}
6062

6163
var hasInit = getInitStatus();
62-
var rows = data.rows;
64+
var rows = data.rows; /* could be undefined */
6365

6466
if ($("#post-list").length > 0) { /* the Home page */
6567
$(".post-preview").each(function() {

0 commit comments

Comments
 (0)