MozillaZine

[Ext] userChrome.js

Announce and Discuss the Latest Theme and Extension Releases.
Old Greg S
 
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Post Posted December 26th, 2006, 11:46 am

Zoolcar9 wrote:
Greg S wrote:Does window.status not work as far as using the clock in there in place of the Done label? I know that it works from within a page but can't get it to work as previously mentioned.

Code: Select all
document.getElementById("statusbar-display").label = timestr

or
Code: Select all
document.getElementById("statusbar-display").setAttribute("label", timestr);





pile0nades wrote:
Does this work?

It does for me. As a matter of fact either of the one's Zoolcar9 posted above worked for me. Although the days are wrong as mentioned. Sunday needs to come before Monday,lol.


I had tried the above before and after asking for help on this with no luck. pileOnades kindly helped me figure out the problem which turned out to be that I didn't have userChrome.js installed on the profile I was trying to use it on,lol. It works great but when hovering over links I only had the 1 second to view what was in the statusbar display which wasn't enough time. My fix for that was a script for showing tooltips when hovering over links which worked well also. I've since decided on using the userChrome.xul to ID a stautusbarpanel in addition to userChrome.js with document.getElementById for it and it works great also. Of course I don't have the nice Options panel like the statusbar clock extension does for changing the time format(easily edited though) but I never changed the time format using the Options panel anyway.


I have an unrelated question. If I have a button with a label that when clicked the label changes via userchrome.js, how can I get the label to change back to it's original label? Simple example, initially the button would say Hi, when clicked it would say Bye. I want it to say Hi when clicked again, if possible.

pile0nades
 
Posts: 756
Joined: May 15th, 2005, 2:31 am

Post Posted December 26th, 2006, 11:52 am

Code: Select all
var button = document.getElementById("button");
button.addEventListener("click", switchlabel, false);

function switchlabel() {
  var button = document.getElementById("button");
  if(button.getAttribute("label") == "Hi") button.setAttribute("label", "Bye");
  else button.setAttribute("label", "Hi");
}
Linkify bug numbers - test: bug 258287

DynaBMan

User avatar
 
Posts: 383
Joined: November 15th, 2003, 9:46 pm
Location: Oklahoma

Post Posted December 26th, 2006, 12:21 pm

pile0nades wrote:
Code: Select all
function Clock() {
    var title = content.document.title;
    var days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];
    var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
    var D = new Date();
    var day = days[D.getDay()];
    var month = months[D.getMonth()];
    var year = D.getFullYear();
    var hours = D.getHours();
    var min = D.getMinutes();
    var sec = D.getSeconds();
    var Time = ((hours > 12) ? hours - 12 :(hours == 0) ? 12 :hours);
    Time += ((min < 10) ? ":0" : ":") + min;
    Time += ((sec <10>= 12) ? " PM" : " AM");
    var date = "*   Greg's Firefox 1.5   *   " + day + ", " + month + " " + D.getDate() + ", " + year;
    var timestr = date + "   " + Time;
    document.getElementById("statusbar-display").setAttribute("label", timestr);
    setTimeout("Clock()", 100);
  }

Clock();


Does this work?


I have it working on my work installation of Firefox except it is showing in my status bar. I would like to have it in the title bar, if possible. I did fix the days so it displays the correct day.
LJ
My best friend is my wife!!
Political Realities

Old Greg S
 
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Post Posted December 26th, 2006, 12:22 pm

pile0nades wrote:
Code: Select all
var button = document.getElementById("button");
button.addEventListener("click", switchlabel, false);

function switchlabel() {
  var button = document.getElementById("button");
  if(button.getAttribute("label") == "Hi") button.setAttribute("label", "Bye");
  else button.setAttribute("label", "Hi");
}


I should have mentioned, my label after being clicked is constantly changing

DynaBMan

User avatar
 
Posts: 383
Joined: November 15th, 2003, 9:46 pm
Location: Oklahoma

Post Posted December 26th, 2006, 4:45 pm

Okay, I have it working in Thunderbird and in Firefox, in the title bar. The only problem I am having is with Thunderbird, where the title bar will flash the title when I change folders and then the time/date display completely takes the place of the title. It is working great in Firefox so I would assume the code has to be different for Thunderbird. I have no idea what it would be. Thanks for all the help.
LJ
My best friend is my wife!!
Political Realities

DynaBMan

User avatar
 
Posts: 383
Joined: November 15th, 2003, 9:46 pm
Location: Oklahoma

Post Posted December 26th, 2006, 7:03 pm

Not sure if this will help or not, but below is the actual code I am using for both Firefox and Thunderbird. As I said in my post above, the clock works fine in Firefox, but in Thunderbird, the actual window title (Mozilla Thunderbird) is replaced by the clock. If I click on Local Folders or any other folder, that title flashes into the title bar only to be replaced by the clock. If I click on an actual message, the subject of that message is entered into the title bar before the clock.

