PageSourceSearch

https://pages.dmt.gov.ae/re-assets/js/TownHallInvitation.js?v=0.5

js dmt.gov.ae collected 2026-10-01 12:11:07 UTC 10,554 bytes, 225 lines download raw bytes

1$(document).ready(function () {
2    $(".section-loader").hide();
3    var key = $("#hdnSiteKey").val();
4    var formId = $("#townhallForm");
5    var requiredText = $("#RequiredText").val();
6    var correctEmailText = $("#CorrectEmail").val();
7    var formType = $("#formType").val();
8    var dataSource = $("#dataSource").val();
9    //var regClosingDate = $("#registrationClosingDate").val();
10    //var closedMessage = $("#closedMessage").val();
11    //var currentDate = new Date();
12    //var closingDate = new Date(regClosingDate);
13    var closingBtnHtml = "<div class='row'><div class='col-md-12 text-center pt-5'> <button href='javascript:' id='closeBtn' class='btn btn-primary'>" + $("#closeBtnTxt").val()+"</button></div></div>";
14
15    if ($("#townhall_view_all").length > 0) {
16        fetchTownhallData(formType, dataSource);
17    }
18    if ($("#townhallForm").length > 0) {
19        refresh();
20    }
21    //if (closingDate < currentDate) {
22    //    $("#closedMessage").show();
23    //    $("#townhallForm").hide();
24    //}
25
26    if ($(".townhall").length > 0) {
27        $(function () {
28            $('.dmt-heading').removeAttr("style");
29            $('.dmt-heading').addClass('townhall-heading');
30            $('.navheader').addClass('d-none');
31        });
32    }
33    function handleButtonClick() {
34        $("#successBoxx").hide()
35        refresh();
36    }
37
38    $("#btnSubmit").click(function () {
39        // jquery validation script by getting form name and there rules for validation
40        $("form[name='townhallResponse']").validate({
41            rules: {
42                name: 'required',
43                email: {
44                    required: true,
45                    email: true
46                },
47                title: 'required',
48                attendanceType: 'required',
49                department: 'required',
50                entity: 'required'
51            },
52            messages: {
53                name: requiredText,
54                email: {
55                    required: requiredText,
56                    email: correctEmailText
57                },
58                title: requiredText,
59                attendanceType: requiredText,
60                department: requiredText,
61                entity: requiredText,
62
63            },
64            errorClass: 'error',
65            validClass: 'valid',
66            errorElement: 'span',
67            // call function on submit of form
68            submitHandler: function () {
69                var formData = $("#townhallForm").serialize() + "&townhallResponse=" + $("#g-recaptcha-response").val() + "&attendanceTypeText=" + $('#attendanceType option:selected').text();
70                formData += "&DataSource=" + dataSource + "&FormType=" + formType;
71                if ($("#g-recaptcha-response").val() != "") {
72                    // $("#townhallForm").hide();
73                    $('.section-loader').css({ 'display': 'flex' });
74                    $.ajax({
75                        data: formData,
76                        type: 'post',
77                        url: '/api/feature/TownhallInvitation/RegisterTownhall',
78                        success: function (data) {
79                            if (data.status) {
80                                if (data.message == "data submitted successfully") {
81                                    $('.section-loader').css({ 'display': 'none' });
82                                    $("#successBoxx").html("");
83                                    $("#successBoxx").html($("#successMessage").val() + closingBtnHtml);
84                                    $("#successBoxx").show()
85                                    $(formId)[0].reset();
86                                }
87                                else {
88                                    $('.section-loader').css({ 'display': 'none' });
89                                    $("#successBoxx").html("");
90                                    $("#successBoxx").html($("#virtualMessage").val() + closingBtnHtml);
91                                    $("#successBoxx").show()
92                                    $(formId)[0].reset();
93                                }
94                                
95                            }
96                            else {
97                                if (data.message == "InvalidCaptcha" || data.message == "Enter the Captcha") {
98                                    $('.section-loader').css({ 'display': 'none' });
99                                    $("#successBoxx").html("");
100                                    $("#successBoxx").html('<div class="text-danger text-center">' + $("#capchaMessage").val() + '</div>' + closingBtnHtml);
101                                    $("#successBoxx").show()
102
103                                }
104                                else if (data.message == "selected entity limit reached") {
105                                    $('.section-loader').css({ 'display': 'none' });
106                                    $("#successBoxx").html("");
107                                    $("#successBoxx").html('<div class="text-danger text-center">' + $("#entityMessage").val() + '</div>' + closingBtnHtml);
108                                    $("#successBoxx").show()
109                                }
110                                else if (data.message == "this email is already registered") {
111                                    $('.section-loader').css({ 'display': 'none' });
112                                    $("#successBoxx").html("");
113                                    $("#successBoxx").html('<div class="text-danger text-center">' + $("#emailMessage").val() + '</div>' + closingBtnHtml);
114                                    $("#successBoxx").show()
115                                }
116                                else {
117                                    $('.section-loader').css({ 'display': 'none' });
118                                    $("#successBoxx").html("");
119                                    $("#successBoxx").html('<div class="text-danger text-center">' + $("#errorMessage").val() + '</div>' + closingBtnHtml);
120                                    $("#successBoxx").show()
121                                }
122                            }
123                            $('#successBoxx').on('click', '#closeBtn', handleButtonClick);
124
125                        },
126                        error: function (error) {
127                            $('.section-loader').css({ 'display': 'none' });
128                            //$("#townhallForm").show();
129
130                        }
131                    });
132                }
133                else {
134                    $('.section-loader').css({ 'display': 'none' });
135                    $("#successBoxx").html("");
136                    $("#successBoxx").html('<div class="text-danger text-center">' + $("#capchaMessage").val() + '</div>' + closingBtnHtml);
137                    $("#successBoxx").show()
138                    $('#successBoxx').on('click', '#closeBtn', handleButtonClick);
139
140                }
141
142            },
143            invalidHandler: function (event, validator) {
144                console.log('eee');
145            },
146            success: function () {
147                console.log('sdfsdfsdf');
148            }
149        });
150    });
151
152    function refresh() {
153        //grecaptcha.reset();
154        var recaptchaContainer = document.querySelector('.g-recaptcha');
155        var recaptchaParent = recaptchaContainer.parentNode;
156
157        var newRecaptchaContainer = document.createElement('div');
158        newRecaptchaContainer.className = 'g-recaptcha';
159        newRecaptchaContainer.setAttribute('data-sitekey', key);
160
161        recaptchaParent.replaceChild(newRecaptchaContainer, recaptchaContainer);
162
163        // Reload the reCAPTCHA widget script
164        var script = document.createElement('script');
165        if ($("#cultureType").val() == "en") {
166            script.src = 'https://www.google.com/recaptcha/api.js';
167        }
168        else {
169            script.src = 'https://www.google.com/recaptcha/api.js?hl=ar';
170        }
171        script.async = true;
172        script.defer = true;
173        document.head.appendChild(script);
174    }
175
176    function fetchTownhallData(formType, dataSource) {
177        $.ajax({
178            url: '/api/feature/TownhallInvitation/GetTownhallRegistrations',
179            type: 'GET',
180            data: {
181                formType: formType,
182                dataSource: dataSource
183            },
184            success: function (data) {
185                if (data.status) {
186                    var entitiesHTML = '';
187                    $.each(data.entitiesWithRemainingSeats, function (index, entity) {
188                        entitiesHTML += `
189                            <p style="display:none;"><strong>${entity.Entity}</strong> - Remaining Seats: ${entity.RemainingSeats}</p>
190                        `;
191                    });
192                    $('#entitySeatsContainer').html(entitiesHTML);
193
194                    var entriesHTML = '';
195                    if (data.entries && data.entries.length > 0) {
196                        $.each(data.entries, function (index, entry) {
197                            entriesHTML += `
198                                <tr>
199                                    <td style="display:none;">${entry.AttendanceType}</td>
200                                    <td>${entry.Name}</td>
201                                    <td>${entry.Email}</td>
202                                    <td>${entry.Title}</td>
203                                    <td>${entry.Department}</td>
204                                    <td style="display:none;">${entry.Entity}</td>
205                                    <td>${entry.Culture !== "en" ? "ar" : "en"}</td>
206                                </tr>
207                            `;
208                        });
209                        $('#townhalltable tbody').html(entriesHTML);
210                        $('#noRecordsMessage').hide();
211                    } else {
212                        $('#noRecordsMessage').show();
213                    }
214                } else {
215                    //alert(data.message);
216                    console.log(data.message);
217                }
218            },
219            error: function (error) {
220                //alert("Error fetching townhall data");
221                console.log("Error fetching townhall data");
222            }
223        });
224    }
225});

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.