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 %} | ||||
|   <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. | ||||
| 
 | ||||
|       // 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); | ||||
|       } | ||||
|     }); | ||||
| 
 | ||||
|       $(".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); | ||||
| 
 | ||||
|         if(history.pushState) { | ||||
|             history.pushState(null, null, "#" + day); | ||||
|         } | ||||
|       }); | ||||
|   </script> | ||||
|   {{ block.super }} | ||||
| {% endblock %} | ||||
|  |  | |||
							
								
								
									
										2
									
								
								vendor/symposion/schedule/views.py
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/symposion/schedule/views.py
									
										
									
									
										vendored
									
									
								
							|  | @ -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) | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Joel Addison
						Joel Addison