PageSourceSearch

https://www.sayanaanswers.co.uk/js/ics/atc.js

js sayanaanswers.co.uk collected 2026-10-08 18:35:16 UTC 2,288 bytes, 65 lines download raw bytes

1// Add to calendar
2
3function parseDate(dateStr) {
4    // Convert date string into Date object
5    const [date, time, period] = dateStr.split(/[\s:]+/);
6    const [day, month, year] = date.split('/').map(Number);
7    let [hours, minutes] = time.split(':').map(Number);
8    // Convert to 24hr time
9    if (period.toLowerCase() === 'pm' && hours !== 12) {
10        hours +=12;
11    }
12    // Base case: midnight
13    if (period.toLowerCase() == 'am' && hours === 12) {
14        hours = 0;
15    }
16    // Create and return UTC date object
17    return new Date(Date.UTC(year, month -1, day, hours, 0));
18}
19
20function atc(){
21    // Extract values from user selection
22    const Title = document.querySelectorAll('span.title')[0].innerHTML;
23    const Description = document.querySelectorAll('span.description')[0].innerHTML.split('<br>').toString().replace(/\.,/g, '. ');
24    const Location = document.querySelectorAll('span.location')[0].innerHTML;
25    const StartStr = document.querySelectorAll('span.start')[0].innerHTML;
26    const EndStr = document.querySelectorAll('span.end')[0].innerHTML;
27    
28    // Convert the strings into Date objects
29    const start = parseDate(StartStr);
30    const end = parseDate(EndStr);
31    // Format the date to ics file standard
32    const formatDate = (date) => {
33        const pad = (num) => (num < 10 ? '0' : '') + num;
34        return date.getUTCFullYear() +
35            pad(date.getUTCMonth() + 1) +
36            pad(date.getUTCDate()) + 'T' +
37            pad(date.getUTCHours()) +
38            pad(date.getUTCMinutes()) +
39            pad(date.getUTCSeconds()) + 'Z';
40    };
41    // Create event content
42    const icsContent = `BEGIN:VCALENDAR
43VERSION:2.0
44PRODID:-//PFIZER UK//SAYANA//EN
45CALSCALE:GREGORIAN
46BEGIN:VEVENT
47DTSTART:${formatDate(start)}
48DTEND:${formatDate(end)}
49SUMMARY:${Title}
50DESCRIPTION:${Description}
51LOCATION:${Location}
52END:VEVENT
53END:VCALENDAR`;
54    // Make MIME type compatible with iCalendar
55    const blob = new Blob([icsContent], { type: 'text/calendar;charset=utf-8;' });
56    // Create downloadable file
57    const link = document.createElement('a');
58    link.href = URL.createObjectURL(blob);
59    link.download = `Injection_Reminder_${StartStr}.ics`;
60
61    document.body.appendChild(link);
62    link.click();
63
64    document.body.removeChild(link);
65}

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.