PageSourceSearch

https://nycsca.org/DesktopModules/NYCSCA/NYCSCA_File_Listing/resources/js/filelist-controller.js?cdv=1257

js nycsca.org collected 2026-10-02 06:54:54 UTC 14,081 bytes, 369 lines download raw bytes

1//Accordian logic - start
2function close_accordion_section(sectionPrefix) {
3    $("div[id^='" + sectionPrefix + "']").removeClass('active');
4    $("div[id^='" + sectionPrefix + "']").slideUp(300).removeClass('open');
5}
6
7function OpenFirst(moduleId, accordId) {
8
9    var sectionId       = accordId.substring(accordId.lastIndexOf('-') + 1);
10    var sectionPrefix   = "accordion-";
11    var itemId          = sectionPrefix + moduleId + "-";
12    
13    $("#" + itemId + sectionId).addClass('active');
14
15    // Open up the hidden content panel
16    $("#" + itemId + sectionId).show().addClass('open');
17
18    $("#" + itemId + sectionId).children("div").each(function () {
19        $(this).children('div').each(function () {
20            var subId = $(this).attr('id');
21            if (subId !== undefined) {
22                ActivateAccordian(moduleId, subId, true);
23            }
24        })
25            
26        }
27     );
28}
29
30function ActivateAccordian(moduleId, accordId, isSubsection) {
31    var sectionId           = accordId.substring(accordId.lastIndexOf('-') + 1);
32    var sectionPrefix       = !isSubsection ? "accordion-" : "accordion-subsection-";
33    var itemId              = sectionPrefix + moduleId + "-";
34
35
36    if ($("#" + itemId + sectionId).is('.active')) {
37        //closes an open section if it clicked
38        $("#" + itemId + sectionId).removeClass('active');
39        $("#" + itemId + sectionId).slideUp(300).removeClass('open');
40    } else {
41        close_accordion_section(itemId);
42        // Add active class to section title
43        $("#" + itemId + sectionId).addClass('active');
44        // Open up the hidden content panel
45        $("#" + itemId + sectionId).slideDown(300).addClass('open');
46    }
47}
48//Accordian logic - end
49
50// Controller Definition
51var $nycsca_fl = $nycsca_fl || {};
52
53var __fl_modId = "";
54
55$nycsca_fl.FileListController = function FileListController($http, $log, $window, $sce, AppServiceFramework) {
56
57    // Set vm to the scope of this controller
58    var vm = this;
59    // Set API base url
60    var serviceRoot = AppServiceFramework.getServiceRoot('FileList');
61    // Scope binding variables
62    vm.FileList = [];
63    
64    vm.getListings = function (moduleId) {
65        
66        var resTopics       = GetSelectedTopics_FL(moduleId);
67        var letter          = GetSelectedLetter_FL(moduleId, "", false);
68        var category        = GetListCategory_FL(moduleId);
69        var viewType        = GetListViewType_FL(moduleId);
70        var isEdit          = GetEditMode_FL(moduleId);
71
72        //console.log("File Listing: " + serviceRoot + 'FileList/getlistings?catName=' + category + "&viewType=" + viewType + '&resTopicFilter=' + resTopics + "&ltrFilter=" + letter);
73        $http.get(serviceRoot + 'FileList/getlistings?catName=' + category + "&viewType=" + viewType + '&resTopicFilter=' + resTopics + "&ltrFilter=" + letter + "&editMode=" + isEdit)
74            .success(function (response) {
75                vm.FileList = response;
76                //console.log("Found: " + response.length);
77                //expand first and set topics
78                var t = setTimeout(function (l) {
79                    return function () { ExpandAccordionFirst(l) }
80                }(moduleId), 300);
81                var st = setTimeout(function (s) {
82                    return function () { SetSelectedTopics_FL(s) }
83                }(moduleId), 100);
84            })
85            .error(function (errorPayload) {
86                $log.error('failure loading documents', errorPayload);
87            });
88    }
89
90    vm.NextState = function (moduleId, item) {
91        $http.get(serviceRoot + 'FileList/nextstate?ID=' + item.ID + '&VersionId=' + item.VersionId)
92                .success(function (response) {
93                    if (response != '\"success\"') {
94                        alert(response);
95                    } else {
96                        vm.getListings(moduleId);
97                    }
98                })
99                .error(function (errorPayload) {
100                    alert('Error: ' + errorPayload);
101                    $log.error('failure moving file listing to next state', errorPayload);
102                });
103
104    }
105
106    vm.UpdateOrder = function () {
107        UpdateSections();
108        ResetSorting();
109    }
110
111    function ResetSorting() {
112        vm.initSorting(__fl_modId);
113    }
114
115    function UpdateSections() {
116        $("input[id^='section_order_new_']").each(function () {
117            var itemId = $(this).prop('id').replace('section_order_new_', '');
118            var origId = $(this).prop('id').replace('_new_', '_orig_');
119            var origValue = $("#" + origId).val();
120
121            if ($(this).val() != origValue) {
122                $http.put(serviceRoot + 'FileList/updatesectionorder?ItemId=' + itemId + "&itemOrder=" + $(this).val())
123                    .success(function (response) {
124
125                    })
126                    .error(function (errorPayload) {
127                        $log.error('failure loading documents', errorPayload);
128                    });
129            }
130        });
131
132        $("input[id^='sectionfile_order_new_']").each(function () {
133            var itemId = $(this).prop('id').replace('sectionfile_order_new_', '');
134            var origId = $(this).prop('id').replace('_new_', '_orig_');
135            var origValue = $("#" + origId).val();
136
137            if ($(this).val() != origValue) {
138                $http.put(serviceRoot + 'FileList/updatefileorder?ItemId=' + itemId + "&itemOrder=" + $(this).val())
139                    .success(function (response) {
140
141                    })
142                    .error(function (errorPayload) {
143                        $log.error('failure loading documents', errorPayload);
144                    });
145            }
146        });
147    }
148
149    vm.filterbySection = function (moduleId, modFilter, sectionId) {
150        //alert(moduleId);
151        var resTopics       = GetSelectedTopics_FL(moduleId);
152        var letter          = GetSelectedLetter_FL(moduleId, "", false);
153        var category        = GetListCategory_FL(moduleId);
154        var viewType        = GetListViewType_FL(moduleId);
155        var isEdit          = GetEditMode_FL(moduleId);
156
157        $http.get(serviceRoot + 'FileList/getlistings?catName=' + category + "&viewT
157ype=" + viewType + '&resTopicFilter=' + resTopics + "&ltrFilter=" + sectionId + "&editMode=" + isEdit)
158            .success(function (response) {
159                vm.FileList = response;
160                
161                var t = setTimeout(function (l) {
162                    return function () { ExpandAccordionFirst(l) }
163                }(moduleId), 300);
164                var st = setTimeout(function (s) {
165                    return function () { SetSelectedTopics_FL(s) }
166                }(moduleId), 100);
167            })
168            .error(function (errorPayload) {
169                $log.error('failure loading documents', errorPayload);
170            });
171    }
172
173    vm.getCategoryListings = function (moduleId, category) {
174        //alert(moduleId);
175        viewType    = '0';
176        resTopics   = '';
177        sectionId   = '999';
178        var isEdit  = "false"; //GetEditMode_FL(moduleId);
179
180        $http.get(serviceRoot + 'FileList/getlistings?catName=' + category + "&viewType=" + viewType + '&resTopicFilter=' + resTopics + "&ltrFilter=" + sectionId + "&editMode=" + isEdit)
181            .success(function (response) {
182                vm.FileList = response;
183
184            })
185            .error(function (errorPayload) {
186                $log.error('failure loading documents', errorPayload);
187            });
188    }
189
190    vm.filterbyLetter = function (moduleId, ltr) {
191        var resTopics       = GetSelectedTopics_FL(moduleId);
192        var letter          = GetSelectedLetter_FL(moduleId, ltr, true);
193        var category        = GetListCategory_FL(moduleId);
194        var viewType        = GetListViewType_FL(moduleId);
195        var isEdit          = GetEditMode_FL(moduleId);
196
197        setTimeout(SetSelectedTopics_FL, 100);
198
199        $http.get(serviceRoot + 'FileList/getlistings?catName=' + category + "&viewType=" + viewType + '&resTopicFilter=' + resTopics + "&ltrFilter=" + letter + "&editMode=" + isEdit)
200            .success(function (response) {
201                vm.FileList = response;
202
203                var t = setTimeout(function (l) {
204                    return function () { ExpandAccordionFirst(l) }
205                }(moduleId), 300);
206            })
207            .error(function (errorPayload) {
208                $log.error('failure loading documents', errorPayload);
209            });
210    }
211
212    var winListingExtensions = ['DOC', 'DOCX', 'ZIP', 'XLS', 'XLSX', 'ZIP', 'TXT'];;
213
214    vm.collapseSection = function (sectionId) {
215        alert(sectionId);
216    }
217
218    vm.openFileById = function (item) {
219        var fileExt     = item.FileExtension.toUpperCase();
220
221        if (item.ID == -1) {
222            alert('File not found.');
223            return;
224        }
225
226        var newWindow       = [];
227        var html            = "<div>Loading File</div>";
228
229        if ($.inArray(fileExt, winListingExtensions) === -1) {
230            newWindow = window.open();
231            $(newWindow.document.body).html(html);
232        }
233
234        $http.get(serviceRoot + 'FileList/getfilebyid?ItemId=' + item.DNNFileId)
235           .success(function (response) {
236
237               if ($.inArray(fileExt, winListingExtensions) === -1)
238                   newWindow.location = response.Path;
239               else
240                   window.open(response.Path, '_self');
241           })
242           .error(function (errorPayload) {
243               html = "<div>Error Loading File: " + item.FileName + " ID: " + item.DNNFileId + "</div>";
244               $(newWindow.document.body).html(html);
245
246               $log.error('failure loading documents', errorPayload);
247           });
248    }
249
250    vm.editAward = function (vm) {
251        // open module Edit view passing projectid 
252        vm.baseEditUrl + '/prjid/' + proj.ProjectId;
253    }
254
255    vm.deleteFileListing = function (moduleId, item) {
256        var itemType = "F";
257
258        if (item.FileName == undefined) {
259            itemType = "S";
260        }
261        
262        if (item.ID == 0)
263        {
264            alert("Cannot delete this record.");
265        } else {
266            var itemId = item.ID;
267            if (confirm('Delete this listing?')) {
268                $http.delete(serviceRoot + 'FileList/deletelisting?ModuleId=' + moduleId + '&ItemId=' + itemId + "&ItemType=" + itemType)
269                    .success(function (response) {
270                        vm.getListings(moduleId);
271                    })
272                    .error(function (errorPayload) {
273                        $log.error('failure deleting project', errorPayload);
274                    });
275            }
276        }
277    }
278
279    vm.init = function (moduleId) {
280        //alert(moduleId);
281        vm.getListings(moduleId);
282    }
283
284    vm.initSorting = function (moduleId) {
285            __fl_modId      = moduleId;
286        var catFieldName    = "_EditSorting_hidNycscaCategory_FileListingSorting";
287        var catId           = $("input[id$='ctr" + moduleId + catFieldName + "']").val();
288        
289        vm.getCategoryListings(moduleId, catId);
290    }
291}
292
293var __topicsListField_FL        = "_View_hidNycscaTopicFilter_FileList";
294var __ltrListField_FL           = "_View_hidNycscaLetterFilter_FileList";
295var __catListField_FL           = "_View_hidNycscaCategory_FileList";
296var __viewListField_FL          = "_View_hidNycscaViewType_FileList";
297var __expandFirstListField_FL   = "_View_hidNycscaExpandAccordian_FileList";
298var __editModeField_FL          = "_View_hidNycscaIsEdit_FileList";
299
300//Gets the category from a hidden field
301function GetListCategory_FL(moduleId) {
302    return $("input[id$='ctr" + moduleId + __catListField_FL + "']").val();
303}
304
305//Gets the viewtype (page layout) from a hidden field
306function GetListViewType_FL(moduleId) {
307    return $("input[id$='ctr" + moduleId + __viewListField_FL + "']").val();
308}
309
310
311//Gets the viewtype (page layout) from a hidden field
312function GetEditMode_FL(moduleId) {
313    return $("input[id$='ctr" + moduleId + __editModeField_FL + "']").val();
314}
315
316
317//Gets/Sets hidden field with selected letter
318function GetSelectedLetter_FL(moduleId, ltr, setLtr) {
319    if (setLtr === true)
320        $("input[id$='ctr" + moduleId + __ltrListField_FL + "']").val(ltr);
321    else
322        ltr = $("input[id$='ctr" + moduleId + __ltrListField_FL + "']").val();
323
324    return ltr;
325}
326
327//Cycles trhough the checkboxes and gets selected values
328function GetSelectedTopics_FL(moduleId) {
329    return $("input[id$='ctr" + moduleId + __topicsListField_FL + "']").val();
330}
331
332function SetSelectedTopics_FL(moduleId) {
333    var topics = [];
334    
335    try {
336        topics = $("input[id$='ctr" + moduleId + __topicsListField_FL + "']").val().split('|');
337    } catch (ex) { console.log("error splitting topics field:" + "input[id$='ctr" + moduleId + __topicsListField_FL + "']"); }
338
339    for (var t = 0; t < topics.length; t++) {
340        $("input[id='chkTag_" + topics[t] + "']").each(function () {
341            $(this).prop('checked', true);
342        });
343    }
344}
345
346//Expands first topic in an accordian
347function ExpandAccordionFirst(moduleId)
348{
349    var exp = $("input[id$='ctr" + moduleId + __expandFirstListField_FL + "']").val();
350    
351    if (exp === "True") {
352        $("a[id^='accordion-" + moduleId + "-title']").each(function (index, element) {
353            if (index === 0)
354             OpenFirst(moduleId, $(this).attr('id'))
355        });
356    }
357}
358
359function showSectionFiles(sectionId) {
360    alert(sectionId);
361}
362
363//closes window if the file is a download
364function UnloadWindow(w, html) {
365    if ($(w.document.body).html() === html)
366        w.close();
367    else
368        w.focus();
369}

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.