-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
more options for caching, prettier frontend, refresh all link,
safe cache as .png in git-like folders
- Loading branch information
1 parent
b087611
commit 145dcab
Showing
10 changed files
with
95 additions
and
92 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
var review = require('..') | ||
|
||
review() | ||
.title('Cached Review') | ||
.sites({ localhost : 'http://localhost:3000/' }) | ||
.resolutions(['1280x1024', '800x600']) | ||
.cache(5) | ||
.title('Review') | ||
.sites({ 'github' : 'https://github.com/' }) | ||
.resolutions(['1440x900', '1200x800', '640x480']) | ||
.cache({ | ||
dir : __dirname + '/cache/', | ||
expires : 86400 | ||
}) | ||
.listen(5000, function () { | ||
console.log('-> Review on port 5000') | ||
}) |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,49 @@ | ||
var images = Array.prototype.slice.apply(document.querySelectorAll('img')) | ||
var info = document.querySelector('#info') | ||
var loading = document.querySelector('#loading') | ||
|
||
var loaded = 0 | ||
var reloads = 0 | ||
var allLoaded = false | ||
var links = Array.prototype.slice.apply(document.querySelectorAll('.refresh')) | ||
var refreshAll = document.querySelector('.refresh-all') | ||
|
||
/** | ||
* loading indicator | ||
* refresh all | ||
*/ | ||
|
||
var iv = setInterval(function () { | ||
if (loaded == images.length) return clearInterval(iv) | ||
|
||
loading.innerHTML += '.' | ||
if (loading.innerHTML == '....') loading.innerHTML = '' | ||
}, 500) | ||
|
||
info.innerHTML = '0 / ' + images.length + ' loaded' | ||
refreshAll.addEventListener('click', function () { | ||
var msg = "You're about to refresh " + images.length + " snapshots. Are you sure?" | ||
if (images.length > 10 && !confirm(msg)) return | ||
images.forEach(refresh) | ||
}) | ||
|
||
/** | ||
* reload | ||
* refresh | ||
*/ | ||
|
||
images.forEach(function (image) { | ||
image.addEventListener('click', function () { | ||
reloads++ | ||
|
||
// show gray placeholder in same dimensions | ||
var oldSrc = image.src + '' | ||
var oldHeight = image.height | ||
|
||
image.src = '/empty.jpg' | ||
image.style.height = oldHeight + 'px' | ||
|
||
setTimeout(function () { | ||
// force reload | ||
var newSrc = oldSrc | ||
newSrc += newSrc.match(/\?/) | ||
? '&reload' | ||
: '?reload' | ||
|
||
image.src = newSrc | ||
|
||
function onLoad () { | ||
image.style.height = 'auto' | ||
image.removeEventListener('load', onLoad) | ||
} | ||
|
||
image.addEventListener('load', onLoad) | ||
}, 500) | ||
|
||
links.forEach(function (link) { | ||
link.addEventListener('click', function () { | ||
refresh(link.parentNode.nextSibling.childNodes[0]) | ||
}) | ||
}) | ||
|
||
/** | ||
* loading status | ||
*/ | ||
|
||
images.forEach(function (image) { | ||
image.addEventListener('load', function () { | ||
if (allLoaded) return | ||
loaded++ | ||
info.innerHTML = (loaded-reloads) + ' / ' + images.length + ' loaded' | ||
if ((loaded-reloads) == images.length) { | ||
allLoaded = true | ||
info.innerHTML = 'all loaded' | ||
loading.innerHTML = '' | ||
function refresh (image) { | ||
// show gray placeholder in same dimensions | ||
var oldSrc = image.src + '' | ||
var oldHeight = image.height | ||
|
||
image.src = '/empty.jpg' | ||
image.style.height = oldHeight + 'px' | ||
|
||
setTimeout(function () { | ||
// force refresh | ||
var newSrc = oldSrc | ||
newSrc += newSrc.match(/\?/) | ||
? '&refresh' | ||
: '?refresh' | ||
|
||
image.src = newSrc | ||
|
||
function onLoad () { | ||
image.style.height = 'auto' | ||
image.removeEventListener('load', onLoad) | ||
} | ||
}) | ||
}) | ||
|
||
image.addEventListener('load', onLoad) | ||
}, 500) | ||
} |
This file contains 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
This file contains 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