How to display Start and END of an event

For discussing the Mozilla Calendar, Sunbird and Lightning projects.
User avatar
WaltS48
Posts: 5141
Joined: May 7th, 2010, 9:38 am
Location: Pennsylvania, USA

Re: How to display Start and END of an event

Post by WaltS48 »

fredcom wrote:Hi,
back again with problem...
After Thunderbird new release, I'm unable to configure the "formattime (endtime)".
The {e2fda1a4-762b-4020-b5ad-a41df1933103}.xpi file seems to be no longer available in folder C:\Users\zzzz\AppData\Roaming\Thunderbird\Profiles\zzzzzz.default-release\extensions\.
So, I can't change anymore the "calendar-month-view.xml" file.

Any idea what can be done to restore the Start and End Time view?
No idea what you are talking about.

Every event I create has a start and end time.
Every task a start and due date.

If you mean Find Events, try selecting the Calendar tab.
Select Events and Tasks from the Menu bar or button.
Enable Find Events.
Linux Desktop - AMD Athlon(tm) II X3 455 3.3GHz | 8.0GB RAM | GeForce GT 630
Windows Notebook - AMD A8 7410 2.2GHz | 6.0GB RAM | AMD Radeon R5
morat
Posts: 6406
Joined: February 3rd, 2009, 6:29 pm

Re: How to display Start and END of an event

Post by morat »

@fredcom

The code line is in chrome://calendar/content/calendar-month-view.js in Thunderbird 78.

I wouldn't the hack the calendar-month-view.js file in the omni.ja archive. (too much trouble)

Reference
http://searchfox.org/comm-esr68/search? ... (startTime
http://searchfox.org/comm-esr78/search? ... (startTime
fredcom
Posts: 24
Joined: August 25th, 2014, 6:21 am

Re: How to display Start and END of an event

Post by fredcom »

Thank you so much Morat, it works as expected.
I really needed this function as i mostly work on the month view.
Hope, one day, it will be implemented in standard in the Thunderbird calendar.

Pictures before / after :
Image
Image

