]>
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 if (searchText
!= undefined && entry
.Summary
!= undefined && entry
.Summary
.indexOf(searchText
) == -1) {
22 if (localId
!= undefined && entry
.LocalId
!= undefined && entry
.LocalId
!= localId
) {
25 if (type
!= undefined && entry
.Type
!= undefined && type
!= entry
.Type
) {
28 if (startRange
!= undefined && entry
.StartTime
!= undefined && this.StringToDate(entry
.StartTime
) < startRange
) {
31 if (endRange
!= undefined && entry
.EndTime
!= undefined && this.StringToDate(entry
.EndTime
) > endRange
) {
44 getNext
: function _getNext()
46 if (this.dataPtr
< this.data
.length
)
47 return this.data
[this.dataPtr
++];
54 else if (criteria
.Type
== "Calendar") {
62 getNext
: function _getNext()
64 if (this.dataPtr
< this.data
.length
)
65 return this.data
[this.dataPtr
++];
74 Add: function (criteria
)
76 if (criteria
.Type
== "CalendarEntry") {
77 var cal
= device
.data
.default;
79 if (criteria
.Item
.id
== undefined && criteria
.Item
.LocalId
!= undefined)
80 criteria
.Item
.id
= criteria
.Item
.LocalId
;
81 var overwriteExisting
= false;
82 var existingIndex
= -1;
83 if (criteria
.Item
.id
!= undefined || criteria
.Item
.LocalId
!= undefined) {
84 itemId
= criteria
.Item
.id
;
85 for(var i
= 0; i
< cal
.length
; i
++) {
86 if (cal
[i
].id
!= undefined && cal
[i
].id
== itemId
) {
87 overwriteExisting
= true;
94 for(var i
= 0; i
< cal
.length
; i
++) {
95 if (cal
[i
].id
!= undefined && cal
[i
].id
== itemId
) {
101 criteria
.Item
.id
= itemId
;
102 criteria
.Item
.LocalId
= itemId
;
103 if (criteria
.Item
.StartTime
!= undefined && criteria
.Item
.StartTime
instanceof Date
)
104 criteria
.Item
.StartTime
= this.DateToString(criteria
.Item
.StartTime
);
105 if (criteria
.Item
.EndTime
!= undefined && criteria
.Item
.EndTime
instanceof Date
)
106 criteria
.Item
.EndTime
= this.DateToString(criteria
.Item
.EndTime
);
107 if (overwriteExisting
)
108 cal
[existingIndex
] = criteria
.Item
;
110 cal
.push(criteria
.Item
);
119 ErrorMessage
: "invalid citeria.Type"
123 Delete: function (criteria
)
125 var cal
= device
.data
.default;
126 for(var i
= cal
.length
- 1; i
>= 0; i
--) {
127 if (criteria
.Data
!= undefined && criteria
.Data
.IdList
!= undefined) {
128 for(var j
= 0; j
< criteria
.Data
.IdList
.length
; j
++) {
129 if (criteria
.Data
.IdList
[j
] == cal
[i
].id
) {
141 RequestNotification: function(criteria
, callback
)
148 Cancel: function(request
)
155 DateToString: function(date
) {
156 // Wednesday, 26 April, 2012 23:…
157 var weekdays
= [ "Sunday", "Monday", "Thuesday", "Wednesday", "Thursday", "Friday", "Saturday" ];
158 var months
= [ "January", "Februrary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ];
159 var hours
= date
.getHours(); if (hours
< 10) hours
= "0" + hours
;
160 var minutes
= date
.getMinutes(); if (minutes
< 10) minutes
= "0" + minutes
;
161 var seconds
= date
.getSeconds(); if (seconds
< 10) seconds
= "0" + seconds
;
162 return weekdays
[date
.getDay()] + ", " + date
.getDate() + " " + months
[date
.getMonth()] + " " + date
.getFullYear() + ", " + hours
+ ":" + minutes
+ ":" + seconds
;
164 StringToDate: function(string
) {
165 var parts
= string
.replace(/,/g,'').replace(/ /g
,' ').split(' ');
167 months
["January"] = 0;
168 months
["February"] = 1;
174 months
["August"] = 7;
175 months
["September"] = 8;
176 months
["October"] = 9;
177 months
["November"] = 10;
178 months
["December"] = 11;
180 weekdays
["Sunday"] = 0;
181 weekdays
["Monday"] = 1;
182 weekdays
["Thuesday"] = 2;
183 weekdays
["Wednesday"] = 3;
184 weekdays
["Thursday"] = 4;
185 weekdays
["Friday"] = 5;
186 weekdays
["Saturday"] = 6;
187 var weekday
= weekdays
[parts
[0]];
188 var day
= Number(parts
[1]);
189 var month
= months
[parts
[2]];
190 var year
= Number(parts
[3]);
191 var timeParts
= parts
[4].split(':');
192 var hours
= Number(timeParts
[0]);
193 var minutes
= Number(timeParts
[1]);
194 var seconds
= Number(timeParts
[2]);
195 return new Date(year
, month
, day
, hours
, minutes
, seconds
);
206 device
.data
.default = [
211 CalendarName
: "default",
213 Location
: "location",
215 StartTime
: device
.getServiceObject().IDataSource
.DateToString(new Date((new Date()).getTime() + 1000 * 60 * 1 * 1)),
216 EndTime
: device
.getServiceObject().IDataSource
.DateToString(new Date((new Date()).getTime() + 1000 * 60 * 60 * 2)),
217 InstanceStartTime
: undefined,
218 InstanceEndTime
: undefined
224 CalendarName
: "default",
226 Location
: "location2",
228 StartTime
: device
.getServiceObject().IDataSource
.DateToString(new Date((new Date()).getTime() + 1000 * 60 * 60 * 24)),
229 EndTime
: device
.getServiceObject().IDataSource
.DateToString(new Date((new Date()).getTime() + 1000 * 60 * 60 * 24)),
230 InstanceStartTime
: undefined,
231 InstanceEndTime
: undefined
237 CalendarName
: "default",
239 Location
: "location3",
241 StartTime
: device
.getServiceObject().IDataSource
.DateToString(new Date((new Date()).getTime() + 1000 * 60 * 60 * 24 * 2)),
242 EndTime
: device
.getServiceObject().IDataSource
.DateToString(new Date((new Date()).getTime() + 1000 * 60 * 60 * 24 * 2)),
243 InstanceStartTime
: undefined,
244 InstanceEndTime
: undefined
250 leftCallback
: undefined,
252 rightCallback
: undefined,
254 setLeftSoftkeyLabel: function(text
, callback
) {
255 if (text
== "" && callback
== null) {
257 callback
= this.defaultLeftCallback
;
259 this.leftText
= text
;
260 this.leftCallback
= callback
;
263 setRightSoftkeyLabel: function(text
, callback
) {
264 if (text
== "" && callback
== null) {
266 callback
= this.defaultRightCallback
;
268 this.rightText
= text
;
269 this.rightCallback
= callback
;
272 defaultLeftCallback: function() {
274 defaultRightCallback: function() {
278 this.menuContent
= [];
281 append: function(arg1
) {
282 this.menuContent
[this.menuContent
.length
] = arg1
;
286 var div
= document
.getElementById("debug");
287 if (div
== undefined) {
288 var body
= document
.getElementsByTagName('body')[0];
289 body
.innerHTML
+= '<div id="debug">Debug DIV</div>';
290 div
= document
.getElementById('debug');
292 var left
= this.leftCallback
== this.defaultLeftCallback
? this.menuContent
.join('<br />') : "";
293 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>';
296 function MenuItem(text
, id
) {
300 MenuItem
.prototype.onSelect
= undefined;
301 MenuItem
.prototype.text
= undefined;
302 MenuItem
.prototype.id
= undefined;
303 MenuItem
.prototype.toString = function() {
304 return '<span style="padding-left:10px;" onclick="' + this.onSelect
.name
+ '()">' + this.text
+ '</span>';
309 openApplication: function(appString
, args
) {
310 //alert("app '" + appString + "' with args '" + args + "' called");
312 prepareForTransition: function() {
314 performTransition: function() {
316 openURL: function(url
) {