Blame view

js/crep.js 1.85 KB
56c75c13   Geoffrey PREUD'HOMME   [Navigation] Ouvr...
1
2
3
4
5
  function file(fichier) {
      if (window.XMLHttpRequest)
          xhr_object = new XMLHttpRequest();
      else if (window.ActiveXObject)
          xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
7ab7e900   Jean Wasilewski   file function added
6
      else
56c75c13   Geoffrey PREUD'HOMME   [Navigation] Ouvr...
7
8
9
10
11
12
13
          return (false);
      xhr_object.open("GET", fichier, false);
      xhr_object.send(null);
      if (xhr_object.readyState == 4)
          return (xhr_object.responseText);
      else
          return (false);
7ab7e900   Jean Wasilewski   file function added
14
15
  }
  
56c75c13   Geoffrey PREUD'HOMME   [Navigation] Ouvr...
16
17
18
  function loadNewDoc(doc) {
      $("#mainContainer").html(file(doc));
      return false
5da68a4a   Jean Wasilewski   Debug of the load...
19
  }
56c75c13   Geoffrey PREUD'HOMME   [Navigation] Ouvr...
20
  
a0daba42   Jean Wasilewski   Partial base64 an...
21
22
23
24
25
26
  function deleteNewNews()
  {
  	if (confirm('Voulez vous vraiment supprimer la news ?'))
  		$("#newNews").remove();
  }
  
febd6409   henyxia   News creation done
27
28
29
30
31
32
33
34
35
36
  function validNewNews()
  {
  	var ret;
  	ret = $.post( "sendNews.php", {title: Base64.encode($("#newNews")[0].childNodes[0].childNodes[0].childNodes[0].value), content: Base64.encode($("#newNews")[0].childNodes[1].childNodes[0].value)});
  	if(ret == true)
  		document.location.reload();
  	else
  		alert("Erreur durant la transmission de la news");
  }
  
d0d663f9   Jean Wasilewski   Add news partiall...
37
38
  function addNews()
  {
a0daba42   Jean Wasilewski   Partial base64 an...
39
  	var elem = "<div id=\"newNews\" class=\"panel panel-default\"><div class=\"panel-heading\"><h3 class=\"panel-title\"><input type=text class=\"form-control\" placeholder=\"Nouvel article\"/></h3></div><div class=\"panel-body\"><textarea class=\"form-control\"></textarea></div><div class=\"panel-footer\"><p><button type=\"button\" onClick=\"validNewNews();\" class=\"btn btn-success\">Success</button>&nbsp;<button type=\"button\" onClick=\"deleteNewNews();\" class=\"btn btn-danger\">Annuler</button></p></div></div>";
d0d663f9   Jean Wasilewski   Add news partiall...
40
41
42
  	$("#mainContainer").append(elem);
  }
  
56c75c13   Geoffrey PREUD'HOMME   [Navigation] Ouvr...
43
44
45
46
47
48
49
50
51
52
  $().ready(function() {
      // Navigue vers la page indiquée dans l'URL en cas de refresh
      if (window.location.hash) {
          $('ul.nav a').each(function() {
              if ($(this).attr('href') == window.location.hash) {
                  loadNewDoc($(this).attr('onclick').replace(/loadNewDoc\(\'(.+)\'\);?/, '$1'))
              }
          })
      }
  })