]>
code.delx.au - comingnext/blob - debug.js
2 getServiceObject: function(cal
, datasource
)
7 GetList: function(criteria
)
9 if (criteria
.Type
== "CalendarEntry") {
11 for(var i
= 0; i
< device
.data
.default.length
; i
++) {
12 var entry
= device
.data
.default[i
];
13 var searchText
= criteria
.Filter
.SearchText
;
14 var localId
= criteria
.Filter
.LocalId
;
15 var type
= criteria
.Filter
.Type
;
17 var startRange
= criteria
.Filter
.StartRange
;
18 var endRange
= criteria
.Filter
.EndRange
;
19 var calendarName
= criteria
.Filter
.CalendarName
;
20 if (searchText
!= undefined && entry
.Summary
!= undefined && entry
.Summary
.indexOf(searchText
) == -1) {
23 if (localId
!= undefined && entry
.LocalId
!= undefined && entry
.LocalId
!= localId
) {
26 if (type
!= undefined && entry
.Type
!= undefined && type
!= entry
.Type
) {
29 if (startRange
!= undefined && entry
.StartTime
!= undefined && this.StringToDate(entry
.StartTime
) < startRange
) {
32 if (endRange
!= undefined && entry
.EndTime
!= undefined && this.StringToDate(entry
.EndTime
) > endRange
) {
35 if (calendarName
!= undefined && entry
.CalendarName
!= undefined && entry
.CalendarName
!= calendarName
) {
48 getNext
: function _getNext()
50 if (this.dataPtr
< this.data
.length
)
51 return this.data
[this.dataPtr
++];
58 else if (criteria
.Type
== "Calendar") {
64 data
: [ "default", "calendar2" ],
66 getNext
: function _getNext()
68 if (this.dataPtr
< this.data
.length
)
69 return this.data
[this.dataPtr
++];
78 Add: function (criteria
)
80 if (criteria
.Type
== "CalendarEntry") {
81 var cal
= device
.data
.default;
83 if (criteria
.Item
.id
== undefined && criteria
.Item
.LocalId
!= undefined)
84 criteria
.Item
.id
= criteria
.Item
.LocalId
;
85 var overwriteExisting
= false;
86 var existingIndex
= -1;
87 if (criteria
.Item
.id
!= undefined || criteria
.Item
.LocalId
!= undefined) {
88 itemId
= criteria
.Item
.id
;
89 for(var i
= 0; i
< cal
.length
; i
++) {
90 if (cal
[i
].id
!= undefined && cal
[i
].id
== itemId
) {
91 overwriteExisting
= true;
98 for(var i
= 0; i
< cal
.length
; i
++) {
99 if (cal
[i
].id
!= undefined && cal
[i
].id
== itemId
) {
105 criteria
.Item
.id
= itemId
;
106 criteria
.Item
.LocalId
= itemId
;
107 if (criteria
.Item
.StartTime
!= undefined && criteria
.Item
.StartTime
instanceof Date
)
108 criteria
.Item
.StartTime
= this.DateToString(criteria
.Item
.StartTime
);
109 if (criteria
.Item
.EndTime
!= undefined && criteria
.Item
.EndTime
instanceof Date
)
110 criteria
.Item
.EndTime
= this.DateToString(criteria
.Item
.EndTime
);
111 if (overwriteExisting
)
112 cal
[existingIndex
] = criteria
.Item
;
114 cal
.push(criteria
.Item
);
123 ErrorMessage
: "invalid citeria.Type"
127 Delete: function (criteria
)
129 var cal
= device
.data
.default;
130 for(var i
= cal
.length
- 1; i
>= 0; i
--) {
131 if (criteria
.Data
!= undefined && criteria
.Data
.IdList
!= undefined) {
132 for(var j
= 0; j
< criteria
.Data
.IdList
.length
; j
++) {
133 if (criteria
.Data
.IdList
[j
] == cal
[i
].id
) {
145 RequestNotification: function(criteria
, callback
)
152 Cancel: function(request
)
159 DateToString: function(date
) {
160 // Wednesday, 26 April, 2012 23:…
161 var weekdays
= [ "Sunday", "Monday", "Thuesday", "Wednesday", "Thursday", "Friday", "Saturday" ];
162 var months
= [ "January", "Februrary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ];
163 var hours
= date
.getHours(); if (hours
< 10) hours
= "0" + hours
;
164 var minutes
= date
.getMinutes(); if (minutes
< 10) minutes
= "0" + minutes
;
165 var seconds
= date
.getSeconds(); if (seconds
< 10) seconds
= "0" + seconds
;
166 return weekdays
[date
.getDay()] + ", " + date
.getDate() + " " + months
[date
.getMonth()] + " " + date
.getFullYear() + ", " + hours
+ ":" + minutes
+ ":" + seconds
;
168 StringToDate: function(string
) {
169 var parts
= string
.replace(/,/g,'').replace(/ /g
,' ').split(' ');
171 months
["January"] = 0;
172 months
["February"] = 1;
178 months
["August"] = 7;
179 months
["September"] = 8;
180 months
["October"] = 9;
181 months
["November"] = 10;
182 months
["December"] = 11;
184 weekdays
["Sunday"] = 0;
185 weekdays
["Monday"] = 1;
186 weekdays
["Thuesday"] = 2;
187 weekdays
["Wednesday"] = 3;
188 weekdays
["Thursday"] = 4;
189 weekdays
["Friday"] = 5;
190 weekdays
["Saturday"] = 6;
191 var weekday
= weekdays
[parts
[0]];
192 var day
= Number(parts
[1]);
193 var month
= months
[parts
[2]];
194 var year
= Number(parts
[3]);
195 var timeParts
= parts
[4].split(':');
196 var hours
= Number(timeParts
[0]);
197 var minutes
= Number(timeParts
[1]);
198 var seconds
= Number(timeParts
[2]);
199 return new Date(year
, month
, day
, hours
, minutes
, seconds
);
210 device
.data
.default = [
215 CalendarName
: "default",
217 Location
: "location",
219 StartTime
: device
.getServiceObject().IDataSource
.DateToString(new Date((new Date()).getTime() + 1000 * 60 * 1 * 1)),
220 EndTime
: device
.getServiceObject().IDataSource
.DateToString(new Date((new Date()).getTime() + 1000 * 60 * 60 * 2)),
221 InstanceStartTime
: undefined,
222 InstanceEndTime
: undefined
228 CalendarName
: "default",
230 Location
: "location2",
232 StartTime
: device
.getServiceObject().IDataSource
.DateToString(new Date((new Date()).getTime() + 1000 * 60 * 60 * 24)),
233 EndTime
: device
.getServiceObject().IDataSource
.DateToString(new Date((new Date()).getTime() + 1000 * 60 * 60 * 24)),
234 InstanceStartTime
: undefined,
235 InstanceEndTime
: undefined
241 CalendarName
: "default",
243 Location
: "location3",
245 StartTime
: device
.getServiceObject().IDataSource
.DateToString(new Date((new Date()).getTime() + 1000 * 60 * 60 * 24 * 2)),
246 EndTime
: device
.getServiceObject().IDataSource
.DateToString(new Date((new Date()).getTime() + 1000 * 60 * 60 * 24 * 2)),
247 InstanceStartTime
: undefined,
248 InstanceEndTime
: undefined
254 CalendarName
: "calendar2",
256 Location
: "location4",
258 StartTime
: device
.getServiceObject().IDataSource
.DateToString(new Date((new Date()).getTime() + 1000 * 60 * 60 * 24 * 3)),
259 EndTime
: device
.getServiceObject().IDataSource
.DateToString(new Date((new Date()).getTime() + 1000 * 60 * 60 * 24 * 3)),
260 InstanceStartTime
: undefined,
261 InstanceEndTime
: undefined
267 leftCallback
: undefined,
269 rightCallback
: undefined,
271 setLeftSoftkeyLabel: function(text
, callback
) {
272 if (text
== "" && callback
== null) {
274 callback
= this.defaultLeftCallback
;
276 this.leftText
= text
;
277 this.leftCallback
= callback
;
280 setRightSoftkeyLabel: function(text
, callback
) {
281 if (text
== "" && callback
== null) {
283 callback
= this.defaultRightCallback
;
285 this.rightText
= text
;
286 this.rightCallback
= callback
;
289 defaultLeftCallback: function() {
291 defaultRightCallback: function() {
295 this.menuContent
= [];
298 append: function(arg1
) {
299 this.menuContent
[this.menuContent
.length
] = arg1
;
303 var div
= document
.getElementById("debug");
304 if (div
== undefined) {
305 var body
= document
.getElementsByTagName('body')[0];
306 body
.innerHTML
+= '<div id="debug">Debug DIV</div>';
307 div
= document
.getElementById('debug');
309 var left
= this.leftCallback
== this.defaultLeftCallback
? this.menuContent
.join('<br />') : "";
310 div
.innerHTML
= '<div style="background-color:#a00000"><span onclick="window.menu.leftCallback()">' + this.leftText
+ "</span><br />" + left
+ '</div> <div style="background-color:#00a000" onclick="window.menu.rightCallback()">' + this.rightText
+ '</div>';
313 function MenuItem(text
, id
) {
317 MenuItem
.prototype.onSelect
= undefined;
318 MenuItem
.prototype.text
= undefined;
319 MenuItem
.prototype.id
= undefined;
320 MenuItem
.prototype.toString = function() {
321 return '<span style="padding-left:10px;" onclick="' + this.onSelect
.name
+ '()">' + this.text
+ '</span>';
326 openApplication: function(appString
, args
) {
327 //alert("app '" + appString + "' with args '" + args + "' called");
329 prepareForTransition: function() {
331 performTransition: function() {
333 openURL: function(url
) {