X-Git-Url: https://code.delx.au/comingnext/blobdiff_plain/aea9742dab7d9dc219a17fbdb82fd4d9224aaed9..5c8ee9833f1c84e423010ada3e96f4cdb7d1c4b0:/comingNextB/index.html diff --git a/comingNextB/index.html b/comingNextB/index.html index 4a5c0d6..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,16 +371,12 @@ function updateData(){ console.info('skipped (already included) ' + entry.id); counter--; continue; - } else { + } else eventIds[entry.id] = 1; - } - - 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; } @@ -391,31 +392,58 @@ function updateData(){ // Convert date/time string to Date object var date = parseDate(entryDate); - console.info(date); + console.info('date: ' + date); + var endDate = ((entryEndTime == null) ? null : parseDate(entryEndTime)); + console.info('endDate: ' + endDate); - // check if event has already passed - if (entry.Type == 'Meeting' || entry.Type == 'Reminder'){ - if (entryEndTime == null){ - if (now.getTime() > date.getTime()){ - counter--; - continue; - } - }else if (entryEndTime != null){ - var endDate = parseDate(entryEndTime); - if (now.getTime() > endDate.getTime()){ - counter--; - continue; - } + // check if meeting event has already passed + if (entry.Type == 'Meeting'){ + var compareTime = ((endDate == null) ? date.getTime() : endDate.getTime()); + if (now.getTime() > compareTime){ + console.info('skipping Meeting (already passed) ' + entry.id); + counter--; + eventIds[entry.id] = 0; + continue; } } + // 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.setMinutes(endDate.getMinutes() - 1); + console.info('fixing DayEvent endDate: ' + endDate); + if (now.getTime() > endDate.getTime()){ + console.info('event already passed ' + entry.id); + counter--; + eventIds[entry.id] = 0; + continue; + } + } + // check if the event is currently taking place - if (entryStartTime != null && entryEndTime != null && date != null) + if (entryStartTime != null && entryEndTime != null && date != null && endDate != null) { // check if we are between start and endtime - var endDate = parseDate(entryEndTime); - if (endDate != null && (date.getTime() < now.getTime()) && (now.getTime() < endDate.getTime())) + if ((date.getTime() < now.getTime()) && (now.getTime() < endDate.getTime())) { date = now; // change appointment date/time to now + console.info('event is currently taking place: ' + date); + } + } + + // 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 @@ -425,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 +'';