Last active
December 22, 2015 11:18
-
-
Save pirxpilot/6464142 to your computer and use it in GitHub Desktop.
appstrio leaderboard snippets without jQuery
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
// 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