ci.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* ajouter un lien lors de copie/colle */
  2. function addLink() {
  3. var body_element = document.getElementsByTagName('body')[0];
  4. var selection;
  5. selection = window.getSelection();
  6. var pagelink = " Lire plus sur : <a href='"+document.location.href+"'>"+document.location.href+"</a>"; // change this if you want
  7. var copytext = selection + pagelink;
  8. var newdiv = document.createElement('div');
  9. body_element.appendChild(newdiv);
  10. newdiv.innerHTML = copytext;
  11. selection.selectAllChildren(newdiv);
  12. window.setTimeout(function() {
  13. body_element.removeChild(newdiv);
  14. },0);
  15. }
  16. /* afficher / masquer un div */
  17. function showhideme(id) {
  18. shown = document.getElementById(id).style.display;
  19. if (shown == 'block') shown2 = 'none'; else shown2 = 'block';
  20. document.getElementById(id).style.display=shown2;
  21. }
  22. function MM_openBrWindow(theURL,winName,features) {
  23. window.open(theURL,winName,features);
  24. }
  25. function confirmeAction(message){
  26. reponse = confirm(message);return reponse;
  27. }
  28. function confirmeSupprime(){
  29. reponse = confirm("Etes-vous certain de vouloir supprimer cette ressource ?");return reponse;
  30. }
  31. /* AJAX */
  32. function sendData(page, div)
  33. {
  34. if(document.all) var XhrObj = new ActiveXObject("Microsoft.XMLHTTP") ;
  35. else var XhrObj = new XMLHttpRequest();
  36. var content = document.getElementById(div);
  37. XhrObj.open("POST", page);
  38. XhrObj.onreadystatechange = function(){
  39. if (XhrObj.readyState == 4 && XhrObj.status == 200)
  40. content.innerHTML = XhrObj.responseText ;
  41. }
  42. XhrObj.setRequestHeader('Content-type', 'application/x-www-form-urlencoded; charset=iso-8859-1');
  43. XhrObj.send(null);
  44. }
  45. function sendData2(page, div, laclass)
  46. {
  47. if(document.all) var XhrObj = new ActiveXObject("Microsoft.XMLHTTP") ;
  48. else var XhrObj = new XMLHttpRequest();
  49. var content = document.getElementById(div);
  50. XhrObj.open("GET", page);
  51. XhrObj.onreadystatechange = function(){
  52. if (XhrObj.readyState == 4 && XhrObj.status == 200) content.innerHTML = XhrObj.responseText;
  53. else content.innerHTML = "<div class=\"" + laclass + "\">Chargement...</div>";
  54. }
  55. XhrObj.setRequestHeader('Content-type', 'application/x-www-form-urlencoded; charset=iso-8859-1');
  56. XhrObj.send(null);
  57. }
  58. function fillbox (valeur, zone, div)
  59. {
  60. document.getElementById(zone).value = valeur;
  61. sendData('stop.php', div);
  62. }