Skip to content

Instantly share code, notes, and snippets.

@pirxpilot
Last active December 22, 2015 11:18
Show Gist options
  • Save pirxpilot/6464142 to your computer and use it in GitHub Desktop.
Save pirxpilot/6464142 to your computer and use it in GitHub Desktop.
appstrio leaderboard snippets without jQuery
// before - with jQuery
$(document).ready(function(){
$('.ad').click(function(e){
e.stopPropagation();
e.preventDefault();
var url, chromeId, isDummy;
url = $(this).attr('href');
chromeId = $(this).data('chromeid');
isDummy = $(this).data('isdummy');
goTo(url, chromeId, isDummy);
});
});
// after - without jQuery
document.addEventListener("DOMContentLoaded", function() {
function onclick(e) {
e.stopPropagation();
e.preventDefault();
var url, chromeId, isDummy;
url = e.currentTarget.getAttribute('href');
chromeId = e.currentTarget.dataset.chromeid;
isDummy = parseInt(e.currentTarget.dataset.isdummy, 10);
goTo(url, chromeId, isDummy);
}
var i, links = document.querySelectorAll('.ad');
for (i = 0; i < links.length; ++i) {
links[i].addEventListener('click', onclick);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment