Skip to content

Instantly share code, notes, and snippets.

@pgeraghty
Last active August 29, 2015 14:16
Show Gist options
  • Save pgeraghty/7c2b27d3c1dc30757f99 to your computer and use it in GitHub Desktop.
Save pgeraghty/7c2b27d3c1dc30757f99 to your computer and use it in GitHub Desktop.
W2V example script - Global Forest Watch
// W2V script intended for http://www.globalforestwatch.org/map/3/15.00/27.00/ALL/grayscale/loss,forestgain?begin=2001-01-01&end=2013-01-01&threshold=30
w2v.info("Injecting polyfill");
// Inject W2V polyfill so that this script will run in normal browsers without errors
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)){ return; }
js = d.createElement(s); js.id = id;
js.onload = function(){
// remote script has loaded
};
js.src = "//w2v-docs.inherentvalue.com/assets/w2v-polyfill-1f99abb481100e0b8b10057bae7a8a2c.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'w2v-polyfill'));
// Adjust UI for W2V and start/stop capture
w2v.info("Adding jQuery init callback");
(function($){
w2v.info("Clicking accept");
$('.accept_btn').click();
})(jQuery);
w2v.inject("https://gist.githubusercontent.com/pgeraghty/7c2b27d3c1dc30757f99/raw/8485c68dfd0baddd853d8c6eeb9089a57c80ac21/gfw2.js");
(function($){
setTimeout(function() {
w2v.info("Timeout 1");
// Hide widgets
$('.widget-box .visible').click();
$('.widget-box .visible, #footerToggle, #zoom_controls, #headerView .layout-header-top').hide();
}, 1000);
setTimeout(function() {
w2v.info("Timeout 2");
// Start video capture
w2v.start();
// Start animation
$('.timeline-year .play').click();
}, 3000);
setTimeout(function() {
w2v.info("Timeout 3");
// Finish video capture
w2v.finish();
}, 10000);
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment