function removeAfter(string, pattern) { var n = string.indexOf(pattern); return string.substring(0, n != -1 ? n : string.length); } function pageName(href) { if (href.indexOf(window.location.host) >= 0) { href = removeAfter(removeAfter(href, '?'), '#') hrefE = href.split('/') return hrefE[hrefE.length - 1] } return false } function pageSpecific(location) { if (pageName(location) == 'contact') { initializeMap() } } function actLink(ev) { var location = ev.currentTarget.href var page = pageName(location) if (page && page != pageName(window.location.href)) { loadDoc(location, function () { history.pushState({ loc: location }, document.title, location) }) return false } } function dynamiseLinks(el) { $("a", el).click(actLink) } function loadDoc(location, callback) { if (!callback) { callback = function () { return undefined } } var eventsLeft = 2 var html = '' function events() { eventsLeft += -1 if (eventsLeft <= 0) { mainContainer.html(html) dynamiseLinks(mainContainer) pageSpecific(location) mainContainer.animate({ // height: "toggle", opacity: 1 }) callback() } } var mainContainer = $("#mainContainer") mainContainer.animate({ // height: "toggle", opacity: 0 }, 'fast', events) $.get(location + '?c', function (data) { html = data events() }) } function historyChange(ev) { loadDoc(ev.state.loc) } $(document).ready(function () { dynamiseLinks(document) pageSpecific(window.location.href) window.onpopstate = historyChange }) function initializeMap() { var mapCanvas = document.getElementById('map-canvas'); mapCanvas.innerHTML = '' var polytechPos = new google.maps.LatLng(50.6074998, 3.1373338); var mapOptions = { center: polytechPos, zoom: 16, mapTypeId: google.maps.MapTypeId.ROADMAP } var map = new google.maps.Map(mapCanvas, mapOptions) var marker = new google.maps.Marker({ place: { location: polytechPos, query: "Polytech Lille" }, attribution: { source: "Coupe de Robotique des Écoles Primaires", webUrl: window.location.host }, map: map, title: "Polytech Lille" }) var infowindow = new google.maps.InfoWindow({ content: "Polytech Lille
Lieux des évènements de la Coupe de Robotique des Écoles Primaires" }) marker.addListener('click', function () { infowindow.open(map, this) }) }