Code: Select all
function Clock() {
    var title = content.document.title;
    var days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
    var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
    var D = new Date();
    var day = days[D.getDay()];
    var month = months[D.getMonth()];
    var year = D.getFullYear();
    var hours = D.getHours();
    var min = D.getMinutes();
    var sec = D.getSeconds();
    var Time = ((hours > 12) ? hours - 12 :(hours == 0) ? 12 :hours);
    Time += ((min < 10) ? ":0" : ":") + min;
    Time += ((sec <10>= 12) ? " PM" : " AM");
    var date = "" + day + ", " + month + " " + D.getDate() + ", " + year;
    var timestr = date + "   " + Time;
    document.title = title + "   " + timestr;
    setTimeout("Clock()", 100);
  }

Clock();
LJ
My best friend is my wife!!
Political Realities

DynaBMan

User avatar
 
Posts: 383
Joined: November 15th, 2003, 9:46 pm
Location: Oklahoma

Post Posted December 26th, 2006, 7:50 pm

I am wondering if it would be possible to use userchrome.js to add a context menu to the home button that would contain the menu bar items, ie: "File, Edit, etc." Could someone help me out on this one? You folks are doing pretty good so far. Thanks again for all of the help.
LJ
My best friend is my wife!!
Political Realities

DynaBMan

User avatar
 
Posts: 383
Joined: November 15th, 2003, 9:46 pm
Location: Oklahoma

Post Posted December 27th, 2006, 6:05 pm

Well, I have been trying to figure out how to add the menubar items to the context menu of the home button, but so for, I have had no luck. I have been looking at a script I found on the page below but I can't figure out what to put into that script to have the menubar. If someone could point me in the right direction, I would be glad to try and write the script myself, but I know nothing about this sort of thing.

http://zoolcar9.lhukie.net/mozilla/user ... text.uc.js
LJ
My best friend is my wife!!
Political Realities

max1million
 
Posts: 2810
Joined: November 15th, 2004, 5:03 am

Post Posted December 28th, 2006, 9:54 pm

DynaBMan:
Something like <a href="data:application/x-javascript;charset=utf-8,%0A%20%20popup.appendChild%28document.createElement%28%22menuseparator%22%29%29%3B%0A%20%20popup.appendChild%28document.getElementById%28%22file-menu%22%29%29%3B%0A%20%20popup.appendChild%28document.getElementById%28%22edit-menu%22%29%29%3B%0A%20%20popup.appendChild%28document.getElementById%28%22view-menu%22%29%29%3B%0A%20%20popup.appendChild%28document.getElementById%28%22go-menu%22%29%29%3B%0A%20%20popup.appendChild%28document.getElementById%28%22bookmarks-menu%22%29%29%3B%0A%20%20popup.appendChild%28document.getElementById%28%22tools-menu%22%29%29%3B%0A%20%20popup.appendChild%28document.getElementById%28%22helpMenu%22%29%29%3B%0A">this</a> added to the end of the first function just above })() at line #48. It should move them off the menubar to the end of the context menu. You might want to move the buttons up to the menubar and togle off the other, or optionally <a href="data:application/x-javascript;charset=utf-8,%20%20document.getElementById%28%22toolbar-menubar%22%29.setAttribute%28%22hidden%22%2C%22true%22%29%3B%0A">set the menubar to hidden</a>.

DynaBMan

User avatar
 
Posts: 383
Joined: November 15th, 2003, 9:46 pm
Location: Oklahoma

Post Posted December 29th, 2006, 5:38 am

max1million wrote:DynaBMan:
Something like <a href="data:application/x-javascript;charset=utf-8,%0A%20%20popup.appendChild%28document.createElement%28%22menuseparator%22%29%29%3B%0A%20%20popup.appendChild%28document.getElementById%28%22file-menu%22%29%29%3B%0A%20%20popup.appendChild%28document.getElementById%28%22edit-menu%22%29%29%3B%0A%20%20popup.appendChild%28document.getElementById%28%22view-menu%22%29%29%3B%0A%20%20popup.appendChild%28document.getElementById%28%22go-menu%22%29%29%3B%0A%20%20popup.appendChild%28document.getElementById%28%22bookmarks-menu%22%29%29%3B%0A%20%20popup.appendChild%28document.getElementById%28%22tools-menu%22%29%29%3B%0A%20%20popup.appendChild%28document.getElementById%28%22helpMenu%22%29%29%3B%0A">this</a> added to the end of the first function just above })() at line #48. It should move them off the menubar to the end of the context menu. You might want to move the buttons up to the menubar and togle off the other, or optionally <a href="data:application/x-javascript;charset=utf-8,%20%20document.getElementById%28%22toolbar-menubar%22%29.setAttribute%28%22hidden%22%2C%22true%22%29%3B%0A">set the menubar to hidden</a>.


Okay, that works. Now can you tell me how to create/edit the file to just show the menubar items and not the rest of the ones listed in that file? I really don't need/want the other items in the context menu.
LJ
My best friend is my wife!!
Political Realities

max1million
 
Posts: 2810
Joined: November 15th, 2004, 5:03 am

Post Posted December 30th, 2006, 12:21 am

Move menus from menubar to bookmarks toolbar button as context menu (without any others) just use <a href="data:application/x-javascript;charset=utf-8,//%20*******%20move%20menus%20from%20menubar%20to%20%0A//%20*******%20bookmarks%20toolbar%20button%20as%20context%20menu%0A%28function%28%29%20%7B%0A%20%20var%20popupset%20%3D%20document.getElementById%28%22mainPopupSet%22%29%3B%0A%20%20var%20popup%20%3D%20popupset.appendChild%28document.createElement%28%22popup%22%29%29%3B%0A%20%20popup.id%20%3D%20%22context-home-button%22%3B%0A%20%20popup.appendChild%28document.getElementById%28%22file-menu%22%29%29%3B%0A%20%20popup.appendChild%28document.getElementById%28%22edit-menu%22%29%29%3B%0A%20%20popup.appendChild%28document.getElementById%28%22view-menu%22%29%29%3B%0A%20%20popup.appendChild%28document.getElementById%28%22go-menu%22%29%29%3B%0A%20%20popup.appendChild%28document.getElementById%28%22bookmarks-menu%22%29%29%3B%0A%20%20popup.appendChild%28document.getElementById%28%22tools-menu%22%29%29%3B%0A%20%20popup.appendChild%28document.getElementById%28%22helpMenu%22%29%29%3B%0A%0A//%20*******%20to%20hide%20the%20menubar%20change%20false%20to%20true%20in%20next%20line%0A%20%20document.getElementById%28%22toolbar-menubar%22%29.setAttribute%28%22hidden%22%2C%22false%22%29%3B%0A%7D%29%28%29%0Awindow.setTimeout%28function%28%29%20%7B%0A%20%20var%20homeButton%20%3D%20document.getElementById%28%22home-button%22%29%3B%0A%20%20if%28%21homeButton%29%20return%3B%0A%20%20homeButton.setAttribute%28%22context%22%2C%20%22context-home-button%22%29%3B%0A%7D%29%3B">this</a>.

DynaBMan

User avatar
 
Posts: 383
Joined: November 15th, 2003, 9:46 pm
Location: Oklahoma

Post Posted December 30th, 2006, 6:06 am

Perfect, Max. Thanks a bunch.
LJ
My best friend is my wife!!
Political Realities

max1million
 
Posts: 2810
Joined: November 15th, 2004, 5:03 am

Post Posted December 30th, 2006, 7:12 pm

Welcome. Maybe you like a context menu for Bookmarks toolbar button Sidebar tile bar. Extension Popbok

Coce
 
Posts: 16
Joined: December 31st, 2006, 9:03 am
Location: Germany

Post Posted December 31st, 2006, 9:19 am

pile0nades wrote:
Code: Select all
function Clock() {
    var title = content.document.title;
    var days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];
    var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
    var D = new Date();
    var day = days[D.getDay()];
    var month = months[D.getMonth()];
    var year = D.getFullYear();
    var hours = D.getHours();
    var min = D.getMinutes();
    var sec = D.getSeconds();
    var Time = ((hours > 12) ? hours - 12 :(hours == 0) ? 12 :hours);
    Time += ((min < 10) ? ":0" : ":") + min;
    Time += ((sec <10>= 12) ? " PM" : " AM");
    var date = "*   Greg's Firefox 1.5   *   " + day + ", " + month + " " + D.getDate() + ", " + year;
    var timestr = date + "   " + Time;
    document.getElementById("statusbar-display").setAttribute("label", timestr);
    setTimeout("Clock()", 100);
  }

Clock();


Does this work?


Hi @ all!

This code works for me, but unfortunately this overwrites the URL displayed in the status bar, when hovering over a link with the cursor. Is iit possible, to place the clock on the right of the statusbar and leave enough space for the URL on the left?
If this is not possible, I'd like to place the clock in the toolbar, as seen on this screenshot:
Image
Is it possible to modify the code to that effect?
Is it also possible to modify the code, so the hour is shown with a leading 0? It should look like this: 05:14 PM.

Thanks in advance and sorry if my English isn't that good. See my profile for the reason. ;-)
Regards, Coce

Old Greg S
 
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Post Posted December 31st, 2006, 9:31 am

The url labels not being visible was the only thing I too didn't like about this. What I did was used userChrome.xul creating a statusbarpanel id then modified this part of the code above to the new id
Code: Select all
document.getElementById("your-new-id").setAttribute("label", timestr);


I still would like to have it in the statusbar-display if there were a fix for link hovers etc.. but I doubt this is possible due to the timeout. I hope I'm wrong though.

Return to Extension/Theme Releases


Who is online

Users browsing this forum: No registered users and 3 guests