Blame view

js/crep.js 1.35 KB
dcc55bea   Geoffrey PREUD'HOMME   Minor cleanup nav...
1
2
3
4
5
6
7
  function pageSpecific(location) {
      if (location.indexOf('contact') >= 0) {
          initializeMap()
      }
  }
  
  function actLink(ev) {
8485d451   Geoffrey PREUD'HOMME   New dynamic JS nav
8
9
      var location = ev.currentTarget.href
      if (location.indexOf(window.location.host) >= 0) {
dcc55bea   Geoffrey PREUD'HOMME   Minor cleanup nav...
10
          loadDoc(location)
8485d451   Geoffrey PREUD'HOMME   New dynamic JS nav
11
12
          return false
      }
7ab7e900   Jean Wasilewski   file function added
13
14
  }
  
8485d451   Geoffrey PREUD'HOMME   New dynamic JS nav
15
  function dynamiseLinks(el) {
dcc55bea   Geoffrey PREUD'HOMME   Minor cleanup nav...
16
      $("a", el).click(actLink)
8485d451   Geoffrey PREUD'HOMME   New dynamic JS nav
17
18
  }
  
dcc55bea   Geoffrey PREUD'HOMME   Minor cleanup nav...
19
20
21
22
  function loadDoc(location) {
      $.get(location + '?c', function (data) {
          mainContainer = $("#mainContainer")
          mainContainer.html(data)
d71b5167   Geoffrey PREUD'HOMME   Almost functionni...
23
24
25
          history.pushState({
              loc: location
          }, document.title, location)
dcc55bea   Geoffrey PREUD'HOMME   Minor cleanup nav...
26
27
28
29
30
          // POST
          dynamiseLinks(mainContainer)
          pageSpecific(location)
      })
  
b8d34eaa   Geoffrey PREUD'HOMME   Moved map initial...
31
32
  }
  
d71b5167   Geoffrey PREUD'HOMME   Almost functionni...
33
34
35
36
  function historyChange(ev) {
      loadDoc(ev.state.loc)
  }
  
8485d451   Geoffrey PREUD'HOMME   New dynamic JS nav
37
38
  $(document).ready(function () {
      dynamiseLinks(document)
b8d34eaa   Geoffrey PREUD'HOMME   Moved map initial...
39
      pageSpecific(window.location.href)
d71b5167   Geoffrey PREUD'HOMME   Almost functionni...
40
      window.onpopstate = historyChange
b8d34eaa   Geoffrey PREUD'HOMME   Moved map initial...
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
  })
  
  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({
          position: polytechPos,
          map: map,
          title: "Polytech Lille"
      });
  }