@@ -74,9 +74,10 @@ var youmax_global_options = {};
7474
7575 } ,
7676
77- showUploads = function ( response ) {
77+ showUploads = function ( ) {
7878 $ ( '#youmax-video-list-div' ) . empty ( ) ;
79-
79+ let response = JSON . parse ( sessionStorage . getItem ( "youtubeResponse" ) ) ;
80+ console . log ( response ) ;
8081 var nextPageToken = response . nextPageToken ;
8182 var $youmaxLoadMoreDiv = $ ( '#youmax-load-more-div' ) ;
8283 youmaxColumns = youmax_global_options . youmaxColumns ;
@@ -104,19 +105,31 @@ var youmax_global_options = {};
104105 } ,
105106
106107 getUploads = function ( ) {
107- let channelId = youmax_global_options . youTubeChannelURL . split ( '/' ) . pop ( ) ;
108- var apiUploadURL = "https://www.googleapis.com/youtube/v3/search?key=" + youmax_global_options . apiKey + "&channelId=" + channelId + "&part=snippet,id&order=date&maxResults=" + youmax_global_options . maxResults ;
109-
110- $ . ajax ( {
111- url : apiUploadURL ,
112- type : "GET" ,
113- async : true ,
114- cache : true ,
115- dataType : 'jsonp' ,
116- success : function ( response ) { showUploads ( response ) ; } ,
117- error : function ( html ) { alert ( html ) ; } ,
118- beforeSend : setHeader
119- } ) ;
108+ let response = JSON . parse ( sessionStorage . getItem ( "youtubeResponse" ) ) ;
109+ if ( ! ( location . hostname === "localhost" || location . hostname === "127.0.0.1" ) ) {
110+ if ( ! response ) {
111+ console . log ( 'gonna call' ) ;
112+ let channelId = youmax_global_options . youTubeChannelURL . split ( '/' ) . pop ( ) ;
113+ var apiUploadURL = "https://www.googleapis.com/youtube/v3/search?key=" + youmax_global_options . apiKey + "&channelId=" + channelId + "&part=snippet,id&order=date&maxResults=" + youmax_global_options . maxResults ;
114+
115+ $ . ajax ( {
116+ url : apiUploadURL ,
117+ type : "GET" ,
118+ async : true ,
119+ cache : true ,
120+ dataType : 'jsonp' ,
121+ success : function ( response ) {
122+ sessionStorage . setItem ( "youtubeResponse" , JSON . stringify ( response ) ) ;
123+ showUploads ( response ) ;
124+ } ,
125+ error : function ( html ) { alert ( html ) ; } ,
126+ beforeSend : setHeader
127+ } ) ;
128+ } else {
129+ showUploads ( ) ;
130+ }
131+ }
132+
120133 } ,
121134
122135 $ . fn . youmax = function ( options ) {
0 commit comments