Widget:ICSGenerator: Difference between revisions
Jump to navigation
Jump to search
Fixed documentation import |
Fixed hashing |
||
Line 1: | Line 1: | ||
<includeonly><span class="ics-container"><script>function buildIcsLink(name, start, end) { | <includeonly><span class="ics-container"><script>/* Hashing as seen on https://stackoverflow.com/a/52171480 */ | ||
var cyrb53 = function(str, seedRaw) { | |||
var seed = seedRaw || 0; | |||
var h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed; | |||
for (var i = 0, ch; i < str.length; i++) { | |||
ch = str.charCodeAt(i); | |||
h1 = Math.imul(h1 ^ ch, 2654435761); | |||
h2 = Math.imul(h2 ^ ch, 1597334677); | |||
} | |||
h1 = Math.imul(h1 ^ (h1>>>16), 2246822507) ^ Math.imul(h2 ^ (h2>>>13), 3266489909); | |||
h2 = Math.imul(h2 ^ (h2>>>16), 2246822507) ^ Math.imul(h1 ^ (h1>>>13), 3266489909); | |||
return 4294967296 * (2097151 & h2) + (h1>>>0); | |||
}; | |||
function buildIcsLink(name, start, end) { | |||
var currentTime = new Date().toISOString(); | var currentTime = new Date().toISOString(); | ||
var hash = cyrb53("" + name + start + end); | |||
var icsContent = "BEGIN:VCALENDAR\r\n"; | var icsContent = "BEGIN:VCALENDAR\r\n"; | ||
icsContent += "VERSION:2.0\r\n"; | icsContent += "VERSION:2.0\r\n"; | ||
Line 8: | Line 24: | ||
icsContent += "BEGIN:VEVENT\r\n"; | icsContent += "BEGIN:VEVENT\r\n"; | ||
icsContent += "DTSTAMP:" + currentTime + "\r\n"; | icsContent += "DTSTAMP:" + currentTime + "\r\n"; | ||
icsContent += "UID: | icsContent += "UID:" + hash + "\r\n"; | ||
icsContent += "DTSTART;TZID=/Etc/UTC:" + start + "\r\n"; | icsContent += "DTSTART;TZID=/Etc/UTC:" + start + "\r\n"; | ||
icsContent += "DTEND;TZID=/Etc/UTC:" + end + "\r\n"; | icsContent += "DTEND;TZID=/Etc/UTC:" + end + "\r\n"; |
Revision as of 18:17, 17 February 2022
Creates a download link for an ICS file (event date container).
Parameter | Description | Type | Status | |
---|---|---|---|---|
Title of the event | title | The general title of the event. This is the text that will be shown in a calendar. Keep it short.
| String | required |
Event start | start | The start date of the event.
| Date | required |
Event end | end | The ending of the event.
| Date | required |
Usage
See the widget's testcases:
Test with given full date definition | |
---|---|
Wiki code | {{#widget:ICSGenerator |title=Name of the event |start=20220218T194956 |end=20220218T195956}} |
Main version | |
Sandbox version | (no sandbox subpage) |
Test with short date definition | |
---|---|
Wiki code | {{#widget:ICSGenerator |title=Name of the event |start=20220218T194956 |end=20220218T195956}} |
Main version | |
Sandbox version | (no sandbox subpage) |
See also
The above documentation is transcluded from Widget:ICSGenerator/doc. (edit | history) |