PageSourceSearch

https://primitivegamesstudio.com/js/scripts.js

js primitivegamesstudio.com collected 2026-09-24 10:42:42 UTC 4,376 bytes, 158 lines download raw bytes

1/* Description: Custom JS file */
2
3/* Navigation*/
4// Collapse the navbar by adding the top-nav-collapse class
5window.onscroll = function () {
6	scrollFunction();
7	scrollFunctionBTT(); // back to top button
8};
9
10function scrollFunction() {
11	let intViewportWidth = window.innerWidth;
12	if (
13		document.body.scrollTop > 30 ||
14		(document.documentElement.scrollTop > 30) & (intViewportWidth > 991)
15	) {
16		document.getElementById("navbar").classList.add("top-nav-collapse");
17	} else if (
18		document.body.scrollTop < 30 ||
19		(document.documentElement.scrollTop < 30) & (intViewportWidth > 991)
20	) {
21		document.getElementById("navbar").classList.remove("top-nav-collapse");
22	}
23}
24
25// Navbar on mobile
26let elements = document.querySelectorAll(".nav-link:not(.dropdown-toggle)");
27
28for (let i = 0; i < elements.length; i++) {
29	elements[i].addEventListener("click", () => {
30		document.querySelector(".offcanvas-collapse").classList.toggle("open");
31	});
32}
33
34document.querySelector(".navbar-toggler").addEventListener("click", () => {
35  	document.querySelector(".offcanvas-collapse").classList.toggle("open");
36});
37
38// Hover on desktop
39function toggleDropdown(e) {
40	const _d = e.target.closest(".dropdown");
41	let _m = document.querySelector(".dropdown-menu", _d);
42
43	setTimeout(
44		function () {
45		const shouldOpen = _d.matches(":hover");
46		_m.classList.toggle("show", shouldOpen);
47		_d.classList.toggle("show", shouldOpen);
48
49		_d.setAttribute("aria-expanded", shouldOpen);
50		},
51		e.type === "mouseleave" ? 300 : 0
52	);
53}
54
55// On hover
56document.querySelector(".dropdown").addEventListener("mouseleave", toggleDropdown);
57
58document.querySelector(".dropdown").addEventListener("mouseover", toggleDropdown);
59
60// On click
61document.querySelector(".dropdown").addEventListener("click", (e) => {
62	const _d = e.target.closest(".dropdown");
63	let _m = document.querySelector(".dropdown-menu", _d);
64	if (_d.classList.contains("show")) {
65		_m.classList.remove("show");
66		_d.classList.remove("show");
67	} else {
68		_m.classList.add("show");
69		_d.classList.add("show");
70	}
71});
72  
73
74/* Card Slider - Swiper */
75var cardSlider = new Swiper('.card-slider', {
76	autoplay: {
77		delay: 4000,
78		disableOnInteraction: false
79	},
80	loop: true,
81	navigation: {
82		nextEl: '.swiper-button-next',
83		prevEl: '.swiper-button-prev'
84	}
85});
86
87
88/* Modal Button Close And Scroll To Link */
89const theModal = document.getElementById('staticBackdrop');
90// Needs the if otherwise it will serve error on pages without the modal like the extra pages
91if (theModal !== null) { 
92	const theModalGen = new bootstrap.Modal(theModal);
93	const theModalCtaBtn = document.getElementById('modalCtaBtn');
94	theModalCtaBtn.addEventListener('click', function () {
95		theModalGen.hide(); 
96	})
97}
98
99
100/* Back To Top Button */
101// Get the button
102myButton = document.getElementById("myBtn");
103
104// When the user scrolls down 20px from the top of the document, show the button
105function scrollFunctionBTT() {
106	if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
107		myButton.style.display = "block";
108	} else {
109		myButton.style.display = "none";
110	}
111}
112
113// When the user clicks on the button, scroll to the top of the document
114function topFunction() {
115	document.body.scrollTop = 0; // for Safari
116	document.documentElement.scrollTop = 0; // for Chrome, Firefox, IE and Opera
117}
118
119function submitToAPI(e) {
120	e.preventDefault();
121	var URL = "https://vozd7wdota.execute-api.us-east-2.amazonaws.com/prod/api/sendemail";
122
123	var name = document.getElementById("name-input").value;
124	var email = document.getElementById("email-input").value;
125	var desc = document.getElementById("message-input").value;
126	var data = {
127	   Name : name,
128	   Email : email,
129	   Desc : desc
130	 };
131
132	 
133	 $.ajax({
134		type: "POST",
135		url : URL,
136		dataType: "json",
137		crossDomain: "true",
138		contentType: "application/json",
139		data: JSON.stringify(data),
140
141		success: function (json, status, xhr) {
142			if(xhr.status === 204) {
143				json = {};
144			}
145		  // clear form and show a success message
146		  alert("Success!");
147		  document.getElementById("contact-form").reset();
148	  location.reload();
149		},
150		error: function () {
151		  // show an error message
152		  alert("Thanks!");
153		  document.getElementById("contact-form").reset();
154		}
155  
156		
157		});
158  }

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.