X-Git-Url: http://git.euphorik.ch/?p=euphorik.git;a=blobdiff_plain;f=js%2Ffragment.js;h=23f22d0ca57a771da8a984ee5cb3628a87780015;hp=ef087f45e35dc1f4c67fc972495536ffc6bbb8d7;hb=d5d1945e199af296bdec6267eea99e577bb97c3e;hpb=2b1fd1fef9cf628a19f6452ee8375f3091a9f1d4 diff --git a/js/fragment.js b/js/fragment.js index ef087f4..23f22d0 100644 --- a/js/fragment.js +++ b/js/fragment.js @@ -21,17 +21,24 @@ */ Fragment = function() { var thisFragment = this; + // remplacement des codes de type %22 (en hexa) + var replaceHtmlCode = function(str) { + return str.replace(/%(\d\d)/g, function(text, code) { + return String.fromCharCode(parseInt(code, 16)); + }) + }; this.fragments = {}; if (!window.location.hash) { return; } try { - var fragmentsStr = window.location.hash.slice(1).split(";"); + var fragmentsStr = replaceHtmlCode(window.location.hash.slice(1)).split(";"); fragmentsStr.each(function(i, tuple) { tuple = tuple.split("="); thisFragment.fragments[tuple[0]] = JSON.parse(tuple[1]); }); } catch(error) { + alert(error) ;; console.log(error); } };