Looking to convert a jQuery snippet to javascript. Totally hitting a wall with this.
Are there any automated tools for doing this?
The reason we're converting this is because the code is used as part of a product that we're planning on injecting in the future and we can't guarantee that the site has the appropriate (or any) version of jQuery running.
EDIT: The reason we can't control the use of jQuery is that the customer will be copying and pasting this code themselves. It's highly likely that they will be non-technical and as such not willing/able to setup the appropriate version of jQuery
This is the jQuery code we're using now:
$(function() {
$.getJSON('http://api.seedthechange.org/get/?method=getCount&str=suitjamas&jsoncallback=?', function(data) {
treecount = csn(data[0]);
$('span.SeedTheChangeCount').text(treecount);
});
})
function csn(val){
// convert int to comma separated number (1000 -> 1,000)
while (/(\d+)(\d{3})/.test(val.toString())){
val = val.toString().replace(/(\d+)(\d{3})/, '$1'+','+'$2');
}
return val;
}
Thanks in advance for any help or tips.