PageSourceSearch

https://kit.ac.in/web-assets/angular/angularjs/controllers/cms-popup-controller.js?version=1782474992

js kit.ac.in collected 2026-09-30 10:02:11 UTC 14,636 bytes, 385 lines download raw bytes

1var csrfloginHash = $('#csrfloginHash').val();
2
3app.controller('homePopupServicesCtrl', function ($scope, $http, toastr, $location, $timeout) {
4    // add modal timeout handle
5    var qrModalTimeout = null;
6
7    $scope.homePopupInit = function () {
8        $scope.homePopupListArray = [];
9        $scope.gethomePopupList();
10
11        $scope.sectionAictInformationArray = [];
12        $scope.AictListArray = [];
13        $scope.getAictId();
14        let eventTitle = localStorage.getItem('eventTitle');
15        let evt_id = localStorage.getItem('evt_id');
16        let evt_valid_from = localStorage.getItem('evt_valid_from');
17        let evt_valid_till = localStorage.getItem('evt_valid_till');
18        let evt_time = localStorage.getItem('evt_time');
19        let eventSeats = localStorage.getItem('eventSeats');
20
21        $scope.eventTitle = eventTitle;
22        $scope.evt_id = evt_id;
23        $scope.evt_valid_from = evt_valid_from;
24        $scope.evt_valid_till = evt_valid_till;
25        $scope.evt_time = evt_time;
26        $scope.evt_seat_capacity = eventSeats;
27        $scope.seperator = "^%^";
28
29        $scope.applicationEvent = eventTitle;
30
31        $scope.registerForm = {
32            evt_id: evt_id,
33            evt_title: eventTitle,
34            evt_time: evt_time,
35            fullname: '',
36            mobile: '',
37            email: '',
38            category: '',
39            city: '',
40            consent: false
41        };
42
43        $scope.submitting = false;
44        $scope.registrationSuccess = false;
45        $scope.registrationError = false;
46        $scope.qrCodeData = null;
47        $scope.showQRCode = false;
48    }
49
50    $scope.createHtmlErrorDiv = function (message) {
51        return '<div class="error-message"><h4 style="color: red; font-size: small">' + message + '</h4></div>';
52    }
53
54    $scope.clearErrorMessages = function () {
55        $('.error-message').remove();
56    }
57
58    $scope.submitEventRegistration = function () {
59        $scope.clearErrorMessages();
60
61        if (!$scope.registerForm.fullname) {
62            document.getElementById("fullName").focus();
63            var getFullNameParent = $("#fullName").parent();
64            getFullNameParent.append($scope.createHtmlErrorDiv("Please enter full name"));
65            return;
66        }
67
68        if (!$scope.registerForm.mobile) {
69            document.getElementById("phoneNumber").focus();
70            var getMobileParent = $("#phoneNumber").parent();
71            getMobileParent.append($scope.createHtmlErrorDiv("Please enter mobile number"));
72            return;
73        }
74
75        if (!$scope.registerForm.category) {
76            document.getElementById("category").focus();
77            var getCategoryParent = $("#category").parent();
78            getCategoryParent.append($scope.createHtmlErrorDiv("Please select category"));
79            return;
80        }
81
82        if (!$scope.registerForm.consent) {
83            document.getElementById("consent").focus();
84            var getConsentParent = $("#consent").parent();
85            getConsentParent.append($scope.createHtmlErrorDiv("Please agree to privacy & terms"));
86            return;
87        }
88
89        $scope.submitting = true;
90        $scope.registrationSuccess = false;
91        $scope.registrationError = false;
92
93        var formData = new FormData();
94        formData.append("evt_id", $scope.registerForm.evt_id);
95        formData.append("evt_title", $scope.registerForm.evt_title);
96        formData.append("evt_time", $scope.registerForm.evt_time);
97        formData.append("fullname", $scope.registerForm.fullname);
98        formData.append("mobile", $scope.registerForm.mobile);
99        formData.append("email", $scope.registerForm.email);
100        formData.append("category", $scope.registerForm.category);
101        formData.append("city", $scope.registerForm.city);
102        formData.append("consent", $scope.registerForm.consent);
103
104        $http.post(window.site_url + 'FrontEndAPI/eventRegister', formData, {
105            headers: { 'Content-Type': undefined },
106            transformRequest: angular.identity
107        }).then(function (response) {
108            $scope.submitting = false;
109            if (response.data.status.status == "1" || response.data.status.status == "201") {
110                toastr.success(response.data.status.message);
111                $scope.registrationSuccess = true;
112                $scope.registrationError = false;
113
114                let registrationId = response.data.data.registration_id || response.data.data;
115                $scope.getRegistrationQRCode(registrationId);
116
117            } else {
118                toastr.error(response.data.status.message);
119                $scope.registrationSuccess = false;
120                $scope.registrationError = true;
121            }
122        }, function (error) {
123            $scope.submitting = false;
124            toastr.error("An error occurred while submitting your registration.");
125            $scope.registrationSuccess = false;
126            $scope.registrationError = true;
127        });
128    }
129    $scope.openPrivacyModal = function () {
130        $('#privacyModal').modal('show');
131    };
132    $scope.clearErrorMessages = function () {
133        $('.error-message').remove();
134    };
135
136    // ✅ New Function to Open Privacy Modal
137    $scope.openPrivacyModal = function () {
138        $('#privacyModal').modal('show');
139    };
140
141    $scope.getRegistrationQRCode = function (registration_id) {
142        $http.get(window.site_url + 'FrontEndAPI/getRegistrationQRCode/' + registration_id)
143            .then(function (response) {
144                if (response.data.status === '200') {
145
146                    $scope.qrCodeData = response.data.data || {};
147
148                    $scope.qrCodeData.ticket_id = ($scope.qrCodeData.ticket_id) ? $scope.qrCodeData.ticket_id : '';
149
150                    $http.get(window.site_url + 'FrontEndAPI/registrationPdf/' + registration_id)
151                        .then(function (pdfRes) {
152                            if (pdfRes.data && pdfRes.data.status == '200' && pdfRes.data.data && pdfRes.data.data.pdf_url) {
153                                $scope.qrCodeData.pdf_url = pdfRes.data.data.pdf_url;
154                            } else {
155                                $scope.qrCodeData.pdf_url = null;
156                            }
157                            $scope.showQRCodeModal();
158                        }, function (err) {
159                            $scope.qrCodeData.pdf_url = null;
160                            $scope.showQRCodeModal();
161                        });
162
163                    if ($scope.registerForm && $scope.registerForm.email) {
164                        // $scope.sendQRCodeEmail(registration_id);
165                    }
166                } else {
167                    toastr.error('Failed to generate QR code');
168                    $scope.registerFormInIt();
169                }
170            }, function (error) {
171                console.error('Error fetching QR code:', error);
172                toastr.error('Error generating QR code');
173                $scope.registerFormInIt();
174            });
175    }
176
177    $scope.sendQRCodeEmail = function (registration_id) {
178
179        $http.post(window.site_url + 'FrontEndAPI/sendQRCodeEmail', {
180            registration_id: registration_id,
181            email: $scope.registerForm.email
182        }).then(function (response) {
183            console.log('QR code email sent successfully');
184        }, function (error) {
185            console.error('Error sending QR code email:', error);
186        });
187    }
188
189    $scope.showQRCodeModal = function () {
190        // show modal
191        $('#qrCodeModal').modal('show');
192        $scope.showQRCode = true;
193
194        // clear any previous auto-close timer
195        if (qrModalTimeout) {
196            clearTimeout(qrModalTimeout);
197            qrModalTimeout = null;
198        }
199
200        // auto-close after 8 seconds (adjust as needed)
201        qrModalTimeout = setTimeout(function () {
202            // hide modal via Bootstrap API
203            $('#qrCodeModal').modal('hide');
204
205            // update scope safely
206            try {
207                $scope.$apply(function () {
208                    $scope.showQRCode = false;
209                });
210            } catch (e) {
211            }
212            qrModalTimeout = null;
213        }, 80000);
214    }
215
216    // ensure timer is cleared when modal is hidden (manual close or auto)
217    $('#qrCodeModal').on('hidden.bs.modal', function () {
218        if (qrModalTimeout) {
219            clearTimeout(qrModalTimeout);
220            qrModalTimeout = null;
221        }
222        // existing handler to reset form
223        $scope.$apply(function () {
224            $scope.registerFormInIt();
225        });
226    });
227
228    // optional precaution: if close button isn't triggering Bootstrap hide (rare), add explicit handler
229    $('#qrCodeModal .close, #qrCodeModal [data-dismiss="modal"]').off('click.autoHide').on('click.autoHide', function () {
230        $('#qrCodeModal').modal('hide');
231    });
232
233    $scope.downloadQRCode = function () {
234        if ($scope.qrCodeData && $scope.qrCodeData.qr_code_url) {
235            var link = document.createElement('a');
236            link.href = $scope.qrCodeData.qr_code_url;
237            link.download = 'event-registration-' + ($scope.qrCodeData.registration_id || 'ticket') + '.png';
238            document.body.appendChild(link);
239            link.click();
240            document.body.removeChild(link);
241            toastr.success('QR code downloaded successfully!');
242        }
243    }
244
245    $scope.downloadTicketPdf = function () {
246        if ($scope.qrCodeData && $scope.qrCodeData.pdf_url) {
247
248            window.open($scope.qrCodeData.pdf_url, '_blank');
249        } else {
250            toastr.error('PDF not available');
251        }
252    }
253
254    $('#qrCodeModal').on('hidden.bs.modal', function () {
255        $scope.$apply(function () {
256            $scope.registerFormInIt();
257        });
258    });
259
260    $scope.registerFormInIt = function () {
261        $scope.registerForm = {
262            evt_id: $scope.evt_id,
263            evt_title: $scope.eventTitle,
264            evt_time: $scope.evt_time,
265            fullname: '',
266            mobile: '',
267            email: '',
268            category: '',
269            city: '',
270            consent: false
271        };
272        $scope.registrationSuccess = false;
273        $scope.registrationError = false;
274        $scope.showQRCode = false;
275        $scope.qrCodeData = null;
276        $scope.submitting = false;
277        $scope.clearErrorMessages();
278
279        if ($scope.eventRegisterForm) {
280            $scope.eventRegisterForm.$setPristine();
281            $scope.eventRegisterForm.$setUntouched();
282        }
283    }
284
285    $scope.gethomePopupList = function () {
286        var transform = function (data) {
287            return $.param(data);
288        }
289        $http.post(window.site_url + 'FrontEndAPI/gethomePopupList', {
290            inputSearchValue: $scope.inputSearchValue,
291        }, {
292            headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
293            transformRequest: transform
294        }).then(function (response) {
295            if (response.data.status.status == "200") {
296                $scope.homePopupListArray = response.data.data;
297                $scope.PopupArrayShowupWise = [];
298                $scope.PopupArrayShowupWise = $scope.homePopupListArray.filter((data) => data.dp_show_on_website == 1);
299                console.log($scope.PopupArrayShowupWise);
300
301                if ($scope.PopupArrayShowupWise.length > 0) {
302                    OpenBootstrapPopup();
303                } else {
304                    HideBootstrapPopup();
305                }
306            } else {
307                toastr.error(response.data.status.message);
308            }
309        })
310    }
311
312    function OpenBootstrapPopup() {
313        $("#dynamicModal").modal('show');
314    }
315
316    function HideBootstrapPopup() {
317        $("#dynamicModal").modal('hide');
318    }
319    // Dynamic popup End
320
321
322    $scope.getAictId = () => {
323        var transform = function (data) {
324            return $.param(data);
325        }
326        $http.post(window.site_url + 'FrontEndAPI/getAICTId', {
327            'libraryUrl': $scope.libraryUrl,
328        }, {
329            headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
330            transformRequest: transform
331        }).then(function (response) {
332            if (response.data.status.status == "200") {
333                $scope.dsl_id_content = response.data.data[0].tal_id;
334                $scope.dsl_id_content = response.data.data[0].tal_id;
335                $timeout(() => {
336                    $scope.getAictSectionsWithContent();
337                    $(".breadcrumbTitle").html(" AICTE ");
338                    $(".breadcrumbPageTitle").html(" AICTE ");
339                }, 100);
340            } else {
341                toastr.error(response.data.status.message);
342            }
343        }, function (error) {
344            console.error('HTTP error in getAictId:', error);
345            toastr.error('Failed to fetch AICTE ID');
346        });
347    }
348
349    $scope.getAictSectionsWithContent = () => {
350        var transform = function (data) {
351            return $.param(data);
352        }
353        $http.post(window.site_url + 'FrontEndAPI/getAICTSection', {
354            'dsl_id': $scope.dsl_id_content,
355        }, {
356            headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
357            transformRequest: transform
358        }).then(function (response) {
359            if (response.data.status.status == "200") {
360                $scope.sectionAictInformationArray = response.data.data;
361                console.log('$scope.sectionAictInformationArray', $scope.sectionAictInformationArray);
362
363                $timeout(() => {
364                    if ($scope.sectionAictInformationArray && $scope.sectionAictInformationArray.length > 0) {
365                        $scope.sectionAictInformationArray[0].isActive = true;
366                        const firstTab = angular.element('#TabMenu0-left');
367                        if (firstTab.length) {
368                            firstTab.tab('show');
369                            console.log('First tab triggered for AICT section');
370                        } else {
371                            console.warn('First tab element #TabMenu0-left not found for AICT');
372                        }
373                    }
374                    $scope.$applyAsync();
375                }, 200);
376            } else {
377                toastr.error(response.data.status.message);
378            }
379        }, function (error) {
380            console.error('HTTP error in getAictSectionsWithContent:', error);
381            toastr.error('Failed to fetch AICTE sections');
382        });
383    }
384
385});

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.