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) {