[Pkg-mozext-commits] [itsalltext] 68/459: * fixed problem with non-unique names, but unique ids * fixed fading the wrong text area.

David Prévot taffit at moszumanska.debian.org
Tue Feb 24 23:26:07 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository itsalltext.

commit e3cb14c0386fbc76c617ab220e3f256ca9371acb
Author: docwhat at gerf.org <docwhat at gerf.org>
Date:   Wed Jan 10 12:19:04 2007 -0500

    * fixed problem with non-unique names, but unique ids
    * fixed fading the wrong text area.
---
 chrome/content/itsalltext.js | 63 ++++++++++++++++++++++++++++++++++++--------
 1 file changed, 52 insertions(+), 11 deletions(-)

diff --git a/chrome/content/itsalltext.js b/chrome/content/itsalltext.js
index 1524e23..b38f3fe 100644
--- a/chrome/content/itsalltext.js
+++ b/chrome/content/itsalltext.js
@@ -254,6 +254,30 @@ function ItsAllTextOverlay() {
   };
 
   /**
+   * Returns a unique identifier for the node, within the document.
+   * @returns {String} the unique identifier.
+   */
+  that.getNodeIdentifier = function(node) {
+    // @todo getNodeIdentifier() - if result isn't unque enough, add id to node.
+    var name = node.getAttribute('name');
+    var id   = node.getAttribute('id');
+    if (id) {
+      return id;
+    } else {
+      return name;
+    }
+  };
+
+  /**
+   * Returns a unique identifier for the document.
+   * @returns {String} the unique identifier.
+   */
+  that.getDocumentIdentifier = function(doc) {
+    // @todo getDocumentIdentifier should sort arguments and append the post data.
+    return doc.URL;
+  };
+
+  /**
    * A Cache object is used to manage the node and the file behind it.
    * @constructor
    * @param {Object} node A DOM Node to watch.
@@ -266,12 +290,14 @@ function ItsAllTextOverlay() {
     self.button = null;
     self.initial_color = 'transparent';
 
-    self.uid = hashString([ node.ownerDocument.URL,
+    self.node_id = that.getNodeIdentifier(node);
+    self.doc_id  = that.getDocumentIdentifier(node.ownerDocument);
+    self.uid = hashString([ self.doc_id,
                             Math.random(),
-                            node.getAttribute("name") ].join(':'));
+                            self.node_id ].join(':'));
 
-    self.filename = hashString([ node.ownerDocument.URL,
-                                 node.getAttribute("name") ].join(':')) +
+    self.filename = hashString([ self.doc_id,
+                                 self.node_id ].join(':')) +
       '.txt';
 
     node.setAttribute(MYSTRING+'_UID', self.uid);
@@ -425,20 +451,31 @@ function ItsAllTextOverlay() {
       }
     };
 
-    fadeStep = function(pallet, step, delay) {
+    /**
+     * Part of the fading technique.
+     * @param {Object} pallet A Color blend pallet object.
+     * @param {int}    step   Size of a step.
+     * @param {delay}  delay  Delay in microseconds.
+     */
+    self.fadeStep = function(pallet, step, delay) {
       return function() {
 		if (step < pallet.length) {
           self.node.style.backgroundColor = pallet[step++].hex();
-          setTimeout(fadeStep(pallet, step, delay),delay);
+          setTimeout(self.fadeStep(pallet, step, delay),delay);
 		}
       };
     };
-      
-    fade = function(steps, delay) {
+
+    /**
+     * Node fade technique.
+     * @param {int} steps  Number of steps in the transition.
+     * @param {int} delay  How long to wait between delay (microseconds).
+     */
+    self.fade = function(steps, delay) {
       var colEnd = new Color(self.initial_color);
       var colStart = new Color('yellow');//colEnd.invert();
       var pallet = colStart.blend(colEnd, steps);
-      setTimeout(fadeStep(pallet, 0, delay), delay);
+      setTimeout(self.fadeStep(pallet, 0, delay), delay);
     };
 
     /**
@@ -449,7 +486,7 @@ function ItsAllTextOverlay() {
       if (self.hasChanged()) {
         var value = self.read();
         if (value !== null) {
-          fade(15, 100);
+          self.fade(15, 100);
           self.node.value = value;
           return true;
         }
@@ -569,7 +606,11 @@ function ItsAllTextOverlay() {
     var XHTMLNS = "http://www.w3.org/1999/xhtml";
     var gumdrop = doc.createElementNS(XHTMLNS, "img");
     gumdrop.setAttribute('src', 'chrome://itsalltext/content/gumdrop.png');
-    gumdrop.setAttribute('tooltipText', "It's All Text!");
+    if (this.getDebug()) {
+      gumdrop.setAttribute('title', cache_object.node_id);
+    } else {
+      gumdrop.setAttribute('title', "It's All Text!");
+    }
     cache_object.button = gumdrop; // Store it for easy finding in the future.
 
     // Click event handler

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/itsalltext.git



More information about the Pkg-mozext-commits mailing list