incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmue...@apache.org
Subject [23/27] closes #35
Date Tue, 03 Jan 2012 18:39:31 GMT
http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/9f1c7663/weinre.web/modules/weinre/target/ElementHighlighter.coffee
----------------------------------------------------------------------
diff --git a/weinre.web/modules/weinre/target/ElementHighlighter.coffee b/weinre.web/modules/weinre/target/ElementHighlighter.coffee
new file mode 100644
index 0000000..b1a7ccb
--- /dev/null
+++ b/weinre.web/modules/weinre/target/ElementHighlighter.coffee
@@ -0,0 +1,119 @@
+
+#---------------------------------------------------------------------------------
+# weinre is available under *either* the terms of the modified BSD license *or* the
+# MIT License (2008). See http:#opensource.org/licenses/alphabetical for full text.
+#
+# Copyright (c) 2010, 2011 IBM Corporation
+#---------------------------------------------------------------------------------
+
+Binding = require('../common/Binding')
+Weinre  = require('../common/Weinre')
+
+#-------------------------------------------------------------------------------
+module.exports = class ElementHighlighter
+
+    ElementHighlighter::__defineGetter__("element", -> @boxMargin)
+
+    constructor: ->
+        @boxMargin  = document.createElement("div")
+        @boxBorder  = document.createElement("div")
+        @boxPadding = document.createElement("div")
+        @boxContent = document.createElement("div")
+
+        @boxMargin.appendChild  @boxBorder
+        @boxBorder.appendChild  @boxPadding
+        @boxPadding.appendChild @boxContent
+
+        @boxMargin.style.backgroundColor  = "#FCC"
+        @boxBorder.style.backgroundColor  = "#000"
+        @boxPadding.style.backgroundColor = "#CFC"
+        @boxContent.style.backgroundColor = "#CCF"
+
+        @boxMargin.style.opacity       = @boxBorder.style.opacity       = @boxPadding.style.opacity       = @boxContent.style.opacity       = 0.6
+        @boxMargin.style.position      = @boxBorder.style.position      = @boxPadding.style.position      = @boxContent.style.position      = "absolute"
+        @boxMargin.style.borderWidth   = @boxBorder.style.borderWidth   = @boxPadding.style.borderWidth   = @boxContent.style.borderWidth   = "thin"
+        @boxMargin.style.borderStyle   = @boxBorder.style.borderStyle   = @boxPadding.style.borderStyle   = @boxContent.style.borderStyle   = "solid"
+        @boxMargin.__weinreHighlighter = @boxBorder.__weinreHighlighter = @boxPadding.__weinreHighlighter = @boxContent.__weinreHighlighter = true
+
+        @boxMargin.style.display = "none"
+        document.body.appendChild @boxMargin
+
+    #---------------------------------------------------------------------------
+    on: (element) ->
+        return if null == element
+        return unless element.nodeType == Node.ELEMENT_NODE
+
+        @calculateMetrics element
+        @boxMargin.style.display = "block"
+
+    #---------------------------------------------------------------------------
+    off: ->
+        @boxMargin.style.display = "none"
+
+    #---------------------------------------------------------------------------
+    calculateMetrics: (element) ->
+        metrics = getMetrics(element)
+
+        @boxMargin.style.top     = metrics.y + "px"
+        @boxMargin.style.left    = metrics.x + "px"
+        @boxMargin.style.height  = metrics.height + "px"
+        @boxMargin.style.width   = metrics.width + "px"
+        @boxBorder.style.top     = metrics.marginTop + "px"
+        @boxBorder.style.left    = metrics.marginLeft + "px"
+        @boxBorder.style.bottom  = metrics.marginBottom + "px"
+        @boxBorder.style.right   = metrics.marginRight + "px"
+        @boxPadding.style.top    = metrics.borderTop + "px"
+        @boxPadding.style.left   = metrics.borderLeft + "px"
+        @boxPadding.style.bottom = metrics.borderBottom + "px"
+        @boxPadding.style.right  = metrics.borderRight + "px"
+        @boxContent.style.top    = metrics.paddingTop + "px"
+        @boxContent.style.left   = metrics.paddingLeft + "px"
+        @boxContent.style.bottom = metrics.paddingBottom + "px"
+        @boxContent.style.right  = metrics.paddingRight + "px"
+
+#-------------------------------------------------------------------------------
+getMetrics = (element) ->
+      result = {}
+      left = 0
+      top  = 0
+      el   = element
+
+      loop
+          left += el.offsetLeft
+          top += el.offsetTop
+          break unless el = el.offsetParent
+
+      result.x = left
+      result.y = top
+
+      cStyle = document.defaultView.getComputedStyle(element)
+
+      result.width         = fromPx(cStyle["width"])
+      result.height        = fromPx(cStyle["height"])
+      result.marginLeft    = fromPx(cStyle["margin-left"])
+      result.marginRight   = fromPx(cStyle["margin-right"])
+      result.marginTop     = fromPx(cStyle["margin-top"])
+      result.marginBottom  = fromPx(cStyle["margin-bottom"])
+      result.borderLeft    = fromPx(cStyle["border-left-width"])
+      result.borderRight   = fromPx(cStyle["border-right-width"])
+      result.borderTop     = fromPx(cStyle["border-top-width"])
+      result.borderBottom  = fromPx(cStyle["border-bottom-width"])
+      result.paddingLeft   = fromPx(cStyle["padding-left"])
+      result.paddingRight  = fromPx(cStyle["padding-right"])
+      result.paddingTop    = fromPx(cStyle["padding-top"])
+      result.paddingBottom = fromPx(cStyle["padding-bottom"])
+
+      result.width  += result.marginLeft + result.marginRight  + result.borderRight  + result.paddingLeft + result.paddingRight
+      result.height += result.marginTop  + result.marginBottom + result.borderBottom + result.paddingTop  + result.paddingBottom
+
+      result.x -= result.marginLeft
+      result.y -= result.marginTop
+
+      result
+
+#-------------------------------------------------------------------------------
+fromPx = (string) ->
+      parseInt string.replace(/px$/, "")
+
+#-------------------------------------------------------------------------------
+require("../common/MethodNamer").setNamesForClass(module.exports)

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/9f1c7663/weinre.web/modules/weinre/target/ElementHighlighter.scoop
----------------------------------------------------------------------
diff --git a/weinre.web/modules/weinre/target/ElementHighlighter.scoop b/weinre.web/modules/weinre/target/ElementHighlighter.scoop
deleted file mode 100644
index d74cb4f..0000000
--- a/weinre.web/modules/weinre/target/ElementHighlighter.scoop
+++ /dev/null
@@ -1,156 +0,0 @@
-
-/*
- * weinre is available under *either* the terms of the modified BSD license *or* the
- * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
- * 
- * Copyright (c) 2011 IBM Corporation
- */
-
-requireClass ../common/Binding
-requireClass ../common/Weinre
-
-//-----------------------------------------------------------------------------
-class ElementHighlighter
-    this.boxMargin  = document.createElement("div")
-    this.boxBorder  = document.createElement("div")
-    this.boxPadding = document.createElement("div")
-    this.boxContent = document.createElement("div")
-    
-    this.boxMargin.appendChild(this.boxBorder)
-    this.boxBorder.appendChild(this.boxPadding)
-    this.boxPadding.appendChild(this.boxContent)
-    
-    this.boxMargin.style.backgroundColor  = "#FCC"
-    this.boxBorder.style.backgroundColor  = "#000"
-    this.boxPadding.style.backgroundColor = "#CFC"
-    this.boxContent.style.backgroundColor = "#CCF"
-    
-    this.boxMargin.style.opacity =
-    this.boxBorder.style.opacity =
-    this.boxPadding.style.opacity =
-    this.boxContent.style.opacity = 0.6
-    
-    this.boxMargin.style.position =
-    this.boxBorder.style.position =
-    this.boxPadding.style.position =
-    this.boxContent.style.position = "absolute"
-    
-    this.boxMargin.style.borderWidth =
-    this.boxBorder.style.borderWidth =
-    this.boxPadding.style.borderWidth =
-    this.boxContent.style.borderWidth = "thin"
-        
-    this.boxMargin.style.borderStyle =
-    this.boxBorder.style.borderStyle =
-    this.boxPadding.style.borderStyle =
-    this.boxContent.style.borderStyle = "solid"
-                
-    this.boxMargin.__weinreHighlighter =
-    this.boxBorder.__weinreHighlighter =
-    this.boxPadding.__weinreHighlighter =
-    this.boxContent.__weinreHighlighter = true
-                        
-    this.boxMargin.style.display = "none"
-        
-    document.body.appendChild(this.boxMargin)
-    
-//-----------------------------------------------------------------------------
-method on(element)
-    if (null == element) return
-    if (element.nodeType != Node.ELEMENT_NODE) return
-    
-    this.calculateMetrics(element)
-    this.boxMargin.style.display = "block"
-
-//-----------------------------------------------------------------------------
-method off
-    this.boxMargin.style.display = "none"
-
-//-----------------------------------------------------------------------------
-getter element
-    return this.boxMargin
-
-//-----------------------------------------------------------------------------
-method calculateMetrics(element)
-
-    var metrics = getMetrics(element)
-    
-    this.boxMargin.style.top     = metrics.y      + "px"
-    this.boxMargin.style.left    = metrics.x      + "px"
-    this.boxMargin.style.height  = metrics.height + "px"
-    this.boxMargin.style.width   = metrics.width  + "px"
-
-    this.boxBorder.style.top     = metrics.marginTop    + "px"
-    this.boxBorder.style.left    = metrics.marginLeft   + "px"
-    this.boxBorder.style.bottom  = metrics.marginBottom + "px"
-    this.boxBorder.style.right   = metrics.marginRight  + "px"
-
-    this.boxPadding.style.top    = metrics.borderTop    + "px"
-    this.boxPadding.style.left   = metrics.borderLeft   + "px"
-    this.boxPadding.style.bottom = metrics.borderBottom + "px"
-    this.boxPadding.style.right  = metrics.borderRight  + "px"
-    
-    this.boxContent.style.top    = metrics.paddingTop    + "px"
-    this.boxContent.style.left   = metrics.paddingLeft   + "px"
-    this.boxContent.style.bottom = metrics.paddingBottom + "px"
-    this.boxContent.style.right  = metrics.paddingRight  + "px"
-    
-//-----------------------------------------------------------------------------
-function getMetrics(element)
-    var result = {}
-    
-    // get the x,y position
-    var left = 0
-    var top  = 0
-        
-    var el = element
-    do {
-        left += el.offsetLeft
-        top  += el.offsetTop
-    } while (el = el.offsetParent)
-    
-    result.x = left
-    result.y = top
-
-    // get the computed style
-    var cStyle = document.defaultView.getComputedStyle(element)
-    
-    result.width  = fromPx(cStyle["width"])
-    result.height = fromPx(cStyle["height"])
-    
-    result.marginLeft    = fromPx(cStyle["margin-left"])
-    result.marginRight   = fromPx(cStyle["margin-right"])
-    result.marginTop     = fromPx(cStyle["margin-top"])
-    result.marginBottom  = fromPx(cStyle["margin-bottom"])
-    
-    result.borderLeft    = fromPx(cStyle["border-left-width"])
-    result.borderRight   = fromPx(cStyle["border-right-width"])
-    result.borderTop     = fromPx(cStyle["border-top-width"])
-    result.borderBottom  = fromPx(cStyle["border-bottom-width"])
-    
-    result.paddingLeft   = fromPx(cStyle["padding-left"])
-    result.paddingRight  = fromPx(cStyle["padding-right"])
-    result.paddingTop    = fromPx(cStyle["padding-top"])
-    result.paddingBottom = fromPx(cStyle["padding-bottom"])
-
-    result.width += 
-        result.marginLeft  + result.marginRight +
-        result.borderRight  +
-        result.paddingLeft + result.paddingRight
-        
-    result.height += 
-        result.marginTop  + result.marginBottom +
-        result.borderBottom  +
-        result.paddingTop + result.paddingBottom
-        
-    result.x -= 
-        result.marginLeft
-        
-    result.y -= 
-        result.marginTop
-
-    return result
-    
-//-----------------------------------------------------------------------------
-function fromPx(string) 
-    return parseInt(string.replace(/px$/,""))

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/9f1c7663/weinre.web/modules/weinre/target/InjectedScriptHostImpl.coffee
----------------------------------------------------------------------
diff --git a/weinre.web/modules/weinre/target/InjectedScriptHostImpl.coffee b/weinre.web/modules/weinre/target/InjectedScriptHostImpl.coffee
new file mode 100644
index 0000000..a4ba59f
--- /dev/null
+++ b/weinre.web/modules/weinre/target/InjectedScriptHostImpl.coffee
@@ -0,0 +1,50 @@
+
+#---------------------------------------------------------------------------------
+# weinre is available under *either* the terms of the modified BSD license *or* the
+# MIT License (2008). See http:#opensource.org/licenses/alphabetical for full text.
+#
+# Copyright (c) 2010, 2011 IBM Corporation
+#---------------------------------------------------------------------------------
+
+Weinre = require('../common/Weinre')
+
+#-------------------------------------------------------------------------------
+module.exports = class InjectedScriptHostImpl
+
+    constructor: ->
+
+    #---------------------------------------------------------------------------
+    clearConsoleMessages: (callback) ->
+        Weinre.WeinreTargetCommands.sendClientCallback callback if callback
+
+    #---------------------------------------------------------------------------
+    nodeForId: (nodeId, callback) ->
+        Weinre.nodeStore.getNode nodeId
+
+    #---------------------------------------------------------------------------
+    pushNodePathToFrontend: (node, withChildren, selectInUI, callback) ->
+        nodeId = Weinre.nodeStore.getNodeId(node)
+        children = Weinre.nodeStore.serializeNode(node, 1)
+        Weinre.wi.DOMNotify.setChildNodes nodeId, children
+        Weinre.WeinreTargetCommands.sendClientCallback callback if callback
+
+    #---------------------------------------------------------------------------
+    inspectedNode: (num, callback) ->
+        nodeId = Weinre.nodeStore.getInspectedNode(num)
+        nodeId
+
+    #---------------------------------------------------------------------------
+    internalConstructorName: (object) ->
+        ctor = object.constructor
+        ctorName = ctor.fullClassName or ctor.displayName or ctor.name
+        return ctorName if ctorName and (ctorName != "Object")
+
+        pattern = /\[object (.*)\]/
+        match = pattern.exec(ctor.toString())
+
+        return match[1] if match
+
+        "Object"
+
+#-------------------------------------------------------------------------------
+require("../common/MethodNamer").setNamesForClass(module.exports)

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/9f1c7663/weinre.web/modules/weinre/target/InjectedScriptHostImpl.scoop
----------------------------------------------------------------------
diff --git a/weinre.web/modules/weinre/target/InjectedScriptHostImpl.scoop b/weinre.web/modules/weinre/target/InjectedScriptHostImpl.scoop
deleted file mode 100644
index 0c9b8af..0000000
--- a/weinre.web/modules/weinre/target/InjectedScriptHostImpl.scoop
+++ /dev/null
@@ -1,52 +0,0 @@
-
-/*
- * weinre is available under *either* the terms of the modified BSD license *or* the
- * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
- * 
- * Copyright (c) 2010, 2011 IBM Corporation
- */
-
-requireClass ../common/Weinre
-
-//-----------------------------------------------------------------------------
-class InjectedScriptHostImpl
-
-//-----------------------------------------------------------------------------
-method clearConsoleMessages(callback)
-    if (callback) {
-        Weinre.WeinreTargetCommands.sendClientCallback(callback)
-    }
-
-//-----------------------------------------------------------------------------
-method nodeForId(/*int*/ nodeId, callback)
-    return Weinre.nodeStore.getNode(nodeId)
-
-//-----------------------------------------------------------------------------
-method pushNodePathToFrontend(/*any*/ node, /*boolean*/ withChildren, /*boolean*/ selectInUI, callback)
-    // callback: function()
-    var nodeId = Weinre.nodeStore.getNodeId(node)
-    var children = Weinre.nodeStore.serializeNode(node, 1)
-    Weinre.wi.DOMNotify.setChildNodes(nodeId, children)
-    
-    if (callback) {
-        Weinre.WeinreTargetCommands.sendClientCallback(callback)
-    }
-
-//-----------------------------------------------------------------------------
-method inspectedNode(/*int*/ num, callback)
-    // callback: function()
-    var nodeId = Weinre.nodeStore.getInspectedNode(num)
-    return nodeId
-
-//-----------------------------------------------------------------------------
-method internalConstructorName(object)
-    var ctor = object.constructor
-    
-    var ctorName = ctor.fullClassName || ctor.displayName || ctor.name
-    if (ctorName && (ctorName != "Object")) return ctorName
-    
-    var pattern = /\[object (.*)\]/
-    var match = pattern.exec(ctor.toString())
-    if (match) return match[1]
-    
-    return "Object"

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/9f1c7663/weinre.web/modules/weinre/target/NodeStore.coffee
----------------------------------------------------------------------
diff --git a/weinre.web/modules/weinre/target/NodeStore.coffee b/weinre.web/modules/weinre/target/NodeStore.coffee
new file mode 100644
index 0000000..edd0269
--- /dev/null
+++ b/weinre.web/modules/weinre/target/NodeStore.coffee
@@ -0,0 +1,219 @@
+
+#---------------------------------------------------------------------------------
+# weinre is available under *either* the terms of the modified BSD license *or* the
+# MIT License (2008). See http:#opensource.org/licenses/alphabetical for full text.
+#
+# Copyright (c) 2010, 2011 IBM Corporation
+#---------------------------------------------------------------------------------
+
+Weinre      = require('../common/Weinre')
+IDGenerator = require('../common/IDGenerator')
+
+#-------------------------------------------------------------------------------
+module.exports = class NodeStore
+
+    constructor: ->
+        @__nodeMap      = {}
+        @__nodeDataMap  = {}
+        @inspectedNodes = []
+
+        document.addEventListener "DOMSubtreeModified",       handleDOMSubtreeModified, false
+        document.addEventListener "DOMNodeInserted",          handleDOMNodeInserted, false
+        document.addEventListener "DOMNodeRemoved",           handleDOMNodeRemoved, false
+        document.addEventListener "DOMAttrModified",          handleDOMAttrModified, false
+        document.addEventListener "DOMCharacterDataModified", handleDOMCharacterDataModified, false
+
+    #---------------------------------------------------------------------------
+    addInspectedNode: (nodeId) ->
+        @inspectedNodes.unshift nodeId
+        @inspectedNodes = @inspectedNodes.slice(0, 5) if @inspectedNodes.length > 5
+
+    #---------------------------------------------------------------------------
+    getInspectedNode: (index) ->
+        @inspectedNodes[index]
+
+    #---------------------------------------------------------------------------
+    getNode: (nodeId) ->
+        @__nodeMap[nodeId]
+
+    #---------------------------------------------------------------------------
+    checkNodeId: (node) ->
+        IDGenerator.checkId node
+
+    #---------------------------------------------------------------------------
+    getNodeId: (node) ->
+        id = @checkNodeId(node)
+        return id if id
+        IDGenerator.getId node, @__nodeMap
+
+    #---------------------------------------------------------------------------
+    getNodeData: (nodeId, depth) ->
+        @serializeNode @getNode(nodeId), depth
+
+    #---------------------------------------------------------------------------
+    getPreviousSiblingId: (node) ->
+        while true
+            sib = node.previousSibling
+            return 0 unless sib
+
+            id = @checkNodeId(sib)
+            return id if id
+
+            node = sib
+
+    #---------------------------------------------------------------------------
+    nextNodeId: () ->
+        "" + IDGenerator.next()
+
+    #---------------------------------------------------------------------------
+    serializeNode: (node, depth) ->
+        nodeName = ""
+        nodeValue = null
+        localName = null
+        id = @getNodeId(node)
+
+        switch node.nodeType
+
+            when Node.TEXT_NODE, Node.COMMENT_NODE, Node.CDATA_SECTION_NODE
+                nodeValue = node.nodeValue
+
+            when Node.ATTRIBUTE_NODE
+                localName = node.localName
+
+            when Node.DOCUMENT_FRAGMENT_NODE
+                break
+
+            else
+                nodeName  = node.nodeName
+                localName = node.localName
+
+        nodeData =
+          id:        id
+          nodeType:  node.nodeType
+          nodeName:  nodeName
+          localName: localName
+          nodeValue: nodeValue
+
+        if node.nodeType == Node.ELEMENT_NODE or node.nodeType == Node.DOCUMENT_NODE or node.nodeType == Node.DOCUMENT_FRAGMENT_NODE
+          nodeData.childNodeCount = @childNodeCount(node)
+          children = @serializeNodeChildren(node, depth)
+          nodeData.children = children if children.length
+
+          if node.nodeType == Node.ELEMENT_NODE
+            nodeData.attributes = []
+            i = 0
+
+            while i < node.attributes.length
+              nodeData.attributes.push node.attributes[i].nodeName
+              nodeData.attributes.push node.attributes[i].nodeValue
+              i++
+
+          else
+            if node.nodeType == Node.DOCUMENT_NODE
+              nodeData.documentURL = window.location.href
+
+        else if node.nodeType == Node.DOCUMENT_TYPE_NODE
+          nodeData.publicId       = node.publicId
+          nodeData.systemId       = node.systemId
+          nodeData.internalSubset = node.internalSubset
+
+        else if node.nodeType == Node.ATTRIBUTE_NODE
+          nodeData.name  = node.nodeName
+          nodeData.value = node.nodeValue
+
+        nodeData
+
+    #---------------------------------------------------------------------------
+    serializeNodeChildren: (node, depth) ->
+        result   = []
+        childIds = @childNodeIds(node)
+
+        if depth == 0
+            if childIds.length == 1
+                childNode = @getNode(childIds[0])
+                if childNode.nodeType == Node.TEXT_NODE
+                    result.push @serializeNode(childNode)
+            return result
+
+        depth--
+        i = 0
+
+        while i < childIds.length
+            result.push @serializeNode(@getNode(childIds[i]), depth)
+            i++
+
+        result
+
+    #---------------------------------------------------------------------------
+    childNodeCount: (node) ->
+        @childNodeIds(node).length
+
+    #---------------------------------------------------------------------------
+    childNodeIds: (node) ->
+        ids = []
+        i = 0
+
+        for childNode in node.childNodes
+            continue if @isToBeSkipped(childNode)
+            ids.push @getNodeId(childNode)
+
+        ids
+
+    #---------------------------------------------------------------------------
+    isToBeSkipped: (node) ->
+        return true unless node
+        return true if node.__weinreHighlighter
+        return false unless node.nodeType == Node.TEXT_NODE
+
+        not not node.nodeValue.match(/^\s*$/)
+
+#-------------------------------------------------------------------------------
+handleDOMSubtreeModified = (event) ->
+      return unless event.attrChange
+      NodeStore.handleDOMAttrModified event
+
+#-------------------------------------------------------------------------------
+handleDOMNodeInserted = (event) ->
+      targetId = Weinre.nodeStore.checkNodeId(event.target)
+      parentId = Weinre.nodeStore.checkNodeId(event.relatedNode)
+
+      return unless parentId
+
+      child    = Weinre.nodeStore.serializeNode(event.target, 0)
+      previous = Weinre.nodeStore.getPreviousSiblingId(event.target)
+      Weinre.wi.DOMNotify.childNodeInserted parentId, previous, child
+
+#-------------------------------------------------------------------------------
+handleDOMNodeRemoved = (event) ->
+      targetId = Weinre.nodeStore.checkNodeId(event.target)
+      parentId = Weinre.nodeStore.checkNodeId(event.relatedNode)
+      return unless parentId
+
+      if targetId
+          Weinre.wi.DOMNotify.childNodeRemoved parentId, targetId
+      else
+          childCount = Weinre.nodeStore.childNodeCount(event.relatedNode)
+          Weinre.wi.DOMNotify.childNodeCountUpdated parentId, childCount
+
+#-------------------------------------------------------------------------------
+handleDOMAttrModified = (event) ->
+      targetId = Weinre.nodeStore.checkNodeId(event.target)
+      return unless targetId
+      attrs = []
+      i = 0
+
+      while i < event.target.attributes.length
+          attrs.push event.target.attributes[i].name
+          attrs.push event.target.attributes[i].value
+          i++
+
+      Weinre.wi.DOMNotify.attributesUpdated targetId, attrs
+
+#-------------------------------------------------------------------------------
+handleDOMCharacterDataModified = (event) ->
+      targetId = Weinre.nodeStore.checkNodeId(event.target)
+      return unless targetId
+      Weinre.wi.DOMNotify.characterDataModified targetId, event.newValue
+
+#-------------------------------------------------------------------------------
+require("../common/MethodNamer").setNamesForClass(module.exports)

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/9f1c7663/weinre.web/modules/weinre/target/NodeStore.scoop
----------------------------------------------------------------------
diff --git a/weinre.web/modules/weinre/target/NodeStore.scoop b/weinre.web/modules/weinre/target/NodeStore.scoop
deleted file mode 100644
index f8b288f..0000000
--- a/weinre.web/modules/weinre/target/NodeStore.scoop
+++ /dev/null
@@ -1,235 +0,0 @@
-
-/*
- * weinre is available under *either* the terms of the modified BSD license *or* the
- * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
- * 
- * Copyright (c) 2010, 2011 IBM Corporation
- */
-
-requireClass ../common/Weinre
-requireClass ../common/IDGenerator
-
-//-----------------------------------------------------------------------------
-class NodeStore
-    this.__nodeMap      = {}
-    this.__nodeDataMap  = {}
-    this.inspectedNodes = []
-    
-    document.addEventListener("DOMSubtreeModified",       handleDOMSubtreeModified, false)
-    document.addEventListener("DOMNodeInserted",          handleDOMNodeInserted, false)
-    document.addEventListener("DOMNodeRemoved",           handleDOMNodeRemoved, false)
-    document.addEventListener("DOMAttrModified",          handleDOMAttrModified, false)
-    document.addEventListener("DOMCharacterDataModified", handleDOMCharacterDataModified, false)
-
-//-----------------------------------------------------------------------------
-method addInspectedNode(nodeId)
-    this.inspectedNodes.unshift(nodeId)
-    if (this.inspectedNodes.length > 5) {
-        this.inspectedNodes = this.inspectedNodes.slice(0,5)
-    }
-
-//-----------------------------------------------------------------------------
-method getInspectedNode(index)
-    return this.inspectedNodes[index]
-
-//-----------------------------------------------------------------------------
-method getNode(nodeId)
-    return this.__nodeMap[nodeId]
-
-//-----------------------------------------------------------------------------
-method checkNodeId(node)
-    return IDGenerator.checkId(node)
-
-//-----------------------------------------------------------------------------
-method getNodeId(node)
-    var id = this.checkNodeId(node)
-    if (id) {
-        return id
-    }
-
-    return IDGenerator.getId(node, this.__nodeMap)    
-
-//-----------------------------------------------------------------------------
-method getNodeData(nodeId, depth)
-    return this.serializeNode(this.getNode(nodeId), depth)
-
-//-----------------------------------------------------------------------------
-method getPreviousSiblingId(node)
-    while (true) {
-        var sib = node.previousSibling
-        if (!sib) return 0
-        
-        var id = this.checkNodeId(sib)
-        if (id) return id
-        
-        node = sib
-    }
-
-//-----------------------------------------------------------------------------
-method nextNodeId()
-    return "" + IDGenerator.next()
-
-//-----------------------------------------------------------------------------
-method serializeNode(node, depth)
-    var nodeName  = ""
-    var nodeValue = null
-    var localName = null
-    var id = this.getNodeId(node) 
-    
-    switch(node.nodeType) {
-        case Node.TEXT_NODE:    
-        case Node.COMMENT_NODE:
-        case Node.CDATA_SECTION_NODE:
-            nodeValue = node.nodeValue
-            break
-        case Node.ATTRIBUTE_NODE:
-            localName = node.localName
-            break
-        case Node.DOCUMENT_FRAGMENT_NODE:
-            break
-        case Node.DOCUMENT_NODE:
-        case Node.ELEMENT_NODE:
-        default:
-            nodeName  = node.nodeName
-            localName = node.localName
-            break
-    }
-    
-    var nodeData = {
-        id:        id,
-        nodeType:  node.nodeType,
-        nodeName:  nodeName,
-        localName: localName,
-        nodeValue: nodeValue
-    }
-    
-    if (node.nodeType == Node.ELEMENT_NODE || node.nodeType == Node.DOCUMENT_NODE || node.nodeType == Node.DOCUMENT_FRAGMENT_NODE) {
-        nodeData.childNodeCount = this.childNodeCount(node)
-        var children = this.serializeNodeChildren(node, depth)
-        if (children.length) {
-            nodeData.children = children
-        }
-        
-        if (node.nodeType == Node.ELEMENT_NODE) {
-            nodeData.attributes = []
-            for (var i=0; i<node.attributes.length; i++) {
-                nodeData.attributes.push(node.attributes[i].nodeName)
-                nodeData.attributes.push(node.attributes[i].nodeValue)
-            }
-        } 
-        
-        else if (node.nodeType == Node.DOCUMENT_NODE) {
-            nodeData.documentURL = window.location.href
-        }
-    } 
-    
-    else if (node.nodeType == Node.DOCUMENT_TYPE_NODE) {
-        nodeData.publicId       = node.publicId
-        nodeData.systemId       = node.systemId
-        nodeData.internalSubset = node.internalSubset
-    } 
-    
-    else if (node.nodeType == Node.ATTRIBUTE_NODE) {
-        nodeData.name  = node.nodeName
-        nodeData.value = node.nodeValue
-    }
-
-    return nodeData
-
-//-----------------------------------------------------------------------------
-method serializeNodeChildren(node, depth)
-    var result   = []
-    var childIds = this.childNodeIds(node)
-    
-    if (depth == 0) {
-        if (childIds.length == 1) {
-            var childNode = this.getNode(childIds[0])
-            if (childNode.nodeType == Node.TEXT_NODE) {
-                result.push(this.serializeNode(childNode))
-            }
-        }
-        return result
-    }
-    
-    depth--;
-    for (var i=0; i<childIds.length; i++) {
-        result.push(this.serializeNode(this.getNode(childIds[i]), depth))
-    }
-    
-    return result
-
-//-----------------------------------------------------------------------------
-method childNodeCount(node)
-    return this.childNodeIds(node).length
-
-//-----------------------------------------------------------------------------
-method childNodeIds(node)
-    var ids = []
-    
-    for (var i=0; i<node.childNodes.length; i++) {
-        if (this.isToBeSkipped(node.childNodes[i])) continue
-        ids.push(this.getNodeId(node.childNodes[i]))
-    }
-    
-    return ids
-
-//-----------------------------------------------------------------------------
-method isToBeSkipped(node)
-    if (!node) return true
-    if (node.__weinreHighlighter) return true 
-    if (node.nodeType != Node.TEXT_NODE) return false
-    return !!node.nodeValue.match(/^\s*$/) 
-
-//-----------------------------------------------------------------------------
-function handleDOMSubtreeModified(event)
-    if (!event.attrChange) return
-    
-    NodeStore.handleDOMAttrModified(event)
-
-//-----------------------------------------------------------------------------
-function handleDOMNodeInserted(event)
-    var targetId = Weinre.nodeStore.checkNodeId(event.target)
-    var parentId = Weinre.nodeStore.checkNodeId(event.relatedNode)
-    
-    if (!parentId) return
-    
-    var child = Weinre.nodeStore.serializeNode(event.target, 0)
-    var previous = Weinre.nodeStore.getPreviousSiblingId(event.target)
-    Weinre.wi.DOMNotify.childNodeInserted(parentId, previous, child)
-
-//-----------------------------------------------------------------------------
-function handleDOMNodeRemoved(event)
-    var targetId = Weinre.nodeStore.checkNodeId(event.target)
-    var parentId = Weinre.nodeStore.checkNodeId(event.relatedNode)
-    
-    if (!parentId) return
-    
-    if (targetId) {
-        Weinre.wi.DOMNotify.childNodeRemoved(parentId, targetId)
-    }
-    else {
-        var childCount = Weinre.nodeStore.childNodeCount(event.relatedNode)
-        Weinre.wi.DOMNotify.childNodeCountUpdated(parentId, childCount)
-    }
-
-//-----------------------------------------------------------------------------
-// This event is not actually fired in WebKit, but DOMSubtreeModified may
-// be fired for attribute changes.  Doesn't seem to be at the moment.
-function handleDOMAttrModified(event)
-    var targetId = Weinre.nodeStore.checkNodeId(event.target)
-    if (!targetId) return
-    
-    attrs = []
-    for (var i=0; i<event.target.attributes.length; i++) {
-        attrs.push(event.target.attributes[i].name)
-        attrs.push(event.target.attributes[i].value)
-    }
-    
-    Weinre.wi.DOMNotify.attributesUpdated(targetId, attrs)
-
-//-----------------------------------------------------------------------------
-function handleDOMCharacterDataModified(event)
-    var targetId = Weinre.nodeStore.checkNodeId(event.target)
-    if (!targetId) return
-    
-    Weinre.wi.DOMNotify.characterDataModified(targetId, event.newValue)

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/9f1c7663/weinre.web/modules/weinre/target/SqlStepper.coffee
----------------------------------------------------------------------
diff --git a/weinre.web/modules/weinre/target/SqlStepper.coffee b/weinre.web/modules/weinre/target/SqlStepper.coffee
new file mode 100644
index 0000000..82b5997
--- /dev/null
+++ b/weinre.web/modules/weinre/target/SqlStepper.coffee
@@ -0,0 +1,91 @@
+
+#---------------------------------------------------------------------------------
+# weinre is available under *either* the terms of the modified BSD license *or* the
+# MIT License (2008). See http:#opensource.org/licenses/alphabetical for full text.
+#
+# Copyright (c) 2010, 2011 IBM Corporation
+#---------------------------------------------------------------------------------
+
+Binding = require('../common/Binding')
+
+#-------------------------------------------------------------------------------
+module.exports = class SqlStepper
+
+    constructor: (steps) ->
+        return new SqlStepper(steps) unless (this instanceof SqlStepper)
+
+        @__context = {}
+
+        context = @__context
+        context.steps = steps
+
+    #---------------------------------------------------------------------------
+    run: (db, errorCallback) ->
+        context = @__context
+        if context.hasBeenRun
+            throw new Ex(arguments, "stepper has already been run")
+
+        context.hasBeenRun       = true
+        context.db               = db
+        context.errorCallback    = errorCallback
+        context.nextStep         = 0
+        context.ourErrorCallback = new Binding(this, ourErrorCallback)
+        context.runStep          = new Binding(this, runStep)
+
+        @executeSql = new Binding(this, executeSql)
+
+        db.transaction context.runStep
+
+    #---------------------------------------------------------------------------
+    @example: (db, id) ->
+        step1 = ->
+            @executeSql "SELECT name FROM sqlite_master WHERE type='table'"
+
+        step2 = (resultSet) ->
+            rows = resultSet.rows
+            result = []
+
+            i = 0
+            while i < rows.length
+                name = rows.item(i).name
+                if name == "__WebKitDatabaseInfoTable__"
+                    i++
+                    continue
+
+                result.push name
+                i++
+
+            console.log "[#{@id}] table names: " + result.join(", ")
+
+        errorCb = (sqlError) ->
+            console.log "[#{@id}] sql error:#{sqlError.code}: " + sqlError.message
+
+        stepper = new SqlStepper([ step1, step2 ])
+        stepper.id = id
+        stepper.run db, errorCb
+
+
+#-------------------------------------------------------------------------------
+executeSql = (statement, data) ->
+      context = @__context
+      context.tx.executeSql statement, data, context.runStep, context.ourErrorCallback
+
+#-------------------------------------------------------------------------------
+ourErrorCallback = (tx, sqlError) ->
+      context = @__context
+      context.errorCallback.call this, sqlError
+
+#-------------------------------------------------------------------------------
+runStep = (tx, resultSet) ->
+      context = @__context
+      return if context.nextStep >= context.steps.length
+
+      context.tx = tx
+      context.currentStep = context.nextStep
+      context.nextStep++
+
+      step = context.steps[context.currentStep]
+      step.call this, resultSet
+
+#-------------------------------------------------------------------------------
+require("../common/MethodNamer").setNamesForClass(module.exports)

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/9f1c7663/weinre.web/modules/weinre/target/SqlStepper.scoop
----------------------------------------------------------------------
diff --git a/weinre.web/modules/weinre/target/SqlStepper.scoop b/weinre.web/modules/weinre/target/SqlStepper.scoop
deleted file mode 100644
index 3789812..0000000
--- a/weinre.web/modules/weinre/target/SqlStepper.scoop
+++ /dev/null
@@ -1,92 +0,0 @@
-
-/*
- * weinre is available under *either* the terms of the modified BSD license *or* the
- * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
- * 
- * Copyright (c) 2010, 2011 IBM Corporation
- */
-
-requireClass ../common/Binding
-
-//-----------------------------------------------------------------------------
-class SqlStepper(steps)
-    if (!(this instanceof SqlStepper)) return new SqlStepper(steps)
-    
-    this.__context = {}
-    
-    var context = this.__context
-    context.steps = steps
-    
-//-----------------------------------------------------------------------------
-method run(db, errorCallback)
-    var context = this.__context
-    
-    if (context.hasBeenRun) 
-        throw new Ex(arguments, "stepper has already been run")
-        
-    context.hasBeenRun = true
-        
-    context.db            = db
-    context.errorCallback = errorCallback
-    context.nextStep      = 0
-    
-    context.ourErrorCallback = new Binding(this, ourErrorCallback)
-    context.runStep          = new Binding(this, runStep)
-    this.executeSql          = new Binding(this, executeSql)
-    
-    db.transaction(context.runStep)
-    
-//-----------------------------------------------------------------------------
-function executeSql(statement, data)
-    var context = this.__context
-    
-    context.tx.executeSql(statement, data, context.runStep, context.ourErrorCallback)
-
-//-----------------------------------------------------------------------------
-function ourErrorCallback(tx, sqlError)
-    var context = this.__context
-    
-    context.errorCallback.call(this, sqlError)
-    
-//-----------------------------------------------------------------------------
-function runStep(tx, resultSet)
-    var context = this.__context
-    
-    if (context.nextStep >= context.steps.length) return
-    
-    context.tx = tx
-    
-    context.currentStep = context.nextStep
-    context.nextStep++
-    
-    var step = context.steps[context.currentStep]
-    
-    step.call(this, resultSet)
-
-//-----------------------------------------------------------------------------
-static method example(db, id)
-    function step1() {
-        this.executeSql("SELECT name FROM sqlite_master WHERE type='table'")
-    }
-    
-    function step2(resultSet) {
-        var rows = resultSet.rows
-        var result = []
-        for (var i=0; i<rows.length; i++) {
-            var name = rows.item(i).name
-            if (name == "__WebKitDatabaseInfoTable__") continue
-        
-            result.push(name)
-        }
-        
-        console.log("[" + this.id + "] table names: " + result.join(", "))
-    }
-
-    function errorCb(sqlError) {
-        
-        console.log("[" + this.id + "] sql error:" + sqlError.code + ": " + sqlError.message)
-    }
-    
-    var stepper = new SqlStepper([step1, step2])
-    stepper.id = id
-    stepper.run(db, errorCb)

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/9f1c7663/weinre.web/modules/weinre/target/Target.coffee
----------------------------------------------------------------------
diff --git a/weinre.web/modules/weinre/target/Target.coffee b/weinre.web/modules/weinre/target/Target.coffee
new file mode 100644
index 0000000..130a05b
--- /dev/null
+++ b/weinre.web/modules/weinre/target/Target.coffee
@@ -0,0 +1,202 @@
+
+#---------------------------------------------------------------------------------
+# weinre is available under *either* the terms of the modified BSD license *or* the
+# MIT License (2008). See http:#opensource.org/licenses/alphabetical for full text.
+#
+# Copyright (c) 2010, 2011 IBM Corporation
+#---------------------------------------------------------------------------------
+
+Native                        = require('../common/Native')
+Ex                            = require('../common/Ex')
+Binding                       = require('../common/Binding')
+Callback                      = require('../common/Callback')
+MessageDispatcher             = require('../common/MessageDispatcher')
+Weinre                        = require('../common/Weinre')
+
+CheckForProblems              = require('./CheckForProblems')
+NodeStore                     = require('./NodeStore')
+CSSStore                      = require('./CSSStore')
+ElementHighlighter            = require('./ElementHighlighter')
+InjectedScriptHostImpl        = require('./InjectedScriptHostImpl')
+WeinreTargetEventsImpl        = require('./WeinreTargetEventsImpl')
+WeinreExtraClientCommandsImpl = require('./WeinreExtraClientCommandsImpl')
+WiConsoleImpl                 = require('./WiConsoleImpl')
+WiCSSImpl                     = require('./WiCSSImpl')
+WiDatabaseImpl                = require('./WiDatabaseImpl')
+WiDOMImpl                     = require('./WiDOMImpl')
+WiDOMStorageImpl              = require('./WiDOMStorageImpl')
+WiInspectorImpl               = require('./WiInspectorImpl')
+WiRuntimeImpl                 = require('./WiRuntimeImpl')
+
+#-------------------------------------------------------------------------------
+module.exports = class Target
+
+    constructor: ->
+
+    #---------------------------------------------------------------------------
+    @main: ->
+        CheckForProblems.check()
+        Weinre.target = new Target()
+        Weinre.target.initialize()
+
+        Weinre.addCSSProperties = addCSSProperties = (properties) ->
+            CSSStore.addCSSProperties properties
+
+    #----------------------------------------------------------------------------
+    setWeinreServerURLFromScriptSrc: (element) ->
+        return if window.WeinreServerURL
+
+        if element
+            pattern = /(http:\/\/(.*?)\/)/
+            match = pattern.exec(element.src)
+            if match
+                window.WeinreServerURL = match[1]
+                return
+
+        message = "unable to calculate the weinre server url; explicity set the variable window.WeinreServerURL instead"
+        alert message
+        throw new Ex(arguments, message)
+
+    #---------------------------------------------------------------------------
+    setWeinreServerIdFromScriptSrc: (element) ->
+        return if window.WeinreServerId
+
+        element = @getTargetScriptElement()
+        hash    = "anonymous"
+
+        if element
+            attempt = element.src.split("#")[1]
+            if attempt
+                hash = attempt
+            else
+                attempt = location.hash.split("#")[1]
+                hash = attempt if attempt
+
+        window.WeinreServerId = hash
+
+    #---------------------------------------------------------------------------
+    getTargetScriptElement: ->
+        elements = document.getElementsByTagName("script")
+        scripts = [ "Target.", "target-script.", "target-script-min." ]
+        i = 0
+
+        while i < elements.length
+            element = elements[i]
+            j = 0
+            while j < scripts.length
+                return element unless -1 == element.src.indexOf("/" + scripts[j])
+                j++
+            i++
+
+    #---------------------------------------------------------------------------
+    initialize: () ->
+        self = this
+
+        element = @getTargetScriptElement()
+
+        @setWeinreServerURLFromScriptSrc element
+        @setWeinreServerIdFromScriptSrc element
+
+        window.WeinreServerURL += "/" unless window.WeinreServerURL[window.WeinreServerURL.length - 1] == "/"
+        injectedScriptHost = new InjectedScriptHostImpl()
+        Weinre.injectedScript = injectedScriptConstructor(injectedScriptHost, window, 0, "?")
+
+        window.addEventListener "load", Binding(this, "onLoaded"), false
+        document.addEventListener "DOMContentLoaded", Binding(this, "onDOMContent"), false
+
+        @_startTime = currentTime()
+        if document.readyState == "loaded"
+            setTimeout (->
+                self.onDOMContent()
+            ), 10
+
+        if document.readyState == "complete"
+            setTimeout (->
+                self.onDOMContent()
+            ), 10
+            setTimeout (->
+                self.onLoaded()
+            ), 20
+
+#        MessageDispatcher.verbose(true)
+        messageDispatcher = new MessageDispatcher(window.WeinreServerURL + "ws/target", window.WeinreServerId)
+        Weinre.messageDispatcher = messageDispatcher
+
+        Weinre.wi = {}
+        Weinre.wi.Console    = new WiConsoleImpl()
+        Weinre.wi.CSS        = new WiCSSImpl()
+        Weinre.wi.Database   = new WiDatabaseImpl()
+        Weinre.wi.DOM        = new WiDOMImpl()
+        Weinre.wi.DOMStorage = new WiDOMStorageImpl()
+        Weinre.wi.Inspector  = new WiInspectorImpl()
+        Weinre.wi.Runtime    = new WiRuntimeImpl()
+
+        messageDispatcher.registerInterface "Console",    Weinre.wi.Console, false
+        messageDispatcher.registerInterface "CSS",        Weinre.wi.CSS, false
+        messageDispatcher.registerInterface "Database",   Weinre.wi.Database, false
+        messageDispatcher.registerInterface "DOM",        Weinre.wi.DOM, false
+        messageDispatcher.registerInterface "DOMStorage", Weinre.wi.DOMStorage, false
+        messageDispatcher.registerInterface "Inspector",  Weinre.wi.Inspector, false
+        messageDispatcher.registerInterface "Runtime",    Weinre.wi.Runtime, false
+
+        messageDispatcher.registerInterface "WeinreExtraClientCommands", new WeinreExtraClientCommandsImpl(), true
+        messageDispatcher.registerInterface "WeinreTargetEvents",        new WeinreTargetEventsImpl(), true
+
+        Weinre.wi.ApplicationCacheNotify = messageDispatcher.createProxy("ApplicationCacheNotify")
+        Weinre.wi.ConsoleNotify          = messageDispatcher.createProxy("ConsoleNotify")
+        Weinre.wi.DOMNotify              = messageDispatcher.createProxy("DOMNotify")
+        Weinre.wi.DOMStorageNotify       = messageDispatcher.createProxy("DOMStorageNotify")
+        Weinre.wi.DatabaseNotify         = messageDispatcher.createProxy("DatabaseNotify")
+        Weinre.wi.InspectorNotify        = messageDispatcher.createProxy("InspectorNotify")
+        Weinre.wi.TimelineNotify         = messageDispatcher.createProxy("TimelineNotify")
+        Weinre.WeinreTargetCommands      = messageDispatcher.createProxy("WeinreTargetCommands")
+        Weinre.WeinreExtraTargetEvents   = messageDispatcher.createProxy("WeinreExtraTargetEvents")
+
+        messageDispatcher.getWebSocket().addEventListener "open", Binding(this, @cb_webSocketOpened)
+
+        Weinre.nodeStore = new NodeStore()
+        Weinre.cssStore  = new CSSStore()
+
+        window.addEventListener "error", ((e) ->
+            Target.handleError e
+        ), false
+
+    #---------------------------------------------------------------------------
+    @handleError: (event) ->
+        filename = event.filename or "[unknown filename]"
+        lineno   = event.lineno   or "[unknown lineno]"
+        message  = event.message  or "[unknown message]"
+
+        Weinre.logError "error occurred: #{filename}:#{lineno}: " + message
+
+    #---------------------------------------------------------------------------
+    cb_webSocketOpened: () ->
+        Weinre.WeinreTargetCommands.registerTarget window.location.href, Binding(this, @cb_registerTarget)
+
+    #---------------------------------------------------------------------------
+    cb_registerTarget: (targetDescription) ->
+        Weinre.targetDescription = targetDescription
+
+    #---------------------------------------------------------------------------
+    onLoaded: ->
+        Weinre.wi.InspectorNotify.loadEventFired currentTime() - @_startTime
+
+    #---------------------------------------------------------------------------
+    onDOMContent: ->
+        Weinre.wi.InspectorNotify.domContentEventFired currentTime() - @_startTime
+
+    #---------------------------------------------------------------------------
+    setDocument: () ->
+        Weinre.elementHighlighter = new ElementHighlighter()
+
+        nodeId   = Weinre.nodeStore.getNodeId(document)
+        nodeData = Weinre.nodeStore.getNodeData(nodeId, 2)
+        Weinre.wi.DOMNotify.setDocument nodeData
+
+#-------------------------------------------------------------------------------
+currentTime = () ->
+      (new Date().getMilliseconds()) / 1000.0
+
+
+#-------------------------------------------------------------------------------
+require("../common/MethodNamer").setNamesForClass(module.exports)

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/9f1c7663/weinre.web/modules/weinre/target/Target.scoop
----------------------------------------------------------------------
diff --git a/weinre.web/modules/weinre/target/Target.scoop b/weinre.web/modules/weinre/target/Target.scoop
deleted file mode 100644
index bb3eeae..0000000
--- a/weinre.web/modules/weinre/target/Target.scoop
+++ /dev/null
@@ -1,212 +0,0 @@
-
-/*
- * weinre is available under *either* the terms of the modified BSD license *or* the
- * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
- * 
- * Copyright (c) 2010, 2011 IBM Corporation
- */
-
-requireClass ../common/Native
-
-requireClass ../common/Ex
-requireClass ../common/Binding
-requireClass ../common/Callback
-requireClass ../common/MessageDispatcher
-requireClass ../common/Weinre
-
-requireClass ./CheckForProblems
-requireClass ./NodeStore
-requireClass ./CSSStore
-requireClass ./ElementHighlighter
-requireClass ./InjectedScriptHostImpl
-
-requireClass ./WeinreTargetEventsImpl
-requireClass ./WeinreExtraClientCommandsImpl
-
-requireClass ./WiConsoleImpl
-requireClass ./WiCSSImpl
-requireClass ./WiDatabaseImpl
-requireClass ./WiDOMImpl
-requireClass ./WiDOMStorageImpl
-requireClass ./WiInspectorImpl
-requireClass ./WiRuntimeImpl
-
-//-----------------------------------------------------------------------------
-class Target
-
-//-----------------------------------------------------------------------------
-static method main
-    CheckForProblems.check()
-    
-    Weinre.target = new Target()
-    Weinre.target.initialize()
-    
-    Weinre.addCSSProperties = function addCSSProperties(properties) {
-        CSSStore.addCSSProperties(properties)
-    }
-    
-//------------------------------------------------------------------------------
-method setWeinreServerURLFromScriptSrc(element)
-    if (window.WeinreServerURL) return
-
-    if (element) {
-        var pattern = /(http:\/\/(.*?)\/)/
-        var match   = pattern.exec(element.src)
-        if (match) {
-            window.WeinreServerURL = match[1]
-            return 
-        }
-    }
-    
-    var message = "unable to calculate the weinre server url; explicity set the variable window.WeinreServerURL instead" 
-    alert(message)
-    throw new Ex(arguments, message)
-
-
-//-----------------------------------------------------------------------------
-method setWeinreServerIdFromScriptSrc(element)
-    if (window.WeinreServerId) return
-
-    var element = this.getTargetScriptElement()
-
-    var hash = "anonymous"
-    if (element) {
-        var attempt = element.src.split("#")[1]
-        if (attempt) {
-            hash = attempt
-        }
-        else {
-            attempt = location.hash.split("#")[1]
-            if (attempt) {
-                hash = attempt
-            }
-        }
-    }
-
-    window.WeinreServerId = hash
-
-//-----------------------------------------------------------------------------
-method getTargetScriptElement
-
-    var elements = document.getElementsByTagName("script")
-
-    var scripts = ["Target.", "target-script.", "target-script-min."]
-    for (var i=0; i<elements.length; i++) {
-        var element = elements[i]
-        
-        for (j=0; j<scripts.length; j++) {
-            if (-1 != element.src.indexOf("/" + scripts[j])) {
-                return element
-            }
-        }
-    }
-
-//-----------------------------------------------------------------------------
-method initialize()
-    var self = this
-
-    var element = this.getTargetScriptElement()
-    this.setWeinreServerURLFromScriptSrc(element)
-    this.setWeinreServerIdFromScriptSrc(element)
-    
-    if (window.WeinreServerURL[window.WeinreServerURL.length-1] != "/") {
-        window.WeinreServerURL += "/"
-    }   
-    
-    var injectedScriptHost = new InjectedScriptHostImpl()
-    Weinre.injectedScript = injectedScriptConstructor(injectedScriptHost, window, 0, "?")
-    
-    window.addEventListener("load", Binding(this, "onLoaded"), false)
-    document.addEventListener("DOMContentLoaded", Binding(this, "onDOMContent"), false)
-    
-    this._startTime = currentTime()
-    
-    if (document.readyState == "loaded") {
-        setTimeout(function() { self.onDOMContent() }, 10)
-    }
-    
-    if (document.readyState == "complete") {
-        setTimeout(function() { self.onDOMContent() }, 10)
-        setTimeout(function() { self.onLoaded() }, 20)
-    }
-
-    var messageDispatcher = new MessageDispatcher(window.WeinreServerURL + "ws/target", window.WeinreServerId)
-    Weinre.messageDispatcher = messageDispatcher
-
-    Weinre.wi = {}
-    
-    Weinre.wi.Console                   = new WiConsoleImpl()
-    Weinre.wi.CSS                       = new WiCSSImpl()
-    Weinre.wi.Database                  = new WiDatabaseImpl()
-    Weinre.wi.DOM                       = new WiDOMImpl()
-    Weinre.wi.DOMStorage                = new WiDOMStorageImpl()
-    Weinre.wi.Inspector                 = new WiInspectorImpl()
-    Weinre.wi.Runtime                   = new WiRuntimeImpl()
-    
-    messageDispatcher.registerInterface("Console",          Weinre.wi.Console          , false)
-    messageDispatcher.registerInterface("CSS",              Weinre.wi.CSS              , false)
-    messageDispatcher.registerInterface("Database",         Weinre.wi.Database         , false)
-    messageDispatcher.registerInterface("DOM",              Weinre.wi.DOM              , false)
-    messageDispatcher.registerInterface("DOMStorage",       Weinre.wi.DOMStorage       , false)
-    messageDispatcher.registerInterface("Inspector",        Weinre.wi.Inspector        , false)
-    messageDispatcher.registerInterface("Runtime",          Weinre.wi.Runtime          , false)
-
-    messageDispatcher.registerInterface("WeinreExtraClientCommands",  new WeinreExtraClientCommandsImpl() , true)
-    messageDispatcher.registerInterface("WeinreTargetEvents",         new WeinreTargetEventsImpl(),         true)
-
-    Weinre.wi.ApplicationCacheNotify = messageDispatcher.createProxy("ApplicationCacheNotify")
-    Weinre.wi.ConsoleNotify          = messageDispatcher.createProxy("ConsoleNotify")
-    Weinre.wi.DOMNotify              = messageDispatcher.createProxy("DOMNotify")
-    Weinre.wi.DOMStorageNotify       = messageDispatcher.createProxy("DOMStorageNotify")
-    Weinre.wi.DatabaseNotify         = messageDispatcher.createProxy("DatabaseNotify")
-    Weinre.wi.InspectorNotify        = messageDispatcher.createProxy("InspectorNotify")
-    Weinre.wi.TimelineNotify         = messageDispatcher.createProxy("TimelineNotify")
-    
-    Weinre.WeinreTargetCommands     = messageDispatcher.createProxy("WeinreTargetCommands")
-    Weinre.WeinreExtraTargetEvents  = messageDispatcher.createProxy("WeinreExtraTargetEvents")
-
-    messageDispatcher.getWebSocket().addEventListener("open", Binding(this, this.cb_webSocketOpened))
-    
-    Weinre.nodeStore = new NodeStore()
-    Weinre.cssStore  = new CSSStore()
-    
-    window.addEventListener("error", function(e) {Target.handleError(e)}, false)
-    
-    
-//-----------------------------------------------------------------------------
-static method handleError(event)
-    var filename = event.filename || "[unknown filename]"
-    var lineno   = event.lineno   || "[unknown lineno]"
-    var message  = event.message  || "[unknown message]"
-
-    Weinre.logError("error occurred: " + filename + ":" + lineno + ": " + message)
-
-//-----------------------------------------------------------------------------
-method cb_webSocketOpened()
-    Weinre.WeinreTargetCommands.registerTarget(window.location.href, Binding(this, this.cb_registerTarget))
-
-//-----------------------------------------------------------------------------
-method cb_registerTarget(targetDescription)
-    Weinre.targetDescription    = targetDescription
-
-//-----------------------------------------------------------------------------
-method onLoaded
-    Weinre.wi.InspectorNotify.loadEventFired(currentTime() - this._startTime)
-
-//-----------------------------------------------------------------------------
-method onDOMContent
-    Weinre.wi.InspectorNotify.domContentEventFired(currentTime() - this._startTime)
-
-//-----------------------------------------------------------------------------
-method setDocument()
-    Weinre.elementHighlighter = new ElementHighlighter()
-    
-    var nodeId = Weinre.nodeStore.getNodeId(document)
-    var nodeData = Weinre.nodeStore.getNodeData(nodeId, 2)
-
-    Weinre.wi.DOMNotify.setDocument(nodeData)
-    
-//-----------------------------------------------------------------------------
-// WebKit's currentTime() seems to return time in seconds
-function currentTime()
-    return (new Date().getMilliseconds()) / 1000.0
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/9f1c7663/weinre.web/modules/weinre/target/Timeline.coffee
----------------------------------------------------------------------
diff --git a/weinre.web/modules/weinre/target/Timeline.coffee b/weinre.web/modules/weinre/target/Timeline.coffee
new file mode 100644
index 0000000..488f0e9
--- /dev/null
+++ b/weinre.web/modules/weinre/target/Timeline.coffee
@@ -0,0 +1,348 @@
+
+#---------------------------------------------------------------------------------
+# weinre is available under *either* the terms of the modified BSD license *or* the
+# MIT License (2008). See http:#opensource.org/licenses/alphabetical for full text.
+#
+# Copyright (c) 2010, 2011 IBM Corporation
+#---------------------------------------------------------------------------------
+
+Ex          = require('../common/Ex')
+Weinre      = require('../common/Weinre')
+IDGenerator = require('../common/IDGenerator')
+StackTrace  = require('../common/StackTrace')
+Native      = require('../common/Native')
+
+Running = false
+
+TimerTimeouts  = {}
+TimerIntervals = {}
+
+TimelineRecordType =
+    EventDispatch:            0
+    Layout:                   1
+    RecalculateStyles:        2
+    Paint:                    3
+    ParseHTML:                4
+    TimerInstall:             5
+    TimerRemove:              6
+    TimerFire:                7
+    XHRReadyStateChange:      8
+    XHRLoad:                  9
+    EvaluateScript:          10
+    Mark:                    11
+    ResourceSendRequest:     12
+    ResourceReceiveResponse: 13
+    ResourceFinish:          14
+    FunctionCall:            15
+    ReceiveResourceData:     16
+    GCEvent:                 17
+    MarkDOMContent:          18
+    MarkLoad:                19
+    ScheduleResourceRequest: 20
+
+
+#-------------------------------------------------------------------------------
+module.exports = class Timeline
+
+    constructor: ->
+
+    #---------------------------------------------------------------------------
+    @start: ->
+        Running = true
+
+    #---------------------------------------------------------------------------
+    @stop: ->
+        Running = false
+
+    #---------------------------------------------------------------------------
+    @isRunning: ->
+        Running
+
+    #---------------------------------------------------------------------------
+    @addRecord_Mark: (message) ->
+        return unless Timeline.isRunning()
+
+        record = {}
+        record.type      = TimelineRecordType.Mark
+        record.category  = name: "scripting"
+        record.startTime = Date.now()
+        record.data      = message: message
+
+        addStackTrace record, 3
+
+        Weinre.wi.TimelineNotify.addRecordToTimeline record
+
+    #---------------------------------------------------------------------------
+    @addRecord_EventDispatch: (event, name, category) ->
+        return unless Timeline.isRunning()
+
+        category = "scripting" unless category
+        record = {}
+        record.type      = TimelineRecordType.EventDispatch
+        record.category  = name: category
+        record.startTime = Date.now()
+        record.data      = type: event.type
+
+        Weinre.wi.TimelineNotify.addRecordToTimeline record
+
+    #---------------------------------------------------------------------------
+    @addRecord_TimerInstall: (id, timeout, singleShot) ->
+        return unless Timeline.isRunning()
+
+        record = {}
+        record.type      = TimelineRecordType.TimerInstall
+        record.category  = name: "scripting"
+        record.startTime = Date.now()
+        record.data =
+            timerId:    id
+            timeout:    timeout
+            singleShot: singleShot
+
+        addStackTrace record, 4
+
+        Weinre.wi.TimelineNotify.addRecordToTimeline record
+
+    #---------------------------------------------------------------------------
+    @addRecord_TimerRemove: (id, timeout, singleShot) ->
+        return unless Timeline.isRunning()
+
+        record = {}
+        record.type      = TimelineRecordType.TimerRemove
+        record.category  = name: "scripting"
+        record.startTime = Date.now()
+        record.data =
+            timerId:    id
+            timeout:    timeout
+            singleShot: singleShot
+
+        addStackTrace record, 4
+        Weinre.wi.TimelineNotify.addRecordToTimeline record
+
+    #---------------------------------------------------------------------------
+    @addRecord_TimerFire: (id, timeout, singleShot) ->
+        return unless Timeline.isRunning()
+
+        record = {}
+        record.type      = TimelineRecordType.TimerFire
+        record.category  = name: "scripting"
+        record.startTime = Date.now()
+        record.data =
+            timerId:    id
+            timeout:    timeout
+            singleShot: singleShot
+
+        Weinre.wi.TimelineNotify.addRecordToTimeline record
+
+    #---------------------------------------------------------------------------
+    @addRecord_XHRReadyStateChange: (method, url, id, xhr) ->
+        return unless Timeline.isRunning()
+
+        if xhr.readyState == XMLHttpRequest.OPENED
+            record =
+                type:      TimelineRecordType.ResourceSendRequest
+                category:  name: "loading"
+                startTime: Date.now()
+                data:
+                    identifier:    id
+                    url:           url
+                    requestMethod: method
+
+        else if xhr.readyState == XMLHttpRequest.DONE
+            record =
+                type: TimelineRecordType.ResourceReceiveResponse
+                category: name: "loading"
+                startTime: Date.now()
+                data:
+                    identifier:            id
+                    statusCode:            xhr.status
+                    mimeType:              xhr.getResponseHeader("Content-Type")
+                    expectedContentLength: xhr.getResponseHeader("Content-Length")
+                    url:                   url
+        else
+            return
+
+        Weinre.wi.TimelineNotify.addRecordToTimeline record
+
+    #---------------------------------------------------------------------------
+    @installGlobalListeners: ->
+        if applicationCache
+            applicationCache.addEventListener "checking", ((e) ->
+                Timeline.addRecord_EventDispatch e, "applicationCache.checking", "loading"
+            ), false
+
+            applicationCache.addEventListener "error", ((e) ->
+                Timeline.addRecord_EventDispatch e, "applicationCache.error", "loading"
+            ), false
+
+            applicationCache.addEventListener "noupdate", ((e) ->
+                Timeline.addRecord_EventDispatch e, "applicationCache.noupdate", "loading"
+            ), false
+
+            applicationCache.addEventListener "downloading", ((e) ->
+                Timeline.addRecord_EventDispatch e, "applicationCache.downloading", "loading"
+            ), false
+
+            applicationCache.addEventListener "progress", ((e) ->
+                Timeline.addRecord_EventDispatch e, "applicationCache.progress", "loading"
+            ), false
+
+            applicationCache.addEventListener "updateready", ((e) ->
+                Timeline.addRecord_EventDispatch e, "applicationCache.updateready", "loading"
+            ), false
+
+            applicationCache.addEventListener "cached", ((e) ->
+                Timeline.addRecord_EventDispatch e, "applicationCache.cached", "loading"
+            ), false
+
+            applicationCache.addEventListener "obsolete", ((e) ->
+                Timeline.addRecord_EventDispatch e, "applicationCache.obsolete", "loading"
+            ), false
+
+        window.addEventListener "error", ((e) ->
+            Timeline.addRecord_EventDispatch e, "window.error"
+        ), false
+
+        window.addEventListener "hashchange", ((e) ->
+            Timeline.addRecord_EventDispatch e, "window.hashchange"
+        ), false
+
+        window.addEventListener "message", ((e) ->
+            Timeline.addRecord_EventDispatch e, "window.message"
+        ), false
+
+        window.addEventListener "offline", ((e) ->
+            Timeline.addRecord_EventDispatch e, "window.offline"
+        ), false
+
+        window.addEventListener "online", ((e) ->
+            Timeline.addRecord_EventDispatch e, "window.online"
+        ), false
+
+        window.addEventListener "scroll", ((e) ->
+            Timeline.addRecord_EventDispatch e, "window.scroll"
+        ), false
+
+    #---------------------------------------------------------------------------
+    @installFunctionWrappers: ->
+        window.clearInterval        = wrapped_clearInterval
+        window.clearTimeout         = wrapped_clearTimeout
+        window.setTimeout           = wrapped_setTimeout
+        window.setInterval          = wrapped_setInterval
+        window.XMLHttpRequest::open = wrapped_XMLHttpRequest_open
+        window.XMLHttpRequest       = wrapped_XMLHttpRequest
+
+
+#-------------------------------------------------------------------------------
+addStackTrace = (record, skip) ->
+      skip = 1 unless skip
+      trace = new StackTrace(arguments).trace
+      record.stackTrace = []
+      i = skip
+
+      while i < trace.length
+          record.stackTrace.push
+              functionName: trace[i]
+              scriptName:   ""
+              lineNumber:   ""
+          i++
+
+#-------------------------------------------------------------------------------
+wrapped_setInterval = (code, interval) ->
+      code = instrumentedTimerCode(code, interval, false)
+
+      id = Native.setInterval(code, interval)
+      code.__timerId = id
+      addTimer id, interval, false
+
+      id
+
+#-------------------------------------------------------------------------------
+wrapped_setTimeout = (code, delay) ->
+      code = instrumentedTimerCode(code, delay, true)
+
+      id = Native.setTimeout(code, delay)
+      code.__timerId = id
+      addTimer id, delay, true
+
+      id
+
+#-------------------------------------------------------------------------------
+wrapped_clearInterval = (id) ->
+      result = Native.clearInterval(id)
+      removeTimer id, false
+
+      result
+
+#-------------------------------------------------------------------------------
+wrapped_clearTimeout = (id) ->
+      result = Native.clearTimeout(id)
+      removeTimer id, true
+
+      result
+
+#-------------------------------------------------------------------------------
+addTimer = (id, timeout, singleShot) ->
+      timerSet = (if singleShot then TimerTimeouts else TimerIntervals)
+
+      timerSet[id] =
+          id: id
+          timeout: timeout
+          singleShot: singleShot
+
+      Timeline.addRecord_TimerInstall id, timeout, singleShot
+
+#-------------------------------------------------------------------------------
+removeTimer = (id, singleShot) ->
+      timerSet = (if singleShot then TimerTimeouts else TimerIntervals)
+      timer = timerSet[id]
+      return unless timer
+
+      Timeline.addRecord_TimerRemove id, timer.timeout, singleShot
+      delete timerSet[id]
+
+#-------------------------------------------------------------------------------
+instrumentedTimerCode = (code, timeout, singleShot) ->
+      return code unless typeof (code) == "function"
+
+      instrumentedCode = ->
+          result = code()
+          id = arguments.callee.__timerId
+          Timeline.addRecord_TimerFire id, timeout, singleShot
+          result
+
+      instrumentedCode
+
+#-------------------------------------------------------------------------------
+wrapped_XMLHttpRequest = () ->
+      xhr = new Native.XMLHttpRequest()
+      IDGenerator.getId xhr
+      xhr.addEventListener "readystatechange", getXhrEventHandler(xhr), false
+      xhr
+
+wrapped_XMLHttpRequest.UNSENT           = 0
+wrapped_XMLHttpRequest.OPENED           = 1
+wrapped_XMLHttpRequest.HEADERS_RECEIVED = 2
+wrapped_XMLHttpRequest.LOADING          = 3
+wrapped_XMLHttpRequest.DONE             = 4
+
+#-------------------------------------------------------------------------------
+wrapped_XMLHttpRequest_open = () ->
+      xhr = this
+
+      xhr.__weinre_method = arguments[0]
+      xhr.__weinre_url = arguments[1]
+      result = Native.XMLHttpRequest_open.apply(xhr, [].slice.call(arguments))
+
+      result
+
+#-------------------------------------------------------------------------------
+getXhrEventHandler = (xhr) ->
+      (event) ->
+          Timeline.addRecord_XHRReadyStateChange xhr.__weinre_method, xhr.__weinre_url, IDGenerator.getId(xhr), xhr
+
+#-------------------------------------------------------------------------------
+Timeline.installGlobalListeners()
+Timeline.installFunctionWrappers()
+
+#-------------------------------------------------------------------------------
+require("../common/MethodNamer").setNamesForClass(module.exports)

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/9f1c7663/weinre.web/modules/weinre/target/Timeline.scoop
----------------------------------------------------------------------
diff --git a/weinre.web/modules/weinre/target/Timeline.scoop b/weinre.web/modules/weinre/target/Timeline.scoop
deleted file mode 100644
index 4e9629b..0000000
--- a/weinre.web/modules/weinre/target/Timeline.scoop
+++ /dev/null
@@ -1,326 +0,0 @@
-
-/*
- * weinre is available under *either* the terms of the modified BSD license *or* the
- * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
- * 
- * Copyright (c) 2011 IBM Corporation
- */
-
-requireClass ../common/Ex
-requireClass ../common/Weinre
-requireClass ../common/IDGenerator
-requireClass ../common/StackTrace
-
-requireClass ../common/Native
-
-//-----------------------------------------------------------------------------
-class Timeline
-
-//-----------------------------------------------------------------------------
-static method start
-    Running = true
-
-//-----------------------------------------------------------------------------
-static method stop
-    Running = false
-
-//-----------------------------------------------------------------------------
-static method isRunning
-    return Running
-
-//-----------------------------------------------------------------------------
-static method addRecord_Mark(message)
-    if (!Timeline.isRunning()) return
-    
-    var record = {}
-
-    record.type      = TimelineRecordType.Mark
-    record.category  = { name: "scripting" }
-    record.startTime = Date.now()
-    record.data      = { message: message }
-    
-    addStackTrace(record, 3)
-    
-    Weinre.wi.TimelineNotify.addRecordToTimeline(record)
-
-//-----------------------------------------------------------------------------
-static method addRecord_EventDispatch(event, name, category)
-    if (!Timeline.isRunning()) return
-    
-    if (!category) category = "scripting"
-    var record = {}
-
-    record.type      = TimelineRecordType.EventDispatch
-    record.category  = { name: category }
-    record.startTime = Date.now()
-    record.data      = { type: event.type }
-    
-    Weinre.wi.TimelineNotify.addRecordToTimeline(record)
-    
-//-----------------------------------------------------------------------------
-static method addRecord_TimerInstall(id, timeout, singleShot)
-    if (!Timeline.isRunning()) return
-    
-    var record = {}
-
-    record.type      = TimelineRecordType.TimerInstall
-    record.category  = { name: "scripting" }
-    record.startTime = Date.now()
-    record.data      = { timerId: id, timeout: timeout, singleShot: singleShot }
-    
-    addStackTrace(record, 4)
-    
-    Weinre.wi.TimelineNotify.addRecordToTimeline(record)
-
-//-----------------------------------------------------------------------------
-static method addRecord_TimerRemove(id, timeout, singleShot)
-    if (!Timeline.isRunning()) return
-
-    var record = {}
-
-    record.type      = TimelineRecordType.TimerRemove
-    record.category  = { name: "scripting" }
-    record.startTime = Date.now()
-    record.data      = { timerId: id, timeout: timeout, singleShot: singleShot }
-
-    addStackTrace(record, 4)
-    
-    Weinre.wi.TimelineNotify.addRecordToTimeline(record)
-
-//-----------------------------------------------------------------------------
-static method addRecord_TimerFire(id, timeout, singleShot)
-    if (!Timeline.isRunning()) return
-
-    var record = {}
-
-    record.type      = TimelineRecordType.TimerFire
-    record.category  = { name: "scripting" }
-    record.startTime = Date.now()
-    record.data      = { timerId: id, timeout: timeout, singleShot: singleShot }
-    
-    Weinre.wi.TimelineNotify.addRecordToTimeline(record)
-
-//-----------------------------------------------------------------------------
-static method addRecord_XHRReadyStateChange(method, url, id, xhr)
-    if (!Timeline.isRunning()) return
-
-    var record
-    
-    if (xhr.readyState == XMLHttpRequest.OPENED) {
-        record = {
-            type:      TimelineRecordType.ResourceSendRequest,
-            category:  { name: "loading" },
-            startTime: Date.now(),
-            data: { 
-                identifier:     id,
-                url:            url,
-                requestMethod:  method
-            }
-        }
-    }
-    
-    else if (xhr.readyState == XMLHttpRequest.DONE) {
-        record = {
-            type:      TimelineRecordType.ResourceReceiveResponse,
-            category:  { name: "loading" },
-            startTime: Date.now(),
-            data: {
-                identifier:            id,
-                statusCode:            xhr.status,
-                mimeType:              xhr.getResponseHeader("Content-Type"),
-                expectedContentLength: xhr.getResponseHeader("Content-Length"),
-                url:                   url
-            }
-        }
-    }
-    
-    else 
-        return
-    
-    Weinre.wi.TimelineNotify.addRecordToTimeline(record)
-
-//-----------------------------------------------------------------------------
-static method installGlobalListeners
-    if (applicationCache) {
-        applicationCache.addEventListener("checking",    function(e) {Timeline.addRecord_EventDispatch(e, "applicationCache.checking",    "loading")}, false)
-        applicationCache.addEventListener("error",       function(e) {Timeline.addRecord_EventDispatch(e, "applicationCache.error",       "loading")}, false)
-        applicationCache.addEventListener("noupdate",    function(e) {Timeline.addRecord_EventDispatch(e, "applicationCache.noupdate",    "loading")}, false)
-        applicationCache.addEventListener("downloading", function(e) {Timeline.addRecord_EventDispatch(e, "applicationCache.downloading", "loading")}, false)
-        applicationCache.addEventListener("progress",    function(e) {Timeline.addRecord_EventDispatch(e, "applicationCache.progress",    "loading")}, false)
-        applicationCache.addEventListener("updateready", function(e) {Timeline.addRecord_EventDispatch(e, "applicationCache.updateready", "loading")}, false)
-        applicationCache.addEventListener("cached",      function(e) {Timeline.addRecord_EventDispatch(e, "applicationCache.cached",      "loading")}, false)
-        applicationCache.addEventListener("obsolete",    function(e) {Timeline.addRecord_EventDispatch(e, "applicationCache.obsolete",    "loading")}, false)
-    }
-    
-    // window.addEventListener("deviceorientation", function(e) {Timeline.addRecord_EventDispatch("window.deviceorientation")}, false)
-    window.addEventListener("error",             function(e) {Timeline.addRecord_EventDispatch(e, "window.error")},             false)
-    window.addEventListener("hashchange",        function(e) {Timeline.addRecord_EventDispatch(e, "window.hashchange")},        false)
-    window.addEventListener("message",           function(e) {Timeline.addRecord_EventDispatch(e, "window.message")},           false)
-    window.addEventListener("offline",           function(e) {Timeline.addRecord_EventDispatch(e, "window.offline")},           false)
-    window.addEventListener("online",            function(e) {Timeline.addRecord_EventDispatch(e, "window.online")},            false)
-    window.addEventListener("scroll",            function(e) {Timeline.addRecord_EventDispatch(e, "window.scroll")},            false)
-    
-//-----------------------------------------------------------------------------
-static method installFunctionWrappers
-    window.clearInterval  = wrapped_clearInterval
-    window.clearTimeout   = wrapped_clearTimeout
-    window.setTimeout     = wrapped_setTimeout
-    window.setInterval    = wrapped_setInterval
-
-    window.XMLHttpRequest.prototype.open = wrapped_XMLHttpRequest_open
-    window.XMLHttpRequest                = wrapped_XMLHttpRequest
-
-//-----------------------------------------------------------------------------
-function addStackTrace(record, skip)
-    if (!skip) skip = 1
-    
-    var trace = new StackTrace(arguments).trace
-    
-    record.stackTrace = []
-    
-    for (var i=skip; i<trace.length; i++) {
-        record.stackTrace.push({
-            functionName: trace[i],
-            scriptName:   "",
-            lineNumber:   ""
-        })
-    }
-    
-//-----------------------------------------------------------------------------
-function wrapped_setInterval(code, interval)
-    var code = instrumentedTimerCode(code, interval, false)
-    var id = Native.setInterval(code, interval)
-    
-    code.__timerId = id
-    
-    addTimer(id, interval, false)
-
-    return id
-
-//-----------------------------------------------------------------------------
-function wrapped_setTimeout(code, delay)
-    var code = instrumentedTimerCode(code, delay, true)
-    var id   = Native.setTimeout(code, delay)
-
-    code.__timerId = id
-    
-    addTimer(id, delay, true)
-
-    return id
-
-//-----------------------------------------------------------------------------
-function wrapped_clearInterval(id)
-    var result = Native.clearInterval(id)
-    
-    removeTimer(id, false)
-    return result
-
-//-----------------------------------------------------------------------------
-function wrapped_clearTimeout(id)
-    var result = Native.clearTimeout(id)
-    
-    removeTimer(id, true)
-    return result
-
-//-----------------------------------------------------------------------------
-function addTimer(id, timeout, singleShot)
-    var timerSet = singleShot ? TimerTimeouts : TimerIntervals
-    
-    timerSet[id] = {
-         id:          id,
-         timeout:     timeout,
-         singleShot: singleShot
-    }
-    
-    Timeline.addRecord_TimerInstall(id, timeout, singleShot)
-    
-//-----------------------------------------------------------------------------
-function removeTimer(id, singleShot)
-    var timerSet = singleShot ? TimerTimeouts : TimerIntervals
-    var timer = timerSet[id]
-    
-    if (!timer) return
-    
-    Timeline.addRecord_TimerRemove(id, timer.timeout, singleShot)
-    
-    delete timerSet[id]
-    
-//-----------------------------------------------------------------------------
-function instrumentedTimerCode(code, timeout, singleShot)
-    if (typeof(code) != "function") return code
-    
-    var instrumentedCode = function() {
-        var result = code()
-        var id     = arguments.callee.__timerId
-
-        Timeline.addRecord_TimerFire(id, timeout, singleShot)
-
-        return result
-    }
-    
-    return instrumentedCode 
-
-//-----------------------------------------------------------------------------
-function wrapped_XMLHttpRequest
-    var xhr = new Native.XMLHttpRequest()
-    IDGenerator.getId(xhr)
-    xhr.addEventListener("readystatechange", getXhrEventHandler(xhr), false)
-    return xhr
-
-init
-    wrapped_XMLHttpRequest.UNSENT           = 0
-    wrapped_XMLHttpRequest.OPENED           = 1
-    wrapped_XMLHttpRequest.HEADERS_RECEIVED = 2
-    wrapped_XMLHttpRequest.LOADING          = 3
-    wrapped_XMLHttpRequest.DONE             = 4    
-
-//-----------------------------------------------------------------------------
-function wrapped_XMLHttpRequest_open()
-    var xhr = this
-    xhr.__weinre_method  = arguments[0]
-    xhr.__weinre_url     = arguments[1]
-    
-    var result = Native.XMLHttpRequest_open.apply(xhr, [].slice.call(arguments))
-    return result
-
-    
-//-----------------------------------------------------------------------------
-function getXhrEventHandler(xhr)
-    return function(event) {
-        Timeline.addRecord_XHRReadyStateChange(xhr.__weinre_method, xhr.__weinre_url, IDGenerator.getId(xhr), xhr)
-    }
-    
-//-----------------------------------------------------------------------------
-init 
-    var Running = false
-    
-    var TimerTimeouts  = {}
-    var TimerIntervals = {}
-
-    var TimelineRecordType = {
-            EventDispatch:            0,
-            Layout:                   1,
-            RecalculateStyles:        2,
-            Paint:                    3,
-            ParseHTML:                4,
-            TimerInstall:             5,
-            TimerRemove:              6,
-            TimerFire:                7,
-            XHRReadyStateChange:      8,
-            XHRLoad:                  9,
-            EvaluateScript:          10,
-            Mark:                    11,
-            ResourceSendRequest:     12,
-            ResourceReceiveResponse: 13,
-            ResourceFinish:          14,
-            FunctionCall:            15,
-            ReceiveResourceData:     16,
-            GCEvent:                 17,
-            MarkDOMContent:          18,
-            MarkLoad:                19,
-            ScheduleResourceRequest: 20
-    }
-
-    Timeline.installGlobalListeners()
-    Timeline.installFunctionWrappers()
-    
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/9f1c7663/weinre.web/modules/weinre/target/WeinreExtraClientCommandsImpl.coffee
----------------------------------------------------------------------
diff --git a/weinre.web/modules/weinre/target/WeinreExtraClientCommandsImpl.coffee b/weinre.web/modules/weinre/target/WeinreExtraClientCommandsImpl.coffee
new file mode 100644
index 0000000..e638355
--- /dev/null
+++ b/weinre.web/modules/weinre/target/WeinreExtraClientCommandsImpl.coffee
@@ -0,0 +1,27 @@
+
+#---------------------------------------------------------------------------------
+# weinre is available under *either* the terms of the modified BSD license *or* the
+# MIT License (2008). See http:#opensource.org/licenses/alphabetical for full text.
+#
+# Copyright (c) 2010, 2011 IBM Corporation
+#---------------------------------------------------------------------------------
+
+Weinre         = require('../common/Weinre')
+WiDatabaseImpl = require('./WiDatabaseImpl')
+Console        = require('./Console')
+
+#-------------------------------------------------------------------------------
+module.exports = class WeinreExtraClientCommandsImpl
+
+    constructor: ->
+
+    #---------------------------------------------------------------------------
+    getDatabases: (callback) ->
+        return unless callback
+        result = WiDatabaseImpl.getDatabases()
+
+        Weinre.WeinreTargetCommands.sendClientCallback callback, [ result ]
+
+#-------------------------------------------------------------------------------
+require("../common/MethodNamer").setNamesForClass(module.exports)
+

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/9f1c7663/weinre.web/modules/weinre/target/WeinreExtraClientCommandsImpl.scoop
----------------------------------------------------------------------
diff --git a/weinre.web/modules/weinre/target/WeinreExtraClientCommandsImpl.scoop b/weinre.web/modules/weinre/target/WeinreExtraClientCommandsImpl.scoop
deleted file mode 100644
index 28d6843..0000000
--- a/weinre.web/modules/weinre/target/WeinreExtraClientCommandsImpl.scoop
+++ /dev/null
@@ -1,24 +0,0 @@
-
-/*
- * weinre is available under *either* the terms of the modified BSD license *or* the
- * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
- * 
- * Copyright (c) 2010, 2011 IBM Corporation
- */
-
-requireClass ../common/Weinre
-
-requireClass ./WiDatabaseImpl
-requireClass ./Console
-
-//-----------------------------------------------------------------------------
-class WeinreExtraClientCommandsImpl
-
-//-----------------------------------------------------------------------------
-method getDatabases(callback)
-    if (!callback) return
-    
-    var result = WiDatabaseImpl.getDatabases()
-    
-    Weinre.WeinreTargetCommands.sendClientCallback(callback, [result])
-


Mime
View raw message