45 lines
1.3 KiB
HTML
45 lines
1.3 KiB
HTML
{% extends "Base.html" %}
|
|
|
|
{% block main-content %}
|
|
<p>Hoi {{ user.first_name }}!</p>
|
|
{% if user.is_staff %}
|
|
<form action="{% url 'admin:index' %}">
|
|
<div class="field-row">
|
|
<label>Administratieve achterkant:</label>
|
|
<input type="submit" value="Admin" />
|
|
</div>
|
|
</form>
|
|
{% endif %}
|
|
<form method="post">
|
|
{% csrf_token %}
|
|
{% if backgrounds %}
|
|
<div class="field-row">
|
|
<label for="wallpaper">Wallpaper:</label>
|
|
<select id="background" name="background" onchange="this.form.submit()">
|
|
{% for background in backgrounds %}
|
|
<option
|
|
value="{{background.id}}"
|
|
{% if background.id == currentBackground %} selected{% endif %}
|
|
>
|
|
{{background.name}}
|
|
</option>
|
|
{% endfor %}
|
|
</select>
|
|
<button id="wallpaper-reset" onclick="wallpaperChanged()">Reset</button>
|
|
</div>
|
|
{% endif %}
|
|
</form>
|
|
<script>
|
|
function wallpaperChanged() {
|
|
const expression = /^https?:\/\/.*\.(jpeg|jpg|png|gif)$/
|
|
const regex = new RegExp(expression)
|
|
val = document.getElementById("wallpaper").value
|
|
if(regex.test(val)) {
|
|
console.log(val)
|
|
localStorage.setItem("wallpaper", val);
|
|
setWallpaper()
|
|
}
|
|
}
|
|
</script>
|
|
{% endblock %}
|