From 5c8ee9833f1c84e423010ada3e96f4cdb7d1c4b0 Mon Sep 17 00:00:00 2001 From: Michael Prager Date: Sat, 5 Sep 2009 21:29:00 +0200 Subject: [PATCH] * fixed memos/anniversaries showing although they have already passed * don't display weekday if date is 'Today' * changed default 'Now' color to #ff00ff to make it different from the 'Today' color * patch by pcmoore: * Fix problem with appointments starting at 12p where they would display as starting 12h later (midnight the following day) * Add a new feature to only display the time for events happening today and only the date for events beyond today (showCombinedDateTime) * Add a new feature to disable showing the location of appointments (showLocation) --- Readme.txt | 12 ++++++- comingNext/index.html | 76 +++++++++++++++++++++++++++++++----------- comingNextB/index.html | 76 +++++++++++++++++++++++++++++++----------- 3 files changed, 125 insertions(+), 39 deletions(-) diff --git a/Readme.txt b/Readme.txt index 2679f20..4686253 100644 --- a/Readme.txt +++ b/Readme.txt @@ -150,4 +150,14 @@ Changelog: - refixed problems that 1.18 should have solved (todos not showing, entries showing twice) 1.20 (2009-09-05) by Oxidative - - fixed memos to show although they have already passed \ No newline at end of file + - fixed memos/anniversaries showing although they have already passed + - don't display weekday if date is 'Today' + - changed default 'Now' color to #ff00ff to make it different from the + 'Today' color + - patch by pcmoore: + - Fix problem with appointments starting at 12p where they + would display as starting 12h later (midnight the following day) + - Add a new feature to only display the time for events happening today + and only the date for events beyond today (showCombinedDateTime) + - Add a new feature to disable showing the location of appointments + (showLocation) \ No newline at end of file diff --git a/comingNext/index.html b/comingNext/index.html index 5ce4fd4..cedf780 100644 --- a/comingNext/index.html +++ b/comingNext/index.html @@ -12,7 +12,7 @@ here you can customize background color, font color, font size etc... .date { } /* Defines the appearance of all date texts */ .today { color:#ff0000; } /* Defines the appearance of "Today" text */ .time { } /* Defines the appearance of all time texts */ -.now { color:#ff0000; } /* Defines the appearance of "Now" text */ +.now { color:#ff00ff; } /* Defines the appearance of "Now" text */ .description { } /* Defines the appearance of all event descriptions */ .icon { width:15px; height:15px; } /* Defines size and appearance of icons */ @@ -23,6 +23,8 @@ here you can customize background color, font color, font size etc... var monthRange = 2; // number of months to include in the event list var includeTodos = true; // disable to remove ToDos from event list var useBackgroundImage = true; // use background_portrait.png and background_landscape.png to fake transparency. Set to "false" to use a solid background color +var showCombinedDateTime = false;// only show the time for events happening today, otherwise just show the date +var showLocation = true; // show the location for meeting events var showTodayAsText = true; // if enabled, the current date will be shown as "Today" instead of "31.12" var todayText = 'Today'; // text to display for "Today" var showNowAsText = true; // if enabled, the appointment time will be shown as "Now" instead of "12:00" @@ -176,6 +178,7 @@ function parseDate(dateString) Wednesday, August 26, 2009 12:00:00 am Wednesday, 2009 August, 26 12:00:00 am Wednesday, 2009 August, 28 8.00.00 pm + Wednesday, 2009 August, 28 08:00:00 PM */ if (dateString == "" || dateString == null) return null; @@ -217,8 +220,10 @@ function parseDate(dateString) var hours = Number(timeArr[0]); var minutes = Number(timeArr[1]); var seconds = Number(timeArr[2]); - if (dateArr.length == 6 && dateArr[5].toLowerCase() == 'pm') + if (dateArr.length == 6 && dateArr[5].toLowerCase() == 'pm' && hours < 12) hours += 12; + if (dateArr.length == 6 && dateArr[5].toLowerCase() == 'am' && hours == 12) + hours = 0; console.info('year=' + year + ' month=' + month + ' day=' + day + ' hours=' + hours + ' minutes=' + minutes+ ' seconds=' + seconds); @@ -366,17 +371,12 @@ function updateData(){ console.info('skipped (already included) ' + entry.id); counter--; continue; - } else { + } else eventIds[entry.id] = 1; - } - - // skip events for the first panel in case this is the second one - if (panelNum == 1 && counter < eventsPerWidget + 1) - continue; // summary can be undefined! var Summary = ((entry.Summary == null) ? '' : entry.Summary); - if (entry.Type == 'Meeting' && entry.Location != ''){ + if (entry.Type == 'Meeting' && entry.Location != '' && showLocation){ Summary += ', ' + entry.Location; } @@ -400,21 +400,33 @@ function updateData(){ if (entry.Type == 'Meeting'){ var compareTime = ((endDate == null) ? date.getTime() : endDate.getTime()); if (now.getTime() > compareTime){ - console.info('skipped (already passed) ' + entry.id); + console.info('skipping Meeting (already passed) ' + entry.id); counter--; + eventIds[entry.id] = 0; continue; } } - // fix DayEvents end time. A bug in WRT causes end times to be off by +12 hours. It's possible that the event has already passed + // check if anniversary passed (not sure why they are in the list, the query was only for today - nokia?) + if (entry.Type == 'Anniversary'){ + var tmp = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0,0,0); + if ( date.getTime() < tmp.getTime() ){ + console.info('skipping Anniversary (already passed) ' + entry.id); + counter--; + eventIds[entry.id] = 0; + continue; + } + } + + // fix DayEvents end time. End times are off by 1 Second. It's possible that the event has already passed if (entry.Type == 'DayEvent' && endDate != null){ - endDate.setHours(endDate.getHours() - 12); endDate.setMinutes(endDate.getMinutes() - 1); console.info('fixing DayEvent endDate: ' + endDate); if (now.getTime() > endDate.getTime()){ - console.info('event already passed'); + console.info('event already passed ' + entry.id); counter--; - continue; + eventIds[entry.id] = 0; + continue; } } @@ -428,6 +440,12 @@ function updateData(){ } } + // skip events for the first panel in case this is the second one + if (panelNum == 1 && counter < eventsPerWidget + 1){ + console.info('skipping (already in first widget) ' + entry.id); + continue; + } + // generate html output entriesHtml += ''; if(date == null){ // some languages have very strange locale date formats, can't parse all those. Also some todos don't have dates at all. @@ -435,11 +453,31 @@ function updateData(){ }else{ var weekDay = date.toLocaleDateString().substr(0,weekDayLength); var time = formatTime(date); - date = formatDate(date, entryDate); - if( entry.Type == 'ToDo' || entry.Type == 'Anniversary' || entry.Type == 'DayEvent' ){ - entriesHtml += '' + weekDay +''+ date +''; - }else if( entry.Type == 'Meeting' || entry.Type == 'Reminder' ){ - entriesHtml += '' + weekDay +''+ date +''+ time +''; + var dateStr = formatDate(date, entryDate); + if( entry.Type == 'ToDo' || entry.Type == 'Anniversary' || entry.Type == 'DayEvent' || entry.Type == 'Reminder' ){ + // decide if we want to leave off the weekday + if (dateStr.search(/Today/) != -1) + entriesHtml += ''+ dateStr +' '; + else + entriesHtml += '' + weekDay +''+ dateStr +''; + }else if( entry.Type == 'Meeting' ){ + if (showCombinedDateTime) { + if (now.getDate() == date.getDate() && now.getMonth() == date.getMonth()) + entriesHtml += ''+ time +' '; + else { + // decide if we want to leave off the weekday + if (dateStr.search(/Today/) != -1) + entriesHtml += ''+ dateStr +' '; + else + entriesHtml += '' + weekDay +''+ dateStr +''; + } + } else { + // decide if we want to leave off the weekday + if (dateStr.search(/Today/) != -1) + entriesHtml += ''+ dateStr +' '+ time +' '; + else + entriesHtml += '' + weekDay +''+ dateStr +''+ time +''; + } } } entriesHtml += '' + Summary +''; diff --git a/comingNextB/index.html b/comingNextB/index.html index ead9bed..58181ce 100644 --- a/comingNextB/index.html +++ b/comingNextB/index.html @@ -12,7 +12,7 @@ here you can customize background color, font color, font size etc... .date { } /* Defines the appearance of all date texts */ .today { color:#ff0000; } /* Defines the appearance of "Today" text */ .time { } /* Defines the appearance of all time texts */ -.now { color:#ff0000; } /* Defines the appearance of "Now" text */ +.now { color:#ff00ff; } /* Defines the appearance of "Now" text */ .description { } /* Defines the appearance of all event descriptions */ .icon { width:15px; height:15px; } /* Defines size and appearance of icons */ @@ -23,6 +23,8 @@ here you can customize background color, font color, font size etc... var monthRange = 2; // number of months to include in the event list var includeTodos = true; // disable to remove ToDos from event list var useBackgroundImage = true; // use background_portrait.png and background_landscape.png to fake transparency. Set to "false" to use a solid background color +var showCombinedDateTime = false;// only show the time for events happening today, otherwise just show the date +var showLocation = true; // show the location for meeting events var showTodayAsText = true; // if enabled, the current date will be shown as "Today" instead of "31.12" var todayText = 'Today'; // text to display for "Today" var showNowAsText = true; // if enabled, the appointment time will be shown as "Now" instead of "12:00" @@ -176,6 +178,7 @@ function parseDate(dateString) Wednesday, August 26, 2009 12:00:00 am Wednesday, 2009 August, 26 12:00:00 am Wednesday, 2009 August, 28 8.00.00 pm + Wednesday, 2009 August, 28 08:00:00 PM */ if (dateString == "" || dateString == null) return null; @@ -217,8 +220,10 @@ function parseDate(dateString) var hours = Number(timeArr[0]); var minutes = Number(timeArr[1]); var seconds = Number(timeArr[2]); - if (dateArr.length == 6 && dateArr[5].toLowerCase() == 'pm') + if (dateArr.length == 6 && dateArr[5].toLowerCase() == 'pm' && hours < 12) hours += 12; + if (dateArr.length == 6 && dateArr[5].toLowerCase() == 'am' && hours == 12) + hours = 0; console.info('year=' + year + ' month=' + month + ' day=' + day + ' hours=' + hours + ' minutes=' + minutes+ ' seconds=' + seconds); @@ -366,17 +371,12 @@ function updateData(){ console.info('skipped (already included) ' + entry.id); counter--; continue; - } else { + } else eventIds[entry.id] = 1; - } - - // skip events for the first panel in case this is the second one - if (panelNum == 1 && counter < eventsPerWidget + 1) - continue; // summary can be undefined! var Summary = ((entry.Summary == null) ? '' : entry.Summary); - if (entry.Type == 'Meeting' && entry.Location != ''){ + if (entry.Type == 'Meeting' && entry.Location != '' && showLocation){ Summary += ', ' + entry.Location; } @@ -400,21 +400,33 @@ function updateData(){ if (entry.Type == 'Meeting'){ var compareTime = ((endDate == null) ? date.getTime() : endDate.getTime()); if (now.getTime() > compareTime){ - console.info('skipped (already passed) ' + entry.id); + console.info('skipping Meeting (already passed) ' + entry.id); counter--; + eventIds[entry.id] = 0; continue; } } - // fix DayEvents end time. A bug in WRT causes end times to be off by +12 hours. It's possible that the event has already passed + // check if anniversary passed (not sure why they are in the list, the query was only for today - nokia?) + if (entry.Type == 'Anniversary'){ + var tmp = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0,0,0); + if ( date.getTime() < tmp.getTime() ){ + console.info('skipping Anniversary (already passed) ' + entry.id); + counter--; + eventIds[entry.id] = 0; + continue; + } + } + + // fix DayEvents end time. End times are off by 1 Second. It's possible that the event has already passed if (entry.Type == 'DayEvent' && endDate != null){ - endDate.setHours(endDate.getHours() - 12); endDate.setMinutes(endDate.getMinutes() - 1); console.info('fixing DayEvent endDate: ' + endDate); if (now.getTime() > endDate.getTime()){ - console.info('event already passed'); + console.info('event already passed ' + entry.id); counter--; - continue; + eventIds[entry.id] = 0; + continue; } } @@ -428,6 +440,12 @@ function updateData(){ } } + // skip events for the first panel in case this is the second one + if (panelNum == 1 && counter < eventsPerWidget + 1){ + console.info('skipping (already in first widget) ' + entry.id); + continue; + } + // generate html output entriesHtml += ''; if(date == null){ // some languages have very strange locale date formats, can't parse all those. Also some todos don't have dates at all. @@ -435,11 +453,31 @@ function updateData(){ }else{ var weekDay = date.toLocaleDateString().substr(0,weekDayLength); var time = formatTime(date); - date = formatDate(date, entryDate); - if( entry.Type == 'ToDo' || entry.Type == 'Anniversary' || entry.Type == 'DayEvent' ){ - entriesHtml += '' + weekDay +''+ date +''; - }else if( entry.Type == 'Meeting' || entry.Type == 'Reminder' ){ - entriesHtml += '' + weekDay +''+ date +''+ time +''; + var dateStr = formatDate(date, entryDate); + if( entry.Type == 'ToDo' || entry.Type == 'Anniversary' || entry.Type == 'DayEvent' || entry.Type == 'Reminder' ){ + // decide if we want to leave off the weekday + if (dateStr.search(/Today/) != -1) + entriesHtml += ''+ dateStr +' '; + else + entriesHtml += '' + weekDay +''+ dateStr +''; + }else if( entry.Type == 'Meeting' ){ + if (showCombinedDateTime) { + if (now.getDate() == date.getDate() && now.getMonth() == date.getMonth()) + entriesHtml += ''+ time +' '; + else { + // decide if we want to leave off the weekday + if (dateStr.search(/Today/) != -1) + entriesHtml += ''+ dateStr +' '; + else + entriesHtml += '' + weekDay +''+ dateStr +''; + } + } else { + // decide if we want to leave off the weekday + if (dateStr.search(/Today/) != -1) + entriesHtml += ''+ dateStr +' '+ time +' '; + else + entriesHtml += '' + weekDay +''+ dateStr +''+ time +''; + } } } entriesHtml += '' + Summary +''; -- 2.39.2