PageSourceSearch

https://lastwordsaloon.com/_dm/s/rt/scripts/platforms/fastMigration2RT.js?version=2026-09-24T12_50_33

js lastwordsaloon.com collected 2026-09-26 14:21:52 UTC 9,081 bytes, 252 lines download raw bytes

1// All code in this file will run on fast migration sites
2(function () {
3    'use strict';
4
5    var methods = {
6        onDocReady: _onDocReady,
7    };
8
9    ready(methods.onDocReady);
10
11    // VANILLA DOCUMENT READY (NO JQUERY)
12    // supports IE8 and above, not tested for old browsers
13    function ready(fn) {
14        if (document.readyState != 'loading') {
15            fn();
16        } else if (document.addEventListener) {
17            document.addEventListener('DOMContentLoaded', fn);
18        } else {
19            document.attachEvent('onreadystatechange', function () {
20                if (document.readyState != 'loading') fn();
21            });
22        }
23    }
24
25    function _onDocReady() {
26        if (
27            document.cookie &&
28            document.cookie.indexOf('persistentCookieExists=true') > -1
29        ) {
30            $('#cookieWrapper').hide();
31        }
32    }
33
34    document.addEventListener('DOMContentLoaded', function (event) {
35        formModifier();
36    });
37
38    function formModifier() {
39        var forms = document.querySelectorAll('form:not([acction^="http"])');
40
41        for (var i = 0; i < forms.length; i++) {
42            var form = forms[i];
43
44            var actionAttr = form.getAttribute('action');
45            if (actionAttr && actionAttr.indexOf('paypal') > 0) {
46                continue;
47            }
48
49            if (actionAttr && actionAttr.endsWith('.aspx')) {
50                continue;
51            }
52
53            if (form.getAttribute('dmnochange')) {
54                continue;
55            }
56
57            form.setAttribute('method', 'POST');
58            form.setAttribute(
59                'action',
60                '/_dm/s/rt/actions/fm/form/action?a=' + siteDetails.SiteAlias
61            );
62            form.setAttribute('dm_dont_rewrite_url', 'true');
63            var allInputs = form.querySelectorAll('input, textarea,select');
64            for (var k = 0; k < allInputs.length; k++) {
65                var input = allInputs[k];
66                var title = input.getAttribute('title');
67                var titleEncoded = encodeURI(title);
68                var inputName = input.getAttribute('name');
69                var formName = form.getAttribute('name');
70                if (inputName && formName) {
71                    input.setAttribute(
72                        'name',
73                        inputName
74                            .replace(formName + '_', '')
75                            .replace(formName, '')
76                    );
77                }
78                if (title) {
79                    title = title.replace(':', '');
80                    input.setAttribute('name', titleEncoded);
81                }
82
83                if (input.type === 'select-one') {
84                    changeValueToTextContent(input);
85                }
86
87                if (input.type === 'file') {
88                    if (!titleEncoded) {
89                        titleEncoded = 'Attachment';
90                    }
91                    input.setAttribute('name', titleEncoded + '_FILE');
92                }
93            }
94            var subjectMail = document.createElement('input');
95            subjectMail.setAttribute('type', 'hidden');
96            subjectMail.setAttribute('name', 'dm-form-m-ignore-subject');
97            subjectMail.setAttribute(
98                'value',
99                'You recevied a new mail from one' + ' of your sites'
100            );
101            form.appendChild(subjectMail);
102
103            var mailField = document.createElement('input');
104            mailField.setAttribute('type', 'hidden');
105            mailField.setAttribute('name', 'dm-form-m-ignore-sendto');
106            mailField.setAttribute(
107                'value',
108                window.fsBodyEnd && window.fsBodyEnd.sendToEmail
109            );
110            form.appendChild(mailField);
111
112            var encryptedMailField = document.createElement('input');
113            encryptedMailField.setAttribute('type', 'hidden');
114            encryptedMailField.setAttribute(
115                'name',
116                'dm-form-m-ignore-sendto-enc'
117            );
118            encryptedMailField.setAttribute(
119                'value',
120                window.fsBodyEnd && window.fsBodyEnd.sendToEmailEncrypted
121            );
122            form.appendChild(encryptedMailField);
123
124            var allHiddenElement = form.querySelectorAll('[type=hidden]');
125            var ignoredAsArray = '';
126            for (var j = 0; j < allHiddenElement.length; j++) {
127                var element = allHiddenElement[j];
128                ignoredAsArray += element.getAttribute('name');
129                if (j < allHiddenElement.length - 1) {
130                    ignoredAsArray += ',';
131                }
132            }
133
134            var ignoreIndicatorElement = document.createElement('input');
135            ignoreIndicatorElement.setAttribute('type', 'hidden');
136            ignoreIndicatorElement.setAttribute('name', 'dm-form-m-ignore');
137            ignoreIndicatorElement.setAttribute('value', ignoredAsArray);
138            form.appendChild(ignoreIndicatorElement);
139            overrideSubmitForm(form);
140        }
141    }
142
143    function changeValueToTextContent(input) {
144        var options = input.options;
145        for (var i = 0; i < options.length; i++) {
146            options[i].value = options[i].textContent;
147        }
148    }
149
150    function getStyle(element, attr) {
151        return document.defaultView
152            .getComputedStyle(element, null)
153            .getPropertyValue(attr);
154    }
155
156    function overrideSubmitForm(form) {
157        var formBtn = document.querySelector("form button[type='submit']");
158        if (formBtn) {
159            formBtn.removeAttribute('onclick');
160        }
161        var successDiv = document.createElement('div');
162        form.onsubmit = function (event) {
163            event.preventDefault();
164            var url = form.getAttribute('action');
165
166            var data = new FormData(form);
167            data.delete('cc-id');
168            data.delete('cc-ntotal');
169            var req = new XMLHttpRequest();
170            req.open('POST', url, true);
171
172            req.onreadystatechange = function () {
173                //Call a function when the state changes.
174                if (
175                    req.readyState == XMLHttpRequest.DONE &&
176                    req.status == 200
177                ) {
178                    var textToShow = req.responseText;
179                    if (req.responseText.startsWith('ERROR_PREFIX')) {
180                        textToShow = textToShow.replace('ERROR_PREFIX', '');
181                    }
182                    var submitBtn = form.querySelector('input[type=submit]');
183                    successDiv.innerHTML = textToShow;
184                    form.style.display = 'none';
185                    if (getStyle(form, 'position') == 'absolute') {
186                        successDiv.style.top = getStyle(form, 'top');
187                        successDiv.style.left = getStyle(form, 'left');
188                        successDiv.style.position = getStyle(form, 'position');
189                    }
190                    form.parentNode.insertBefore(successDiv, form.nextSibling);
191                }
192            };
193            req.send(data);
194
195            return false;
196        };
197    }
198
199    //
200    window.emptyFunction = function () {};
201    var allRelativeAnchors = document.querySelectorAll('a:not([href^="http"])');
202    for (var i = 0, len = allRelativeAnchors.length; i < len; i++) {
203        var anchor = allRelativeAnchors[i];
204        if (
205            anchor.getAttribute('href') &&
206            anchor.getAttribute('href') !== '#'
207        ) {
208            var onclick = anchor.getAttribute('onclick');
209            if (onclick && window.isPreview) {
210                onclick = onclick.replace(
211                    'window.open',
212                    'window.emptyFunction'
213                );
214                if (onclick.indexOf('scroll') < 0) {
215                    onclick = onclick.replace('return false;', '');
216                }
217                anchor.setAttribute('onclick', onclick);
218            } else {
219                anchor.setAttribute('onclick', '');
220            }
221        }
222        var homePage = 'index.html';
223        var hrefAttr = anchor.getAttribute('href');
224
225        const dm_device = getParameterByName('dm_device');
226        if (dm_device && hrefAttr && hrefAttr.indexOf('dm_device') < 0) {
227            anchor.href = hrefAttr += '?dm_device=' + dm_device;
228        }
229
230        if (location.pathname !== '/') {
231            continue;
232        }
233
234        if (
235            hrefAttr &&
236            hrefAttr.startsWith(homePage) &&
237            hrefAttr !== homePage
238        ) {
239            anchor.href = hrefAttr.replace(homePage, '');
240        }
241    }
242
243    function getParameterByName(name, url) {
244        if (!url) url = window.location.href;
245        name = name.replace(/[\[\]]/g, '\\$&');
246        var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
247            results = regex.exec(url);
248        if (!results) return null;
249        if (!results[2]) return '';
250        return decodeURIComponent(results[2].replace(/\+/g, ' '));
251    }
252})();

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.