22
33// Page Parameters ------------------------------------------------------------
44
5- function GetURL ( ) {
6- return new URL ( location ) ;
7- }
8-
9- function GetPageArgs ( ) {
10- return GetURL ( ) . searchParams ;
11- }
12-
13- function GetPageQueryString ( ) {
14- return GetPageArgs ( ) . toString ( ) ;
15- }
5+ var page_query_string = location . search . substring ( 1 ) ;
6+ const page_args = new URLSearchParams ( location . search ) ;
167
178function GetPageArg ( key , def ) {
18- return GetPageArgs ( ) . get ( key ) || def ;
9+ return page_args . get ( key ) || def ;
1910}
2011
2112function MergePageArgsIntoLink ( a ) {
22- if ( GetPageArgs ( ) . size === 0 || ! a . dataset . pltdoc ) return ;
13+ if ( page_args . size === 0 || ! a . dataset . pltdoc ) return ;
2314 a . href = MergePageArgsIntoUrl ( a . href ) ;
2415}
2516
2617function MergePageArgsIntoUrl ( href ) {
2718 const url = new URL ( href , window . location . href ) ;
28- for ( const [ key , val ] of GetPageArgs ( ) ) {
19+ for ( const [ key , val ] of page_args ) {
2920 if ( url . searchParams . has ( key ) ) continue ;
3021 url . searchParams . append ( key , val )
3122 }
@@ -79,24 +70,14 @@ function SetPLTRoot(ver, relative) {
7970
8071// adding index.html works because of the above
8172function GotoPLTRoot ( ver , relative ) {
82- var u = GetRootPath ( ver ) ;
73+ var u = GetCookie ( "PLT_Root." + ver , null ) ;
8374 if ( u == null ) return true ; // no cookie: use plain up link
8475 // the relative path is optional, default goes to the toplevel start page
8576 if ( ! relative ) relative = "index.html" ;
8677 location = u + relative ;
8778 return false ;
8879}
8980
90- function GetRootPath ( ver ) {
91- var u = GetCookie ( "PLT_Root." + ver , null ) ;
92- if ( u != null )
93- return u ;
94- // use root specified by local-redirect wrapper, if present
95- if ( typeof user_doc_root != "undefined" )
96- return user_doc_root ;
97- return null ;
98- }
99-
10081// Utilities ------------------------------------------------------------------
10182
10283var normalize_rxs = [ / \/ \/ + / g, / \/ \. ( \/ | $ ) / , / \/ [ ^ \/ ] * \/ \. \. ( \/ | $ ) / ] ;
@@ -116,7 +97,7 @@ function NormalizePath(path) {
11697function DoSearchKey ( event , field , ver , top_path ) {
11798 var val = field . value ;
11899 if ( event && event . key === 'Enter' ) {
119- var u = GetRootPath ( ver ) ;
100+ var u = GetCookie ( "PLT_Root." + ver , null ) ;
120101 if ( u == null ) u = top_path ; // default: go to the top path
121102 u += "search/index.html?q=" + encodeURIComponent ( val ) ;
122103 u = MergePageArgsIntoUrl ( u ) ;
0 commit comments