From 8b2f0b3ced0e9374a1fb7bcb820fbb3aec815c38 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 31 Jan 2018 19:58:53 +0100 Subject: [PATCH 1/8] add expand function --- remix-debugger/src/ui/TreeView.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/remix-debugger/src/ui/TreeView.js b/remix-debugger/src/ui/TreeView.js index d137d8261b..8765e75d13 100644 --- a/remix-debugger/src/ui/TreeView.js +++ b/remix-debugger/src/ui/TreeView.js @@ -46,6 +46,8 @@ class TreeView { this.view = null this.nodeIsExpanded = {} this.nodes = {} + this.labels = {} + this.carets = {} } render (json) { @@ -91,13 +93,11 @@ class TreeView { var isExpanded = self.nodeIsExpanded[keyPath] var list = yo`` this.nodes[keyPath] = list - list.style.display = isExpanded !== undefined ? (isExpanded ? 'block' : 'none') : (expand ? 'block' : 'none') + this.labels[keyPath] = label + this.carets[keyPath] = caret caret.className = list.style.display === 'none' ? 'fa fa-caret-right' : 'fa fa-caret-down' label.onclick = function () { - caret.className = caret.className === 'fa fa-caret-right' ? 'fa fa-caret-down' : 'fa fa-caret-right' - list.style.display = list.style.display === 'none' ? 'block' : 'none' - self.nodeIsExpanded[keyPath] = list.style.display === 'block' - self.event.trigger('nodeClick', [keyPath, list]) + self.expand(keyPath) } li.appendChild(list) } else { @@ -106,6 +106,14 @@ class TreeView { return li } + expand (path) { + if (this.labels[path]) { + this.carets[path].className = this.carets[path].className === 'fa fa-caret-right' ? 'fa fa-caret-down' : 'fa fa-caret-right' + this.nodes[path].style.display = this.nodes[path].style.display === 'none' ? 'block' : 'none' + this.event.trigger('nodeClick', [path, this.nodes[path]]) + } + } + nodeAt (path) { return this.nodes[path] } From e4bb25a3e208e80f86db763cfb0452c0d35cfbf6 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 31 Jan 2018 19:59:13 +0100 Subject: [PATCH 2/8] add expand param --- remix-debugger/src/ui/TreeView.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/remix-debugger/src/ui/TreeView.js b/remix-debugger/src/ui/TreeView.js index 8765e75d13..9f542ecbbf 100644 --- a/remix-debugger/src/ui/TreeView.js +++ b/remix-debugger/src/ui/TreeView.js @@ -50,8 +50,8 @@ class TreeView { this.carets = {} } - render (json) { - var view = this.renderProperties(json, false) + render (json, expand) { + var view = this.renderProperties(json, expand) if (!this.view) { this.view = view } From af098965247104f656b7678968895638b33daab1 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 31 Jan 2018 19:59:19 +0100 Subject: [PATCH 3/8] remove nodeIsExpanded --- remix-debugger/src/ui/TreeView.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/remix-debugger/src/ui/TreeView.js b/remix-debugger/src/ui/TreeView.js index 9f542ecbbf..92112840c6 100644 --- a/remix-debugger/src/ui/TreeView.js +++ b/remix-debugger/src/ui/TreeView.js @@ -44,7 +44,6 @@ class TreeView { this.extractData = opts.extractData || this.extractDataDefault this.formatSelf = opts.formatSelf || this.formatSelfDefault this.view = null - this.nodeIsExpanded = {} this.nodes = {} this.labels = {} this.carets = {} @@ -90,11 +89,11 @@ class TreeView { ` li.appendChild(label) if (data.children) { - var isExpanded = self.nodeIsExpanded[keyPath] var list = yo`
    ${children}
` this.nodes[keyPath] = list this.labels[keyPath] = label this.carets[keyPath] = caret + list.style.display = 'none' caret.className = list.style.display === 'none' ? 'fa fa-caret-right' : 'fa fa-caret-down' label.onclick = function () { self.expand(keyPath) From c0cbca5123231cc422c5186be40f8cd57a5406bf Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 1 Feb 2018 17:31:11 +0100 Subject: [PATCH 4/8] add isExpanded && updateNode function --- remix-debugger/src/ui/TreeView.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/remix-debugger/src/ui/TreeView.js b/remix-debugger/src/ui/TreeView.js index 92112840c6..bcca518b2e 100644 --- a/remix-debugger/src/ui/TreeView.js +++ b/remix-debugger/src/ui/TreeView.js @@ -105,6 +105,14 @@ class TreeView { return li } + isExpanded (path) { + var current = this.nodeAt(path) + if (current) { + return current.style.display !== 'none' + } + return false + } + expand (path) { if (this.labels[path]) { this.carets[path].className = this.carets[path].className === 'fa fa-caret-right' ? 'fa fa-caret-down' : 'fa fa-caret-right' @@ -117,6 +125,17 @@ class TreeView { return this.nodes[path] } + updateNode (path, newNode) { + var current = this.nodeAt(path) + if (current) { + var parent = current.parentNode + if (parent) { + parent.replaceChild(newNode, current) + this.nodes[path] = newNode + } + } + } + formatSelfDefault (key, data) { return yo`` } From 6267341c6f5c656f5deb5f8b009a637e53a8e606 Mon Sep 17 00:00:00 2001 From: yann300 Date: Fri, 2 Feb 2018 14:56:20 +0100 Subject: [PATCH 5/8] fix styling --- remix-debugger/src/ui/TreeView.js | 1 - 1 file changed, 1 deletion(-) diff --git a/remix-debugger/src/ui/TreeView.js b/remix-debugger/src/ui/TreeView.js index bcca518b2e..a2aa788727 100644 --- a/remix-debugger/src/ui/TreeView.js +++ b/remix-debugger/src/ui/TreeView.js @@ -20,7 +20,6 @@ var css = csjs` -webkit-padding-start: 0px; } .caret_tv { - margin-top: 3px; width: 10px; } .label_tv { From a33693f438324f0de107bc9c585f0140d327ff61 Mon Sep 17 00:00:00 2001 From: yann300 Date: Fri, 2 Feb 2018 14:56:57 +0100 Subject: [PATCH 6/8] retrieve node, caret, label by querySelector && add leafClick --- remix-debugger/src/ui/TreeView.js | 56 ++++++++++++++++++------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/remix-debugger/src/ui/TreeView.js b/remix-debugger/src/ui/TreeView.js index a2aa788727..d2133c69ba 100644 --- a/remix-debugger/src/ui/TreeView.js +++ b/remix-debugger/src/ui/TreeView.js @@ -43,9 +43,6 @@ class TreeView { this.extractData = opts.extractData || this.extractDataDefault this.formatSelf = opts.formatSelf || this.formatSelfDefault this.view = null - this.nodes = {} - this.labels = {} - this.carets = {} } render (json, expand) { @@ -70,36 +67,37 @@ class TreeView { return this.formatData(key, data, children, expand, keyPath) } - renderProperties (json, expand) { + renderProperties (json, expand, key) { + key = key || '' var children = Object.keys(json).map((innerkey) => { return this.renderObject(json[innerkey], json, innerkey, expand, innerkey) }) - return yo`
    ${children}
` + return yo`
    ${children}
` } formatData (key, data, children, expand, keyPath) { var self = this var li = yo`
  • ` - var caret = yo`
    ` + var caret = yo`
    ` var label = yo` -
    +
    ${caret} ${self.formatSelf(key, data, li)}
    ` li.appendChild(label) if (data.children) { - var list = yo`
      ${children}
    ` - this.nodes[keyPath] = list - this.labels[keyPath] = label - this.carets[keyPath] = caret + var list = yo`
      ${children}
    ` list.style.display = 'none' - caret.className = list.style.display === 'none' ? 'fa fa-caret-right' : 'fa fa-caret-down' + caret.className = list.style.display === 'none' ? `fa fa-caret-right caret ${css.caret_tv}` : `fa fa-caret-down caret ${css.caret_tv}` label.onclick = function () { self.expand(keyPath) } li.appendChild(list) } else { caret.style.visibility = 'hidden' + label.onclick = function () { + self.event.trigger('leafClick', [key, data, label]) + } } return li } @@ -113,25 +111,35 @@ class TreeView { } expand (path) { - if (this.labels[path]) { - this.carets[path].className = this.carets[path].className === 'fa fa-caret-right' ? 'fa fa-caret-down' : 'fa fa-caret-right' - this.nodes[path].style.display = this.nodes[path].style.display === 'none' ? 'block' : 'none' - this.event.trigger('nodeClick', [path, this.nodes[path]]) + var caret = this.caretAt(path) + var node = this.nodeAt(path) + if (node) { + node.style.display = node.style.display === 'none' ? 'block' : 'none' + caret.className = node.style.display === 'none' ? `fa fa-caret-right caret ${css.caret_tv}` : `fa fa-caret-down caret ${css.caret_tv}` + this.event.trigger('nodeClick', [path, node]) + } + } + + caretAt (path) { + var label = this.labelAt(path) + if (label) { + return label.querySelector('.caret') } } + labelAt (path) { + return this.view.querySelector(`div[key="${path}"]`) + } + nodeAt (path) { - return this.nodes[path] + return this.view.querySelector(`ul[key="${path}"]`) } - updateNode (path, newNode) { + updateNodeFromJSON (path, jsonTree, expand) { + var newTree = this.renderProperties(jsonTree, expand, path) var current = this.nodeAt(path) - if (current) { - var parent = current.parentNode - if (parent) { - parent.replaceChild(newNode, current) - this.nodes[path] = newNode - } + if (current && current.parentElement) { + current.parentElement.replaceChild(newTree, current) } } From 28073acf6b704444daaa6fd162c426dfc1294e16 Mon Sep 17 00:00:00 2001 From: yann300 Date: Fri, 2 Feb 2018 15:30:31 +0100 Subject: [PATCH 7/8] add itemAt function --- remix-debugger/src/ui/TreeView.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/remix-debugger/src/ui/TreeView.js b/remix-debugger/src/ui/TreeView.js index d2133c69ba..c1541f4ff0 100644 --- a/remix-debugger/src/ui/TreeView.js +++ b/remix-debugger/src/ui/TreeView.js @@ -77,7 +77,7 @@ class TreeView { formatData (key, data, children, expand, keyPath) { var self = this - var li = yo`
  • ` + var li = yo`
  • ` var caret = yo`
    ` var label = yo`
    @@ -127,6 +127,10 @@ class TreeView { } } + itemAt (path) { + return this.view.querySelector(`li[key="${path}"]`) + } + labelAt (path) { return this.view.querySelector(`div[key="${path}"]`) } From 8fbc563d0d3c729f1c19c6717d9ac181028c2f39 Mon Sep 17 00:00:00 2001 From: yann300 Date: Fri, 2 Feb 2018 17:25:48 +0100 Subject: [PATCH 8/8] preinstall solc && bump version --- remix-solidity/package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/remix-solidity/package.json b/remix-solidity/package.json index 8be51744e0..f73686e00b 100644 --- a/remix-solidity/package.json +++ b/remix-solidity/package.json @@ -1,6 +1,6 @@ { "name": "remix-solidity", - "version": "0.0.7", + "version": "0.0.8", "description": "Ethereum IDE and tools for the web", "contributors": [ { @@ -32,7 +32,8 @@ "scripts": { "test": "standard && npm run downloadsolc && tape ./test/tests.js", "downloadsolc": "cd node_modules/solc && (test -e soljson.js || wget https://ethereum.github.io/solc-bin/soljson.js) && cd ..", - "prepublish": "mkdirp build; npm-run-all -ls downloadsolc" + "prepublish": "mkdirp build; npm-run-all -ls downloadsolc", + "postinstall": "npm-run-all -ls downloadsolc" }, "standard": { "ignore": [