@@ -31,11 +31,14 @@ if (parseSearch().value || parseHash().id_token) {
31
31
32
32
}
33
33
34
- try {
35
- localStorage . setItem ( "visited" , "1" ) ;
36
- } catch ( e ) {
37
- // Safari when in private browsing doesn't allow it
34
+ function safeLocalStorageSetItem ( key , value ) {
35
+ try {
36
+ localStorage . setItem ( key , value ) ;
37
+ } catch ( e ) {
38
+ // Safari when in private browsing doesn't allow it
39
+ }
38
40
}
41
+ safeLocalStorageSetItem ( "visited" , "1" ) ;
39
42
40
43
/*
41
44
* Show menu mobile
@@ -441,7 +444,7 @@ FaFp+DyAe+b4nDwuJaW2LURbr8AEZga7oQj0uYxcYw==\n\
441
444
442
445
function saveToStorage ( jwt ) {
443
446
// Save last valid jwt value for refresh
444
- localStorage . setItem ( "jwtValue" , jwt ) ;
447
+ safeLocalStorageSetItem ( "jwtValue" , jwt ) ;
445
448
446
449
447
450
}
@@ -728,15 +731,16 @@ $('.stars').each(function(idx, element){
728
731
}
729
732
730
733
if ( repo ) {
731
- if ( ! localStorage [ "stars_" + repo ] ) {
734
+ var repoKey = "stars_" + repo ;
735
+ if ( ! localStorage . getItem ( repoKey ) ) {
732
736
733
737
$ . getJSON ( 'https://api.github.com/repos/' + repo , function ( repoData ) {
734
- localStorage . setItem ( "stars_" + repo , repoData . stargazers_count ) ;
735
-
736
- setCount ( localStorage [ "stars_" + repo ] ) ;
738
+ var starCount = repoData . stargazers_count ;
739
+ safeLocalStorageSetItem ( repoKey , starCount ) ;
740
+ setCount ( starCount ) ;
737
741
} ) ;
738
742
} else {
739
- setCount ( localStorage [ "stars_" + repo ] ) ;
743
+ setCount ( localStorage . getItem ( repoKey ) ) ;
740
744
}
741
745
}
742
746
} ) ;
0 commit comments