62 lines
1.3 KiB
HTML
62 lines
1.3 KiB
HTML
{% extends 'base.html' %}
|
|
{% load static %}
|
|
|
|
{% block title %}
|
|
| Results
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
|
|
{% if user.is_authenticated %}
|
|
|
|
<head>
|
|
<!--<link rel="stylesheet" href="https://pyscript.net/latest/pyscript.css" />
|
|
<script defer src="https://pyscript.net/latest/pyscript.js"></script>-->
|
|
</head>
|
|
|
|
<form>
|
|
<input type = "button" value = "Team Number" onclick = "teams_input();" />
|
|
</form>
|
|
|
|
|
|
<script>
|
|
var CSRF_TOKEN = '{{ csrf_token}}';
|
|
var arr = [];
|
|
|
|
function teams_input() {
|
|
var a = prompt ("Enter the Total Team Number: ", "Type Here...");
|
|
if (a != null) {
|
|
while(arr.length < a){
|
|
var r = Math.floor(Math.random() * a) + 1;
|
|
if(arr.indexOf(r) === -1) arr.push(r);
|
|
}
|
|
console.log(arr);
|
|
team_data(arr);
|
|
}
|
|
}
|
|
|
|
function team_data(arr) {
|
|
$.ajax({
|
|
url: '/results/append_data',
|
|
data: {'a': arr, 'csrfmiddlewaretoken':'{{csrf_token}}'},
|
|
type: 'POST',
|
|
cache:'false',
|
|
success: function(data) {
|
|
alert(data);
|
|
},
|
|
error: function(data) {
|
|
alert('error; '+ eval(error));
|
|
}
|
|
})
|
|
}
|
|
|
|
</script>
|
|
|
|
{% include 'form.html' %}
|
|
|
|
{% else %}
|
|
<p class="alert alert-danger">You are not logged in</p>
|
|
<a class='btn btn-outline-success text-dark' href="{% url 'login' %}">Log In</a>
|
|
{% endif %}
|
|
|
|
{% endblock %} |