PageSourceSearch

https://houseoffunguide.web.app/assets/formoid/formoid.min.js

js houseoffunguide.web.app collected 2026-10-03 12:25:43 UTC 10,164 bytes, 264 lines download raw bytes

1jQuery(function ($) {
2
3   var Formoid = (function () {
4
5       var API_URL = ('https:' == location.protocol ? 'https:' : 'http:') + '//formoid.net/api/push';
6
7       var $ajax = (function () {
8           var ie = (/MSIE (\d+)\./.exec(navigator.userAgent) || [0, 0])[1];
9           if (8 == ie || (9 == ie && 'file:' != location.protocol)) {
10               return function (url, settings) {
11                   var xdr = new XDomainRequest(), defer = $.Deferred();
12                   xdr.open(settings.type, url);
13                   xdr.onload = function () {
14                       defer.resolve(this.responseText);
15                   };
16                   xdr.onerror = function () {
17                       defer.reject();
18                   };
19                   xdr.send(settings.data);
20                   return defer;
21               };
22           } else {
23               $.support.cors = true;
24               return $.ajax;
25           }
26       })();
27
28       var prop = function (name, args) {
29           name = '__' + name + '__';
30           if (args.length) {
31               this[name] = args[0];
32               return this;
33           }
34           return this[name];
35       };
36
37       var attachMethods = function (obj, context, methods) {
38           $.each(methods, function (i, method) {
39               obj[method] = function () {
40                   return context[method].apply(context, arguments);
41               };
42           });
43           return obj;
44       };
45
46       var Form = function (settings) {
47           settings = settings || {};
48           this.__email__ = settings.email || '';
49           this.__title__ = settings.title || '';
50           this.__data__ = settings.data || [];
51       };
52
53       Form.prototype.email = function (value) {
54           return prop.call(this, 'email', arguments);
55       };
56
57       Form.prototype.title = function (value) {
58           return prop.call(this, 'title', arguments);
59       };
60
61       Form.prototype.data = function (value) {
62           return prop.call(this, 'data', arguments);
63       };
64
65       Form.prototype.send = function (data, beforeStart) {
66           var defer = attachMethods($.Deferred(), this, ['email', 'title', 'data', 'send']);
67           if (beforeStart) {
68               beforeStart.call(this, defer);
69               if ('pending' != defer.state())
70                   return defer;
71           }
72           $ajax(API_URL, {
73               type: 'POST',
74               data: JSON.stringify({
75                   email: this.__email__,
76                   form: {
77                       title: this.__title__,
78                       data: (arguments.length ? data : this.__data__)
79                   }
80               })
81           }).done(function (responseText) {
82               try {
83                   var data = JSON.parse(responseText);
84                   if (data.error) defer.reject(data.error);
85                   else defer.resolve(data.response);
86               } catch (e) {
87                   defer.reject('Incorrect server response.');
88               }
89           }).fail(function () {
90               var error = 'Failed to query the server. ';
91               if ('onLine' in navigator && !navigator.onLine)
92                   error += 'No connection to the Internet.';
93               else error += 'Check the connection and try again.';
94               defer.reject(error);
95           });
96           return defer;
97       };
98
99       return {
100           Form: function (settings) {
101               return new Form(settings);
102           }
103       }
104
105   })();
106
107   var isValidEmail = function (input) {
108       var isValid = true,
109           value = $(input).val();
110
111       if (value) {
112           isValid = /^([^@]+?)@(([a-z0-9]-*)*[a-z0-9]+\.)+([a-z0-9]+)$/i.test(value);
113       }
114
115       return isValid;
116   };
117
118   $('[data-form-type="formoid"]').each(function () {
119       var form,
120           $this = $(this),
121           $form = $this.is('form') ? $this : $this.find('form'),
122           $alert = $this.find('[data-form-alert]'),
123           $title = $this.is('[data-form-title]') ? $this : $this.find('[data-form-title]'),
124           $submit = $this.find('[type="submit"]'),
125           $inputArr = $form.find('[data-form-field]'),
126           alertSuccess = $alert.html();
127
128       // on change form inputs if input[type=file].files[0]size>1mb disable sumbit button and show form alert
129       $form.change(function (event) {
130           if (event.target.type === 'file') {
131               if (event.target.files[0].size > 1000000) {
132                   $alert.removeAttr('hidden');
133                   $alert.removeClass('alert-success').addClass('alert-danger');
134                   $alert.html('File size must be less than 1mb');
135                   $submit.addClass('btn-loading').prop('disabled', true);
136               }
137           }
138       });
139
140       $inputArr.each(function (index, elem) {
141           $(elem).on("focus", function () {
142               $alert.attr('hidden', 'hidden');
143               $alert.addClass('alert-success').removeClass('alert-danger');
144               $alert.html('');
145               $submit.removeClass('btn-loading').prop('disabled', false);
146           })
147       });
148
149       // event on form submit
150       $form.submit(function (event) {
151           event.preventDefault();
152           if ($submit.hasClass('btn-loading')) return;
153
154           var data = [],
155               inputs = $inputArr;
156
157           $form.addClass('form-active');
158           $submit.addClass('btn-loading').prop('disabled', true);
159           $alert.html('');
160           form = form || Formoid.Form({
161               email: $this.find('[data-form-email]').val(),
162               title: $title.attr('data-form-title') || $title.text()
163           });
164
165           function parseInputs(inputs) {
166               var def = $.Deferred(),
167                   arrDeferred = [];
168
169               inputs.each(function (index, input) {
170                   var $input = $(input),
171                       typeInput = $input.attr('type'),
172                       objDeferred = $.Deferred();
173
174                   arrDeferred.push(objDeferred);
175
176                   // valide email
177                   if ($input.attr('name') === "email") {
178                       if (!isValidEmail(input)) {
179                           $submit.removeClass('btn-loading').prop('disabled', true);
180                           def.reject(new Error('Form is not val
180id'));
181                           return false;
182                       }
183                   }
184
185                   switch (typeInput) {
186                       case 'file': {
187                           var reader = new FileReader,
188                               name = $input.attr('data-form-field') || $input.attr('name'),
189                               files = $input[0].files[0];
190
191                           reader.onloadend = function () {
192                               data.push([
193                                   name,
194                                   reader.result
195                               ]);
196                               objDeferred.resolve();
197                           };
198                           reader.onerror = function () {
199                               $alert.html(reader.error);
200                               def.reject(reader.error);
201                           };
202
203                           if (files) {
204                               reader.readAsDataURL(files);
205                           }
206                       }
207                           break;
208                       case 'checkbox': {
209                           data.push([
210                               $input.attr('data-form-field') || $input.attr('name'),
211                               $input.prop("checked") ? $input.val() : 'No'
212                           ]);
213                           objDeferred.resolve();
214                       }
215                           break;
216                       case 'radio': {
217                           if ($input.prop("checked")) {
218                               data.push([
219                                   $input.attr('data-form-field') || $input.attr('name'),
220                                   $input.val()
221                               ]);
222                               objDeferred.resolve();
223                           }
224                       }
225                           break;
226                       default: {
227                           data.push([
228                               $input.attr('data-form-field') || $input.attr('name'),
229                               $input.val()
230                           ]);
231                           objDeferred.resolve();
232                       }
233                   }
234               });
235
236               return def.resolve(arrDeferred);
237           }
238
239           parseInputs(inputs).then(function (arrDef) {
240               $.when.apply(this, arrDef).then(function () {
241                   form.send(data)
242                       .always(function () {
243                           $submit.removeClass('btn-loading').prop('disabled', false);
244                           $alert.removeAttr('hidden');
245                       })
246                       .then(function (message) {
247                           $form[0].reset();
248                           $form.removeClass('form-active');
249                           $alert.text(alertSuccess || message);
250                           $alert.removeClass('alert-danger').addClass('alert-success')
251                       })
252                       .fail(function (error) {
253                           $alert.text(error);
254                           $alert.removeClass('alert-success').addClass('alert-danger')
255                       })
256               }, function (err) {
257                   $alert.html(err.message);
258                   $alert.removeClass('alert-success').addClass('alert-danger');
259                   $alert.removeAttr('hidden');
260               })
261           });
262       });
263   });
264});

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.