From a45e38adfcdbf44adca30b25372d89d729ba8464 Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Tue, 27 May 2008 15:12:31 +0000 Subject: [PATCH] user documentation root is now stored in a cookie svn: r9978 original commit: 1e9e508ec02be10f9a45450bdd6cf8292bb43682 --- collects/scribble/scribble-common.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/collects/scribble/scribble-common.js b/collects/scribble/scribble-common.js index c42b58aa..97cd0388 100644 --- a/collects/scribble/scribble-common.js +++ b/collects/scribble/scribble-common.js @@ -19,15 +19,25 @@ function SetCookie(key, val) { key + "=" + escape(val) + "; expires="+ d.toGMTString() + "; path=/"; } -function GotoPLTRoot() { - var u = GetCookie("PLT_Root"); +function GotoPLTRoot(ver) { + var u = GetCookie("PLT_Root."+ver); if (u == null) return true; // no cookie: use plain up link location = u; return false; } -function SetPLTRoot() { - SetCookie("PLT_Root", location); +function SetPLTRoot(ver, relative) { + var root = location.protocol + "//" + location.host + + NormalizePath(location.pathname.replace(/[^\/]*$/, relative)); + SetCookie("PLT_Root."+ver, root); +} + +normalize_rxs = [/\/\/+/g, /\/\.(\/|$)/, /\/[^\/]*\/\.\.(\/|$)/]; +function NormalizePath(path) { + var tmp, i; + for (i = 0; i < normalize_rxs.length; i++) + while ((tmp = path.replace(normalize_rxs[i], "/")) != path) path = tmp; + return path; } function DoSearchKey(event, field) {