page refresh with hash url
authorThomas Walker Lynch <eknp9n@reasoningtechnology.com>
Fri, 15 May 2026 07:19:24 +0000 (07:19 +0000)
committerThomas Walker Lynch <eknp9n@reasoningtechnology.com>
Fri, 15 May 2026 07:19:24 +0000 (07:19 +0000)
consumer/release/RT/core/utility.js
consumer/release/RT/layout/article_tech_ref.js
developer/authored/RT/core/utility.js
developer/authored/RT/layout/article_tech_ref.js

index 3044654..b8522c9 100644 (file)
@@ -13,6 +13,7 @@ window.StyleRT.debug = {
     'style', 'layout', 'pagination'
     ,'selector', 'config', 'error'
     ,'term'
+    ,'scroll'
   ]),
 
   active_tokens: new Set([
@@ -21,6 +22,7 @@ window.StyleRT.debug = {
 */  
 
   active_tokens: new Set([
+    'scroll'
   ]),
 
 
index 275d597..9e571f3 100644 (file)
@@ -1,10 +1,13 @@
 (function(){
-  console.log("[RT-Scroll] 1. Initializing script.");
+  const RT = window.StyleRT = window.StyleRT || {};
+  const debug = RT.debug || { log: function(){} };
+
+  debug.log('scroll', "1. Initializing script.");
 
   // 1. Intercept native history restoration immediately
   if ('scrollRestoration' in history) {
     history.scrollRestoration = 'manual';
-    console.log("[RT-Scroll] 2. history.scrollRestoration set to manual.");
+    debug.log('scroll', "2. history.scrollRestoration set to manual.");
   }
 
   // 2. Read coordinate from memory before any layout shifts occur
     }
   }
 
-  console.log(`[RT-Scroll] 3. Target Y: ${target_y} | Is Reload: ${is_reload}`);
+  debug.log('scroll', `3. Target Y: ${target_y} | Is Reload: ${is_reload}`);
 
   // 4. The Lock
   let is_layout_locked = true;
 
-  const RT = window.StyleRT = window.StyleRT || {};
-
   // 5. Declare Dependencies
   RT.include('RT/core/utility');
   RT.include('RT/element/math');
 
   // 7. The Execution Sequence
   function run_semantics() {
-    console.log(`[RT-Scroll] 4. run_semantics starting.`);
+    debug.log('scroll', `4. run_semantics starting.`);
     if(RT.theme) RT.theme();     
     RT.article(); 
     if(RT.title) RT.title(); 
   }
 
   function run_layout() {
-    console.log(`[RT-Scroll] 5. run_layout starting.`);
+    debug.log('scroll', `5. run_layout starting.`);
     if(RT.TOC) RT.TOC();
     if(RT.paginate_by_element) RT.paginate_by_element();
     if(RT.page) RT.page();
     if(RT.body_visibility_visible) RT.body_visibility_visible();
     
-    console.log(`[RT-Scroll] 6. Pagination complete.`);
+    debug.log('scroll', `6. Pagination complete.`);
 
     let final_target = target_y;
     let use_hash = false;
 
-    // Prioritize the hash only if it is NOT a page reload
     if (window.location.hash && !is_reload) {
         const hash_target = document.getElementById(window.location.hash.substring(1));
         if (hash_target) {
         }
     }
 
-    console.log(`[RT-Scroll] 7. Commencing viewport enforce loop. Mode: ${use_hash ? 'HASH' : 'Y-COORDINATE'}`);
+    debug.log('scroll', `7. Commencing viewport enforce loop. Mode: ${use_hash ? 'HASH' : 'Y-COORDINATE'}`);
     enforce_scroll(final_target, use_hash, 0);
   }
 
   // 8. The Enforcer Logic
   function enforce_scroll(target, use_hash, attempts) {
     if (attempts > 15) {
-      console.log("[RT-Scroll] 8. Scroll enforcement timed out. Unlocking.");
+      debug.log('scroll', "8. Scroll enforcement timed out. Unlocking.");
       is_layout_locked = false;
       return;
     }
       const hash_target = document.getElementById(window.location.hash.substring(1));
       if (hash_target) {
         hash_target.scrollIntoView();
-        console.log(`[RT-Scroll] 8a. Attempt ${attempts}: Scrolled to Hash Target. Y is now ${window.scrollY}`);
+        debug.log('scroll', `8a. Attempt ${attempts}: Scrolled to Hash Target. Y is now ${window.scrollY}`);
       }
     } else {
       window.scrollTo(0, target);
-      console.log(`[RT-Scroll] 8b. Attempt ${attempts}: Scrolled to Y=${target}. Current Y is ${window.scrollY}`);
+      debug.log('scroll', `8b. Attempt ${attempts}: Scrolled to Y=${target}. Current Y is ${window.scrollY}`);
     }
 
     let is_successful = false;
     }
 
     if (is_successful && document.body.scrollHeight > 1000) { 
-       console.log(`[RT-Scroll] 9. Viewport anchored successfully.`);
+       debug.log('scroll', `9. Viewport anchored successfully.`);
        
-       // Hold the line against native browser hash jumping
        setTimeout(() => {
          if (!use_hash && Math.abs(window.scrollY - target) >= 5) {
-             console.log(`[RT-Scroll] 9a. Browser late-stage rebellion detected. Re-enforcing.`);
+             debug.log('scroll', `9a. Browser late-stage rebellion detected. Re-enforcing.`);
              enforce_scroll(target, use_hash, attempts + 1);
          } else {
              is_layout_locked = false;
-             console.log("[RT-Scroll] 10. Layout fully unlocked.");
+             debug.log('scroll', "10. Layout fully unlocked.");
          }
        }, 100);
     } else {
     clearTimeout(scroll_timer);
     scroll_timer = setTimeout(() => {
       sessionStorage.setItem('RT_saved_y', window.scrollY);
-      console.log(`[RT-Scroll] X. User stopped scrolling. Saved Y: ${window.scrollY}`);
+      debug.log('scroll', `X. User stopped scrolling. Saved Y: ${window.scrollY}`);
     }, 200);
   }, { passive: true });
 
   window.addEventListener('beforeunload', () => {
     is_layout_locked = true;
-    console.log("[RT-Scroll] Y. Page unloading. Scroll listener locked.");
+    debug.log('scroll', "Y. Page unloading. Scroll listener locked.");
   });
 
   // 10. Bind to DOM Ready
index 3044654..b070510 100644 (file)
@@ -13,6 +13,7 @@ window.StyleRT.debug = {
     'style', 'layout', 'pagination'
     ,'selector', 'config', 'error'
     ,'term'
+    ,'scroll'
   ]),
 
   active_tokens: new Set([
@@ -23,7 +24,6 @@ window.StyleRT.debug = {
   active_tokens: new Set([
   ]),
 
-
   log: function(token, message) {
     if (this.active_tokens.has(token)) {
       console.log(`[StyleRT:${token}]`, message);
index 275d597..47e6a78 100644 (file)
@@ -1,10 +1,14 @@
+// debug messsages don't work here, because RT/core/utility isn't loaded until after the function runs.
 (function(){
-  console.log("[RT-Scroll] 1. Initializing script.");
+  const RT = window.StyleRT = window.StyleRT || {};
+  const debug = RT.debug || { log: function(){} };
+
+  debug.log('scroll', "1. Initializing script.");
 
   // 1. Intercept native history restoration immediately
   if ('scrollRestoration' in history) {
     history.scrollRestoration = 'manual';
-    console.log("[RT-Scroll] 2. history.scrollRestoration set to manual.");
+    debug.log('scroll', "2. history.scrollRestoration set to manual.");
   }
 
   // 2. Read coordinate from memory before any layout shifts occur
     }
   }
 
-  console.log(`[RT-Scroll] 3. Target Y: ${target_y} | Is Reload: ${is_reload}`);
+  debug.log('scroll', `3. Target Y: ${target_y} | Is Reload: ${is_reload}`);
 
   // 4. The Lock
   let is_layout_locked = true;
 
-  const RT = window.StyleRT = window.StyleRT || {};
-
   // 5. Declare Dependencies
   RT.include('RT/core/utility');
   RT.include('RT/element/math');
 
   // 7. The Execution Sequence
   function run_semantics() {
-    console.log(`[RT-Scroll] 4. run_semantics starting.`);
+    debug.log('scroll', `4. run_semantics starting.`);
     if(RT.theme) RT.theme();     
     RT.article(); 
     if(RT.title) RT.title(); 
   }
 
   function run_layout() {
-    console.log(`[RT-Scroll] 5. run_layout starting.`);
+    debug.log('scroll', `5. run_layout starting.`);
     if(RT.TOC) RT.TOC();
     if(RT.paginate_by_element) RT.paginate_by_element();
     if(RT.page) RT.page();
     if(RT.body_visibility_visible) RT.body_visibility_visible();
     
-    console.log(`[RT-Scroll] 6. Pagination complete.`);
+    debug.log('scroll', `6. Pagination complete.`);
 
     let final_target = target_y;
     let use_hash = false;
 
-    // Prioritize the hash only if it is NOT a page reload
     if (window.location.hash && !is_reload) {
         const hash_target = document.getElementById(window.location.hash.substring(1));
         if (hash_target) {
         }
     }
 
-    console.log(`[RT-Scroll] 7. Commencing viewport enforce loop. Mode: ${use_hash ? 'HASH' : 'Y-COORDINATE'}`);
+    debug.log('scroll', `7. Commencing viewport enforce loop. Mode: ${use_hash ? 'HASH' : 'Y-COORDINATE'}`);
     enforce_scroll(final_target, use_hash, 0);
   }
 
   // 8. The Enforcer Logic
   function enforce_scroll(target, use_hash, attempts) {
     if (attempts > 15) {
-      console.log("[RT-Scroll] 8. Scroll enforcement timed out. Unlocking.");
+      debug.log('scroll', "8. Scroll enforcement timed out. Unlocking.");
       is_layout_locked = false;
       return;
     }
       const hash_target = document.getElementById(window.location.hash.substring(1));
       if (hash_target) {
         hash_target.scrollIntoView();
-        console.log(`[RT-Scroll] 8a. Attempt ${attempts}: Scrolled to Hash Target. Y is now ${window.scrollY}`);
+        debug.log('scroll', `8a. Attempt ${attempts}: Scrolled to Hash Target. Y is now ${window.scrollY}`);
       }
     } else {
       window.scrollTo(0, target);
-      console.log(`[RT-Scroll] 8b. Attempt ${attempts}: Scrolled to Y=${target}. Current Y is ${window.scrollY}`);
+      debug.log('scroll', `8b. Attempt ${attempts}: Scrolled to Y=${target}. Current Y is ${window.scrollY}`);
     }
 
     let is_successful = false;
     }
 
     if (is_successful && document.body.scrollHeight > 1000) { 
-       console.log(`[RT-Scroll] 9. Viewport anchored successfully.`);
+       debug.log('scroll', `9. Viewport anchored successfully.`);
        
-       // Hold the line against native browser hash jumping
        setTimeout(() => {
          if (!use_hash && Math.abs(window.scrollY - target) >= 5) {
-             console.log(`[RT-Scroll] 9a. Browser late-stage rebellion detected. Re-enforcing.`);
+             debug.log('scroll', `9a. Browser late-stage rebellion detected. Re-enforcing.`);
              enforce_scroll(target, use_hash, attempts + 1);
          } else {
              is_layout_locked = false;
-             console.log("[RT-Scroll] 10. Layout fully unlocked.");
+             debug.log('scroll', "10. Layout fully unlocked.");
          }
        }, 100);
     } else {
     clearTimeout(scroll_timer);
     scroll_timer = setTimeout(() => {
       sessionStorage.setItem('RT_saved_y', window.scrollY);
-      console.log(`[RT-Scroll] X. User stopped scrolling. Saved Y: ${window.scrollY}`);
+      debug.log('scroll', `X. User stopped scrolling. Saved Y: ${window.scrollY}`);
     }, 200);
   }, { passive: true });
 
   window.addEventListener('beforeunload', () => {
     is_layout_locked = true;
-    console.log("[RT-Scroll] Y. Page unloading. Scroll listener locked.");
+    debug.log('scroll', "Y. Page unloading. Scroll listener locked.");
   });
 
   // 10. Bind to DOM Ready