Skip to content

Commit 4c62058

Browse files
committed
fix safari stars
1 parent 5c2fe89 commit 4c62058

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

js/app.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -665,15 +665,27 @@ $('.stars').each(function(idx, element){
665665
var $el = $(element);
666666
var repo = $el.attr('data-repo');
667667

668+
function setCount(count) {
669+
var $count = $('<span>');
670+
671+
$count.text(count);
672+
673+
$el.find('i').after($count);
674+
675+
$el.show();
676+
}
677+
668678
if (repo){
669-
$.getJSON('//api.github.com/repos/' + repo, function(repoData){
670-
var $count = $('<span>');
671-
$count.text(repoData.stargazers_count);
679+
if(!localStorage["stars_" + repo]) {
672680

673-
$el.find('i').after($count);
681+
$.getJSON('https://api.github.com/repos/' + repo, function(repoData){
682+
localStorage.setItem("stars_" + repo, repoData.stargazers_count);
674683

675-
$el.show();
676-
});
684+
setCount(localStorage["stars_" + repo]);
685+
});
686+
} else {
687+
setCount(localStorage["stars_" + repo]);
688+
}
677689
}
678690
});
679691

0 commit comments

Comments
 (0)