Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
54c6336e22 | ||
|
|
7da888aa09 | ||
|
|
07d98bf11d | ||
|
|
4584ba0143 | ||
|
|
6feac7ef2e | ||
|
|
5efb93ea68 |
@@ -20,5 +20,5 @@ from django.http import JsonResponse
|
|||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
# path('api/', include('api.urls')),
|
# path('api/', include('api.urls')),
|
||||||
path('', include('ui.urls')),
|
path('', include('ui.urls')),
|
||||||
path('admin/', admin.site.urls),
|
# path('admin/', admin.site.urls),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
html, body {
|
html, body {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
touch-action: manipulation;
|
||||||
}
|
}
|
||||||
|
|
||||||
.section, .container {
|
.section, .container {
|
||||||
|
|||||||
@@ -1,27 +1,12 @@
|
|||||||
function getCookie(name) {
|
const csrftoken = getCookie('csrftoken');
|
||||||
var cookieValue = null;
|
const button = document.getElementById("BUTTON");
|
||||||
if (document.cookie && document.cookie !== '') {
|
const count = document.getElementById("COUNT");
|
||||||
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");
|
|
||||||
|
|
||||||
|
// when button is clicked submit an empty post request
|
||||||
button.addEventListener("click", event => {
|
button.addEventListener("click", event => {
|
||||||
button.disabled = true;
|
button.disabled = true;
|
||||||
button.classList.add("is-loading");
|
button.classList.add("is-loading");
|
||||||
fetch('/button', {
|
fetch('/button/', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@@ -39,4 +24,5 @@ button.addEventListener("click", event => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// when the page is loaded automatically select the button
|
||||||
button.focus();
|
button.focus();
|
||||||
16
ui/static/ui/helper.js
Normal file
16
ui/static/ui/helper.js
Normal file
@@ -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;
|
||||||
|
}
|
||||||
@@ -7,10 +7,10 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block js %}
|
{% block js %}
|
||||||
|
<script src="{% static 'ui/helper.js' %}"></script>
|
||||||
<script src="{% static 'ui/button.js' %}"></script>
|
<script src="{% static 'ui/button.js' %}"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<section class="section">
|
<section class="section">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|||||||
@@ -2,5 +2,5 @@ from django.urls import path
|
|||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('button', views.button, name = 'button'),
|
path('button/', views.button, name = 'button'),
|
||||||
]
|
]
|
||||||
Reference in New Issue
Block a user