PageSourceSearch

https://autofax.org/script.js

js autofax.org collected 2026-10-02 15:25:22 UTC 18,439 bytes, 495 lines download raw bytes

1window.onerror = function(message, url, linenumber, columnNo, error) {
2	//ignore stripe errors on chrome ios
3	if((""+message).indexOf("Blocked a frame with origin") != -1)
4		return;
5	if ( typeof error !== 'undefined' && typeof error.stack !== 'undefined' ){
6		console.warn(message,url,linenumber,columnNo,"\n" + error.stack);
7		logistics("jserror", message, error.stack);
8	}else{
9		console.warn(message,url,linenumber);
10		logistics("jserror", message, url + "-" + linenumber);
11	}
12  	//alert("JavaScript error: " + message + " on line " + linenumber + " for " + url);
13};
14function manualErr(){ //invoke using href link to test js errors - doesn't fire if invoked from console
15	nothingHere();
16}
17
18var vin = "";
19var checkedvins = [];
20function checkVIN(callback){
21    vin = document.getElementsByName("vin")[0].value.toUpperCase().trim();
22    document.getElementById("vinresult").style.color = "#aa0000";
23    if(vin.length != 17){
24        document.getElementById("vinresult").innerHTML = "VIN number should be 17 characters long";
25        callback(false);
26        return;
27    }
28    if(vin.indexOf(" ") != -1){
29        document.getElementById("vinresult").innerHTML = "VIN number should not contain spaces";
30        callback(false);
31        return;
32    }
33    if(typeof checkedvins[vin] !== "undefined"){
34        document.getElementById("vinresult").innerHTML = checkedvins[vin];
35        document.getElementById("vinresult").style.color = "#008800";
36        document.getElementById("vinresult").innerHTML = "Found records for " + document.getElementById("vinresult").innerHTML;
37        callback(true);
38        return;
39    }
40    document.getElementById("vinresult").innerHTML = 'Checking VIN, please wait <img src="/images/balls.svg" style="height:2em;vertical-align:middle">';
41    file_get_contents("/resolvevin.php?vin=" + vin + "&ran=" + Math.random(), function(response){
42        var resp = response.split("\n")[0];
43        document.getElementById("vinresult").innerHTML = resp;
44        if(response.split("\n").length == 1){
45            document.getElementById("vinresult").innerHTML = "Error verifying VIN, please contact us for support (email address in footer).";
46            callback(false);
47        }else if(resp == "No records found for the VIN"){
48            document.getElementById("vinresult").innerHTML = "Invalid VIN";
49            callback(false);
50        }else{
51            document.getElementById("vinresult").style.color = "#008800";
52            document.getElementById("vinresult").innerHTML = "Found records for " + document.getElementById("vinresult").innerHTML;
53            checkedvins[vin] = resp;
54            callback(true);
55        }
56    }, function(){
57        document.getElementById("vinresult").innerHTML = "Error verifying VIN, please contact us for support (email address in footer).";
58        callback(false);
59    });
60}
61
62function checkPromo(){
63    /*document.getElementsByName('promo')[0].style.display = document.getElementsByName('promochk')[0].checked ? '' : 'none';
64    document.getElementById("promoresult").innerHTML = "";
65    document.getElementById("price").innerHTML = "$13.99";
66    var promo = document.getElementsByName("promo")[0].value;
67    discount = "0;";
68    if(promo == "") //|| !document.getElementsByName('promochk')[0].checked)
69        return false;
70    var xmlHttp = new XMLHttpRequest();
71    var theUrl = "/resolvepromo.php?promo=" + encodeURIComponent(promo) + "&ran=" + Math.random();
72    xmlHttp.open("GET", theUrl, false);
73    xmlHttp.send(null);
74    discount = xmlHttp.responseText;
75    document.getElementById("promoresult").innerHTML = discount.split(";")[1];
76    if(discount.split(";")[0] == "0"){
77        document.getElementById("promoresult").style.color = "#aa0000";
78        return false;
79    }else{
80        document.getElementById("promoresult").style.color = "#008800";
81        document.getElementById("price").innerHTML = "<s>$13.99</s> $" + (13.99 - parseInt(discount.split(";")[0]) * 0.01 * 13.99).toFixed(2);
82        document.getElementById("btnpp").style.display = "none";
83        document.getElementById("verticalsplit2").style.display = "none";
84        return true;
85    }*/
86}
87
88function checkEmail(){
89    if(!validateEmail(emailid.value)){
90        document.getElementById("emailresult").innerHTML = "Input a valid email address to proceed";
91        return false;
92    }else{
93        document.getElementById("emailresult").innerHTML = "";
94        setCookie("useremail", emailid.value, 90);
95        return true;
96    }
97}
98
99function refSubmit(){
100    checkVIN(function(ret){
101        if(!ret){
102            alert("Please enter a valid VIN to continue");
103            return;
104        }
105        if(!checkEmail()){
106            alert("Please enter a valid email address to continue");
107            return;
108        }
109        window.location = "/ppcomplete.php?cdt=" + encodeURIComponent(parseQueryString("cdt")[0]) + "&vin=" + encodeURIComponent(vin);
110    });
111}
112
113function srpeSubmit(){
114    checkVIN(function(ret){
115        if(!ret){
116            alert("Please enter a valid VIN to continue");
117            return;
118        }
119        if(!checkEmail()){
120            alert("Please enter a valid email address to continue");
121            return;
122        }
123        logistics('pur-srpe', vin, ppfrm.os2.value);
124        stripe.createToken(card).then(function(result) {
125            if (result.error) {
126                var errorElement = document.getElementById('card-errors');
127                errorElement.textContent = result.error.message;
128            } else {
129                srpefrm1.token1.value = result.token.id;
130                srpefrm1.vin1.value = vin;
131                if(document.getElementsByName("nds-pmd").length > 0){
132                    document.getElementsByName("nds-pmd")[0].value = "";
133                    document.getElementsByName("nds-pmd")[1].value = "";
134                }
135                srpefrm1.submit();
136            }
137        });
138    });
139}
140
141function sqreSubmit(){
142    checkVIN(function(ret){
143        if(!ret){
144            alert("Please enter a valid VIN to continue");
145            return;
146        }
147        if(!checkEmail()){
148            alert("Please enter a valid email address to continue");
149            return;
150        }
151        logistics('pur-sqre', vin, ppfrm.os2.value);
152        (async() => {
153            var tokenResult = await sqre_card.tokenize();
154            if(tokenResult.status == "OK"){
155                srpefrm1.token1.value = tokenResult.token;
156                srpefrm1.vin1.value = vin;
157                if(document.getElementsByName("nds-pmd").length > 0){
158                    document.getElementsByName("nds-pmd")[0].value = "";
159                    document.getElementsByName("nds-pmd")[1].value = "";
160                }
161                srpefrm1.submit();
162                document.getElementById("spinner").style.display = "block";
163                document.getElementById("divsubmit").style.display = "none";
164            }
165        })();
166    });
167}
168
169function sqregoogleSubmit(){
170    checkVIN(function(ret){
171        if(!ret){
172            alert("Please enter a valid VIN to continue");
173            return;
174        }
175        if(!checkEmail()){
176            alert("Please enter a valid email address to continue");
177            return;
178        }
179        logistics('pur-sqre', vin, ppfrm.os2.value);
180        (async() => {
181            var tokenResult = await sqre_googlepay.tokenize();
182            if(tokenResult.status == "OK"){
183                srpefrm1.token1.value = tokenResult.token;
184                srpefrm1.vin1.value = vin;
185                srpefrm1.tag1.value = "GooglePay";
186                if(document.getElementsByName("nds-pmd").length > 0){
187                    document.getElementsByName("nds-pmd")[0].value = "";
188                    document.getElementsByName("nds-pmd")[1].value = "";
189                }
190                srpefrm1.submit();
191                document.getElementById("spinner").style.display = "block";
192                document.getElementById("divsubmit").style.display = "none";
193            }
194        })();
195    });
196}
197
198function sqreappleSubmit(){
199    checkVIN(function(ret){
200        if(!ret){
201            alert("Please enter a valid VIN to continue");
202            return;
203        }
204        if(!checkEmail()){
205            alert("Please enter a valid email address to continue");
206            return;
207        }
208        logistics('pur-sqre', vin, ppfrm.os2.value);
209        (async() => {
210            var tokenResult = await sqre_applepay.tokenize();
211            if(tokenResult.status == "OK"){
212                srpefrm1.token1.value = tokenResult.token;
213                srpefrm1.vin1.value = vin;
214                srpefrm1.tag1.value = "ApplePay";
215                if(document.getElementsByName("nds-pmd").length > 0){
216                    document.getElementsByName("nds-pmd")[0].value = "";
217                    document.getElementsByName("nds-pmd")[1].value = "";
218                }
219                srpefrm1.submit();
220                document.getElementById("spinner").style.display = "block";
221                document.getElementById("divsubmit").style.display = "none";
222            }
223        })();
224    });
225}
226
227function ppSubmit(){
228    checkVIN(function(ret){
229        if(!ret){
230            alert("Please enter a valid VIN to continue");
231            return;
232        }
233        if(!checkEmail()){
234            alert("Please enter a valid email address to continue");
235            return;
236        }
237        ppfrm.os0.value = vin;
238        logistics('pur-pp', vin, ppfrm.os2.value);
239        if(document.getElementsByName("nds-pmd").length > 0){
240            document.getElementsByName("nds-pmd")[0].value = "";
241            document.getElementsByName("nds-pmd")[1].value = "";
242        }
243        ppfrm.submit();
244    });
245}
246 
247function inputVIN(event){
248    /*if(event.keyCode == 13){
249        if(document.getElementById("btnsrpe"))
250            btnsrpe.click();
251        else
252            submitPage("pp");
253    }*/
254}
255
256var chkcount = 0;
257var token = "";
258var temail = "";
259function chkReport(){
260    var xmlHttp = new XMLHttpRequest();
261    var theUrl = "/reports/" + token + ".pdf?ran=" + Math.random();
262    var contents = "";
263    try{
264        xmlHttp.open("GET", theUrl, false);
265        xmlHttp.send(null);
266        contents = xmlHttp.responseText;
267    }catch(e){}
268    if(contents.length > 20000){   
269        document.getElementById("reportlink").href = "/reports/" + token +".pdf";        
270        if(getCookie("and") == "yes"){
271            document.getElementById("reportlink").href = "https://docs.google.com/gview?embedded=true&url=" + document.getElementById("reportlink").href;
272            document.getElementById("reportlink").target = "";
273        }
274        document.getElementById("complete").style.display = "";
275        document.getElementById("inprocess").style.display = "none";
276        logistics('purchase','delivered',temail);
277        return;
278    }else if(chkcount > 5){
279        document.getElementById("email").style.display = "";
280        document.getElementById("inprocess").style.display = "none";
281        logistics('purchase','delayed',temail);
282        return;
283    }
284    chkcount++;
285    setTimeout(chkReport, 10000);
286}
287
288function createReferID(){
289    var email = document.getElementById("txt1").value.toLowerCase().trim();
290    if( !validateEmail(email) ){
291        alert("Please enter a valid email address");
292    }else{
293        var xmlHttp = new XMLHttpRequest();
294        var theUrl = "/resolverefer.php?email=" + encodeURIComponent(email) + "&ran=" + Math.random();
295        xmlHttp.open("GET", theUrl, false);
296        xmlHttp.send(null);
297        var id = xmlHttp.responseText;
298        if(id.length == 10){
299            document.getElementById("title1").innerHTML = "Your referral link";
300            document.getElementById("txt1").value = "https://autofax.org/?ref=" + id;
301            document.getElementById("txt1").setAttribute("readonly","");
302            document.getElementById("txt1").select();
303            document.getElementById("btn1").setAttribute("onclick", "javascript:copyLink();");
304            document.getElementById("btn1").innerHTML = "Copy to clipboard";
305            logistics("refer", "signedup", email);
306        }else{
307            alert("Server not responding");
308        }
309    }
310}
311
312
313//-------------
314var stripe, elements, card;
315
316function srpemainLoad(){
317    elements = stripe.elements();
318    card = elements.create('card');
319    card.mount('#card-element');
320
321    // Handle real-time validation errors from the card Element.
322    card.addEventListener('change', function(event) {
323      const displayError = document.getElementById('card-errors');
324      if (event.error) {
325        displayError.textContent = event.error.message;
326      } else {
327        displayError.textContent = '';
328      }
329    });
330}
331//-------------
332var appId, locationId, sqre_card, sqre_applepay, sqre_googlepay;
333
334function sqremainLoad(){
335    (async() => {
336        if (!window.Square)
337            throw new Error('Square.js failed to load properly');
338        const payments = window.Square.payments(appId, locationId);
339        try {
340            sqre_card = await payments.card();
341            await sqre_card.attach('#card-container'); 
342        } catch (e) {
343            console.error('Initializing Card failed', e);
344            return;
345        }
346
347        try {
348            sqre_applepay = await payments.applePay(payments.paymentRequest({
349                countryCode: 'US',
350                currencyCode: 'USD',
351                total: {
352                  amount: '17.99',
353                  label: 'Total',
354                },
355              }));
356              document.getElementById("applepaybutton").style.display = "inline-block";
357        } catch (e) {
358            //console.error('Initializing Apple Pay failed', e);
359        }
360
361        try {
362            sqre_googlepay = await payments.googlePay(payments.paymentRequest({
363                countryCode: 'US',
364                currencyCode: 'USD',
365                total: {
366                  amount: '17.99',
367                  label: 'Total',
368                },
369              }));
370            await sqre_googlepay.attach('#googlepaybutton',{ buttonColor: 'black', buttonSizeMode: 'static', buttonType: 'long' });
371        } catch (e) {
372            console.error('Initializing Google Pay failed', e);
373        }
374
375        document.getElementById("spinner").style.display = "none";
376    })();
377}
378
379//---------------------
380
381      
382function inputEmail(event){
383    if(event.keyCode == 13){
384        if(document.getElementById("btn1").innerHTML == "Copy to clipboard")
385            copyLink();
386        else
387            createReferID();
388    }
389}
390
391function copyLink(){
392    document.getElementById("txt1").select();
393    document.execCommand('copy');
394}
395
396function sbLoad(){
397    if(location.origin != null && document.referrer != null && document.referrer != "" && document.referrer.indexOf(location.origin.toLowerCase()) == -1){
398        if(isRWLocalStorage() && window.localStorage.firstref == null){
399            window.localStorage.firstref = document.referrer;
400            logistics("referrer", "first", window.localStorage.firstref);
401        }else
402            logistics("referrer", "repeat", document.referrer);
403    }
404    if(parseQueryString("trk")!=null || parseQueryString("src")!=null || parseQueryString("ref")!=null){
405        logistics("source", replaceAll(''+parseQueryString("trk")+parseQueryString("src")+parseQueryString("ref"),"undefined",""),"");
406	}
407}
408
409function getCookie(c_name){
410	var c_value = document.cookie;
411	var c_start = c_value.indexOf(" " + c_name + "=");
412	if (c_start == -1)
413		c_start = c_value.indexOf(c_name + "=");
414	if (c_start == -1)
415		c_value = "";
416	else
417	{
418	c_start = c_value.indexOf("=", c_start) + 1;
419	var c_end = c_value.indexOf(";", c_start);
420	if (c_end == -1)
421		c_end = c_value.length;
422	c_value = decodeURIComponent(c_value.substring(c_start,c_end));
423	}
424	return c_value;
425}
426
427function setCookie(c_name,value,expireindays){
428    var d = new Date();
429    d.setTime(d.getTime() + (expireindays*24*60*60*1000));
430	var c_value=encodeURIComponent(value) + "; expires="+ d.toUTCString();
431	document.cookie=c_name + "=" + c_value;
432}
433
434function parseQueryString(param) {
435    var query = (window.location.search || '?').substr(1),
436        map   = {};
437    query.replace(/([^&=]+)=?([^&]*)(?:&+|$)/g, function(match, key, value) {
438        (map[key] = map[key] || []).push(value);
439    });
440    return map[param];
441}
442
443function logistics(evtname,evtval,notes)
444{
445    var ref = (window.localStorage == null || window.localStorage.firstref == null) ?  "" + document.referrer : window.localStorage.firstref;
446    ref = location.origin != null && ref.toLowerCase().indexOf(location.origin.toLowerCase()) != -1 ? "" : ref;
447    if(notes != ""){
448        ref = notes;
449    }else{
450        if(ref == "")
451            ref = "web";
452    }
453    var category = "web";
454    if(getCookie("and") == "yes")
455        category = "android";
456    var theUrl = "/logistics/ln.php?cat=" + category + "&notes=" + encodeURIComponent(ref) + "&evtname=" + encodeURIComponent(evtname) + "&evtval=" + encodeURIComponent(evtval);
457    file_get_contents(theUrl, function(){}, function(){});
458}
459
460function replaceAll(str,search,replacement){
461    return str.replace(new RegExp(search, 'g'), replacement);
462}
463
464function validateEmail(email) 
465{
466    var re = /\S+@\S+\.\S+/;
467    return re.test(email);
468}
469
470function file_get_contents(url, cb_load, cb_error){ //async
471    var xhr = new XMLHttpRequest();
472    xhr.open("GET", url + "&ran=" + Math.random(), true);
473    xhr.onload = function (e) {
474      if (xhr.readyState === 4) {
475        if (xhr.status === 200) {
476          cb_load(xhr.responseText);
477        } else {
478          cb_error(xhr.statusText);
479        }
480      }
481    };
482    xhr.onerror = function (e) {
483      cb_error(xhr.statusText);
484    };
485    xhr.send(null);
486}
487
488function isRWLocalStorage() { //checks if local storage is available and write supported (incognito mode)
489    try {
490        localStorage.setItem("__test", "data");
491    } catch (e) {
492        return false;
493    } 
494    return true;
495}

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.