]> code.delx.au - comingnext/commitdiff
* code cleanup: settings are stored as an object. This allows to dynamically generate...
authorMichael Prager <michael@pragers.de>
Mon, 21 Dec 2009 00:34:34 +0000 (01:34 +0100)
committerMichael Prager <michael@pragers.de>
Mon, 21 Dec 2009 00:34:34 +0000 (01:34 +0100)
* increased update interval for screen rotation detection from 3 to 1 secs

comingNext/index.html
comingNextB/index.html

index 1c6c2e9a5ec5fa7efd9083fe04480dbef093a847..668867eff6db9c93a388571d6b8bc511e3a19100 100644 (file)
 <title>Coming Next</title>\r
 \r
 <style type="text/css">\r
-.background { color:#ffffff; background-color:#000000 } /* Defines the background of the widget. If you want to use a background image, set useBackgroundImage = true below */\r
-                                       /* for the default themes, black, gray, and light blue, codes are #292029, #e7dfe7, #009aef */\r
-.backgroundFullscreen { color:#ffffff; background-color:#000000 } /* Same as background but for the fullscreen version of the widget */\r
-.weekDay { }                           /* Defines the appearance of all week day texts */\r
-.date { }                              /* Defines the appearance of all date texts */\r
-.today { color:#ff0000; }              /* Defines the appearance of "Today" text */\r
-.tomorrow { color:#0000ff; }           /* Defines the appearance of "Tomorrow" text */\r
-.time { }                              /* Defines the appearance of all time texts */\r
-.now { color:#ff00ff; }                        /* Defines the appearance of "Now" text */\r
-.description { }                       /* Defines the appearance of all event descriptions */\r
-.icon { width:15px; height:15px; }     /* Defines size and appearance of icons */\r
+/* The following classes can be modified by widget settings */\r
+.background { }\r
+.backgroundFullscreen { }\r
+.weekDay { }\r
+.date { }\r
+.today { }\r
+.tomorrow { }\r
+.time { }\r
+.now { }\r
+.description { }\r
+.icon { }\r
 </style>\r
 \r
 <script>\r
-var monthRange = 2;            // number of months to include in the event list\r
-var includeTodos = true;       // disable to remove ToDos from event list\r
-var useBackgroundImage = true; // use background_portrait.png and background_landscape.png to fake transparency. Set to "false" to use a solid background color\r
-var showCombinedDateTime = false;// only show the time for events happening today, otherwise just show the date\r
-var showLocation = true;       // show the location for meeting events\r
-var showTodayAsText = true;    // if enabled, the current date will be shown as "Today" instead of "31.12"\r
-var todayText = 'Today';       // text to display for "Today"\r
-var tomorrowText = 'Tomorrow'; // text to display for "Tomorrow"\r
-var showNowAsText = true;      // if enabled, the appointment time will be shown as "Now" instead of "12:00"\r
-var nowText = 'Now';           // text to display for "Now"\r
-var dateSeparator = '.';       // separator for dates. e.g. "31.12" or "31/12"\r
-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\r
-var weekDayLength = 2;         // defines how many characters of the weekday will be shown. E.g. 2 will cut "Friday" to "Fr"\r
-var updateDataInterval = 5;    // how many minutes to wait before updating the displayed data. The higher the number, the less battery is used\r
-var calendarApp = 0x10005901;  // UID of the calendar app to run when clicking the widget. 0x10005901 = buildin calendar, 0x20004ec1 = Epocware Handy Calendar\r
-var eventsPerWidget = 4;       // number of events to show per widget. Default is 4\r
-var showNothingText = true;    // if set to "true", show a text if no events are in the list\r
-var nothingText = 'No further events within ' + monthRange + ' months';                // text to show when no events are in the list\r
-var enableDaylightSaving = true;// enable this if you are in a timezone that has daylight saving time (+1h)\r
-\r
-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\r
-var cssStyle_backgroundFullscreen = "color:#ffffff; background-color:#000000"; // Same as background but for the fullscreen version of the widget\r
-var cssStyle_weekDay = "";                     // Defines the appearance of all week day texts\r
-var cssStyle_date = "";                                // Defines the appearance of all date texts\r
-var cssStyle_today = "color:#ff0000";          // Defines the appearance of "Today" text\r
-var cssStyle_tomorrow = "color:#0000ff";       // Defines the appearance of "Tomorrow" text\r
-var cssStyle_time = "";                                // Defines the appearance of all time texts\r
-var cssStyle_now = "color:#ff00ff";            // Defines the appearance of "Now" text\r
-var cssStyle_description = "";                 // Defines the appearance of all event descriptions\r
-var cssStyle_icon = "width:15px; height:15px"; // Defines size and appearance of icons\r
+// valid types for the config object are 'Int', 'Bool', 'String', 'Enum', 'UID'\r
+var config = {\r
+monthRange: {\r
+       Type: 'Int',\r
+       Default: 2,\r
+       Value: 2,\r
+       Name: 'Month Range',\r
+       Info: 'number of months to include in the event list',},\r
+includeTodos: {\r
+       Type: 'Bool',\r
+       Default: true,\r
+       Value: true,\r
+       Name: 'Include ToDos',\r
+       Info: 'disable to remove ToDos from event list',},\r
+useBackgroundImage: {\r
+       Type: 'Bool',\r
+       Default: true,\r
+       Value: true,\r
+       Name: 'Use Background Image',\r
+       Info: 'use background_portrait.png and background_landscape.png to fake transparency. Disable to use a solid background color',},\r
+showCombinedDateTime: {\r
+       Type: 'Bool',\r
+       Default: false,\r
+       Value: false,\r
+       Name: 'Show Combined Date/Time',\r
+       Info: 'only show the time for events happening today, otherwise just show the date',},\r
+showLocation: {\r
+       Type: 'Bool',\r
+       Default: true,\r
+       Value: true,\r
+       Name: 'Show Location',\r
+       Info: 'show the location for meeting events',},\r
+showTodayAsText: {\r
+       Type: 'Bool',\r
+       Default: true,\r
+       Value: true,\r
+       Name: 'Show Today as Text',\r
+       Info: 'if enabled, the current date will be shown as "Today" instead of "31.12"',},\r
+todayText: {\r
+       Type: 'String',\r
+       Default: 'Today',\r
+       Value: 'Today',\r
+       Name: '"Today" Text',\r
+       Info: 'text to display for "Today"',},\r
+tomorrowText: {\r
+       Type: 'String',\r
+       Default: 'Tomorrow',\r
+       Value: 'Tomorrow',\r
+       Name: '"Tomorrow" Text',\r
+       Info: 'text to display for "Tomorrow"',},\r
+showNowAsText: {\r
+       Type: 'Bool',\r
+       Default: true,\r
+       Value: true,\r
+       Name: 'Show Now as Text',\r
+       Info: 'if enabled, the appointment time will be shown as "Now" instead of "12:00"',},\r
+nowText: {\r
+       Type: 'String',\r
+       Default: 'Now',\r
+       Value: 'Now',\r
+       Name: '"Now" Text',\r
+       Info: 'text to display for "Now"',},\r
+dateSeparator: {\r
+       Type: 'String',\r
+       Default: '.',\r
+       Value: '.',\r
+       Name: 'Date Separator',\r
+       Info: 'separator for dates. e.g. "31.12" or "31/12"',},\r
+dateFormat: {\r
+       Type: 'Enum',\r
+       Default: 'auto',\r
+       Value: 'auto',\r
+       ValidValues: ['auto', 'DDMM', 'MMDD'],\r
+       Name: 'Date Format',\r
+       Info: 'how dates will be displayed. \'auto\' will autodetect your phone\'s date format setting. \'MMDD\' will write month first, \'DDMM\' will write day first',},\r
+weekDayLength: {\r
+       Type: 'Int',\r
+       Default: 2,\r
+       Value: 2,\r
+       Name: 'Weekday Length',\r
+       Info: 'defines how many characters of the weekday will be shown. E.g. 2 will cut "Friday" to "Fr"',},\r
+updateDataInterval: {\r
+       Type: 'Int',\r
+       Default: 5,\r
+       Value: 5,\r
+       Name: 'Update Data Interval',\r
+       Info: 'how many minutes to wait before updating the displayed data. The higher the number, the less battery is used',},\r
+calendarApp: {\r
+       Type: 'UID',\r
+       Default: 0x10005901,\r
+       Value: 0x10005901,\r
+       Name: 'Calendar Application To Run',\r
+       Info: 'UID of the calendar app to run when clicking the widget. 0x10005901 = buildin calendar, 0x20004ec1 = Epocware Handy Calendar',},\r
+eventsPerWidget: {\r
+       Type: 'Int',\r
+       Default: 4,\r
+       Value: 4,\r
+       Name: 'Events Per Widget',\r
+       Info: 'number of events to show per widget. Default is 4',},\r
+showNothingText: {\r
+       Type: 'Bool',\r
+       Default: true,\r
+       Value: true,\r
+       Name: 'Show "Nothing" Text',\r
+       Info: 'if enabled, show a text if no events are in the list',},\r
+nothingText: {\r
+       Type: 'String',\r
+       Default: 'No further events within 2 months',\r
+       Value: 'No further events within 2 months',\r
+       Name: '"No further events..." Text',\r
+       Info: 'text to show when no events are in the list',},\r
+enableDaylightSaving: {\r
+       Type: 'Bool',\r
+       Default: true,\r
+       Value: true,\r
+       Name: 'Enable Daylight Saving (+1h)',\r
+       Info: 'enable this if you are in a timezone that has daylight saving time (+1h)',},\r
+cssStyle_background: {\r
+       Type: 'String',\r
+       Default: 'color:#ffffff; background-color:#000000',\r
+       Value: 'color:#ffffff; background-color:#000000',\r
+       Name: '.background',\r
+       Info: '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',},\r
+cssStyle_backgroundFullscreen: {\r
+       Type: 'String',\r
+       Default: 'color:#ffffff; background-color:#000000',\r
+       Value: 'color:#ffffff; background-color:#000000',\r
+       Name: '.backgroundFullscreen',\r
+       Info: 'Same as background but for the fullscreen version of the widget',},\r
+cssStyle_weekDay: {\r
+       Type: 'String',\r
+       Default: '',\r
+       Value: '',\r
+       Name: '.weekDay',\r
+       Info: 'Defines the appearance of all week day texts',},\r
+cssStyle_date: {\r
+       Type: 'String',\r
+       Default: '',\r
+       Value: '',\r
+       Name: '.date',\r
+       Info: 'Defines the appearance of all date texts',},\r
+cssStyle_today: {\r
+       Type: 'String',\r
+       Default: 'color:#ff0000',\r
+       Value: 'color:#ff0000',\r
+       Name: '.today',\r
+       Info: 'Defines the appearance of "Today" text',},\r
+cssStyle_tomorrow: {\r
+       Type: 'String',\r
+       Default: 'color:#0000ff',\r
+       Value: 'color:#0000ff',\r
+       Name: '.tomorrow',\r
+       Info: 'Defines the appearance of "Tomorrow" text',},\r
+cssStyle_time: {\r
+       Type: 'String',\r
+       Default: '',\r
+       Value: '',\r
+       Name: '.time',\r
+       Info: 'Defines the appearance of all time texts',},\r
+cssStyle_now: {\r
+       Type: 'String',\r
+       Default: 'color:#ff00ff',\r
+       Value: 'color:#ff00ff',\r
+       Name: '.now',\r
+       Info: 'Defines the appearance of "Now" text',},\r
+cssStyle_description: {\r
+       Type: 'String',\r
+       Default: '',\r
+       Value: '',\r
+       Name: '.description',\r
+       Info: 'Defines the appearance of all event descriptions',},\r
+cssStyle_icon: {\r
+       Type: 'String',\r
+       Default: 'width:15px; height:15px',\r
+       Value: 'width:15px; height:15px',\r
+       Name: '.icon',\r
+       Info: 'Defines size and appearance of icons',},\r
+}\r
 \r
 //-------------------------------------------------------\r
 // Nothing of interest from here on...\r
@@ -329,7 +477,7 @@ function parseDate(dateString)
        console.info('year=' + year + ' month=' + month + ' day=' + day + ' hours=' + hours + ' minutes=' + minutes+ ' seconds=' + seconds);\r
 \r
        // take care of daylight saving time\r
-       if (enableDaylightSaving) {\r
+       if (config['enableDaylightSaving'].Value) {\r
                var date = new Date(year, month - 1, day, hours, minutes, seconds);\r
                if (summertime && date > daylightsavingWinter && date < daylightsavingSummer)\r
                        hours -= 1;\r
@@ -348,27 +496,27 @@ function formatDate(date, format)
        while (day.length < 2) { day = '0' + day; }\r
        while (month.length < 2) { month = '0' + month; }\r
 \r
-       if (showTodayAsText && isToday(date))\r
-               return '<span class="today">' + todayText + '</span>';\r
-       if (showTodayAsText && isTomorrow(date))\r
-               return '<span class="tomorrow">' + tomorrowText + '</span>';\r
+       if (config['showTodayAsText'].Value && isToday(date))\r
+               return '<span class="today">' + config['todayText'].Value + '</span>';\r
+       if (config['showTodayAsText'].Value && isTomorrow(date))\r
+               return '<span class="tomorrow">' + config['tomorrowText'].Value + '</span>';\r
 \r
        var dateArr = format.replace(/,/g,'').replace(/\./g,':').replace(/  /g,' ').split(' ');\r
        if (dateArr.length != 5 && dateArr.length != 6) {\r
                // we don't know how to format this\r
-               if (dateFormat == 'auto' || dateFormat == 'DDMM')\r
-                       return day + dateSeparator + month;\r
+               if (config['dateFormat'].Value == 'auto' || config['dateFormat'].Value == 'DDMM')\r
+                       return day + config['dateSeparator'].Value + month;\r
                else\r
-                       return month + dateSeparator + day;\r
+                       return month + config['dateSeparator'].Value + day;\r
        }\r
 \r
        var dayFirst = true;\r
-       if (dateFormat == 'MMDD')\r
+       if (config['dateFormat'].Value == 'MMDD')\r
                dayFirst = false;\r
-       else if (dateFormat == 'DDMM')\r
+       else if (config['dateFormat'].Value == 'DDMM')\r
                dayFirst = true;\r
        else {\r
-               // dateFormat == 'auto', try to detect system setting\r
+               // config['dateFormat'].Value == 'auto', try to detect system setting\r
                // parse date\r
                var day_ = dateArr[1];\r
                var month_ = dateArr[2];\r
@@ -391,9 +539,9 @@ function formatDate(date, format)
        }\r
 \r
        if (dayFirst)\r
-               return day + dateSeparator + month;\r
+               return day + config['dateSeparator'].Value + month;\r
        else\r
-               return month + dateSeparator + day;\r
+               return month + config['dateSeparator'].Value + day;\r
 }\r
 \r
 function formatTime(date)\r
@@ -403,8 +551,8 @@ function formatTime(date)
        var time = date.toLocaleTimeString().replace(/[\.:]00/, ''); // remove seconds from string\r
        if (time.replace(/\./, ':').split(':')[0].length < 2)\r
                time = '0' + time;\r
-       if (showNowAsText && date.getTime() == now.getTime())\r
-               time = '<span class="now">' + nowText + '</span>';\r
+       if (config['showNowAsText'].Value && date.getTime() == now.getTime())\r
+               time = '<span class="now">' + config['nowText'].Value + '</span>';\r
        return time;\r
 }\r
 \r
@@ -419,7 +567,7 @@ function updateData()
                        Type:'CalendarEntry',\r
                        Filter:{\r
                                StartRange: (new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0)),\r
-                               EndRange: (new Date(now.getFullYear(), now.getMonth() + monthRange, now.getDate(), 0, 0, 0))\r
+                               EndRange: (new Date(now.getFullYear(), now.getMonth() + config['monthRange'].Value, now.getDate(), 0, 0, 0))\r
                        }\r
                }\r
                var meetingResult = calendarService.IDataSource.GetList(meetingListFiltering);\r
@@ -427,7 +575,7 @@ function updateData()
 \r
                // todos don't, they start on 00:00 hrs., but should be visible anyway\r
                // this will generate a list of passed todos. We have to check if they have been marked as "done" yet\r
-               if (includeTodos) {\r
+               if (config['includeTodos'].Value) {\r
                        var todayTodoListFiltering = {\r
                                Type:'CalendarEntry',\r
                                Filter:{\r
@@ -456,7 +604,7 @@ function updateData()
                var eventIds = [];\r
                var max;\r
                if (mode == 0)\r
-                       max = ((panelNum == 0) ? eventsPerWidget : 2 * eventsPerWidget);\r
+                       max = ((panelNum == 0) ? config['eventsPerWidget'].Value : 2 * config['eventsPerWidget'].Value);\r
                else\r
                        max = 30; // we can display a lot more events in fullscreen mode\r
 \r
@@ -479,7 +627,7 @@ function updateData()
                                );\r
 \r
                                // we don't want ToDos when includeTodos == false or when they are completed\r
-                               if (entry.Type == 'ToDo' && (entry.Status == "TodoCompleted" || !includeTodos)) {\r
+                               if (entry.Type == 'ToDo' && (entry.Status == "TodoCompleted" || !config['includeTodos'].Value)) {\r
                                        console.info('skipping ' + entry.id );\r
                                        counter--;\r
                                        continue;\r
@@ -495,7 +643,7 @@ function updateData()
 \r
                                // summary can be undefined!\r
                                var Summary = ((entry.Summary == null) ? '' : entry.Summary);\r
-                               if (entry.Type == 'Meeting' && entry.Location != '' && showLocation)\r
+                               if (entry.Type == 'Meeting' && entry.Location != '' && config['showLocation'].Value)\r
                                        Summary += ', ' + entry.Location;\r
                                \r
                                // fix by yves: determine start and end dates/times\r
@@ -558,7 +706,7 @@ function updateData()
                                }\r
 \r
                                // skip events for the first panel in case this is the second one and we're not in fullscreen mode\r
-                               if (mode == 0 && panelNum == 1 && counter < eventsPerWidget + 1) {\r
+                               if (mode == 0 && panelNum == 1 && counter < config['eventsPerWidget'].Value + 1) {\r
                                        console.info('skipping (already in first widget) ' + entry.id);\r
                                        continue;\r
                                }\r
@@ -569,16 +717,16 @@ function updateData()
                                        // some languages have very strange locale date formats, can't parse all those. Also some todos don't have dates at all.\r
                                        entriesHtml += '<td colspan="4"><span class="date">' + entryDate + '</span> ';\r
                                } else {\r
-                                       var weekDay = date.toLocaleDateString().substr(0,weekDayLength);\r
+                                       var weekDay = date.toLocaleDateString().substr(0,config['weekDayLength'].Value);\r
                                        var time = formatTime(date);\r
                                        var dateStr = formatDate(date, entryDate);\r
                                        if (entry.Type == 'ToDo' || entry.Type == 'Anniversary' || entry.Type == 'DayEvent' || entry.Type == 'Reminder') {\r
-                                               if ((isToday(date) || isTomorrow(date)) && showTodayAsText) // show weekday if the date string is not text. looks odd otherwise\r
+                                               if ((isToday(date) || isTomorrow(date)) && config['showTodayAsText'].Value) // show weekday if the date string is not text. looks odd otherwise\r
                                                        entriesHtml += '<td colspan="4" width="1px"><span class="date">' + dateStr + '</span> ';\r
                                                else\r
                                                        entriesHtml += '<td class="weekDay" width="1px">' + weekDay + '</td><td width="1px" class="date">' + dateStr + '</td><td colspan="2">';\r
                                        } else if (entry.Type == 'Meeting') {\r
-                                               if (showCombinedDateTime) {\r
+                                               if (config['showCombinedDateTime'].Value) {\r
                                                        if (isToday(date))\r
                                                                entriesHtml += '<td width="1px" colspan="4"><span class="today">' + time + '</span> ';\r
                                                        else if (isTomorrow(date))\r
@@ -586,7 +734,7 @@ function updateData()
                                                        else\r
                                                                entriesHtml += '<td width="1px" class="weekDay">' + weekDay + '</td><td width="1px" class="date">' + dateStr + '</td><td colspan="2">';\r
                                                } else {\r
-                                                       if ((isToday(date) || isTomorrow(date)) && showTodayAsText)\r
+                                                       if ((isToday(date) || isTomorrow(date)) && config['showTodayAsText'].Value)\r
                                                                entriesHtml += '<td colspan="4" width="1px"><span class="today">' + dateStr + '</span> <span class="time">' + time + '</span> ';\r
                                                        else\r
                                                                entriesHtml += '<td width="1px" class="weekDay">' + weekDay + '</td><td width="1px" class="date">' + dateStr + '</td><td width="1px" class="time">' + time + '</td><td>';\r
@@ -597,8 +745,8 @@ function updateData()
                        }\r
                }\r
                entriesHtml += '</table>';\r
-               if (showNothingText && entriesHtml == '<table></table>')\r
-                       entriesHtml = '<div style="width:295px; height:75px; text-align:center; line-height:75px; overflow:visible;">' + nothingText + '</div>';\r
+               if (config['showNothingText'].Value && entriesHtml == '<table></table>')\r
+                       entriesHtml = '<div style="width:295px; height:75px; text-align:center; line-height:75px; overflow:visible;">' + config['nothingText'].Value + '</div>';\r
                if (cacheEntriesHtml != entriesHtml) {\r
                        if (mode == 0)\r
                                document.getElementById('calendarList').innerHTML = entriesHtml;\r
@@ -636,7 +784,7 @@ function updateScreen()
 function launchCalendar()\r
 {\r
        try {\r
-               widget.openApplication(calendarApp, "");\r
+               widget.openApplication(config['calendarApp'].Value, "");\r
                //window.close();\r
        } catch(e) {\r
                error('starting Calendar App');\r
@@ -659,14 +807,14 @@ function init()
        collectLocales();\r
        //updateData();\r
        requestNotification();\r
-       window.setInterval('updateData()', 1000 * 60 * updateDataInterval);\r
+       window.setInterval('updateData()', 1000 * 60 * config['updateDataInterval'].Value);\r
 \r
        mode = 0;\r
        showHomescreen();\r
        updateScreen();\r
-       if (useBackgroundImage)\r
-               // check for screen rotation every 3 secs\r
-               window.setInterval('updateScreen()', 1000 * 3);\r
+       if (config['useBackgroundImage'].Value)\r
+               // check for screen rotation every 1 secs\r
+               window.setInterval('updateScreen()', 1000 * 1);\r
 }\r
 \r
 function createMenu()\r
@@ -697,47 +845,24 @@ function showSettings()
        \r
        window.menu.setLeftSoftkeyLabel("Save", function()\r
        {\r
-               //document.forms[0].elements["settings.monthRange"].value = monthRange;\r
-               monthRange = parseInt(document.forms[0].elements["settings.monthRange"].value);\r
-               if (monthRange < 0 || monthRange > 100)\r
-                       monthRange = 2;\r
-               includeTodos = document.forms[0].elements["settings.includeTodos"].checked;\r
-               useBackgroundImage = document.forms[0].elements["settings.useBackgroundImage"].checked;\r
-               showCombinedDateTime = document.forms[0].elements["settings.showCombinedDateTime"].checked;\r
-               showLocation = document.forms[0].elements["settings.showLocation"].checked;\r
-               showTodayAsText = document.forms[0].elements["settings.showTodayAsText"].checked;\r
-               todayText = document.forms[0].elements["settings.todayText"].value;\r
-               tomorrowText = document.forms[0].elements["settings.tomorrowText"].value;\r
-               showNowAsText = document.forms[0].elements["settings.showNowAsText"].checked;\r
-               nowText = document.forms[0].elements["settings.nowText"].value;\r
-               dateSeparator = document.forms[0].elements["settings.dateSeparator"].value;\r
-               dateFormat = document.forms[0].elements["settings.dateFormat"].value;\r
-               if (dateFormat != 'auto' && dateFormat != 'DDMM' && dateFormat != 'MMDD')\r
-                       dateFormat = 'auto';\r
-               weekDayLength = Number(parseInt(document.forms[0].elements["settings.weekDayLength"].value));\r
-               if (weekDayLength < 0 || weekDayLength > 20)\r
-                       weekDayLength = 2;\r
-               updateDataInterval = parseInt(document.forms[0].elements["settings.updateDataInterval"].value);\r
-               if (updateDataInterval < 1 || updateDataInterval > 1000)\r
-                       updateDataInterval = 5;\r
-               calendarApp = parseInt(document.forms[0].elements["settings.calendarApp"].value);\r
-               eventsPerWidget = parseInt(document.forms[0].elements["settings.eventsPerWidget"].value);\r
-               if (eventsPerWidget < 1 || eventsPerWidget > 10)\r
-                       eventsPerWidget = 4;\r
-               showNothingText = document.forms[0].elements["settings.showNothingText"].checked;\r
-               nothingText = document.forms[0].elements["settings.nothingText"].value;\r
-               enableDaylightSaving = document.forms[0].elements["settings.enableDaylightSaving"].checked;\r
-               \r
-               cssStyle_background = document.forms[0].elements["settings.cssStyle_background"].value;\r
-               cssStyle_backgroundFullscreen = document.forms[0].elements["settings.cssStyle_backgroundFullscreen"].value;\r
-               cssStyle_weekDay = document.forms[0].elements["settings.cssStyle_weekDay"].value;\r
-               cssStyle_date = document.forms[0].elements["settings.cssStyle_date"].value;\r
-               cssStyle_today = document.forms[0].elements["settings.cssStyle_today"].value;\r
-               cssStyle_tomorrow = document.forms[0].elements["settings.cssStyle_tomorrow"].value;\r
-               cssStyle_time = document.forms[0].elements["settings.cssStyle_time"].value;\r
-               cssStyle_now = document.forms[0].elements["settings.cssStyle_now"].value;\r
-               cssStyle_description = document.forms[0].elements["settings.cssStyle_description"].value;\r
-               cssStyle_icon = document.forms[0].elements["settings.cssStyle_icon"].value;\r
+               for (var key in config) {\r
+                       if (config[key].Type == 'String')\r
+                               config[key].Value = document.forms[0].elements["settings." + key].value;\r
+                       else if (config[key].Type == 'Int') {\r
+                               config[key].Value = parseInt(document.forms[0].elements["settings." + key].value);\r
+                               if (config[key].Value < 0)\r
+                                       config[key].Value = config[key].Default;\r
+                       }\r
+                       else if (config[key].Type == 'Bool')\r
+                               config[key].Value = document.forms[0].elements["settings." + key].checked;\r
+                       else if (config[key].Type == 'UID')\r
+                               config[key].Value = parseInt(document.forms[0].elements["settings." + key].value);\r
+                       else if (config[key].Type == 'Enum') {\r
+                               config[key].Value = document.forms[0].elements["settings." + key].value;\r
+                               if (config[key].ValidValues.indexOf(config[key].Value) == -1)\r
+                                       config[key].Value = config[key].Default;\r
+                       }\r
+               }\r
                                \r
                updateCssClasses();\r
                \r
@@ -752,44 +877,26 @@ function showSettings()
                showFullscreen();\r
        });\r
        \r
-       document.getElementById("settingsList").innerHTML = \r
-       '<form>' +\r
-       '<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') +\r
-       '<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') +\r
-       '<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') +\r
-       '<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') +\r
-       '<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') +\r
-       '<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"') +\r
-       '<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>' +\r
-       '<hr><table><tr><td>"Tomorrow" Text:<br><input class="textInput" name="settings.tomorrowText" type="text" value="' + tomorrowText + '" /></td>' + printHintBox('text to display for "Tomorrow"') +\r
-       '<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"') +\r
-       '<hr><table><tr><td>"Now" Text:<br><input class="textInput" name="settings.nowText" type="text" value="' + nowText + '" /></td>' + printHintBox('text to display for "Now"') +\r
-       '<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"') +\r
-       '<hr><table><tr><td>Date Format:<br><select name="settings.dateFormat" size="1">' + \r
-               '<option label="auto detect"' + (dateFormat == 'auto' ? ' selected="selected"' : '') + '>auto</option>' +\r
-               '<option label="MMDD"' + (dateFormat == 'MMDD' ? ' selected="selected"' : '') + '>MMDD</option>' +\r
-               '<option label="DDMM"' + (dateFormat == 'DDMM' ? ' selected="selected"' : '') + '>DDMM</option>' +\r
-               '</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>' +\r
-       '<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"') +\r
-       '<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') +\r
-       '<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') +\r
-       '<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') +\r
-       '<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') +\r
-       '<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') +\r
-       '<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)') +\r
-       '<hr style="margin-bottom:60px;"><h1 class="title">CSS Styles</h1>' +\r
-       '<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') +\r
-       '<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') +\r
-       '<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') +\r
-       '<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') +\r
-       '<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') +\r
-       '<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') +\r
-       '<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') +\r
-       '<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') +\r
-       '<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') +\r
-       '<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') +\r
-       '<hr style="margin-bottom:60px;"><input name="reset" type="button" value="Restore Defaults" onclick="javascript:restoreDefaultSettings();showSettings();" />' +\r
-       '</form>';\r
+       var settingsHtml = '<form>';\r
+       for (var key in config) {\r
+               if (config[key].Type == 'String')\r
+                       settingsHtml += '<table><tr><td>' + config[key].Name + '<br /><input class="textInput" name="settings.' + key + '" type="text" value="' + config[key].Value + '" /></td>' + printHintBox(config[key].Info) + '<hr />';\r
+               else if (config[key].Type == 'Int')\r
+                       settingsHtml += '<table><tr><td>' + config[key].Name + '<br /><input class="textInput" name="settings.' + key + '" type="text" value="' + config[key].Value + '" /></td>' + printHintBox(config[key].Info) + '<hr />';\r
+               else if (config[key].Type == 'Bool')\r
+                       settingsHtml += '<table><tr><td>' + config[key].Name + '<br /><input name="settings.' + key + '" type="checkbox" value="true" ' + (config[key].Value ? 'checked="checked"' : '') + '/></td>' + printHintBox(config[key].Info) + '<hr />';\r
+               else if (config[key].Type == 'UID')\r
+                       settingsHtml += '<table><tr><td>' + config[key].Name + '<br /><input class="textInput" name="settings.' + key + '" type="text" value="0x' + config[key].Value.toString(16) + '" /></td>' + printHintBox(config[key].Info) + '<hr />';\r
+               else if (config[key].Type == 'Enum') {\r
+                       settingsHtml += '<table><tr><td>' + config[key].Name + '<br /><select name="settings.' + key + '" size="1">';\r
+                       for(var i = 0; i < config[key].ValidValues.length; i++)\r
+                               settingsHtml += '<option label="' + config[key].ValidValues[i] + '"' + (config[key].Value == config[key].ValidValues[i] ? ' selected="selected"' : '') + '>' + config[key].ValidValues[i] + '</option>';\r
+                       settingsHtml += '</select></div></td>' + printHintBox(config[key].Info) + '<hr />';\r
+               }\r
+       }\r
+       settingsHtml += '<input name="reset" type="button" value="Restore Defaults" onclick="javascript:restoreDefaultSettings();showSettings();" />';\r
+       settingsHtml += '</form>';\r
+       document.getElementById("settingsList").innerHTML = settingsHtml;\r
 }\r
 \r
 function changeCssClass(classname, properties)\r
@@ -806,234 +913,52 @@ function changeCssClass(classname, properties)
 \r
 function updateCssClasses()\r
 {\r
-       changeCssClass(".background", cssStyle_background);\r
-       changeCssClass(".backgroundFullscreen", cssStyle_backgroundFullscreen);\r
-       changeCssClass(".weekDay", cssStyle_weekDay);\r
-       changeCssClass(".date", cssStyle_date);\r
-       changeCssClass(".today", cssStyle_today);\r
-       changeCssClass(".tomorrow", cssStyle_tomorrow);\r
-       changeCssClass(".time", cssStyle_time);\r
-       changeCssClass(".now", cssStyle_now);\r
-       changeCssClass(".description", cssStyle_description);\r
-       changeCssClass(".icon", cssStyle_icon);\r
+       for(var key in config) {\r
+               changeCssClass(config[key].Name, config[key].Value);\r
+       }\r
 }\r
 \r
 function restoreDefaultSettings()\r
 {\r
-       monthRange = 2;\r
-       includeTodos = true;\r
-       useBackgroundImage = true;\r
-       showCombinedDateTime = false;\r
-       showLocation = true;\r
-       showTodayAsText = true;\r
-       todayText = 'Today';\r
-       tomorrowText = 'Tomorrow';\r
-       showNowAsText = true;\r
-       nowText = 'Now';\r
-       dateSeparator = '.';\r
-       dateFormat = 'auto'\r
-       weekDayLength = 2;\r
-       updateDataInterval = 5;\r
-       calendarApp = 0x10005901;\r
-       eventsPerWidget = 4;\r
-       showNothingText = true;\r
-       nothingText = 'No further events within ' + monthRange + ' months';\r
-       enableDaylightSaving = true;\r
-\r
-       cssStyle_background = "color:#ffffff; background-color:#000000";\r
-       cssStyle_backgroundFullscreen = "color:#ffffff; background-color:#000000";\r
-       cssStyle_weekDay = "";\r
-       cssStyle_date = "";\r
-       cssStyle_today = "color:#ff0000";\r
-       cssStyle_tomorrow = "color:#0000ff";\r
-       cssStyle_time = "";\r
-       cssStyle_now = "color:#ff00ff";\r
-       cssStyle_description = "";\r
-       cssStyle_icon = "width:15px; height:15px";\r
+       for (var key in config)\r
+               config[key].Value = config[key].Default;\r
 }\r
 \r
 function loadSettings()\r
 {\r
-       if (widget.preferenceForKey('monthRange'))\r
-               monthRange = Number(widget.preferenceForKey('monthRange'));\r
-       else\r
-               monthRange = 2;\r
-       \r
-       if (widget.preferenceForKey('includeTodos'))\r
-               includeTodos = (widget.preferenceForKey('includeTodos') == 'true');\r
-       else\r
-               includeTodos = true;\r
-       \r
-       if (widget.preferenceForKey('useBackgroundImage'))\r
-               useBackgroundImage = (widget.preferenceForKey('useBackgroundImage') == 'true');\r
-       else\r
-               useBackgroundImage = true;\r
-       \r
-       if (widget.preferenceForKey('showCombinedDateTime'))\r
-               showCombinedDateTime = (widget.preferenceForKey('showCombinedDateTime') == 'true');\r
-       else\r
-               showCombinedDateTime = false;\r
-       \r
-       if (widget.preferenceForKey('showLocation'))\r
-               showLocation = (widget.preferenceForKey('showLocation') == 'true');\r
-       else\r
-               showLocation = true;\r
-       \r
-       if (widget.preferenceForKey('showTodayAsText'))\r
-               showTodayAsText = (widget.preferenceForKey('showTodayAsText') == 'true');\r
-       else\r
-               showTodayAsText = true;\r
-       \r
-       if (widget.preferenceForKey('todayText'))\r
-               todayText = widget.preferenceForKey('todayText');\r
-       else\r
-               todayText = 'Today';\r
-       \r
-       if (widget.preferenceForKey('tomorrowText'))\r
-               tomorrowText = widget.preferenceForKey('tomorrowText');\r
-       else\r
-               tomorrowText = 'Tomorrow';\r
-       \r
-       if (widget.preferenceForKey('showNowAsText'))\r
-               showNowAsText = (widget.preferenceForKey('showNowAsText') == 'true');\r
-       else\r
-               showNowAsText = true;\r
-       \r
-       if (widget.preferenceForKey('nowText'))\r
-               nowText = widget.preferenceForKey('nowText');\r
-       else\r
-               nowText = 'Now';\r
-       \r
-       if (widget.preferenceForKey('dateSeparator'))\r
-               dateSeparator = widget.preferenceForKey('dateSeparator');\r
-       else\r
-               dateSeparator = '.';\r
-       \r
-       if (widget.preferenceForKey('dateFormat'))\r
-               dateFormat = widget.preferenceForKey('dateFormat');\r
-       else\r
-               dateFormat = 'auto';\r
-       \r
-       if (widget.preferenceForKey('weekDayLength'))\r
-               weekDayLength = Number(widget.preferenceForKey('weekDayLength'));\r
-       else\r
-               weekDayLength = 2;\r
-       \r
-       if (widget.preferenceForKey('updateDataInterval'))\r
-               updateDataInterval = Number(widget.preferenceForKey('updateDataInterval'));\r
-       else\r
-               updateDataInterval = 5;\r
-       \r
-       if (widget.preferenceForKey('calendarApp'))\r
-               calendarApp = Number(widget.preferenceForKey('calendarApp'));\r
-       else\r
-               calendarApp = 0x10005901;\r
-       \r
-       if (widget.preferenceForKey('eventsPerWidget'))\r
-               eventsPerWidget = Number(widget.preferenceForKey('eventsPerWidget'));\r
-       else\r
-               eventsPerWidget = 4;\r
-       \r
-       if (widget.preferenceForKey('showNothingText'))\r
-               showNothingText = (widget.preferenceForKey('showNothingText') == 'true');\r
-       else\r
-               showNothingText = true;\r
-       \r
-       if (widget.preferenceForKey('nothingText'))\r
-               nothingText = widget.preferenceForKey('nothingText');\r
-       else\r
-               nothingText = 'No further events within ' + monthRange + ' months';\r
-       \r
-       if (widget.preferenceForKey('enableDaylightSaving'))\r
-               enableDaylightSaving = (widget.preferenceForKey('enableDaylightSaving') == 'true');\r
-       else\r
-               enableDaylightSaving = true;\r
-       \r
-       // CSS styles\r
-               \r
-       if (widget.preferenceForKey('cssStyle_background'))\r
-               cssStyle_background = widget.preferenceForKey('cssStyle_background');\r
-       else\r
-               cssStyle_background = "color:#ffffff; background-color:#000000";\r
-\r
-       if (widget.preferenceForKey('cssStyle_backgroundFullscreen'))\r
-               cssStyle_backgroundFullscreen = widget.preferenceForKey('cssStyle_backgroundFullscreen');\r
-       else\r
-               cssStyle_backgroundFullscreen = "color:#ffffff; background-color:#000000";\r
-               \r
-       if (widget.preferenceForKey('cssStyle_weekDay'))\r
-               cssStyle_weekDay = widget.preferenceForKey('cssStyle_weekDay');\r
-       else\r
-               cssStyle_weekDay = "";\r
-               \r
-       if (widget.preferenceForKey('cssStyle_date'))\r
-               cssStyle_date = widget.preferenceForKey('cssStyle_date');\r
-       else\r
-               cssStyle_date = "";\r
+       for (var key in config) {\r
+               if (widget.preferenceForKey(key)) {\r
+                       if (config[key].Type == 'Int')\r
+                               config[key].Value = Number(widget.preferenceForKey(key));\r
+                       else if (config[key].Type == 'String')\r
+                               config[key].Value = widget.preferenceForKey(key);\r
+                       else if (config[key].Type == 'Bool')\r
+                               config[key].Value = (widget.preferenceForKey(key) == 'true')\r
+                       else if (config[key].Type == 'Enum')\r
+                               config[key].Value = widget.preferenceForKey(key);\r
+                       else if (config[key].Type == 'UID')\r
+                               config[key].Value = Number(widget.preferenceForKey(key));\r
+               }\r
+               else\r
+                       config[key].Value = config[key].Default;\r
                \r
-       if (widget.preferenceForKey('cssStyle_today'))\r
-               cssStyle_today = widget.preferenceForKey('cssStyle_today');\r
-       else\r
-               cssStyle_today = "color:#ff0000";\r
-       \r
-       if (widget.preferenceForKey('cssStyle_tomorrow'))\r
-               cssStyle_tomorrow = widget.preferenceForKey('cssStyle_tomorrow');\r
-       else\r
-               cssStyle_tomorrow = "color:#0000ff";\r
-       \r
-       if (widget.preferenceForKey('cssStyle_time'))\r
-               cssStyle_time = widget.preferenceForKey('cssStyle_time');\r
-       else\r
-               cssStyle_time = "";\r
-       \r
-       if (widget.preferenceForKey('cssStyle_now'))\r
-               cssStyle_now = widget.preferenceForKey('cssStyle_now');\r
-       else\r
-               cssStyle_now = "color:#ff00ff";\r
-       \r
-       if (widget.preferenceForKey('cssStyle_description'))\r
-               cssStyle_description = widget.preferenceForKey('cssStyle_description');\r
-       else\r
-               cssStyle_description = "";\r
-       \r
-       if (widget.preferenceForKey('cssStyle_icon'))\r
-               cssStyle_icon = widget.preferenceForKey('cssStyle_icon');\r
-       else\r
-               cssStyle_icon = "width:15px; height:15px";\r
+       }\r
 }\r
 \r
 function saveSettings()\r
 {\r
-       widget.setPreferenceForKey(monthRange.toString(), 'monthRange');\r
-       widget.setPreferenceForKey(includeTodos ? 'true' : 'false', 'includeTodos');\r
-       widget.setPreferenceForKey(useBackgroundImage ? 'true' : 'false', 'useBackgroundImage');\r
-       widget.setPreferenceForKey(showCombinedDateTime ? 'true' : 'false', 'showCombinedDateTime');\r
-       widget.setPreferenceForKey(showLocation ? 'true' : 'false', 'showLocation');\r
-       widget.setPreferenceForKey(showTodayAsText ? 'true' : 'false', 'showTodayAsText');\r
-       widget.setPreferenceForKey(todayText, 'todayText');\r
-       widget.setPreferenceForKey(tomorrowText, 'tomorrowText');\r
-       widget.setPreferenceForKey(showNowAsText ? 'true' : 'false', 'showNowAsText');\r
-       widget.setPreferenceForKey(nowText, 'nowText');\r
-       widget.setPreferenceForKey(dateSeparator, 'dateSeparator');\r
-       widget.setPreferenceForKey(dateFormat, 'dateFormat');\r
-       widget.setPreferenceForKey(weekDayLength.toString(), 'weekDayLength');\r
-       widget.setPreferenceForKey(updateDataInterval.toString(), 'updateDataInterval');\r
-       widget.setPreferenceForKey(calendarApp.toString(), 'calendarApp');\r
-       widget.setPreferenceForKey(eventsPerWidget.toString(), 'eventsPerWidget');\r
-       widget.setPreferenceForKey(showNothingText ? 'true' : 'false', 'showNothingText');\r
-       widget.setPreferenceForKey(nothingText, 'nothingText');\r
-       widget.setPreferenceForKey(enableDaylightSaving ? 'true' : 'false', 'enableDaylightSaving');\r
-       \r
-       widget.setPreferenceForKey(cssStyle_background, 'cssStyle_background');\r
-       widget.setPreferenceForKey(cssStyle_backgroundFullscreen, 'cssStyle_backgroundFullscreen');\r
-       widget.setPreferenceForKey(cssStyle_weekDay, 'cssStyle_weekDay');\r
-       widget.setPreferenceForKey(cssStyle_date, 'cssStyle_date');\r
-       widget.setPreferenceForKey(cssStyle_today, 'cssStyle_today');\r
-       widget.setPreferenceForKey(cssStyle_tomorrow, 'cssStyle_tomorrow');\r
-       widget.setPreferenceForKey(cssStyle_time, 'cssStyle_time');\r
-       widget.setPreferenceForKey(cssStyle_now, 'cssStyle_now');\r
-       widget.setPreferenceForKey(cssStyle_description, 'cssStyle_description');\r
-       widget.setPreferenceForKey(cssStyle_icon, 'cssStyle_icon');\r
+       for (var key in config) {\r
+               if (config[key].Type == 'Int')\r
+                       widget.setPreferenceForKey(config[key].Value.toString(), key);\r
+               else if (config[key].Type == 'String')\r
+                       widget.setPreferenceForKey(config[key].Value, key);\r
+               else if (config[key].Type == 'Bool')\r
+                       widget.setPreferenceForKey(config[key].Value ? 'true' : 'false', key);\r
+               else if (config[key].Type == 'Enum')\r
+                       widget.setPreferenceForKey(config[key].Value, key);\r
+               else if (config[key].Type == 'UID')\r
+                       widget.setPreferenceForKey(config[key].Value.toString(), key);\r
+       }\r
 }\r
 \r
 function toggleVisibility(elementId)\r
@@ -1090,7 +1015,7 @@ function showFullscreen()
 \r
 function updateHomescreen()\r
 {\r
-       if (useBackgroundImage) {\r
+       if (config['useBackgroundImage'].Value) {\r
                // check for screen rotation\r
                if (orientation != 'portrait' && screen.width == 360 && screen.height == 640) {\r
                        window.widget.prepareForTransition("fade");\r
index 65d3c5ee9f1f6e6bdbf900dac84c90dd4fc3ea20..5f693a0033caa6a61fccf9a566f3077dcb2207f4 100644 (file)
 <title>Coming Next</title>\r
 \r
 <style type="text/css">\r
-.background { color:#ffffff; background-color:#000000 } /* Defines the background of the widget. If you want to use a background image, set useBackgroundImage = true below */\r
-                                       /* for the default themes, black, gray, and light blue, codes are #292029, #e7dfe7, #009aef */\r
-.backgroundFullscreen { color:#ffffff; background-color:#000000 } /* Same as background but for the fullscreen version of the widget */\r
-.weekDay { }                           /* Defines the appearance of all week day texts */\r
-.date { }                              /* Defines the appearance of all date texts */\r
-.today { color:#ff0000; }              /* Defines the appearance of "Today" text */\r
-.tomorrow { color:#0000ff; }           /* Defines the appearance of "Tomorrow" text */\r
-.time { }                              /* Defines the appearance of all time texts */\r
-.now { color:#ff00ff; }                        /* Defines the appearance of "Now" text */\r
-.description { }                       /* Defines the appearance of all event descriptions */\r
-.icon { width:15px; height:15px; }     /* Defines size and appearance of icons */\r
+/* The following classes can be modified by widget settings */\r
+.background { }\r
+.backgroundFullscreen { }\r
+.weekDay { }\r
+.date { }\r
+.today { }\r
+.tomorrow { }\r
+.time { }\r
+.now { }\r
+.description { }\r
+.icon { }\r
 </style>\r
 \r
 <script>\r
-var monthRange = 2;            // number of months to include in the event list\r
-var includeTodos = true;       // disable to remove ToDos from event list\r
-var useBackgroundImage = true; // use background_portrait.png and background_landscape.png to fake transparency. Set to "false" to use a solid background color\r
-var showCombinedDateTime = false;// only show the time for events happening today, otherwise just show the date\r
-var showLocation = true;       // show the location for meeting events\r
-var showTodayAsText = true;    // if enabled, the current date will be shown as "Today" instead of "31.12"\r
-var todayText = 'Today';       // text to display for "Today"\r
-var tomorrowText = 'Tomorrow'; // text to display for "Tomorrow"\r
-var showNowAsText = true;      // if enabled, the appointment time will be shown as "Now" instead of "12:00"\r
-var nowText = 'Now';           // text to display for "Now"\r
-var dateSeparator = '.';       // separator for dates. e.g. "31.12" or "31/12"\r
-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\r
-var weekDayLength = 2;         // defines how many characters of the weekday will be shown. E.g. 2 will cut "Friday" to "Fr"\r
-var updateDataInterval = 5;    // how many minutes to wait before updating the displayed data. The higher the number, the less battery is used\r
-var calendarApp = 0x10005901;  // UID of the calendar app to run when clicking the widget. 0x10005901 = buildin calendar, 0x20004ec1 = Epocware Handy Calendar\r
-var eventsPerWidget = 4;       // number of events to show per widget. Default is 4\r
-var showNothingText = true;    // if set to "true", show a text if no events are in the list\r
-var nothingText = 'No further events within ' + monthRange + ' months';                // text to show when no events are in the list\r
-var enableDaylightSaving = true;// enable this if you are in a timezone that has daylight saving time (+1h)\r
-\r
-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\r
-var cssStyle_backgroundFullscreen = "color:#ffffff; background-color:#000000"; // Same as background but for the fullscreen version of the widget\r
-var cssStyle_weekDay = "";                     // Defines the appearance of all week day texts\r
-var cssStyle_date = "";                                // Defines the appearance of all date texts\r
-var cssStyle_today = "color:#ff0000";          // Defines the appearance of "Today" text\r
-var cssStyle_tomorrow = "color:#0000ff";       // Defines the appearance of "Tomorrow" text\r
-var cssStyle_time = "";                                // Defines the appearance of all time texts\r
-var cssStyle_now = "color:#ff00ff";            // Defines the appearance of "Now" text\r
-var cssStyle_description = "";                 // Defines the appearance of all event descriptions\r
-var cssStyle_icon = "width:15px; height:15px"; // Defines size and appearance of icons\r
+// valid types for the config object are 'Int', 'Bool', 'String', 'Enum', 'UID'\r
+var config = {\r
+monthRange: {\r
+       Type: 'Int',\r
+       Default: 2,\r
+       Value: 2,\r
+       Name: 'Month Range',\r
+       Info: 'number of months to include in the event list',},\r
+includeTodos: {\r
+       Type: 'Bool',\r
+       Default: true,\r
+       Value: true,\r
+       Name: 'Include ToDos',\r
+       Info: 'disable to remove ToDos from event list',},\r
+useBackgroundImage: {\r
+       Type: 'Bool',\r
+       Default: true,\r
+       Value: true,\r
+       Name: 'Use Background Image',\r
+       Info: 'use background_portrait.png and background_landscape.png to fake transparency. Disable to use a solid background color',},\r
+showCombinedDateTime: {\r
+       Type: 'Bool',\r
+       Default: false,\r
+       Value: false,\r
+       Name: 'Show Combined Date/Time',\r
+       Info: 'only show the time for events happening today, otherwise just show the date',},\r
+showLocation: {\r
+       Type: 'Bool',\r
+       Default: true,\r
+       Value: true,\r
+       Name: 'Show Location',\r
+       Info: 'show the location for meeting events',},\r
+showTodayAsText: {\r
+       Type: 'Bool',\r
+       Default: true,\r
+       Value: true,\r
+       Name: 'Show Today as Text',\r
+       Info: 'if enabled, the current date will be shown as "Today" instead of "31.12"',},\r
+todayText: {\r
+       Type: 'String',\r
+       Default: 'Today',\r
+       Value: 'Today',\r
+       Name: '"Today" Text',\r
+       Info: 'text to display for "Today"',},\r
+tomorrowText: {\r
+       Type: 'String',\r
+       Default: 'Tomorrow',\r
+       Value: 'Tomorrow',\r
+       Name: '"Tomorrow" Text',\r
+       Info: 'text to display for "Tomorrow"',},\r
+showNowAsText: {\r
+       Type: 'Bool',\r
+       Default: true,\r
+       Value: true,\r
+       Name: 'Show Now as Text',\r
+       Info: 'if enabled, the appointment time will be shown as "Now" instead of "12:00"',},\r
+nowText: {\r
+       Type: 'String',\r
+       Default: 'Now',\r
+       Value: 'Now',\r
+       Name: '"Now" Text',\r
+       Info: 'text to display for "Now"',},\r
+dateSeparator: {\r
+       Type: 'String',\r
+       Default: '.',\r
+       Value: '.',\r
+       Name: 'Date Separator',\r
+       Info: 'separator for dates. e.g. "31.12" or "31/12"',},\r
+dateFormat: {\r
+       Type: 'Enum',\r
+       Default: 'auto',\r
+       Value: 'auto',\r
+       ValidValues: ['auto', 'DDMM', 'MMDD'],\r
+       Name: 'Date Format',\r
+       Info: 'how dates will be displayed. \'auto\' will autodetect your phone\'s date format setting. \'MMDD\' will write month first, \'DDMM\' will write day first',},\r
+weekDayLength: {\r
+       Type: 'Int',\r
+       Default: 2,\r
+       Value: 2,\r
+       Name: 'Weekday Length',\r
+       Info: 'defines how many characters of the weekday will be shown. E.g. 2 will cut "Friday" to "Fr"',},\r
+updateDataInterval: {\r
+       Type: 'Int',\r
+       Default: 5,\r
+       Value: 5,\r
+       Name: 'Update Data Interval',\r
+       Info: 'how many minutes to wait before updating the displayed data. The higher the number, the less battery is used',},\r
+calendarApp: {\r
+       Type: 'UID',\r
+       Default: 0x10005901,\r
+       Value: 0x10005901,\r
+       Name: 'Calendar Application To Run',\r
+       Info: 'UID of the calendar app to run when clicking the widget. 0x10005901 = buildin calendar, 0x20004ec1 = Epocware Handy Calendar',},\r
+eventsPerWidget: {\r
+       Type: 'Int',\r
+       Default: 4,\r
+       Value: 4,\r
+       Name: 'Events Per Widget',\r
+       Info: 'number of events to show per widget. Default is 4',},\r
+showNothingText: {\r
+       Type: 'Bool',\r
+       Default: true,\r
+       Value: true,\r
+       Name: 'Show "Nothing" Text',\r
+       Info: 'if enabled, show a text if no events are in the list',},\r
+nothingText: {\r
+       Type: 'String',\r
+       Default: 'No further events within 2 months',\r
+       Value: 'No further events within 2 months',\r
+       Name: '"No further events..." Text',\r
+       Info: 'text to show when no events are in the list',},\r
+enableDaylightSaving: {\r
+       Type: 'Bool',\r
+       Default: true,\r
+       Value: true,\r
+       Name: 'Enable Daylight Saving (+1h)',\r
+       Info: 'enable this if you are in a timezone that has daylight saving time (+1h)',},\r
+cssStyle_background: {\r
+       Type: 'String',\r
+       Default: 'color:#ffffff; background-color:#000000',\r
+       Value: 'color:#ffffff; background-color:#000000',\r
+       Name: '.background',\r
+       Info: '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',},\r
+cssStyle_backgroundFullscreen: {\r
+       Type: 'String',\r
+       Default: 'color:#ffffff; background-color:#000000',\r
+       Value: 'color:#ffffff; background-color:#000000',\r
+       Name: '.backgroundFullscreen',\r
+       Info: 'Same as background but for the fullscreen version of the widget',},\r
+cssStyle_weekDay: {\r
+       Type: 'String',\r
+       Default: '',\r
+       Value: '',\r
+       Name: '.weekDay',\r
+       Info: 'Defines the appearance of all week day texts',},\r
+cssStyle_date: {\r
+       Type: 'String',\r
+       Default: '',\r
+       Value: '',\r
+       Name: '.date',\r
+       Info: 'Defines the appearance of all date texts',},\r
+cssStyle_today: {\r
+       Type: 'String',\r
+       Default: 'color:#ff0000',\r
+       Value: 'color:#ff0000',\r
+       Name: '.today',\r
+       Info: 'Defines the appearance of "Today" text',},\r
+cssStyle_tomorrow: {\r
+       Type: 'String',\r
+       Default: 'color:#0000ff',\r
+       Value: 'color:#0000ff',\r
+       Name: '.tomorrow',\r
+       Info: 'Defines the appearance of "Tomorrow" text',},\r
+cssStyle_time: {\r
+       Type: 'String',\r
+       Default: '',\r
+       Value: '',\r
+       Name: '.time',\r
+       Info: 'Defines the appearance of all time texts',},\r
+cssStyle_now: {\r
+       Type: 'String',\r
+       Default: 'color:#ff00ff',\r
+       Value: 'color:#ff00ff',\r
+       Name: '.now',\r
+       Info: 'Defines the appearance of "Now" text',},\r
+cssStyle_description: {\r
+       Type: 'String',\r
+       Default: '',\r
+       Value: '',\r
+       Name: '.description',\r
+       Info: 'Defines the appearance of all event descriptions',},\r
+cssStyle_icon: {\r
+       Type: 'String',\r
+       Default: 'width:15px; height:15px',\r
+       Value: 'width:15px; height:15px',\r
+       Name: '.icon',\r
+       Info: 'Defines size and appearance of icons',},\r
+}\r
 \r
 //-------------------------------------------------------\r
 // Nothing of interest from here on...\r
@@ -329,7 +477,7 @@ function parseDate(dateString)
        console.info('year=' + year + ' month=' + month + ' day=' + day + ' hours=' + hours + ' minutes=' + minutes+ ' seconds=' + seconds);\r
 \r
        // take care of daylight saving time\r
-       if (enableDaylightSaving) {\r
+       if (config['enableDaylightSaving'].Value) {\r
                var date = new Date(year, month - 1, day, hours, minutes, seconds);\r
                if (summertime && date > daylightsavingWinter && date < daylightsavingSummer)\r
                        hours -= 1;\r
@@ -348,27 +496,27 @@ function formatDate(date, format)
        while (day.length < 2) { day = '0' + day; }\r
        while (month.length < 2) { month = '0' + month; }\r
 \r
-       if (showTodayAsText && isToday(date))\r
-               return '<span class="today">' + todayText + '</span>';\r
-       if (showTodayAsText && isTomorrow(date))\r
-               return '<span class="tomorrow">' + tomorrowText + '</span>';\r
+       if (config['showTodayAsText'].Value && isToday(date))\r
+               return '<span class="today">' + config['todayText'].Value + '</span>';\r
+       if (config['showTodayAsText'].Value && isTomorrow(date))\r
+               return '<span class="tomorrow">' + config['tomorrowText'].Value + '</span>';\r
 \r
        var dateArr = format.replace(/,/g,'').replace(/\./g,':').replace(/  /g,' ').split(' ');\r
        if (dateArr.length != 5 && dateArr.length != 6) {\r
                // we don't know how to format this\r
-               if (dateFormat == 'auto' || dateFormat == 'DDMM')\r
-                       return day + dateSeparator + month;\r
+               if (config['dateFormat'].Value == 'auto' || config['dateFormat'].Value == 'DDMM')\r
+                       return day + config['dateSeparator'].Value + month;\r
                else\r
-                       return month + dateSeparator + day;\r
+                       return month + config['dateSeparator'].Value + day;\r
        }\r
 \r
        var dayFirst = true;\r
-       if (dateFormat == 'MMDD')\r
+       if (config['dateFormat'].Value == 'MMDD')\r
                dayFirst = false;\r
-       else if (dateFormat == 'DDMM')\r
+       else if (config['dateFormat'].Value == 'DDMM')\r
                dayFirst = true;\r
        else {\r
-               // dateFormat == 'auto', try to detect system setting\r
+               // config['dateFormat'].Value == 'auto', try to detect system setting\r
                // parse date\r
                var day_ = dateArr[1];\r
                var month_ = dateArr[2];\r
@@ -391,9 +539,9 @@ function formatDate(date, format)
        }\r
 \r
        if (dayFirst)\r
-               return day + dateSeparator + month;\r
+               return day + config['dateSeparator'].Value + month;\r
        else\r
-               return month + dateSeparator + day;\r
+               return month + config['dateSeparator'].Value + day;\r
 }\r
 \r
 function formatTime(date)\r
@@ -403,8 +551,8 @@ function formatTime(date)
        var time = date.toLocaleTimeString().replace(/[\.:]00/, ''); // remove seconds from string\r
        if (time.replace(/\./, ':').split(':')[0].length < 2)\r
                time = '0' + time;\r
-       if (showNowAsText && date.getTime() == now.getTime())\r
-               time = '<span class="now">' + nowText + '</span>';\r
+       if (config['showNowAsText'].Value && date.getTime() == now.getTime())\r
+               time = '<span class="now">' + config['nowText'].Value + '</span>';\r
        return time;\r
 }\r
 \r
@@ -419,7 +567,7 @@ function updateData()
                        Type:'CalendarEntry',\r
                        Filter:{\r
                                StartRange: (new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0)),\r
-                               EndRange: (new Date(now.getFullYear(), now.getMonth() + monthRange, now.getDate(), 0, 0, 0))\r
+                               EndRange: (new Date(now.getFullYear(), now.getMonth() + config['monthRange'].Value, now.getDate(), 0, 0, 0))\r
                        }\r
                }\r
                var meetingResult = calendarService.IDataSource.GetList(meetingListFiltering);\r
@@ -427,7 +575,7 @@ function updateData()
 \r
                // todos don't, they start on 00:00 hrs., but should be visible anyway\r
                // this will generate a list of passed todos. We have to check if they have been marked as "done" yet\r
-               if (includeTodos) {\r
+               if (config['includeTodos'].Value) {\r
                        var todayTodoListFiltering = {\r
                                Type:'CalendarEntry',\r
                                Filter:{\r
@@ -456,7 +604,7 @@ function updateData()
                var eventIds = [];\r
                var max;\r
                if (mode == 0)\r
-                       max = ((panelNum == 0) ? eventsPerWidget : 2 * eventsPerWidget);\r
+                       max = ((panelNum == 0) ? config['eventsPerWidget'].Value : 2 * config['eventsPerWidget'].Value);\r
                else\r
                        max = 30; // we can display a lot more events in fullscreen mode\r
 \r
@@ -479,7 +627,7 @@ function updateData()
                                );\r
 \r
                                // we don't want ToDos when includeTodos == false or when they are completed\r
-                               if (entry.Type == 'ToDo' && (entry.Status == "TodoCompleted" || !includeTodos)) {\r
+                               if (entry.Type == 'ToDo' && (entry.Status == "TodoCompleted" || !config['includeTodos'].Value)) {\r
                                        console.info('skipping ' + entry.id );\r
                                        counter--;\r
                                        continue;\r
@@ -495,7 +643,7 @@ function updateData()
 \r
                                // summary can be undefined!\r
                                var Summary = ((entry.Summary == null) ? '' : entry.Summary);\r
-                               if (entry.Type == 'Meeting' && entry.Location != '' && showLocation)\r
+                               if (entry.Type == 'Meeting' && entry.Location != '' && config['showLocation'].Value)\r
                                        Summary += ', ' + entry.Location;\r
                                \r
                                // fix by yves: determine start and end dates/times\r
@@ -558,7 +706,7 @@ function updateData()
                                }\r
 \r
                                // skip events for the first panel in case this is the second one and we're not in fullscreen mode\r
-                               if (mode == 0 && panelNum == 1 && counter < eventsPerWidget + 1) {\r
+                               if (mode == 0 && panelNum == 1 && counter < config['eventsPerWidget'].Value + 1) {\r
                                        console.info('skipping (already in first widget) ' + entry.id);\r
                                        continue;\r
                                }\r
@@ -569,16 +717,16 @@ function updateData()
                                        // some languages have very strange locale date formats, can't parse all those. Also some todos don't have dates at all.\r
                                        entriesHtml += '<td colspan="4"><span class="date">' + entryDate + '</span> ';\r
                                } else {\r
-                                       var weekDay = date.toLocaleDateString().substr(0,weekDayLength);\r
+                                       var weekDay = date.toLocaleDateString().substr(0,config['weekDayLength'].Value);\r
                                        var time = formatTime(date);\r
                                        var dateStr = formatDate(date, entryDate);\r
                                        if (entry.Type == 'ToDo' || entry.Type == 'Anniversary' || entry.Type == 'DayEvent' || entry.Type == 'Reminder') {\r
-                                               if ((isToday(date) || isTomorrow(date)) && showTodayAsText) // show weekday if the date string is not text. looks odd otherwise\r
+                                               if ((isToday(date) || isTomorrow(date)) && config['showTodayAsText'].Value) // show weekday if the date string is not text. looks odd otherwise\r
                                                        entriesHtml += '<td colspan="4" width="1px"><span class="date">' + dateStr + '</span> ';\r
                                                else\r
                                                        entriesHtml += '<td class="weekDay" width="1px">' + weekDay + '</td><td width="1px" class="date">' + dateStr + '</td><td colspan="2">';\r
                                        } else if (entry.Type == 'Meeting') {\r
-                                               if (showCombinedDateTime) {\r
+                                               if (config['showCombinedDateTime'].Value) {\r
                                                        if (isToday(date))\r
                                                                entriesHtml += '<td width="1px" colspan="4"><span class="today">' + time + '</span> ';\r
                                                        else if (isTomorrow(date))\r
@@ -586,7 +734,7 @@ function updateData()
                                                        else\r
                                                                entriesHtml += '<td width="1px" class="weekDay">' + weekDay + '</td><td width="1px" class="date">' + dateStr + '</td><td colspan="2">';\r
                                                } else {\r
-                                                       if ((isToday(date) || isTomorrow(date)) && showTodayAsText)\r
+                                                       if ((isToday(date) || isTomorrow(date)) && config['showTodayAsText'].Value)\r
                                                                entriesHtml += '<td colspan="4" width="1px"><span class="today">' + dateStr + '</span> <span class="time">' + time + '</span> ';\r
                                                        else\r
                                                                entriesHtml += '<td width="1px" class="weekDay">' + weekDay + '</td><td width="1px" class="date">' + dateStr + '</td><td width="1px" class="time">' + time + '</td><td>';\r
@@ -597,8 +745,8 @@ function updateData()
                        }\r
                }\r
                entriesHtml += '</table>';\r
-               if (showNothingText && entriesHtml == '<table></table>')\r
-                       entriesHtml = '<div style="width:295px; height:75px; text-align:center; line-height:75px; overflow:visible;">' + nothingText + '</div>';\r
+               if (config['showNothingText'].Value && entriesHtml == '<table></table>')\r
+                       entriesHtml = '<div style="width:295px; height:75px; text-align:center; line-height:75px; overflow:visible;">' + config['nothingText'].Value + '</div>';\r
                if (cacheEntriesHtml != entriesHtml) {\r
                        if (mode == 0)\r
                                document.getElementById('calendarList').innerHTML = entriesHtml;\r
@@ -636,7 +784,7 @@ function updateScreen()
 function launchCalendar()\r
 {\r
        try {\r
-               widget.openApplication(calendarApp, "");\r
+               widget.openApplication(config['calendarApp'].Value, "");\r
                //window.close();\r
        } catch(e) {\r
                error('starting Calendar App');\r
@@ -659,14 +807,14 @@ function init()
        collectLocales();\r
        //updateData();\r
        requestNotification();\r
-       window.setInterval('updateData()', 1000 * 60 * updateDataInterval);\r
+       window.setInterval('updateData()', 1000 * 60 * config['updateDataInterval'].Value);\r
 \r
        mode = 0;\r
        showHomescreen();\r
        updateScreen();\r
-       if (useBackgroundImage)\r
-               // check for screen rotation every 3 secs\r
-               window.setInterval('updateScreen()', 1000 * 3);\r
+       if (config['useBackgroundImage'].Value)\r
+               // check for screen rotation every 1 secs\r
+               window.setInterval('updateScreen()', 1000 * 1);\r
 }\r
 \r
 function createMenu()\r
@@ -697,47 +845,24 @@ function showSettings()
        \r
        window.menu.setLeftSoftkeyLabel("Save", function()\r
        {\r
-               //document.forms[0].elements["settings.monthRange"].value = monthRange;\r
-               monthRange = parseInt(document.forms[0].elements["settings.monthRange"].value);\r
-               if (monthRange < 0 || monthRange > 100)\r
-                       monthRange = 2;\r
-               includeTodos = document.forms[0].elements["settings.includeTodos"].checked;\r
-               useBackgroundImage = document.forms[0].elements["settings.useBackgroundImage"].checked;\r
-               showCombinedDateTime = document.forms[0].elements["settings.showCombinedDateTime"].checked;\r
-               showLocation = document.forms[0].elements["settings.showLocation"].checked;\r
-               showTodayAsText = document.forms[0].elements["settings.showTodayAsText"].checked;\r
-               todayText = document.forms[0].elements["settings.todayText"].value;\r
-               tomorrowText = document.forms[0].elements["settings.tomorrowText"].value;\r
-               showNowAsText = document.forms[0].elements["settings.showNowAsText"].checked;\r
-               nowText = document.forms[0].elements["settings.nowText"].value;\r
-               dateSeparator = document.forms[0].elements["settings.dateSeparator"].value;\r
-               dateFormat = document.forms[0].elements["settings.dateFormat"].value;\r
-               if (dateFormat != 'auto' && dateFormat != 'DDMM' && dateFormat != 'MMDD')\r
-                       dateFormat = 'auto';\r
-               weekDayLength = Number(parseInt(document.forms[0].elements["settings.weekDayLength"].value));\r
-               if (weekDayLength < 0 || weekDayLength > 20)\r
-                       weekDayLength = 2;\r
-               updateDataInterval = parseInt(document.forms[0].elements["settings.updateDataInterval"].value);\r
-               if (updateDataInterval < 1 || updateDataInterval > 1000)\r
-                       updateDataInterval = 5;\r
-               calendarApp = parseInt(document.forms[0].elements["settings.calendarApp"].value);\r
-               eventsPerWidget = parseInt(document.forms[0].elements["settings.eventsPerWidget"].value);\r
-               if (eventsPerWidget < 1 || eventsPerWidget > 10)\r
-                       eventsPerWidget = 4;\r
-               showNothingText = document.forms[0].elements["settings.showNothingText"].checked;\r
-               nothingText = document.forms[0].elements["settings.nothingText"].value;\r
-               enableDaylightSaving = document.forms[0].elements["settings.enableDaylightSaving"].checked;\r
-               \r
-               cssStyle_background = document.forms[0].elements["settings.cssStyle_background"].value;\r
-               cssStyle_backgroundFullscreen = document.forms[0].elements["settings.cssStyle_backgroundFullscreen"].value;\r
-               cssStyle_weekDay = document.forms[0].elements["settings.cssStyle_weekDay"].value;\r
-               cssStyle_date = document.forms[0].elements["settings.cssStyle_date"].value;\r
-               cssStyle_today = document.forms[0].elements["settings.cssStyle_today"].value;\r
-               cssStyle_tomorrow = document.forms[0].elements["settings.cssStyle_tomorrow"].value;\r
-               cssStyle_time = document.forms[0].elements["settings.cssStyle_time"].value;\r
-               cssStyle_now = document.forms[0].elements["settings.cssStyle_now"].value;\r
-               cssStyle_description = document.forms[0].elements["settings.cssStyle_description"].value;\r
-               cssStyle_icon = document.forms[0].elements["settings.cssStyle_icon"].value;\r
+               for (var key in config) {\r
+                       if (config[key].Type == 'String')\r
+                               config[key].Value = document.forms[0].elements["settings." + key].value;\r
+                       else if (config[key].Type == 'Int') {\r
+                               config[key].Value = parseInt(document.forms[0].elements["settings." + key].value);\r
+                               if (config[key].Value < 0)\r
+                                       config[key].Value = config[key].Default;\r
+                       }\r
+                       else if (config[key].Type == 'Bool')\r
+                               config[key].Value = document.forms[0].elements["settings." + key].checked;\r
+                       else if (config[key].Type == 'UID')\r
+                               config[key].Value = parseInt(document.forms[0].elements["settings." + key].value);\r
+                       else if (config[key].Type == 'Enum') {\r
+                               config[key].Value = document.forms[0].elements["settings." + key].value;\r
+                               if (config[key].ValidValues.indexOf(config[key].Value) == -1)\r
+                                       config[key].Value = config[key].Default;\r
+                       }\r
+               }\r
                                \r
                updateCssClasses();\r
                \r
@@ -752,44 +877,26 @@ function showSettings()
                showFullscreen();\r
        });\r
        \r
-       document.getElementById("settingsList").innerHTML = \r
-       '<form>' +\r
-       '<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') +\r
-       '<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') +\r
-       '<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') +\r
-       '<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') +\r
-       '<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') +\r
-       '<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"') +\r
-       '<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>' +\r
-       '<hr><table><tr><td>"Tomorrow" Text:<br><input class="textInput" name="settings.tomorrowText" type="text" value="' + tomorrowText + '" /></td>' + printHintBox('text to display for "Tomorrow"') +\r
-       '<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"') +\r
-       '<hr><table><tr><td>"Now" Text:<br><input class="textInput" name="settings.nowText" type="text" value="' + nowText + '" /></td>' + printHintBox('text to display for "Now"') +\r
-       '<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"') +\r
-       '<hr><table><tr><td>Date Format:<br><select name="settings.dateFormat" size="1">' + \r
-               '<option label="auto detect"' + (dateFormat == 'auto' ? ' selected="selected"' : '') + '>auto</option>' +\r
-               '<option label="MMDD"' + (dateFormat == 'MMDD' ? ' selected="selected"' : '') + '>MMDD</option>' +\r
-               '<option label="DDMM"' + (dateFormat == 'DDMM' ? ' selected="selected"' : '') + '>DDMM</option>' +\r
-               '</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>' +\r
-       '<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"') +\r
-       '<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') +\r
-       '<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') +\r
-       '<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') +\r
-       '<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') +\r
-       '<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') +\r
-       '<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)') +\r
-       '<hr style="margin-bottom:60px;"><h1 class="title">CSS Styles</h1>' +\r
-       '<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') +\r
-       '<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') +\r
-       '<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') +\r
-       '<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') +\r
-       '<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') +\r
-       '<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') +\r
-       '<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') +\r
-       '<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') +\r
-       '<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') +\r
-       '<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') +\r
-       '<hr style="margin-bottom:60px;"><input name="reset" type="button" value="Restore Defaults" onclick="javascript:restoreDefaultSettings();showSettings();" />' +\r
-       '</form>';\r
+       var settingsHtml = '<form>';\r
+       for (var key in config) {\r
+               if (config[key].Type == 'String')\r
+                       settingsHtml += '<table><tr><td>' + config[key].Name + '<br /><input class="textInput" name="settings.' + key + '" type="text" value="' + config[key].Value + '" /></td>' + printHintBox(config[key].Info) + '<hr />';\r
+               else if (config[key].Type == 'Int')\r
+                       settingsHtml += '<table><tr><td>' + config[key].Name + '<br /><input class="textInput" name="settings.' + key + '" type="text" value="' + config[key].Value + '" /></td>' + printHintBox(config[key].Info) + '<hr />';\r
+               else if (config[key].Type == 'Bool')\r
+                       settingsHtml += '<table><tr><td>' + config[key].Name + '<br /><input name="settings.' + key + '" type="checkbox" value="true" ' + (config[key].Value ? 'checked="checked"' : '') + '/></td>' + printHintBox(config[key].Info) + '<hr />';\r
+               else if (config[key].Type == 'UID')\r
+                       settingsHtml += '<table><tr><td>' + config[key].Name + '<br /><input class="textInput" name="settings.' + key + '" type="text" value="0x' + config[key].Value.toString(16) + '" /></td>' + printHintBox(config[key].Info) + '<hr />';\r
+               else if (config[key].Type == 'Enum') {\r
+                       settingsHtml += '<table><tr><td>' + config[key].Name + '<br /><select name="settings.' + key + '" size="1">';\r
+                       for(var i = 0; i < config[key].ValidValues.length; i++)\r
+                               settingsHtml += '<option label="' + config[key].ValidValues[i] + '"' + (config[key].Value == config[key].ValidValues[i] ? ' selected="selected"' : '') + '>' + config[key].ValidValues[i] + '</option>';\r
+                       settingsHtml += '</select></div></td>' + printHintBox(config[key].Info) + '<hr />';\r
+               }\r
+       }\r
+       settingsHtml += '<input name="reset" type="button" value="Restore Defaults" onclick="javascript:restoreDefaultSettings();showSettings();" />';\r
+       settingsHtml += '</form>';\r
+       document.getElementById("settingsList").innerHTML = settingsHtml;\r
 }\r
 \r
 function changeCssClass(classname, properties)\r
