Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions js/addNewEvent.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
/* --------------------------
* UPDATE UPCOMING EVENT DATE
* --------------------------
* --------------------------
*
* IMPORTANT: The date has to be in the Pacific Standard Time (PST) zone
*
*/
const
const
// The time zone when the event will be held. Format: time zone identifier (e.g., "PDT" or "PST")
timeZone = 'PDT',
// Format: YYYY (2020)
year = 2021,
// The month as a number, not the index
// Format: MM (09) or M (9), both are valid
// Format: MM (09) or M (9), both are valid
month = 06,
// Format: DD (09) or D (9), both are valid
day = 07,
// Format: 0 - 24 / 5 == 5 AM / 17 == 5 PM
day = 07,
// Format: 0 - 24 / 5 == 5 AM / 17 == 5 PM
hour = 10,
// Format: MM (09) or M (9), both are valid
minute = 00;
Expand All @@ -25,3 +25,4 @@ minute = 00;
* --------------------------
*/
const eventName = 'Glow and behold.';
const calendarUrl = 'https://www.apple.com/v/apple-events/home/q/built/assets/event.ics';
25 changes: 3 additions & 22 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if (distance < -7200001) {
timer = setInterval(showRemaining, 1000);
}

createCalendar(eventName, start, end);
createCalendar();

function showRemaining() {
let now = new Date(),
Expand All @@ -42,8 +42,6 @@ function showRemaining() {
minutes = Math.floor((distance % _hour) / _minute),
seconds = Math.floor((distance % _minute) / _second);

console.log(days / 100)

if(days / 100 < 1) {
$('#days').html(("0" + days).slice(-2));
} else {
Expand All @@ -54,23 +52,6 @@ console.log(days / 100)
$('#seconds').html(("0" + seconds).slice(-2));
}

function createCalendar(title, startDate, endDate) {
let startTime = startDate.toISOString().replace(/-|:|\.\d+/g, '');
let endTime = endDate.toISOString().replace(/-|:|\.\d+/g, '');
let href = encodeURI(
'data:text/calendar;charset=utf8,' + [
'BEGIN:VCALENDAR',
'VERSION:2.0',
'BEGIN:VEVENT',
'URL:' + document.URL,
'DTSTART:' + (startTime || ''),
'DTEND:' + (endTime),
'SUMMARY:' + (title || ''),
'DESCRIPTION:' + (''),
'LOCATION:' + (''),
'END:VEVENT',
'END:VCALENDAR'].join('\n')
);

$("#localtime").append('<a href="' + href + '"><img class="ics" src="./images/cal.svg" alt=""/></a>');
function createCalendar() {
$("#localtime").append('<a href="' + calendarUrl + '"><img class="ics" src="./images/cal.svg" alt=""/></a>');
}