just go for it
This commit is contained in:
@@ -25,7 +25,7 @@ function add_achievement(text) {
|
||||
button.addEventListener("click", event => {
|
||||
button.disabled = true;
|
||||
button.classList.add("is-loading");
|
||||
fetch('/button/', {
|
||||
fetch(button.dataset.action, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
html, body, .section, .container {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.container {
|
||||
overflow-y: hidden;
|
||||
}
|
||||
|
||||
.element::-webkit-scrollbar { width: 0 !important }
|
||||
.element { overflow: -moz-scrollbars-none; }
|
||||
.element { -ms-overflow-style: none; }
|
||||
|
||||
.hide-overflow {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.h-100 {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.w-100 {
|
||||
width: 100%;
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
// temp0.scrollIntoView({behavior: "smooth"});
|
||||
const scroll0 = document.getElementById("scroll-0");
|
||||
const scroll1 = document.getElementById("scroll-1");
|
||||
const scroll2 = document.getElementById("scroll-2");
|
||||
const scroll3 = document.getElementById("scroll-3");
|
||||
|
||||
window.addEventListener("scroll", function(event) {
|
||||
window.addEventListener("mouseup", event => {
|
||||
console.log("hello");
|
||||
});
|
||||
event.preventDefault();
|
||||
document.querySelector("html").classList.add("hide-overflow");
|
||||
if (scroll0.dataset.isScrolling != "true") {
|
||||
scroll0.dataset.isScrolling = 'true';
|
||||
|
||||
if (scroll1.dataset.seen != "true") {
|
||||
scroll1.dataset.seen = "true";
|
||||
scroll1.scrollIntoView({behavior: "smooth"});
|
||||
}
|
||||
else if (scroll2.dataset.seen != "true") {
|
||||
scroll2.dataset.seen = "true";
|
||||
scroll2.scrollIntoView({behavior: "smooth"});
|
||||
}
|
||||
else if (scroll3.dataset.seen != "true") {
|
||||
scroll3.dataset.seen = "true";
|
||||
scroll3.scrollIntoView({behavior: "smooth"});
|
||||
}
|
||||
else {
|
||||
scroll1.dataset.seen = "false";
|
||||
scroll2.dataset.seen = "false";
|
||||
scroll3.dataset.seen = "false";
|
||||
scroll0.scrollIntoView({behavior: "smooth"});
|
||||
}
|
||||
setTimeout(() => {
|
||||
scroll0.dataset.isScrolling = false;
|
||||
document.querySelector("html").classList.remove("hide-overflow");
|
||||
}, 1000)
|
||||
}
|
||||
});
|
||||
@@ -22,7 +22,7 @@
|
||||
<h1 class="title">
|
||||
The Button
|
||||
</h1>
|
||||
<button class="button is-danger" id="BUTTON">Press</button>
|
||||
<button class="button is-danger" id="BUTTON" data-action = "{% url 'button' %}">Press</button>
|
||||
</div>
|
||||
<div><br></div>
|
||||
<div>
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
{% extends 'ui/base.html' %}
|
||||
|
||||
{% load static %}
|
||||
|
||||
{% block css %}
|
||||
<link rel="stylesheet" href="{% static 'ui/smooth.css' %}">
|
||||
{% endblock %}
|
||||
|
||||
{% block js %}
|
||||
<script src="{% static 'ui/smooth.js' %}"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<div class="container">
|
||||
<div id="scroll-0" class="h-100 w-100">
|
||||
<h1 class="title">Hello There</h1>
|
||||
</div>
|
||||
|
||||
<div id="scroll-1" class="h-100 w-100">
|
||||
<h1 class="title">I'm an Apple Ad</h1>
|
||||
</div>
|
||||
|
||||
<div id="scroll-2" class="h-100 w-100">
|
||||
<h1 class="title">See me scroll</h1>
|
||||
</div>
|
||||
|
||||
<div id="scroll-3" class="h-100 w-100">
|
||||
<h1 class="title">You owe me $3,000 dollars for this</h1>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -2,6 +2,5 @@ from django.urls import path
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
path('button/', views.button, name = 'button'),
|
||||
path('smooth/', views.smooth, name = 'smooth'),
|
||||
path('', views.button, name = 'button'),
|
||||
]
|
||||
19
ui/views.py
19
ui/views.py
@@ -55,25 +55,18 @@ achievements = {
|
||||
def button(request):
|
||||
PRESSED = 'pressed'
|
||||
ACHIEVE = 'achievement'
|
||||
|
||||
try:
|
||||
request.session[PRESSED]
|
||||
except KeyError:
|
||||
request.session[PRESSED] = 0
|
||||
current = request.session.get(PRESSED, 0)
|
||||
request.session[PRESSED] = current + 1
|
||||
|
||||
if request.method == "POST":
|
||||
request.session[PRESSED] += 1
|
||||
response = {
|
||||
PRESSED: request.session[PRESSED],
|
||||
ACHIEVE: achievements.get(request.session[PRESSED])
|
||||
PRESSED: current,
|
||||
ACHIEVE: achievements.get(current)
|
||||
}
|
||||
return JsonResponse(response)
|
||||
|
||||
pressed = request.session[PRESSED]
|
||||
pressed = current
|
||||
response = {PRESSED: pressed}
|
||||
achieved = {k:v for k,v in achievements.items() if k <= pressed}
|
||||
response.update({ACHIEVE: achieved})
|
||||
return render(request, "ui/button.html", response)
|
||||
|
||||
def smooth(request):
|
||||
return render(request, "ui/smooth.html")
|
||||
return render(request, "ui/button.html", response)
|
||||
Reference in New Issue
Block a user