Created
September 8, 2016 10:06
-
-
Save nielsnuebel/f27ee60a315f01574f8258a574afa219 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Restart GIFs (doesn't work in Firefox) | |
| if( /\.gif/i.test( backgroundImageURL ) ) { | |
| var searchstring = '.gif?currenttime='; | |
| var timestamp = Math.floor(Date.now() / 1000) | |
| var position = backgroundImageURL.indexOf(searchstring); | |
| if(position !== -1) { | |
| var oldtimestamp = backgroundImageURL.substr(position + searchstring.length, timestamp.length); | |
| backgroundImageURL = backgroundImageURL.replace(oldtimestamp,timestamp); | |
| } | |
| else { | |
| backgroundImageURL = backgroundImageURL.replace('.gif', searchstring + timestamp); | |
| } | |
| currentBackground.style.backgroundImage = backgroundImageURL; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment