From b5e94bc733faae2c1aff3df57b81ff38b88af1a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georges=20Dup=C3=A9ron?= Date: Thu, 28 Apr 2011 18:34:36 +0200 Subject: [PATCH] =?UTF-8?q?Et=20encore=20un=20bug=20=C3=A0=20cause=20des?= =?UTF-8?q?=20guillemets.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/serveur/php/ressources/pticlic.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/code/serveur/php/ressources/pticlic.js b/code/serveur/php/ressources/pticlic.js index 3fb992c..814ebab 100644 --- a/code/serveur/php/ressources/pticlic.js +++ b/code/serveur/php/ressources/pticlic.js @@ -8,7 +8,7 @@ function State(init) { var futureHashChange = null; State.prototype.commit = function() { try { - futureHashChange = "#"+encodeURI($.JSON.encode(this)); + futureHashChange = "#"+encodeURI('"'+$.JSON.encode(this)); location.hash = futureHashChange; return this; } catch(e) {alert("Error State.prototype.commit");alert(e);} @@ -46,8 +46,10 @@ function hashchange() { if (futureHashChange === location.hash) { futureHashChange = null; } else { - var stateJSON = decodeURI(location.hash.substring(location.hash.indexOf("#") + 1)); - state = new State($.parseJSON(stateJSON)).validate(); + var stateJSON = location.hash.substring(location.hash.indexOf("#") + 1); + if (stateJSON.charAt(0) != '"') { stateJSON = decodeURI(stateJSON); } + stateJSON = stateJSON.substring(1); + state = new State($.parseJSON(stateJSON || '{}')).validate(); } } catch(e) {alert("Error hashchange");alert(e);} }