According to morat explanations, my procedure:
- close Thunderbird;
- created a point of restauration in Windows (to be able to go back if thing goes wrong);
- make a copy of my thunderbird profile (to be able to desinstall/reinstall if thing goes wrong);
- copy "omni.ja" file in C:\Program Files (x86)\Mozilla Thunderbird;
- paste "omni.ja" in a work folder;
- rename "omni.ja" as "omni.zip", and extract with 7zip in a new folder;
- in this folder, navigate to chrome/calendar/content and copy "calendar-month-view.js";
- paste "calendar-month-view.js" in the work folder;
- open it with a source code editor (Notepad++ works great);
- at the end of the code, find :
} else if (comp == 1) {
icon.setAttribute("type", "start");
label.value = formatter.formatTime(startTime);
} else {
label.value = formatter.formatTime(startTime);


and change the last line to have :
} else if (comp == 1) {
icon.setAttribute("type", "start");
label.value = formatter.formatTime(startTime);
} else {
label.value = formatter.formatTime(startTime) + " " + formatter.formatTime(endTime);


then save the file;
- copy and paste this new "calendar-month-view.js" in the chrome/calendar/content (so, it will replace the original one);
- up 3 times in the folder, then Select all the files and folders;
Image
- right_click/send_to/comressed_folder (i don't use 7zip to compress, but the one with windows explorer, don't know if it's mandatory but it works without corruption);
- rename the new zip file as "omni.ja";
- be sure that steps 1 and 2 and 3 were done, it may save your life ;
- navigate to C:\Program Files (x86)\Mozilla Thunderbird, and rename the original "onmi.ja" as "omni.ja_master" (another way to go back if trouble...);
- copy the new "omni.ja" in C:\Program Files (x86)\Mozilla Thunderbird;
- start Thunderbird.
morat
Posts: 6406
Joined: February 3rd, 2009, 6:29 pm

Re: How to display Start and END of an event

Post by morat »

You will need to redo the hack after each minor update.

I think it isn't possible to accomplish the same thing with an extension.

For example, Casey uses the chrome.manifest file to override a chrome file in TB 68, but that isn't possible in TB 78.

More info
http://thunderbird.topicbox.com/groups/ ... 2a7c695190

Search Results Sort By Date Not Relevance by Casey
http://addons.thunderbird.net/thunderbird/addon/265079

And AFAIK, you can't redefine custom elements.

Code: Select all

customElements.define("calendar-month-day-box-item", MozCalendarMonthDayBoxItem);
fredcom
Posts: 24
Joined: August 25th, 2014, 6:21 am

Re: How to display Start and END of an event

Post by fredcom »

Hi,
the hack just ended with the last release :-(
As said by morat, I had to redo the hack after each new release, ans it works for more than a year.

I thought that it was due to a modification in the "calendar-month-view.js" in the chrome/calendar/content.
And yes,"calendar-month-view.js" is now bigger.
But I found code lines who were closed to what I need :

Code: Select all

 set occurrence(val) {
      cal.ASSERT(!this.mOccurrence, "Code changes needed to set the occurrence twice", true);
      this.mOccurrence = val;
      let labelTime;
      if (val.isEvent()) {
        let type;
        if (!val.startDate.isDate) {
          let timezone = this.calendarView ? this.calendarView.mTimezone : cal.dtz.defaultTimezone;
          let parentDate = this.parentBox.date;
          let parentTime = cal.createDateTime();
          parentTime.resetTo(parentDate.year, parentDate.month, parentDate.day, 0, 0, 0, timezone);
          let startTime = val.startDate.getInTimezone(timezone);
          let endTime = val.endDate.getInTimezone(timezone);
          let nextDay = parentTime.clone();
          nextDay.day++;
          let comp = endTime.compare(nextDay);
          if (startTime.compare(parentTime) == -1) {
            if (comp == 1) {
              type = "continue";
            } else if (comp == 0) {
              type = "start";
            } else {
              type = "end";
              labelTime = endTime;
            }
          } else if (comp == 1) {
            type = "start";
            labelTime = startTime;
          } else {
            labelTime = startTime;
I think that the very last line is the important one...

Previously (before the last releases of TB), I made the change like that :

Code: Select all

    } else if (comp == 1) {
          icon.setAttribute("type", "start");
          label.value = formatter.formatTime(startTime);
        } else {
          label.value = formatter.formatTime(startTime) + " " + formatter.formatTime(endTime);
So, I tried to modify in the same way (and recompile, and paste the new omni.ja, and -purgecaches):

Code: Select all

          } else if (comp == 1) {
            type = "start";
            labelTime = startTime;
          } else {
            labelTime = startTime;
to :

Code: Select all

          } else if (comp == 1) {
            type = "start";
            labelTime = startTime;
          } else {
            labelTime = startTime + endTime;
but it doesn't work (all my events stay hidden).

I think that this is "endTime" that is not reconized. Maybe

Please, any idea to get back this so useful hack?
morat
Posts: 6406
Joined: February 3rd, 2009, 6:29 pm

Re: How to display Start and END of an event

Post by morat »

Try this:

Code: Select all

- timeLabel.textContent = formatter.formatTime(labelTime);
+ timeLabel.textContent = formatter.formatTime(startTime) + " " + formatter.formatTime(endTime);
Reference
http://searchfox.org/comm-esr78/search? ... (startTime
http://searchfox.org/comm-esr91/search? ... &path=view
fredcom
Posts: 24
Joined: August 25th, 2014, 6:21 am

Re: How to display Start and END of an event

Post by fredcom »

Hi morat,
thanks for your answer.
I tried :

Code: Select all

- timeLabel.textContent = formatter.formatTime(labelTime);
+ timeLabel.textContent = formatter.formatTime(startTime) + " " + formatter.formatTime(endTime);
but also :

Code: Select all

- timeLabel.textContent = formatter.formatTime(labelTime);
+ timeLabel.textContent = startTime + " " + endTime;
but it doesn't work, the result is no more events, or just a compact blue line without letters.
When i revert back to :

Code: Select all

 timeLabel.textContent = formatter.formatTime(labelTime);
it's working again with only the startTime -> my problem is not the compilation.

Any more idea for testing?
morat
Posts: 6406
Joined: February 3rd, 2009, 6:29 pm

Re: How to display Start and END of an event

Post by morat »

Does the following hack fail as well?

Code: Select all

- timeLabel.textContent = formatter.formatTime(labelTime);
+ timeLabel.textContent = formatter.formatTime(labelTime) + " " + "X";
Try running the following code to show the timeLabels using the error console.

Code: Select all

(function () {
  var timeLabels = document.querySelectorAll(".item-time-label");
  var out = [];
  out.push("timeLabels.length = " + timeLabels.length);
  out.push("");
  for (var i = 0; i < timeLabels.length; i++) {
    if (timeLabels[i].textContent) {
      out.push(timeLabels[i].textContent);
    }
  }
  alert(out.join("\n"));
})();
Does the timeLabels have an "X" at the end?

e.g. 12:30 PM X
fredcom
Posts: 24
Joined: August 25th, 2014, 6:21 am

Re: How to display Start and END of an event

Post by fredcom »

-With the original code in "calendar-month-view.js" :

Code: Select all

timeLabel.textContent = formatter.formatTime(labelTime);
the test result is :
Image

-With "X" modification

Code: Select all

- timeLabel.textContent = formatter.formatTime(labelTime);
+ timeLabel.textContent = formatter.formatTime(labelTime) + " " + "X";
the result is :
Image
which seems OK.

-And when i try :

Code: Select all

- timeLabel.textContent = formatter.formatTime(labelTime);
+ timeLabel.textContent = formatter.formatTime(startTime) + " " + formatter.formatTime(endTime);
the resul is :
Image
and in the console i have these errors :
Image
--> endTime seems not defined
morat
Posts: 6406
Joined: February 3rd, 2009, 6:29 pm

Re: How to display Start and END of an event

Post by morat »

Try this:

Code: Select all

- timeLabel.textContent = formatter.formatTime(labelTime);
+ if (startTime === undefined || endTime === undefined) {
+   timeLabel.textContent = formatter.formatTime(labelTime);
+ } else {
+   timeLabel.textContent = formatter.formatTime(startTime) + " " + formatter.formatTime(endTime);
+ }
fredcom
Posts: 24
Joined: August 25th, 2014, 6:21 am

Re: How to display Start and END of an event

Post by fredcom »

Hi morat,
Still no display at all of the dated events.
I've these errors :
Image
morat
Posts: 6406
Joined: February 3rd, 2009, 6:29 pm

Re: How to display Start and END of an event

Post by morat »

Sorry, I screwed up the last answer.

variable === undefined vs. typeof variable === "undefined" in JavaScript
http://www.geeksforgeeks.org/variable-u ... avascript/

Try this:

Code: Select all

- timeLabel.textContent = formatter.formatTime(labelTime);
+ if (typeof startTime === "undefined" || typeof endTime === "undefined") {
+   timeLabel.textContent = formatter.formatTime(labelTime);
+ } else {
+   timeLabel.textContent = formatter.formatTime(startTime) + " " + formatter.formatTime(endTime);
+ }
fredcom
Posts: 24
Joined: August 25th, 2014, 6:21 am

Re: How to display Start and END of an event

Post by fredcom »

With the last code, there is visually no difference with the former code. No errors in the console.

So,I tried :

Code: Select all

- timeLabel.textContent = formatter.formatTime(labelTime);
+ if (typeof startTime === "undefined" || typeof endTime === "undefined") {
+   timeLabel.textContent = "Z";
+ } else {
+   timeLabel.textContent = formatter.formatTime(startTime) + " " + formatter.formatTime(endTime);
+ }
and the result for the Timelabel is :
Image

I also tried :

Code: Select all

- timeLabel.textContent = formatter.formatTime(labelTime);
+ if (typeof startTime === "undefined" || typeof endTime === "undefined") {
+   timeLabel.textContent = "Z";
+ } else {
+   timeLabel.textContent = "X" + " " + "Y";
+ }
and the result is the same (still no errors in the console):
Image
morat
Posts: 6406
Joined: February 3rd, 2009, 6:29 pm

Re: How to display Start and END of an event

Post by morat »

Okay. I got it working. The problem was the scope of the startTime and endTime variables.

let statement
http://developer.mozilla.org/docs/Web/J ... ements/let

Try this:

Code: Select all

- let startTime = val.startDate.getInTimezone(timezone);
- let endTime = val.endDate.getInTimezone(timezone);
+ var startTime = val.startDate.getInTimezone(timezone);
+ var endTime = val.endDate.getInTimezone(timezone);

Code: Select all

- timeLabel.textContent = formatter.formatTime(labelTime);
+ if (typeof startTime === "undefined" || typeof endTime === "undefined") {
+   timeLabel.textContent = formatter.formatTime(labelTime);
+ } else {
+   timeLabel.textContent = formatter.formatTime(startTime) + " " + formatter.formatTime(endTime);
+ }
Tested with:

Thunderbird Portable 91.3.2 (fresh install)
Windows 10 Pro 20H2 32-bit
fredcom
Posts: 24
Joined: August 25th, 2014, 6:21 am

Re: How to display Start and END of an event

Post by fredcom »

hip hip hip hurrah =D>
Thank you so much morat for your help and your patience.
Probably, for most of the people, this function of display is not needed, but for me it's essential.
the result :
Image
Post Reply