diff js/black-box.js @ 102:00b02ba5236c

made all delegates have a dotted name (namespaced), modified black-box.js a bit
author Atul Varma <avarma@mozilla.com>
date Wed, 28 Apr 2010 20:06:26 -0700
parents 106a0018e601
children a994fc89f341
line wrap: on
line diff
--- a/js/black-box.js	Wed Apr 28 18:37:08 2010 -0700
+++ b/js/black-box.js	Wed Apr 28 20:06:26 2010 -0700
@@ -1,27 +1,3 @@
-function getXPathForElement(el, xml) {
-  var xpath = "";
-  var pos, tempitem2;
-  
-  while (el !== xml.documentElement) {    
-    pos = 0;
-    tempitem2 = el;
-    while (tempitem2) {
-      if (tempitem2.nodeType === 1 && tempitem2.nodeName === el.nodeName) {
-        // If it is ELEMENT_NODE of the same name
-        pos += 1;
-      }
-      tempitem2 = tempitem2.previousSibling;
-    }
-    
-    xpath = el.nodeName + "[" + pos + "]" + "/" + xpath;
-
-    el = el.parentNode;
-  }
-  xpath = "/" + xml.documentElement.nodeName + "/" + xpath;
-  xpath = xpath.replace(/\/$/, '');
-  return xpath;
-}
-
 function onDashboardLoaded(dashboard, options) {
   var require = Require.build(Require.modules, {window: window});
 
@@ -31,57 +7,12 @@
       console.warn("An error occurred in the dashboard iframe.");
     });
 
-  function DOMElementToCSSSelector(element) {
-    if (element.id)
-      return "#" + element.id;
-
-    var document = element.ownerDocument;
-
-    function isUnique(selector) {
-      return (document.querySelectorAll(selector).length == 1);
-    }
-
-    var parent = element.parentNode;
-    while (parent) {
-      if (parent.id)
-        break;
-      parent = parent.parentNode;
-    }
-
-    if (parent && parent.id) {
-      var selector = "#" + parent.id;
-
-      var list = element.classList;
-      for (var i = 0; i < list.length; i++) {
-        selector += " ." + list[i];
-        if (isUnique(selector))
-          return selector;
-      }
-    }
-    return null;
-  }
-
-  dashboard.addEventListener(
-    "mousedown",
-    function(event) {
-      var document = event.target.ownerDocument;
-      var xpath = getXPathForElement(event.target, document);
-      var result = document.evaluate(xpath, document, null,
-                                     XPathResult.ANY_TYPE, null);
-      console.log("mousedown", event.target,
-                  DOMElementToCSSSelector(event.target),
-                  xpath,
-                  result.iterateNext());
-    },
-    true
-  );
-
   var moduleExports = {};
   var dbrequire = dashboard.Require.build(dashboard.Require.modules,
                                           moduleExports);
 
   function delegate(method, args) {
-    //console.log(method, args);
+    console.log(method, args);
   }
 
   // Get rid of any form values cached by the browser.