diff --git a/chrome/content/options.xul b/chrome/content/options.xul
index be5bef5..2aca955 100644
--- a/chrome/content/options.xul
+++ b/chrome/content/options.xul
@@ -8,6 +8,9 @@
+
+
+
@@ -31,6 +34,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/chrome/content/yourlsshortener.js b/chrome/content/yourlsshortener.js
index 55fe741..fd983e9 100644
--- a/chrome/content/yourlsshortener.js
+++ b/chrome/content/yourlsshortener.js
@@ -59,6 +59,32 @@ var YOURLSshortener = function () {
}
}
},
+ changeButtons : function (icon) {
+ var btn = document.getElementById("yourls-shortener-toolbar-button");
+ if (btn)
+ btn.style.listStyleImage = 'url("chrome://yourls-shortener/skin/' + icon + '")';
+ var btn = document.getElementById("yourls-shortener-status-bar-icon");
+ if (btn)
+ btn.src = 'chrome://yourls-shortener/skin/' + icon;
+ },
+ failed: function () {
+ if (!prefManager.getBoolPref ("extensions.yourls-shortener.changeicons"))
+ return;
+ this.changeButtons ("favicon-failed.gif");
+ var obj = this;
+ setTimeout (function () {
+ obj.changeButtons ("favicon.gif")
+ },3000);
+ },
+ success : function () {
+ if (!prefManager.getBoolPref ("extensions.yourls-shortener.changeicons"))
+ return;
+ this.changeButtons ("favicon-success.gif");
+ var obj = this;
+ setTimeout (function () {
+ obj.changeButtons ("favicon.gif")
+ },3000);
+ },
run : function (long) {
if (typeof gContextMenu != 'undefined' && gContextMenu.onLink)
@@ -82,6 +108,7 @@ var YOURLSshortener = function () {
api += '/';
api += "yourls-api.php";
+ var me = this;
if (api && api != "http://yoursite/")
{
try
@@ -120,6 +147,7 @@ var YOURLSshortener = function () {
var requestTimer = setTimeout (function () {
request.abort ();
prompts.alert(null, "YOURLS shortener: failed", "Did not get an answer from server!\nTry again later or increase maximum waiting time.");
+ me.failed ();
return;
}, maxwait);
request.onreadystatechange = function () {
@@ -128,18 +156,25 @@ var YOURLSshortener = function () {
clearTimeout (requestTimer);
if ((request.status == 200 || request.status == 201) && request.responseText.match(/^\s*\S+\s*$/))
{
- prompts.alert (null, "YOURLS shortener: short URL", long + "\n\nis shortened by:\n\n" + request.responseText);
- clipboard.copyString (request.responseText);
+ if (prefManager.getBoolPref ("extensions.yourls-shortener.showprompt"))
+ prompts.alert (null, "YOURLS shortener: short URL", long + "\n\nis shortened by:\n\n" + request.responseText);
+
+ if (prefManager.getBoolPref ("extensions.yourls-shortener.copyclipboard"))
+ clipboard.copyString (request.responseText);
+
+ me.success ();
return;
}
else if ((request.status == 200 || request.status == 201) && request.responseText.match(/^\s*$/))
{
prompts.alert(null, "YOURLS shortener: failed", "Shortening failed.. Maybe chosen key already in use!?\nTry again!");
+ me.failed ();
return;
}
else
{
prompts.alert(null, "YOURLS shortener: failed", "Do not understand the response from API!\nPlease check your signature and the API-URL.");
+ me.failed ();
return;
}
}
@@ -149,11 +184,15 @@ var YOURLSshortener = function () {
catch (e)
{
prompts.alert(null, "YOURLS shortener: failed", "Failed to start XMLHttpRequest:\n" + e.message);
+ me.failed ();
}
}
else
+ {
prompts.alert(null, "YOURLS shortener: failed", "No API-URL specified... Check your settings!");
+ me.failed ();
+ }
}
};
} ();
\ No newline at end of file
diff --git a/defaults/preferences/prefs.js b/defaults/preferences/prefs.js
index 74c9128..6ea766f 100644
--- a/defaults/preferences/prefs.js
+++ b/defaults/preferences/prefs.js
@@ -1,4 +1,7 @@
pref("extensions.yourls-shortener.api", "http://yoursite/");
pref("extensions.yourls-shortener.signature", "123456");
pref("extensions.yourls-shortener.askforkey", false);
-pref("extensions.yourls-shortener.maxwait", 4);
\ No newline at end of file
+pref("extensions.yourls-shortener.maxwait", 4);
+pref("extensions.yourls-shortener.showprompt", true);
+pref("extensions.yourls-shortener.copyclipboard", true);
+pref("extensions.yourls-shortener.changeicons", true);
\ No newline at end of file
diff --git a/skin/favicon-failed.gif b/skin/favicon-failed.gif
new file mode 100644
index 0000000..f9158ee
Binary files /dev/null and b/skin/favicon-failed.gif differ
diff --git a/skin/favicon-success.gif b/skin/favicon-success.gif
new file mode 100644
index 0000000..a20372d
Binary files /dev/null and b/skin/favicon-success.gif differ