PageSourceSearch

https://cart.pcmatic.com/js/cart-ui-functions.js

js pcmatic.com collected 2026-09-24 10:52:05 UTC 11,182 bytes, 318 lines download raw bytes

1function getState(zipString) {
2
3	/* Ensure param is a string to prevent unpredictable parsing results */
4	if (typeof zipString !== 'string') {
5		//console.error('Must pass the zipcode as a string.');
6		return 'none';
7	}
8  
9	/* Ensure we have exactly 5 characters to parse */
10	if (zipString.length !== 5) {
11		//console.error('Must pass a 5-digit zipcode.');
12		return 'none';
13	}
14  
15	/* Ensure we don't parse strings starting with 0 as octal values */
16	const zipcode = parseInt(zipString, 10);
17  
18	var st = 'none';
19	var stFull = 'none';
20  
21	/* Code cases alphabetized by state */
22	if (zipcode >= 35000 && zipcode <= 36999) {
23		st = 'AL';
24		stFull = 'Alabama';
25	} else if (zipcode >= 99500 && zipcode <= 99999) {
26		st = 'AK';
27		stFull = 'Alaska';
28	} else if (zipcode >= 85000 && zipcode <= 86999) {
29		st = 'AZ';
30		stFull = 'Arizona';
31	} else if (zipcode >= 71600 && zipcode <= 72999) {
32		st = 'AR';
33		stFull = 'Arkansas';
34	} else if (zipcode >= 90000 && zipcode <= 96699) {
35		st = 'CA';
36		stFull = 'California';
37	} else if (zipcode >= 80000 && zipcode <= 81999) {
38		st = 'CO';
39		stFull = 'Colorado';
40	} else if ((zipcode >= 6000 && zipcode <= 6389) || (zipcode >= 6391 && zipcode <= 6999)) {
41		st = 'CT';
42		stFull = 'Connecticut';
43	} else if (zipcode >= 19700 && zipcode <= 19999) {
44		st = 'DE';
45		stFull = 'Delaware';
46	} else if (zipcode >= 32000 && zipcode <= 34999) {
47		st = 'FL';
48		stFull = 'Florida';
49	} else if ( (zipcode >= 30000 && zipcode <= 31999) || (zipcode >= 39800 && zipcode <= 39999) ) {
50		st = 'GA';
51		stFull = 'Georgia';
52	} else if (zipcode >= 96700 && zipcode <= 96999) {
53		st = 'HI';
54		stFull = 'Hawaii';
55	} else if (zipcode >= 83200 && zipcode <= 83999 && zipcode != 83414) {
56		st = 'ID';
57		stFull = 'Idaho';
58	} else if (zipcode >= 60000 && zipcode <= 62999) {
59		st = 'IL';
60		stFull = 'Illinois';
61	} else if (zipcode >= 46000 && zipcode <= 47999) {
62		st = 'IN';
63		stFull = 'Indiana';
64	} else if (zipcode >= 50000 && zipcode <= 52999) {
65		st = 'IA';
66		stFull = 'Iowa';
67	} else if (zipcode >= 66000 && zipcode <= 67999) {
68		st = 'KS';
69		stFull = 'Kansas';
70	} else if (zipcode >= 40000 && zipcode <= 42999) {
71		st = 'KY';
72		stFull = 'Kentucky';
73	} else if (zipcode >= 70000 && zipcode <= 71599) {
74		st = 'LA';
75		stFull = 'Louisiana';
76	} else if (zipcode >= 3900 && zipcode <= 4999) {
77		st = 'ME';
78		stFull = 'Maine';
79	} else if (zipcode >= 20600 && zipcode <= 21999) {
80		st = 'MD';
81		stFull = 'Maryland';
82	} else if ( (zipcode >= 1000 && zipcode <= 2799) || (zipcode == 5501) || (zipcode == 5544 ) ) {
83		st = 'MA';
84		stFull = 'Massachusetts';
85	} else if (zipcode >= 48000 && zipcode <= 49999) {
86		st = 'MI';
87		stFull = 'Michigan';
88	} else if (zipcode >= 55000 && zipcode <= 56899) {
89		st = 'MN';
90		stFull = 'Minnesota';
91	} else if (zipcode >= 38600 && zipcode <= 39999) {
92		st = 'MS';
93		stFull = 'Mississippi';
94	} else if (zipcode >= 63000 && zipcode <= 65999) {
95		st = 'MO';
96		stFull = 'Missouri';
97	} else if (zipcode >= 59000 && zipcode <= 59999) {
98		st = 'MT';
99		stFull = 'Montana';
100	} else if (zipcode >= 27000 && zipcode <= 28999) {
101		st = 'NC';
102		stFull = 'North Carolina';
103	} else if (zipcode >= 58000 && zipcode <= 58999) {
104		st = 'ND';
105		stFull = 'North Dakota';
106	} else if (zipcode >= 68000 && zipcode <= 69999) {
107		st = 'NE';
108		stFull = 'Nebraska';
109	} else if (zipcode >= 88900 && zipcode <= 89999) {
110		st = 'NV';
111		stFull = 'Nevada';
112	} else if (zipcode >= 3000 && zipcode <= 3899) {
113		st = 'NH';
114		stFull = 'New Hampshire';
115	} else if (zipcode >= 7000 && zipcode <= 8999) {
116		st = 'NJ';
117		stFull = 'New Jersey';
118	} else if (zipcode >= 87000 && zipcode <= 88499) {
119		st = 'NM';
120		stFull = 'New Mexico';
121	} else if ( (zipcode >= 10000 && zipcode <= 14999) || (zipcode == 6390) || (zipcode == 501) || (zipcode == 544) ) {
122		st = 'NY';
123		stFull = 'New York';
124	} else if (zipcode >= 43000 && zipcode <= 45999) {
125		st = 'OH';
126		stFull = 'Ohio';
127	} else if ((zipcode >= 73000 && zipcode <= 73199) || (zipcode >= 73400 && zipcode <= 74999) ) {
128		st = 'OK';
129		stFull = 'Oklahoma';
130	} else if (zipcode >= 97000 && zipcode <= 97999) {
131		st = 'OR';
132		stFull = 'Oregon';
133	} else if (zipcode >= 15000 && zipcode <= 19699) {
134		st = 'PA';
135		stFull = 'Pennsylvania';
136	} else if (zipcode >= 300 && zipcode <= 999) {
137		st = 'PR';
138		stFull = 'Puerto Rico';
139	} else if (zipcode >= 2800 && zipcode <= 2999) {
140		st = 'RI';
141		stFull = 'Rhode Island';
142	} else if (zipcode >= 29000 && zipcode <= 29999) {
143		st = 'SC';
144		stFull = 'South Carolina';
145	} else if (zipcode >= 57000 && zipcode <= 57999) {
146		st = 'SD';
147		stFull = 'South Dakota';
148	} else if (zipcode >= 37000 && zipcode <= 38599) {
149		st = 'TN';
150		stFull = 'Tennessee';
151	} else if ( (zipcode >= 75000 && zipcode <= 79999) || (zipcode >= 73301 && zipcode <= 73399) ||  (zipcode >= 88500 && zipcode <= 88599) ) {
152		st = 'TX';
153		stFull = 'Texas';
154	} else if (zipcode >= 84000 && zipcode <= 84999) {
155		st = 'UT';
156		stFull = 'Utah';
157	} else if (zipcode >= 5000 && zipcode <= 5999) {
158		st = 'VT';
159		stFull = 'Vermont';
160	} else if ( (zipcode >= 20100 && zipcode <= 20199) || (zipcode >= 22000 && zipcode <= 24699) || (zipcode == 20598) ) {
161		st = 'VA';
162		stFull = 'Virginia';
163	} else if ( (zipcode >= 20000 && zipcode <= 20099) || (zipcode >= 20200 && zipcode <= 20599) || (zipcode >= 56900 && zipcode <= 56999) ) {
164		st = 'DC';
165		stFull = 'Washington DC';
166	} else if (zipcode >= 98000 && zipcode <= 99499) {
167		st = 'WA';
168		stFull = 'Washington';
169	} else if (zipcode >= 24700 && zipcode <= 26999) {
170		st = 'WV';
171		stFull = 'West Virginia';
172	} else if (zipcode >= 53000 && zipcode <= 54999) {
173		st = 'WI';
174		stFull = 'Wisconsin';
175	} else if ( (zipcode >= 82000 && zipcode <= 83199) || zipcode == 83414 ) {
176		st = 'WY';
177		stFull = 'Wyoming';
178	} else {
179		st = 'none';
180		stFull = 'none';
181	}
182  
183	return st;
184}
185
186$.fn.serializeObject = function() {
187	var o = {};
188	var a = this.serializeArray();
189	$.each(a, function() {
190		if (o[this.name] !== undefined) {
191			if (!o[this.name].push) {
192				o[this.name] = [o[this.name]];
193			}
194			o[this.name].push(this.value || '');
195		} else {
196			o[this.name] = this.value || '';
197		}
198	});
199	return o;
200};
201
202function getIcon(type) {
203	switch (type) {
204		case "error":
205			return "<div class='toast-icon error'><i class='fa-solid fa-triangle-exclamation'></i></div>";
206		case "warning":
207			return "<div class='toast-icon warning'><i class='fa-solid fa-hexagon-exclamation'></i></div>";
208		case "success":
209			return "<div class='toast-icon success'><i class='fa-solid fa-check'></i></div>";
210		case "info":
211		default:
212			return "<div class='toast-icon default'><i class='fa-solid fa-info'></i></div>";
213	}
214}
215
216function getError(rescode) {
217	// https://docs.stripe.com/declines/codes
218	switch (rescode) {
219		case "fraudulent":
220		case "not_permitted":
221		case "lost_card":
222		case "stolen_card":
223		case "do_not_honor":
224		case "generic_decline":
225			return "<div class='toast-error-message'>Generic Decline: Please contact your card issuer for more information.</div>";
226		case "insufficient_funds":
227			return "<div class='toast-error-message'>Insufficient Funds: The card has insufficient funds to complete the purchase. Please attempt your purchase with an alternative payment method.</div>";
228		case "card_velocity_exceeded":
229			return "<div class='toast-error-message'>Card Velocity Exceeded: You have exceeded the balance, credit limit, or transaction amount limit available on your card. Please contact your card issuer for more information.</div>";
230		case "incorrect_zip":
231			return "<div class='toast-error-message'>Incorrect Zip Code: The postal code entered is incorrect, please try again with the correct code.</div>";
232		case "incorrect_cvc":
233			return "<div class='toast-error-message'>Incorrect CVV: The CVV entered is incorrect, please try again with the correct number.</div>";
234		case "expired_card":
235			return "<div class='toast-error-message'>Expired Card: Please check your credit card for the correct expiration date and try again with the correct date.</div>";
236		case "incorrect_number":
237			return "<div class='toast-error-message'>Invalid Account: Please check your credit card for the correct number and try again. Please contact your card issuer for more information.</div>";
238		case "requires_action":
239			return "<div class='toast-error-message'>Unsupported Card: This card requires an additional authentication step, such as MasterCard 3D Secure, which is not supported by the PC Matic shopping cart at this time. Please either enter a different payment method or contact your bank for help on removing the additional authentication requirement.</div>";
240		case "http_500":
241			return "<div class='toast-error-message'>PC Matic Error: Please try again or contact our support team for assistance.</div>";
242		case "pcmatic_fraud":
243			return "<div class='toast-error-message'>PC Matic Error: This transaction has been blocked due to potential fraudulent activity. If this is not a fraudulent transaction, please contact our support team.</div>";
244		case "non_rescode": 
245			return "";
246		case "processing_error":
247		default:
248			return "<div class='toast-error-message'>Unknown Error: Please try again or contact our support team for assistance.</div>";
249	}
250}
251
252function notify({message, type, duration, position, rescode}) {
253	var error = (rescode) ? getError(rescode) : getError();
254
255	let toast = Toastify({
256		text: "<div class='toast-row'>" + getIcon(type) + "<div class='toast-message'>" + message + error + "</div></div>",
257		offset: {
258			x: position ? position.left : null,
259			y: position ? position.top : null
260		},
261		duration: duration || 6000,
262		close: true,  
263		gravity: "top",
264		position: "right",
265		stopOnFocus: true,
266		escapeMarkup: false
267	});
268
269	toast.showToast();
270	var toastElement = toast.toastElement;
271	toastElement.style.cursor = 'pointer';
272	toastElement.addEventListener('click', function () {
273		toast.hideToast(); // Close the toast when clicked
274	});
275}
276
277function changeAutoRenewal(element) {	
278	// 0 = Turning it on | 1 = Turning it off
279	var autorenew = $(element).closest("form").find("#renew_type").val() 
280
281	if (autorenew == 1) {
282
283		$(".confirm-cancel-overlay").show();
284
285		$("#stay-active").click(function () {
286			$(".confirm-cancel-overlay").hide();
287
288			// Reset the toggle to the state it was before they clicked it
289			$(element).prop("checked", true);
290		})
291
292		$("#cancel-subscription").click(function (){
293			$(element).closest("form").submit();
294			$(".confirm-cancel-overlay").hide();
295			
296			var notifyData = {
297				message: "Automatic renewal has been disabled. You can continue using it until your expiration date arrives.",
298				type: "success",
299				duration: 6000,
300				rescode: "non_rescode"
301			}
302
303			notify(notifyData)
304		})
305	} else {
306		$(element).closest("form").submit();
307		$(".confirm-cancel-overlay").hide();
308			
309		var notifyData = {
310			message: "Automatic renewal has been enabled!",
311			type: "success",
312			duration: 6000,
313			rescode: "non_rescode"
314		}
315
316		notify(notifyData)
317	}
318}

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.