Skip to content

Commit 099c0ad

Browse files
Add files via upload
1 parent be959fe commit 099c0ad

3 files changed

Lines changed: 245 additions & 141 deletions

File tree

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE HTML>
22
<html>
33
<head>
4-
<title>Jerry Codes</title>
4+
<title>Jerry Codes Stuff</title>
55
<link rel="stylesheet" type="text/css" href="styles/styles.css">
66
<meta name="viewport" content="width=device-width, initial-scale=1">
77
<meta name="description" content="Welcome to JerryCodes! I am a frontend web developer, and this is where I infrequently post everything from updates to projects. Have a look around if you like.">

scripts/analytics.js

Lines changed: 62 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ async function sendAnalytics(p) {
3535
const formData = new FormData();
3636
formData.append("data", JSON.stringify(log));
3737

38-
fetch('https://script.google.com/macros/s/AKfycbxAP4kL4hH0YTdpJsUC1jKGlnIKYa4RnHnG532hX2IJHK6FXIebVEuPyuwJv8veVNyD/exec', {
38+
fetch('https://script.google.com/macros/s/AKfycbyjf6pKC8fpgh_8Ee081286tvSxpSQve2rKgUv4x5GeTTwFuIZQkOSz0eMg6lxE2JU/exec', {
3939
method: 'POST',
4040
body: formData
4141
})
@@ -50,6 +50,22 @@ async function sendAnalytics(p) {
5050
});
5151
}
5252

53+
function getLocalTimeZone() {
54+
const date = new Date();
55+
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
56+
57+
// Get the time zone abbreviation using toLocaleString
58+
const options = { timeZone, timeZoneName: 'short' };
59+
const timeZoneInfo = date.toLocaleString('en-US', options);
60+
61+
// The abbreviation is usually at the end of the returned string
62+
const abbreviation = timeZoneInfo.split(' ').pop();
63+
64+
return `${timeZone} (${abbreviation})`;
65+
}
66+
67+
68+
5369
function getOS() {
5470
const userAgent = navigator.userAgent;
5571

@@ -80,6 +96,43 @@ function getOS() {
8096
}
8197
}
8298

99+
function getDetroitDateTime() {
100+
// Create a date object for the current time
101+
const now = new Date();
102+
103+
// Convert the current time to Detroit time (Eastern Time)
104+
const options = {
105+
timeZone: 'America/New_York',
106+
month: 'long',
107+
day: 'numeric',
108+
year: 'numeric',
109+
hour: 'numeric',
110+
minute: 'numeric',
111+
hour12: true
112+
};
113+
114+
// Get the formatted date
115+
const detroitDate = new Intl.DateTimeFormat('en-US', options).format(now);
116+
117+
// Split the date and time
118+
const [monthDay, year, time] = detroitDate.split(', ');
119+
const [month, dayWithSuffix] = monthDay.split(' ');
120+
121+
// Determine the ordinal suffix for the day
122+
const day = parseInt(dayWithSuffix, 10);
123+
const suffix = (day) => {
124+
if (day > 3 && day < 21) return 'th'; // Catch 11th-13th
125+
return ['st', 'nd', 'rd'][day % 10 - 1] || 'th';
126+
};
127+
128+
// Combine everything into the desired format
129+
return `${month} ${day}${suffix(day)}, ${year}`;
130+
}
131+
132+
function getLocalLanguage() {
133+
return navigator.language || navigator.userLanguage; // For older versions of IE
134+
}
135+
83136
async function getCurrentDateTime(page) {
84137

85138
const now = new Date();
@@ -99,14 +152,17 @@ async function getCurrentDateTime(page) {
99152
const time = now.toLocaleString('en-US', { hour: 'numeric', minute: 'numeric', hour12: true }).toLowerCase();
100153
// Combine everything into the desired format
101154
return {
102-
time: `${month} ${day}${suffix(day)}, ${now.getFullYear()} at ${time}`,
103-
type: page,
104-
post: window.location.hash,
155+
site: window.location.href,
156+
localTime: `${month} ${day}${suffix(day)}, ${now.getFullYear()} at ${time}`,
157+
hqTime: getDetroitDateTime(),
158+
page: page,
159+
hash: window.location.hash,
105160
ip: ip,
106161
os: getOS(),
107162
location: `${locationn.city}, ${locationn.region} ${locationn.postal}`,
163+
timeZone: getLocalTimeZone(),
164+
lang: getLocalLanguage(),
108165
wifi: locationn.org,
109-
gmaps: `https://www.google.com/maps?q=${locationn.loc.split(',')[0]},${locationn.loc.split(',')[1]}`,
110-
site: window.location.href
166+
gmaps: `https://www.google.com/maps?q=${locationn.loc.split(',')[0]},${locationn.loc.split(',')[1]}`
111167
}
112168
}

0 commit comments

Comments
 (0)