MozillaZine

How can I change default reminder times per calendar?

For discussing the Mozilla Calendar, Sunbird and Lightning projects.
Weboh
 
Posts: 12
Joined: October 31st, 2014, 4:08 pm

Post Posted October 26th, 2016, 2:45 pm

I have two different calendars. I want both of them to get reminders, but I want one to give me reminders a day in advance and the other to give me reminders an hour in advance. I know I can just manually change the time each time I add something to the calendar, but I'd rather Thunderbird do it automatically since I always want the same period for each calendar. Is there a default way to do this? If not, is there an addon that does this? Thanks.

Daifne
Moderator

User avatar
 
Posts: 122999
Joined: July 31st, 2005, 9:17 pm
Location: Where the Waters Meet, Wisconsin

Post Posted October 27th, 2016, 7:03 am

Moving to the Calendar Forum

morat
 
Posts: 2447
Joined: February 3rd, 2009, 6:29 pm

Post Posted October 28th, 2016, 8:10 am

You would need to hack the extension.

* edit extensions\{e2fda1a4-762b-4020-b5ad-a41df1933103}\chrome\calendar\content\calendar\calendar-event-dialog.js
* restart application

Code: Select all
  // load reminder details
  loadReminders(item.getAlarms({}));
+ if (cal.isEvent(item) &&
+     getElementValue("item-title") == "New Event" &&
+     document.getElementById("item-alarm").selectedIndex == 0) {
+   if (item.calendar.name == "Alpha") {
+     document.getElementById("item-alarm").selectedIndex = 7; // 1 hour before
+   }
+   if (item.calendar.name == "Beta") {
+     document.getElementById("item-alarm").selectedIndex = 11; // 1 day before
+   }
+ }

Remember to edit the calendar names, Alpha & Beta, in the code.

If you see the chrome.jar file in the extension folder, then remove the extension in the Add-ons Manager and install the extension from the AMO page, then the chrome folder appears instead of the chrome.jar file.

Lightning
http://addons.mozilla.org/thunderbird/addon/2313

Similar thread: viewtopic.php?f=46&t=2864153

Weboh
 
Posts: 12
Joined: October 31st, 2014, 4:08 pm

Post Posted November 1st, 2016, 10:52 am

That seems to make events not be able to be created. Now it makes a task when event is selected. The change stayed even after I deleted the extra code.

I just inserted the code on top of the load reminder details section.
Thanks for the help.
Last edited by Weboh on November 13th, 2016, 7:33 pm, edited 1 time in total.

morat
 
Posts: 2447
Joined: February 3rd, 2009, 6:29 pm

Post Posted November 1st, 2016, 12:04 pm

Weboh wrote:The change stayed even after I deleted the extra code.

Normally, all you need to do is remove the extra code and restart the application.

Try this:

1. remove the Lightning extension in the Add-ons Manager
2. download the Lightning extension from the AMO page

http://addons.mozilla.org/thunderbird/addon/2313

3. install the Lightning extension from file
4. open the application with the purgecaches flag

i.e.

thunderbird.exe -purgecaches
ThunderbirdPortable.exe -purgecaches

These steps should reset the extension, but not your settings.

Weboh
 
Posts: 12
Joined: October 31st, 2014, 4:08 pm

Post Posted November 13th, 2016, 9:50 pm

That worked and now I have the regular create event dialog back. I recently tried this again, trying systematically taking out the closing parenthesis, but that didn't work either. At least this time removing the code defaulted it to normal. I added it like so:
Code: Select all
  // load reminder details
  loadReminders(item.getAlarms({}));
+ if (cal.isEvent(item) &&
+     getElementValue("item-title") == "New Event" &&
+     document.getElementById("item-alarm").selectedIndex == 0) {
+   if (item.calendar.name == "Alpha") {
+     document.getElementById("item-alarm").selectedIndex = 7; // 1 hour before
+   }
+   if (item.calendar.name == "Beta") {
+     document.getElementById("item-alarm").selectedIndex = 11; // 1 day before
+   }
+ }
// hide rows based on if this is an event or todo
    updateStyle();

    // Synchronize link-top-image with keep-duration-button status
    let keepAttribute = document.getElementById("keepduration-button").getAttribute("keep") == "true";
    setBooleanAttribute("link-image-top", "keep", keepAttribute);

    updateDateTime();
etc.
Am I doing anything wrong? Did you accidentally give me wrong code? What can I do? Thanks.

morat
 
Posts: 2447
Joined: February 3rd, 2009, 6:29 pm

Post Posted November 14th, 2016, 2:56 am

Are you correctly editing the file? Did you remove the leftmost plus signs? A leftmost plus sign indicates you should add the line. It is not part of the code.

Find:

Code: Select all
// load reminder details
loadReminders(item.getAlarms({}));

// hide rows based on if this is an event or todo
updateStyle();

Replace with:

Code: Select all
// load reminder details
loadReminders(item.getAlarms({}));
if (cal.isEvent(item) &&
    getElementValue("item-title") == "New Event" &&
    document.getElementById("item-alarm").selectedIndex == 0) {
  if (item.calendar.name == "Alpha") {
    document.getElementById("item-alarm").selectedIndex = 7; // 1 hour before
  }
  if (item.calendar.name == "Beta") {
    document.getElementById("item-alarm").selectedIndex = 11; // 1 day before
  }
}

// hide rows based on if this is an event or todo
updateStyle();

If you are correctly editing the file, then there may be a conflict with another extension. I don't know.

The code works for me. I tested it with the following setup.

Lightning 4.7.4
Thunderbird 45.4.0
Windows 7 SP1 32-bit

Weboh
 
Posts: 12
Joined: October 31st, 2014, 4:08 pm

Post Posted November 18th, 2016, 9:45 pm

I had an ancient version of Lightning installed and added the pluses to the code. It should work now. Thanks.

Return to Calendar


Who is online

Users browsing this forum: No registered users and 4 guests