PageSourceSearch

https://www.forgeandform.co/squall/js/squall.js

js forgeandform.co collected 2026-10-02 15:13:20 UTC 6,166 bytes, 233 lines download raw bytes

1
2var lastScroll = -100000;
3var subNavTop = -100000;
4var navTop = -100000;
5var cOffset = 0;
6
7function layout() {
8
9    docHighlight();
10    lastScroll = document.body.scrollTop;
11    onScroll();
12
13
14    loadIFrames();
15    if (window.location.hash) {
16        hideMenu();
17    }
18}
19
20function loadIFrames(){
21
22    var frames = document.getElementsByTagName("iframe");
23    console.log("frames", frames);
24    for (var i = 0; i < frames.length; i++) {
25        var frame = frames[i];
26        if (frame.attributes.loadsrc) {
27            frame.src = frame.attributes.loadsrc.value;
28        }
29    }
30
31}
32	
33function winSize() {
34  return {
35    width: (window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth),
36    height: (window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight)
37  };
38}
39
40$(document).ready(function(){
41  $('a[href*=#]').click(function() {
42    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
43    && location.hostname == this.hostname) {
44      var $target = $(this.hash);
45      $target = $target.length && $target
46      || $('[name=' + this.hash.slice(1) +']');
47      if ($target.length) {
48        var targetOffset = $target.offset().top;
49        $('html,body')
50        .animate({scrollTop: targetOffset}, 300);
51       return false;
52      }
53    }
54  });
55});
56
57function scrollNext(){
58    
59    var icons = document.getElementById("coverIcons");
60     var box = icons.getBoundingClientRect().top;
61    
62    
63    $('html,body').animate({scrollTop: box}, 300);
64}
65
66function setDocElementActive(doc) {
67	
68	var id = doc.getAttribute("docID");
69	var navList = window.document.getElementById("docNavList");
70	var active = navList.getElementsByClassName("active")[0];
71	if (active != doc) {
72		if (active) {
73		active.classList.remove("active");
74
75		}
76		
77		var docNav = window.document.getElementById("docNav"+id);
78		docNav.classList.add("active");
79		
80	}
81		
82}
83
84function docHighlight() { 
85	
86	var w = winSize();
87	var entries = window.document.getElementsByClassName("docEntry");
88	for (var index = 0; index < entries.length; index++) {
89		var entry = entries[index];
90		
91		var h = entry.getBoundingClientRect();
92		
93		var active = false;
94		if (h.bottom  >= 0.0 && h.bottom > w.height*0.5) {
95			setDocElementActive(entry);
96			break;
97		} else if (h.top >=0.0 && h.top < w.height * 0.5) {
98			setDocElementActive(entry);
99			break;
100			}
101				
102	}
103	
104}
105
106function softClamp(value, from, to, range, multi) {
107        var overflowMin = value-from;
108        
109        if (overflowMin<0.0) {
110            overflowMin = Math.abs(overflowMin)/range;
111            overflowMin = Math.max(Math.min(1.0, overflowMin), 0.0);
112            overflowMin = 1.0-(1.0-overflowMin)*(1.0-overflowMin);
113            
114            overflowMin *= multi;
115            value = from-overflowMin*range;
116        }
117        
118        var overflowMax = value-to;
119        overflowMax = Math.max(0.0, overflowMax)/range;
120        if (overflowMax>0.0) {
121            overflowMax = Math.max(Math.min(1.0, overflowMax), 0.0);
122            overflowMax = 1.0-(1.0-overflowMax)*(1.0-overflowMax);
123            overflowMax *= multi;
124            value = to+overflowMax*range;
125        }
126        
127        return value;    
128}
129
130function hideMenu(){
131    var navigation = document.getElementById("navigation");
132    var subNavigation = document.getElementById("subNavigation");
133
134    var box = navigation.getBoundingClientRect();
135
136    if (navigation) {
137        navigation.style.top = (-box.height).toString() + "px"; 
138    }
139
140    var subBox = subNavigation ? subNavigation.getBoundingClientRect() : {height : 0.0};
141    if (subBox) {
142        subBox.style.top = (-subBox.height).toString() + "px";
143    }
144}
145
146function driveMenu(){
147    
148    var cScroll = Math.max(document.body.scrollTop,0.0);
149    if (lastScroll == -100000) {
150        lastScroll = cScroll;
151    }
152    var diff = cScroll-lastScroll;
153    lastScroll = cScroll;
154    
155    var pauseScroll = 300.0;
156     
157    var navigation = document.getElementById("navigation");
158    var subNavigation = document.getElementById("subNavigation");
159    var box = navigation.getBoundingClientRect();
160    var subBox = subNavigation ? subNavigation.getBoundingClientRect() : {height : 0.0};
161     
162    var subStart = -subBox.height-pauseScroll;
163    var subStop = box.height-subBox.height;
164    
165    var subNavClampDistance = subBox.height/0.1;
166    
167    if (subNavTop == -100000) {
168        subNavTop = box.height+subNavClampDistance;
169    }
170    if (navTop == -100000) {
171        navTop = 0;
172    }
173    subNavTop = subNavTop - diff;
174    subNavTop = Math.min(Math.max((subNavTop),subStart),subStop+subNavClampDistance);
175    
176    var clamped = softClamp(subNavTop, subStart, subStop, subNavClampDistance, 0.1);
177    
178    if (subNavigation) {
179       subNavigation.style.top = clamped.toString() + "px";    
180    } 
181    
182    if (clamped < (box.height-subBox.height)) {
183        navTop = Math.min(Math.max((navTop - diff),-box.height-pauseScroll),0);
184        navigation.style.top = navTop.toString() + "px";    
185        
186    } else {
187        navTop = 0;
188        navigation.style.top = "0px";
189    }
190    
191    var docLeft = document.getElementById("documentationLeft");
192    if (docLeft && docLeft.style.display != "none") {
193        subBox = subNavigation ? subNavigation.getBoundingClientRect() : {height : 0.0, bottom : 0.0};
194        docLeft.style.top = (Math.max(subBox.bottom,0)).toString() + "px";
195    }
196    
197}
198
199function toggleMobileMenu(){
200    
201    $("#navigationCore").toggleClass("hideMobile");
202
203    
204}
205
206function setNavMenuStart() {
207    
208      var nav = document.getElementById("navigation");
209      var cScroll = document.body.scrollTop;
210      if (nav) {
211          if (cScroll <= 0) {
212               nav.classList.add("pageAtTop")
213               document.body.classList.add("pageAtTop")   
214          } else {
215                nav.classList.remove("pageAtTop")
216               document.body.classList.remove("pageAtTop")
217          }
218      }
219}
220
221function onScroll(){
222    
223    docHighlight();
224    driveMenu();
225    setNavMenuStart();
226}
227
228
229
230
231window.addEventListener("load", layout);
232window.addEventListener("scroll", onScroll);
233window.addEventListener("resize", onScroll);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.