author | ivanl |
Tue, 09 Mar 2010 10:34:58 +0000 | |
changeset 20 | 918767a9c8d3 |
parent 7 | 97dcd250e5be |
permissions | -rw-r--r-- |
7
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
1 |
/*************** START iCalReader.js ******************************************************************************/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
2 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
3 |
/* HEADER START |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
4 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
5 |
iCalendar Reader for Javascript v. 1.1 |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
6 |
Parses and reads iCalendar data format. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
7 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
8 |
By Per-Kristian Nordnes (pk@yammin.com), august 2007. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
9 |
Copyright (C) 2007 - Per Kristian Nordnes. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
10 |
All rights reserved. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
11 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
12 |
The parsing algorithm in iCalendar.parse() is inspired by a PHP-script by Roman Ožana. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
13 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
14 |
Changelog: |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
15 |
1.0 - Initial release (aug. 2007). |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
16 |
1.1 - Some fixes for parsing Google iCal-data. Thanks to Emilis Dambauskas (feb. 25, 2008) |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
17 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
18 |
Contents: |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
19 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
20 |
Class: iCalReader() - parser object. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
21 |
Public methods: |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
22 |
* Array prepareData(String data) : set and prepare iCalendar data to read. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
23 |
Throws exception if invalid data. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
24 |
* void parse() : parse the data. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
25 |
* void sort() : sort events in the calendar object. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
26 |
* vCalendar getCalendar() : get the calendar object. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
27 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
28 |
Class: vCalendar() - calendar object. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
29 |
Public methods: |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
30 |
* Array<vEvent> getEvents() : get a array of the calendar events. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
31 |
* Int getNrOfEvents() : get the number of events. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
32 |
* Array<String> getPropertyNames() : get an array of the calendar's property names. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
33 |
* PropertyMap getProperties() : get the property map object for the calendar. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
34 |
* 0bject getProperty(String key) : get a property value by name. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
35 |
Throws exception if property is not found (invalidPropertyException). |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
36 |
* vEvent getEventAtIndex(int index) : get an event object at given position in calendar. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
37 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
38 |
Class: vEvent() - event object. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
39 |
Public methods: |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
40 |
* Date getStartDate() : get the starting date for the event. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
41 |
* Date getEndDate() : get the ending date for the event. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
42 |
* String getTimezone() : get the timezone accociated with the event. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
43 |
* PropertyMap getRuleProperties() : get a map of rules for the event. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
44 |
* Array<String> getPropertyNames() : get an array of available property names. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
45 |
* Object getProperty(String key) : get an event property by name. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
46 |
Throws exception if property is not found (invalidPropertyException). |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
47 |
* String getHtmlValue(String key) : get an string property in HTML format (\n become <br/>). |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
48 |
Throws exception if property is not found (invalidPropertyException). |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
49 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
50 |
Class: PropertyMap() - property hashmap object for vCal and vEvent. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
51 |
Public methods: |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
52 |
* Object getProperty(String) : get property value of property with key. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
53 |
* void toString() : print an overview of the map's properties and values. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
54 |
* boolean containsValue(Object value) : check if the property map contains a given value. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
55 |
* boolean containsKey(String key) : check if the property map contains a given property name. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
56 |
* int size() : the length of the property map. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
57 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
58 |
There are also several "private" methods which are used internally by the reader/parser (but available). |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
59 |
Please refer to the code for overview/documentation on these. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
60 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
61 |
License: |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
62 |
You may use this script, as long as this header is kept intact. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
63 |
Released under the GNU General Public License Version 2 or later (the "GPL"). |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
64 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
65 |
Usage example: |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
66 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
67 |
This example parses a iCalendar file and displays every property within it. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
68 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
69 |
[Begin example code] |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
70 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
71 |
// Parse data |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
72 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
73 |
var myTestData = [some string content of iCalendar file or stream]; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
74 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
75 |
var myCalReader = new iCalReader(); // Construction of the reader object. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
76 |
myCalReader.prepareData(myTestData); // Prepare and set the data for the parser. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
77 |
myCalReader.parse(); // Parse the data. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
78 |
myCalReader.sort(); // Sort the data. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
79 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
80 |
// Read data |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
81 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
82 |
// Get the calendar properties. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
83 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
84 |
var calendarInfo = 'Properties for calendar:\n\n'; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
85 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
86 |
var calendarPropertyNames = myCalReader.getCalendar().getPropertyNames(); // Get the list of availale properties. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
87 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
88 |
for(var i=0; i<calendarPropertyNames.length; i++) { // Loop through all the properties. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
89 |
var propertyName = calendarPropertyNames[i]; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
90 |
var propertyValue = myCalReader.getCalendar().getProperty(propertyName); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
91 |
calendarInfo += 'Calendar property "'+propertyName+'" has value: "'+propertyValue+'"\n'; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
92 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
93 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
94 |
alert(calendarInfo); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
95 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
96 |
// Get the event properties. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
97 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
98 |
alert('About to show all events and their properties...'); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
99 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
100 |
var events = myCalReader.getCalendar().getEvents(); // Get all events. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
101 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
102 |
for(var i=0; i<myCalReader.getCalendar().getNrOfEvents(); i++) { // Loop through all events. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
103 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
104 |
var event = myCalReader.getCalendar().getEventAtIndex(i); // A single event. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
105 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
106 |
// Get Javascript date for start and end time. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
107 |
var startDate = event.getStartDate(); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
108 |
var endDate = event.getEndDate(); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
109 |
var timeZone = event.getTimeZone(); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
110 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
111 |
// Get rules. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
112 |
var rules = event.getRuleProperties(); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
113 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
114 |
var eventInfo = 'Showing properties for event number '+(i+1)+'.\n\n'+ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
115 |
'This event starts '+startDate+' and ends '+endDate+'\n\n'+'Timezone is: "'+timeZone+'"\n\n'+ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
116 |
'This event have the following rules: '+rules.toString()+'\n\n'; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
117 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
118 |
var eventPropertyNames = event.getPropertyNames(); // Get the list of available properties. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
119 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
120 |
for(var n=0; n<eventPropertyNames.length; n++) { // Loop through all the properties. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
121 |
var propertyName = eventPropertyNames[n]; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
122 |
var propertyValue = event.getProperty(propertyName); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
123 |
eventInfo += 'Property "'+propertyName+'" has value: "'+propertyValue+'"\n'; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
124 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
125 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
126 |
alert(eventInfo); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
127 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
128 |
} // End for each event. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
129 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
130 |
[End example code] |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
131 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
132 |
HEADER END /* |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
133 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
134 |
/*************** CLASS DEFINITIONS ***************************************************************************/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
135 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
136 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
137 |
* The main object for reading and parsing iCalendar data. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
138 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
139 |
function iCalReader() { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
140 |
this.data = null; // Holds the iCalendar input data. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
141 |
this.calendar = new vCalendar(); // The VCALENDAR object. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
142 |
this.eventCount = -1; // Tracks the number of events in the calendar. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
143 |
this.lastKey = null; // Reference to last proccessed key (property). |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
144 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
145 |
// Class methods |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
146 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
147 |
iCalReader.prototype = { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
148 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
149 |
* Prepares and sets the data for the parser. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
150 |
* @input calendar file data (string). |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
151 |
* @throws invalidCalendarException |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
152 |
* @return prepared data (array of lines) |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
153 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
154 |
prepareData: function(data) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
155 |
// Fix for malformed Mozilla VCALENDAR syntax. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
156 |
this.data = data.replace(/[\r\n]{1,} ([:;])/g, '$1'); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
157 |
// Make array of all the lines. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
158 |
this.data = this.data.split(/\r?\n/); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
159 |
// Is it really a VCALENDAR? |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
160 |
if(this.data[0].indexOf('BEGIN:VCALENDAR') == -1) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
161 |
throw('invalidCalendarException'); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
162 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
163 |
return this.data; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
164 |
}, |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
165 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
166 |
* Method that does the actual parsing. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
167 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
168 |
parse: function() { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
169 |
this.calendar = new vCalendar(); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
170 |
// Loop through all lines and analyze them. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
171 |
for(var i=0; i<this.data.length; i++) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
172 |
var line = this.data[i]; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
173 |
// Get possible key/value for line. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
174 |
var values = this.returnKeyValue(line); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
175 |
key = values[0]; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
176 |
value = values[1]; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
177 |
switch(line) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
178 |
// It's a new event. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
179 |
case 'BEGIN:VEVENT': |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
180 |
this.eventCount++; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
181 |
type = 'VEVENT'; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
182 |
break; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
183 |
// It's a calendar property. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
184 |
case 'BEGIN:VCALENDAR': |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
185 |
case 'BEGIN:DAYLIGHT': |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
186 |
case 'BEGIN:VTIMEZONE': |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
187 |
case 'BEGIN:STANDARD': |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
188 |
type = value; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
189 |
break; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
190 |
// It's the end of the calendar property or event. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
191 |
case 'END:VEVENT': |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
192 |
case 'END:VCALENDAR': |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
193 |
case 'END:DAYLIGHT': |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
194 |
case 'END:VTIMEZONE': |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
195 |
case 'END:STANDARD': |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
196 |
type = 'VCALENDAR'; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
197 |
break; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
198 |
// Add data to the calendar or event. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
199 |
default: |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
200 |
this.addToCalendar(type, key, value); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
201 |
break; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
202 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
203 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
204 |
}, |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
205 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
206 |
* Adds data to the calendar object from the parser. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
207 |
* @input type of current item in parsing queue. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
208 |
* @input key (name) of item property. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
209 |
* @input value of item property. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
210 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
211 |
addToCalendar: function(type, key, value) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
212 |
// Make a new event if we are not proccessing a current one and type is VEVENT. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
213 |
if(type == 'VEVENT') { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
214 |
try { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
215 |
var event = this.calendar.getEventAtIndex(this.eventCount); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
216 |
} catch(e) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
217 |
var event = new vEvent(); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
218 |
this.calendar.addEvent(event); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
219 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
220 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
221 |
// If no key, add the current value to currently proccessing property's value. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
222 |
if (key == false) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
223 |
key = this.lastKey; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
224 |
var oldValue; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
225 |
switch(type) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
226 |
case 'VEVENT': |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
227 |
oldValue = this.calendar.getEventAtIndex(this.eventCount).getProperty(key); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
228 |
value = oldValue+this.trimStart(value); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
229 |
break; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
230 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
231 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
232 |
// Convert calendar date properties to javascript date. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
233 |
if ((key == 'DTSTAMP') || (key == 'LAST-MODIFIED') || (key == 'CREATED')) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
234 |
value = this.toDate(value); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
235 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
236 |
// Convert event date properties to own detailed mapping. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
237 |
if (key.indexOf('DTSTART') > -1 || key.indexOf('DTEND') > -1|| key.indexOf('ALTDTSTART') > -1) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
238 |
var dateArray = this.toDateProperties(key,value); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
239 |
key = dateArray[0]; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
240 |
value = dateArray[1]; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
241 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
242 |
// Parse any rules for item. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
243 |
if (key == 'RRULE' ) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
244 |
value = this.makeRuleProperties(value); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
245 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
246 |
// Add the data. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
247 |
switch(type) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
248 |
// It's an event. Add property and value to event. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
249 |
case 'VEVENT': |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
250 |
this.calendar.getEventAtIndex(this.eventCount).setProperty(key,value); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
251 |
break; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
252 |
// It's a calendar's property. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
253 |
default: |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
254 |
this.calendar.setProperty(key,value); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
255 |
break; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
256 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
257 |
// Reference last proccessed key. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
258 |
this.lastKey = key; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
259 |
}, |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
260 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
261 |
* Make rule property map. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
262 |
* @input string RRULE-string. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
263 |
* @return PropertyMap of rules. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
264 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
265 |
makeRuleProperties: function(value) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
266 |
var ruledata = value.split(';'); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
267 |
var rule = new PropertyMap(); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
268 |
for(var r in ruledata) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
269 |
var data = ruledata[r].split('='); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
270 |
rule.put(data[0], data[1]); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
271 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
272 |
return rule; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
273 |
}, |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
274 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
275 |
* Parse a VEVENT type date to a own property map object. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
276 |
* @input string property name (like "DTSTART;TZID=Europe/Oslo") |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
277 |
* @input string property value (like "20070719T220000"). |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
278 |
* @return array(string DTSTART or DTEND, PropertyMap{ property JSDATE = [Date], property TZID = [string] } ) |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
279 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
280 |
toDateProperties: function(key,value) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
281 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
282 |
var dtProperty = new PropertyMap(); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
283 |
dtProperty.put('TZID', 'Undefined'); // Default in case we don't find any timezone data. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
284 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
285 |
// Convert time to JS-date and make property. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
286 |
dtProperty.put('JSDATE', this.toDate(value)); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
287 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
288 |
// Get date info from key value. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
289 |
var dtInfo = key.split(';'); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
290 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
291 |
key = dtInfo[0]; // Shorten the key to read DTSTART or DTEND not "DTSTART;TZID=Europe/Oslo". |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
292 |
dtProperty.put(key, value); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
293 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
294 |
if(typeof(dtInfo[1]) != 'undefined') { // Timezone is specified. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
295 |
// Get timezone. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
296 |
var tzInfo = dtInfo[1].split('='); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
297 |
var timezoneValue = tzInfo[1]; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
298 |
dtProperty.put('TZID', timezoneValue); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
299 |
return new Array(key,dtProperty); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
300 |
} else { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
301 |
// Try get the calendar default TZ. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
302 |
try { dtProperty.put('TZID', this.calendar.getProperty('TZID')); } catch(e) {} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
303 |
try { dtProperty.put('TZID', this.calendar.getProperty('X-WR-TIMEZONE')); } catch(e) {} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
304 |
return new Array(key,dtProperty); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
305 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
306 |
}, |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
307 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
308 |
* Convert a iCal type timestamp to Javascript date. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
309 |
* @input calendar type date string. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
310 |
* @return javascript date object. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
311 |
* @throws invalidDateException. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
312 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
313 |
toDate: function(dateString) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
314 |
dateString = dateString.replace('T', ''); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
315 |
dateString = dateString.replace('Z', ''); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
316 |
var pattern = /([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})([0-9]{0,2})/; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
317 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
318 |
try { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
319 |
var dArr = pattern.exec(dateString); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
320 |
var calDate = new Date(); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
321 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
322 |
var months = (dArr[2][0] == '0') ? dArr[2][1] : dArr[2]; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
323 |
months = parseInt(months)-1; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
324 |
var days = (dArr[3][0] == '0') ? dArr[3][1] : dArr[3]; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
325 |
days = parseInt(days); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
326 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
327 |
var hours = (dArr[4][0] == '0') ? dArr[4][1] : dArr[4]; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
328 |
hours = hours == '' ? '0' : hours; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
329 |
hours = parseInt(hours); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
330 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
331 |
var minutes = (dArr[5][0] == '0') ? dArr[5][1] : dArr[5]; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
332 |
minutes = minutes == '' ? '0' : minutes; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
333 |
minutes = parseInt(minutes); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
334 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
335 |
var seconds = (dArr[6][0] == '0') ? dArr[6][1] : dArr[6]; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
336 |
seconds = seconds == '' ? '0' : seconds; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
337 |
seconds = parseInt(seconds); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
338 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
339 |
calDate.setFullYear(dArr[1]); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
340 |
calDate.setMonth(months); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
341 |
calDate.setDate(days); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
342 |
calDate.setHours(hours); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
343 |
calDate.setMinutes(minutes); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
344 |
calDate.setSeconds(seconds); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
345 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
346 |
} catch(e) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
347 |
throw('invalidDateException'); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
348 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
349 |
return calDate; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
350 |
}, |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
351 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
352 |
* Returns a possible value/key-set of a calendar data line. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
353 |
* @input calendar data line (string). |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
354 |
* @return array of key,value. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
355 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
356 |
returnKeyValue: function(line) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
357 |
// Regex for VCALENDAR syntax. Match letters in uppercase in the beginning |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
358 |
// of the line followed by VCALENDAR-type operator and value. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
359 |
var pattern = /^([A-Z]+[^:]+)[:]([\w\W]*)/; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
360 |
var matches = pattern.exec(line); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
361 |
if(matches) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
362 |
return matches.splice(1,2); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
363 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
364 |
// No key found, just return value. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
365 |
return new Array(false,line); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
366 |
}, |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
367 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
368 |
* Trims the beginning of string one whitespace character. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
369 |
* @input string to trim. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
370 |
* @return trimmed string. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
371 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
372 |
trimStart: function(str) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
373 |
str=str.replace(/^\s{0,1}(.*)/, '$1'); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
374 |
return str; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
375 |
}, |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
376 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
377 |
* Get the calendar object for the reader. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
378 |
* @return vCalendar object. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
379 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
380 |
getCalendar: function() { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
381 |
return this.calendar; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
382 |
}, |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
383 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
384 |
* Sorts the calendar events by time desc. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
385 |
* |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
386 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
387 |
sort: function(){ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
388 |
this.calendar.sort(); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
389 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
390 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
391 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
392 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
393 |
* Object to hold the calendar propterties. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
394 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
395 |
function vCalendar() { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
396 |
this.vEvents = new Array(); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
397 |
this.properties = new PropertyMap(); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
398 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
399 |
// Class methods |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
400 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
401 |
vCalendar.prototype = { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
402 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
403 |
* Gets the event array. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
404 |
* @return array of event objects. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
405 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
406 |
getEvents: function() { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
407 |
return this.vEvents; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
408 |
}, |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
409 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
410 |
* Gets the properties hashmap. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
411 |
* @return PropertyMap. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
412 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
413 |
getProperties: function() { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
414 |
return this.properties; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
415 |
}, |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
416 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
417 |
* Get the number of events. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
418 |
* @return number |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
419 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
420 |
getNrOfEvents: function() { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
421 |
return this.vEvents.length; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
422 |
}, |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
423 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
424 |
* Sorts the array of events by time desc. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
425 |
* |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
426 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
427 |
sort: function(){ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
428 |
this.vEvents = this.vEvents.sort(this.sortByDate); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
429 |
}, |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
430 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
431 |
* Get list of available properties for the calendar. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
432 |
* @return array of strings. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
433 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
434 |
getPropertyNames: function() { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
435 |
return this.properties.keys(); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
436 |
}, |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
437 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
438 |
* Get an event at a given index. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
439 |
* @input int index. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
440 |
* @return vEvent event. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
441 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
442 |
getEventAtIndex: function(index) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
443 |
var evt = this.vEvents[index]; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
444 |
if(typeof(evt) == 'undefined') { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
445 |
throw('eventNotFoundException'); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
446 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
447 |
return this.vEvents[index]; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
448 |
}, |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
449 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
450 |
* Get value of a given property. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
451 |
* @input string property name. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
452 |
* @return object value. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
453 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
454 |
getProperty: function(property) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
455 |
try { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
456 |
return this.properties.get(property); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
457 |
} catch(e) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
458 |
throw(e); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
459 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
460 |
}, |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
461 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
462 |
* Adds a vEvent object to the event array. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
463 |
* @input vEvent event. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
464 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
465 |
addEvent: function(vEvent) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
466 |
this.vEvents.push(vEvent); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
467 |
}, |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
468 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
469 |
* Set a property to the calendar. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
470 |
* @input string property name. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
471 |
* @input object value. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
472 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
473 |
setProperty: function(property, value) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
474 |
if(typeof(property) == 'string' && property != null && property != '') { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
475 |
this.properties.put(property,value); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
476 |
} else { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
477 |
throw('invalidKeyNameException'); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
478 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
479 |
}, |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
480 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
481 |
* Sorting method for the events. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
482 |
* |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
483 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
484 |
sortByDate: function(a, b) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
485 |
var x = a.getStartDate(); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
486 |
var y = b.getStartDate(); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
487 |
return ((x < y) ? -1 : ((x > y) ? 1 : 0)); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
488 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
489 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
490 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
491 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
492 |
* Object to hold the VEVENT propterties. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
493 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
494 |
function vEvent() { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
495 |
this.properties = new PropertyMap(); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
496 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
497 |
// Class methods |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
498 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
499 |
vEvent.prototype = { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
500 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
501 |
* Get start time for event. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
502 |
* @return Date start. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
503 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
504 |
getStartDate: function() { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
505 |
var dt = this.getProperty('DTSTART'); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
506 |
return dt.get('JSDATE'); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
507 |
}, |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
508 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
509 |
* Get start time for event. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
510 |
* @return Date start. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
511 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
512 |
getAltStartDate: function() { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
513 |
var dt = this.getProperty('ALTDTSTART'); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
514 |
return dt.get('JSDATE'); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
515 |
}, |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
516 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
517 |
* Get end time for event. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
518 |
* @return Date end. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
519 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
520 |
getEndDate: function() { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
521 |
var dt = this.getProperty('DTEND'); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
522 |
return dt.get('JSDATE'); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
523 |
}, |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
524 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
525 |
* Get timezone for event. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
526 |
* @return string timezone. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
527 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
528 |
getTimeZone: function() { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
529 |
var dt = this.getProperty('DTSTART'); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
530 |
return dt.get('TZID'); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
531 |
}, |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
532 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
533 |
* Get rules for event. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
534 |
* @return PropertyMap of rules. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
535 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
536 |
getRuleProperties: function() { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
537 |
var r; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
538 |
try { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
539 |
var r = this.getProperty('RRULE'); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
540 |
} catch(e) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
541 |
r = new PropertyMap(); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
542 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
543 |
return r; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
544 |
}, |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
545 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
546 |
* Get a property by name. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
547 |
* @input string property |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
548 |
* @return property value. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
549 |
* @throws invalidPropertyException. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
550 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
551 |
getProperty: function(property) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
552 |
try { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
553 |
return this.removeSlashes(this.properties.get(property)); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
554 |
} catch(e) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
555 |
throw(e); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
556 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
557 |
}, |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
558 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
559 |
* Sets a property with given name and value. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
560 |
* @input string property name. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
561 |
* @input object value. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
562 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
563 |
setProperty: function(property, value) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
564 |
if(typeof(property) == 'string' && property != null && property != '') { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
565 |
this.properties.put(property, value); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
566 |
} else { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
567 |
throw('invalidKeyNameException'); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
568 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
569 |
}, |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
570 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
571 |
* Get property with given key in HTML-format. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
572 |
* @input string property name. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
573 |
* @return HTML-string. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
574 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
575 |
getHtmlValue: function(property) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
576 |
prop = this.removeSlashes(this.properties.get(property)); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
577 |
if(typeof(prop) == 'string') { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
578 |
prop = prop.replace('\n','<br/>', 'g'); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
579 |
return prop; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
580 |
} else { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
581 |
return prop; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
582 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
583 |
}, |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
584 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
585 |
* Get a list of property- names for this event. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
586 |
* @return array of strings. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
587 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
588 |
getPropertyNames: function() { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
589 |
return this.properties.keys(); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
590 |
}, |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
591 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
592 |
* Removes slashes from a string |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
593 |
* @input string. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
594 |
* @return fixed string. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
595 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
596 |
removeSlashes: function(str) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
597 |
if(typeof(str) == 'string') { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
598 |
str = str.replace('\\n','\n', 'g'); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
599 |
str = str.replace('\\,','\,', 'g'); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
600 |
str = str.replace('\\;','\;', 'g'); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
601 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
602 |
return str; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
603 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
604 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
605 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
606 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
607 |
* Hashmap class to hold properties |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
608 |
* for calendar and events. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
609 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
610 |
function PropertyMap() { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
611 |
this.size = 0; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
612 |
this.properties = new Object(); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
613 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
614 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
615 |
// Class methods |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
616 |
|
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
617 |
PropertyMap.prototype = { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
618 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
619 |
* Add or update property. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
620 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
621 |
put: function(key, value) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
622 |
if(!this.containsKey(key)) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
623 |
this.size++ ; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
624 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
625 |
this.properties[key] = value; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
626 |
}, |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
627 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
628 |
* Get property with given key. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
629 |
* @input property name. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
630 |
* @return object. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
631 |
* @throws invalidPropertyException. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
632 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
633 |
get: function(key) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
634 |
if(this.containsKey(key)) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
635 |
return this.properties[key]; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
636 |
} else { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
637 |
throw('invalidPropertyException'); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
638 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
639 |
}, |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
640 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
641 |
* Alias for get method to keep consistancy in syntax in regard to the other classes. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
642 |
* @input property name. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
643 |
* @return object. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
644 |
* @throws invalidPropertyException. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
645 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
646 |
getProperty: function(key) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
647 |
try { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
648 |
return this.get(key); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
649 |
} catch(e) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
650 |
throw(e); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
651 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
652 |
}, |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
653 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
654 |
* Remove property with key. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
655 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
656 |
remove: function(key) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
657 |
if( this.containsKey(key) && (delete this.properties[key])) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
658 |
size--; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
659 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
660 |
}, |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
661 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
662 |
* Check if a property exists. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
663 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
664 |
containsKey: function(key) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
665 |
return (key in this.properties); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
666 |
}, |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
667 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
668 |
* Check if a value exists. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
669 |
* @return boolean. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
670 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
671 |
containsValue: function(value) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
672 |
for(var prop in this.properties) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
673 |
if(this.properties[prop] == value) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
674 |
return true; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
675 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
676 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
677 |
return false; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
678 |
}, |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
679 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
680 |
* Get all the values. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
681 |
* @return array of values. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
682 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
683 |
values: function () { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
684 |
var values = new Array(); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
685 |
for(var prop in this.properties) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
686 |
values.push(this.properties[prop]); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
687 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
688 |
return values; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
689 |
}, |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
690 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
691 |
* Get all the keys. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
692 |
* @return array of keys. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
693 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
694 |
keys: function () { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
695 |
var keys = new Array(); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
696 |
for(var prop in this.properties) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
697 |
keys.push(prop); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
698 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
699 |
return keys; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
700 |
}, |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
701 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
702 |
* Get the size of map. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
703 |
* @return int size. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
704 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
705 |
size: function () { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
706 |
return this.size; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
707 |
}, |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
708 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
709 |
* Clears all properties. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
710 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
711 |
clear: function () { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
712 |
this.size = 0; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
713 |
this.properties = new Object(); |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
714 |
}, |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
715 |
/** |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
716 |
* Gives a string representation of this propertymap. |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
717 |
*/ |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
718 |
toString: function() { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
719 |
var str = ''; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
720 |
for(var prop in this.properties) { |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
721 |
str += prop+'='+this.get(prop)+', '; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
722 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
723 |
return '{ '+str.substring(0,(str.length-2))+' }'; |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
724 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
725 |
} |
97dcd250e5be
checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
726 |
/*************** END iCalReader.js ******************************************************************************/ |