]> code.delx.au - comingnext/blob - comingNext/index.html
fixed background image beeing used in fullscreen mode (now there is an extra CSS...
[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
697 window.menu.setLeftSoftkeyLabel("Save", function()
698 {
699 //document.forms[0].elements["settings.monthRange"].value = monthRange;
700 monthRange = parseInt(document.forms[0].elements["settings.monthRange"].value);
701 if (monthRange < 0 || monthRange > 100)
702 monthRange = 2;
703 includeTodos = document.forms[0].elements["settings.includeTodos"].checked;
704 useBackgroundImage = document.forms[0].elements["settings.useBackgroundImage"].checked;
705 showCombinedDateTime = document.forms[0].elements["settings.showCombinedDateTime"].checked;
706 showLocation = document.forms[0].elements["settings.showLocation"].checked;
707 showTodayAsText = document.forms[0].elements["settings.showTodayAsText"].checked;
708 todayText = document.forms[0].elements["settings.todayText"].value;
709 tomorrowText = document.forms[0].elements["settings.tomorrowText"].value;
710 showNowAsText = document.forms[0].elements["settings.showNowAsText"].checked;
711 nowText = document.forms[0].elements["settings.nowText"].value;
712 dateSeparator = document.forms[0].elements["settings.dateSeparator"].value;
713 dateFormat = document.forms[0].elements["settings.dateFormat"].value;
714 if (dateFormat != 'auto' && dateFormat != 'DDMM' && dateFormat != 'MMDD')
715 dateFormat = 'auto';
716 weekDayLength = Number(parseInt(document.forms[0].elements["settings.weekDayLength"].value));
717 if (weekDayLength < 0 || weekDayLength > 20)
718 weekDayLength = 2;
719 updateDataInterval = parseInt(document.forms[0].elements["settings.updateDataInterval"].value);
720 if (updateDataInterval < 1 || updateDataInterval > 1000)
721 updateDataInterval = 5;
722 calendarApp = parseInt(document.forms[0].elements["settings.calendarApp"].value);
723 eventsPerWidget = parseInt(document.forms[0].elements["settings.eventsPerWidget"].value);
724 if (eventsPerWidget < 1 || eventsPerWidget > 10)
725 eventsPerWidget = 4;
726 showNothingText = document.forms[0].elements["settings.showNothingText"].checked;
727 nothingText = document.forms[0].elements["settings.nothingText"].value;
728 enableDaylightSaving = document.forms[0].elements["settings.enableDaylightSaving"].checked;
729
730 cssStyle_background = document.forms[0].elements["settings.cssStyle_background"].value;
731 cssStyle_backgroundFullscreen = document.forms[0].elements["settings.cssStyle_backgroundFullscreen"].value;
732 cssStyle_weekDay = document.forms[0].elements["settings.cssStyle_weekDay"].value;
733 cssStyle_date = document.forms[0].elements["settings.cssStyle_date"].value;
734 cssStyle_today = document.forms[0].elements["settings.cssStyle_today"].value;
735 cssStyle_tomorrow = document.forms[0].elements["settings.cssStyle_tomorrow"].value;
736 cssStyle_time = document.forms[0].elements["settings.cssStyle_time"].value;
737 cssStyle_now = document.forms[0].elements["settings.cssStyle_now"].value;
738 cssStyle_description = document.forms[0].elements["settings.cssStyle_description"].value;
739 cssStyle_icon = document.forms[0].elements["settings.cssStyle_icon"].value;
740
741 updateCssClasses();
742
743 saveSettings();
744
745 mode = 1;
746 showFullscreen();
747 });
748 window.menu.setRightSoftkeyLabel("Cancel", function()
749 {
750 mode = 1;
751 showFullscreen();
752 });
753
754 document.getElementById("settingsList").innerHTML =
755 '<form>' +
756 '<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') +
757 '<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') +
758 '<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') +
759 '<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') +
760 '<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') +
761 '<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"') +
762 '<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>' +
763 '<hr><table><tr><td>"Tomorrow" Text:<br><input class="textInput" name="settings.tomorrowText" type="text" value="' + tomorrowText + '" /></td>' + printHintBox('text to display for "Tomorrow"') +
764 '<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"') +
765 '<hr><table><tr><td>"Now" Text:<br><input class="textInput" name="settings.nowText" type="text" value="' + nowText + '" /></td>' + printHintBox('text to display for "Now"') +
766 '<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"') +
767 '<hr><table><tr><td>Date Format:<br><select name="settings.dateFormat" size="1">' +
768 '<option label="auto detect"' + (dateFormat == 'auto' ? ' selected="selected"' : '') + '>auto</option>' +
769 '<option label="MMDD"' + (dateFormat == 'MMDD' ? ' selected="selected"' : '') + '>MMDD</option>' +
770 '<option label="DDMM"' + (dateFormat == 'DDMM' ? ' selected="selected"' : '') + '>DDMM</option>' +
771 '</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>' +
772 '<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"') +
773 '<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') +
774 '<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') +
775 '<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') +
776 '<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') +
777 '<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') +
778 '<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)') +
779 '<hr style="margin-bottom:60px;"><h1 class="title">CSS Styles</h1>' +
780 '<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') +
781 '<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') +
782 '<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') +
783 '<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') +
784 '<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') +
785 '<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') +
786 '<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') +
787 '<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') +
788 '<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') +
789 '<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') +
790 '<hr style="margin-bottom:60px;"><input name="reset" type="button" value="Restore Defaults" onclick="javascript:restoreDefaultSettings();showSettings();" />' +
791 '</form>';
792 }
793
794 function changeCssClass(classname, properties)
795 {
796 for(var i = 0; i < document.styleSheets[0]['cssRules'].length; i++)
797 {
798 if (document.styleSheets[0]['cssRules'][i].selectorText == classname) {
799 document.styleSheets[0].deleteRule(i);
800 document.styleSheets[0].insertRule(classname + ' { ' + properties + ' }', document.styleSheets[0]['cssRules'].length);
801 break;
802 }
803 }
804 }
805
806 function updateCssClasses()
807 {
808 changeCssClass(".background", cssStyle_background);
809 changeCssClass(".backgroundFullscreen", cssStyle_backgroundFullscreen);
810 changeCssClass(".weekDay", cssStyle_weekDay);
811 changeCssClass(".date", cssStyle_date);
812 changeCssClass(".today", cssStyle_today);
813 changeCssClass(".tomorrow", cssStyle_tomorrow);
814 changeCssClass(".time", cssStyle_time);
815 changeCssClass(".now", cssStyle_now);
816 changeCssClass(".description", cssStyle_description);
817 changeCssClass(".icon", cssStyle_icon);
818 }
819
820 function restoreDefaultSettings()
821 {
822 monthRange = 2;
823 includeTodos = true;
824 useBackgroundImage = true;
825 showCombinedDateTime = false;
826 showLocation = true;
827 showTodayAsText = true;
828 todayText = 'Today';
829 tomorrowText = 'Tomorrow';
830 showNowAsText = true;
831 nowText = 'Now';
832 dateSeparator = '.';
833 dateFormat = 'auto'
834 weekDayLength = 2;
835 updateDataInterval = 5;
836 calendarApp = 0x10005901;
837 eventsPerWidget = 4;
838 showNothingText = true;
839 nothingText = 'No further events within ' + monthRange + ' months';
840 enableDaylightSaving = true;
841
842 cssStyle_background = "color:#ffffff; background-color:#000000";
843 cssStyle_backgroundFullscreen = "color:#ffffff; background-color:#000000";
844 cssStyle_weekDay = "";
845 cssStyle_date = "";
846 cssStyle_today = "color:#ff0000";
847 cssStyle_tomorrow = "color:#0000ff";
848 cssStyle_time = "";
849 cssStyle_now = "color:#ff00ff";
850 cssStyle_description = "";
851 cssStyle_icon = "width:15px; height:15px";
852 }
853
854 function loadSettings()
855 {
856 if (widget.preferenceForKey('monthRange'))
857 monthRange = Number(widget.preferenceForKey('monthRange'));
858 else
859 monthRange = 2;
860
861 if (widget.preferenceForKey('includeTodos'))
862 includeTodos = (widget.preferenceForKey('includeTodos') == 'true');
863 else
864 includeTodos = true;
865
866 if (widget.preferenceForKey('useBackgroundImage'))
867 useBackgroundImage = (widget.preferenceForKey('useBackgroundImage') == 'true');
868 else
869 useBackgroundImage = true;
870
871 if (widget.preferenceForKey('showCombinedDateTime'))
872 showCombinedDateTime = (widget.preferenceForKey('showCombinedDateTime') == 'true');
873 else
874 showCombinedDateTime = false;
875
876 if (widget.preferenceForKey('showLocation'))
877 showLocation = (widget.preferenceForKey('showLocation') == 'true');
878 else
879 showLocation = true;
880
881 if (widget.preferenceForKey('showTodayAsText'))
882 showTodayAsText = (widget.preferenceForKey('showTodayAsText') == 'true');
883 else
884 showTodayAsText = true;
885
886 if (widget.preferenceForKey('todayText'))
887 todayText = widget.preferenceForKey('todayText');
888 else
889 todayText = 'Today';
890
891 if (widget.preferenceForKey('tomorrowText'))
892 tomorrowText = widget.preferenceForKey('tomorrowText');
893 else
894 tomorrowText = 'Tomorrow';
895
896 if (widget.preferenceForKey('showNowAsText'))
897 showNowAsText = (widget.preferenceForKey('showNowAsText') == 'true');
898 else
899 showNowAsText = true;
900
901 if (widget.preferenceForKey('nowText'))
902 nowText = widget.preferenceForKey('nowText');
903 else
904 nowText = 'Now';
905
906 if (widget.preferenceForKey('dateSeparator'))
907 dateSeparator = widget.preferenceForKey('dateSeparator');
908 else
909 dateSeparator = '.';
910
911 if (widget.preferenceForKey('dateFormat'))
912 dateFormat = widget.preferenceForKey('dateFormat');
913 else
914 dateFormat = 'auto';
915
916 if (widget.preferenceForKey('weekDayLength'))
917 weekDayLength = Number(widget.preferenceForKey('weekDayLength'));
918 else
919 weekDayLength = 2;
920
921 if (widget.preferenceForKey('updateDataInterval'))
922 updateDataInterval = Number(widget.preferenceForKey('updateDataInterval'));
923 else
924 updateDataInterval = 5;
925
926 if (widget.preferenceForKey('calendarApp'))
927 calendarApp = Number(widget.preferenceForKey('calendarApp'));
928 else
929 calendarApp = 0x10005901;
930
931 if (widget.preferenceForKey('eventsPerWidget'))
932 eventsPerWidget = Number(widget.preferenceForKey('eventsPerWidget'));
933 else
934 eventsPerWidget = 4;
935
936 if (widget.preferenceForKey('showNothingText'))
937 showNothingText = (widget.preferenceForKey('showNothingText') == 'true');
938 else
939 showNothingText = true;
940
941 if (widget.preferenceForKey('nothingText'))
942 nothingText = widget.preferenceForKey('nothingText');
943 else
944 nothingText = 'No further events within ' + monthRange + ' months';
945
946 if (widget.preferenceForKey('enableDaylightSaving'))
947 enableDaylightSaving = (widget.preferenceForKey('enableDaylightSaving') == 'true');
948 else
949 enableDaylightSaving = true;
950
951 // CSS styles
952
953 if (widget.preferenceForKey('cssStyle_background'))
954 cssStyle_background = widget.preferenceForKey('cssStyle_background');
955 else
956 cssStyle_background = "color:#ffffff; background-color:#000000";
957
958 if (widget.preferenceForKey('cssStyle_backgroundFullscreen'))
959 cssStyle_backgroundFullscreen = widget.preferenceForKey('cssStyle_backgroundFullscreen');
960 else
961 cssStyle_backgroundFullscreen = "color:#ffffff; background-color:#000000";
962
963 if (widget.preferenceForKey('cssStyle_weekDay'))
964 cssStyle_weekDay = widget.preferenceForKey('cssStyle_weekDay');
965 else
966 cssStyle_weekDay = "";
967
968 if (widget.preferenceForKey('cssStyle_date'))
969 cssStyle_date = widget.preferenceForKey('cssStyle_date');
970 else
971 cssStyle_date = "";
972
973 if (widget.preferenceForKey('cssStyle_today'))
974 cssStyle_today = widget.preferenceForKey('cssStyle_today');
975 else
976 cssStyle_today = "color:#ff0000";
977
978 if (widget.preferenceForKey('cssStyle_tomorrow'))
979 cssStyle_tomorrow = widget.preferenceForKey('cssStyle_tomorrow');
980 else
981 cssStyle_tomorrow = "color:#0000ff";
982
983 if (widget.preferenceForKey('cssStyle_time'))
984 cssStyle_time = widget.preferenceForKey('cssStyle_time');
985 else
986 cssStyle_time = "";
987
988 if (widget.preferenceForKey('cssStyle_now'))
989 cssStyle_now = widget.preferenceForKey('cssStyle_now');
990 else
991 cssStyle_now = "color:#ff00ff";
992
993 if (widget.preferenceForKey('cssStyle_description'))
994 cssStyle_description = widget.preferenceForKey('cssStyle_description');
995 else
996 cssStyle_description = "";
997
998 if (widget.preferenceForKey('cssStyle_icon'))
999 cssStyle_icon = widget.preferenceForKey('cssStyle_icon');
1000 else
1001 cssStyle_icon = "width:15px; height:15px";
1002 }
1003
1004 function saveSettings()
1005 {
1006 widget.setPreferenceForKey(monthRange.toString(), 'monthRange');
1007 widget.setPreferenceForKey(includeTodos ? 'true' : 'false', 'includeTodos');
1008 widget.setPreferenceForKey(useBackgroundImage ? 'true' : 'false', 'useBackgroundImage');
1009 widget.setPreferenceForKey(showCombinedDateTime ? 'true' : 'false', 'showCombinedDateTime');
1010 widget.setPreferenceForKey(showLocation ? 'true' : 'false', 'showLocation');
1011 widget.setPreferenceForKey(showTodayAsText ? 'true' : 'false', 'showTodayAsText');
1012 widget.setPreferenceForKey(todayText, 'todayText');
1013 widget.setPreferenceForKey(tomorrowText, 'tomorrowText');
1014 widget.setPreferenceForKey(showNowAsText ? 'true' : 'false', 'showNowAsText');
1015 widget.setPreferenceForKey(nowText, 'nowText');
1016 widget.setPreferenceForKey(dateSeparator, 'dateSeparator');
1017 widget.setPreferenceForKey(dateFormat, 'dateFormat');
1018 widget.setPreferenceForKey(weekDayLength.toString(), 'weekDayLength');
1019 widget.setPreferenceForKey(updateDataInterval.toString(), 'updateDataInterval');
1020 widget.setPreferenceForKey(calendarApp.toString(), 'calendarApp');
1021 widget.setPreferenceForKey(eventsPerWidget.toString(), 'eventsPerWidget');
1022 widget.setPreferenceForKey(showNothingText ? 'true' : 'false', 'showNothingText');
1023 widget.setPreferenceForKey(nothingText, 'nothingText');
1024 widget.setPreferenceForKey(enableDaylightSaving ? 'true' : 'false', 'enableDaylightSaving');
1025
1026 widget.setPreferenceForKey(cssStyle_background, 'cssStyle_background');
1027 widget.setPreferenceForKey(cssStyle_backgroundFullscreen, 'cssStyle_backgroundFullscreen');
1028 widget.setPreferenceForKey(cssStyle_weekDay, 'cssStyle_weekDay');
1029 widget.setPreferenceForKey(cssStyle_date, 'cssStyle_date');
1030 widget.setPreferenceForKey(cssStyle_today, 'cssStyle_today');
1031 widget.setPreferenceForKey(cssStyle_tomorrow, 'cssStyle_tomorrow');
1032 widget.setPreferenceForKey(cssStyle_time, 'cssStyle_time');
1033 widget.setPreferenceForKey(cssStyle_now, 'cssStyle_now');
1034 widget.setPreferenceForKey(cssStyle_description, 'cssStyle_description');
1035 widget.setPreferenceForKey(cssStyle_icon, 'cssStyle_icon');
1036 }
1037
1038 function toggleVisibility(elementId)
1039 {
1040 if (document.getElementById(elementId).style.display == "none")
1041 document.getElementById(elementId).style.display = "block";
1042 else
1043 document.getElementById(elementId).style.display = "none";
1044 }
1045
1046 var uniqueId = 0;
1047 function printHintBox(text)
1048 {
1049 uniqueId++;
1050 return '<td width="1%" align="right" onclick="javascript:toggleVisibility(\'info' + uniqueId + '\')">Help</td></tr></table>'+
1051 '<div class="settingsInfo" id="info' + uniqueId + '">' + text + '</div>';
1052 }
1053
1054 function showAbout()
1055 {
1056 mode = 3;
1057 document.getElementById("homescreenView").style.display = "none";
1058 document.getElementById("fullscreenView").style.display = "none";
1059 document.getElementById("aboutView").style.display = "block";
1060 document.getElementById("settingsView").style.display = "none";
1061
1062 window.menu.setLeftSoftkeyLabel(" ", function(){});
1063 window.menu.setRightSoftkeyLabel("Back", function()
1064 {
1065 mode = 1;
1066 showFullscreen();
1067 });
1068
1069 //document.getElementById("aboutView").innerHTML = 'aboutView';
1070 document.getElementById("name").innerHTML = "Coming Next " + version;
1071 }
1072
1073 function updateFullscreen()
1074 {
1075 }
1076
1077 function showFullscreen()
1078 {
1079 document.getElementById("homescreenView").style.display = "none";
1080 document.getElementById("fullscreenView").style.display = "block";
1081 document.getElementById("aboutView").style.display = "none";
1082 document.getElementById("settingsView").style.display = "none";
1083 document.getElementById('body').className = "backgroundFullscreen";
1084 createMenu();
1085 updateData();
1086 }
1087
1088 function updateHomescreen()
1089 {
1090 if (useBackgroundImage) {
1091 // check for screen rotation
1092 if (orientation != 'portrait' && screen.width == 360 && screen.height == 640) {
1093 window.widget.prepareForTransition("fade");
1094 orientation = 'portrait';
1095 document.getElementById('body').style.backgroundImage = 'url(background_' + orientation + '.png)';
1096 document.getElementById('body').style.backgroundColor = 'none';
1097 window.widget.performTransition();
1098 } else if (orientation != 'landscape' && screen.width == 640 && screen.height == 360) {
1099 window.widget.prepareForTransition("fade");
1100 orientation = 'landscape';
1101 document.getElementById('body').style.backgroundImage = 'url(background_' + orientation + '.png)';
1102 document.getElementById('body').style.backgroundColor = 'none';
1103 window.widget.performTransition();
1104 }
1105 else if (document.getElementById('body').style.backgroundImage == "")
1106 {
1107 document.getElementById('body').style.backgroundImage = 'url(background_' + orientation + '.png)';
1108 }
1109 }
1110 }
1111
1112 function showHomescreen()
1113 {
1114 document.getElementById("homescreenView").style.display = "block";
1115 document.getElementById("fullscreenView").style.display = "none";
1116 document.getElementById("aboutView").style.display = "none";
1117 document.getElementById("settingsView").style.display = "none";
1118 document.getElementById('body').className = "background";
1119 updateData();
1120 }
1121
1122 </script>
1123
1124 <style type="text/css">
1125 table { margin:0px; padding:0px; border-spacing:0px; }
1126 td { padding:0px 5px 0px 0px; white-space:nowrap; overflow:hidden; }
1127 hr { color:#ffffff; background-color:#ffffff; height:1px; text-align:left; border-style:none; }
1128 .settingsInfo { display:none; font-style:italic; }
1129 .title { font-weight:bold; font-size:14pt; }
1130 .textInput { width:90%; }
1131 #homescreenView { width: 315px; height:91px; overflow:hidden; }
1132 #calendarList { position:absolute; left:10px; top:4px; width:295px; height:75px; overflow:hidden; }
1133 #name { text-align:center; }
1134 #appicon { display: block; margin-left: auto; margin-right: auto; margin-top: 50px; }
1135 #smallappicon { width:22px; height:22px; margin-right:10px; float:left; }
1136 </style>
1137
1138 </head>
1139
1140 <body id="body" class="background">
1141 <div id="homescreenView">
1142 <div id="calendarList"></div>
1143 </div>
1144 <div id="fullscreenView" style="display:none">
1145 <img src="Icon.png" id="smallappicon" onClick="javascript:launchCalendar()">
1146 <h1 class="title" onClick="javascript:launchCalendar()">Coming Next</h1>
1147 <hr />
1148 <div id="fullscreenCalendarList">loading...</div>
1149 </div>
1150 <div id="settingsView" style="display:none">
1151 <img src="Icon.png" id="smallappicon">
1152 <h1 class="title">Settings</h1>
1153 <hr />
1154 <div id="settingsList"></div>
1155 </div>
1156 <div id="aboutView" style="display:none">
1157 <img src="Icon.png" id="appicon">
1158 <h1 id="name">Coming Next</h1>
1159 <hr />
1160 <p>Created by Dr. Cochambre and Michael Prager.</p>
1161 <p>This software is open source and licensed under the GPLv3.</p>
1162 <p>Visit https://sourceforge.net/projects/comingnext/ for free updates.</p>
1163 <hr />
1164 </div>
1165 </body>
1166
1167 </html>