Hack #39. Build Calendar Events
Use a graphical interface to construct HCalendar event markup.
HCalendar is an emerging microformat for displaying event information in XHTML. An HCalendar event can be displayed as is in any web page; the raw data itself is already valid XHTML (and HTML). But the data is structured enough that it can be processed by scripts without any complicated heuristics or loss of data.
Tip
Learn more about microformats at http://microformats.org.
This hack adds a complete HCalendar interface for entering event information in web forms.
The Code
This user script runs on all pages. You can change the @include parameter to run only on HCalendar-aware scheduling sites. It adds a link before each <textarea> element to show the HCalendar interface. When you click the hCal link, it replaces the <textarea> with a subform that contains all the common HCalendar fields, such as the event summary, start and end times, and a URL for more information. Once you submit the HCalendar form, the script constructs the HCalendar markup for you and inserts it into the original <textarea>.
Save the following user script as magic-hcalendar.user.js:
// ==UserScript== // @name Magic hCalendar Microformatter // @namespace http://www.decafbad.com/ // @description Enhances text areas with hCalendar microformat tools // @include * // ==/UserScript== // based on code by Les Orchard // and included here with his gracious permission function HCalendarCreator(editor_id, callback) { this.editor_id ...Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access