Skip to content

Instantly share code, notes, and snippets.

@wuputah
Created December 29, 2008 23:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wuputah/41432 to your computer and use it in GitHub Desktop.
Save wuputah/41432 to your computer and use it in GitHub Desktop.
// invokes +callback+ on elements found by +selector+ that have an href property value
// equal to the current page (pathname). It is recommended to use a selector that selects
// anchor (a) elements.
function currentPage(selector, callback) {
$$(selector).each(function(e) {
if (e.href == document.URL) {
callback.call(null, e);
}
})
}
// mark current nav item as selected. This is redundant for the navigation implemented
// in the app, but not for a snippet.
Event.onReady(function() {
currentPage('#storyNavColumn ol a', function(e) {
e.addClassName('leftNavSelected');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment