js: wrap CSRF javascript in jQuery(function(){})

Also remove the unnecessary `csrftoken` variable and use the `getCookie`
function directly.