PageSourceSearch

https://mariodemiranda.com/js/main.js

js mariodemiranda.com collected 2026-10-02 12:57:29 UTC 16,123 bytes, 488 lines download raw bytes

1$(document).ready(function () {
2	//Homepage Banner Slider
3	$(".cartoon-slider").owlCarousel({
4		loop: true,
5		margin: 0,
6		items: 1,
7		autoplay: true,
8		autoplayTimeout: 2000,
9		smartSpeed: 800,
10		autoplayHoverPause: true,
11		nav: false,
12		dots: true,
13	});
14	//size chart
15	$(".s_chart").css("visibility", "hidden");
16	if ($(".s_c").val() == "size") {
17		$(".s_chart").css("display", "block");
18		$(".s_chart").css("visibility", "visible");
19	}
20	//Color Validation
21	$(".prod-color").on("click", function () {
22		$(".color ul li a img").css("visibility", "hidden");
23		$(this).find("img").css("visibility", "visible");
24		var colorId = $(this).attr("id");
25		$(".prod-color-order").val($(this).attr("name") + "|" + colorId);
26	});
27	//Size Validation
28	$(".prod-size").on("click", function () {
29		$(".size ul li a").css("background-color", "#eee");
30		$(this).css("background-color", "#fdbe19");
31		var sizeId = $(this).attr("id");
32		$(".prod-size-order").val($(this).text() + "|" + sizeId);
33		var datastring = "attr_id=" + sizeId;
34		$.ajax({
35			type: "POST",
36			url: "config/api.php",
37			data: datastring,
38			cache: false,
39			success: function (response) {
40				if (parseInt(response) > 0) {
41					$(".product-rate").text(response);
42				}
43			},
44			error: function (response) {
45				alert("Something went wrong, Please try again after sometime!");
46			},
47		});
48	});
49
50	$(".prod-size-1").on("click", function () {
51		var sizeId = $(this).attr("id");
52		$(".prod-size-order").val($(this).val() + "|" + sizeId);
53		var datastring = "attr_id=" + sizeId;
54		$.ajax({
55			type: "POST",
56			url: "config/api.php",
57			data: datastring,
58			cache: false,
59			success: function (response) {
60				if (parseInt(response) > 0) {
61					$(".product-rate").text(response);
62				}
63			},
64			error: function (response) {
65				alert("Something went wrong, Please try again after sometime!");
66			},
67		});
68	});
69
70	//Cart Count Adjustment
71	if ($(".total-count").text() == 0) $(".total-count").css("display", "none");
72	else $(".total-count").css("display", "block");
73	//Cart Count Adjustment On change in cart list
74	$(".total-count").on("DOMSubtreeModified", function () {
75		if ($(".total-count").text() == 0) $(".total-count").css("display", "none");
76		else $(".total-count").css("display", "block");
77	});
78	//Selected Greeting
79	if ($(".selected-greeting").val() != "") {
80		$("#greeting-select-" + $(".selected-greeting").val())
81			.children("img")
82			.css("border", "4px solid #fdbe19");
83	}
84	//Greeting Value
85	if (parseInt($(".gift-wrap-total").text().replace("₹ ", ""), 10) == 0) {
86		$(".gift-wrap-line").css("display", "none");
87	}
88	checkGiftWraps();
89});
90
91//Add Item to Cart
92$(".add-to-cart-btn").on("click", function () {
93	if ($(this).text().includes("Go To Cart")) window.location.href = $(".add-to-cart-btn").attr("onclick");
94	else {
95		var color = $(".prod-color-order").val();
96		var size = $(".prod-size-order").val();
97		var quant = $(".input-number").val();
98		var prodId = $(".productid").val();
99		var prodCatId = $(".productcatid").val();
100		var price = $(".discount").text().replace("₹ ", "");
101		$(".color ul").css("border", "1px solid white");
102		$(".size ul").css("border", "1px solid white");
103		if (color == "" || size == "") {
104			if (color == "") $(".color ul").css("border", "1px solid red");
105			if (size == "") $(".size ul").css("border", "1px solid red");
106			return false;
107		}
108		var datastring = "color=" + color + "&size=" + size + "&quant=" + quant + "&productid=" + prodId + "&productcatid=" + prodCatId + "&price=" + price;
109		$.ajax({
110			type: "POST",
111			url: "processcart",
112			data: datastring,
113			cache: false,
114			success: function (response) {
115				$(".total-count").html(response);
116				$(".add-to-cart-btn").html("Go To Cart");
117				$(".add-to-cart-btn").attr("onclick", "cart");
118			},
119			error: function (response) {
120				alert("Something went wrong, Please try again after sometime!");
121			},
122		});
123		return true;
124	}
125});
126
127$(".sub-add-to-cart-btn").on("click", function () {
128	if ($(this).text().includes("Go To Cart")) window.location.href = $(".sub-add-to-cart-btn").attr("onclick");
129	else {
130		var color = $(".sub-prod-color-order").val();
131		var size = $(".sub-prod-size-order").val();
132		var quant = 1;
133		var prodId = $(this).attr("name");
134		var prodCatId = $(".productcatid").val();
135		var price = $(".sub-discount-" + prodId)
136			.text()
137			.replace("₹ ", "");
138		var datastring = "color=" + color + "&size=" + size + "&quant=" + quant + "&productid=" + prodId + "&productcatid=" + prodCatId + "&price=" + price;
139		$.ajax({
140			type: "POST",
141			url: "processcart",
142			data: datastring,
143			cache: false,
144			success: function (response) {
145				$(".total-count").html(response);
146				$("button[name='" + prodId + "']").html("Go To Cart");
147				$("button[name='" + prodId + "']").attr("onclick", "cart");
148			},
149			error: function (response) {
150				alert("Something went wrong, Please try again after sometime!");
151			},
152		});
153		return true;
154	}
155});
156
157//Cart Quantity Addition
158$(".cart-item-add").on("click", function () {
159	var prodId = $(this).attr("name").split("|")[0];
160	var cartKey = $(this).attr("name").split("|")[1];
161	var qty = parseInt($(".item-qty-" + prodId).val(), 10);
162	var price = parseInt(
163		$(".item-price-" + prodId)
164			.text()
165			.replace("₹ ", ""),
166		10
167	);
168	var stotal = parseInt($(".cart-subtotal").text().replace("₹ ", ""), 10);
169	var giftwp = isNaN(parseInt($(".gift-wrap-total").text().replace("₹ ", ""), 10)) ? 0 : parseInt($(".gift-wrap-total").text().replace("₹ ", ""), 10);
170	$(".total-amount-" + prodId).html("<b>&#8377; " + qty * price + "</b>");
171	$(".cart-subtotal").html("<b>&#8377; " + (stotal + price) + "</b>");
172	var discount = parseInt($(".cart-discount").text().replace("- ₹ ", ""), 10);
173	$(".cart-total").html("<b>&#8377; " + (stotal + price + giftwp - discount) + "</b>");
174	var datastring = "operation=UPD&cartkey=" + cartKey + "&quantity=" + qty + "&productid=" + prodId;
175	$.ajax({
176		type: "POST",
177		url: "processcart",
178		data: datastring,
179		cache: false,
180		success: function (response) {},
181		error: function (response) {
182			alert("Something went wrong, Please try again after sometime!");
183		},
184	});
185});
186
187//Cart Quantity Reduction
188$(".cart-item-minus").on("click", function () {
189	var prodId = $(this).attr("name").split("|")[0];
190	var cartKey = $(this).attr("name").split("|")[1];
191	var qty = parseInt($(".item-qty-" + prodId).val(), 10);
192	var price = parseInt(
193		$(".item-price-" + prodId)
194			.text()
195			.replace("₹ ", ""),
196		10
197	);
198	var stotal = parseInt($(".cart-subtotal").text().replace("₹ ", ""), 10);
199	var giftwp = isNaN(parseInt($(".gift-wrap-total").text().replace("₹ ", ""), 10)) ? 0 : parseInt($(".gift-wrap-total").text().replace("₹ ", ""), 10);
200	$(".total-amount-" + prodId).html("<b>&#8377; " + qty * price + "</b>");
201	$(".cart-subtotal").html("<b>&#8377; " + (stotal - price) + "</b>");
202	var discount = parseInt($(".cart-discount").text().replace("- ₹ ", ""), 10);
203	$(".cart-total").html("<b>&#8377; " + (stotal - price + giftwp - discount) + "</b>");
204	var datastring = "operation=UPD&cartkey=" + cartKey + "&quantity=" + qty + "&productid=" + prodId;
205	if ($(".coupon-mini").val() > stotal - price) {
206		$(".cart-discount").html("<b>- &#8377; 0 </b>");
207		$(".coupon-code").val("");
208	}
209	$.ajax({
210		type: "POST",
211		url: "processcart",
212		data: datastring,
213		cache: false,
214		success: function (response) {},
215		error: function (response) {
216			alert("Something went wrong, Please try again after sometime!");
217		},
218	});
219});
220
221//Cart Item Delete
222$(".cart-item-delete").on("click", function () {
223	var prodId = $(this).attr("name").split("|")[0];
224	var cartKey = $(this).attr("name").split("|")[1];
225	var qty = parseInt($(".item-qty-" + prodId).val(), 10);
226	var price = parseInt(
227		$(".item-price-" + prodId)
228			.text()
229			.replace("₹ ", ""),
230		10
231	);
232	var stotal = parseInt($(".cart-subtotal").text().replace("₹ ", ""), 10);
233	var giftwp = isNaN(parseInt($(".gift-wrap-total").text().replace("₹ ", ""), 10)) ? 0 : parseInt($(".gift-wrap-total").text().replace("₹ ", ""), 10);
234	stotal = stotal - qty * price;
235	$(".cart-subtotal").html("<b>&#8377; " + stotal + "</b>");
236	var discount = parseInt($(".cart-discount").text().replace("- ₹ ", ""), 10);
237	$(".cart-total").html("<b>&#8377; " + (stotal + giftwp - discount) + "</b>");
238	var datastring = "operation=DEL&cartkey=" + cartKey + "&productid=" + prodId;
239	$.ajax({
240		type: "POST",
241		url: "processcart",
242		data: datastring,
243		cache: false,
244		success: function (response) {
245			$(".cart-item-" + prodId).css("display", "none");
246			$(".cart-item-" + prodId).remove();
247			$(".total-count").html(response);
248			checkGiftWraps();
249			emptyCartCheck();
250		},
251		error: function (response) {
252			alert("Something went wrong, Please try again after sometime!");
253		},
254	});
255});
256
257//Cart Gift Wrap
258$(".greeting-btn").click(function () {
259	event.preventDefault();
260	if ($(".selected-greeting").val() == "") {
261		$(".owl-stage-outer").css("border", "3px solid red");
262	} else {
263		var greetingId = $(".selected-greeting").val();
264		var greetingMsg = $(".greeting-message").val();
265		var datastring = "greetingid=" + greetingId + "&greetingmessage=" + greetingMsg;
266		$.ajax({
267			type: "POST",
268			url: "processcart",
269			data: datastring,
270			cache: false,
271			success: function (response) {
272				$(".greeting-btn").html("Edit Message");
273			},
274			error: function (response) {
275				alert("Something went wrong, Please try again after sometime!");
276			},
277		});
278	}
279});
280
281$(".gift-wrap").click(function () {
282	var productId = $(this).attr("id");
283	var giftcharge = parseInt(50, 10);
284	var operation;
285	if ($(this).is(":checked")) {
286		var stotal = parseInt($(".cart-subtotal").text().replace("₹ ", ""), 10);
287		var giftwp = isNaN(parseInt($(".gift-wrap-total").text().replace("₹ ", ""), 10)) ? 0 : parseInt($(".gift-wrap-total").text().replace("₹ ", ""), 10);
288		giftwp += giftcharge;
289		var discount = parseInt($(".cart-discount").text().replace("- ₹ ", ""), 10);
290		$(".cart-total").html("<b>&#8377; " + (stotal + giftwp - discount) + "</b>");
291		operation = "Y";
292	} else {
293		var stotal = parseInt($(".cart-subtotal").text().replace("₹ ", ""), 10);
294		var giftwp = isNaN(parseInt($(".gift-wrap-total").text().replace("₹ ", ""), 10)) ? 0 : parseInt($(".gift-wrap-total").text().replace("₹ ", ""), 10);
295		giftwp -= giftcharge;
296		var discount = parseInt($(".cart-discount").text().replace("- ₹ ", ""), 10);
297		$(".cart-total").html("<b>&#8377; " + (stotal + giftwp - discount) + "</b>");
298		operation = "N";
299	}
300	$(".gift-wrap-total").html("<b>&#8377; " + giftwp + "</b>");
301	giftwp > 0 ? $(".gift-wrap-line").css("display", "block") : $(".gift-wrap-line").css("display", "none");
302	var datastring = "productid=" + productId + "&greetingstatus=" + operation;
303	$.ajax({
304		type: "POST",
305		url: "processcart",
306		data: datastring,
307		cache: false,
308		success: function (response) {
309			checkGiftWraps();
310		},
311		error: function (response) {
312			alert("Something went wrong, Please try again after sometime!");
313		},
314	});
315});
316
317$(".greeting-select").click(function () {
318	$(".greeting-select").children("img").css("border", "none");
319	$(this).children("img").css("border", "4px solid #fdbe19");
320	var greetingId = $(this).attr("name");
321	$(".selected-greeting").val(greetingId);
322});
323
324function checkGiftWraps() {
325	var inputElems = document.getElementsByTagName("input"),
326		count = 0;
327	for (var i = 0; i < inputElems.length; i++) {
328		if (inputElems[i].type === "checkbox" && inputElems[i].checked === true) {
329			count++;
330		}
331	}
332	if (count == 0) $(".greeting-section").css("display", "none");
333	else $(".greeting-section").css("display", "block");
334}
335
336function emptyCartCheck() {
337	var inputElems = document.getElementsByClassName("product-des"),
338		count = inputElems.length;
339	if (count == 0) location.reload();
340}
341
342//Coupon Functionality
343$(".coupon-btn").on("click", function () {
344	var couponCode = $(".coupon-code").val();
345	$(".coupon-error").css("display", "block");
346	var stotal = parseInt($(".cart-subtotal").text().replace("₹ ", ""), 10);
347	var datastring = "coupon=" + couponCode;
348	if (couponCode != "") {
349		$.ajax({
350			type: "GET",
351			url: "config/api.php",
352			data: datastring,
353			cache: false,
354			success: function (response) {
355				if (response == "NF") {
356					$(".coupon-error").html("Coupon is Invalid!");
357					$(".coupon-error").css("display", "block");
358				} else {
359					var discount = response.split("|")[0];
360					var minamount = response.split("|")[1];
361					if (minamount >
361 stotal) {
362						$(".coupon-error").css("display", "block");
363						$(".coupon-code").val("");
364						$(".coupon-error").html("Coupon is applicable on minimum purchase of &#8377; " + minamount);
365					} else {
366						$(".coupon-mini").val(minamount);
367						$(".cart-discount").html("<b>- &#8377; " + discount + "</b>");
368						$(".cart-total").html("<b>&#8377; " + (stotal - discount) + "</b>");
369						$(".coupon-error").css("display", "none");
370						//Setting coupon in session
371						$.ajax({
372							type: "POST",
373							url: "processcart",
374							data: datastring,
375							cache: false,
376							success: function (response) {},
377							error: function (response) {
378								alert("Something went wrong, Please try again after sometime!");
379							},
380						});
381					}
382				}
383			},
384			error: function (response) {
385				alert("Something went wrong, Please try again after sometime!");
386			},
387		});
388	}
389});
390
391//Add Product to Wishlist
392$(".add-wishlist").on("click", function () {
393	var prodid = $(".productid").val();
394	var userid = $(".userid").val();
395	if (userid == "NULL") window.location.href = "login";
396	else {
397		datastring = "prod=" + prodid + "&user=" + userid;
398		$.ajax({
399			type: "POST",
400			url: "config/api.php",
401			data: datastring,
402			cache: false,
403			success: function (response) {
404				$(".add-wishlist").css("background-color", "#fdbe19");
405			},
406			error: function (response) {
407				alert("Something went wrong, Please try again after sometime!");
408			},
409		});
410	}
411});
412
413//Address Edit Redirection
414$(".edit-address").on("click", function () {
415	$("#exampleModal").modal("toggle");
416	$("#exampleModal").modal("show");
417});
418
419//Checkout Form Validation
420$(".final-checkout-btn").on("click", function () {
421	var flowType = $(".selected-address").val();
422	if (flowType == "GUEST") {
423		//
424	} else if (flowType == "NOT_SELECTED") {
425		alert("Please choose a address to proceed further!");
426	} else {
427		window.location.href = "place-order/" + flowType;
428	}
429});
430
431//Checkout Address Selection
432$(".customer-address-city").change(function () {
433	var countryId = $(this).val();
434	var cart = $(".cart-data").val();
435
436	if (countryId > 0) {
437		$.ajax({
438			type: "POST",
439			url: "shipping.php",
440			data: {
441				shippingCountry: countryId,
442				cartDump: cart,
443			},
444			cache: false,
445			success: function (response) {
446				console.log("Response in success is: ");
447				console.log(response);
448
449				if (response >= 0) {
450					var subtotal = parseInt($(".cart-subtotal").text().replace("₹ ", ""), 10);
451					if (isNaN(parseInt($(".cart-gift-wrap").text().replace("₹ ", ""), 10))) var giftWrap = 0;
452					else var giftWrap = parseInt($(".cart-gift-wrap").text().replace("₹ ", ""), 10);
453					if (isNaN(parseInt($(".cart-discount").text().replace("₹ ", ""), 10))) var cartDisc = 0;
454					else var cartDisc = parseInt($(".cart-discount").text().replace("₹ ", ""), 10);
455
456					if (isNaN(parseInt($(".cart-offer-discount").text().replace("₹ ", ""), 10))) var offrDisc = 0;
457					else var offrDisc = parseInt($(".cart-offer-discount").text().replace("₹ ", ""), 10);
458
459					var shipping = parseInt(response, 10);
460					var totalAmt = parseInt(subtotal + giftWrap + shipping - cartDisc - offrDisc, 10);
461
462					$(".cart-shipping").html("&#8377; " + response);
463					$(".cart-total").html("&#8377; " + totalAmt);
464				}
465			},
466			error: function (response) {
467				console.log("Response in error: " + response);
468				alert("Something went wrong, Please try again after sometime!");
469			},
470		});
471	}
472});
473
474//Toggle Display
475function toggleDisplay(d, b) {
476	var c = document.getElementById(d);
477	if (c.style.display == "block") {
478		c.style.display = "none";
479		if (b) {
480			b.innerHTML = "Read more...";
481		}
482	} else {
483		c.style.display = "block";
484		if (b) {
485			b.innerHTML = "Read less...";
486		}
487	}
488}

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.