>Форум Mozilla Россия http://forum.mozilla-russia.org/index.php >Поддержка пользователей http://forum.mozilla-russia.org/viewforum.php?id=26 >Нужна помощь с расширением goo.gl lite http://forum.mozilla-russia.org/viewtopic.php?id=44750 |
Systematis > 06-06-2010 01:24:51 |
Приветствую. Ссылка на .jar: http://dl.dropbox.com/u/94984/goo.gl_lite.jar скрытый текст Выделить код Код:goo_gl_lite = new function() { const gClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"]. getService(Components.interfaces.nsIClipboardHelper); const notificationValue = "goo.gl lite notification"; const iconURL = "chrome://goo.gl_lite/skin/icon_16x16.png"; /** * Basic initiation */ this.init = function() { document.getElementById("contentAreaContextMenu").addEventListener("popupshowing", goo_gl_lite.popupshowing, false); }; /** * Show/hide context menu entries on demand */ this.popupshowing = function() { gContextMenu.showItem("context-goo_gl_lite-current", !(gContextMenu.isContentSelected || gContextMenu.onTextInput || gContextMenu.onLink || gContextMenu.onImage || gContextMenu.onVideo || gContextMenu.onAudio)); // Shows Copy Goo.gl URL for This Page whenever Bookmark This Page is shown gContextMenu.showItem("context-goo_gl_lite-link", gContextMenu.onLink && !gContextMenu.onMailtoLink); // Shows Copy Goo.gl URL for Link Location whenver Bookmark this Link is shown. }; /** * Makes a short url from long_url * @param long_url long url, unescaped. */ this.make_short_url = function(long_url) { var req = new XMLHttpRequest(); req.addEventListener("load", function() { var response = JSON.parse(req.responseText); if(response.error_message) { goo_gl_lite.error("Gateway returned error message: " + response.error_message); } goo_gl_lite.notify(response.short_url + " has been copied to the clipboard. Shortened from " + long_url, "PRIORITY_INFO_MEDIUM"); gClipboardHelper.copyString(response.short_url); }, false); req.addEventListener("error", function() { goo_gl_lite.error("Error contacting gateway. Status code: " + req.status); }, false); req.open("GET", "http://ggl-shortener.appspot.com/?url=" + encodeURIComponent(long_url)); req.send(); }; /** * @param text Text of notification * @param priorityKey key to specify priority, as string */ this.notify = function(text, priorityKey) { var notifyBox = window.getNotificationBox(top.getBrowser().selectedBrowser.contentWindow); notifyBox.removeAllNotifications(false); notifyBox.appendNotification("Goo.gl Lite: " + text, this.notificationValue, this.iconURL, notifyBox[priorityKey], null); }; this.error = function(error_text) { this.notify("Short URL creation failed: " + error_text, "PRIORITY_WARNING_MEDIUM"); throw new Error("[goo.gl lite] Short URL creation failed: " + error_text); }; this.make_from_current_page = function() { this.make_short_url(top.getBrowser().currentURI.spec); }; this.make_from_link = function() { this.make_short_url(gContextMenu.linkURL); }; }(); window.addEventListener("load", goo_gl_lite.init, false); и XUL (хотя он, видимо, в данном случае мало чем сможет помочь): скрытый текст Выделить код Код:<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?> <?xml-stylesheet href="chrome://goo.gl_lite/skin/goo.gl_lite.css" type="text/css"?> <!DOCTYPE toolbarpalette SYSTEM "chrome://goo.gl_lite/locale/goo.gl_lite.dtd"> <overlay id="goo.gl_lite_overlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <script type="text/javascript" src="goo.gl_lite.js"/> <toolbarpalette id="BrowserToolbarPalette"> <toolbarbutton id="goo_gl_lite_button" class="toolbarbutton-1" label="&goo.gl_lite.toolbar_button_label;" tooltiptext="&goo.gl_lite.toolbar_button_tooltip;" oncommand="goo_gl_lite.make_from_current_page();"/> </toolbarpalette> <popup id="contentAreaContextMenu"> <menuitem id="context-goo_gl_lite-current" label="&goo.gl_lite.context_current_label;" accesskey="&goo.gl_lite.context_current_accesskey;" insertafter="context-bookmarkpage" oncommand="goo_gl_lite.make_from_current_page();"/> <menuitem id="context-goo_gl_lite-link" label="&goo.gl_lite.context_link_label;" accesskey="&goo.gl_lite.context_link_accesskey;" insertafter="context-copylink" oncommand="goo_gl_lite.make_from_link();"/> </popup> </overlay> Надеюсь, кто-нибудь знающий сможет найти пару свободных минут. Спасибо. |
Infocatcher > 06-06-2010 01:44:41 |
После Выделить код Код:notifyBox.appendNotification("Goo.gl Lite: " + text, this.notificationValue, this.iconURL, notifyBox[priorityKey], null); добавить Выделить код Код:setTimeout(function(notifyBox, notify) { if(notify.parentNode) notifyBox.removeNotification(notify); }, 7000, notifyBox, notify); 7000 – в миллисекундах. 06-06-2010 01:45:16 |
Systematis > 06-06-2010 13:02:09 |
Infocatcher Видимо, придётся писать автору. |