MozillaZine

Task pre fill description

For discussing the Mozilla Calendar, Sunbird and Lightning projects.
Caeles
 
Posts: 7
Joined: February 23rd, 2018, 5:54 am

Post Posted March 2nd, 2018, 6:02 am

Hi all,

how i can pre fill description in task
can i hack the todo.js in calendar ?

thanks all

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

Post Posted March 2nd, 2018, 8:15 am

I set a description for a new task with the userChromeJS extension. (for advanced users only)

Code: Select all
/* Thunderbird userChrome.js */

(function(){

if (location == "chrome://calendar/content/calendar-event-dialog.xul") {

  setTimeout(function () {

    var iframe = document.getElementById("lightning-item-panel-iframe");
    var win = iframe.contentWindow;
    if (win.getElementValue("item-title") == "New Task" &&
        win.getElementValue("item-description") == "") {
      win.setElementValue("item-description", "Abracadabra");
    }

  }, 1000);

}

})();

http://userchromejs.mozdev.org/
http://userchromejs.mozdev.org/faq.html

Instructions:

1. install userChromeJS extension
2. close email client
3. create or edit the userChrome.js file in the chrome folder in the profile folder
4. open email client with the -purgecaches command line option

i.e.

thunderbird.exe -purgecaches
ThunderbirdPortable.exe -purgecaches

You have to purge the caches only after creating or editing the userChrome.js file.

userChromeJS 2.0 (signed)
Lightning 5.4.6
Thunderbird 52.6.0
Windows 7 SP1 32-bit

Caeles
 
Posts: 7
Joined: February 23rd, 2018, 5:54 am

Post Posted March 7th, 2018, 10:46 am

Thanks for you response
i think i did somethign wrong about it

here is my chrome.js
Code: Select all
/*
 * userChromeJS
 *
 * This file can be used to customize the functioning of Mozilla's user
 * interface.  Usage and syntax follow below; for useful code snippets see
 * http://mozilla.zeniko.ch/userchrome.js.html.
 *
 * Examples:
 * setTimeout(function() { document.title = "A new title for every window" }, 2000);
 *
 * if (location == "chrome://browser/content/browser.xul") {
 *   alert("Script loaded in main browser only");
 * }
 *
 * // DOMi window
 * if (location == "chrome://inspector/content/inspector.xul") {
 *    // Move Urlbar box to main toolbar
 *    var tb = document.getElementById('bxURLBar');
 *    var el = document.getElementById('mbrInspectorMain');
 *    if (tb && el) el.appendChild(tb, el.firstChild);
 * }
 *
 * NOTE: userChromeJS includes an 'import' function to facilitate file management.
 * An absolute path or relative path with Directory name property token can be
 * used, as follows:
 *
 * // Single file (javascript .js or overlay .xul file)
 * userChrome.import("Full file path");
 * userChrome.import("Relative file path", "Token");
 * // All .js and .xul files in a folder will be loaded.
 * userChrome.import("Full file folder path");
 * userChrome.import("Relative file folder path/name", "Token");
 * userChrome.import("*", "Token");
 *
 * NOTE: absolute windows files and folders must be have backslash escaped:
 * "C:\\Program Files\\Mozilla\\scripts\\myscript.js"
 *
 * Examples:
 * // Import script in [ProfileDir]/chrome/scripts/myscript.js
 * userChrome.import("scripts/myscript.js", "UChrm");
 * // Import script in [Profiles]/scripts/myscript.js (share same script in
 * // multiple profiles
 * userChrome.import("scripts/myscript.js", "DefProfRt");
 * // All .js or .xul in profile chrome directory
 * userChrome.import("*", "UChrm");
 * // Import overlay
 * userChrome.import("C:\\Program Files\\Mozilla\\scripts\\myOverlay.xul");
 * // Import everything in Desktop folder /scripts
 * userChrome.import("scripts", "Desk");
 * // Perhaps the only thing you need in this file..
 * if (location == "chrome://browser/content/browser.xul") {
 *  userChrome.import("scripts", "DefProfRt");
 * }
 *
 * NOTE: for a full listing of directory tokens see the two links found here:
 * https://developer.mozilla.org/en/Code_snippets/File_I%2f%2fO#Getting_special_files
 * // What's the path for a token?  This will print it in the console..
 * userChrome.log(userChrome.getAbsoluteFile("Desk").path, "getAbsoluteFile:'Desk'");
 *
 * NOTE: userChromeJS includes a log function, invoked as follows:
 * userChrome.log("string1", ["string2"])
 * Example:
 * userChrome.log("hello world!", "myscript.js");
 * Results in a console message:
 * 2009-05-22 18:07:40 userChromeJS.js::myscript.js: hello world!
 *
 * NOTE: the date format for the userChrome.log console logger may be user defined:
 * Example:
 * userChrome.dateFormat = "%Y-%m-%d %H:%M:%S";
 *
 * NOTE: the default charSet is "UTF-8"; for code using the 'import' or
 *       'importFolder' functions to manage files, the charSet for subscript loader
 *       may be user defined, prior to calling the import or importFolder functions:
 * Example:
 * userChrome.charSet = "UTF-8";
 *
 */* Thunderbird userChrome.js */

(function(){

if (location == "chrome://calendar/content/calendar-event-dialog.xul") {

  setTimeout(function () {

    var iframe = document.getElementById("lightning-item-panel-iframe");
    var win = iframe.contentWindow;
    if (win.getElementValue("item-title") == "New Task" &&
        win.getElementValue("item-description") == "") {
      win.setElementValue("item-description", "Abracadabra");
    }




thanks

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

Post Posted March 7th, 2018, 7:17 pm

The file name is wrong. The file contents are wrong.

P.S.

If you are not an English user, then you would need to change the "New Task" string to another language.

Code: Select all
alert(cal.calGetString("calendar-event-dialog", "newTask")); // New Task

Caeles
 
Posts: 7
Joined: February 23rd, 2018, 5:54 am

Post Posted March 15th, 2018, 4:14 am

thanks for your advice but this don't work
i tried with this but the description text wont appear

thanks Morat for your support

Return to Calendar


Who is online

Users browsing this forum: No registered users and 4 guests