|
45 | 45 | } |
46 | 46 | </script> |
47 | 47 | <script src="{{ "/js/default.js" | prepend: site.baseurl }}"></script> |
48 | | - {% if page.permalink == '/' or page.permalink == '/hackathon/' %} |
| 48 | + |
| 49 | + <!-- Maps API loading script with callback --> |
49 | 50 | <script> |
| 51 | + // Define global callback function that will be called when Maps API is loaded |
| 52 | + window.initGoogleMaps = function() { |
| 53 | + // This flag indicates Maps API is fully loaded and ready |
| 54 | + window.googleMapsLoaded = true; |
| 55 | + |
| 56 | + // Trigger an event to notify other scripts |
| 57 | + if (document.createEvent) { |
| 58 | + var event = document.createEvent('Event'); |
| 59 | + event.initEvent('google-maps-loaded', true, true); |
| 60 | + window.dispatchEvent(event); |
| 61 | + } |
| 62 | + }; |
| 63 | + |
| 64 | + // Pre-define variables that will be needed globally |
| 65 | + {% if page.permalink == '/' %} |
| 66 | + if ($(window).width() > 767) { |
| 67 | + window.googleMaps = 'index'; |
| 68 | + } else { |
| 69 | + window.staticGoogleMaps = true; |
| 70 | + window.eventPlaceCoordinates = '{{ site.eventPlaceCoordinates | replace:' ','' }}'; |
| 71 | + window.centerMapCoordinates = '{{ site.mapCenterCoordinates | replace:' ','' }}'; |
| 72 | + window.mobileCenterMapCoordinates = '{{ site.mapMobileCenterCoordinates | replace:' ','' }}'; |
| 73 | + window.icon = '{{ site.baseurl | prepend: site.url }}/img/other/map-marker.png'; |
| 74 | + } |
| 75 | + window.twitterFeedUrl = '{{ site.twitterFeed }}'; |
| 76 | + {% elsif page.permalink == '/logistics/' %} |
| 77 | + window.googleMaps = 'logistics'; |
| 78 | + window.autoDirectionEnabled = {% if site.logisticsMapAutoDirections %} true {% else %} false {% endif %}; |
| 79 | + {% elsif page.permalink == '/hackathon/' %} |
| 80 | + if ($(window).width() > 767) { |
| 81 | + window.googleMaps = 'hackathon'; |
| 82 | + } else { |
| 83 | + window.staticGoogleMaps = true; |
| 84 | + window.eventPlaceCoordinates = '{{ site.hackathonPlaceCoordinates | replace:' ','' }}'; |
| 85 | + window.centerMapCoordinates = '{{ site.hackathonMapCenterCoordinates | replace:' ','' }}'; |
| 86 | + window.mobileCenterMapCoordinates = '{{ site.hackathonMapMobileCenterCoordinates | replace:' ','' }}'; |
| 87 | + window.icon = '{{ site.baseurl | prepend: site.url }}/img/other/map-marker.png'; |
| 88 | + } |
| 89 | + {% endif %} |
| 90 | + |
| 91 | + // Conditionally load appropriate Maps API based on page |
| 92 | + {% if page.permalink == '/' or page.permalink == '/hackathon/' %} |
50 | 93 | if ($(window).width() > 767) { |
51 | | - document.write('<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&key=AIzaSyAQr5Br-dyp10Z_dV0Q0aOIBKSbnRjjz3k"><\/script>') |
52 | | - } |
| 94 | + var script = document.createElement('script'); |
| 95 | + script.src = "https://maps.googleapis.com/maps/api/js?v=3.exp&key=AIzaSyAQr5Br-dyp10Z_dV0Q0aOIBKSbnRjjz3k&callback=initGoogleMaps"; |
| 96 | + script.async = true; |
| 97 | + document.head.appendChild(script); |
| 98 | + } |
| 99 | + {% elsif page.permalink == '/logistics/' %} |
| 100 | + var script = document.createElement('script'); |
| 101 | + script.src = "https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places,geometry&callback=initGoogleMaps"; |
| 102 | + script.async = true; |
| 103 | + document.head.appendChild(script); |
| 104 | + {% endif %} |
53 | 105 | </script> |
54 | | - {% elsif page.permalink == '/logistics/' %} |
55 | | - <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places,geometry"></script> |
56 | | - <script type="text/javascript"> |
57 | | - var autoDirectionEnabled = {% if site.logisticsMapAutoDirections %} true {% else %} false {% endif %}; |
58 | | - </script> |
59 | | - {% endif %} |
| 106 | + |
60 | 107 | <script> |
61 | 108 | Waves.displayEffect(); |
| 109 | + |
| 110 | + // Setup map coordinates once API is loaded |
| 111 | + document.addEventListener('google-maps-loaded', function() { |
| 112 | + {% if page.permalink == '/' %} |
| 113 | + if ($(window).width() > 767) { |
| 114 | + window.eventPlace = new google.maps.LatLng({{ site.eventPlaceCoordinates | replace:' ','' }}); |
| 115 | + window.centerMap = new google.maps.LatLng({{ site.mapCenterCoordinates | replace:' ','' }}); |
| 116 | + window.mobileCenterMap = new google.maps.LatLng({{ site.mapMobileCenterCoordinates | replace:' ','' }}); |
| 117 | + window.icon = '{{ site.baseurl }}/img/other/map-marker.svg'; |
| 118 | + } |
| 119 | + {% elsif page.permalink == '/logistics/' %} |
| 120 | + window.eventPlace = new google.maps.LatLng({{ site.eventPlaceCoordinates }}); |
| 121 | + window.centerMap = new google.maps.LatLng({{ site.logisticsMapCenterCoordinates }}); |
| 122 | + window.mobileCenterMap = new google.maps.LatLng({{ site.logisticsMapMobileCenterCoordinates }}); |
| 123 | + window.icon = '{{ site.baseurl }}/img/other/map-marker.svg'; |
| 124 | + {% elsif page.permalink == '/hackathon/' %} |
| 125 | + if ($(window).width() > 767) { |
| 126 | + window.eventPlace = new google.maps.LatLng({{ site.hackathonPlaceCoordinates }}); |
| 127 | + window.centerMap = new google.maps.LatLng({{ site.hackathonMapCenterCoordinates }}); |
| 128 | + window.mobileCenterMap = new google.maps.LatLng({{ site.hackathonMapMobileCenterCoordinates }}); |
| 129 | + window.icon = '{{ site.baseurl }}/img/other/map-marker.svg'; |
| 130 | + } |
| 131 | + {% endif %} |
| 132 | + }); |
| 133 | + |
62 | 134 | {% if page.permalink == '/' %} |
63 | | - if ($(window).width() > 767) { |
64 | | - var googleMaps = 'index', |
65 | | - eventPlace = new google.maps.LatLng({{ site.eventPlaceCoordinates | replace:' ','' }}), |
66 | | - centerMap = new google.maps.LatLng({{ site.mapCenterCoordinates | replace:' ','' }}), |
67 | | - mobileCenterMap = new google.maps.LatLng({{ site.mapMobileCenterCoordinates | replace:' ','' }}), |
68 | | - icon = '{{ site.baseurl }}/img/other/map-marker.svg'; |
69 | | - } else { |
70 | | - var staticGoogleMaps = true, |
71 | | - eventPlaceCoordinates = '{{ site.eventPlaceCoordinates | replace:' ','' }}', |
72 | | - centerMapCoordinates = '{{ site.mapCenterCoordinates | replace:' ','' }}', |
73 | | - mobileCenterMapCoordinates = '{{ site.mapMobileCenterCoordinates | replace:' ','' }}', |
74 | | - icon = '{{ site.baseurl | prepend: site.url }}/img/other/map-marker.png'; |
75 | | - } |
76 | | - var twitterFeedUrl = '{{ site.twitterFeed }}'; |
77 | 135 | $(document).ready(function () { |
78 | 136 | $(function () { |
79 | 137 | if ($(window).width() > 767) { |
|
107 | 165 | } |
108 | 166 | } |
109 | 167 | }); |
110 | | - {% elsif page.permalink == '/logistics/' %} |
111 | | - var googleMaps = 'logistics', |
112 | | - eventPlace = new google.maps.LatLng({{ site.eventPlaceCoordinates }}), |
113 | | - centerMap = new google.maps.LatLng({{ site.logisticsMapCenterCoordinates }}), |
114 | | - mobileCenterMap = new google.maps.LatLng({{ site.logisticsMapMobileCenterCoordinates }}), |
115 | | - icon = '{{ site.baseurl }}/img/other/map-marker.svg'; |
116 | | - {% elsif page.permalink == '/hackathon/' %} |
117 | | - if ($(window).width() > 767) { |
118 | | - var googleMaps = 'hackathon', |
119 | | - eventPlace = new google.maps.LatLng({{ site.hackathonPlaceCoordinates }}), |
120 | | - centerMap = new google.maps.LatLng({{ site.hackathonMapCenterCoordinates }}), |
121 | | - mobileCenterMap = new google.maps.LatLng({{ site.hackathonMapMobileCenterCoordinates }}), |
122 | | - icon = '{{ site.baseurl }}/img/other/map-marker.svg'; |
123 | | - } else { |
124 | | - var staticGoogleMaps = true, |
125 | | - eventPlaceCoordinates = '{{ site.hackathonPlaceCoordinates | replace:' ','' }}', |
126 | | - centerMapCoordinates = '{{ site.hackathonMapCenterCoordinates | replace:' ','' }}', |
127 | | - mobileCenterMapCoordinates = '{{ site.hackathonMapMobileCenterCoordinates | replace:' ','' }}', |
128 | | - icon = '{{ site.baseurl | prepend: site.url }}/img/other/map-marker.png'; |
129 | | - } |
130 | | - |
131 | | - {% endif %} |
| 168 | + {% endif %} |
132 | 169 | </script> |
133 | | - <script src="{{ "/js/scripts.min.js" | prepend: site.baseurl }}"></script> |
| 170 | + <script src="{{ "/js/scripts.js" | prepend: site.baseurl }}"></script> |
134 | 171 | {% if page.permalink == '/schedule/' %} |
135 | 172 | <script type="text/javascript" defer> |
136 | 173 | $(document).ready(function () { |
|
0 commit comments