@@ -135,70 +135,77 @@ Module.register("MMM-GooglePhotos", {
135135 this . needMorePicsFlag = true ;
136136 }
137137 if ( this . needMorePicsFlag ) {
138- this . sendSocketNotification ( "NEED_MORE_PICS" , [ ] ) ;
138+ setTimeout ( ( ) => {
139+ this . sendSocketNotification ( "NEED_MORE_PICS" , [ ] ) ;
140+ } , 2000 ) ;
139141 }
140142 } ,
141143
142144 ready : function ( url , target ) {
143145 let hidden = document . createElement ( "img" ) ;
146+ const _this = this ;
144147 hidden . onerror = ( event , source , lineno , colno , error ) => {
145148 const errObj = { url, event, source, lineno, colno, error } ;
146149 this . sendSocketNotification ( "IMAGE_LOAD_FAIL" , errObj ) ;
147150 } ;
148151 hidden . onload = ( ) => {
149- let back = document . getElementById ( "GPHOTO_BACK" ) ;
150- let current = document . getElementById ( "GPHOTO_CURRENT" ) ;
151- current . textContent = "" ;
152- //current.classList.remove("animated")
153- // let dom = document.getElementById("GPHOTO");
154- back . style . backgroundImage = `url(/sitelet?url=https%3A%2F%2Fgithub.com%2Fhermanho%2FMMM-GooglePhotos%2Fcommit%2F%253Cspan%2520class%3Dpl-s1%253E%253Cspan%2520class%3Dpl-kos%253E%24%257B%253C%2Fspan%253E%253Cspan%2520class%3Dpl-s1%253Eurl%253C%2Fspan%253E%253Cspan%2520class%3Dpl-kos%253E%257D%253C%2Fspan%253E%253C%2Fspan%253E)` ;
155- current . style . backgroundImage = `url(/sitelet?url=https%3A%2F%2Fgithub.com%2Fhermanho%2FMMM-GooglePhotos%2Fcommit%2F%253Cspan%2520class%3Dpl-s1%253E%253Cspan%2520class%3Dpl-kos%253E%24%257B%253C%2Fspan%253E%253Cspan%2520class%3Dpl-s1%253Eurl%253C%2Fspan%253E%253Cspan%2520class%3Dpl-kos%253E%257D%253C%2Fspan%253E%253C%2Fspan%253E)` ;
156- current . classList . add ( "animated" ) ;
157- const info = document . getElementById ( "GPHOTO_INFO" ) ;
158- const album = Array . isArray ( this . albums ) ? this . albums . find ( ( a ) => a . id === target . _albumId ) : { id : - 1 , title : '' } ;
159- if ( this . config . autoInfoPosition ) {
160- let op = ( album , target ) => {
161- let now = new Date ( ) ;
162- let q = Math . floor ( now . getMinutes ( ) / 15 ) ;
163- let r = [
164- [ 0 , "none" , "none" , 0 ] ,
165- [ "none" , "none" , 0 , 0 ] ,
166- [ "none" , 0 , 0 , "none" ] ,
167- [ 0 , 0 , "none" , "none" ] ,
168- ] ;
169- return r [ q ] ;
170- } ;
171- if ( typeof this . config . autoInfoPosition === "function" ) {
172- op = this . config . autoInfoPosition ;
173- }
174- const [ top , left , bottom , right ] = op ( album , target ) ;
175- info . style . setProperty ( "--top" , top ) ;
176- info . style . setProperty ( "--left" , left ) ;
177- info . style . setProperty ( "--bottom" , bottom ) ;
178- info . style . setProperty ( "--right" , right ) ;
179- }
180- info . innerHTML = "" ;
181- let albumCover = document . createElement ( "div" ) ;
182- albumCover . classList . add ( "albumCover" ) ;
183- albumCover . style . backgroundImage = `url(/sitelet?url=https%3A%2F%2Fgithub.com%2Fhermanho%2FMMM-GooglePhotos%2Fcommit%2Fmodules%2FMMM-GooglePhotos%2Fcache%2F%253Cspan%2520class%3Dpl-s1%253E%253Cspan%2520class%3Dpl-kos%253E%24%257B%253C%2Fspan%253E%253Cspan%2520class%3Dpl-s1%253Ealbum%253C%2Fspan%253E%253Cspan%2520class%3Dpl-kos%253E.%253C%2Fspan%253E%253Cspan%2520class%3Dpl-c1%253Eid%253C%2Fspan%253E%253Cspan%2520class%3Dpl-kos%253E%257D%253C%2Fspan%253E%253C%2Fspan%253E)` ;
184- let albumTitle = document . createElement ( "div" ) ;
185- albumTitle . classList . add ( "albumTitle" ) ;
186- albumTitle . innerHTML = album . title ;
187- let photoTime = document . createElement ( "div" ) ;
188- photoTime . classList . add ( "photoTime" ) ;
189- photoTime . innerHTML = this . config . timeFormat === "relative" ? moment ( target . mediaMetadata . creationTime ) . fromNow ( ) : moment ( target . mediaMetadata . creationTime ) . format ( this . config . timeFormat ) ;
190- let infoText = document . createElement ( "div" ) ;
191- infoText . classList . add ( "infoText" ) ;
192-
193- info . appendChild ( albumCover ) ;
194- infoText . appendChild ( albumTitle ) ;
195- infoText . appendChild ( photoTime ) ;
196- info . appendChild ( infoText ) ;
197- this . sendSocketNotification ( "IMAGE_LOADED" , { id : target . id , index : this . index } ) ;
152+ _this . render ( url , target ) ;
198153 } ;
199154 hidden . src = url ;
200155 } ,
201156
157+ render : function ( url , target ) {
158+ let back = document . getElementById ( "GPHOTO_BACK" ) ;
159+ let current = document . getElementById ( "GPHOTO_CURRENT" ) ;
160+ current . textContent = "" ;
161+ //current.classList.remove("animated")
162+ // let dom = document.getElementById("GPHOTO");
163+ back . style . backgroundImage = `url(/sitelet?url=https%3A%2F%2Fgithub.com%2Fhermanho%2FMMM-GooglePhotos%2Fcommit%2F%253Cspan%2520class%3Dpl-s1%253E%253Cspan%2520class%3Dpl-kos%253E%24%257B%253C%2Fspan%253E%253Cspan%2520class%3Dpl-s1%253Eurl%253C%2Fspan%253E%253Cspan%2520class%3Dpl-kos%253E%257D%253C%2Fspan%253E%253C%2Fspan%253E)` ;
164+ current . style . backgroundImage = `url(/sitelet?url=https%3A%2F%2Fgithub.com%2Fhermanho%2FMMM-GooglePhotos%2Fcommit%2F%253Cspan%2520class%3Dpl-s1%253E%253Cspan%2520class%3Dpl-kos%253E%24%257B%253C%2Fspan%253E%253Cspan%2520class%3Dpl-s1%253Eurl%253C%2Fspan%253E%253Cspan%2520class%3Dpl-kos%253E%257D%253C%2Fspan%253E%253C%2Fspan%253E)` ;
165+ current . classList . add ( "animated" ) ;
166+ const info = document . getElementById ( "GPHOTO_INFO" ) ;
167+ const album = Array . isArray ( this . albums ) ? this . albums . find ( ( a ) => a . id === target . _albumId ) : { id : - 1 , title : '' } ;
168+ if ( this . config . autoInfoPosition ) {
169+ let op = ( album , target ) => {
170+ let now = new Date ( ) ;
171+ let q = Math . floor ( now . getMinutes ( ) / 15 ) ;
172+ let r = [
173+ [ 0 , "none" , "none" , 0 ] ,
174+ [ "none" , "none" , 0 , 0 ] ,
175+ [ "none" , 0 , 0 , "none" ] ,
176+ [ 0 , 0 , "none" , "none" ] ,
177+ ] ;
178+ return r [ q ] ;
179+ } ;
180+ if ( typeof this . config . autoInfoPosition === "function" ) {
181+ op = this . config . autoInfoPosition ;
182+ }
183+ const [ top , left , bottom , right ] = op ( album , target ) ;
184+ info . style . setProperty ( "--top" , top ) ;
185+ info . style . setProperty ( "--left" , left ) ;
186+ info . style . setProperty ( "--bottom" , bottom ) ;
187+ info . style . setProperty ( "--right" , right ) ;
188+ }
189+ info . innerHTML = "" ;
190+ let albumCover = document . createElement ( "div" ) ;
191+ albumCover . classList . add ( "albumCover" ) ;
192+ albumCover . style . backgroundImage = `url(/sitelet?url=https%3A%2F%2Fgithub.com%2Fhermanho%2FMMM-GooglePhotos%2Fcommit%2Fmodules%2FMMM-GooglePhotos%2Fcache%2F%253Cspan%2520class%3Dpl-s1%253E%253Cspan%2520class%3Dpl-kos%253E%24%257B%253C%2Fspan%253E%253Cspan%2520class%3Dpl-s1%253Ealbum%253C%2Fspan%253E%253Cspan%2520class%3Dpl-kos%253E.%253C%2Fspan%253E%253Cspan%2520class%3Dpl-c1%253Eid%253C%2Fspan%253E%253Cspan%2520class%3Dpl-kos%253E%257D%253C%2Fspan%253E%253C%2Fspan%253E)` ;
193+ let albumTitle = document . createElement ( "div" ) ;
194+ albumTitle . classList . add ( "albumTitle" ) ;
195+ albumTitle . innerHTML = album . title ;
196+ let photoTime = document . createElement ( "div" ) ;
197+ photoTime . classList . add ( "photoTime" ) ;
198+ photoTime . innerHTML = this . config . timeFormat === "relative" ? moment ( target . mediaMetadata . creationTime ) . fromNow ( ) : moment ( target . mediaMetadata . creationTime ) . format ( this . config . timeFormat ) ;
199+ let infoText = document . createElement ( "div" ) ;
200+ infoText . classList . add ( "infoText" ) ;
201+
202+ info . appendChild ( albumCover ) ;
203+ infoText . appendChild ( albumTitle ) ;
204+ infoText . appendChild ( photoTime ) ;
205+ info . appendChild ( infoText ) ;
206+ this . sendSocketNotification ( "IMAGE_LOADED" , { id : target . id , index : this . index } ) ;
207+ } ,
208+
202209 getDom : function ( ) {
203210 let wrapper = document . createElement ( "div" ) ;
204211 wrapper . id = "GPHOTO" ;
0 commit comments