Changeset - 0d6890c84934
[Not reviewed]
0 2 0
Joel Addison - 4 years ago 2019-12-15 04:49:00
joel@addison.net.au
Fix schedule day view

Retrieve day from URL on page load and open the schedule for that day.
2 files changed with 28 insertions and 28 deletions:
0 comments (0 inline, 0 general)
pinaxcon/templates/symposion/schedule/schedule_conference.html
Show inline comments
...
 
@@ -50,13 +50,16 @@
 
{% block scripts_extra %}
 
  <script type="text/javascript">
 

	
 
    fragment = window.location.hash.toLowerCase().substring(1);
 
    var fragment = window.location.hash.toLowerCase().substring(1);
 

	
 
    if (!fragment) {
 
      OFFSET = -10 * (60 * 60 * 1000); // Gold Coast is 10 hours ahead of UTC in Jan.
 
      JAN = 0; // because January is 0, not 1
 
    if (fragment) {
 
      var fragmentid = "#schedule_day_" + fragment + "-tab";
 
      $(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": "tuesday", "time": Date.UTC(2020, JAN, 14)},
 
        {"day": "wednesday", "time": Date.UTC(2020, JAN, 15)},
...
 
@@ -65,42 +68,41 @@
 
        {"day": "saturday", "time": Date.UTC(2020, JAN, 18)},
 
      ];
 

	
 
      now = new Date().getTime();
 
      var now = new Date().getTime();
 

	
 
      for (i = 0; i < 5; i++) {
 
        f = fragments[i];
 
        g = fragments[i+1];
 
      for (var i = 0; i < 5; i++) {
 
        var f = fragments[i];
 
        var g = fragments[i+1];
 
        if ((f.time + OFFSET) <= now && now < (g.time + OFFSET)) {
 
          fragment = f.day;
 
        }
 
      }
 
    }
 

	
 
    document.addEventListener("hashchange", function(event) {
 
      fragment = window.location.hash.toLowerCase().substring(1);
 
    window.addEventListener("hashchange", function(event) {
 
      var fragment = window.location.hash.toLowerCase().substring(1);
 

	
 
      if (!fragment) {
 
        return;
 
      };
 

	
 
      fragmentid = "#schedule_day_" + fragment + "-tab";
 
      $(fragmentid).tab('show');
 

	
 
    });
 
      var tab_id = "#schedule_day_" + fragment + "-tab";
 
      $(tab_id).tab('show');
 
    }, false);
 

	
 
      $(".nav-item").click(function(event) {
 
        // This updates the window location fragment so that
 
        // the URL bar is updated, and so that when you go
 
        // back, it loads the right page.
 
    $(".nav-item").click(function(event) {
 
      // This updates the window location fragment so that
 
      // the URL bar is updated, and so that when you go
 
      // back, it loads the right page.
 

	
 
        // len("schedule_day_") == 13
 
        day_tab = event.target.id.substring(13);
 
        day = day_tab.substr(0, day_tab.length-4);
 
      // len("schedule_day_") == 13
 
      var day_tab = event.target.id.substring(13);
 
      var day = day_tab.substr(0, day_tab.length-4);
 

	
 
        if(history.pushState) {
 
            history.pushState(null, null, "#" + day);
 
        }
 
      });
 
      if (history.pushState) {
 
        history.pushState(null, null, "#" + day);
 
      }
 
    });
 
  </script>
 
  {{ block.super }}
 
{% endblock %}
vendor/symposion/schedule/views.py
Show inline comments
...
 
@@ -53,10 +53,8 @@ def schedule_conference(request):
 
            "days": days,
 
        })
 

	
 
    day_switch = request.GET.get('day', None)
 
    ctx = {
 
        "sections": sections,
 
        "day_switch": day_switch
 
    }
 
    return render(request, "symposion/schedule/schedule_conference.html", ctx)
 

	
0 comments (0 inline, 0 general)