Skip to content

Instantly share code, notes, and snippets.

@Mottie
Created April 23, 2011 14:58
Show Gist options
  • Save Mottie/938670 to your computer and use it in GitHub Desktop.
Save Mottie/938670 to your computer and use it in GitHub Desktop.
Cycle Through Visual Event Bookmarklet Layers
// Code I paste into the Firebug Console after I run the Visual Event
// bookmarklet (http://www.sprymedia.co.uk/article/Visual+Event)
// so I can cycle through the layers - Use arrow keys to cycle
var veColors = [ 'black', 'orange', 'purple', 'green', 'blue', 'yellow', 'red' ],
veColorLength= veColors.length - 1,
veLayerIndex = 0;
function showVeLayer(nxt){
veLayerIndex += (nxt) ? 1 : -1;
if (veLayerIndex > veColorLength) { veLayerIndex = 0; }
if (veLayerIndex < 0) { veLayerIndex = veColorLength; }
var veLayer = $('.Event_bg_' + veColors[veLayerIndex]);
if (veLayer.length === 0 ) { showVeLayer(nxt); return; }
$('.Event_bg_' + veColors.join(', .Event_bg_')).hide();
veLayer.show();
};
$(document).keyup(function(e){
switch(e.which){
case 39: case 40: // right/down
showVeLayer(true);
break;
case 37: case 38: // left/up
showVeLayer();
break;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment