It's late and I really don't know what I'm doing
- diesel_travis
- Posts: 133
- Joined: September 16th, 2003, 11:31 pm
- Location: Rochester, NY
- Contact:
It's late and I really don't know what I'm doing
I've never written an extension before, but I'm attempting to write one that adds 2 options to the context menu when images are right-clicked on: Zoom In, Zoom Out. Zoom In doubles the dimensions of the image, and Zoom Out halves them. I used the source from the Next/Prev Image extension as a basis, but I really am not sure what I'm doing.
Here is my source:
http://travis.servebeer.com/imagezoomer/
I've done some brief googling to no avail, but does a tutorial exist for extension writing?
I think I probably compressed the Jar and Xpi incorrectly as well. (I used winrar for the Jar and winzip for the Xpi)
Thanks in advance and I apologize for being such a n00b.
Here is my source:
http://travis.servebeer.com/imagezoomer/
I've done some brief googling to no avail, but does a tutorial exist for extension writing?
I think I probably compressed the Jar and Xpi incorrectly as well. (I used winrar for the Jar and winzip for the Xpi)
Thanks in advance and I apologize for being such a n00b.
- Pike
- Posts: 2293
- Joined: August 10th, 2003, 12:12 pm
- Location: UK
- Contact:
- diesel_travis
- Posts: 133
- Joined: September 16th, 2003, 11:31 pm
- Location: Rochester, NY
- Contact:
yay
Ok, after using winzip for both files and correcting an error in my install.js, my extension appeared to install successfully. (Thanx Pike)
Now I have this big red error in my status bar:
My extension doesn't work. What is the best way to debug this error?
Thanks
Now I have this big red error in my status bar:
Code: Select all
label="&zoominimage:label;"
-------------------^
My extension doesn't work. What is the best way to debug this error?
Thanks
- diesel_travis
- Posts: 133
- Joined: September 16th, 2003, 11:31 pm
- Location: Rochester, NY
- Contact:
- diesel_travis
- Posts: 133
- Joined: September 16th, 2003, 11:31 pm
- Location: Rochester, NY
- Contact:
OK, now my extension installs fine, and the items show up in the context menu.
I thought there might be a bug in my javascript, but I made a test page: http://travis.servebeer.com/imagezoomer/imageZoomer.html and it seems to work fine.
I'm guessing that there's something wrong with the following code in imageZoomerOverlay.js:
here's some other methods called for reference:
(as you can see most of this code was copied from the Next/Prev Image extension)
Anyone have any ideas?
Also, can anyone suggest a better install.js template?
Thanks!
I thought there might be a bug in my javascript, but I made a test page: http://travis.servebeer.com/imagezoomer/imageZoomer.html and it seems to work fine.
I'm guessing that there's something wrong with the following code in imageZoomerOverlay.js:
Code: Select all
var imageZ = null;
function imageZoomerContext()
{
imageZ = getImage(self._content.location.toString());
var disable = (imageZ == null);
// show all or none
disableElement("context-sep-imagezoomer", disable);
disableElement("context-zoominimage", disable);
disableElement("context-zoomoutimage", disable);
}
here's some other methods called for reference:
Code: Select all
function getImage(urlstr)
{
if (!urlstr) return null;
var file = getFile(urlstr);
if(isImage(file)) return file;
return null;
}
function getFile(urlstr)
{
// copied from utilityOverlay.js
var lastSlash = urlstr.slice(urlstr.lastIndexOf( "/" )+1);
if (lastSlash)
{
var nameIndex = lastSlash.lastIndexOf( "filename=" );
if (nameIndex != -1) {
return (lastSlash.slice(nameIndex+9));
}
else {
return lastSlash;
}
}
return null;
}
function isImage(file)
{
var imageRegExp = /(\.jpe?g$)|(\.gif$)|(\.png$)/i
return imageRegExp.test(file);
}
function disableElement(ele, disabled)
{
document.getElementById(ele).setAttribute("disabled", disabled);
}
(as you can see most of this code was copied from the Next/Prev Image extension)
Anyone have any ideas?
Also, can anyone suggest a better install.js template?
Thanks!
-
- Posts: 1974
- Joined: November 5th, 2002, 3:25 am
- Location: Lancaster, UK
- Contact:
diesel_jackass wrote:Also, can anyone suggest a better install.js template?
what's the problem with the current one?
if you want profile install support you could grab a more recent version of that script from the ToolbarExt source here
i'm planning on updating the script soon to detect if the extension has already been installed to the profile before, and if so disallow installing globally (because the profile version seems to take precedence, which will confuse the user)
- diesel_travis
- Posts: 133
- Joined: September 16th, 2003, 11:31 pm
- Location: Rochester, NY
- Contact:
-
- Posts: 1974
- Joined: November 5th, 2002, 3:25 am
- Location: Lancaster, UK
- Contact:
-
- Posts: 1899
- Joined: November 10th, 2002, 12:35 pm
- Location: Mexico / Boulder Co.
- Contact:
clav wrote:i'm planning on updating the script soon to detect if the extension has already been installed to the profile before, and if so disallow installing globally (because the profile version seems to take precedence, which will confuse the user)
I've made an installer script that does what you are saying for quicknote <a href="http://www.mozdev.org/source/browse/quicknote/src/install.js?rev=1.13&content-type=text/x-cvsweb-markup">here</a>.
I think it's actually one of Clav's first install scripts modded up a bit
Feel free to use it
Basically it first checks to see if the extension already exists either in the Profile or Globar dir's
If not, you get asked. If it does already exists, then it does not ask you and defaults to where it is currently located.
-
- Posts: 1974
- Joined: November 5th, 2002, 3:25 am
- Location: Lancaster, UK
- Contact:
- diesel_travis
- Posts: 133
- Joined: September 16th, 2003, 11:31 pm
- Location: Rochester, NY
- Contact:
jedbro wrote:Feel free to use it
Thanks, don't mind if I do.
I've altered the source somewhat, but my extension still doesn't work correctly.
Problem #1: the options show up in the menu all the time instead of just on images (i've tried code from Next/Prev Image and Copy Image extensions)
Problem #2: I am most certainly incorrectly assuming that "self" references the image that last had its context menu activated. How would I go about accessing this? self._content.location ?
Last edited by diesel_travis on September 17th, 2003, 1:30 pm, edited 1 time in total.
- diesel_travis
- Posts: 133
- Joined: September 16th, 2003, 11:31 pm
- Location: Rochester, NY
- Contact:
clav wrote:it's missing support for locale packages. is QuickNote using hard coded strings ?
As far as locales go how hard is it to support multiple locales?
Is it this easy:
Code: Select all
const APP_LOCALE_FOLDER1 = "locale/en-US/";
const APP_LOCALE_FOLDER2 = "locale/en/";
const APP_LOCALE_FOLDER3 = "locale/eo/";
registerChrome(localeFlag, folder, APP_LOCALE_FOLDER1);
registerChrome(localeFlag, folder, APP_LOCALE_FOLDER2);
registerChrome(localeFlag, folder, APP_LOCALE_FOLDER3);
... or am I oversimplifying it?
-
- Posts: 98
- Joined: February 5th, 2003, 10:08 am
- Contact:
this sounds like a cool extension. I can't wait to test it out
dkDesignCo.com--Professional designs for all your web needs.
- diesel_travis
- Posts: 133
- Joined: September 16th, 2003, 11:31 pm
- Location: Rochester, NY
- Contact:
-
- Posts: 1974
- Joined: November 5th, 2002, 3:25 am
- Location: Lancaster, UK
- Contact:
self would reference the current window or frame I think.
the node for which the current context menu or other popup has been created can be accessed from document.popupNode, in XUL at least. might be different when you want a node inside the html document, but it might just be window._content.document.popupNode
I really ought to know this, since I must have used it when i wrote GoTo...
the node for which the current context menu or other popup has been created can be accessed from document.popupNode, in XUL at least. might be different when you want a node inside the html document, but it might just be window._content.document.popupNode
I really ought to know this, since I must have used it when i wrote GoTo...