mirror of
https://git.42l.fr/neil/sncf.git
synced 2024-05-04 06:53:12 +02:00
separate JS and HTML, fixes #32
This commit is contained in:
parent
162cdad7fe
commit
05a15b1680
11
templates/assets/index.js
Normal file
11
templates/assets/index.js
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
// csrf_token is retrieved from server-side template
|
||||||
|
document.getElementById('new_link_button').addEventListener('click', function () {
|
||||||
|
new_link(csrf_token);
|
||||||
|
});
|
||||||
|
|
||||||
|
function new_link(csrf) {
|
||||||
|
document.getElementById("csrf_token").value = csrf;
|
||||||
|
document.getElementById('new_link').submit();
|
||||||
|
document.getElementById('new_link_button').classList.add("hidden");
|
||||||
|
document.getElementById('loading_ring').classList.remove("hidden");
|
||||||
|
}
|
|
@ -10,26 +10,8 @@
|
||||||
<link rel="stylesheet" href="/assets/index.css?v=1.2" />
|
<link rel="stylesheet" href="/assets/index.css?v=1.2" />
|
||||||
<link rel="stylesheet" href="/assets/cloud.css?v=1.0" />
|
<link rel="stylesheet" href="/assets/cloud.css?v=1.0" />
|
||||||
<noscript><style> .jsonly { display: none } </style></noscript>
|
<noscript><style> .jsonly { display: none } </style></noscript>
|
||||||
<script>
|
<script>const csrf_token = "{{ csrf_token }}";</script>
|
||||||
/* junk javascript with basic spambot protection features.
|
<script src="/assets/index.js" defer></script>
|
||||||
Drunk indentation is vim's fault.
|
|
||||||
unsatisifed? Please make a PR. : ) */
|
|
||||||
window.onload = function() {
|
|
||||||
// retrieved from server-side template
|
|
||||||
let csrf_token = "{{ csrf_token }}";
|
|
||||||
document.getElementById('new_link_button').addEventListener('click', function () {
|
|
||||||
new_link(csrf_token);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function new_link(csrf) {
|
|
||||||
document.getElementById("csrf_token").value = csrf;
|
|
||||||
document.getElementById('new_link').submit();
|
|
||||||
document.getElementById('new_link_button').classList.add("hidden");
|
|
||||||
document.getElementById('loading_ring').classList.remove("hidden");
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="flex page-heading fullheight">
|
<div class="flex page-heading fullheight">
|
||||||
|
|
Loading…
Reference in a new issue