parent
8e0c1ce08b
commit
25262fb5fe
34
public/static/js/mapguesser.js
Normal file
34
public/static/js/mapguesser.js
Normal file
@ -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';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})();
|
@ -1,7 +1,9 @@
|
|||||||
<script>
|
<script>
|
||||||
const STATIC_ROOT = '<?= $_ENV['STATIC_ROOT'] ?>';
|
const STATIC_ROOT = '<?= $_ENV['STATIC_ROOT'] ?>';
|
||||||
const REVISION = '<?= REVISION ?>';
|
const REVISION = '<?= REVISION ?>';
|
||||||
|
const ANTI_CSRF_TOKEN = '<?= $_SESSION['anti_csrf_token'] ?>';
|
||||||
</script>
|
</script>
|
||||||
|
<script src="<?= $_ENV['STATIC_ROOT'] ?>/js/mapguesser.js?rev=<?= REVISION ?>"></script>
|
||||||
<?php if (isset($jsFiles)) : ?>
|
<?php if (isset($jsFiles)) : ?>
|
||||||
<?php foreach ($jsFiles as $jsFile) : ?>
|
<?php foreach ($jsFiles as $jsFile) : ?>
|
||||||
<?php
|
<?php
|
||||||
@ -12,18 +14,5 @@
|
|||||||
<script src="<?= $jsFile ?>"></script>
|
<script src="<?= $jsFile ?>"></script>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<script>
|
|
||||||
(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';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
Loading…
Reference in New Issue
Block a user