X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;ds=sidebyside;f=js%2Ffragment.js;h=50ec9438de83d503504d98e910b5c8701bbee63a;hb=79f0cfc91b7220d98e4caf50fbb3857807fc6bc4;hp=f5a734eab72d5b066d25e5ad61104c24352a4a5c;hpb=6c0fcdfaefd072f8b0ee1d7d8f1ba2a2c1ede8ec;p=euphorik.git diff --git a/js/fragment.js b/js/fragment.js index f5a734e..50ec943 100644 --- a/js/fragment.js +++ b/js/fragment.js @@ -17,16 +17,22 @@ // along with Euphorik. If not, see . /** - * + * Gestion du fragment d'url, permet de le modifier en direct. */ 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]); @@ -66,4 +72,4 @@ Fragment.prototype.write = function() { first = false; }); window.location.hash = fragmentsStr; -}; \ No newline at end of file +};