File tree Expand file tree Collapse file tree 1 file changed +18
-6
lines changed Expand file tree Collapse file tree 1 file changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -665,15 +665,27 @@ $('.stars').each(function(idx, element){
665
665
var $el = $ ( element ) ;
666
666
var repo = $el . attr ( 'data-repo' ) ;
667
667
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
+
668
678
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 ] ) {
672
680
673
- $el . find ( 'i' ) . after ( $count ) ;
681
+ $ . getJSON ( 'https://api.github.com/repos/' + repo , function ( repoData ) {
682
+ localStorage . setItem ( "stars_" + repo , repoData . stargazers_count ) ;
674
683
675
- $el . show ( ) ;
676
- } ) ;
684
+ setCount ( localStorage [ "stars_" + repo ] ) ;
685
+ } ) ;
686
+ } else {
687
+ setCount ( localStorage [ "stars_" + repo ] ) ;
688
+ }
677
689
}
678
690
} ) ;
679
691
You can’t perform that action at this time.
0 commit comments