diff --git a/public/static/js/mapguesser.js b/public/static/js/mapguesser.js new file mode 100644 index 0000000..06cbc89 --- /dev/null +++ b/public/static/js/mapguesser.js @@ -0,0 +1,34 @@ +var MapGuesser = { + httpRequest: function (method, url, callback, data) { + var xhr = new XMLHttpRequest(); + + xhr.responseType = 'json'; + xhr.onload = callback; + + xhr.open(method, url, true); + + if (method === 'POST') { + if (typeof data === 'undefined') { + data = new FormData(); + } + + data.append('anti_csrf_token', ANTI_CSRF_TOKEN); + + xhr.send(data); + } else { + xhr.send(); + } + } +}; + +(function () { + var anchors = document.getElementsByTagName('a'); + for (var i = 0; i < anchors.length; i++) { + var a = anchors[i]; + if (a.href !== 'javascript:;' && a.target !== '_blank') { + a.onclick = function () { + document.getElementById('loading').style.visibility = 'visible'; + } + } + } +})(); diff --git a/views/templates/main_footer.php b/views/templates/main_footer.php index f1008bc..bb36eb7 100644 --- a/views/templates/main_footer.php +++ b/views/templates/main_footer.php @@ -1,7 +1,9 @@ + "> - \ No newline at end of file