PageSourceSearch

https://members.acera.org/Scripts/Common.js

js acera.org collected 2026-09-25 23:33:49 UTC 5,787 bytes, 193 lines download raw bytes

1var skipToggleEvent = false;
2
3/// <summary>
4/// Function to toggle the display of the given item between block and none.
5/// </summary>
6function toggleBlockDisplay(id)
7{
8    var el = document.getElementById(id);
9    
10    if (el != null)
11    {
12        el.style.display = (el.style.display == 'block') ? 'none' : 'block';
13        el.style.marginLeft = '-15px';
14        
15        return el.style.display == 'block';
16    }
17    
18    return false;
19}
20
21/// <summary>
22/// Called when the graphic next to the node is clicked
23/// </summary>
24function OnSideNavigationToggle(node)
25{
26    if (!skipToggleEvent)
27    {      
28        if (node.Expanded == 0 || node.Expanded == false)
29        {
30            AjaxCallbacks.SetSideNavigationItemExpanded(node.Value, false, null, OnFailed);
31        }
32        else    
33        {
34            AjaxCallbacks.SetSideNavigationItemExpanded(node.Value, true, null, OnFailed);
35        }
36    }
37    else
38    {
39        skipToggleEvent = false;
40    }
41}
42
43/// <summary>
44/// Called when a collapsible panel is being clicked to toggle its state.
45/// </summary>
46function toggleCollapsePanel(item, collapseID)
47{   
48    if (item != null)
49    {
50        var viewDiv = item.nextSibling;
51        if (viewDiv != null)
52        {
53            viewDiv.style.display =  (viewDiv.style.display == 'block' || viewDiv.style.display == '') ? 'none' : 'block';
54            
55            var imageDiv = item.getElementsByTagName('DIV')[0];
56            if (imageDiv != null)
57            {             
58                imageDiv.className = ((viewDiv.style.display == 'block') ? 'collapsablePanelImageExpanded' : 'collapsablePanelImageCollapsed')
59            }
60            
61            AjaxCallbacks.SetPanelExpanded(collapseID, (viewDiv.style.display == 'block'), null, OnFailed);            
62        }
63    }
64}
65
66/// <summary>
67/// Creates a function like c#'s string.format.  Can be called like:
68///    var tempString = 'this is a {0}.';
69//     alert(tempString.format('test');
70/// </summary>
71String.prototype.format = function() 
72{
73  var params = String.prototype.format.arguments;
74  var toReturn = this;
75
76  for (var i = 0; i < params.length; i++) 
77  {
78    var regex = new RegExp("\\{" + i + "\\}", "g");
79    toReturn = toReturn.replace(regex, params[i]);
80  }
81
82  return toReturn;
83}
84
85/// <summary>
86/// Just like toggleBlockDisplay, except targeted towards the trace output.  Needed to 
87/// be this way because browser css couldn't select the #__traceoutput id, but can select the
88/// tracecontent class.
89/// </summary>
90function toggleTraceDisplay()
91{
92    var el = document.getElementById('__asptrace');
93    
94    if (el != null)
95    {
96        var styleBlock = el.firstChild;
97        if (styleBlock != null)
98        {
99            var traceSpan = styleBlock.nextSibling;
100            
101            traceSpan.style.display = (traceSpan.style.display == 'block') ? 'none' : 'block';
102        }
103    }       
104}
105
106/// <summary>
107/// Synchronizes a partner drop down selection with the same key
108/// </summary>
109function syncPartnerDropDown(owner,partnerName)
110{
111  var index = owner.id.lastIndexOf("_");
112  if  (index != -1)
113  {
114     fullPartnerName = owner.id.substring(0,index + 1);
115  }
116  fullPartnerName += partnerName;
117  partner = document.getElementById(fullPartnerName);
118
119  var key = owner[owner.selectedIndex].value;
120  for (wsub = 0;wsub < partner.options.length;wsub++)
121  {
122    if  (partner[wsub].value == key)
123    {
124      partner.selectedIndex = wsub;
125      break;
126    }
127  }
128  return;
129}
130
131// Used in the wizards when a postback might take a while, and you don't want the
132// user to be able to click a navigation button while they are waiting.
133function showWizardProcessing()
134{
135    document.getElementById('wizardNavigation').disabled = true; 
136    document.getElementById('wizardContent').style.cursor = 'wait';
137}
138
139/// <summary>
140/// Called when an error occurs and refreshes the users screen
141/// </summary>
142function OnFailed(error, userContext, methodName) 
143{ 
144    window.location.href = window.location.href;
145}
146
147/// <summary>
148/// Hanlde the notification error more gracefully
149/// </summary>
150function OnNotificationFailed(error, userContext, methodName) {
151    alert('An unknown error occurred. Please try again.');
152}
153
154/// <summary>
155/// Called when the Quick Search node is clicked
156/// </summary>
157function SetQuickSearchExpanded(flag)
158{
159    AjaxCallbacks.SetQuickSearchExpanded(flag, null, OnFailed);
160}
161
162/**
163 * Determine if n is a number
164 */
165function IsNumber(n) {
166    return !isNaN(parseFloat(n)) && isFinite(n);
167}
168
169/**
170 * Add the contents of provided textboxes, putting the result in resultTextBox
171 */
172function SumTextBoxes(resultTextBox) {
173    // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments#defining_a_function_that_concatenates_several_strings
174    let textboxes = Array.prototype.slice.call(arguments, 1);
175
176    // https://stackoverflow.com/questions/1230233/how-to-find-the-sum-of-an-array-of-numbers/43363105#43363105
177    resultTextBox.val(textboxes.reduce((accumulator, textbox) => accumulator + (IsNumber(textbox.val()) ? parseFloat(textbox.val()) : 0), 0).toFixed(2));
178}
179
180/**
181 * Register the input event of provided textboxes to put their sum in resultTextBox
182 */
183function RegisterSumTextBoxes(resultTextBox) {
184    let args = Array.prototype.slice.call(arguments);
185    let textboxes = args.slice(1);
186
187    textboxes.forEach(textbox => {
188        textbox.on('input', function () {
189            // https://stackoverflow.com/questions/3914557/passing-arguments-forward-to-another-javascript-function/3914600
190            SumTextBoxes.apply(null, args);
191        });
192    });
193}

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.