Forráskód Böngészése

Fixed the bug where selected text is deselected when you mouseout. Added log statements and updated README.

dvemula 13 éve
szülő
commit
23dd31b23a
2 módosított fájl, 21 hozzáadás és 9 törlés
  1. 11 1
      README
  2. 10 8
      copylinkaddress.js

+ 11 - 1
README

@@ -1 +1,11 @@
-This file was created by JetBrains WebStorm 4.0.1 for binding GitHub repository
+copylinkaddress
+===============
+
+Use Chrome? Copy link address without right-clicking! Just use your standard keyboard shortcut!
+----
+
+If you need to copy link addresses more than once, you know how annoying it is.
+You need to right-click, find the "Copy Link Address" menu item, and click it.
+
+This extension makes your life easy. Just point to your link and hit your standard keyboard shortcut
+(Ctrl-C, or Cmd-C for Mac) and you're done!

+ 10 - 8
copylinkaddress.js

@@ -6,22 +6,24 @@ $('body').append(linkAddress);
 $(function() {
     $('a').on({
         mouseenter: function() {
-            if(window.getSelection().rangeCount == 0) {
-                //console.log("Nothing is selected. Copyl kicks in.");
+            if(window.getSelection().toString()) {
+                console.log("Something is already selected. Copyl backs out.");
+            } else {
+                console.log("Nothing is selected. Copyl kicks in.");
                 linkAddress.val($(this).prop('href'));
                 linkAddress.select();
-                //console.log(linkAddress.val());
-            } else {
-                console.log("Something is already selected. Copyl backs out.");
+                console.log("linkAddress: " + linkAddress.val());
             }
+            console.log("Current Selection: " + window.getSelection().toString());
         },
         mouseleave: function() {
-            //console.log("Leaving link.");
-            if (linkAddress.val) {
+            console.log("Leaving link.");
+            if (linkAddress.val()) {
                 linkAddress.val(null);
-                //console.log("Cleared Copyl");
+                console.log("Cleared linkAddress");
                 window.getSelection().removeAllRanges();
             }
+            console.log("Current selection: " + window.getSelection().toString());
         }
     });
 });