PageSourceSearch

https://hslda.org/ResourcePackages/HSLDA/assets/dist/js/legal-series-custom.js

js hslda.org collected 2026-10-01 10:24:11 UTC 14,865 bytes, 266 lines download raw bytes

1/*! jquery.cookie v1.4.1 | MIT */
2!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?a(require("jquery")):a(jQuery)}(function(a){function b(a){return h.raw?a:encodeURIComponent(a)}function c(a){return h.raw?a:decodeURIComponent(a)}function d(a){return b(h.json?JSON.stringify(a):String(a))}function e(a){0===a.indexOf('"')&&(a=a.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\/g,"\\"));try{return a=decodeURIComponent(a.replace(g," ")),h.json?JSON.parse(a):a}catch(b){}}function f(b,c){var d=h.raw?b:e(b);return a.isFunction(c)?c(d):d}var g=/\+/g,h=a.cookie=function(e,g,i){if(void 0!==g&&!a.isFunction(g)){if(i=a.extend({},h.defaults,i),"number"==typeof i.expires){var j=i.expires,k=i.expires=new Date;k.setTime(+k+864e5*j)}return document.cookie=[b(e),"=",d(g),i.expires?"; expires="+i.expires.toUTCString():"",i.path?"; path="+i.path:"",i.domain?"; domain="+i.domain:"",i.secure?"; secure":""].join("")}for(var l=e?void 0:{},m=document.cookie?document.cookie.split("; "):[],n=0,o=m.length;o>n;n++){var p=m[n].split("="),q=c(p.shift()),r=p.join("=");if(e&&e===q){l=f(r,g);break}e||void 0===(r=f(r))||(l[q]=r)}return l};h.defaults={},a.removeCookie=function(b,c){return void 0===a.cookie(b)?!1:(a.cookie(b,"",a.extend({},c,{expires:-1})),!a.cookie(b))}});
3
4// $.getQuery() function
5(function ($) {
6    $.getQuery = function (query) {
7        query = query.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
8        var expr = "[\\?&]" + query + "=([^&#]*)";
9        var regex = new RegExp(expr);
10        var results = regex.exec(window.location.href);
11        if (results !== null) {
12            return results[1];
13        } else {
14            return false;
15        }
16    };
17})(jQuery);
18
19// Set cookie
20var setCookie = function() {
21    $.cookie('EmailSubmitted', 'true', { expires: 365, path: "/" });
22};
23
24// Show the thank-you popup
25var showThankYou = function() {
26    // Clean up the URL
27    history.replaceState( {} , 'Thank You', window.location.pathname);
28    // Add the thank you code
29    $('body').append('<div id="email-done" class="modal" tabindex="-1" role="dialog"><div class="modal-dialog" role="document" style="max-width: 385px;"><div class="modal-content"><div class="modal-header border-0"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="54" fill="#41A248" class="pr-2" viewBox="0 0 16 16"><path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zm-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z"></path></svg><h4 class="modal-title" style="font-family: \'foro sans\';">Thank you for signing up! You\'ve been added to our email list.</h4><button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button></div></div></div></div>');
30    $('#email-done').modal();
31};
32
33// Check for cookie
34var hasCookie = function () {
35    if (document.location.search.indexOf('success') > -1) {
36        // They have just signed up
37        showThankYou();
38        setCookie();
39        return true;
40    } else if (document.referrer.startsWith('https://go.hslda.org/') && document.cookie.indexOf('redirectUrl') !== -1) {
41        // They have just signed up
42        showThankYou();
43        setCookie();
44        return true;
45    } else if (document.location.search.indexOf('error') > -1) {
46        // They tried to sign up but something went wronge
47        // We should show them an error here
48        console.log('Pardot returned an error');
49        return false;
50    } else if ($.getQuery('utm_source') === 'HSLDA%20email') {
51        // If this true, they came from an email message that we sent and we don't need to ask them for their email again.
52        setCookie();
53        return true;
54    } else if ($.cookie('EmailSubmitted') === 'true') {
55        return true;
56    }
57    return false;
58};
59
60// Check on what state legal series the user is viewing
61var allStates = ['Alabama','Alaska','American Samoa','Arizona','Arkansas','California','Colorado','Connecticut','Delaware','District of Columbia','Florida','Georgia','Guam','Hawaii','Idaho','Illinois','Indiana','Iowa','Kansas','Kentucky','Louisiana','Maine','Maryland','Massachusetts','Michigan','Minnesota','Mississippi','Missouri','Montana','Nebraska','Nevada','New Hampshire','New Jersey','New Mexico','New York','North Carolina','North Dakota','Northern Mariana Islands','Ohio','Oklahoma','Oregon','Pennsylvania','Puerto Rico','Rhode Island','South Carolina','South Dakota','Tennessee','Texas','Virgin Islands','Utah','Vermont','Virginia','Washington','West Virginia','Wisconsin','Wyoming'];
62var allStateCodes = ['AL','AK','AS','AZ','AR','CA','CO','CT','DE','DC','FL','GA','GU','HI','ID','IL','IN','IA','KS','KY','LA','ME','MD','MA','MI','MN','MS','MO','MT','NE','NV','NH','NJ','NM','NY','NC','ND','MP','OH','OK','OR','PA','PR','RI','SC','SD','TN','TX','VI','UT','VT','VA','WA','WV','WI','WY'];
63
64function whatState() {
65    var state;
66    // We loop through all the possible states and see if they are in the URL
67    allStates.forEach(function (stateName) {
68        if (window.location.pathname.includes(stateName.toLowerCase().replace(' ','-'))) {
69            state = stateName;
70        }
71    });
72    return state;
73}
74
75// Add form to page
76function addEmailCapture() {
77    // This will be the state we find in the URL
78    var state = whatState() || '';
79    // This will be the state code we get from the state in the URL
80    var stateCode = allStateCodes[allStates.indexOf(state)] || '';
81    // Add it to the page
82	$('#complyEmailForm').detach().insertAfter('.post-content').removeClass('d-none'); //it's a form already on the page just moved into place and enabled
83	$('.stateName').val(state);		//add the state values to the form fields on the page
84	$('.stateAbbr').val(stateCode);
85
86    // Hook up the zip validation
87    document.getElementById('zip').oninput = zipToState;
88}
89
90//Add form to member savings page
91function addMemberEmail() {
92    // Member savings form code
93    var emailMember ='<div class="container-small"><article class="card simple-card bg-inviting-lightest" style="z-index: 1;"><div class="card-img rounded-circle d-none d-lg-block" style="background-image:url(https://hslda.org/images/librariesprovider2/images/member-savings/member-savings-promo-istock-682961712.jpg?Status=Temp&sfvrsn=36ebd4d1_2);"></div><div class="card-body text-inviting text-left" style="font-size:16px;"><h2 class="title text-inviting" style="margin:0;">Stay updated on the latest and greatest savings</h2>Sign up to receive quarterly updates on more special discounts. We make it easy to unsubscribe.<form action="https://go.hslda.org/l/795273/2022-05-18/3s4t9n" method="post" class="d-block mt-2 d-lg-flex text-center"><input class="form-control mr-0 mr-lg-2 mb-2 mb-lg-0 p-2" type="text" id="firstName" name="firstName" placeholder="First Name" autocomplete="on" required="" style="height: 44px;font-size: 16px;"><input class="form-control mr-0 mr-lg-2 mb-2 mb-lg-0 p-2" type="email" id="email" name="email" placeholder="Email" autocomplete="on" required="" style="height: 44px;font-size: 16px;"><input class="form-control mr-0 mr-lg-2 mb-2 mb-lg-0 p-2" type="text" id="zip" name="zip" placeholder="Zip" autocomplete="on" style="height: 44px;font-size: 16px;"><input type="hidden" id="st" name="stateWhereYouLive"><input type="hidden" id="emailOptIn" name="emailOptIn" value="TRUE"><input type="hidden" id="state" name="stateName" value="Washington"><input type="hidden" id="state" name="stateAbbr" value="WA"><input class="btn btn-inviting" type="submit" value="Yes, sign me up!" style="margin: 0;padding: 11px 22px;height: 43px;min-width: max-content;border: 0;"></form></div></article></div>';
94
95    // Add it to the page
96    $('.post-content').after(emailMember);
97
98    // Hook up the zip validation
99    document.getElementById('zip').oninput = zipToState;
100}
101
102
103
104
105
106$(function() {
107    // Check if we want to target this page
108    if (window.location.pathname.startsWith('/post/')) {
109        var urlsToTarget = ['/post/how-to-comply-with', '/post/compulsory-school-age', '/post/how-to-withdraw-your-child-from-school-in', '/post/public-school-access-for-homeschoolers-in', '/post/special-education-provisions', '/post/the-importance-of-recordkeeping-in'];
110        urlsToTarget.forEach(function (url) {
111            if (window.location.pathname.startsWith(url) && hasCookie() !== true) {
112                // Yes, we want to target this page
113                addEmailCapture();
114            }
115        });
116        //If a posts has as an member savings icon, add the function to those pages.
117        if ($(".icon-member-savings").length) {
118            addMemberEmail();
119        }
120    }
121});
122
123// Calculate state code from zip code
124function zipToState() {
125    // Get the zip code element
126    var elm = document.getElementById('zip');
127    // Get the inputted value from the element
128    var zip = elm.value + '';
129    // Ensure param is a string to prevent unpredictable parsing results
130    if (typeof zip !== 'string') {
131        console.log('Must pass the zipcode as a string.');
132        return;
133    }
134    // Ensure we have exactly 5 characters to parse
135    if (zip.length !== 5) {
136        console.log('Must pass a 5-digit zipcode.');
137        elm.setCustomValidity('Enter a valid 5-digit zip code');
138        return;
139    }
140    // Ensure we don't parse strings starting with 0 as octal values
141    var zipcode = parseInt(zip, 10);
142    // This will be the state we calculate from the zip code
143    var st;
144    // Code cases alphabetized by state
145    if (zipcode >= 35000 && zipcode <= 36999) {
146        st = 'AL';
147    } else if (zipcode >= 99500 && zipcode <= 99999) {
148        st = 'AK';
149    } else if (zipcode >= 85000 && zipcode <= 86999) {
150        st = 'AZ';
151    } else if (zipcode >= 71600 && zipcode <= 72999) {
152        st = 'AR';
153    } else if (zipcode >= 90000 && zipcode <= 96699) {
154        st = 'CA';
155    } else if (zipcode >= 80000 && zipcode <= 81999) {
156        st = 'CO';
157    } else if ((zipcode >= 6000 && zipcode <= 6389) || (zipcode >= 6391 && zipcode <= 6999)) {
158        st = 'CT';
159    } else if (zipcode >= 19700 && zipcode <= 19999) {
160        st = 'DE';
161    } else if (zipcode >= 32000 && zipcode <= 34999) {
162        st = 'FL';
163    } else if ( (zipcode >= 30000 && zipcode <= 31999) || (zipcode >= 39800 && zipcode <= 39999) ) {
164        st = 'GA';
165    } else if (zipcode >= 96700 && zipcode <= 96999) {
166        st = 'HI';
167    } else if (zipcode >= 83200 && zipcode <= 83999) {
168        st = 'ID';
169    } else if (zipcode >= 60000 && zipcode <= 62999) {
170        st = 'IL';
171    } else if (zipcode >= 46000 && zipcode <= 47999) {
172        st = 'IN';
173    } else if (zipcode >= 50000 && zipcode <= 52999) {
174        st = 'IA';
175    } else if (zipcode >= 66000 && zipcode <= 67999) {
176        st = 'KS';
177    } else if (zipcode >= 40000 && zipcode <= 42999) {
178        st = 'KY';
179    } else if (zipcode >= 70000 && zipcode <= 71599) {
180        st = 'LA';
181    } else if (zipcode >= 3900 && zipcode <= 4999) {
182        st = 'ME';
183    } else if (zipcode >= 20600 && zipcode <= 21999) {
184        st = 'MD';
185    } else if ( (zipcode >= 1000 && zipcode <= 2799) || (zipcode == 5501) || (zipcode == 5544 ) ) {
186        st = 'MA';
187    } else if (zipcode >= 48000 && zipcode <= 49999) {
188        st = 'MI';
189    } else if (zipcode >= 55000 && zipcode <= 56899) {
190        st = 'MN';
191    } else if (zipcode >= 38600 && zipcode <= 39999) {
192        st = 'MS';
193    } else if (zipcode >= 63000 && zipcode <= 65999) {
194        st = 'MO';
195    } else if (zipcode >= 59000 && zipcode <= 59999) {
196        st = 'MT';
197    } else if (zipcode >= 27000 && zipcode <= 28999) {
198        st = 'NC';
199    } else if (zipcode >= 58000 && zipcode <= 58999) {
200        st = 'ND';
201    } else if (zipcode >= 68000 && zipcode <= 69999) {
202        st = 'NE';
203    } else if (zipcode >= 88900 && zipcode <= 89999) {
204        st = 'NV';
205    } else if (zipcode >= 3000 && zipcode <= 3899) {
206        st = 'NH';
207    } else if (zipcode >= 7000 && zipcode <= 8999) {
208        st = 'NJ';
209    } else if (zipcode >= 87000 && zipcode <= 88499) {
210        st = 'NM';
211    } else if ( (zipcode >= 10000 && zipcode <= 14999) || (zipcode == 6390) || (zipcode == 501) || (zipcode == 544) ) {
212        st = 'NY';
213    } else if (zipcode >
213= 43000 && zipcode <= 45999) {
214        st = 'OH';
215    } else if ((zipcode >= 73000 && zipcode <= 73199) || (zipcode >= 73400 && zipcode <= 74999) ) {
216        st = 'OK';
217    } else if (zipcode >= 97000 && zipcode <= 97999) {
218        st = 'OR';
219    } else if (zipcode >= 15000 && zipcode <= 19699) {
220        st = 'PA';
221    } else if (zipcode >= 300 && zipcode <= 999) {
222        st = 'PR';
223    } else if (zipcode >= 2800 && zipcode <= 2999) {
224        st = 'RI';
225    } else if (zipcode >= 29000 && zipcode <= 29999) {
226        st = 'SC';
227    } else if (zipcode >= 57000 && zipcode <= 57999) {
228        st = 'SD';
229    } else if (zipcode >= 37000 && zipcode <= 38599) {
230        st = 'TN';
231    } else if ( (zipcode >= 75000 && zipcode <= 79999) || (zipcode >= 73301 && zipcode <= 73399) ||  (zipcode >= 88500 && zipcode <= 88599) ) {
232        st = 'TX';
233    } else if (zipcode >= 84000 && zipcode <= 84999) {
234        st = 'UT';
235    } else if (zipcode >= 5000 && zipcode <= 5999) {
236        st = 'VT';
237    } else if ( (zipcode >= 20100 && zipcode <= 20199) || (zipcode >= 22000 && zipcode <= 24699) || (zipcode == 20598) ) {
238        st = 'VA';
239    } else if ( (zipcode >= 20000 && zipcode <= 20099) || (zipcode >= 20200 && zipcode <= 20599) || (zipcode >= 56900 && zipcode <= 56999) ) {
240        st = 'DC';
241    } else if (zipcode >= 98000 && zipcode <= 99499) {
242        st = 'WA';
243    } else if (zipcode >= 24700 && zipcode <= 26999) {
244        st = 'WV';
245    } else if (zipcode >= 53000 && zipcode <= 54999) {
246        st = 'WI';
247    } else if (zipcode >= 82000 && zipcode <= 83199) {
248        st = 'WY';
249    } else {
250        // If we didn't find their zip, set the error on the zip input
251        console.log('Enter a valid zip code');
252        elm.setCustomValidity('Enter a valid zip code');
253        return;
254    }
255    // If "st" has a value, we found a state and are done here
256    if (st) {
257        // We set a cookie with short expiration so that we can catch a redirect to the homepage on browsers like Chrome
258        $.cookie('redirectUrl', document.location.pathname + '?resp=success', { expires: .01, path: "/" });
259        // Set the user's state code
260        document.getElementById('st').value = st;
261        // Clear the zip code error
262        elm.setCustomValidity('');
263        // End validation
264        return;
265    }
266}

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.