Fix schedule day view
Retrieve day from URL on page load and open the schedule for that day.
This commit is contained in:
parent
89a11ac558
commit
0d6890c849
2 changed files with 29 additions and 29 deletions
|
@ -50,13 +50,16 @@
|
||||||
{% block scripts_extra %}
|
{% block scripts_extra %}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
fragment = window.location.hash.toLowerCase().substring(1);
|
var fragment = window.location.hash.toLowerCase().substring(1);
|
||||||
|
|
||||||
if (!fragment) {
|
if (fragment) {
|
||||||
OFFSET = -10 * (60 * 60 * 1000); // Gold Coast is 10 hours ahead of UTC in Jan.
|
var fragmentid = "#schedule_day_" + fragment + "-tab";
|
||||||
JAN = 0; // because January is 0, not 1
|
$(fragmentid).tab('show');
|
||||||
|
} else {
|
||||||
|
var OFFSET = -10 * (60 * 60 * 1000); // Gold Coast is 10 hours ahead of UTC in Jan.
|
||||||
|
var JAN = 0; // because January is 0, not 1
|
||||||
|
|
||||||
fragments = [
|
var fragments = [
|
||||||
{"day": "monday", "time": Date.UTC(2020, JAN, 13)},
|
{"day": "monday", "time": Date.UTC(2020, JAN, 13)},
|
||||||
{"day": "tuesday", "time": Date.UTC(2020, JAN, 14)},
|
{"day": "tuesday", "time": Date.UTC(2020, JAN, 14)},
|
||||||
{"day": "wednesday", "time": Date.UTC(2020, JAN, 15)},
|
{"day": "wednesday", "time": Date.UTC(2020, JAN, 15)},
|
||||||
|
@ -65,28 +68,27 @@
|
||||||
{"day": "saturday", "time": Date.UTC(2020, JAN, 18)},
|
{"day": "saturday", "time": Date.UTC(2020, JAN, 18)},
|
||||||
];
|
];
|
||||||
|
|
||||||
now = new Date().getTime();
|
var now = new Date().getTime();
|
||||||
|
|
||||||
for (i = 0; i < 5; i++) {
|
for (var i = 0; i < 5; i++) {
|
||||||
f = fragments[i];
|
var f = fragments[i];
|
||||||
g = fragments[i+1];
|
var g = fragments[i+1];
|
||||||
if ((f.time + OFFSET) <= now && now < (g.time + OFFSET)) {
|
if ((f.time + OFFSET) <= now && now < (g.time + OFFSET)) {
|
||||||
fragment = f.day;
|
fragment = f.day;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener("hashchange", function(event) {
|
window.addEventListener("hashchange", function(event) {
|
||||||
fragment = window.location.hash.toLowerCase().substring(1);
|
var fragment = window.location.hash.toLowerCase().substring(1);
|
||||||
|
|
||||||
if (!fragment) {
|
if (!fragment) {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
fragmentid = "#schedule_day_" + fragment + "-tab";
|
var tab_id = "#schedule_day_" + fragment + "-tab";
|
||||||
$(fragmentid).tab('show');
|
$(tab_id).tab('show');
|
||||||
|
}, false);
|
||||||
});
|
|
||||||
|
|
||||||
$(".nav-item").click(function(event) {
|
$(".nav-item").click(function(event) {
|
||||||
// This updates the window location fragment so that
|
// This updates the window location fragment so that
|
||||||
|
@ -94,10 +96,10 @@
|
||||||
// back, it loads the right page.
|
// back, it loads the right page.
|
||||||
|
|
||||||
// len("schedule_day_") == 13
|
// len("schedule_day_") == 13
|
||||||
day_tab = event.target.id.substring(13);
|
var day_tab = event.target.id.substring(13);
|
||||||
day = day_tab.substr(0, day_tab.length-4);
|
var day = day_tab.substr(0, day_tab.length-4);
|
||||||
|
|
||||||
if(history.pushState) {
|
if (history.pushState) {
|
||||||
history.pushState(null, null, "#" + day);
|
history.pushState(null, null, "#" + day);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
2
vendor/symposion/schedule/views.py
vendored
2
vendor/symposion/schedule/views.py
vendored
|
@ -53,10 +53,8 @@ def schedule_conference(request):
|
||||||
"days": days,
|
"days": days,
|
||||||
})
|
})
|
||||||
|
|
||||||
day_switch = request.GET.get('day', None)
|
|
||||||
ctx = {
|
ctx = {
|
||||||
"sections": sections,
|
"sections": sections,
|
||||||
"day_switch": day_switch
|
|
||||||
}
|
}
|
||||||
return render(request, "symposion/schedule/schedule_conference.html", ctx)
|
return render(request, "symposion/schedule/schedule_conference.html", ctx)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue