diff --git a/ui/static/ui/button.js b/ui/static/ui/button.js
index 478b5b3..af40ead 100644
--- a/ui/static/ui/button.js
+++ b/ui/static/ui/button.js
@@ -1,23 +1,8 @@
-function getCookie(name) {
- var cookieValue = null;
- if (document.cookie && document.cookie !== '') {
- var cookies = document.cookie.split(';');
- for (var i = 0; i < cookies.length; i++) {
- var cookie = cookies[i].trim();
- // Does this cookie string begin with the name we want?
- if (cookie.substring(0, name.length + 1) === (name + '=')) {
- cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
- break;
- }
- }
- }
- return cookieValue;
-}
-
-var csrftoken = getCookie('csrftoken');
-var button = document.getElementById("BUTTON");
-var count = document.getElementById("COUNT");
+const csrftoken = getCookie('csrftoken');
+const button = document.getElementById("BUTTON");
+const count = document.getElementById("COUNT");
+// when button is clicked submit an empty post request
button.addEventListener("click", event => {
button.disabled = true;
button.classList.add("is-loading");
@@ -39,4 +24,5 @@ button.addEventListener("click", event => {
});
});
+// when the page is loaded automatically select the button
button.focus();
\ No newline at end of file
diff --git a/ui/static/ui/helper.js b/ui/static/ui/helper.js
new file mode 100644
index 0000000..30dc7a5
--- /dev/null
+++ b/ui/static/ui/helper.js
@@ -0,0 +1,16 @@
+// get cookies when fetching with django
+function getCookie(name) {
+ var cookieValue = null;
+ if (document.cookie && document.cookie !== '') {
+ var cookies = document.cookie.split(';');
+ for (var i = 0; i < cookies.length; i++) {
+ var cookie = cookies[i].trim();
+ // Does this cookie string begin with the name we want?
+ if (cookie.substring(0, name.length + 1) === (name + '=')) {
+ cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
+ break;
+ }
+ }
+ }
+ return cookieValue;
+}
\ No newline at end of file
diff --git a/ui/templates/ui/button.html b/ui/templates/ui/button.html
index 163d3f0..82056d7 100644
--- a/ui/templates/ui/button.html
+++ b/ui/templates/ui/button.html
@@ -7,10 +7,10 @@
{% endblock %}
{% block js %}
+
{% endblock %}
-
{% block body %}