Using the dates array in Epoch PrimeThe dates array forms the core of Epoch Prime, containing all important dates, holidays, and events. Users familiar with older Epoch versions (1.0.6 and below) may wonder what to do with the selectedDates array. The dates array in Epoch Prime replaces the function of selectedDates. selectedDates, like before, contains all currently selected dates in the calendar. However, it is now secondary to the dates array, and must be updated if you make any changes to dates. If you use Epoch Prime's date handling routines, you won't have to worry about this at all. Overviewdates is an array contains all dates of importance for Epoch Prime. Dates of importance include any date that is not the default standard, non-selected date. Use dates to specify dates that are holidays, have custom HTML/titles, are not selectable, or are otherwise important to the user. selectedDates is an array containing all dates that are currently selected in Epoch Prime. It is a simple pointer array; each element is a pointer to a date in the dates array—it is updated automatically whenever a date is selected/deselected. Because of the complex nature of date handling in Epoch Prime, we strongly recommend you do not add or remove dates from dates or selectedDates using the push(), pop(), or any other array methods. Instead, use Epoch Prime's XML date features, or the addDates(), selectDates(), removeDates(), and resetSelections() methods. A few additions to the dates stored in datesIn order to enable the extra features in Epoch Prime, a few modifications have been made to the dates that reside in the dates array, namely the addition of several extra properties. These are: canSelectA boolean (true/false) value – whether this date's calendar cell may be selected. selectedA boolean (true/false) value – whether this date's calendar cell is currently selected. typeA string (can be 'normal', or 'holiday') value – if a date is a 'holiday', its calendar cell will have a different color (which you can specify in epoch_styles.css). titleA string (can be any text) value – contains the HTML title (or tooltip) that displays when the user hovers their mouse cursor over this date's calendar cell. You can use this to give hints or brief information about this date to the user. hrefA string (can be any text) value containing a URL for this date. A cell that has a date with a URL will have a hyperlink over the day of the month—you can choose to make it a traditional link (i.e. when the user clicks on the day number only), or a JavaScript link (user clicks anywhere in the cell). See the setURL() entry in the CalCell Object entry for more details. cellHTMLA string (can be any text) value – contains any HTML you want to display under the date number in this date's calendar cell. Since by default Epoch's caledar cells are quite small, we recommend you change the default size of the calendar cells by modifying epoch_styles.css. Adding/Removing Dates Using XMLUsing importXML() to add DatesWith Epoch Prime you can initialize and update the calendar on both page load and at run-time using XML. On Page-LoadThis is the easiest way to get started with the XML importation.
After Page LoadYou can update the dates in the calendar at any time using XML, either created client-side (in your user's browser), or server-side (via AJAX and the XMLHttpRequest object) – either way, the XML format is the same. Getting the XML data via AJAX:Below is a simplified example of an AJAX query to fetch dates from the server. We strongly recommend that you are familiar with general AJAX methods before trying this.
Using importXML() to remove DatesThe format of the datesrem section is very similar to datesadd – however, date tags in datesrem only requires a value attribute.
Tip: You can add and remove dates simultaneously by using both <datesadd> and <datesrem> in the same XML string. Using addDates() and removeDates() MethodsEpoch Prime maintains the addDates() and removeDates() from the Epoch JavaScript Calendar. However, using addDates() is a bit tedious compared to adding dates via XML (due to the additional date properties), but may be advantageous if you just need to add 1 or 2 dates after you've initialized the calendar. Using addDates()
Using removeDates()
Resetting the dates ArrayResetting the dates array is easy; simply call the resetSelections() method. This will remove all normal selected dates, keeping holidays and blackout dates intact.
|