@@ -806,234 +913,52 @@ function changeCssClass(classname, properties)
 \r
 function updateCssClasses()\r
 {\r
-       changeCssClass(".background", cssStyle_background);\r
-       changeCssClass(".backgroundFullscreen", cssStyle_backgroundFullscreen);\r
-       changeCssClass(".weekDay", cssStyle_weekDay);\r
-       changeCssClass(".date", cssStyle_date);\r
-       changeCssClass(".today", cssStyle_today);\r
-       changeCssClass(".tomorrow", cssStyle_tomorrow);\r
-       changeCssClass(".time", cssStyle_time);\r
-       changeCssClass(".now", cssStyle_now);\r
-       changeCssClass(".description", cssStyle_description);\r
-       changeCssClass(".icon", cssStyle_icon);\r
+       for(var key in config) {\r
+               changeCssClass(config[key].Name, config[key].Value);\r
+       }\r
 }\r
 \r
 function restoreDefaultSettings()\r
 {\r
-       monthRange = 2;\r
-       includeTodos = true;\r
-       useBackgroundImage = true;\r
-       showCombinedDateTime = false;\r
-       showLocation = true;\r
-       showTodayAsText = true;\r
-       todayText = 'Today';\r
-       tomorrowText = 'Tomorrow';\r
-       showNowAsText = true;\r
-       nowText = 'Now';\r
-       dateSeparator = '.';\r
-       dateFormat = 'auto'\r
-       weekDayLength = 2;\r
-       updateDataInterval = 5;\r
-       calendarApp = 0x10005901;\r
-       eventsPerWidget = 4;\r
-       showNothingText = true;\r
-       nothingText = 'No further events within ' + monthRange + ' months';\r
-       enableDaylightSaving = true;\r
-\r
-       cssStyle_background = "color:#ffffff; background-color:#000000";\r
-       cssStyle_backgroundFullscreen = "color:#ffffff; background-color:#000000";\r
-       cssStyle_weekDay = "";\r
-       cssStyle_date = "";\r
-       cssStyle_today = "color:#ff0000";\r
-       cssStyle_tomorrow = "color:#0000ff";\r
-       cssStyle_time = "";\r
-       cssStyle_now = "color:#ff00ff";\r
-       cssStyle_description = "";\r
-       cssStyle_icon = "width:15px; height:15px";\r
+       for (var key in config)\r
+               config[key].Value = config[key].Default;\r
 }\r
 \r
 function loadSettings()\r
 {\r
-       if (widget.preferenceForKey('monthRange'))\r
-               monthRange = Number(widget.preferenceForKey('monthRange'));\r
-       else\r
-               monthRange = 2;\r
-       \r
-       if (widget.preferenceForKey('includeTodos'))\r
-               includeTodos = (widget.preferenceForKey('includeTodos') == 'true');\r
-       else\r
-               includeTodos = true;\r
-       \r
-       if (widget.preferenceForKey('useBackgroundImage'))\r
-               useBackgroundImage = (widget.preferenceForKey('useBackgroundImage') == 'true');\r
-       else\r
-               useBackgroundImage = true;\r
-       \r
-       if (widget.preferenceForKey('showCombinedDateTime'))\r
-               showCombinedDateTime = (widget.preferenceForKey('showCombinedDateTime') == 'true');\r
-       else\r
-               showCombinedDateTime = false;\r
-       \r
-       if (widget.preferenceForKey('showLocation'))\r
-               showLocation = (widget.preferenceForKey('showLocation') == 'true');\r
-       else\r
-               showLocation = true;\r
-       \r
-       if (widget.preferenceForKey('showTodayAsText'))\r
-               showTodayAsText = (widget.preferenceForKey('showTodayAsText') == 'true');\r
-       else\r
-               showTodayAsText = true;\r
-       \r
-       if (widget.preferenceForKey('todayText'))\r
-               todayText = widget.preferenceForKey('todayText');\r
-       else\r
-               todayText = 'Today';\r
-       \r
-       if (widget.preferenceForKey('tomorrowText'))\r
-               tomorrowText = widget.preferenceForKey('tomorrowText');\r
-       else\r
-               tomorrowText = 'Tomorrow';\r
-       \r
-       if (widget.preferenceForKey('showNowAsText'))\r
-               showNowAsText = (widget.preferenceForKey('showNowAsText') == 'true');\r
-       else\r
-               showNowAsText = true;\r
-       \r
-       if (widget.preferenceForKey('nowText'))\r
-               nowText = widget.preferenceForKey('nowText');\r
-       else\r
-               nowText = 'Now';\r
-       \r
-       if (widget.preferenceForKey('dateSeparator'))\r
-               dateSeparator = widget.preferenceForKey('dateSeparator');\r
-       else\r
-               dateSeparator = '.';\r
-       \r
-       if (widget.preferenceForKey('dateFormat'))\r
-               dateFormat = widget.preferenceForKey('dateFormat');\r
-       else\r
-               dateFormat = 'auto';\r
-       \r
-       if (widget.preferenceForKey('weekDayLength'))\r
-               weekDayLength = Number(widget.preferenceForKey('weekDayLength'));\r
-       else\r
-               weekDayLength = 2;\r
-       \r
-       if (widget.preferenceForKey('updateDataInterval'))\r
-               updateDataInterval = Number(widget.preferenceForKey('updateDataInterval'));\r
-       else\r
-               updateDataInterval = 5;\r
-       \r
-       if (widget.preferenceForKey('calendarApp'))\r
-               calendarApp = Number(widget.preferenceForKey('calendarApp'));\r
-       else\r
-               calendarApp = 0x10005901;\r
-       \r
-       if (widget.preferenceForKey('eventsPerWidget'))\r
-               eventsPerWidget = Number(widget.preferenceForKey('eventsPerWidget'));\r
-       else\r
-               eventsPerWidget = 4;\r
-       \r
-       if (widget.preferenceForKey('showNothingText'))\r
-               showNothingText = (widget.preferenceForKey('showNothingText') == 'true');\r
-       else\r
-               showNothingText = true;\r
-       \r
-       if (widget.preferenceForKey('nothingText'))\r
-               nothingText = widget.preferenceForKey('nothingText');\r
-       else\r
-               nothingText = 'No further events within ' + monthRange + ' months';\r
-       \r
-       if (widget.preferenceForKey('enableDaylightSaving'))\r
-               enableDaylightSaving = (widget.preferenceForKey('enableDaylightSaving') == 'true');\r
-       else\r
-               enableDaylightSaving = true;\r
-       \r
-       // CSS styles\r
-               \r
-       if (widget.preferenceForKey('cssStyle_background'))\r
-               cssStyle_background = widget.preferenceForKey('cssStyle_background');\r
-       else\r
-               cssStyle_background = "color:#ffffff; background-color:#000000";\r
-\r
-       if (widget.preferenceForKey('cssStyle_backgroundFullscreen'))\r
-               cssStyle_backgroundFullscreen = widget.preferenceForKey('cssStyle_backgroundFullscreen');\r
-       else\r
-               cssStyle_backgroundFullscreen = "color:#ffffff; background-color:#000000";\r
-               \r
-       if (widget.preferenceForKey('cssStyle_weekDay'))\r
-               cssStyle_weekDay = widget.preferenceForKey('cssStyle_weekDay');\r
-       else\r
-               cssStyle_weekDay = "";\r
-               \r
-       if (widget.preferenceForKey('cssStyle_date'))\r
-               cssStyle_date = widget.preferenceForKey('cssStyle_date');\r
-       else\r
-               cssStyle_date = "";\r
+       for (var key in config) {\r
+               if (widget.preferenceForKey(key)) {\r
+                       if (config[key].Type == 'Int')\r
+                               config[key].Value = Number(widget.preferenceForKey(key));\r
+                       else if (config[key].Type == 'String')\r
+                               config[key].Value = widget.preferenceForKey(key);\r
+                       else if (config[key].Type == 'Bool')\r
+                               config[key].Value = (widget.preferenceForKey(key) == 'true')\r
+                       else if (config[key].Type == 'Enum')\r
+                               config[key].Value = widget.preferenceForKey(key);\r
+                       else if (config[key].Type == 'UID')\r
+                               config[key].Value = Number(widget.preferenceForKey(key));\r
+               }\r
+               else\r
+                       config[key].Value = config[key].Default;\r
                \r
-       if (widget.preferenceForKey('cssStyle_today'))\r
-               cssStyle_today = widget.preferenceForKey('cssStyle_today');\r
-       else\r
-               cssStyle_today = "color:#ff0000";\r
-       \r
-       if (widget.preferenceForKey('cssStyle_tomorrow'))\r
-               cssStyle_tomorrow = widget.preferenceForKey('cssStyle_tomorrow');\r
-       else\r
-               cssStyle_tomorrow = "color:#0000ff";\r
-       \r
-       if (widget.preferenceForKey('cssStyle_time'))\r
-               cssStyle_time = widget.preferenceForKey('cssStyle_time');\r
-       else\r
-               cssStyle_time = "";\r
-       \r
-       if (widget.preferenceForKey('cssStyle_now'))\r
-               cssStyle_now = widget.preferenceForKey('cssStyle_now');\r
-       else\r
-               cssStyle_now = "color:#ff00ff";\r
-       \r
-       if (widget.preferenceForKey('cssStyle_description'))\r
-               cssStyle_description = widget.preferenceForKey('cssStyle_description');\r
-       else\r
-               cssStyle_description = "";\r
-       \r
-       if (widget.preferenceForKey('cssStyle_icon'))\r
-               cssStyle_icon = widget.preferenceForKey('cssStyle_icon');\r
-       else\r
-               cssStyle_icon = "width:15px; height:15px";\r
+       }\r
 }\r
 \r
 function saveSettings()\r
 {\r
-       widget.setPreferenceForKey(monthRange.toString(), 'monthRange');\r
-       widget.setPreferenceForKey(includeTodos ? 'true' : 'false', 'includeTodos');\r
-       widget.setPreferenceForKey(useBackgroundImage ? 'true' : 'false', 'useBackgroundImage');\r
-       widget.setPreferenceForKey(showCombinedDateTime ? 'true' : 'false', 'showCombinedDateTime');\r
-       widget.setPreferenceForKey(showLocation ? 'true' : 'false', 'showLocation');\r
-       widget.setPreferenceForKey(showTodayAsText ? 'true' : 'false', 'showTodayAsText');\r
-       widget.setPreferenceForKey(todayText, 'todayText');\r
-       widget.setPreferenceForKey(tomorrowText, 'tomorrowText');\r
-       widget.setPreferenceForKey(showNowAsText ? 'true' : 'false', 'showNowAsText');\r
-       widget.setPreferenceForKey(nowText, 'nowText');\r
-       widget.setPreferenceForKey(dateSeparator, 'dateSeparator');\r
-       widget.setPreferenceForKey(dateFormat, 'dateFormat');\r
-       widget.setPreferenceForKey(weekDayLength.toString(), 'weekDayLength');\r
-       widget.setPreferenceForKey(updateDataInterval.toString(), 'updateDataInterval');\r
-       widget.setPreferenceForKey(calendarApp.toString(), 'calendarApp');\r
-       widget.setPreferenceForKey(eventsPerWidget.toString(), 'eventsPerWidget');\r
-       widget.setPreferenceForKey(showNothingText ? 'true' : 'false', 'showNothingText');\r
-       widget.setPreferenceForKey(nothingText, 'nothingText');\r
-       widget.setPreferenceForKey(enableDaylightSaving ? 'true' : 'false', 'enableDaylightSaving');\r
-       \r
-       widget.setPreferenceForKey(cssStyle_background, 'cssStyle_background');\r
-       widget.setPreferenceForKey(cssStyle_backgroundFullscreen, 'cssStyle_backgroundFullscreen');\r
-       widget.setPreferenceForKey(cssStyle_weekDay, 'cssStyle_weekDay');\r
-       widget.setPreferenceForKey(cssStyle_date, 'cssStyle_date');\r
-       widget.setPreferenceForKey(cssStyle_today, 'cssStyle_today');\r
-       widget.setPreferenceForKey(cssStyle_tomorrow, 'cssStyle_tomorrow');\r
-       widget.setPreferenceForKey(cssStyle_time, 'cssStyle_time');\r
-       widget.setPreferenceForKey(cssStyle_now, 'cssStyle_now');\r
-       widget.setPreferenceForKey(cssStyle_description, 'cssStyle_description');\r
-       widget.setPreferenceForKey(cssStyle_icon, 'cssStyle_icon');\r
+       for (var key in config) {\r
+               if (config[key].Type == 'Int')\r
+                       widget.setPreferenceForKey(config[key].Value.toString(), key);\r
+               else if (config[key].Type == 'String')\r
+                       widget.setPreferenceForKey(config[key].Value, key);\r
+               else if (config[key].Type == 'Bool')\r
+                       widget.setPreferenceForKey(config[key].Value ? 'true' : 'false', key);\r
+               else if (config[key].Type == 'Enum')\r
+                       widget.setPreferenceForKey(config[key].Value, key);\r
+               else if (config[key].Type == 'UID')\r
+                       widget.setPreferenceForKey(config[key].Value.toString(), key);\r
+       }\r
 }\r
 \r
 function toggleVisibility(elementId)\r
@@ -1090,7 +1015,7 @@ function showFullscreen()
 \r
 function updateHomescreen()\r
 {\r
-       if (useBackgroundImage) {\r
+       if (config['useBackgroundImage'].Value) {\r
                // check for screen rotation\r
                if (orientation != 'portrait' && screen.width == 360 && screen.height == 640) {\r
                        window.widget.prepareForTransition("fade");\r