PageSourceSearch

https://go.threeriversparks.org/ThreeRiversWeb/scripts/AdvanceFacilityAvailibilityGrid.js?v1.0.3

js threeriversparks.org collected 2026-09-24 09:19:48 UTC 11,477 bytes, 331 lines download raw bytes

1
2var selectedUnitId = null;
3var columnDates = new Array();
4var rowUnits = new Array();
5var cellClientIds = new Array();
6
7var selectionStartIndex = -1;
8var selectionCount = 1;
9
10var htmlArrivalDate = null;
11var htmlUnitId = null;
12var htmlNightsDropDown = null;
13
14var htmlOnlyShowAvailable = null;
15
16// void selNights_click(object sender)
17// Callback activated when the user changes the drop down box.
18function selNights_change(sender) {
19    if (sender == null) {
20        return;
21    }
22
23    var count = parseInt(sender.value);
24
25    unitGrid_changeSelectionBounds(selectionStartIndex, count);
26
27    // DO POSTBACK IF 'SHOW ONLY AVAILABLE' IS CHECKED
28    if (htmlOnlyShowAvailable != null && htmlOnlyShowAvailable.checked) {
29        document.aspnetForm.submit();
30    }
31}
32// void bAvailabilityCell_click(int column, int row)
33// Callback activated when the user clicks a cell in the availability grid.
34function bAvailabilityCellUnNumber_click(column, row) {
35
36    //alert("bAvailabilityCell_click(" + column + ", " + row + ")");
37
38    var date = columnDates[column];
39    //alert(date);
40
41    updategrid(date);
42    var unitId = rowUnits[row];
43
44    var index = unitGrid_mapXYCoordToCellIndex(column, row);
45
46    var clientId = cellClientIds[index];
47    selectedUnitId = unitId;
48    $('input[id*="txtUnitID"]').val(unitId);
49    //document.getElementById('<%= txtUnitID.ClientID %>').value = unitId;
50    //alert("Selecting cell - Date '" + date + "', UnitId '" + unitId + "', and/or ClientId '" + clientId + "'.");
51
52    if (date == null || unitId == null || clientId == null) {
53
54        return;
55    }
56    selectionCount = $("#Grid_ddlNights").val();
57    unitGrid_changeSelectionBoundsUnNumber(index, selectionCount);
58}
59
60// void unitGrid_mapXYCoordToCellIndex(int x, int y)
61// Maps the given X-Y coordinate into an index that represents that cell in the matrix.
62function unitGrid_mapXYCoordToCellIndex(x, y) {
63    return (y * columnDates.length) + x;
64}
65
66// void unitGrid_mapCellIndexToXYCoord(int cellIndex)
67// Maps the given cell index into an X-Y coordinate that represents that cell in the matrix.   
68function unitGrid_mapCellIndexToXYCoord(cellIndex) {
69    var y = Math.floor(cellIndex / columnDates.length);
70    var x = cellIndex % columnDates.length;
71
72    var coord = new Object();
73
74    coord.X = x;
75    coord.Y = y;
76
77    return coord;
78}
79
80// void unitGrid_changeSelectionBounds(int startIndex, int count)
81// Changes the selection to the start index and count requested.
82function unitGrid_changeSelectionBoundsUnNumber(startIndex, count) {
83    //alert("unitGrid_changeSelectionBounds(" + startIndex + ", " + count + ")");
84
85    //if (selectionStartIndex == startIndex && selectionCount == count)
86    //{
87    //    return;
88    //}  
89
90    //alert("Changing selection to start index " + startIndex + " and count " + count);
91
92    // UNSELECT ALL OF THE PREVIOUS SELECTION, IF SPECIFIED        
93    if (selectionStartIndex != -1) {
94        // ONLY SELECT CELLS ON THE SAME ROW
95        var endIndex = unitGrid_retrieveLastSameIndexOnRowUnNumber(selectionStartIndex, selectionCount);
96
97        //alert("The previous last index on this same row is index " + endIndex);
98
99        unitGrid_deselectCellsUnNumber(selectionStartIndex, endIndex);
100    }
101     
102    selectionCount = count;
103
104    // DO NOT SELECT ANYTHING IF THE INDEX IS NOT REAL
105    if (startIndex == null || startIndex < 0) {
106        return;
107    }
108
109    // ASSIGN SELECTED       
110    selectionStartIndex = startIndex;
111
112    if (htmlArrivalDate == null || htmlUnitId == null) {
113        alert("Error: The ArrivalDate ASP.NET control or the UnitId ASP.NET control was not found.");
114
115        return;
116    }
117
118    var coord = unitGrid_mapCellIndexToXYCoord(startIndex);
119
120    if (coord == null) {
121        alert('Error: Unable to map cell index to XY coordinate!');
122
123        return;
124    }
125
126    var date = columnDates[coord.X];
127    var unitId = rowUnits[coord.Y];
128
129    htmlArrivalDate.val(date);
130    htmlUnitId.value = unitId;
131
132    // GET THE LAST INDEX TO SELECT       
133    var endIndex = unitGrid_retrieveLastSameIndexOnRowUnNumber(startIndex, count);
134    $('input[id*="hdnnotavailableunit"]').val("0");
135    unitGrid_selectCellsUnNumber(startIndex, endIndex);
136}
137
138// void unitGrid_selectCells(int startIndex, int endIndex)
139// Selects all grid cells in the matrix specified by the starting and end bounds of the cells, inclusive.
140function unitGrid_selectCellsUnNumber(startIndex, endIndex) {
141    if (startIndex < 0) {
142        return;
143    }
144
145    //alert("Selecting cells from index " + startIndex + " to " + endIndex);
146
147    for (var index = startIndex; index <= endIndex; index++) {
148        var clientId = cellClientIds[index];
149        
150        if (clientId == null) {
151            //alert("Error: The cell at index " + index + " does not exist.");
152
153            return;
154        }
155
156
157        var htmlGridCell = $("." + clientId);
158        //var selectedHex = htmlGridCell.attr("class").split(' ')[0];
159        if (htmlGridCell.attr("class") == undefined)
160        {
161            $('input[id*="hdnnotavailableunit"]').val("3");
162            IsNotAvailable = 0;
163            return true;
164        }
165        var selectedHex = htmlGridCell.attr("class").split(' ');
166        if (selectedHex.length == 0) {
167            selectedHex = htmlGridCell.attr("class");
168        } else {
169            selectedHex = htmlGridCell.attr("class").split(' ')[0];
170        }
171        $('input[id*="hdnnotavailableunit"]').val("");
172
173        if (selectedHex == "green_bg_tab") {
174            // AVAILABLE (GREEN)
175            advancegridcellHex.css("background-color", "rgb(134, 163, 85)");
176            advancegridcellHex.css("color", "#ffffff");
177        }
178        if (selectedHex == "lottery-img") {
179            // AVAILABLE (GREEN)
180            htmlGridCell.css("background-color", "#ffdf5d");
181            htmlGridCell.css("color", "#ffffff");
182        }
183        if (selectedHex == "cancel-img1") { // NOT AVAILABLE (RED)
184            //htmlGridCell.style.backgroundColor = "#ffdfd2";
185            //htmlGridCell.style.color = "#000000"
186            // htmlGridCell.css("background-color", "#ff0000");
187            // htmlGridCell.css("color", "#ffffff");
188
189            $('input[id*="hdnnotavailableunit"]').val("1");
190        }
191        if (selectedHex == "gray-img") {
192            // NO WEB BOOKING (Grey round icon)
193            //htmlGridCell.style.backgroundColor = "#ffdaab";
194            //htmlGridCell.style.color = "#000000"
195            // htmlGridCell.css("background-color", "#ff8b00");
196            // htmlGridCell.css("color", "#ffffff");
197
198        }
199        if (selectedHex == "blue_brd_box_not") {
200            htmlGridCell.css("background-color", "rgb(134, 163, 85)");
201            htmlGridCell.css("color", "#ffffff");
202            //$("#" + advancegridcellId + " i").css("border-bottom", "none");
203            if (IsNotAvailable == 0)
204                $('input[id*="hdnnotavailableunit"]').val("2");
205        }
206
207        if (selectedHex == "blue_brd_box") {
208            $('input[id*="hdnnotavailableunit"]').val("0");
209            //htmlGridCell.css("background-color", "rgb(134, 163, 85)");
210            //htmlGridCell.css("color", "#ffffff");
211            htmlGridCell.attr('style', " background-color:rgb(72, 76, 16) !important; color:#ffffff;");
212            if (IsNotAvailable == 0)
213                $('input[id*="hdnnotavailableunit"]').val("2");
214        }
215        if (selectedHex == "yellow_brd_box") {
216            $('input[id*="hdnnotavailableunit"]').val("1");
217            IsNotAvailable = 1;
218        }
219        if (selectedHex == "red_brd_box") {
220            $('input[id*="hdnnotavailableunit"]').val("3");
221            IsNotAvailable = 1;
222        }
223
224    }
225
226}
227
228// void unitGrid_deselectCells(int startIndex, int count)
229// Deselects all grid cells in the matrix specified by the starting and end bounds of the cells, inclusive.   
230function unitGrid_deselectCellsUnNumber(startIndex, endIndex) {
231    //alert("unitGrid_deselectCells(" + startIndex + ", " + endIndex + ")");
232
233    if (startIndex == null) {
234        return;
235    }
236
237    for (var index = startIndex; index <= endIndex; index++) {
238        var clientId = cellClientIds[index];
239
240        if (clientId == null) {
241            //alert("Error: The cell at index " + index + " does not exist.");
242
243            return;
244        }
245
246        //alert("Selecting client id '" + clientId + "'");
247
248        var htmlGridCell = $("." + clientId);
249        if (htmlGridCell.attr("class") == undefined) {
250            $('input[id*="hdnnotavailableunit"]').val("3");
251            IsNotAvailable = 1;
252            return true;
253        }
254        var selectedHex = htmlGridCell.attr("class").split(' ');
255        if (selectedHex.length == 0)
256        {
257            selectedHex = htmlGridCell.attr("class");
258        } else {
259            selectedHex = htmlGridCell.attr("class").split(' ')[0];
260        }
261        var advancegridcellHex = htmlGridCell.find("div");
262
263        if (selectedHex == "blue_brd_box") {
264            // AVAILABLE (GREEN)
265            //htmlGridCell.css("background-color", "#97e5a2");
266            //htmlGridCell.css("color", "#000000");
267            htmlGridCell.attr('style', " background-color:#09850E !important; color:#000000;")
268
269        }
270        if (selectedHex == "blue-img") {
271            // AVAILABLE (GREEN)
272            htmlGridCell.css("background-color", "white");
273            htmlGridCell.css("color", "#000000");
274
275        }
276        if (selectedHex == "lottery-img") {
277            // AVAILABLE (GREEN)
278            htmlGridCell.css("background-color", "white");
279            htmlGridCell.css("color", "#000000");
280
281        }
282        //
283        if (selectedHex == "cancel-img1") {
284            // AVAILABLE (GREEN)
285            htmlGridCell.css("background-color", "white");
286            htmlGridCell.css("color", "#000000");
287
288        }
289        if (selectedHex == "gray-img") {
290            // AVAILABLE (GREEN)
291            htmlGridCell.css("background-color", "white");
292            htmlGridCell.css("color", "#000000");
293
294        }
295
296    }
297}
298
299// int unitGrid_retrieveLastSameIndexOnRow(int startIndex, int count)
300// Retrieves the last index that is for the same unitid (same row) specified by the cell at the start index.
301function unitGrid_retrieveLastSameIndexOnRowUnNumber(startIndex, count) {
302    //alert("unitGrid_retrieveLastSameIndexOnRow(" + startIndex + ", " + count + ")");
303
304    var coord = unitGrid_mapCellIndexToXYCoord(startIndex);
305
306    if (coord == null) {
307        alert('Error: Unable to map cell index to XY coordinate!');
308
309        return;
310    }
311
312    var date = columnDates[coord.X];
313    var unitId = rowUnits[coord.Y];
314
315    var columnsUntilEnd = columnDates.length - coord.X - 1;
316
317    //alert('There are ' + columnsUntilEnd + ' columns until the end of the row.');
318
319    var endIndex;
320
321    if ((parseInt(coord.X) + parseInt(count)) <= columnDates.length) {
322        endIndex = unitGrid_mapXYCoordToCellIndex((parseInt(coord.X) + parseInt(count)) - 1, coord.Y);
323    }
324    else {
325        endIndex = unitGrid_mapXYCoordToCellIndex((parseInt(coord.X) + parseInt(columnsUntilEnd)), coord.Y);
326    }
327
328    //alert("The last index of this row that needs to be selected is " + endIndex);
329
330    return endIndex;
331}

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.