]> code.delx.au - comingnext/blob - comingNext/index.html
open calendar when clicking anywhere in fullscreen view
[comingnext] / comingNext / index.html
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5
6 <title>Coming Next</title>
7
8 <style type="text/css">
9 .background { color:#ffffff; background-color:#000000 } /* Defines the background of the widget. If you want to use a background image, set useBackgroundImage = true below */
10 /* for the default themes, black, gray, and light blue, codes are #292029, #e7dfe7, #009aef */
11 .backgroundFullscreen { color:#ffffff; background-color:#000000 } /* Same as background but for the fullscreen version of the widget */
12 .weekDay { } /* Defines the appearance of all week day texts */
13 .date { } /* Defines the appearance of all date texts */
14 .today { color:#ff0000; } /* Defines the appearance of "Today" text */
15 .tomorrow { color:#0000ff; } /* Defines the appearance of "Tomorrow" text */
16 .time { } /* Defines the appearance of all time texts */
17 .now { color:#ff00ff; } /* Defines the appearance of "Now" text */
18 .description { } /* Defines the appearance of all event descriptions */
19 .icon { width:15px; height:15px; } /* Defines size and appearance of icons */
20 </style>
21
22 <script>
23 var monthRange = 2; // number of months to include in the event list
24 var includeTodos = true; // disable to remove ToDos from event list
25 var useBackgroundImage = true; // use background_portrait.png and background_landscape.png to fake transparency. Set to "false" to use a solid background color
26 var showCombinedDateTime = false;// only show the time for events happening today, otherwise just show the date
27 var showLocation = true; // show the location for meeting events
28 var showTodayAsText = true; // if enabled, the current date will be shown as "Today" instead of "31.12"
29 var todayText = 'Today'; // text to display for "Today"
30 var tomorrowText = 'Tomorrow'; // text to display for "Tomorrow"
31 var showNowAsText = true; // if enabled, the appointment time will be shown as "Now" instead of "12:00"
32 var nowText = 'Now'; // text to display for "Now"
33 var dateSeparator = '.'; // separator for dates. e.g. "31.12" or "31/12"
34 var dateFormat = 'auto' // how dates will be displayed. 'auto' will autodetect your phone's date format setting. 'MMDD' will write month first, 'DDMM' will write day first
35 var weekDayLength = 2; // defines how many characters of the weekday will be shown. E.g. 2 will cut "Friday" to "Fr"
36 var updateDataInterval = 5; // how many minutes to wait before updating the displayed data. The higher the number, the less battery is used
37 var calendarApp = 0x10005901; // UID of the calendar app to run when clicking the widget. 0x10005901 = buildin calendar, 0x20004ec1 = Epocware Handy Calendar
38 var eventsPerWidget = 4; // number of events to show per widget. Default is 4
39 var showNothingText = true; // if set to "true", show a text if no events are in the list
40 var nothingText = 'No further events within ' + monthRange + ' months'; // text to show when no events are in the list
41 var enableDaylightSaving = true;// enable this if you are in a timezone that has daylight saving time (+1h)
42
43 var cssStyle_background = "color:#ffffff; background-color:#000000"; // Defines the background of the widget. If you want to use a background image, set useBackgroundImage = true below. For the default themes, black, gray, and light blue, codes are #292029, #e7dfe7, #009aef
44 var cssStyle_backgroundFullscreen = "color:#ffffff; background-color:#000000"; // Same as background but for the fullscreen version of the widget
45 var cssStyle_weekDay = ""; // Defines the appearance of all week day texts
46 var cssStyle_date = ""; // Defines the appearance of all date texts
47 var cssStyle_today = "color:#ff0000"; // Defines the appearance of "Today" text
48 var cssStyle_tomorrow = "color:#0000ff"; // Defines the appearance of "Tomorrow" text
49 var cssStyle_time = ""; // Defines the appearance of all time texts
50 var cssStyle_now = "color:#ff00ff"; // Defines the appearance of "Now" text
51 var cssStyle_description = ""; // Defines the appearance of all event descriptions
52 var cssStyle_icon = "width:15px; height:15px"; // Defines size and appearance of icons
53
54 //-------------------------------------------------------
55 // Nothing of interest from here on...
56 //-------------------------------------------------------
57 var panelNum = 0; // use 1 for second panel
58 var version = "1.23";
59 var calendarService = null;
60 var cacheEntriesHtml = [];
61 var months_translated = [];
62 var orientation = '';
63 var now = new Date();
64 var mode = 0; // 0 = homescreen, 1 = fullscreen, 2 = settings, 3 = about
65
66 // vars for daylight saving time
67 var daylightsavingWinter = 0;
68 var daylightsavingSummer = 0;
69 var summertime = false;
70
71 window.onload = init;
72 window.onresize = updateScreen;
73 window.onshow = updateScreen;
74
75 function isLeapYear( year ) {
76 if (( year % 4 == 0 && year % 100 != 0 ) || year % 400 == 0 )
77 return true;
78 else
79 return false;
80 }
81
82 function calcLeapYear(year, days)
83 {
84 if (isLeapYear(year))
85 return ++days;
86 else
87 return days;
88 }
89
90 function subToSunday(myDate, year, days, prevMonthDays)
91 {
92 for (i = myDate.getDay(); i > 0 ;i--)
93 days--;
94 days -= prevMonthDays;
95 days = isLeapYear(year) ? --days : days;
96 return days;
97 }
98
99 function calcDaylightSaving()
100 {
101 var thisYearS = new Date(now.getFullYear(), 3, 0, 0, 0, 0 );
102 var thisYearW = new Date(now.getFullYear(), 10, 0, 0, 0, 0 );
103 var nextYearS = new Date(now.getFullYear() + 1, 3, 0, 0, 0, 0 );
104 var nextYearW = new Date(now.getFullYear() + 1, 10, 0, 0, 0, 0 );
105 var summer = false;
106 var winter = false;
107
108 thisYearSDays = nextYearSDays = 90;
109 thisYearWDays = nextYearWDays = 304;
110
111 thisYearSDays = calcLeapYear(now.getFullYear(), thisYearSDays);
112 thisYearWDays = calcLeapYear(now.getFullYear(), thisYearWDays);
113 nextYearSDays = calcLeapYear(now.getFullYear() + 1, nextYearSDays);
114 nextYearWDays = calcLeapYear(now.getFullYear() + 1, nextYearWDays);
115
116 thisYearSDays = subToSunday(thisYearS, now.getFullYear(), thisYearSDays, 59);
117 thisYearWDays = subToSunday(thisYearW, now.getFullYear(), thisYearWDays, 273);
118 nextYearSDays = subToSunday(nextYearS, now.getFullYear() + 1, nextYearSDays, 59);
119 nextYearWDays = subToSunday(nextYearW, now.getFullYear() + 1, nextYearWDays, 273);
120
121 daylightsavingSummer = new Date (now.getFullYear(), 03-1, thisYearSDays, 2, 0, 0);
122 daylightsavingWinter = new Date (now.getFullYear(), 10-1, thisYearWDays, 2, 0, 0);
123 if (daylightsavingSummer < now) {
124 daylightsavingSummer = new Date (now.getFullYear()+1, 03-1, nextYearSDays, 2, 0, 0);
125 var summer = true;
126 }
127 if (daylightsavingWinter < now) {
128 daylightsavingWinter = new Date (now.getFullYear()+1, 10-1, nextYearWDays, 2, 0, 0);
129 var winter = true;
130 }
131 if (summer && !winter)
132 summertime = true;
133 else
134 summertime = false;
135 }
136
137 function error(message)
138 {
139 console.info('Error: ' + message);
140 document.getElementById("calendarList").innerHTML = 'Error: ' + message;
141 }
142
143 function isToday(date)
144 {
145 if (date.getDate() == now.getDate() && date.getMonth() == now.getMonth())
146 return true;
147 return false;
148 }
149
150 function isTomorrow(date)
151 {
152 if ((date.getDate() == now.getDate() + 1 && date.getMonth() == now.getMonth()) ||
153 (date.getDate() == 0 && date.getMonth() == now.getMonth() + 1) ||
154 (date.getDate() == 0 && date.getMonth() == now.getMonth() + 1 && date.getYear() == now.getYear() + 1))
155 return true;
156 return false;
157 }
158
159 function collectLocales()
160 {
161 var tmpyear = ((panelNum == 0) ? 2000 : 2001);
162 var month = 0;
163
164 if (months_translated.length > 0)
165 return;
166 for (month = 0; month < 12; month++) {
167 var startDate = new Date(tmpyear, month, 15);
168
169 var item = new Object();
170 item.Type = "DayEvent";
171 item.StartTime = startDate;
172 item.Summary = "__temp" + month;
173
174 var criteria = new Object();
175 criteria.Type = "CalendarEntry";
176 criteria.Item = item;
177
178 try {
179 var result = calendarService.IDataSource.Add(criteria);
180 if (result.ErrorCode)
181 error(result.ErrorMessage);
182 } catch (e) {
183 error("collectLocales: " + e + ', line ' + e.line);
184 }
185 }
186 try {
187 var startTime = new Date(tmpyear,0,1);
188 var endTime = new Date(tmpyear,11,31);
189 var listFiltering = {
190 Type:'CalendarEntry',
191 Filter:{
192 StartRange: startTime,
193 EndRange: endTime,
194 SearchText: '__temp',
195 Type: 'DayEvent'
196 }
197 }
198 var result = calendarService.IDataSource.GetList(listFiltering);
199 if (result.ErrorCode) {
200 error(result.ErrorMessage);
201 return;
202 }
203 var list = result.ReturnValue;
204 } catch(e) {
205 error(e + ', line ' + e.line);
206 return;
207 }
208 var ids = new Array();
209 try {
210 var entry;
211 var counter = 0;
212 var dateArr = [];
213
214 while (list && (entry = list.getNext()) != undefined) {
215 dateArr = entry.StartTime.replace(/,/g,'').replace(/\./g,':').replace(/ /g,' ').split(' ');
216 var day = dateArr[1];
217 var month = dateArr[2];
218 var year = dateArr[3];
219
220 // make sure month is set properly
221 if (isNaN(parseInt(day))) {
222 var tmp = day;
223 day = month;
224 month = tmp;
225 } else if (isNaN(parseInt(year))) {
226 var tmp = year;
227 year = month;
228 month = tmp;
229 }
230
231 console.info(entry.StartTime + ' -> ' + month + ' ' + counter);
232 ids[counter] = entry.id;
233 months_translated[month] = counter + 1;
234 counter++;
235 }
236 } catch(e) {
237 error(e + ', line ' + e.line);
238 return;
239 }
240 console.info(ids);
241 try {
242 var criteria = new Object();
243 criteria.Type = "CalendarEntry";
244 criteria.Data = {
245 IdList: ids
246 }
247
248 var result = calendarService.IDataSource.Delete(criteria);
249 if (result.ErrorCode)
250 error(result.ErrorMessage);
251 } catch(e) {
252 error('deleting temp calendar entries:' + e + ', line ' + e.line);
253 return;
254 }
255 }
256
257 function requestNotification()
258 {
259 var criteria = new Object();
260 criteria.Type = "CalendarEntry";
261
262 try {
263 var result = calendarService.IDataSource.RequestNotification(criteria, callback);
264 if (result.ErrorCode)
265 error('loading Calendar items list');
266 } catch (e) {
267 error("requestNotification: " + e + ', line ' + e.line);
268 }
269 }
270
271 function callback(transId, eventCode, result)
272 {
273 updateData();
274 }
275
276 function parseDate(dateString)
277 {
278 /*
279 Dates my look very differently. Also keep in mind that the names are localized!!! These are the possibilities depending on the users date format setting:
280 Wednesday, 26 August, 2009 24:00:00
281 Wednesday, 26 August, 2009 12:00:00 am
282 Wednesday, August 26, 2009 12:00:00 am
283 Wednesday, 2009 August, 26 12:00:00 am
284 Wednesday, 2009 August, 28 8.00.00 pm
285 Wednesday, 2009 August, 28 08:00:00 PM
286 */
287
288 if (dateString == "" || dateString == null)
289 return null;
290 var dateArr = dateString.replace(/,/g,'').replace(/\./g,':').replace(/ /g,' ').split(' ');
291 if (dateArr.length != 5 && dateArr.length != 6)
292 return null;
293
294 // parse date
295 var weekDay = dateArr[0];
296 var day = dateArr[1];
297 var month = dateArr[2];
298 var year = dateArr[3];
299 // make sure month is set properly
300 if (isNaN(parseInt(day))) {
301 var tmp = day;
302 day = month;
303 month = tmp;
304 } else if (isNaN(parseInt(year))) {
305 var tmp = year;
306 year = month;
307 month = tmp;
308 }
309 // make sure day and year are set properly
310 if (Number(day) > Number(year)) {
311 var tmp = year;
312 year = day;
313 day = tmp;
314 }
315 month = months_translated[month];
316
317 // parse time
318 var timeArr = dateArr[4].split(':');
319 if (timeArr.length != 3)
320 return null;
321 var hours = Number(timeArr[0]);
322 var minutes = Number(timeArr[1]);
323 var seconds = Number(timeArr[2]);
324 if (dateArr.length == 6 && dateArr[5].toLowerCase() == 'pm' && hours < 12)
325 hours += 12;
326 if (dateArr.length == 6 && dateArr[5].toLowerCase() == 'am' && hours == 12)
327 hours = 0;
328
329 console.info('year=' + year + ' month=' + month + ' day=' + day + ' hours=' + hours + ' minutes=' + minutes+ ' seconds=' + seconds);
330
331 // take care of daylight saving time
332 if (enableDaylightSaving) {
333 var date = new Date(year, month - 1, day, hours, minutes, seconds);
334 if (summertime && date > daylightsavingWinter && date < daylightsavingSummer)
335 hours -= 1;
336 else if (!summertime && date > daylightsavingSummer && date < daylightsavingWinter)
337 hours += 1;
338 }
339
340 return new Date(year, month - 1, day, hours, minutes, seconds);
341 }
342
343 // returns a short date as string ("31.12" or "12.31") based on the format string which should look like "Wednesday, 26 August, 2009 12:00:00 am"
344 function formatDate(date, format)
345 {
346 var day = date.getDate().toString();
347 var month = (date.getMonth() + 1).toString();
348 while (day.length < 2) { day = '0' + day; }
349 while (month.length < 2) { month = '0' + month; }
350
351 if (showTodayAsText && isToday(date))
352 return '<span class="today">' + todayText + '</span>';
353 if (showTodayAsText && isTomorrow(date))
354 return '<span class="tomorrow">' + tomorrowText + '</span>';
355
356 var dateArr = format.replace(/,/g,'').replace(/\./g,':').replace(/ /g,' ').split(' ');
357 if (dateArr.length != 5 && dateArr.length != 6) {
358 // we don't know how to format this
359 if (dateFormat == 'auto' || dateFormat == 'DDMM')
360 return day + dateSeparator + month;
361 else
362 return month + dateSeparator + day;
363 }
364
365 var dayFirst = true;
366 if (dateFormat == 'MMDD')
367 dayFirst = false;
368 else if (dateFormat == 'DDMM')
369 dayFirst = true;
370 else {
371 // dateFormat == 'auto', try to detect system setting
372 // parse date
373 var day_ = dateArr[1];
374 var month_ = dateArr[2];
375 var year_ = dateArr[3];
376 // make sure month is set properly
377 if (isNaN(parseInt(day_))) {
378 var tmp = day_;
379 day_ = month_;
380 month_ = tmp;
381 dayFirst = false;
382 } else if (isNaN(parseInt(year_))) {
383 var tmp = year_;
384 year_ = month_;
385 month_ = tmp;
386 dayFirst = true;
387 }
388 // make sure day and year are set properly
389 if (Number(day_) > Number(year_))
390 dayFirst = false;
391 }
392
393 if (dayFirst)
394 return day + dateSeparator + month;
395 else
396 return month + dateSeparator + day;
397 }
398
399 function formatTime(date)
400 {
401 // date is a Date() object
402 date.setSeconds(0); // we don't care about seconds
403 var time = date.toLocaleTimeString().replace(/[\.:]00/, ''); // remove seconds from string
404 if (time.replace(/\./, ':').split(':')[0].length < 2)
405 time = '0' + time;
406 if (showNowAsText && date.getTime() == now.getTime())
407 time = '<span class="now">' + nowText + '</span>';
408 return time;
409 }
410
411 function updateData()
412 {
413 calcDaylightSaving();
414 try {
415 // meetings have time
416 // note: anniveraries have a start time of 12:00am. So since we want to include them, we have to query the whole day and check if events have passed later
417 now = new Date();
418 var meetingListFiltering = {
419 Type:'CalendarEntry',
420 Filter:{
421 StartRange: (new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0)),
422 EndRange: (new Date(now.getFullYear(), now.getMonth() + monthRange, now.getDate(), 0, 0, 0))
423 }
424 }
425 var meetingResult = calendarService.IDataSource.GetList(meetingListFiltering);
426 var meetingList = meetingResult.ReturnValue;
427
428 // todos don't, they start on 00:00 hrs., but should be visible anyway
429 // this will generate a list of passed todos. We have to check if they have been marked as "done" yet
430 if (includeTodos) {
431 var todayTodoListFiltering = {
432 Type:'CalendarEntry',
433 Filter:{
434 Type: 'ToDo',
435 StartRange: (new Date(now.getFullYear() - 1, now.getMonth(), now.getDate(), 0, 0, 0)),
436 EndRange: (new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 1))
437 }
438 }
439 var todayTodoResult = calendarService.IDataSource.GetList(todayTodoListFiltering);
440 var todayTodoList = todayTodoResult.ReturnValue;
441 var entryLists = [todayTodoList, meetingList];
442 } else {
443 var entryLists = [meetingList];
444 }
445 } catch(e) {
446 error('loading Calendar items list:' + e + ', line ' + e.line);
447 return;
448 }
449
450 try {
451 var entry;
452 var counter = 0;
453 var entryDate = '';
454 var dateArr = [];
455 var entriesHtml = '<table>';
456 var eventIds = [];
457 var max;
458 if (mode == 0)
459 max = ((panelNum == 0) ? eventsPerWidget : 2 * eventsPerWidget);
460 else
461 max = 30; // we can display a lot more events in fullscreen mode
462
463 // the first outer loop iteration is for passed ToDos, the second loop is for all upcomming events (may also include ToDos)
464 for (var i=0; counter < max && i < entryLists.length; i++) {
465 while (counter < max && (entry = entryLists[i].getNext()) != undefined) {
466 counter++;
467
468 // output event info for debugging
469 console.info(
470 'event: Id=' + entry.id +
471 ',Type=' + entry.Type +
472 ',Summary=' + entry.Summary +
473 ',Location=' + entry.Location +
474 ',Status=' + entry.Status +
475 ',StartTime=' + entry.StartTime +
476 ',EndTime=' + entry.EndTime +
477 ',InstanceStartTime=' + entry.InstanceStartTime +
478 ',InstanceEndTime=' + entry.InstanceEndTime
479 );
480
481 // we don't want ToDos when includeTodos == false or when they are completed
482 if (entry.Type == 'ToDo' && (entry.Status == "TodoCompleted" || !includeTodos)) {
483 console.info('skipping ' + entry.id );
484 counter--;
485 continue;
486 }
487
488 // make sure that we don't include an event twice (useful for ToDos that might come up twice)
489 if (eventIds[entry.id] == 1) {
490 console.info('skipped (already included) ' + entry.id);
491 counter--;
492 continue;
493 } else
494 eventIds[entry.id] = 1;
495
496 // summary can be undefined!
497 var Summary = ((entry.Summary == null) ? '' : entry.Summary);
498 if (entry.Type == 'Meeting' && entry.Location != '' && showLocation)
499 Summary += ', ' + entry.Location;
500
501 // fix by yves: determine start and end dates/times
502 entryStartTime = ((entry.InstanceStartTime == null) ? entry.StartTime : entry.InstanceStartTime);
503 entryEndTime = ((entry.InstanceEndTime == null) ? entry.EndTime : entry.InstanceEndTime);
504
505 // there can be ToDos that have no date at all!
506 if (entry.Type == 'ToDo' && entry.EndTime == null)
507 entryDate = ""; // this will cause parseDate(entryDate) to return null;
508 else
509 entryDate = ((entry.Type == 'ToDo') ? entryEndTime : entryStartTime); // ToDo's use their EndTime, the rest use StartTime
510
511 // Convert date/time string to Date object
512 var date = parseDate(entryDate);
513 console.info('date: ' + date);
514 var endDate = ((entryEndTime == null) ? null : parseDate(entryEndTime));
515 console.info('endDate: ' + endDate);
516
517 // check if meeting event has already passed
518 if (entry.Type == 'Meeting') {
519 var compareTime = ((endDate == null) ? date.getTime() : endDate.getTime());
520 if (now.getTime() > compareTime) {
521 console.info('skipping Meeting (already passed) ' + entry.id);
522 counter--;
523 eventIds[entry.id] = 0;
524 continue;
525 }
526 }
527
528 // check if anniversary passed (not sure why they are in the list, the query was only for today - nokia?)
529 if (entry.Type == 'Anniversary') {
530 var tmp = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0,0,0);
531 if (date.getTime() < tmp.getTime()) {
532 console.info('skipping Anniversary (already passed) ' + entry.id);
533 counter--;
534 eventIds[entry.id] = 0;
535 continue;
536 }
537 }
538
539 // fix DayEvents end time. End times are off by 1 Second. It's possible that the event has already passed
540 if (entry.Type == 'DayEvent' && endDate != null) {
541 endDate.setMinutes(endDate.getMinutes() - 1);
542 console.info('fixing DayEvent endDate: ' + endDate);
543 if (now.getTime() > endDate.getTime()) {
544 console.info('event already passed ' + entry.id);
545 counter--;
546 eventIds[entry.id] = 0;
547 continue;
548 }
549 }
550
551 // check if the event is currently taking place
552 if (entryStartTime != null && entryEndTime != null && date != null && endDate != null) {
553 // check if we are between start and endtime
554 if ((date.getTime() < now.getTime()) && (now.getTime() < endDate.getTime())) {
555 date = now; // change appointment date/time to now
556 console.info('event is currently taking place: ' + date);
557 }
558 }
559
560 // skip events for the first panel in case this is the second one and we're not in fullscreen mode
561 if (mode == 0 && panelNum == 1 && counter < eventsPerWidget + 1) {
562 console.info('skipping (already in first widget) ' + entry.id);
563 continue;
564 }
565
566 // generate html output
567 entriesHtml += '<tr><td><img class="icon" src="' + entry.Type + '.png" /></td>';
568 if(date == null) {
569 // some languages have very strange locale date formats, can't parse all those. Also some todos don't have dates at all.
570 entriesHtml += '<td colspan="4"><span class="date">' + entryDate + '</span> ';
571 } else {
572 var weekDay = date.toLocaleDateString().substr(0,weekDayLength);
573 var time = formatTime(date);
574 var dateStr = formatDate(date, entryDate);
575 if (entry.Type == 'ToDo' || entry.Type == 'Anniversary' || entry.Type == 'DayEvent' || entry.Type == 'Reminder') {
576 if ((isToday(date) || isTomorrow(date)) && showTodayAsText) // show weekday if the date string is not text. looks odd otherwise
577 entriesHtml += '<td colspan="4" width="1px"><span class="date">' + dateStr + '</span> ';
578 else
579 entriesHtml += '<td class="weekDay" width="1px">' + weekDay + '</td><td width="1px" class="date">' + dateStr + '</td><td colspan="2">';
580 } else if (entry.Type == 'Meeting') {
581 if (showCombinedDateTime) {
582 if (isToday(date))
583 entriesHtml += '<td width="1px" colspan="4"><span class="today">' + time + '</span> ';
584 else if (isTomorrow(date))
585 entriesHtml += '<td width="1px" colspan="4"><span class="tomorrow">' + dateStr + '</span> <span class="time">' + time + '</span> ';
586 else
587 entriesHtml += '<td width="1px" class="weekDay">' + weekDay + '</td><td width="1px" class="date">' + dateStr + '</td><td colspan="2">';
588 } else {
589 if ((isToday(date) || isTomorrow(date)) && showTodayAsText)
590 entriesHtml += '<td colspan="4" width="1px"><span class="today">' + dateStr + '</span> <span class="time">' + time + '</span> ';
591 else
592 entriesHtml += '<td width="1px" class="weekDay">' + weekDay + '</td><td width="1px" class="date">' + dateStr + '</td><td width="1px" class="time">' + time + '</td><td>';
593 }
594 }
595 }
596 entriesHtml += '<span class="description">' + Summary + '</span></td></tr>';
597 }
598 }
599 entriesHtml += '</table>';
600 if (showNothingText && entriesHtml == '<table></table>')
601 entriesHtml = '<div style="width:295px; height:75px; text-align:center; line-height:75px; overflow:visible;">' + nothingText + '</div>';
602 if (cacheEntriesHtml != entriesHtml) {
603 if (mode == 0)
604 document.getElementById('calendarList').innerHTML = entriesHtml;
605 else
606 document.getElementById('fullscreenCalendarList').innerHTML = entriesHtml;
607 cacheEntriesHtml = entriesHtml;
608 }
609 } catch(e) {
610 error('displaying list:' + e + ', line ' + e.line);
611 return;
612 }
613 }
614
615 function updateScreen()
616 {
617 // check if opening fullscreen
618 if( window.innerHeight > 91 && mode == 0) {
619 mode = 1;
620 cacheEntriesHtml = '';
621 document.getElementById('body').style.backgroundImage = "";
622 showFullscreen();
623 }
624 else if (window.innerHeight <= 91 && mode != 0) {
625 mode = 0;
626 cacheEntriesHtml = '';
627 showHomescreen();
628 }
629
630 if (mode == 0)
631 updateHomescreen();
632 else if (mode == 1)
633 updateFullscreen();
634 }
635
636 function launchCalendar()
637 {
638 try {
639 widget.openApplication(calendarApp, "");
640 //window.close();
641 } catch(e) {
642 error('starting Calendar App');
643 return;
644 }
645 }
646
647 function init()
648 {
649 try {
650 // call calendar service
651 calendarService = device.getServiceObject("Service.Calendar", "IDataSource");
652 } catch(e) {
653 error('loading Calendar service');
654 return;
655 }
656
657 loadSettings();
658 updateCssClasses();
659 collectLocales();
660 //updateData();
661 requestNotification();
662 window.setInterval('updateData()', 1000 * 60 * updateDataInterval);
663
664 mode = 0;
665 showHomescreen();
666 updateScreen();
667 if (useBackgroundImage)
668 // check for screen rotation every 3 secs
669 window.setInterval('updateScreen()', 1000 * 3);
670 }
671
672 function createMenu()
673 {
674 window.menu.setLeftSoftkeyLabel("",null);
675 window.menu.setRightSoftkeyLabel("",null);
676 var id = 0;
677 var menuSettings = new MenuItem("Settings", id++);
678 var menuCallApp = new MenuItem("Open Calendar App", id++);
679 var menuAbout = new MenuItem("About", id++);
680 menuSettings.onSelect = showSettings;
681 menuAbout.onSelect = showAbout;
682 menuCallApp.onSelect = launchCalendar;
683 window.menu.clear();
684 window.menu.append(menuCallApp);
685 window.menu.append(menuSettings);
686 window.menu.append(menuAbout);
687 }
688
689 function showSettings()
690 {
691 mode = 2;
692 document.getElementById("homescreenView").style.display = "none";
693 document.getElementById("fullscreenView").style.display = "none";
694 document.getElementById("aboutView").style.display = "none";
695 document.getElementById("settingsView").style.display = "block";
696 document.onclick = null;
697
698 window.menu.setLeftSoftkeyLabel("Save", function()
699 {
700 //document.forms[0].elements["settings.monthRange"].value = monthRange;
701 monthRange = parseInt(document.forms[0].elements["settings.monthRange"].value);
702 if (monthRange < 0 || monthRange > 100)
703 monthRange = 2;
704 includeTodos = document.forms[0].elements["settings.includeTodos"].checked;
705 useBackgroundImage = document.forms[0].elements["settings.useBackgroundImage"].checked;
706 showCombinedDateTime = document.forms[0].elements["settings.showCombinedDateTime"].checked;
707 showLocation = document.forms[0].elements["settings.showLocation"].checked;
708 showTodayAsText = document.forms[0].elements["settings.showTodayAsText"].checked;
709 todayText = document.forms[0].elements["settings.todayText"].value;
710 tomorrowText = document.forms[0].elements["settings.tomorrowText"].value;
711 showNowAsText = document.forms[0].elements["settings.showNowAsText"].checked;
712 nowText = document.forms[0].elements["settings.nowText"].value;
713 dateSeparator = document.forms[0].elements["settings.dateSeparator"].value;
714 dateFormat = document.forms[0].elements["settings.dateFormat"].value;
715 if (dateFormat != 'auto' && dateFormat != 'DDMM' && dateFormat != 'MMDD')
716 dateFormat = 'auto';
717 weekDayLength = Number(parseInt(document.forms[0].elements["settings.weekDayLength"].value));
718 if (weekDayLength < 0 || weekDayLength > 20)
719 weekDayLength = 2;
720 updateDataInterval = parseInt(document.forms[0].elements["settings.updateDataInterval"].value);
721 if (updateDataInterval < 1 || updateDataInterval > 1000)
722 updateDataInterval = 5;
723 calendarApp = parseInt(document.forms[0].elements["settings.calendarApp"].value);
724 eventsPerWidget = parseInt(document.forms[0].elements["settings.eventsPerWidget"].value);
725 if (eventsPerWidget < 1 || eventsPerWidget > 10)
726 eventsPerWidget = 4;
727 showNothingText = document.forms[0].elements["settings.showNothingText"].checked;
728 nothingText = document.forms[0].elements["settings.nothingText"].value;
729 enableDaylightSaving = document.forms[0].elements["settings.enableDaylightSaving"].checked;
730
731 cssStyle_background = document.forms[0].elements["settings.cssStyle_background"].value;
732 cssStyle_backgroundFullscreen = document.forms[0].elements["settings.cssStyle_backgroundFullscreen"].value;
733 cssStyle_weekDay = document.forms[0].elements["settings.cssStyle_weekDay"].value;
734 cssStyle_date = document.forms[0].elements["settings.cssStyle_date"].value;
735 cssStyle_today = document.forms[0].elements["settings.cssStyle_today"].value;
736 cssStyle_tomorrow = document.forms[0].elements["settings.cssStyle_tomorrow"].value;
737 cssStyle_time = document.forms[0].elements["settings.cssStyle_time"].value;
738 cssStyle_now = document.forms[0].elements["settings.cssStyle_now"].value;
739 cssStyle_description = document.forms[0].elements["settings.cssStyle_description"].value;
740 cssStyle_icon = document.forms[0].elements["settings.cssStyle_icon"].value;
741
742 updateCssClasses();
743
744 saveSettings();
745
746 mode = 1;
747 showFullscreen();
748 });
749 window.menu.setRightSoftkeyLabel("Cancel", function()
750 {
751 mode = 1;
752 showFullscreen();
753 });
754
755 document.getElementById("settingsList").innerHTML =
756 '<form>' +
757 '<table><tr><td>Month Range:<br><input class="textInput" name="settings.monthRange" type="text" value="' + monthRange + '" /></td>' + printHintBox('number of months to include in the event list') +
758 '<hr><table><tr><td>Include ToDos:<br><input name="settings.includeTodos" type="checkbox" value="true" ' + (includeTodos ? 'checked="checked"' : '') + '/></td>' + printHintBox('disable to remove ToDos from event list') +
759 '<hr><table><tr><td>Use Background Image:<br><input name="settings.useBackgroundImage" type="checkbox" value="true" ' + (useBackgroundImage ? 'checked="checked"' : '') + '/></td>' + printHintBox('use background_portrait.png and background_landscape.png to fake transparency. Disable to use a solid background color') +
760 '<hr><table><tr><td>Show Combined Date & Time:<br><input name="settings.showCombinedDateTime" type="checkbox" value="true" ' + (showCombinedDateTime ? 'checked="checked"' : '') + '/></td>' + printHintBox('only show the time for events happening today, otherwise just show the date') +
761 '<hr><table><tr><td>Show Location:<br><input name="settings.showLocation" type="checkbox" value="true" ' + (showLocation ? 'checked="checked"' : '') + '/></td>' + printHintBox('show the location for meeting events') +
762 '<hr><table><tr><td>Show Today As Text:<br><input name="settings.showTodayAsText" type="checkbox" value="true" ' + (showTodayAsText ? 'checked="checked"' : '') + '/></td>' + printHintBox('if enabled, the current date will be shown as "Today" instead of "31.12"') +
763 '<hr><table><tr><td>"Today" Text:<br><input class="textInput" name="settings.todayText" type="text" value="' + todayText + '" /></td>' + printHintBox('text to display for "Today"') + '</tr>' +
764 '<hr><table><tr><td>"Tomorrow" Text:<br><input class="textInput" name="settings.tomorrowText" type="text" value="' + tomorrowText + '" /></td>' + printHintBox('text to display for "Tomorrow"') +
765 '<hr><table><tr><td>Show "Now" As Text:<br><input name="settings.showNowAsText" type="checkbox" value="true" ' + (showNowAsText ? 'checked="checked"' : '') + '/></td>' + printHintBox('if enabled, the appointment time will be shown as "Now" instead of "12:00"') +
766 '<hr><table><tr><td>"Now" Text:<br><input class="textInput" name="settings.nowText" type="text" value="' + nowText + '" /></td>' + printHintBox('text to display for "Now"') +
767 '<hr><table><tr><td>Date Separator:<br><input class="textInput" name="settings.dateSeparator" type="text" value="' + dateSeparator + '" /></td>' + printHintBox('separator for dates. e.g. "31.12" or "31/12"') +
768 '<hr><table><tr><td>Date Format:<br><select name="settings.dateFormat" size="1">' +
769 '<option label="auto detect"' + (dateFormat == 'auto' ? ' selected="selected"' : '') + '>auto</option>' +
770 '<option label="MMDD"' + (dateFormat == 'MMDD' ? ' selected="selected"' : '') + '>MMDD</option>' +
771 '<option label="DDMM"' + (dateFormat == 'DDMM' ? ' selected="selected"' : '') + '>DDMM</option>' +
772 '</select></div>' + printHintBox('how dates will be displayed. \'auto\' will autodetect your phone\'s date format setting. \'MMDD\' will write month first, \'DDMM\' will write day first') + '</tr>' +
773 '<hr><table><tr><td>Weekday Length:<br><input class="textInput" name="settings.weekDayLength" type="text" value="' + weekDayLength + '" /></td>' + printHintBox('defines how many characters of the weekday will be shown. E.g. 2 will cut "Friday" to "Fr"') +
774 '<hr><table><tr><td>Update Data Interval:<br><input class="textInput" name="settings.updateDataInterval" type="text" value="' + updateDataInterval + '" /></td>' + printHintBox('how many minutes to wait before updating the displayed data. The higher the number, the less battery is used') +
775 '<hr><table><tr><td>Calendar Application UID:<br><input class="textInput" name="settings.calendarApp" type="text" value="0x' + calendarApp.toString(16) + '" /></td>' + printHintBox('UID of the calendar app to run when clicking the widget. 0x10005901 = buildin calendar, 0x20004ec1 = Epocware Handy Calendar') +
776 '<hr><table><tr><td>Events Per Widget:<br><input class="textInput" name="settings.eventsPerWidget" type="text" value="' + eventsPerWidget + '" /></td>' + printHintBox('number of events to show per widget. Default is 4') +
777 '<hr><table><tr><td>Show Nothing Text:<br><input name="settings.showNothingText" type="checkbox" value="true" ' + (showNothingText ? 'checked="checked"' : '') + '/></td>' + printHintBox('if enabled, show a text if no events are in the list') +
778 '<hr><table><tr><td>"nothing" Text:<br><input class="textInput" name="settings.nothingText" type="text" value="' + nothingText + '" /></td>' + printHintBox('text to show when no events are in the list') +
779 '<hr><table><tr><td>Enable Daylight Saving:<br><input name="settings.enableDaylightSaving" type="checkbox" value="true" ' + (enableDaylightSaving ? 'checked="checked"' : '') + '/></td>' + printHintBox('enable this if you are in a timezone that has daylight saving time (+1h)') +
780 '<hr style="margin-bottom:60px;"><h1 class="title">CSS Styles</h1>' +
781 '<hr><table><tr><td>.background:<br><input class="textInput" name="settings.cssStyle_background" type="text" value="' + cssStyle_background + '" /></td>' + printHintBox('Defines the background of the widget. If you want to use a background image, enable "useBackgroundImage" instead. For the default themes, black, gray, and light blue, codes are #292029, #e7dfe7, #009aef') +
782 '<hr><table><tr><td>.backgroundFullscreen:<br><input class="textInput" name="settings.cssStyle_backgroundFullscreen" type="text" value="' + cssStyle_backgroundFullscreen + '" /></td>' + printHintBox('Same as background but for the fullscreen version of the widget') +
783 '<hr><table><tr><td>.weekDay:<br><input class="textInput" name="settings.cssStyle_weekDay" type="text" value="' + cssStyle_weekDay + '" /></td>' + printHintBox('Defines the appearance of all week day texts') +
784 '<hr><table><tr><td>.date:<br><input class="textInput" name="settings.cssStyle_date" type="text" value="' + cssStyle_date + '" /></td>' + printHintBox('Defines the appearance of all date texts') +
785 '<hr><table><tr><td>.today:<br><input class="textInput" name="settings.cssStyle_today" type="text" value="' + cssStyle_today + '" /></td>' + printHintBox('Defines the appearance of "Today" text') +
786 '<hr><table><tr><td>.tomorrow:<br><input class="textInput" name="settings.cssStyle_tomorrow" type="text" value="' + cssStyle_tomorrow + '" /></td>' + printHintBox('Defines the appearance of "Tomorrow" text') +
787 '<hr><table><tr><td>.time:<br><input class="textInput" name="settings.cssStyle_time" type="text" value="' + cssStyle_time + '" /></td>' + printHintBox('Defines the appearance of all time texts') +
788 '<hr><table><tr><td>.now:<br><input class="textInput" name="settings.cssStyle_now" type="text" value="' + cssStyle_now + '" /></td>' + printHintBox('Defines the appearance of "Now" text') +
789 '<hr><table><tr><td>.description:<br><input class="textInput" name="settings.cssStyle_description" type="text" value="' + cssStyle_description + '" /></td>' + printHintBox('Defines the appearance of all event descriptions') +
790 '<hr><table><tr><td>.icon:<br><input class="textInput" name="settings.cssStyle_icon" type="text" value="' + cssStyle_icon + '" /></td>' + printHintBox('Defines size and appearance of icons') +
791 '<hr style="margin-bottom:60px;"><input name="reset" type="button" value="Restore Defaults" onclick="javascript:restoreDefaultSettings();showSettings();" />' +
792 '</form>';
793 }
794
795 function changeCssClass(classname, properties)
796 {
797 for(var i = 0; i < document.styleSheets[0]['cssRules'].length; i++)
798 {
799 if (document.styleSheets[0]['cssRules'][i].selectorText == classname) {
800 document.styleSheets[0].deleteRule(i);
801 document.styleSheets[0].insertRule(classname + ' { ' + properties + ' }', document.styleSheets[0]['cssRules'].length);
802 break;
803 }
804 }
805 }
806
807 function updateCssClasses()
808 {
809 changeCssClass(".background", cssStyle_background);
810 changeCssClass(".backgroundFullscreen", cssStyle_backgroundFullscreen);
811 changeCssClass(".weekDay", cssStyle_weekDay);
812 changeCssClass(".date", cssStyle_date);
813 changeCssClass(".today", cssStyle_today);
814 changeCssClass(".tomorrow", cssStyle_tomorrow);
815 changeCssClass(".time", cssStyle_time);
816 changeCssClass(".now", cssStyle_now);
817 changeCssClass(".description", cssStyle_description);
818 changeCssClass(".icon", cssStyle_icon);
819 }
820
821 function restoreDefaultSettings()
822 {
823 monthRange = 2;
824 includeTodos = true;
825 useBackgroundImage = true;
826 showCombinedDateTime = false;
827 showLocation = true;
828 showTodayAsText = true;
829 todayText = 'Today';
830 tomorrowText = 'Tomorrow';
831 showNowAsText = true;
832 nowText = 'Now';
833 dateSeparator = '.';
834 dateFormat = 'auto'
835 weekDayLength = 2;
836 updateDataInterval = 5;
837 calendarApp = 0x10005901;
838 eventsPerWidget = 4;
839 showNothingText = true;
840 nothingText = 'No further events within ' + monthRange + ' months';
841 enableDaylightSaving = true;
842
843 cssStyle_background = "color:#ffffff; background-color:#000000";
844 cssStyle_backgroundFullscreen = "color:#ffffff; background-color:#000000";
845 cssStyle_weekDay = "";
846 cssStyle_date = "";
847 cssStyle_today = "color:#ff0000";
848 cssStyle_tomorrow = "color:#0000ff";
849 cssStyle_time = "";
850 cssStyle_now = "color:#ff00ff";
851 cssStyle_description = "";
852 cssStyle_icon = "width:15px; height:15px";
853 }
854
855 function loadSettings()
856 {
857 if (widget.preferenceForKey('monthRange'))
858 monthRange = Number(widget.preferenceForKey('monthRange'));
859 else
860 monthRange = 2;
861
862 if (widget.preferenceForKey('includeTodos'))
863 includeTodos = (widget.preferenceForKey('includeTodos') == 'true');
864 else
865 includeTodos = true;
866
867 if (widget.preferenceForKey('useBackgroundImage'))
868 useBackgroundImage = (widget.preferenceForKey('useBackgroundImage') == 'true');
869 else
870 useBackgroundImage = true;
871
872 if (widget.preferenceForKey('showCombinedDateTime'))
873 showCombinedDateTime = (widget.preferenceForKey('showCombinedDateTime') == 'true');
874 else
875 showCombinedDateTime = false;
876
877 if (widget.preferenceForKey('showLocation'))
878 showLocation = (widget.preferenceForKey('showLocation') == 'true');
879 else
880 showLocation = true;
881
882 if (widget.preferenceForKey('showTodayAsText'))
883 showTodayAsText = (widget.preferenceForKey('showTodayAsText') == 'true');
884 else
885 showTodayAsText = true;
886
887 if (widget.preferenceForKey('todayText'))
888 todayText = widget.preferenceForKey('todayText');
889 else
890 todayText = 'Today';
891
892 if (widget.preferenceForKey('tomorrowText'))
893 tomorrowText = widget.preferenceForKey('tomorrowText');
894 else
895 tomorrowText = 'Tomorrow';
896
897 if (widget.preferenceForKey('showNowAsText'))
898 showNowAsText = (widget.preferenceForKey('showNowAsText') == 'true');
899 else
900 showNowAsText = true;
901
902 if (widget.preferenceForKey('nowText'))
903 nowText = widget.preferenceForKey('nowText');
904 else
905 nowText = 'Now';
906
907 if (widget.preferenceForKey('dateSeparator'))
908 dateSeparator = widget.preferenceForKey('dateSeparator');
909 else
910 dateSeparator = '.';
911
912 if (widget.preferenceForKey('dateFormat'))
913 dateFormat = widget.preferenceForKey('dateFormat');
914 else
915 dateFormat = 'auto';
916
917 if (widget.preferenceForKey('weekDayLength'))
918 weekDayLength = Number(widget.preferenceForKey('weekDayLength'));
919 else
920 weekDayLength = 2;
921
922 if (widget.preferenceForKey('updateDataInterval'))
923 updateDataInterval = Number(widget.preferenceForKey('updateDataInterval'));
924 else
925 updateDataInterval = 5;
926
927 if (widget.preferenceForKey('calendarApp'))
928 calendarApp = Number(widget.preferenceForKey('calendarApp'));
929 else
930 calendarApp = 0x10005901;
931
932 if (widget.preferenceForKey('eventsPerWidget'))
933 eventsPerWidget = Number(widget.preferenceForKey('eventsPerWidget'));
934 else
935 eventsPerWidget = 4;
936
937 if (widget.preferenceForKey('showNothingText'))
938 showNothingText = (widget.preferenceForKey('showNothingText') == 'true');
939 else
940 showNothingText = true;
941
942 if (widget.preferenceForKey('nothingText'))
943 nothingText = widget.preferenceForKey('nothingText');
944 else
945 nothingText = 'No further events within ' + monthRange + ' months';
946
947 if (widget.preferenceForKey('enableDaylightSaving'))
948 enableDaylightSaving = (widget.preferenceForKey('enableDaylightSaving') == 'true');
949 else
950 enableDaylightSaving = true;
951
952 // CSS styles
953
954 if (widget.preferenceForKey('cssStyle_background'))
955 cssStyle_background = widget.preferenceForKey('cssStyle_background');
956 else
957 cssStyle_background = "color:#ffffff; background-color:#000000";
958
959 if (widget.preferenceForKey('cssStyle_backgroundFullscreen'))
960 cssStyle_backgroundFullscreen = widget.preferenceForKey('cssStyle_backgroundFullscreen');
961 else
962 cssStyle_backgroundFullscreen = "color:#ffffff; background-color:#000000";
963
964 if (widget.preferenceForKey('cssStyle_weekDay'))
965 cssStyle_weekDay = widget.preferenceForKey('cssStyle_weekDay');
966 else
967 cssStyle_weekDay = "";
968
969 if (widget.preferenceForKey('cssStyle_date'))
970 cssStyle_date = widget.preferenceForKey('cssStyle_date');
971 else
972 cssStyle_date = "";
973
974 if (widget.preferenceForKey('cssStyle_today'))
975 cssStyle_today = widget.preferenceForKey('cssStyle_today');
976 else
977 cssStyle_today = "color:#ff0000";
978
979 if (widget.preferenceForKey('cssStyle_tomorrow'))
980 cssStyle_tomorrow = widget.preferenceForKey('cssStyle_tomorrow');
981 else
982 cssStyle_tomorrow = "color:#0000ff";
983
984 if (widget.preferenceForKey('cssStyle_time'))
985 cssStyle_time = widget.preferenceForKey('cssStyle_time');
986 else
987 cssStyle_time = "";
988
989 if (widget.preferenceForKey('cssStyle_now'))
990 cssStyle_now = widget.preferenceForKey('cssStyle_now');
991 else
992 cssStyle_now = "color:#ff00ff";
993
994 if (widget.preferenceForKey('cssStyle_description'))
995 cssStyle_description = widget.preferenceForKey('cssStyle_description');
996 else
997 cssStyle_description = "";
998
999 if (widget.preferenceForKey('cssStyle_icon'))
1000 cssStyle_icon = widget.preferenceForKey('cssStyle_icon');
1001 else
1002 cssStyle_icon = "width:15px; height:15px";
1003 }
1004
1005 function saveSettings()
1006 {
1007 widget.setPreferenceForKey(monthRange.toString(), 'monthRange');
1008 widget.setPreferenceForKey(includeTodos ? 'true' : 'false', 'includeTodos');
1009 widget.setPreferenceForKey(useBackgroundImage ? 'true' : 'false', 'useBackgroundImage');
1010 widget.setPreferenceForKey(showCombinedDateTime ? 'true' : 'false', 'showCombinedDateTime');
1011 widget.setPreferenceForKey(showLocation ? 'true' : 'false', 'showLocation');
1012 widget.setPreferenceForKey(showTodayAsText ? 'true' : 'false', 'showTodayAsText');
1013 widget.setPreferenceForKey(todayText, 'todayText');
1014 widget.setPreferenceForKey(tomorrowText, 'tomorrowText');
1015 widget.setPreferenceForKey(showNowAsText ? 'true' : 'false', 'showNowAsText');
1016 widget.setPreferenceForKey(nowText, 'nowText');
1017 widget.setPreferenceForKey(dateSeparator, 'dateSeparator');
1018 widget.setPreferenceForKey(dateFormat, 'dateFormat');
1019 widget.setPreferenceForKey(weekDayLength.toString(), 'weekDayLength');
1020 widget.setPreferenceForKey(updateDataInterval.toString(), 'updateDataInterval');
1021 widget.setPreferenceForKey(calendarApp.toString(), 'calendarApp');
1022 widget.setPreferenceForKey(eventsPerWidget.toString(), 'eventsPerWidget');
1023 widget.setPreferenceForKey(showNothingText ? 'true' : 'false', 'showNothingText');
1024 widget.setPreferenceForKey(nothingText, 'nothingText');
1025 widget.setPreferenceForKey(enableDaylightSaving ? 'true' : 'false', 'enableDaylightSaving');
1026
1027 widget.setPreferenceForKey(cssStyle_background, 'cssStyle_background');
1028 widget.setPreferenceForKey(cssStyle_backgroundFullscreen, 'cssStyle_backgroundFullscreen');
1029 widget.setPreferenceForKey(cssStyle_weekDay, 'cssStyle_weekDay');
1030 widget.setPreferenceForKey(cssStyle_date, 'cssStyle_date');
1031 widget.setPreferenceForKey(cssStyle_today, 'cssStyle_today');
1032 widget.setPreferenceForKey(cssStyle_tomorrow, 'cssStyle_tomorrow');
1033 widget.setPreferenceForKey(cssStyle_time, 'cssStyle_time');
1034 widget.setPreferenceForKey(cssStyle_now, 'cssStyle_now');
1035 widget.setPreferenceForKey(cssStyle_description, 'cssStyle_description');
1036 widget.setPreferenceForKey(cssStyle_icon, 'cssStyle_icon');
1037 }
1038
1039 function toggleVisibility(elementId)
1040 {
1041 if (document.getElementById(elementId).style.display == "none")
1042 document.getElementById(elementId).style.display = "block";
1043 else
1044 document.getElementById(elementId).style.display = "none";
1045 }
1046
1047 var uniqueId = 0;
1048 function printHintBox(text)
1049 {
1050 uniqueId++;
1051 return '<td width="1%" align="right" onclick="javascript:toggleVisibility(\'info' + uniqueId + '\')">Help</td></tr></table>'+
1052 '<div class="settingsInfo" id="info' + uniqueId + '">' + text + '</div>';
1053 }
1054
1055 function showAbout()
1056 {
1057 mode = 3;
1058 document.getElementById("homescreenView").style.display = "none";
1059 document.getElementById("fullscreenView").style.display = "none";
1060 document.getElementById("aboutView").style.display = "block";
1061 document.getElementById("settingsView").style.display = "none";
1062 document.onclick = null;
1063
1064 window.menu.setLeftSoftkeyLabel(" ", function(){});
1065 window.menu.setRightSoftkeyLabel("Back", function()
1066 {
1067 mode = 1;
1068 showFullscreen();
1069 });
1070
1071 //document.getElementById("aboutView").innerHTML = 'aboutView';
1072 document.getElementById("name").innerHTML = "Coming Next " + version;
1073 }
1074
1075 function updateFullscreen()
1076 {
1077 }
1078
1079 function showFullscreen()
1080 {
1081 document.getElementById("homescreenView").style.display = "none";
1082 document.getElementById("fullscreenView").style.display = "block";
1083 document.getElementById("aboutView").style.display = "none";
1084 document.getElementById("settingsView").style.display = "none";
1085 document.getElementById('body').className = "backgroundFullscreen";
1086 document.onclick = launchCalendar;
1087 createMenu();
1088 updateData();
1089 }
1090
1091 function updateHomescreen()
1092 {
1093 if (useBackgroundImage) {
1094 // check for screen rotation
1095 if (orientation != 'portrait' && screen.width == 360 && screen.height == 640) {
1096 window.widget.prepareForTransition("fade");
1097 orientation = 'portrait';
1098 document.getElementById('body').style.backgroundImage = 'url(background_' + orientation + '.png)';
1099 document.getElementById('body').style.backgroundColor = 'none';
1100 window.widget.performTransition();
1101 } else if (orientation != 'landscape' && screen.width == 640 && screen.height == 360) {
1102 window.widget.prepareForTransition("fade");
1103 orientation = 'landscape';
1104 document.getElementById('body').style.backgroundImage = 'url(background_' + orientation + '.png)';
1105 document.getElementById('body').style.backgroundColor = 'none';
1106 window.widget.performTransition();
1107 }
1108 else if (document.getElementById('body').style.backgroundImage == "")
1109 {
1110 document.getElementById('body').style.backgroundImage = 'url(background_' + orientation + '.png)';
1111 }
1112 }
1113 }
1114
1115 function showHomescreen()
1116 {
1117 document.getElementById("homescreenView").style.display = "block";
1118 document.getElementById("fullscreenView").style.display = "none";
1119 document.getElementById("aboutView").style.display = "none";
1120 document.getElementById("settingsView").style.display = "none";
1121 document.getElementById('body').className = "background";
1122 document.onclick = null;
1123 updateData();
1124 }
1125
1126 </script>
1127
1128 <style type="text/css">
1129 table { margin:0px; padding:0px; border-spacing:0px; }
1130 td { padding:0px 5px 0px 0px; white-space:nowrap; overflow:hidden; }
1131 hr { color:#ffffff; background-color:#ffffff; height:1px; text-align:left; border-style:none; }
1132 .settingsInfo { display:none; font-style:italic; }
1133 .title { font-weight:bold; font-size:14pt; }
1134 .textInput { width:90%; }
1135 #homescreenView { width: 315px; height:91px; overflow:hidden; }
1136 #calendarList { position:absolute; left:10px; top:4px; width:295px; height:75px; overflow:hidden; }
1137 #name { text-align:center; }
1138 #appicon { display: block; margin-left: auto; margin-right: auto; margin-top: 50px; }
1139 #smallappicon { width:22px; height:22px; margin-right:10px; float:left; }
1140 </style>
1141
1142 </head>
1143
1144 <body id="body" class="background">
1145 <div id="homescreenView">
1146 <div id="calendarList"></div>
1147 </div>
1148 <div id="fullscreenView" style="display:none;">
1149 <img src="Icon.png" id="smallappicon">
1150 <h1 class="title">Coming Next</h1>
1151 <hr />
1152 <div id="fullscreenCalendarList">loading...</div>
1153 </div>
1154 <div id="settingsView" style="display:none">
1155 <img src="Icon.png" id="smallappicon">
1156 <h1 class="title">Settings</h1>
1157 <hr />
1158 <div id="settingsList"></div>
1159 </div>
1160 <div id="aboutView" style="display:none">
1161 <img src="Icon.png" id="appicon">
1162 <h1 id="name">Coming Next</h1>
1163 <hr />
1164 <p>Created by Dr. Cochambre and Michael Prager.</p>
1165 <p>This software is open source and licensed under the GPLv3.</p>
1166 <p>Visit https://sourceforge.net/projects/comingnext/ for free updates.</p>
1167 <hr />
1168 </div>
1169 </body>
1170
1171 </html>