Skip to content
Snippets Groups Projects
Verified Commit 695ccc2d authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Move JS code to new files

parent a7d4036f
No related branches found
No related tags found
1 merge request!31Biscuit merge. Closes #53.
function updateDatepicker() {
if (!displayDateOnly) {
$("#date").val(formatDate(activeDate));
}
}
function update() {
console.log("Render new.");
updateDatepicker();
}
function loadNew() {
window.location.href = dest + formatDateForDjango(activeDate);
}
function onDateBeforeClick() {
if (activeDate.getDay() === 1) {
var minus = 3;
} else {
var minus = 1;
}
activeDate.setDate(activeDate.getDate() - minus);
update();
loadNew();
}
function onDateNextClick() {
if (activeDate.getDay() === 5) {
var plus = 3;
} else {
var plus = 1;
}
activeDate.setDate(activeDate.getDate() + plus);
update();
loadNew();
}
function onDateChanged() {
var str = $("#date").val();
var split = str.split(".")
activeDate = new Date(split[2], split[1] - 1, split[0]);
update();
loadNew();
}
$(document).ready(function () {
$("#date-before").click(onDateBeforeClick);
$("#date-next").click(onDateNextClick);
$("#date").change(onDateChanged);
update();
});
function goToCalendarWeek(cw, year) {
window.location.href = dest + year + "/" + cw;
}
function onCalendarWeekChanged(where) {
goToCalendarWeek($(where).val(), year);
}
$(document).ready(function () {
$("#calendar-week-1").change(function () {
onCalendarWeekChanged("#calendar-week-1");
});
$("#calendar-week-2").change(function () {
onCalendarWeekChanged("#calendar-week-2");
});
$("#calendar-week-3").change(function () {
onCalendarWeekChanged("#calendar-week-3");
});
});
{% load date_js static %} {% load date_js static %}
<script src="{% static "js/helper.js" %}"></script> <script type="text/javascript" src="{% static "js/helper.js" %}"></script>
<script type="text/javascript"> <script type="text/javascript">
function updateDatepicker() { var activeDate = new Date({{ day|date_unix }});
{% if not display_date_only %} var displayDateOnly = {% if display_date_only %}true{% else %}false{% endif %};
$("#date").val(formatDate(activeDate));
{% endif %}
}
function update() {
console.log("Render new.");
updateDatepicker();
}
function loadNew() {
window.location.href = dest + formatDateForDjango(activeDate);
}
function onDateBeforeClick() {
if (activeDate.getDay() === 1) {
var minus = 3;
} else {
var minus = 1;
}
activeDate.setDate(activeDate.getDate() - minus);
update();
loadNew();
}
function onDateNextClick() {
if (activeDate.getDay() === 5) {
var plus = 3;
} else {
var plus = 1;
}
activeDate.setDate(activeDate.getDate() + plus);
update();
loadNew();
}
function onDateChanged() {
var str = $("#date").val();
var split = str.split(".")
activeDate = new Date(split[2], split[1] - 1, split[0]);
update();
loadNew();
}
var activeDate = new Date({{ day|date_unix }});
$(document).ready(function () {
$("#date-before").click(onDateBeforeClick);
$("#date-next").click(onDateNextClick);
$("#date").change(onDateChanged);
update();
})
</script> </script>
<script type="text/javascript" src="{% static "js/chronos/date_select.js" %}"></script>
<div class="col s2" style="display: initial;"> <div class="col s2" style="display: initial;">
......
...@@ -7,32 +7,15 @@ ...@@ -7,32 +7,15 @@
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<script type="text/javascript"> {% if smart %}
{% if smart %} <script type="text/javascript">
var week = {{ week.week }}; var week = {{ week.week }};
var year = {{ week.year }}; var year = {{ week.year }};
var dest = "{% url "timetable" type pk %}";
</script>
<script type="text/javascript" src="{% static "js/chronos/week_select.js" %}"></script>
{% endif %}
function goToCalendarWeek(cw, year) {
window.location.href = "{% url "timetable" type pk %}/" + year + "/" + cw;
}
function onCalendarWeekChanged(where) {
goToCalendarWeek($(where).val(), year);
}
$(document).ready(function () {
$("#calendar-week-1").change(function () {
onCalendarWeekChanged("#calendar-week-1");
});
$("#calendar-week-2").change(function () {
onCalendarWeekChanged("#calendar-week-2");
});
$("#calendar-week-3").change(function () {
onCalendarWeekChanged("#calendar-week-3");
});
});
{% endif %}
</script>
<div class="row no-margin"> <div class="row no-margin">
<div class="col s8 m6 l8 xl9"> <div class="col s8 m6 l8 xl9">
<h4> <h4>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment