mirror of
https://git.42l.fr/neil/sncf.git
synced 2024-05-03 14:33:10 +02:00
now refreshing the page when previous browser button is hit. fixes #29
This commit is contained in:
parent
ade36cf053
commit
b45e65d427
|
@ -1,11 +1,36 @@
|
||||||
|
// on clicking Previous button in browser, reset the page
|
||||||
|
// needed to get another CSRF token and remove the spinning wheel
|
||||||
|
window.onpageshow = function() {
|
||||||
|
if (performance.getEntriesByType("navigation")[0].type == "back_forward") {
|
||||||
|
location.reload(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let browse_forms_button = get('browse_forms_button');
|
||||||
|
let new_link_button = get('new_link_button');
|
||||||
|
|
||||||
// csrf_token is retrieved from server-side template
|
// csrf_token is retrieved from server-side template
|
||||||
document.getElementById('new_link_button').addEventListener('click', function () {
|
new_link_button.addEventListener('click', function() {
|
||||||
new_link(csrf_token);
|
get("csrf_token").value = csrf_token;
|
||||||
|
get("new_link").submit();
|
||||||
|
hideButtonsAndSpin();
|
||||||
});
|
});
|
||||||
|
|
||||||
function new_link(csrf) {
|
if (browse_forms_button != undefined) {
|
||||||
document.getElementById("csrf_token").value = csrf;
|
browse_forms_button.addEventListener('click', function () {
|
||||||
document.getElementById('new_link').submit();
|
hideButtonsAndSpin();
|
||||||
document.getElementById('new_link_button').classList.add("hidden");
|
});
|
||||||
document.getElementById('loading_ring').classList.remove("hidden");
|
}
|
||||||
|
|
||||||
|
function hideButtonsAndSpin() {
|
||||||
|
new_link_button.classList.add("hidden");
|
||||||
|
// hide the access forms button if it exists
|
||||||
|
if (browse_forms_button != undefined) {
|
||||||
|
browse_forms_button.classList.add("hidden");
|
||||||
|
}
|
||||||
|
get('loading_ring').classList.remove("hidden");
|
||||||
|
}
|
||||||
|
|
||||||
|
function get(elemId) {
|
||||||
|
return document.getElementById(elemId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
<a class="ncstyle-button margin-bottom">{{ "index_nojs"|tr(lang) }}</a>
|
<a class="ncstyle-button margin-bottom">{{ "index_nojs"|tr(lang) }}</a>
|
||||||
</noscript>
|
</noscript>
|
||||||
{% if sncf_admin_token.is_some() %}
|
{% if sncf_admin_token.is_some() %}
|
||||||
<a href="/admin/{{ sncf_admin_token.as_ref().unwrap() }}" class="ncstyle-button margin-bottom">{{ "index_continueform_button"|tr(lang) }}</a>
|
<a id="browse_forms_button" href="/admin/{{ sncf_admin_token.as_ref().unwrap() }}" class="ncstyle-button margin-bottom">{{ "index_continueform_button"|tr(lang) }}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<form id="new_link" action="/link" method="post">
|
<form id="new_link" action="/link" method="post">
|
||||||
<input id="csrf_token" name="csrf_token" type="text" class="hidden">
|
<input id="csrf_token" name="csrf_token" type="text" class="hidden">
|
||||||
|
|
Loading…
Reference in a new issue