PageSourceSearch

https://cornerstonebaptistchurch.org.uk/Publisher/form.js?SV=V136BK

js cornerstonebaptistchurch.org.uk collected 2026-10-03 18:59:49 UTC 12,931 bytes, 273 lines download raw bytes

1function doFormSubmission(elSubmitButton, strControlClientID) {
2    var bErrorActivated = false;
3    var strMandatoryErrorMessage = '';
4    var regexMandatory = new RegExp(" ", "g");
5    var regexEmail = new RegExp(strValidEmailRegex.replace(/&/g, '&'), "g");
6
7    function ActivateError(strElName, strErrorText, SPANerrorText) {
8        if (SPANerrorText) {
9            SPANerrorText.style.display = "block";
10            SPANerrorText.innerHTML = 'This ' + strErrorText;
11        } else {
12            strMandatoryErrorMessage = strMandatoryErrorMessage + '"' + strElName + '" ' + strErrorText + '<br>';
13        }
14        bErrorActivated = true;
15    }
16
17    var strClientID, strContainerID;
18    if (strControlClientID) {
19        strClientID = strControlClientID;
20        strContainerID = strClientID + '_elFormContents';
21    }
22    else {
23        if (!elSubmitButton) elSubmitButton = document.getElementById('ArticleSubmitButton');
24        strContainerID = $e(elSubmitButton).parents('[id$="_elFormContents"]').attr('id');
25        strClientID = strContainerID.replace('_elFormContents', '');
26    }
27
28    var strArticleID = document.getElementById(strClientID + '_FormDocumentID').value;
29
30    var form;
31    var $form = $e('#' + strContainerID + ' form.form-for-submission');
32    if ($form.length) 
33        $form.empty();
34    else
35        $form = $e('<form class="form-for-submission" />');
36    
37    form = $form.get(0);
38    
39    var blnCustomReplyTo = false;
40    var blnCustomSubject = false;
41    var arrRadioGroupsScanned = [];
42
43    $e('#' + strContainerID + ' input, #' + strContainerID + ' textarea, #' + strContainerID + ' select').each(function () {
44        var elm = $e(this);
45        if (elm.prop('tagName') != 'SELECT') {
46            var id = elm.attr('id');
47            if (id) {
48                if (id.indexOf('_FormDocumentID') > 0) return true; //next iteration                
49            }
50
51            var strType = elm.attr('type') ? elm.attr('type') : 'text';
52            strType = strType.toLowerCase();
53
54            switch (strType) {
55                case 'button':
56                case 'file':
57                case 'image':
58                case 'submit':
59                    return true;
60                case 'text':
61                    //Remove any current error messages
62                    var SPANerrorText = document.getElementById(elm.id + '_errortext');
63                    if (SPANerrorText) {
64                        SPANerrorText.style.display = "none";
65                        SPANerrorText.innerHTML = '';
66                    }
67
68
69                    if (elm.val().replace(regexMandatory, '') == '') {
70                        //If it's blank, check if it's mandatory
71                        var strMandatoryAttr = elm.attr('lang');
72                        if (strMandatoryAttr && (strMandatoryAttr != '')) {
73                            ActivateError(elm.attr('name'), 'is a required field', SPANerrorText);
74                        }
75                    }
76                    else {
77                        //Else check for enforced field types.
78                        var strAccept = elm.attr('accept') ? elm.attr('accept') : '';
79                        strAccept = strAccept.toLowerCase();
80
81                        switch (strAccept) {
82                            case 'whole_number':
83                                if (!elm.val().match(/^\d+$/))
84                                    ActivateError(elm.attr('name'), 'must be a positive whole number', SPANerrorText);
85                                break;
86                            case 'number':
87                                if (!elm.val().match(/^\-?(\d+\.?|\.)\d*$/))
88                                    ActivateError(elm.attr('name'), 'must be a number', SPANerrorText);
89                                break;
90                            case 'email':
91                                if (!elm.val().match(regexEmail)) {
92                                    ActivateError(elm.attr('name'), 'must be an email address', SPANerrorText);
93                                }
94                                break;
95                            case 'email_reply':
96                                if (!elm.val().match(regexEmail)) {
97                                    ActivateError(elm.attr('name'), 'must be an email address', SPANerrorText);
98                                    break;
99                                }
100                                if (!blnCustomReplyTo) {
101                                    var elmEmail = document.createElement('input');
102                                    elmEmail.type = 'hidden';
103                                    elmEmail.name = 'NotificationReplyTo';
104                                    elmEmail.value = elm.val();
105                                    form.appendChild(elmEmail);
106                                    blnCustomReplyTo = true;
107                                }
108                                break;
109                            case 'subject':
110                                if (!blnCustomSubject) {
111                                    var elmSubject = document.createElement('input');
112                                    elmSubject.type = 'hidden';
113                                    elmSubject.name = 'NotificationSubject';
114                                    elmSubject.value = elm.val();
115                                    form.appendChild(elmSubject);
116                                    blnCustomSubject = true;
117                                }
118                                break;
119                        }
120                    }
121                    break;
122                case 'checkbox':
123                    //Remove any current error messages
124                    var SPANerrorText = document.getElementById(elm.id + '_errortext');
125                    if (SPANerrorText) {
126                        SPANerrorText.style.display = "none";
127                        SPANerrorText.innerHTML = '';
128                    }
129
130
131                    if (!elm[0].checked) {
132                        //If it's blank, check if it's mandatory
133                        var strMandatoryAttr = elm.attr('lang');
134                        if (strMandatoryAttr && (strMandatoryAttr != '')) {
135                            ActivateError(elm.attr('name'), 'is a required field', SPANerrorText);
136                        }
137                    }
138                    break;
139                case 'radio':
140                    //Remove any current error messages
141                    var SPANerrorText = document.getElementById(elm.id + '_errortext');
142                    if (SPANerrorText) {
143                        SPANerrorText.style.display = "none";
144                        SPANerrorText.innerHTML = '';
145                    }
146
147                    //Check radio group as a whole then record that we've checked it
148                    var strRadioGroup = elm.attr('name');
149                    if (!arrRadioGroupsScanned.includes(strRadioGroup)) {
150                        var $allRadiosInGroup = $("#" + strContainerID + " input[name='" + strRadioGroup + "']");
151
152                        if ($allRadiosInGroup.filter(":checked").length == 0 && $allRadiosInGroup.filter("[lang='1']").length > 0) {
153                            ActivateError(strRadioGroup, 'is a required field', SPANerrorText);
154                        }
155
156                        arrRadioGroupsScanned.push(strRadioGroup);
157                    }
158                    break;
159            }
160        }
161        var elSubmit = elm.clone();
162        elSubmit.val(elm.val()); //Textareas, selects lose value when cloning
163        form.appendChild(elSubmit.get(0));
164    });
165
166    if (strMandatoryErrorMessage != '') {
167        ShowOverlay(strMandatoryErrorMessage + '<br>Please correct your form.' + '<div style="text-align: center; margin-top: 5px;"><input type="button" class="button" value="OK" onclick="$e(\'#divOverlay\').dialog(\'destroy\');" /></div>');
168        return false;
169    }
170
171    if (bErrorActivated) {
172        return false;
173    } 
174    else {
175        document.getElementById(strContainerID).appendChild(form);
176        if (typeof Recaptcha !== 'undefined' && typeof Recaptcha.Lookup[strClientID] !== 'undefined')
177            Recaptcha.Execute(strClientID);
178        else
179            SubmitValidForm(strClientID);
180    }
181}
182
183function ShowOverlay(strHTML) {
184    var divOverlay = $e('<div id="divOverlay" class="form_submission_overlay"></div>');
185    divOverlay.html(strHTML);
186    divOverlay.dialog({
187        modal: true,
188        resizable: false,
189        minHeight: 50,
190        dialogClass: 'shadedbox',
191        create: function (event, ui) {
192            $e(this).closest('.ui-dialog').wrap('<div class="endis-jquery-ui" />');
193        },
194        open: function (event, ui) {
195            $e('.ui-widget-overlay').wrap('<div class="endis-jquery-ui" />');
196            var dz = $e('.ui-front').css('z-index');
197            $e('.ui-widget-overlay').css({ 'z-index': dz - 1 });
198            $e('.ui-dialog-titlebar').css({ 'display': 'none' });
199            $e(this).dialog('option', 'width', '300');
200            $e(this).parent().css({ 'position': 'fixed' });
201            $e(this).parent().position({ my: 'center', at: 'center', of: '.ui-widget-overlay:visible' });
202        },
203        close: function (event, ui) {
204            $e('.endis-jquery-ui').filter(function () {
205                if ($e(this).text() == "") {
206                    return true;
207                }
208                return false;
209            }).remove();
210        }
211    });
212    divOverlay.parent().css({ 'position': 'fixed' });
213    divOverlay.parent().position({ my: 'center', at: 'center', of: '.ui-widget-overlay:visible' });
214
215    return divOverlay;
216}
217
218function SubmitValidForm(strClientID) {
219    var strArticleID = document.getElementById(strClientID + '_FormDocumentID').value;    
220    var strRecaptchaResponse = (typeof Recaptcha !== 'undefined') ? Recaptcha.GetResponse(strClientID) : '';
221    
222    var strContainerID = strClientID + '_elFormContents';
223    var form = $e('#' + strContainerID + ' form.form-for-submission').get(0);
224
225    if (intMobileGroupID) {
226        form.action = '/Publisher/SubmitForm.aspx?recaptcha_response=' + strRecaptchaResponse + '&article_id=' + strArticleID + '&mobile_group_id=' + intMobileGroupID;
227        form.method = 'POST';
228        form.style.display = 'none';
229
230        form.submit();
231    }
232    else {
233        var divOverlay = ShowOverlay('<img src="/Admin/Images/throbber.gif" alt="" align="left" style="padding-right: 5px;" /> Submitting....');
234
235        var SubmitFailed = function () {
236            divOverlay.html('Submission failed <br /><div style="text-align: center; margin-top: 5px;"><input type="button" class="button" value="Continue" onclick="$e(\'#divOverlay\').dialog(\'destroy\');" /></div>');
237            divOverlay.parent().css({ 'position': 'fixed' });
238            divOverlay.parent().position({ my: 'center', at: 'center', of: '.ui-widget-overlay:visible' });
239        };
240
241        $e.ajax({
242            type: 'POST',
243            url: '/Publisher/SubmitForm.aspx?recaptcha_response=' + strRecaptchaResponse + '&article_id=' + strArticleID,
244            data: $e(form).serialize(),
245            success: function (data) {
246                try {
247                    var objData = $e.parseJSON(data);
248                    if (objData.valid == 'true') {
249                        var strOnClick;
250                        if (qs.get("WA") == "true" || IsHubbPage()) {
251                            strOnClick = (typeof dlg == 'undefined' ? 'window.top.AppNavigate();' : 'InsightAreYouSure.SuspendForPostback(); dlg.Close();');
252                        } else {
253                            strOnClick = 'document.location.href =\'' + objData.destination + '\'';
254                        }
255                        divOverlay.html(objData.message + '<br />' + '<div style="text-align: center; margin-top: 5px;"><input type="button" class="button" value="Continue" onclick="$e(\'body\').css(\'cursor\', \'wait\'); ' + strOnClick + '" /></div>');
256                        divOverlay.dialog('option', 'width', 300);
257                        divOverlay.dialog('option', 'height', 'auto');
258                        divOverlay.parent().css({ 'position': 'fixed' });
259                        divOverlay.parent().position({ my: 'center', at: 'center', of: '.ui-widget-overlay:visible' });
260                    }
261                    else {
262                        SubmitFailed();
263                    }
264                } catch (e) {
265                    SubmitFailed();
266                }
267            },
268            error: function (data) {
269                SubmitFailed();
270            }
271        });
272    }
273}

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.