@@ -19,11 +19,11 @@ Module.register("compliments", {
1919 afternoonStartTime : 12 ,
2020 afternoonEndTime : 17 ,
2121 random : true ,
22- specialDayUnique : false ,
22+ specialDayUnique : false
2323 } ,
24- urlSuffix :"" ,
25- compliments_new :null ,
26- refreshMinimumDelay :15 * 60 * 60 * 1000 , // 15 minutes
24+ urlSuffix : "" ,
25+ compliments_new : null ,
26+ refreshMinimumDelay : 15 * 60 * 60 * 1000 , // 15 minutes
2727 lastIndexUsed : - 1 ,
2828 // Set currentweather from module
2929 currentWeatherType : "" ,
@@ -45,16 +45,15 @@ Module.register("compliments", {
4545 const response = await this . loadComplimentFile ( ) ;
4646 this . config . compliments = JSON . parse ( response ) ;
4747 this . updateDom ( ) ;
48- if ( this . config . remoteFileRefreshInterval !== 0 ) {
49- if ( ( this . config . remoteFileRefreshInterval >= this . refreshMinimumDelay ) || window . mmTestMode == ' true' ) {
48+ if ( this . config . remoteFileRefreshInterval !== 0 ) {
49+ if ( ( this . config . remoteFileRefreshInterval >= this . refreshMinimumDelay ) || window . mmTestMode === " true" ) {
5050 setInterval ( async ( ) => {
51- const response = await this . loadComplimentFile ( ) ;
52- this . compliments_new = JSON . parse ( response ) ;
53- } ,
54- this . config . remoteFileRefreshInterval
55- )
51+ const response = await this . loadComplimentFile ( ) ;
52+ this . compliments_new = JSON . parse ( response ) ;
53+ } ,
54+ this . config . remoteFileRefreshInterval ) ;
5655 } else {
57- Log . error ( this . name + " remoteFileRefreshInterval less than minimum" )
56+ Log . error ( ` ${ this . name } remoteFileRefreshInterval less than minimum` ) ;
5857 }
5958 }
6059 }
@@ -205,10 +204,9 @@ Module.register("compliments", {
205204 // we need to force the server to not give us the cached result
206205 // create an extra property (ignored by the server handler) just so the url string is different
207206 // that will never be the same, using the ms value of date
208- if ( this . config . remoteFileRefreshInterval != 0 )
209- this . urlSuffix = "?dummy=" + Date . now ( )
207+ if ( this . config . remoteFileRefreshInterval !== 0 ) this . urlSuffix = `?dummy=${ Date . now ( ) } ` ;
210208 //
211- const response = await fetch ( url + this . urlSuffix ) ;
209+ const response = await fetch ( url + this . urlSuffix ) ;
212210 return await response . text ( ) ;
213211 } ,
214212
@@ -261,23 +259,23 @@ Module.register("compliments", {
261259 }
262260 // if a new set of compliments was loaded from the refresh task
263261 // we do this here to make sure no other function is using the compliments list
264- if ( this . compliments_new ) {
262+ if ( this . compliments_new ) {
265263 // use them
266- if ( JSON . stringify ( this . config . compliments ) !== JSON . stringify ( this . compliments_new ) ) {
264+ if ( JSON . stringify ( this . config . compliments ) !== JSON . stringify ( this . compliments_new ) ) {
267265 // only reset if the contents changes
268- this . config . compliments = this . compliments_new
266+ this . config . compliments = this . compliments_new ;
269267 // reset the index
270268 this . lastIndexUsed = - 1 ;
271269 }
272270 // clear new file list so we don't waste cycles comparing between refreshes
273- this . compliments_new = null
271+ this . compliments_new = null ;
274272 }
275273 // only in test mode
276- if ( window . mmTestMode === ' true' ) {
274+ if ( window . mmTestMode === " true" ) {
277275 // check for (undocumented) remoteFile2 to test new file load
278- if ( this . config . remoteFile2 !== null && this . config . remoteFileRefreshInterval !== 0 ) {
276+ if ( this . config . remoteFile2 !== null && this . config . remoteFileRefreshInterval !== 0 ) {
279277 // switch the file so that next time it will be loaded from a changed file
280- this . config . remoteFile = this . config . remoteFile2
278+ this . config . remoteFile = this . config . remoteFile2 ;
281279 }
282280 }
283281 return wrapper ;
0 commit comments