From 56c75c13f3ccc24d3a153e85447c33a1c66af9e8 Mon Sep 17 00:00:00 2001 From: Geoffrey Frogeye Date: Mon, 10 Nov 2014 21:54:19 +0100 Subject: [PATCH] [Navigation] Ouvre la page dernièrement ouverte en cas de refresh --- index.php | 2 +- js/crep.js | 42 ++++++++++++++++++++++++++---------------- menu.php | 10 +++++----- 3 files changed, 32 insertions(+), 22 deletions(-) diff --git a/index.php b/index.php index f4f55cb..97b4d34 100644 --- a/index.php +++ b/index.php @@ -14,10 +14,10 @@ require_once("creds.php"); - + diff --git a/js/crep.js b/js/crep.js index 5241a0f..64eedc6 100644 --- a/js/crep.js +++ b/js/crep.js @@ -1,20 +1,30 @@ -function file(fichier) -{ - if(window.XMLHttpRequest) - xhr_object = new XMLHttpRequest(); - else if(window.ActiveXObject) - xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); - else - return(false); - xhr_object.open("GET", fichier, false); - xhr_object.send(null); - if(xhr_object.readyState == 4) - return(xhr_object.responseText); +function file(fichier) { + if (window.XMLHttpRequest) + xhr_object = new XMLHttpRequest(); + else if (window.ActiveXObject) + xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); else - return(false); + return (false); + xhr_object.open("GET", fichier, false); + xhr_object.send(null); + if (xhr_object.readyState == 4) + return (xhr_object.responseText); + else + return (false); } -function loadNewDoc(doc) -{ - $("#mainContainer").html(file(doc)); +function loadNewDoc(doc) { + $("#mainContainer").html(file(doc)); + return false } + +$().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')) + } + }) + } +}) diff --git a/menu.php b/menu.php index 4b05129..8d54a51 100644 --- a/menu.php +++ b/menu.php @@ -1,20 +1,20 @@