Repository: ivan111/vtree
Branch: master
Commit: 008e1fe3d6a2
Files: 25
Total size: 120.1 KB
Directory structure:
gitextract_gick23ka/
├── .eslintrc
├── .gitignore
├── LICENSE
├── README.md
├── css/
│ ├── custom.css
│ └── vtree.css
├── dist/
│ └── vtree.js
├── index.html
├── package.json
├── src/
│ ├── decorator/
│ │ └── linkName.js
│ ├── layout/
│ │ ├── array.js
│ │ └── tree.js
│ ├── node/
│ │ ├── README.md
│ │ ├── array.js
│ │ ├── dummy.js
│ │ ├── node.js
│ │ ├── string.js
│ │ ├── table.js
│ │ └── util.js
│ ├── reader/
│ │ ├── object.js
│ │ └── test/
│ │ └── object_reader_test.js
│ ├── util.js
│ └── vtree.js
├── test.html
└── webpack.config.js
================================================
FILE CONTENTS
================================================
================================================
FILE: .eslintrc
================================================
{
"env": {
"browser": true,
"node": true,
"es6": true,
"mocha": true
},
"ecmaFeatures": {
"modules": true
},
"parserOptions": {
"sourceType": "module"
},
"extends": "eslint:recommended",
"rules": {
"no-undef": 2,
"no-console": 1
}
}
================================================
FILE: .gitignore
================================================
node_modules
npm-debug.log
lib/
================================================
FILE: LICENSE
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
================================================
FILE: README.md
================================================
JSON to Tree Diagram Converter
==============================
> For Yakusugi
This tool converts JSON strings into tree diagrams. For example, it is used to show AST(Abstract Syntax Tree) as tree diagrams for debugging. In that case, of course, you need to translate AST into JSON.
[Online JSON to Tree Diagram Converter](http://vanya.jp.net/vtree/)

================================================
FILE: css/custom.css
================================================
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #f8f9fa;
display: flex;
align-items: center;
min-height: 100vh;
}
.container {
max-width: 1030px;
width: 100%;
background-color: #ffffff;
border-radius: 8px;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.12), 0 4px 8px rgba(0, 0, 0, 0.14);
padding: 2rem;
margin: 0 auto;
}
header {
margin-bottom: 2rem;
}
button {
width: 100%;
}
textarea {
resize: none;
}
footer {
margin-top: 3rem;
}
================================================
FILE: css/vtree.css
================================================
svg.vtree {
overflow: hidden;
background: #ffffff;
-webkit-box-shadow: 4px 4px 8px rgba(0,0,0,0.5);
-moz-box-shadow : 4px 4px 8px rgba(0,0,0,0.5);
box-shadow : 4px 4px 8px rgba(0,0,0,0.5);
}
================================================
FILE: dist/vtree.js
================================================
var VTree =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = "./src/vtree.js");
/******/ })
/************************************************************************/
/******/ ({
/***/ "./src/decorator/linkName.js":
/*!***********************************!*\
!*** ./src/decorator/linkName.js ***!
\***********************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar pad = 4;\n\nvar LinkNameDecorator = function () {\n function LinkNameDecorator(linkName) {\n _classCallCheck(this, LinkNameDecorator);\n\n this.linkName = linkName;\n }\n\n _createClass(LinkNameDecorator, [{\n key: 'render',\n value: function render(g, oldG, width) {\n var t = g.append('text').text(this.linkName);\n\n var b = t.node().getBBox();\n var textW = Math.ceil(b.width);\n var textH = Math.ceil(b.height);\n\n var textTotalW = textW + pad * 2;\n\n var newW = width;\n\n if (textTotalW > width) {\n newW = textTotalW;\n }\n\n var textTotalH = textH + pad;\n\n var dw = newW - width;\n var dh = textTotalH;\n var dx = Math.round(dw / 2);\n var dy = textTotalH;\n\n t.attr('x', Math.round(newW / 2)).attr('y', textH).attr('text-anchor', 'middle');\n\n return { dx: dx, dy: dy, dw: dw, dh: dh };\n }\n }]);\n\n return LinkNameDecorator;\n}();\n\nexports.default = LinkNameDecorator;\n\n//# sourceURL=webpack://VTree/./src/decorator/linkName.js?");
/***/ }),
/***/ "./src/layout/array.js":
/*!*****************************!*\
!*** ./src/layout/array.js ***!
\*****************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\n/* global d3 */\n\nvar DURATION = 1000;\n\nvar diagonal = d3.svg.diagonal();\n\nvar ArrayLayout = function () {\n function ArrayLayout() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n\n _classCallCheck(this, ArrayLayout);\n\n this.hideLinks = options.hideLinks;\n }\n\n _createClass(ArrayLayout, [{\n key: 'layout',\n value: function layout(node) {\n calcChildrenWidth(node);\n calcTotalSize(node);\n\n _layout(node);\n }\n }, {\n key: 'renderLinks',\n value: function renderLinks(node) {\n if (!this.hideLinks) {\n _renderLinks(node);\n }\n }\n }]);\n\n return ArrayLayout;\n}();\n\nexports.default = ArrayLayout;\n\n\nfunction _layout(node) {\n if (node.children.length === 0) {\n return;\n }\n\n var x = -Math.round(node.childrenWidth / 2);\n var y = 0;\n\n node.children.forEach(function (child) {\n child.x = x + Math.round(child.totalWidth / 2) - Math.round(child.width / 2);\n child.y = y;\n\n child.g.transition().duration(DURATION).attr('transform', 'translate(' + child.x + ',' + child.y + ')');\n\n x += child.totalWidth + node.margin;\n });\n}\n\nfunction _renderLinks(node) {\n if (node.children.length === 0) {\n return;\n }\n\n var h = node.children[0].linkY;\n\n node.children.forEach(function (child) {\n h = Math.min(h, child.linkY);\n });\n\n var orig = { x: 0, y: 0 };\n\n var i, src, dst;\n\n for (i = 0; i < node.children.length; i++) {\n if (i === 0) {\n continue;\n }\n\n var prev = node.children[i - 1];\n var child = node.children[i];\n\n src = {\n x: prev.x + prev.linkX,\n y: prev.y + h\n };\n\n dst = {\n x: child.x + child.linkX,\n y: child.y + h\n };\n\n var link = node.g.insert('path', ':first-child').attr('class', 'vtree-link').attr('d', function () {\n return diagonal({ source: orig, target: orig });\n });\n\n link.transition().duration(DURATION).attr('d', function () {\n return diagonal({ source: src, target: dst });\n });\n }\n}\n\nfunction calcChildrenWidth(node) {\n if (node.children.length === 0) {\n node.childrenWidth = 0;\n\n return;\n }\n\n var w = 0;\n\n node.children.forEach(function (child) {\n w += child.totalWidth;\n });\n\n w += (node.children.length - 1) * node.margin;\n\n node.childrenWidth = w;\n}\n\nfunction calcTotalSize(node) {\n if (node.children.length === 0) {\n node.totalWidth = node.width;\n node.totalHeight = node.height;\n\n return;\n }\n\n node.totalWidth = Math.max(node.width, node.childrenWidth);\n\n var maxChildH = 0;\n\n node.children.forEach(function (child) {\n maxChildH = Math.max(maxChildH, child.totalHeight);\n });\n\n node.totalHeight = maxChildH;\n}\n\n//# sourceURL=webpack://VTree/./src/layout/array.js?");
/***/ }),
/***/ "./src/layout/tree.js":
/*!****************************!*\
!*** ./src/layout/tree.js ***!
\****************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /* global d3 */\n\nvar _array = __webpack_require__(/*! ../node/array.js */ \"./src/node/array.js\");\n\nvar _array2 = _interopRequireDefault(_array);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar MARGIN = 10;\nvar HEIGHT = 50;\nvar DURATION = 1000;\n\nvar diagonal = d3.svg.diagonal();\n\nvar TreeLayout = function () {\n function TreeLayout() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n\n _classCallCheck(this, TreeLayout);\n\n this.height = options.height || HEIGHT;\n }\n\n _createClass(TreeLayout, [{\n key: 'layout',\n value: function layout(node) {\n calcChildrenWidth(node);\n calcTotalSize(node, this.height);\n\n _layout(node, this.height);\n }\n }, {\n key: 'renderLinks',\n value: function renderLinks(node) {\n _renderLinks(node);\n }\n }]);\n\n return TreeLayout;\n}();\n\nexports.default = TreeLayout;\n\n\nfunction _layout(node, height) {\n if (node.children.length === 0) {\n return;\n }\n\n var x = Math.round(node.width / 2) - Math.round(node.childrenWidth / 2);\n var y = node.height + height;\n\n node.children.forEach(function (child) {\n child.x = x + Math.round(child.totalWidth / 2) - Math.round(child.width / 2);\n child.y = y;\n\n child.g.transition().duration(DURATION).attr('transform', 'translate(' + child.x + ',' + child.y + ')');\n\n x += child.totalWidth + MARGIN;\n });\n}\n\nfunction _renderLinks(node) {\n var src = {\n x: node.linkX,\n y: node.linkY\n };\n\n node.children.forEach(function (child) {\n var dst = {\n x: child.x + child.linkX,\n y: child.y + child.linkY\n };\n\n if (child.constructor === _array2.default) {\n if (child.children.length !== 0) {\n var gc = child.children[0];\n dst.x += gc.x + gc.linkX;\n dst.y += gc.y + gc.linkY;\n }\n }\n\n var link = node.g.insert('path', ':first-child').attr('class', 'vtree-link').attr('d', function () {\n return diagonal({ source: src, target: src });\n });\n\n link.transition().duration(DURATION).attr('d', function () {\n return diagonal({ source: src, target: dst });\n });\n });\n}\n\nfunction calcChildrenWidth(node) {\n if (node.children.length === 0) {\n node.childrenWidth = 0;\n\n return;\n }\n\n var w = 0;\n\n node.children.forEach(function (child) {\n w += child.totalWidth;\n });\n\n w += (node.children.length - 1) * MARGIN;\n\n node.childrenWidth = w;\n}\n\nfunction calcTotalSize(node, height) {\n if (node.children.length === 0) {\n node.totalWidth = node.width;\n node.totalHeight = node.height;\n\n return;\n }\n\n node.totalWidth = Math.max(node.width, node.childrenWidth);\n\n var maxChildH = 0;\n\n node.children.forEach(function (child) {\n maxChildH = Math.max(maxChildH, child.totalHeight);\n });\n\n node.totalHeight = node.height + height + maxChildH;\n}\n\n//# sourceURL=webpack://VTree/./src/layout/tree.js?");
/***/ }),
/***/ "./src/node/array.js":
/*!***************************!*\
!*** ./src/node/array.js ***!
\***************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _node = __webpack_require__(/*! ./node.js */ \"./src/node/node.js\");\n\nvar _node2 = _interopRequireDefault(_node);\n\nvar _array = __webpack_require__(/*! ../layout/array.js */ \"./src/layout/array.js\");\n\nvar _array2 = _interopRequireDefault(_array);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\nvar defaultLayout = new _array2.default();\n\nvar MARGIN = 10;\n\nvar ArrayNode = function (_Node) {\n _inherits(ArrayNode, _Node);\n\n function ArrayNode(nodes, layout) {\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n\n _classCallCheck(this, ArrayNode);\n\n if (!layout) {\n layout = defaultLayout;\n }\n\n var _this = _possibleConstructorReturn(this, (ArrayNode.__proto__ || Object.getPrototypeOf(ArrayNode)).call(this, null, nodes, layout));\n\n _this.width = 0;\n _this.height = 0;\n\n _this.linkX = 0;\n _this.linkY = 0;\n\n _this.margin = options.margin || MARGIN;\n return _this;\n }\n\n _createClass(ArrayNode, [{\n key: '_render',\n value: function _render() {}\n }]);\n\n return ArrayNode;\n}(_node2.default);\n\nexports.default = ArrayNode;\n\n//# sourceURL=webpack://VTree/./src/node/array.js?");
/***/ }),
/***/ "./src/node/dummy.js":
/*!***************************!*\
!*** ./src/node/dummy.js ***!
\***************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _node = __webpack_require__(/*! ./node.js */ \"./src/node/node.js\");\n\nvar _node2 = _interopRequireDefault(_node);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\nvar DummyNode = function (_Node) {\n _inherits(DummyNode, _Node);\n\n function DummyNode(child) {\n _classCallCheck(this, DummyNode);\n\n var _this = _possibleConstructorReturn(this, (DummyNode.__proto__ || Object.getPrototypeOf(DummyNode)).call(this, null, [child]));\n\n _this.r = 4;\n return _this;\n }\n\n _createClass(DummyNode, [{\n key: '_render',\n value: function _render(g) {\n g.append('circle').attr('cx', this.r).attr('cy', this.r).attr('r', this.r);\n\n this.width = this.r * 2;\n this.height = this.r * 2;\n\n this.linkX = this.r;\n this.linkY = this.r;\n }\n }]);\n\n return DummyNode;\n}(_node2.default);\n\nexports.default = DummyNode;\n\n//# sourceURL=webpack://VTree/./src/node/dummy.js?");
/***/ }),
/***/ "./src/node/node.js":
/*!**************************!*\
!*** ./src/node/node.js ***!
\**************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\n/**\n * Node\n *\n * A tree consists of nodes and links.\n * A node consists of the following fields:\n *\n * - id : auto increment ID.\n * - data : data which may be displayed.\n * The data format is determined by the renderer.\n * - children : children of the node\n */\n\nvar curMaxId = 0;\n\nvar Node = function () {\n function Node(data, children, layout) {\n _classCallCheck(this, Node);\n\n this.id = ++curMaxId;\n this.data = data;\n this.children = children;\n\n if (layout) {\n this.layout = layout;\n }\n\n this.width = 0;\n this.height = 0;\n\n this.decorators = [];\n }\n\n _createClass(Node, [{\n key: 'render',\n value: function render(g) {\n var _this = this;\n\n if (this.decorators.length === 0) {\n this._render(g);\n return;\n }\n\n var prevG = g.append('g');\n this._render(prevG);\n\n this.decorators.forEach(function (decorator) {\n var newG = g.append('g');\n\n var dbbox = decorator.render(newG, prevG, _this.width, _this.height);\n\n if (dbbox.dw || dbbox.dh) {\n _this.width += dbbox.dw;\n _this.height += dbbox.dh;\n }\n\n if (dbbox.dx || dbbox.dy) {\n prevG.attr('transform', 'translate(' + dbbox.dx + ',' + dbbox.dy + ')');\n\n _this.linkX += dbbox.dx;\n _this.linkY += dbbox.dy;\n }\n\n prevG = newG;\n });\n }\n }, {\n key: '_render',\n value: function _render() {\n throw new Error('[no overwride errror] _render is not implemented.');\n }\n }]);\n\n return Node;\n}();\n\nexports.default = Node;\n\n//# sourceURL=webpack://VTree/./src/node/node.js?");
/***/ }),
/***/ "./src/node/string.js":
/*!****************************!*\
!*** ./src/node/string.js ***!
\****************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _node = __webpack_require__(/*! ./node.js */ \"./src/node/node.js\");\n\nvar _node2 = _interopRequireDefault(_node);\n\nvar _util = __webpack_require__(/*! ./util.js */ \"./src/node/util.js\");\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\nvar StringNode = function (_Node) {\n _inherits(StringNode, _Node);\n\n function StringNode(data) {\n _classCallCheck(this, StringNode);\n\n var _this = _possibleConstructorReturn(this, (StringNode.__proto__ || Object.getPrototypeOf(StringNode)).call(this, data, []));\n\n _this.textPad = 4;\n return _this;\n }\n\n _createClass(StringNode, [{\n key: '_render',\n value: function _render(g) {\n var bbox = (0, _util.appendRectText)(g, 0, 0, this.data, this.textPad);\n\n this.width = bbox.width;\n this.height = bbox.height;\n\n this.linkX = Math.round(this.width / 2);\n this.linkY = Math.round(this.height / 2);\n }\n }]);\n\n return StringNode;\n}(_node2.default);\n\nexports.default = StringNode;\n\n//# sourceURL=webpack://VTree/./src/node/string.js?");
/***/ }),
/***/ "./src/node/table.js":
/*!***************************!*\
!*** ./src/node/table.js ***!
\***************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _node = __webpack_require__(/*! ./node.js */ \"./src/node/node.js\");\n\nvar _node2 = _interopRequireDefault(_node);\n\nvar _util = __webpack_require__(/*! ./util.js */ \"./src/node/util.js\");\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\nvar TableNode = function (_Node) {\n _inherits(TableNode, _Node);\n\n function TableNode(data, children) {\n _classCallCheck(this, TableNode);\n\n var _this = _possibleConstructorReturn(this, (TableNode.__proto__ || Object.getPrototypeOf(TableNode)).call(this, data, children));\n\n _this.textPad = 4;\n return _this;\n }\n\n _createClass(TableNode, [{\n key: '_render',\n value: function _render(g) {\n if (this.data.length === 0 || this.data[0].length === 0) {\n return;\n }\n\n var tbl = this.renderCells(g);\n var size = this.layoutCells(tbl);\n\n this.width = size.width;\n this.height = size.height;\n\n this.linkX = Math.round(this.width / 2);\n this.linkY = Math.round(this.height / 2);\n }\n }, {\n key: 'renderCells',\n value: function renderCells(g) {\n var _this2 = this;\n\n var tbl = [];\n\n this.data.forEach(function (row) {\n var tblRow = [];\n\n row.forEach(function (col) {\n var colG = g.append('g');\n var bbox = (0, _util.appendRectText)(colG, 0, 0, col, _this2.textPad);\n\n tblRow.push({\n g: colG,\n bbox: bbox\n });\n });\n\n tbl.push(tblRow);\n });\n\n return tbl;\n }\n }, {\n key: 'layoutCells',\n value: function layoutCells(tbl) {\n var maxW = this.calcMaxWidths(tbl);\n var maxH = this.calcMaxHeights(tbl);\n\n var x = 0;\n var y = 0;\n\n tbl.forEach(function (row, rowI) {\n x = 0;\n\n row.forEach(function (col, colI) {\n col.g.attr('transform', 'translate(' + x + ',' + y + ')');\n col.g.select('rect').attr('width', maxW[colI]).attr('height', maxH[rowI]);\n\n x += maxW[colI];\n });\n\n y += maxH[rowI];\n });\n\n return { width: x, height: y };\n }\n }, {\n key: 'calcMaxWidths',\n value: function calcMaxWidths(tbl) {\n var maxW = [];\n var colI, rowI;\n\n for (colI = 0; colI < tbl[0].length; colI++) {\n var w = 0;\n\n for (rowI = 0; rowI < tbl.length; rowI++) {\n w = Math.max(w, tbl[rowI][colI].bbox.width);\n }\n\n maxW.push(w);\n }\n\n return maxW;\n }\n }, {\n key: 'calcMaxHeights',\n value: function calcMaxHeights(tbl) {\n var maxH = [];\n\n tbl.forEach(function (row) {\n var h = 0;\n\n row.forEach(function (col) {\n h = Math.max(h, col.bbox.height);\n });\n\n maxH.push(h);\n });\n\n return maxH;\n }\n }]);\n\n return TableNode;\n}(_node2.default);\n\nexports.default = TableNode;\n\n//# sourceURL=webpack://VTree/./src/node/table.js?");
/***/ }),
/***/ "./src/node/util.js":
/*!**************************!*\
!*** ./src/node/util.js ***!
\**************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\n\nexports.appendRectText = appendRectText;\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar MAX_LEN = 32;\n\nvar BBox = exports.BBox = function BBox() {\n var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;\n var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;\n var width = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;\n var height = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;\n\n _classCallCheck(this, BBox);\n\n this.x = x;\n this.y = y;\n this.width = width;\n this.height = height;\n};\n\nfunction appendRectText(g, x, y, text, pad) {\n if (typeof text === 'string' && text.length > MAX_LEN) {\n text = text.substr(0, MAX_LEN) + '...';\n }\n\n var rect = g.append('rect').attr('class', getClassName(text));\n\n var t = g.append('text').text(text);\n\n var b = t.node().getBBox();\n var w = Math.ceil(b.width);\n var h = Math.ceil(b.height);\n\n t.attr('x', x + pad).attr('y', y + pad + h);\n\n var bbox = new BBox(x, y, w + pad * 2, h + pad * 2);\n\n rect.attr('x', bbox.x).attr('y', bbox.y).attr('width', bbox.width).attr('height', bbox.height);\n\n return bbox;\n}\n\nfunction getClassName(d) {\n var name = '';\n var type = typeof d === 'undefined' ? 'undefined' : _typeof(d);\n\n if (d === null) {\n return 'null-text';\n } else if (type === 'string') {\n name = 'string-text';\n } else if (type === 'number') {\n name = 'number-text';\n } else if (type === 'boolean') {\n name = 'boolean-text';\n } else {\n name = 'unknown-text';\n }\n\n return name;\n}\n\n//# sourceURL=webpack://VTree/./src/node/util.js?");
/***/ }),
/***/ "./src/reader/object.js":
/*!******************************!*\
!*** ./src/reader/object.js ***!
\******************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _string = __webpack_require__(/*! ../node/string.js */ \"./src/node/string.js\");\n\nvar _string2 = _interopRequireDefault(_string);\n\nvar _array = __webpack_require__(/*! ../node/array.js */ \"./src/node/array.js\");\n\nvar _array2 = _interopRequireDefault(_array);\n\nvar _table = __webpack_require__(/*! ../node/table.js */ \"./src/node/table.js\");\n\nvar _table2 = _interopRequireDefault(_table);\n\nvar _dummy = __webpack_require__(/*! ../node/dummy.js */ \"./src/node/dummy.js\");\n\nvar _dummy2 = _interopRequireDefault(_dummy);\n\nvar _linkName = __webpack_require__(/*! ../decorator/linkName.js */ \"./src/decorator/linkName.js\");\n\nvar _linkName2 = _interopRequireDefault(_linkName);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar ObjectReader = function () {\n function ObjectReader() {\n _classCallCheck(this, ObjectReader);\n }\n\n _createClass(ObjectReader, [{\n key: 'read',\n value: function read(obj) {\n return obj2node(obj, '');\n }\n }]);\n\n return ObjectReader;\n}();\n\nexports.default = ObjectReader;\n\n\nfunction obj2node(obj, linkName) {\n var node;\n\n if (isPrimitive(obj)) {\n node = new _string2.default(obj);\n } else if (Array.isArray(obj)) {\n var nodes = [];\n\n obj.forEach(function (item, i) {\n if (Array.isArray(item)) {\n node = new _dummy2.default(obj2node(item, ''));\n node.decorators.push(new _linkName2.default(linkName + '[' + i + ']'));\n nodes.push(node);\n } else {\n node = obj2node(item, linkName + '[' + i + ']');\n nodes.push(node);\n }\n });\n\n // empty array\n if (nodes.length === 0) {\n node = obj2node(null, linkName + '[]');\n nodes.push(node);\n }\n\n node = new _array2.default(nodes);\n } else {\n var name;\n var tbl = [];\n var children = [];\n\n for (name in obj) {\n if (!Object.prototype.hasOwnProperty.call(obj, name)) {\n continue;\n }\n\n var data = obj[name];\n\n if (isPrimitive(data)) {\n tbl.push([name, data]);\n } else {\n children.push(obj2node(data, name));\n }\n }\n\n if (tbl.length === 0) {\n node = new _table2.default([[' ', ' ']], children);\n } else {\n node = new _table2.default(tbl, children);\n }\n }\n\n if (linkName !== '' && node.constructor !== _array2.default) {\n node.decorators.push(new _linkName2.default(linkName));\n }\n\n return node;\n}\n\nfunction isPrimitive(d) {\n var type = typeof d === 'undefined' ? 'undefined' : _typeof(d);\n\n if (d === null || type === 'string' || type === 'number' || type === 'boolean') {\n return true;\n }\n\n return false;\n}\n\n//# sourceURL=webpack://VTree/./src/reader/object.js?");
/***/ }),
/***/ "./src/util.js":
/*!*********************!*\
!*** ./src/util.js ***!
\*********************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.visitBefore = visitBefore;\nexports.visitAfter = visitAfter;\nfunction visitBefore(node, callback) {\n var nodes = [node];\n\n while (nodes.length !== 0) {\n node = nodes.pop();\n\n callback(node);\n\n var children = node.children;\n\n if (children) {\n var n = children.length;\n\n while (--n >= 0) {\n nodes.push(children[n]);\n }\n }\n }\n}\n\nfunction visitAfter(node, callback) {\n var nodes = [node];\n var nodes2 = [];\n\n while (nodes.length !== 0) {\n node = nodes.pop();\n\n nodes2.push(node);\n\n var children = node.children;\n\n if (children) {\n var i = -1;\n var n = children.length;\n\n while (++i < n) {\n nodes.push(children[i]);\n }\n }\n }\n\n while (nodes2.length !== 0) {\n node = nodes2.pop();\n\n callback(node);\n }\n}\n\n//# sourceURL=webpack://VTree/./src/util.js?");
/***/ }),
/***/ "./src/vtree.js":
/*!**********************!*\
!*** ./src/vtree.js ***!
\**********************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
eval("\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /* global d3 */\n\nvar _node = __webpack_require__(/*! ./node/node.js */ \"./src/node/node.js\");\n\nvar _node2 = _interopRequireDefault(_node);\n\nvar _string = __webpack_require__(/*! ./node/string.js */ \"./src/node/string.js\");\n\nvar _string2 = _interopRequireDefault(_string);\n\nvar _table = __webpack_require__(/*! ./node/table.js */ \"./src/node/table.js\");\n\nvar _table2 = _interopRequireDefault(_table);\n\nvar _array = __webpack_require__(/*! ./node/array.js */ \"./src/node/array.js\");\n\nvar _array2 = _interopRequireDefault(_array);\n\nvar _tree = __webpack_require__(/*! ./layout/tree.js */ \"./src/layout/tree.js\");\n\nvar _tree2 = _interopRequireDefault(_tree);\n\nvar _array3 = __webpack_require__(/*! ./layout/array.js */ \"./src/layout/array.js\");\n\nvar _array4 = _interopRequireDefault(_array3);\n\nvar _object = __webpack_require__(/*! ./reader/object.js */ \"./src/reader/object.js\");\n\nvar _object2 = _interopRequireDefault(_object);\n\nvar _util = __webpack_require__(/*! ./util.js */ \"./src/util.js\");\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar WIDTH = 960;\nvar HEIGHT = 800;\nvar MARGIN = 20;\n\nvar DEFAULT_TREE_LAYOUT_HEIGHT = 50;\nvar DEBUG_TREE_LAYOUT_HEIGHT = 100;\n\nvar style = '\\n.vtree-node text { font: 14px sans-serif; }\\n.vtree-link { fill: none; stroke: #888; stroke-width: 2px; }\\n.vtree-table { stroke-width: 2px; stroke: steelblue; }\\npath.vtree-table { fill: white; }\\ng.vtree-node rect { fill: white; stroke: black; stroke-width: 1px; }\\ng.vtree-node rect.number-text { fill: #d8f0ed; }\\ng.vtree-node rect.string-text { fill: #e7f0db; }\\ng.vtree-node rect.boolean-text { fill: #e1d8f0; }\\ng.vtree-node rect.null-text { fill: #888; }\\n';\n\nvar VTree = function () {\n function VTree(container) {\n var _this = this;\n\n _classCallCheck(this, VTree);\n\n this.root = new _array2.default([], new _array4.default({ hideLinks: true }));\n this.defaultLayout = new _tree2.default({ height: DEFAULT_TREE_LAYOUT_HEIGHT });\n this.container = container;\n this._width = WIDTH;\n this._height = HEIGHT;\n this._debug = false;\n\n this.d3 = {};\n\n this.d3.container = d3.select(this.container);\n\n this.d3.zoomListener = d3.behavior.zoom().scaleExtent([0.1, 10]).on('zoom', function () {\n var e = d3.event;\n\n if (_this.d3.g) {\n _this.d3.g.attr('transform', 'translate(' + e.translate + ')scale(' + e.scale + ')');\n }\n });\n\n this.d3.svg = this.d3.container.append('svg').attr('class', 'vtree').attr('width', this._width).attr('height', this._height).call(this.d3.zoomListener);\n }\n\n _createClass(VTree, [{\n key: 'width',\n value: function width(_width) {\n if (arguments.length === 0) {\n return this._width;\n }\n\n this._width = _width;\n\n this.d3.container.select('svg').attr('width', _width);\n\n return this;\n }\n }, {\n key: 'height',\n value: function height(_height) {\n if (arguments.length === 0) {\n return this._height;\n }\n\n this._height = _height;\n\n this.d3.container.select('svg').attr('height', _height);\n\n return this;\n }\n }, {\n key: 'debug',\n value: function debug(_debug) {\n if (arguments.length === 0) {\n return this._debug;\n }\n\n if (_debug) {\n this.defaultLayout.height = DEBUG_TREE_LAYOUT_HEIGHT;\n } else {\n this.defaultLayout.height = DEFAULT_TREE_LAYOUT_HEIGHT;\n }\n\n this._debug = _debug;\n\n return this;\n }\n }, {\n key: 'data',\n value: function data(_data) {\n if (Array.isArray(_data)) {\n this.root.children = _data;\n } else {\n this.root.children = [_data];\n }\n\n return this;\n }\n }, {\n key: 'createSvgString',\n value: function createSvgString() {\n var svg = this.d3.svg.node();\n var serializer = new XMLSerializer();\n var source = serializer.serializeToString(svg);\n\n if (!source.match(/^<svg[^>]+xmlns=\"http:\\/\\/www\\.w3\\.org\\/2000\\/svg\"/)) {\n source = source.replace(/^<svg/, '<svg xmlns=\"http://www.w3.org/2000/svg\"');\n }\n\n if (!source.match(/^<svg[^>]+\"http:\\/\\/www\\.w3\\.org\\/1999\\/xlink\"/)) {\n source = source.replace(/^<svg/, '<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\"');\n }\n\n source = '<?xml version=\"1.0\" standalone=\"no\"?>\\r\\n' + source;\n\n return source;\n }\n }, {\n key: 'createTreeGroups',\n value: function createTreeGroups(parentG, depth) {\n var hasChildren = false;\n\n var g = parentG.selectAll('g.vtree-node').data(function (d) {\n if (d.children.length !== 0) {\n hasChildren = true;\n }\n\n return d.children;\n }).enter().append('g').attr('class', 'vtree-node').each(function (d) {\n d.g = d3.select(this);\n });\n\n if (hasChildren) {\n this.createTreeGroups(g, depth + 1);\n }\n }\n }, {\n key: 'update',\n value: function update() {\n var _this2 = this;\n\n var root = {\n id: 1,\n children: [this.root]\n };\n\n this.d3.svg.selectAll('*').remove();\n\n this.d3.svg.append('style').text(style);\n\n this._debugDrawGrid();\n\n this.d3.g = this.d3.svg.selectAll('g.vtree-root').data([root]).enter().append('g').attr('class', 'vtree-root');\n\n this.createTreeGroups(this.d3.g, 0);\n\n (0, _util.visitAfter)(this.root, function (node) {\n node.render(node.g);\n\n var layout = node.layout || _this2.defaultLayout;\n\n layout.layout(node);\n\n if (layout.renderLinks) {\n layout.renderLinks(node);\n }\n });\n\n if (this._debug) {\n (0, _util.visitAfter)(this.root, function (node) {\n _this2._debugDrawNodeInfo(node);\n });\n }\n\n this.setRootPos();\n\n return this;\n }\n }, {\n key: 'setRootPos',\n value: function setRootPos() {\n this.root.x = Math.round((this._width - this.root.width) / 2);\n this.root.y = Math.round((this._height - this.root.totalHeight) / 2);\n\n if (this.root.y < MARGIN) {\n this.root.y = MARGIN;\n }\n\n this.root.g.attr('transform', 'translate(' + this.root.x + ',' + this.root.y + ')');\n }\n }, {\n key: '_debugGetG',\n value: function _debugGetG() {\n if (!this._debug) {\n return;\n }\n\n var g = this.d3.svg.select('g.debug-info');\n\n if (!g.empty()) {\n return g;\n }\n\n return this.d3.svg.append('g').attr('class', 'debug-info');\n }\n }, {\n key: '_debugDrawGrid',\n value: function _debugDrawGrid() {\n if (!this._debug) {\n return;\n }\n\n var g = this._debugGetG();\n\n g.append('line').style('stroke', 'red').attr('x1', this._width / 2).attr('y1', 0).attr('x2', this._width / 2).attr('y2', this._height);\n\n g.append('line').style('stroke', 'red').attr('x1', 0).attr('y1', this._height / 2).attr('x2', this._width).attr('y2', this._height / 2);\n }\n }, {\n key: '_debugDrawNodeInfo',\n value: function _debugDrawNodeInfo(node) {\n if (node.constructor === _array2.default) {\n return;\n }\n\n // node rect\n node.g.append('rect').style('fill', 'none').style('stroke', 'tomato').attr('x', -1).attr('y', -1).attr('width', node.width + 2).attr('height', node.height + 2);\n\n // node total rect\n node.g.append('rect').style('fill', 'none').style('stroke', 'mediumpurple').attr('x', (node.width - node.totalWidth) / 2).attr('y', 0).attr('width', node.totalWidth).attr('height', node.totalHeight);\n\n // x, y\n var xy = node.g.append('text').text('x=' + node.x + ' y=' + node.y);\n\n var bbox = xy.node().getBBox();\n var x = node.width / 2;\n var y = node.height + bbox.height + 2;\n\n xy.attr('x', x).attr('y', y).attr('text-anchor', 'middle');\n\n y += bbox.height + 2;\n\n // width, height\n node.g.append('text').text('w=' + node.width + ' h=' + node.height).attr('x', x).attr('y', y).attr('text-anchor', 'middle');\n\n y += bbox.height + 2;\n\n // totalWidth, totalHeight\n node.g.append('text').text('tw=' + node.totalWidth + ' th=' + node.totalHeight).attr('x', x).attr('y', y).attr('text-anchor', 'middle');\n\n y += bbox.height + 2;\n\n // childrenWidth\n node.g.append('text').text('cw=' + node.childrenWidth).attr('x', x).attr('y', y).attr('text-anchor', 'middle');\n }\n }]);\n\n return VTree;\n}();\n\nVTree.node = {};\nVTree.node.Node = _node2.default;\nVTree.node.String = _string2.default;\nVTree.node.Table = _table2.default;\nVTree.node.Array = _array2.default;\n\nVTree.layout = {};\nVTree.layout.Tree = _tree2.default;\nVTree.layout.Array = _array4.default;\n\nVTree.reader = {};\nVTree.reader.Object = _object2.default;\n\nmodule.exports = VTree;\n\n//# sourceURL=webpack://VTree/./src/vtree.js?");
/***/ })
/******/ });
================================================
FILE: index.html
================================================
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Online JSON to Tree Diagram Converter</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<link rel="stylesheet" href="css/vtree.css" type="text/css" />
<link rel="stylesheet" href="css/custom.css" type="text/css" />
<script src="https://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="dist/vtree.js"></script>
<script type="text/javascript">
var vt;
window.onload = function () {
var container = document.getElementById("container");
var msg = document.getElementById("msg");
vt = new VTree(container);
var reader = new VTree.reader.Object();
function updateTree() {
var s = document.getElementById("from-text").value;
msg.innerHTML = '';
try {
var jsonData = JSON.parse(s);
} catch (e) {
msg.innerHTML = 'JSON parse error: ' + e.message;
}
var data = reader.read(jsonData);
vt.data(data)
.update();
}
function createSvgString() {
document.getElementById("svg-text").value = vt.createSvgString();
}
document.getElementById("go-button").onclick = updateTree;
document.getElementById("svg-button").onclick = createSvgString;
updateTree();
};
</script>
</head>
<body>
<!-- https://tholman.com/github-corners/ -->
<a href="https://github.com/ivan111/vtree" target="_blank" class="github-corner" aria-label="View project on GitHub" title="View project on GitHub">
<svg width="80" height="80" viewBox="0 0 250 250" style="fill:#151513; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true">
<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
<path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>
<path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path>
</svg>
</a>
<style>
.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}
</style>
<div class="container my-4">
<header class="d-flex align-items-center">
<h1 class="mb-3">Online JSON to Tree Diagram Converter</h1>
</header>
<div class="mb-3">
<label for="from-text" class="form-label">JSON</label>
<textarea id="from-text" class="form-control" rows="6">[{ "array": [ 1, 2, [3, 4], 5 ], "boolean": true, "null": null, "number": 123, "object": { "a": "b", "c": "d", "e": "f" }, "string": "Hello World" }, { "|": "|", " ": { "ʕ": "" }, " ": ["◕", [ { "hello! ": "<ニフ" } ], "◕"], "_": { "": "ʔ" } }]</textarea>
</div>
<div class="mb-3">
<button id="go-button" type="button" class="btn btn-primary">Visualize</button>
</div>
<div id="msg" class="text-danger mb-3"></div>
<div id="container" class="mb-3"></div>
<div class="mb-3">
<button id="svg-button" type="button" class="btn btn-primary">Get SVG String</button>
</div>
<div class="mb-3">
<p>If you want to export the diagram as a svg file, copy the following text into a text editor and save the file with a .svg extension.</p>
<textarea id="svg-text" class="form-control" rows="6"></textarea>
</div>
<footer class="text-end">
<small>Created Date: 2014-07-27, Modified Date: 2018-11-01</small>
</footer>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.min.js" integrity="sha384-QJHtvGhmr9XOIpI6YVutG+2QOK9T+ZnN4kzFN1RtK3zEFEIsxhlmWl5/YESvpZ13" crossorigin="anonymous"></script>
</body>
</html>
================================================
FILE: package.json
================================================
{
"name": "vtree",
"version": "0.3.0",
"description": "display json data in a tree diagram.",
"main": "build/vtree.js",
"scripts": {
"build": "webpack"
},
"repository": {
"type": "git",
"url": "git+https://github.com/ivan111/vtree.git"
},
"keywords": [
"json",
"tree"
],
"author": "ivan111",
"license": "Apache License Version 2",
"bugs": {
"url": "https://github.com/ivan111/vtree/issues"
},
"homepage": "https://github.com/ivan111/vtree#readme",
"devDependencies": {
"babel-core": "^6.23.1",
"babel-loader": "^7",
"babel-preset-es2015": "^6.22.0",
"eslint": "^5.8.0",
"eslint-loader": "^2.1.1",
"webpack": "^4.23.1",
"webpack-cli": "^3.1.2"
}
}
================================================
FILE: src/decorator/linkName.js
================================================
const pad = 4;
export default class LinkNameDecorator {
constructor(linkName) {
this.linkName = linkName;
}
render(g, oldG, width) {
const t = g.append('text')
.text(this.linkName);
const b = t.node().getBBox();
const textW = Math.ceil(b.width);
const textH = Math.ceil(b.height);
const textTotalW = textW + pad * 2;
var newW = width;
if (textTotalW > width) {
newW = textTotalW;
}
const textTotalH = textH + pad;
const dw = newW - width;
const dh = textTotalH;
const dx = Math.round(dw / 2);
const dy = textTotalH;
t
.attr('x', Math.round(newW / 2))
.attr('y', textH)
.attr('text-anchor', 'middle');
return { dx, dy, dw, dh };
}
}
================================================
FILE: src/layout/array.js
================================================
/* global d3 */
const DURATION = 1000;
const diagonal = d3.svg.diagonal();
export default class ArrayLayout {
constructor(options={}) {
this.hideLinks = options.hideLinks;
}
layout(node) {
calcChildrenWidth(node);
calcTotalSize(node);
layout(node);
}
renderLinks(node) {
if (!this.hideLinks) {
renderLinks(node);
}
}
}
function layout(node) {
if (node.children.length === 0) {
return;
}
var x = -Math.round(node.childrenWidth / 2);
const y = 0;
node.children.forEach((child) => {
child.x = x + Math.round(child.totalWidth / 2) - Math.round(child.width / 2);
child.y = y;
child.g
.transition()
.duration(DURATION)
.attr('transform', `translate(${child.x},${child.y})`);
x += child.totalWidth + node.margin;
});
}
function renderLinks(node) {
if (node.children.length === 0) {
return;
}
var h = node.children[0].linkY;
node.children.forEach((child) => {
h = Math.min(h, child.linkY);
});
const orig = { x: 0, y: 0 };
var i, src, dst;
for (i = 0; i < node.children.length; i++) {
if (i === 0) {
continue;
}
const prev = node.children[i - 1];
const child = node.children[i];
src = {
x: prev.x + prev.linkX,
y: prev.y + h
};
dst = {
x: child.x + child.linkX,
y: child.y + h
};
const link = node.g.insert('path', ':first-child')
.attr('class', 'vtree-link')
.attr('d', function () {
return diagonal({ source: orig, target: orig });
});
link
.transition()
.duration(DURATION)
.attr('d', function () {
return diagonal({ source: src, target: dst });
});
}
}
function calcChildrenWidth(node) {
if (node.children.length === 0) {
node.childrenWidth = 0;
return;
}
var w = 0;
node.children.forEach((child) => {
w += child.totalWidth;
});
w += (node.children.length - 1) * node.margin;
node.childrenWidth = w;
}
function calcTotalSize(node) {
if (node.children.length === 0) {
node.totalWidth = node.width;
node.totalHeight = node.height;
return;
}
node.totalWidth = Math.max(node.width, node.childrenWidth);
var maxChildH = 0;
node.children.forEach((child) => {
maxChildH = Math.max(maxChildH, child.totalHeight);
});
node.totalHeight = maxChildH;
}
================================================
FILE: src/layout/tree.js
================================================
/* global d3 */
import ArrayNode from '../node/array.js';
const MARGIN = 10;
const HEIGHT = 50;
const DURATION = 1000;
const diagonal = d3.svg.diagonal();
export default class TreeLayout {
constructor(options={}) {
this.height = options.height || HEIGHT;
}
layout(node) {
calcChildrenWidth(node);
calcTotalSize(node, this.height);
layout(node, this.height);
}
renderLinks(node) {
renderLinks(node);
}
}
function layout(node, height) {
if (node.children.length === 0) {
return;
}
var x = Math.round(node.width / 2) - Math.round(node.childrenWidth / 2);
const y = node.height + height;
node.children.forEach((child) => {
child.x = x + Math.round(child.totalWidth / 2) - Math.round(child.width / 2);
child.y = y;
child.g
.transition()
.duration(DURATION)
.attr('transform', `translate(${child.x},${child.y})`);
x += child.totalWidth + MARGIN;
});
}
function renderLinks(node) {
const src = {
x: node.linkX,
y: node.linkY
};
node.children.forEach((child) => {
const dst = {
x: child.x + child.linkX,
y: child.y + child.linkY
};
if (child.constructor === ArrayNode) {
if (child.children.length !== 0) {
const gc = child.children[0]
dst.x += gc.x + gc.linkX;
dst.y += gc.y + gc.linkY;
}
}
const link = node.g.insert('path', ':first-child')
.attr('class', 'vtree-link')
.attr('d', function () {
return diagonal({ source: src, target: src });
});
link
.transition()
.duration(DURATION)
.attr('d', function () {
return diagonal({ source: src, target: dst });
});
});
}
function calcChildrenWidth(node) {
if (node.children.length === 0) {
node.childrenWidth = 0;
return;
}
var w = 0;
node.children.forEach((child) => {
w += child.totalWidth;
});
w += (node.children.length - 1) * MARGIN;
node.childrenWidth = w;
}
function calcTotalSize(node, height) {
if (node.children.length === 0) {
node.totalWidth = node.width;
node.totalHeight = node.height;
return;
}
node.totalWidth = Math.max(node.width, node.childrenWidth);
var maxChildH = 0;
node.children.forEach((child) => {
maxChildH = Math.max(maxChildH, child.totalHeight);
});
node.totalHeight = node.height + height + maxChildH;
}
================================================
FILE: src/node/README.md
================================================
# How to make a custom node
1. extend the Node class
```js
export default class MyNode extends Node {
...
}
```
2. create the constructor functio and call super in it.
```js
constructor(data, children) {
super(data, children);
...
}
```
3. write a custom \_render function.
And set this.width, this.height, this.linkX and this.linkY in it.
(linkX, linkY) is a link coord.
```js
_render(g) {
...
this.width = ...;
this.height = ...;
this.linkX = ...;
this.linkY = ...;
}
```
================================================
FILE: src/node/array.js
================================================
import Node from './node.js';
import ArrayLayout from '../layout/array.js';
const defaultLayout = new ArrayLayout();
const MARGIN = 10;
export default class ArrayNode extends Node {
constructor(nodes, layout, options={}) {
if (!layout) {
layout = defaultLayout;
}
super(null, nodes, layout);
this.width = 0;
this.height = 0;
this.linkX = 0;
this.linkY = 0;
this.margin = options.margin || MARGIN;
}
_render() {
}
}
================================================
FILE: src/node/dummy.js
================================================
import Node from './node.js';
export default class DummyNode extends Node {
constructor(child) {
super(null, [child]);
this.r = 4;
}
_render(g) {
g.append('circle')
.attr('cx', this.r)
.attr('cy', this.r)
.attr('r', this.r);
this.width = this.r * 2;
this.height = this.r * 2;
this.linkX = this.r;
this.linkY = this.r;
}
}
================================================
FILE: src/node/node.js
================================================
/**
* Node
*
* A tree consists of nodes and links.
* A node consists of the following fields:
*
* - id : auto increment ID.
* - data : data which may be displayed.
* The data format is determined by the renderer.
* - children : children of the node
*/
var curMaxId = 0;
export default class Node {
constructor(data, children, layout) {
this.id = ++curMaxId;
this.data = data;
this.children = children;
if (layout) {
this.layout = layout;
}
this.width = 0;
this.height = 0;
this.decorators = [];
}
render(g) {
if (this.decorators.length === 0) {
this._render(g);
return;
}
var prevG = g.append('g');
this._render(prevG);
this.decorators.forEach((decorator) => {
const newG = g.append('g');
const dbbox = decorator.render(newG, prevG, this.width, this.height);
if (dbbox.dw || dbbox.dh) {
this.width += dbbox.dw;
this.height += dbbox.dh;
}
if (dbbox.dx || dbbox.dy) {
prevG.attr('transform', `translate(${dbbox.dx},${dbbox.dy})`);
this.linkX += dbbox.dx;
this.linkY += dbbox.dy;
}
prevG = newG;
});
}
_render() {
throw new Error('[no overwride errror] _render is not implemented.');
}
}
================================================
FILE: src/node/string.js
================================================
import Node from './node.js';
import { appendRectText } from './util.js';
export default class StringNode extends Node {
constructor(data) {
super(data, []);
this.textPad = 4;
}
_render(g) {
const bbox = appendRectText(g, 0, 0, this.data, this.textPad);
this.width = bbox.width;
this.height = bbox.height;
this.linkX = Math.round(this.width / 2);
this.linkY = Math.round(this.height / 2);
}
}
================================================
FILE: src/node/table.js
================================================
import Node from './node.js';
import { appendRectText } from './util.js';
export default class TableNode extends Node {
constructor(data, children) {
super(data, children);
this.textPad = 4;
}
_render(g) {
if (this.data.length === 0 || this.data[0].length === 0) {
return;
}
const tbl = this.renderCells(g);
const size = this.layoutCells(tbl);
this.width = size.width;
this.height = size.height;
this.linkX = Math.round(this.width / 2);
this.linkY = Math.round(this.height / 2);
}
renderCells(g) {
const tbl = [];
this.data.forEach((row) => {
const tblRow = [];
row.forEach((col) => {
const colG = g.append('g');
const bbox = appendRectText(colG, 0, 0, col, this.textPad);
tblRow.push({
g: colG,
bbox: bbox
});
});
tbl.push(tblRow);
});
return tbl;
}
layoutCells(tbl) {
const maxW = this.calcMaxWidths(tbl);
const maxH = this.calcMaxHeights(tbl);
var x = 0;
var y = 0;
tbl.forEach((row, rowI) => {
x = 0;
row.forEach((col, colI) => {
col.g.attr('transform', `translate(${x},${y})`);
col.g.select('rect')
.attr('width', maxW[colI])
.attr('height', maxH[rowI]);
x += maxW[colI];
});
y += maxH[rowI];
});
return { width: x, height: y };
}
calcMaxWidths(tbl) {
const maxW = [];
var colI, rowI;
for (colI = 0; colI < tbl[0].length; colI++) {
var w = 0;
for (rowI = 0; rowI < tbl.length; rowI++) {
w = Math.max(w, tbl[rowI][colI].bbox.width);
}
maxW.push(w);
}
return maxW;
}
calcMaxHeights(tbl) {
const maxH = [];
tbl.forEach((row) => {
var h = 0;
row.forEach((col) => {
h = Math.max(h, col.bbox.height);
});
maxH.push(h);
});
return maxH;
}
}
================================================
FILE: src/node/util.js
================================================
const MAX_LEN = 32;
export class BBox {
constructor(x=0, y=0, width=0, height=0) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
}
export function appendRectText(g, x, y, text, pad) {
if (typeof text === 'string' && text.length > MAX_LEN) {
text = text.substr(0, MAX_LEN) + '...';
}
const rect = g.append('rect')
.attr('class', getClassName(text));
const t = g.append('text')
.text(text);
const b = t.node().getBBox();
const w = Math.ceil(b.width);
const h = Math.ceil(b.height);
t
.attr('x', x + pad)
.attr('y', y + pad + h);
const bbox = new BBox(x, y, w + pad * 2, h + pad * 2);
rect
.attr('x', bbox.x)
.attr('y', bbox.y)
.attr('width', bbox.width)
.attr('height', bbox.height);
return bbox;
}
function getClassName(d) {
var name = '';
const type = typeof d;
if (d === null) {
return 'null-text';
} else if (type === 'string') {
name = 'string-text';
} else if (type === 'number') {
name = 'number-text';
} else if (type === 'boolean') {
name = 'boolean-text';
} else {
name = 'unknown-text';
}
return name;
}
================================================
FILE: src/reader/object.js
================================================
import StringNode from '../node/string.js';
import ArrayNode from '../node/array.js';
import TableNode from '../node/table.js';
import DummyNode from '../node/dummy.js';
import LinkNameDecorator from '../decorator/linkName.js';
export default class ObjectReader {
constructor() {
}
read(obj) {
return obj2node(obj, '');
}
}
function obj2node(obj, linkName) {
var node;
if (isPrimitive(obj)) {
node = new StringNode(obj);
} else if (Array.isArray(obj)) {
const nodes = [];
obj.forEach((item, i) => {
if (Array.isArray(item)) {
node = new DummyNode(obj2node(item, ''));
node.decorators.push(new LinkNameDecorator(`${linkName}[${i}]`));
nodes.push(node);
} else {
node = obj2node(item, `${linkName}[${i}]`);
nodes.push(node);
}
});
// empty array
if (nodes.length === 0) {
node = obj2node(null, `${linkName}[]`);
nodes.push(node);
}
node = new ArrayNode(nodes);
} else {
var name;
var tbl = [];
var children = [];
for (name in obj) {
if (!Object.prototype.hasOwnProperty.call(obj, name)) {
continue;
}
var data = obj[name];
if (isPrimitive(data)) {
tbl.push([name, data]);
} else {
children.push(obj2node(data, name));
}
}
if (tbl.length === 0) {
node = new TableNode([[' ', ' ']], children);
} else {
node = new TableNode(tbl, children);
}
}
if (linkName !== '' && node.constructor !== ArrayNode) {
node.decorators.push(new LinkNameDecorator(linkName));
}
return node;
}
function isPrimitive(d) {
const type = typeof d;
if (d === null || type === 'string' || type === 'number' || type === 'boolean') {
return true;
}
return false;
}
================================================
FILE: src/reader/test/object_reader_test.js
================================================
/* eslint-disable no-undef */
import Reader from '../object.js';
import StringNode from '../../node/string.js';
import ArrayNode from '../../node/array.js';
import TableNode from '../../node/table.js';
import DummyNode from '../../node/dummy.js';
import LinkNameDecorator from '../../decorator/linkName.js';
describe('test ObjectReader', function () {
var r;
beforeEach(function () {
r = new Reader();
});
// read a primitive object
it ('read a null', function () {
var d = r.read(null);
expect(d).to.be.instanceof(StringNode);
expect(d.data).to.equal(null);
expect(d.children).to.have.lengthOf(0);
});
it ('read a boolean', function () {
var d = r.read(true);
expect(d).to.be.instanceof(StringNode);
expect(d.data).to.equal(true);
expect(d.children).to.have.lengthOf(0);
d = r.read(false);
expect(d).to.be.instanceof(StringNode);
expect(d.data).to.equal(false);
expect(d.children).to.have.lengthOf(0);
});
it ('read a number', function () {
var d = r.read(666);
expect(d).to.be.instanceof(StringNode);
expect(d.data).to.equal(666);
expect(d.children).to.have.lengthOf(0);
d = r.read(3.14);
expect(d).to.be.instanceof(StringNode);
expect(d.data).to.equal(3.14);
expect(d.children).to.have.lengthOf(0);
});
it ('read a string', function () {
var d = r.read('JK business');
expect(d).to.be.instanceof(StringNode);
expect(d.data).to.equal('JK business');
expect(d.children).to.have.lengthOf(0);
d = r.read('お茶漬け');
expect(d).to.be.instanceof(StringNode);
expect(d.data).to.equal('お茶漬け');
expect(d.children).to.have.lengthOf(0);
});
// read a complex object
it ('read an array', function () {
var d = r.read([1, 2]);
expect(d.data).to.equal(null);
expect(d).to.be.instanceof(ArrayNode);
expect(d.children).to.have.lengthOf(2);
var c = d.children[0];
expect(c).to.be.instanceof(StringNode);
expect(c.data).to.equal(1);
expect(c.children).to.have.lengthOf(0);
c = d.children[1];
expect(c).to.be.instanceof(StringNode);
expect(c.data).to.equal(2);
expect(c.children).to.have.lengthOf(0);
});
it ('read a nested array', function () {
var d = r.read([1, [2, 3]]);
expect(d.data).to.equal(null);
expect(d).to.be.instanceof(ArrayNode);
expect(d.children).to.have.lengthOf(2);
var c = d.children[0];
expect(c).to.be.instanceof(StringNode);
expect(c.data).to.equal(1);
expect(c.children).to.have.lengthOf(0);
c = d.children[1];
expect(c).to.be.instanceof(DummyNode);
expect(c.data).to.eql(null);
expect(c.children).to.have.lengthOf(1);
d = c.children[0];
expect(d).to.be.instanceof(ArrayNode);
expect(d.data).to.equal(null);
expect(d.children).to.have.lengthOf(2);
c = d.children[0];
expect(c).to.be.instanceof(StringNode);
expect(c.data).to.equal(2);
expect(c.children).to.have.lengthOf(0);
c = d.children[1];
expect(c).to.be.instanceof(StringNode);
expect(c.data).to.equal(3);
expect(c.children).to.have.lengthOf(0);
});
it ('read an object', function () {
var d = r.read({
x: 1,
y: 2
});
expect(d).to.be.instanceof(TableNode);
expect(d.data).to.eql([['x', 1], ['y', 2]]);
expect(d.children).to.have.lengthOf(0);
});
it ('read a nested object', function () {
var d = r.read({
name: {
first: 'Bob',
last: 'Bach'
},
age: 24
});
expect(d).to.be.instanceof(TableNode);
expect(d.data).to.eql([['age', 24]]);
expect(d.children).to.have.lengthOf(1);
var c = d.children[0];
expect(c).to.be.instanceof(TableNode);
expect(c.data).to.eql([['first', 'Bob'], ['last', 'Bach']]);
expect(c.children).to.have.lengthOf(0);
var deco = c.decorators[0];
expect(deco).to.be.instanceof(LinkNameDecorator);
expect(deco.linkName).to.equal('name');
});
it ('read a nested object with no parent data', function () {
var d = r.read({
name: {
first: 'Bob',
last: 'Bach'
}
});
expect(d).to.be.instanceof(TableNode);
expect(d.data).to.eql([[' ', ' ']]);
expect(d.children).to.have.lengthOf(1);
var c = d.children[0];
expect(c).to.be.instanceof(TableNode);
expect(c.data).to.eql([['first', 'Bob'], ['last', 'Bach']]);
expect(c.children).to.have.lengthOf(0);
var deco = c.decorators[0];
expect(deco).to.be.instanceof(LinkNameDecorator);
expect(deco.linkName).to.equal('name');
});
it ('read an array containing an object', function () {
var d = r.read([1, {val: 4}]);
expect(d.data).to.equal(null);
expect(d).to.be.instanceof(ArrayNode);
expect(d.children).to.have.lengthOf(2);
var c = d.children[0];
expect(c).to.be.instanceof(StringNode);
expect(c.data).to.equal(1);
expect(c.children).to.have.lengthOf(0);
c = d.children[1];
expect(c).to.be.instanceof(TableNode);
expect(c.data).to.eql([['val', 4]]);
expect(c.children).to.have.lengthOf(0);
});
it ('read an object containing an array', function () {
var d = r.read({
name: 'Mike',
vals: [2, 4]
});
expect(d).to.be.instanceof(TableNode);
expect(d.data).to.eql([['name', 'Mike']]);
expect(d.children).to.have.lengthOf(1);
var c = d.children[0];
expect(c).to.be.instanceof(ArrayNode);
expect(c.data).to.equal(null);
expect(c.children).to.have.lengthOf(2);
d = c.children[0];
expect(d).to.be.instanceof(StringNode);
expect(d.data).to.equal(2);
expect(d.children).to.have.lengthOf(0);
var deco = d.decorators[0];
expect(deco).to.be.instanceof(LinkNameDecorator);
expect(deco.linkName).to.equal('vals[0]');
d = c.children[1];
expect(d).to.be.instanceof(StringNode);
expect(d.data).to.equal(4);
expect(d.children).to.have.lengthOf(0);
deco = d.decorators[0];
expect(deco).to.be.instanceof(LinkNameDecorator);
expect(deco.linkName).to.equal('vals[1]');
});
});
================================================
FILE: src/util.js
================================================
export function visitBefore(node, callback) {
const nodes = [node];
while (nodes.length !== 0) {
node = nodes.pop();
callback(node);
const children = node.children;
if (children) {
var n = children.length;
while (--n >= 0) {
nodes.push(children[n]);
}
}
}
}
export function visitAfter(node, callback) {
const nodes = [node];
const nodes2 = [];
while (nodes.length !== 0) {
node = nodes.pop();
nodes2.push(node);
const children = node.children;
if (children) {
var i = -1;
const n = children.length;
while (++i < n) {
nodes.push(children[i]);
}
}
}
while (nodes2.length !== 0) {
node = nodes2.pop();
callback(node);
}
}
================================================
FILE: src/vtree.js
================================================
/* global d3 */
import Node from './node/node.js';
import StringNode from './node/string.js';
import TableNode from './node/table.js';
import ArrayNode from './node/array.js';
import TreeLayout from './layout/tree.js';
import ArrayLayout from './layout/array.js';
import ObjectReader from './reader/object.js';
import { visitAfter } from './util.js';
const WIDTH = 960;
const HEIGHT = 800;
const MARGIN = 20;
const DEFAULT_TREE_LAYOUT_HEIGHT = 50;
const DEBUG_TREE_LAYOUT_HEIGHT = 100;
const style = `
.vtree-node text { font: 14px sans-serif; }
.vtree-link { fill: none; stroke: #888; stroke-width: 2px; }
.vtree-table { stroke-width: 2px; stroke: steelblue; }
path.vtree-table { fill: white; }
g.vtree-node rect { fill: white; stroke: black; stroke-width: 1px; }
g.vtree-node rect.number-text { fill: #d8f0ed; }
g.vtree-node rect.string-text { fill: #e7f0db; }
g.vtree-node rect.boolean-text { fill: #e1d8f0; }
g.vtree-node rect.null-text { fill: #888; }
`;
class VTree {
constructor(container) {
this.root = new ArrayNode([], new ArrayLayout({ hideLinks: true }));
this.defaultLayout = new TreeLayout({height: DEFAULT_TREE_LAYOUT_HEIGHT});
this.container = container;
this._width = WIDTH;
this._height = HEIGHT;
this._debug = false;
this.d3 = {};
this.d3.container = d3.select(this.container);
this.d3.zoomListener = d3.behavior.zoom()
.scaleExtent([0.1, 10])
.on('zoom', () => {
const e = d3.event;
if (this.d3.g) {
this.d3.g.attr('transform', `translate(${e.translate})scale(${e.scale})`);
}
});
this.d3.svg = this.d3.container.append('svg')
.attr('class', 'vtree')
.attr('width', this._width)
.attr('height', this._height)
.call(this.d3.zoomListener);
}
width(width) {
if (arguments.length === 0) {
return this._width;
}
this._width = width;
this.d3.container.select('svg')
.attr('width', width);
return this;
}
height(height) {
if (arguments.length === 0) {
return this._height;
}
this._height = height;
this.d3.container.select('svg')
.attr('height', height);
return this;
}
debug(debug) {
if (arguments.length === 0) {
return this._debug;
}
if (debug) {
this.defaultLayout.height = DEBUG_TREE_LAYOUT_HEIGHT;
} else {
this.defaultLayout.height = DEFAULT_TREE_LAYOUT_HEIGHT;
}
this._debug = debug;
return this;
}
data(data) {
if (Array.isArray(data)) {
this.root.children = data;
} else {
this.root.children = [data];
}
return this;
}
createSvgString() {
var svg = this.d3.svg.node();
var serializer = new XMLSerializer();
var source = serializer.serializeToString(svg);
if (!source.match(/^<svg[^>]+xmlns="http:\/\/www\.w3\.org\/2000\/svg"/)) {
source = source.replace(/^<svg/, '<svg xmlns="http://www.w3.org/2000/svg"');
}
if (!source.match(/^<svg[^>]+"http:\/\/www\.w3\.org\/1999\/xlink"/)) {
source = source.replace(/^<svg/, '<svg xmlns:xlink="http://www.w3.org/1999/xlink"');
}
source = '<?xml version="1.0" standalone="no"?>\r\n' + source;
return source;
}
createTreeGroups(parentG, depth) {
var hasChildren = false;
const g = parentG
.selectAll('g.vtree-node')
.data(function (d) {
if (d.children.length !== 0) {
hasChildren = true;
}
return d.children;
})
.enter()
.append('g')
.attr('class', 'vtree-node')
.each(function (d) {
d.g = d3.select(this);
});
if (hasChildren) {
this.createTreeGroups(g, depth + 1);
}
}
update() {
const root = {
id: 1,
children: [this.root]
};
this.d3.svg.selectAll('*').remove();
this.d3.svg.append('style').text(style);
this._debugDrawGrid();
this.d3.g = this.d3.svg.selectAll('g.vtree-root')
.data([root])
.enter()
.append('g')
.attr('class', 'vtree-root');
this.createTreeGroups(this.d3.g, 0);
visitAfter(this.root, (node) => {
node.render(node.g);
const layout = node.layout || this.defaultLayout;
layout.layout(node);
if (layout.renderLinks) {
layout.renderLinks(node);
}
});
if (this._debug) {
visitAfter(this.root, (node) => {
this._debugDrawNodeInfo(node);
});
}
this.setRootPos();
return this;
}
setRootPos() {
this.root.x = Math.round((this._width - this.root.width) / 2);
this.root.y = Math.round((this._height - this.root.totalHeight) / 2);
if (this.root.y < MARGIN) {
this.root.y = MARGIN;
}
this.root.g.attr('transform', `translate(${this.root.x},${this.root.y})`);
}
_debugGetG() {
if (!this._debug) {
return;
}
var g = this.d3.svg.select('g.debug-info');
if (!g.empty()) {
return g;
}
return this.d3.svg.append('g')
.attr('class', 'debug-info');
}
_debugDrawGrid() {
if (!this._debug) {
return;
}
const g = this._debugGetG();
g.append('line')
.style('stroke', 'red')
.attr('x1', this._width / 2)
.attr('y1', 0)
.attr('x2', this._width / 2)
.attr('y2', this._height);
g.append('line')
.style('stroke', 'red')
.attr('x1', 0)
.attr('y1', this._height / 2)
.attr('x2', this._width)
.attr('y2', this._height / 2);
}
_debugDrawNodeInfo(node) {
if (node.constructor === ArrayNode) {
return;
}
// node rect
node.g.append('rect')
.style('fill', 'none')
.style('stroke', 'tomato')
.attr('x', -1)
.attr('y', -1)
.attr('width', node.width + 2)
.attr('height', node.height + 2);
// node total rect
node.g.append('rect')
.style('fill', 'none')
.style('stroke', 'mediumpurple')
.attr('x', (node.width - node.totalWidth) / 2)
.attr('y', 0)
.attr('width', node.totalWidth)
.attr('height', node.totalHeight);
// x, y
const xy = node.g.append('text')
.text(`x=${node.x} y=${node.y}`);
const bbox = xy.node().getBBox();
var x = node.width / 2;
var y = node.height + bbox.height + 2;
xy
.attr('x', x)
.attr('y', y)
.attr('text-anchor', 'middle');
y += bbox.height + 2;
// width, height
node.g.append('text')
.text(`w=${node.width} h=${node.height}`)
.attr('x', x)
.attr('y', y)
.attr('text-anchor', 'middle');
y += bbox.height + 2;
// totalWidth, totalHeight
node.g.append('text')
.text(`tw=${node.totalWidth} th=${node.totalHeight}`)
.attr('x', x)
.attr('y', y)
.attr('text-anchor', 'middle');
y += bbox.height + 2;
// childrenWidth
node.g.append('text')
.text(`cw=${node.childrenWidth}`)
.attr('x', x)
.attr('y', y)
.attr('text-anchor', 'middle');
}
}
VTree.node = {};
VTree.node.Node = Node;
VTree.node.String = StringNode;
VTree.node.Table = TableNode;
VTree.node.Array = ArrayNode;
VTree.layout = {};
VTree.layout.Tree = TreeLayout;
VTree.layout.Array = ArrayLayout;
VTree.reader = {};
VTree.reader.Object = ObjectReader;
module.exports = VTree;
================================================
FILE: test.html
================================================
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>vtree tests</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="css/vtree.css" type="text/css"/>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="dist/vtree.js"></script>
<script type="text/javascript">
window.onload = function () {
var NUM_TEST_S = 6;
var NUM_TEST_M = 6;
var NUM_TEST = 8;
var reader = new VTree.reader.Object();
function drawJSON(name, width, height) {
var container = document.getElementById("div-test-" + name);
var s = document.getElementById("code-test-" + name).innerHTML;
var jsonData = JSON.parse(s);
var data = reader.read(jsonData);
new VTree(container)
.width(width)
.height(height)
.debug(true)
.data(data)
.update();
}
var i;
for (i = 0; i < NUM_TEST_S; i++) {
drawJSON('s-' + i, 200, 200);
}
for (i = 0; i < NUM_TEST_M; i++) {
drawJSON('m-' + i, 400, 400);
}
for (i = 0; i < NUM_TEST; i++) {
drawJSON(i, 600, 600);
}
};
</script>
</head>
<body style="background-color: #DFD;">
<div class="container-fluid">
<div class="row">
<h1>vtree tests</h1>
</div>
<div class="row">
<div class="col-md-2 col-xs-4">
<code id="code-test-s-0">null</code>
<div id="div-test-s-0"></div>
</div>
<div class="col-md-2 col-xs-4">
<code id="code-test-s-1">true</code>
<div id="div-test-s-1"></div>
</div>
<div class="col-md-2 col-xs-4">
<code id="code-test-s-2">123</code>
<div id="div-test-s-2"></div>
</div>
<div class="col-md-2 col-xs-4">
<code id="code-test-s-3">"黄 飛鴻"</code>
<div id="div-test-s-3"></div>
</div>
<div class="col-md-2 col-xs-4">
<code id="code-test-s-4">[1234.56789, "ABCDE"]</code>
<div id="div-test-s-4"></div>
</div>
<div class="col-md-2 col-xs-4">
<code id="code-test-s-5">{ "key": "value" }</code>
<div id="div-test-s-5"></div>
</div>
</div>
<div class="row">
<div class="col-md-4 col-xs-6">
<code id="code-test-m-0">{"name": "=" ,"children": [{"name": "id=range"},{"name": "class=range"}]}</code>
<div id="div-test-m-0"></div>
</div>
<div class="col-md-4 col-xs-6">
<code id="code-test-m-1">{
"array": [
1,
2,
3
],
"boolean": true,
"null": null,
"number": 123,
"object": {
"a": "b",
"c": "d",
"e": "f"
},
"string": "Hello World"
}</code>
<div id="div-test-m-1"></div>
</div>
<div class="col-md-4 col-xs-6">
<code id="code-test-m-2">{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [125.6, 10.1]
},
"properties": {
"name": "Dinagat Islands"
}
}</code>
<div id="div-test-m-2"></div>
</div>
</div>
<div class="row">
<div class="col-md-4 col-xs-6">
<code id="code-test-m-3">{"employees":[
{"firstName":"John", "lastName":"Doe"},
{"firstName":"Anna", "lastName":"Smith"},
{"firstName":"Peter", "lastName":"Jones"}
]}</code>
<div id="div-test-m-3"></div>
</div>
<div class="col-md-4 col-xs-6">
<code id="code-test-m-4">{
"items": [
{
"index": 1,
"index_start_at": 56,
"integer": 29,
"float": 16.8278,
"name": "Milton",
"surname": "Jensen",
"fullname": "Sheryl Winters",
"email": "denise@weiss.na",
"bool": false
}
]
}</code>
<div id="div-test-m-4"></div>
</div>
<div class="col-md-4 col-xs-6">
<code id="code-test-m-5">[1, [2, [3, 4]]]</code>
<div id="div-test-m-5"></div>
</div>
</div>
<div class="row">
<div class="col-md-6 col-xs-12">
<code id="code-test-0" style="display: none;">[{"sha": "faddda990159ad8a17eabf49fd0f89c24506d8c0", "commit": {"author": {"name": "ivan111", "date": "2017-03-19T13:52:24+09:00"}, "committer": {"name": "ivan111", "date": "2017-03-19T13:52:24+09:00"}, "message": "remove unused js", "tree": {"sha": "44c77d4d627c1c69b78041d838a38d7339c17409"}}, "parents": [{"sha": "1e2b280d5a182309af10b03e0d5bd0cefb038464"}]}, {"sha": "1e2b280d5a182309af10b03e0d5bd0cefb038464", "commit": {"author": {"name": "ivan111", "date": "2017-03-19T12:55:05+09:00"}, "committer": {"name": "ivan111", "date": "2017-03-19T12:55:05+09:00"}, "message": "make more readable and maintanable", "tree": {"sha": "83806c1db236a10975b195fda5ac703edaa6b3a6"}}, "parents": [{"sha": "c0f3d8d9ee3b19298bc470682cbb2ddcd2fdfc69"}, {"sha": "1dbf187a83ca55e4633eb4736c8a9e96ce1c9ea9"}]}]</code>
<div id="div-test-0"></div>
</div>
<div class="col-md-6 col-xs-12">
<code id="code-test-1" style="display: none;">{"name": "for" ,"children": [{"name": "id=i"},{"name": "call" ,"children": [{"name": "id=range"},{"name": "list" ,"children": [{"name": "1"},{"name": "cell" ,"children": [{"name": "5"},{"name": "None"}]},{"name": "cell" ,"children": [{"name": "5"},{"name": "None"}]}]}]},{"name": "cell" ,"children": [{"name": "call" ,"children": [{"name": "id=print"},{"name": "list" ,"children": [{"name": "1"},{"name": "cell" ,"children": [{"name": "id=i"},{"name": "None"}]},{"name": "cell" ,"children": [{"name": "id=i"},{"name": "None"}]}]}]},{"name": "None"}]}]}</code>
<div id="div-test-1"></div>
</div>
</div>
<div class="row">
<div class="col-md-6 col-xs-12">
<code id="code-test-2" style="display: none;">{
"firstName": "John",
"lastName": "Smith",
"gender": "man",
"age": 32,
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
"postalCode": "10021"
},
"phoneNumbers": [
{ "type": "home", "number": "212 555-1234" },
{ "type": "fax", "number": "646 555-4567" }
]
}</code>
<div id="div-test-2"></div>
</div>
<div class="col-md-6 col-xs-12">
<code id="code-test-3" style="display: none;">{
"first": "John",
"last": "Doe",
"age": 39,
"sex": "M",
"salary": 70000,
"registered": true,
"interests": [ "Reading", "Mountain Biking", "Hacking" ],
"favorites": {
"color": "Blue",
"sport": "Soccer",
"food": "Spaghetti"
},
"skills": [
{
"category": "JavaScript",
"tests": [
{ "name": "One", "score": 90 },
{ "name": "Two", "score": 96 }
]
},
{
"category": "CouchDB",
"tests": [
{ "name": "One", "score": 79 },
{ "name": "Two", "score": 84 }
]
},
{
"category": "Node.js",
"tests": [
{ "name": "One", "score": 97 },
{ "name": "Two", "score": 93 }
]
}
]
}</code>
<div id="div-test-3"></div>
</div>
</div>
<div class="row">
<div class="col-md-6 col-xs-12">
<code id="code-test-4" style="display: none;">{"responseData": {"feed":{"feedUrl":"http://feeds.feedburner.com/marcqualie","title":"Marc Qualie","link":"http://blog.marcqualie.com/","author":"","description":"My Personal Tech Blog and Ramblings","type":"atom10","entries":[{"title":"Server Backups with s3cmd","link":"http://feedproxy.google.com/~r/marcqualie/~3/acTzLDpmoBA/server-backups-with-s3cmd","author":"Marc Qualie","publishedDate":"Sun, 28 Jul 2013 13:04:32 -0700","contentSnippet":"I've been asked a few times how I back up my servers at Digital Ocean. It seems this topic is quite popular due to the fact ...","content":"I've been asked a few times how I back up my servers at \u003ca href\u003d\"https://www.digitalocean.com/?refcode\u003d4f6e23440060\"\u003eDigital Ocean\u003c/a\u003e. It seems this topic is quite popular due to the fact they just started charging for automated backups on the 1st of July. In this article I'm going to go through the process of using \u003ca href\u003d\"http://s3tools.org/s3cmd\"\u003es3cmd\u003c/a\u003e with \u003ca href\u003d\"https://aws.amazon.com/s3/\"\u003eAmazon S3\u003c/a\u003e to easily backup and restore your servers. Although I use Digital Ocean as my own hosting company, and this is where this backup system is in place, it can just as easily be transferred to any hosting provider.\u003cbr\u003e\u003cbr\u003eLabels: \u003ca href\u003d\"http://marcqualie.com/tag/linux\"\u003eLinux\u003c/a\u003e, \u003ca href\u003d\"http://marcqualie.com/tag/digital-ocean\"\u003eDigital Ocean\u003c/a\u003e, \u003ca href\u003d\"http://marcqualie.com/tag/aws\"\u003eAWS\u003c/a\u003e, \u003ca href\u003d\"http://marcqualie.com/tag/backup\"\u003eBackup\u003c/a\u003e, \u003ca href\u003d\"http://marcqualie.com/tag/servers\"\u003eServers\u003c/a\u003e, \u003ca href\u003d\"http://marcqualie.com/tag/s3\"\u003eS3\u003c/a\u003e\u003cbr\u003eSource: \u003ca href\u003d\"http://marcqualie.com/2013/07/server-backups-with-s3cmd\"\u003ehttp://marcqualie.com/2013/07/server-backups-with-s3cmd\u003c/a\u003e\u003cimg src\u003d\"http://feeds.feedburner.com/~r/marcqualie/~4/acTzLDpmoBA\" height\u003d\"1\" width\u003d\"1\"\u003e","categories":["Linux","Digital Ocean","AWS","Backup","Servers","S3"]},{"title":"Criterion: A PHP CI Server","link":"http://feedproxy.google.com/~r/marcqualie/~3/2OSaAVrZ2-A/criterion:-a-php-ci-server","author":"Marc Qualie","publishedDate":"Sat, 20 Jul 2013 12:42:06 -0700","contentSnippet":"Today, the Romhut team just released an open source project that has been aggressively developed over the last few weeks. It ...","content":"Today, the Romhut team just released an open source project that has been aggressively developed over the last few weeks. It started as a personal tool to test our many private repositories in a controlled environment but quickly evolved into a fully fledged, generic open source continuous integration server. Thanks to hours of discussion and endless commits (mainly from \u003ca href\u003d\"https://github.com/scottymeuk\"\u003e@scottymeuk\u003c/a\u003e), \u003ca href\u003d\"http://romhut.github.io/criterion\"\u003eCriterion\u003c/a\u003e was born.\u003cbr\u003e\u003cbr\u003eLabels: \u003ca href\u003d\"http://marcqualie.com/tag/open-source\"\u003eOpen Source\u003c/a\u003e, \u003ca href\u003d\"http://marcqualie.com/tag/php\"\u003ePHP\u003c/a\u003e, \u003ca href\u003d\"http://marcqualie.com/tag/ci\"\u003eCI\u003c/a\u003e, \u003ca href\u003d\"http://marcqualie.com/tag/romhut\"\u003eRomhut\u003c/a\u003e\u003cbr\u003eSource: \u003ca href\u003d\"http://marcqualie.com/2013/07/criterion:-a-php-ci-server\"\u003ehttp://marcqualie.com/2013/07/criterion:-a-php-ci-server\u003c/a\u003e\u003cimg src\u003d\"http://feeds.feedburner.com/~r/marcqualie/~4/2OSaAVrZ2-A\" height\u003d\"1\" width\u003d\"1\"\u003e","categories":["Open Source","PHP","CI","Romhut"]},{"title":"Homebrew Nginx Tap","link":"http://feedproxy.google.com/~r/marcqualie/~3/-lMBWS9lz9I/homebrew-nginx-tap","author":"Marc Qualie","publishedDate":"Sun, 30 Jun 2013 02:31:46 -0700","contentSnippet":"I've recently been working on an Nginx Tap for Mac OS X Homebrew and now I think it's time to share with the world. Originally ...","content":"I've recently been working on an \u003ca href\u003d\"https://github.com/marcqualie/homebrew-nginx\"\u003eNginx Tap\u003c/a\u003e for Mac OS X Homebrew and now I think it's time to share with the world. Originally I created a pull request on the original repo but due to the custom nature of the modules I needed it was reccomended that I create a tap and maintain my own repository (tap). The main goal behind the tap is to create a version of Nginx with as many modules as possible so people can create fully custom builds very easily.\u003cbr\u003e\u003cbr\u003eLabels: \u003ca href\u003d\"http://marcqualie.com/tag/open-source\"\u003eOpen Source\u003c/a\u003e, \u003ca href\u003d\"http://marcqualie.com/tag/nginx\"\u003eNginx\u003c/a\u003e, \u003ca href\u003d\"http://marcqualie.com/tag/ruby\"\u003eRuby\u003c/a\u003e, \u003ca href\u003d\"http://marcqualie.com/tag/homebrew\"\u003eHomebrew\u003c/a\u003e\u003cbr\u003eSource: \u003ca href\u003d\"http://marcqualie.com/2013/06/homebrew-nginx-tap\"\u003ehttp://marcqualie.com/2013/06/homebrew-nginx-tap\u003c/a\u003e\u003cimg src\u003d\"http://feeds.feedburner.com/~r/marcqualie/~4/-lMBWS9lz9I\" height\u003d\"1\" width\u003d\"1\"\u003e","categories":["Open Source","Nginx","Ruby","Homebrew"]},{"title":"Open Source Challenge Complete!","link":"http://feedproxy.google.com/~r/marcqualie/~3/K36wPrXGE0s/open-source-challenge-complete","author":"Marc Qualie","publishedDate":"Thu, 20 Jun 2013 14:20:35 -0700","contentSnippet":"For those of you that follow my blog reguarly, a few weeks ago I announced I was undertaking my Open Source Challenge. Today ...","content":"For those of you that follow my blog reguarly, a few weeks ago I announced I was undertaking my \u003ca href\u003d\"/2013/05/open-source-challenge\"\u003eOpen Source Challenge\u003c/a\u003e. Today marks the 32nd day of consecutive code pushes, so I successfully completed my goal! I've attached a list of the projects I contributed to for you guys to check out.\u003cbr\u003e\u003cbr\u003eLabels: \u003ca href\u003d\"http://marcqualie.com/tag/open-source\"\u003eOpen Source\u003c/a\u003e, \u003ca href\u003d\"http://marcqualie.com/tag/php\"\u003ePHP\u003c/a\u003e\u003cbr\u003eSource: \u003ca href\u003d\"http://marcqualie.com/2013/06/open-source-challenge-complete\"\u003ehttp://marcqualie.com/2013/06/open-source-challenge-complete\u003c/a\u003e\u003cimg src\u003d\"http://feeds.feedburner.com/~r/marcqualie/~4/K36wPrXGE0s\" height\u003d\"1\" width\u003d\"1\"\u003e","categories":["Open Source","PHP"]},{"title":"StatsD PHP Library","link":"http://feedproxy.google.com/~r/marcqualie/~3/RkDcfkSNX54/statsd-php-library","author":"Marc Qualie","publishedDate":"Thu, 13 Jun 2013 05:09:44 -0700","contentSnippet":"Today, I just created a StatsD PHP Library and released it on Github . Before you start with \"but there are already loads..\", I ...","content":"Today, I just created a \u003ca href\u003d\"https://github.com/etsy/statsd/\"\u003eStatsD\u003c/a\u003e PHP Library and released it on \u003ca href\u003d\"https://github.com/marcqualie/php-statsd\"\u003eGithub \u003c/a\u003e. Before you start with \"but there are already loads..\", I do realise this, but they didn't suite my needs. This is a short post to let you know why I opted to create my own, and what I hope to achieve from it.\u003cbr\u003e\u003cbr\u003eLabels: \u003ca href\u003d\"http://marcqualie.com/tag/open-source\"\u003eOpen Source\u003c/a\u003e, \u003ca href\u003d\"http://marcqualie.com/tag/github\"\u003eGithub\u003c/a\u003e, \u003ca href\u003d\"http://marcqualie.com/tag/php\"\u003ePHP\u003c/a\u003e, \u003ca href\u003d\"http://marcqualie.com/tag/statistics\"\u003eStatistics\u003c/a\u003e, \u003ca href\u003d\"http://marcqualie.com/tag/library\"\u003eLibrary\u003c/a\u003e\u003cbr\u003eSource: \u003ca href\u003d\"http://marcqualie.com/2013/06/statsd-php-library\"\u003ehttp://marcqualie.com/2013/06/statsd-php-library\u003c/a\u003e\u003cimg src\u003d\"http://feeds.feedburner.com/~r/marcqualie/~4/RkDcfkSNX54\" height\u003d\"1\" width\u003d\"1\"\u003e","categories":["Open Source","Github","PHP","Statistics","Library"]},{"title":"Open Source Challenge","link":"http://feedproxy.google.com/~r/marcqualie/~3/Vs9h5mvWdOs/open-source-challenge","author":"Marc Qualie","publishedDate":"Mon, 27 May 2013 04:13:48 -0700","contentSnippet":"It's bank Holiday Monday and I think it's about time for a new challenge. I've been working a lot with Open Source lately, both ...","content":"It's bank Holiday Monday and I think it's about time for a new challenge. I've been working a lot with Open Source lately, both contributing to other people's projects and refactoring/improving my own. My current contribution streak on Github is 8 consecutive days of published code, which is pretty awesome considering my previous best was 2 days from about 6 months ago. Not only is this making me a better programmer but it's also extremely fun. With this in mind I've decided the new challenge is to try and create a 32 day streak.\u003cbr\u003e\u003cbr\u003eLabels: \u003ca href\u003d\"http://marcqualie.com/tag/open-source\"\u003eOpen Source\u003c/a\u003e, \u003ca href\u003d\"http://marcqualie.com/tag/programming\"\u003eProgramming\u003c/a\u003e, \u003ca href\u003d\"http://marcqualie.com/tag/github\"\u003eGithub\u003c/a\u003e, \u003ca href\u003d\"http://marcqualie.com/tag/challenge\"\u003eChallenge\u003c/a\u003e\u003cbr\u003eSource: \u003ca href\u003d\"http://marcqualie.com/2013/05/open-source-challenge\"\u003ehttp://marcqualie.com/2013/05/open-source-challenge\u003c/a\u003e\u003cimg src\u003d\"http://feeds.feedburner.com/~r/marcqualie/~4/Vs9h5mvWdOs\" height\u003d\"1\" width\u003d\"1\"\u003e","categories":["Open Source","Programming","Github","Challenge"]},{"title":"Why I use Digital Ocean Hosting","link":"http://feedproxy.google.com/~r/marcqualie/~3/qoXUdyFGckQ/why-i-use-digital-ocean-hosting","author":"Marc Qualie","publishedDate":"Thu, 23 May 2013 12:19:14 -0700","contentSnippet":"In the last few years I've used a lot of hosting providers. Until now I've never actually found any that have been able to ...","content":"In the last few years I've used a lot of hosting providers. Until now I've never actually found any that have been able to satisfy my needs at the right price. Sure, there are huge companies such as AWS, Rackspace and Softlayer to name a few, but who has the budget to use these kinds of providers for research or personal projects outside of a big enterprise company. Previously I used Linode. I'm going to let you guys know why I switched and why \u003ca href\u003d\"https://www.digitalocean.com/?refcode\u003d4f6e23440060\"\u003eDigital Ocean\u003c/a\u003e is my host of choice right now.\u003cbr\u003e\u003cbr\u003eLabels: \u003ca href\u003d\"http://marcqualie.com/tag/hosting\"\u003eHosting\u003c/a\u003e, \u003ca href\u003d\"http://marcqualie.com/tag/promotion\"\u003ePromotion\u003c/a\u003e, \u003ca href\u003d\"http://marcqualie.com/tag/digital-ocean\"\u003eDigital Ocean\u003c/a\u003e\u003cbr\u003eSource: \u003ca href\u003d\"http://marcqualie.com/2013/05/why-i-use-digital-ocean-hosting\"\u003ehttp://marcqualie.com/2013/05/why-i-use-digital-ocean-hosting\u003c/a\u003e\u003cimg src\u003d\"http://feeds.feedburner.com/~r/marcqualie/~4/qoXUdyFGckQ\" height\u003d\"1\" width\u003d\"1\"\u003e","categories":["Hosting","Promotion","Digital Ocean"]},{"title":"Why I learned Ruby","link":"http://feedproxy.google.com/~r/marcqualie/~3/MUhruEiZUgY/why-i-learned-ruby","author":"Marc Qualie","publishedDate":"Sat, 04 May 2013 13:30:13 -0700","contentSnippet":"For a while now I've been hearing a lot of people taking about the programming language Ruby. Not that it's anything new, it ...","content":"For a while now I've been hearing a lot of people taking about the programming language Ruby. Not that it's anything new, it just seems to be a lot more popular in my circle of friends and my Twitter feed. Naturally, as a professional PHP developer, I should hate the idea of Ruby and start some crazy argument about how PHP is far superior and Ruby should die (blah blah etc.. boring). Instead of this approach, I took it upon myself to learn Ruby from the ground up and understand why so many people enjoy using it to power their applications. Too many people argue over things without understanding both points of view, which always annoys me.\u003cbr\u003e\u003cbr\u003eLabels: \u003ca href\u003d\"http://marcqualie.com/tag/programming\"\u003eProgramming\u003c/a\u003e, \u003ca href\u003d\"http://marcqualie.com/tag/php\"\u003ePHP\u003c/a\u003e, \u003ca href\u003d\"http://marcqualie.com/tag/project\"\u003eProject\u003c/a\u003e, \u003ca href\u003d\"http://marcqualie.com/tag/ruby\"\u003eRuby\u003c/a\u003e\u003cbr\u003eSource: \u003ca href\u003d\"http://marcqualie.com/2013/05/why-i-learned-ruby\"\u003ehttp://marcqualie.com/2013/05/why-i-learned-ruby\u003c/a\u003e\u003cimg src\u003d\"http://feeds.feedburner.com/~r/marcqualie/~4/MUhruEiZUgY\" height\u003d\"1\" width\u003d\"1\"\u003e","categories":["Programming","PHP","Project","Ruby"]},{"title":"Using Cloudflare Page Rules","link":"http://feedproxy.google.com/~r/marcqualie/~3/-qkvCDEJ0p0/using-cloudflare-page-rules","author":"Marc Qualie","publishedDate":"Mon, 01 Apr 2013 11:46:04 -0700","contentSnippet":"Today, I decided to explore Cloudflare features in a bit more depth. I currently manage quite a few applications, both personal ...","content":"Today, I decided to explore Cloudflare features in a bit more depth. I currently manage quite a few applications, both personal and business related on the platform. One feature which I'd never really looked into before was Page Rules. I'd read about them, but never actually applied them to any sites. Due to how much of an affect it actually had by applying a few rules, I feel like I should spread the word for anyone who isn't aware of what they are and how amazing they can be when used correctly.\u003cbr\u003e\u003cbr\u003eLabels: \u003ca href\u003d\"http://marcqualie.com/tag/php\"\u003ePHP\u003c/a\u003e, \u003ca href\u003d\"http://marcqualie.com/tag/nginx\"\u003eNginx\u003c/a\u003e, \u003ca href\u003d\"http://marcqualie.com/tag/cloudflare\"\u003eCloudflare\u003c/a\u003e, \u003ca href\u003d\"http://marcqualie.com/tag/cache\"\u003eCache\u003c/a\u003e, \u003ca href\u003d\"http://marcqualie.com/tag/cdn\"\u003eCDN\u003c/a\u003e\u003cbr\u003eSource: \u003ca href\u003d\"http://marcqualie.com/2013/04/using-cloudflare-page-rules\"\u003ehttp://marcqualie.com/2013/04/using-cloudflare-page-rules\u003c/a\u003e\u003cimg src\u003d\"http://feeds.feedburner.com/~r/marcqualie/~4/-qkvCDEJ0p0\" height\u003d\"1\" width\u003d\"1\"\u003e","categories":["PHP","Nginx","Cloudflare","Cache","CDN"]},{"title":"New Writing Topics","link":"http://feedproxy.google.com/~r/marcqualie/~3/NsovESjzfNM/new-writing-topics","author":"Marc Qualie","publishedDate":"Wed, 20 Mar 2013 16:34:59 -0700","contentSnippet":"I've been neglecting my Blog lately mainly because I feel like I need to always write masses of code examples and showcase my ...","content":"I've been neglecting my Blog lately mainly because I feel like I need to always write masses of code examples and showcase my own projects but I've decided that shouldn't be the case. Most of the code I write I can't share due to contracts, but I've been using so many awesome tools from the open source world that I feel like I need to share and spread awareness to other programmers.\u003cbr\u003e\u003cbr\u003eLabels: \u003ca href\u003d\"http://marcqualie.com/tag/open-source\"\u003eOpen Source\u003c/a\u003e, \u003ca href\u003d\"http://marcqualie.com/tag/random\"\u003eRandom\u003c/a\u003e, \u003ca href\u003d\"http://marcqualie.com/tag/personal\"\u003ePersonal\u003c/a\u003e\u003cbr\u003eSource: \u003ca href\u003d\"http://marcqualie.com/2013/03/new-writing-topics\"\u003ehttp://marcqualie.com/2013/03/new-writing-topics\u003c/a\u003e\u003cimg src\u003d\"http://feeds.feedburner.com/~r/marcqualie/~4/NsovESjzfNM\" height\u003d\"1\" width\u003d\"1\"\u003e","categories":["Open Source","Random","Personal"]}]}}, "responseDetails": null, "responseStatus": 200}</code>
<div id="div-test-4"></div>
</div>
<div class="col-md-6 col-xs-12">
<code id="code-test-5" style="display: none;">["FunctionLiteral", {"name":""}, ["ExpressionStatement", ["Assignment", {"op":"ASSIGN"}, ["VariableProxy", {"name":"x"} ], ["Literal", {"handle":1} ] ] ], ["IfStatement", ["CompareOperation", {"op":"GT"}, ["VariableProxy", {"name":"x"} ], ["Literal", {"handle":0} ] ], ["Block", ["ExpressionStatement", ["Assignment", {"op":"ASSIGN"}, ["VariableProxy", {"name":"y"} ], ["BinaryOperation", {"op":"ADD"}, ["VariableProxy", {"name":"x"} ], ["Literal", {"handle":2} ] ] ] ], ["ExpressionStatement", ["Call", ["VariableProxy", {"name":"print"} ], ["VariableProxy", {"name":"y"} ] ] ] ], ["EmptyStatement"] ] ]</code>
<div id="div-test-5"></div>
</div>
</div>
<div class="row">
<div class="col-md-6 col-xs-12">
<code id="code-test-6" style="display: none;">
{
"responseData": {
"results": [{
"GsearchResultClass": "GwebSearch",
"unescapedUrl": "http://en.wikipedia.org/wiki/Stack_(abstract_data_type )",
"url": "http://en.wikipedia.org/wiki/Stack_(abstract_data_type )",
"visibleUrl": "en.wikipedia.org",
"cacheUrl": "http://www.google.com/search?q\u003dcache:hhCsdZCgMlUJ:en.wikipedia.org ",
"title": "\u003cb\u003eStack\u003c/b\u003e (abstract data type) - Wikipedia, the free encyclopedia",
"titleNoFormatting": "Stack (abstract data type) - Wikipedia, the free encyclopedia",
"content": "In computer science, a \u003cb\u003estack\u003c/b\u003e is a particular kind of abstract data type or collection \nin which the principal (or only) operations on the collection are the addition of \u003cb\u003e...\u003c/b\u003e"
}, {
"GsearchResultClass": "GwebSearch",
"unescapedUrl": "http://stackoverflow.com/",
"url": "http://stackoverflow.com/",
"visibleUrl": "stackoverflow.com",
"cacheUrl": "http://www.google.com/search?q\u003dcache:U1GC2GYOToIJ:stackoverflow.com ",
"title": "\u003cb\u003eStack\u003c/b\u003e Overflow",
"titleNoFormatting": "Stack Overflow",
"content": "A language-independent collaboratively edited question and answer site for \nprogrammers."
}, {
"GsearchResultClass": "GwebSearch",
"unescapedUrl": "http://www.stack.com/ ",
"url": "http://www.stack.com/ ",
"visibleUrl": "www.stack.com",
"cacheUrl": "http://www.google.com/search?q\u003dcache:E20ImyHZCpIJ:www.stack.com ",
"title": "Get Bigger, Stronger, Better, Faster | \u003cb\u003eSTACK\u003c/b\u003e",
"titleNoFormatting": "Get Bigger, Stronger, Better, Faster | STACK",
"content": "Get better at the sports you play and the life you lead at \u003cb\u003eSTACK\u003c/b\u003e. Improve your \ntraining, nutrition and lifestyle with daily."
}, {
"GsearchResultClass": "GwebSearch",
"unescapedUrl": "http://docs.oracle.com/javase/7/docs/api/java/util/Stack.html ",
"url": "http://docs.oracle.com/javase/7/docs/api/java/util/Stack.html ",
"visibleUrl": "docs.oracle.com",
"cacheUrl": "http://www.google.com/search?q\u003dcache:5G3WpASlFXAJ:docs.oracle.com ",
"title": "\u003cb\u003eStack\u003c/b\u003e (Java Platform SE 7 ) - Oracle Documentation",
"titleNoFormatting": "Stack (Java Platform SE 7 ) - Oracle Documentation",
"content": "The \u003cb\u003eStack\u003c/b\u003e class represents a last-in-first-out (LIFO) \u003cb\u003estack\u003c/b\u003e of objects. It extends \nclass Vector with five operations that allow a vector to be treated as a \u003cb\u003estack\u003c/b\u003e."
}],
"cursor": {
"resultCount": "18,800,000",
"pages": [{
"start": "0",
"label": 1
}, {
"start": "4",
"label": 2
}, {
"start": "8",
"label": 3
}, {
"start": "12",
"label": 4
}, {
"start": "16",
"label": 5
}, {
"start": "20",
"label": 6
}, {
"start": "24",
"label": 7
}, {
"start": "28",
"label": 8
}],
"estimatedResultCount": "18800000",
"currentPageIndex": 0,
"moreResultsUrl": "http://www.google.com/search?oe\u003dutf8\u0026ie\u003dutf8\u0026source\u003duds\u0026start\u003d0\u0026hl\u003den\u0026q\u003dstack ",
"searchResultTime": "0.14"
}
},
"responseDetails": null,
"responseStatus": 200
}
</code>
<div id="div-test-6"></div>
</div>
<div class="col-md-6 col-xs-12">
<code id="code-test-7" style="display: none;">"vacant lot"</code>
<div id="div-test-7"></div>
</div>
</div>
</div>
</body>
</html>
================================================
FILE: webpack.config.js
================================================
const path = require('path')
const config = {
mode: 'development',
entry: './src/vtree.js',
output: {
path: path.join(__dirname, 'dist'),
filename: 'vtree.js',
library: 'VTree'
},
module: {
rules: [
{
enforce: 'pre',
test: /\.js$/,
exclude: /node_modules/,
loader: 'eslint-loader'
},
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['es2015']
}
}
]
}
}
module.exports = config
gitextract_gick23ka/ ├── .eslintrc ├── .gitignore ├── LICENSE ├── README.md ├── css/ │ ├── custom.css │ └── vtree.css ├── dist/ │ └── vtree.js ├── index.html ├── package.json ├── src/ │ ├── decorator/ │ │ └── linkName.js │ ├── layout/ │ │ ├── array.js │ │ └── tree.js │ ├── node/ │ │ ├── README.md │ │ ├── array.js │ │ ├── dummy.js │ │ ├── node.js │ │ ├── string.js │ │ ├── table.js │ │ └── util.js │ ├── reader/ │ │ ├── object.js │ │ └── test/ │ │ └── object_reader_test.js │ ├── util.js │ └── vtree.js ├── test.html └── webpack.config.js
SYMBOL INDEX (75 symbols across 13 files)
FILE: dist/vtree.js
function __webpack_require__ (line 7) | function __webpack_require__(moduleId) {
FILE: src/decorator/linkName.js
class LinkNameDecorator (line 3) | class LinkNameDecorator {
method constructor (line 4) | constructor(linkName) {
method render (line 8) | render(g, oldG, width) {
FILE: src/layout/array.js
constant DURATION (line 3) | const DURATION = 1000;
class ArrayLayout (line 8) | class ArrayLayout {
method constructor (line 9) | constructor(options={}) {
method layout (line 13) | layout(node) {
method renderLinks (line 20) | renderLinks(node) {
function layout (line 28) | function layout(node) {
function renderLinks (line 50) | function renderLinks(node) {
function calcChildrenWidth (line 99) | function calcChildrenWidth(node) {
function calcTotalSize (line 118) | function calcTotalSize(node) {
FILE: src/layout/tree.js
constant MARGIN (line 5) | const MARGIN = 10;
constant HEIGHT (line 6) | const HEIGHT = 50;
constant DURATION (line 7) | const DURATION = 1000;
class TreeLayout (line 12) | class TreeLayout {
method constructor (line 13) | constructor(options={}) {
method layout (line 17) | layout(node) {
method renderLinks (line 24) | renderLinks(node) {
function layout (line 30) | function layout(node, height) {
function renderLinks (line 52) | function renderLinks(node) {
function calcChildrenWidth (line 88) | function calcChildrenWidth(node) {
function calcTotalSize (line 107) | function calcTotalSize(node, height) {
FILE: src/node/array.js
constant MARGIN (line 6) | const MARGIN = 10;
class ArrayNode (line 9) | class ArrayNode extends Node {
method constructor (line 10) | constructor(nodes, layout, options={}) {
method _render (line 26) | _render() {
FILE: src/node/dummy.js
class DummyNode (line 4) | class DummyNode extends Node {
method constructor (line 5) | constructor(child) {
method _render (line 11) | _render(g) {
FILE: src/node/node.js
class Node (line 16) | class Node {
method constructor (line 17) | constructor(data, children, layout) {
method render (line 32) | render(g) {
method _render (line 62) | _render() {
FILE: src/node/string.js
class StringNode (line 5) | class StringNode extends Node {
method constructor (line 6) | constructor(data) {
method _render (line 12) | _render(g) {
FILE: src/node/table.js
class TableNode (line 5) | class TableNode extends Node {
method constructor (line 6) | constructor(data, children) {
method _render (line 12) | _render(g) {
method renderCells (line 27) | renderCells(g) {
method layoutCells (line 49) | layoutCells(tbl) {
method calcMaxWidths (line 74) | calcMaxWidths(tbl) {
method calcMaxHeights (line 91) | calcMaxHeights(tbl) {
FILE: src/node/util.js
constant MAX_LEN (line 1) | const MAX_LEN = 32;
class BBox (line 3) | class BBox {
method constructor (line 4) | constructor(x=0, y=0, width=0, height=0) {
function appendRectText (line 13) | function appendRectText(g, x, y, text, pad) {
function getClassName (line 44) | function getClassName(d) {
FILE: src/reader/object.js
class ObjectReader (line 9) | class ObjectReader {
method constructor (line 10) | constructor() {
method read (line 13) | read(obj) {
function obj2node (line 19) | function obj2node(obj, linkName) {
function isPrimitive (line 80) | function isPrimitive(d) {
FILE: src/util.js
function visitBefore (line 1) | function visitBefore(node, callback) {
function visitAfter (line 21) | function visitAfter(node, callback) {
FILE: src/vtree.js
constant WIDTH (line 16) | const WIDTH = 960;
constant HEIGHT (line 17) | const HEIGHT = 800;
constant MARGIN (line 18) | const MARGIN = 20;
constant DEFAULT_TREE_LAYOUT_HEIGHT (line 20) | const DEFAULT_TREE_LAYOUT_HEIGHT = 50;
constant DEBUG_TREE_LAYOUT_HEIGHT (line 21) | const DEBUG_TREE_LAYOUT_HEIGHT = 100;
class VTree (line 36) | class VTree {
method constructor (line 37) | constructor(container) {
method width (line 66) | width(width) {
method height (line 79) | height(height) {
method debug (line 92) | debug(debug) {
method data (line 108) | data(data) {
method createSvgString (line 118) | createSvgString() {
method createTreeGroups (line 136) | createTreeGroups(parentG, depth) {
method update (line 160) | update() {
method setRootPos (line 204) | setRootPos() {
method _debugGetG (line 216) | _debugGetG() {
method _debugDrawGrid (line 231) | _debugDrawGrid() {
method _debugDrawNodeInfo (line 253) | _debugDrawNodeInfo(node) {
Condensed preview — 25 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (131K chars).
[
{
"path": ".eslintrc",
"chars": 287,
"preview": "{\n \"env\": {\n \"browser\": true,\n \"node\": true,\n \"es6\": true,\n \"mocha\": true\n },\n\n \"ecmaFeatures\": {\n \"mo"
},
{
"path": ".gitignore",
"chars": 32,
"preview": "node_modules\nnpm-debug.log\nlib/\n"
},
{
"path": "LICENSE",
"chars": 11323,
"preview": "Apache License\n Version 2.0, January 2004\n http://www.apache.org/licens"
},
{
"path": "README.md",
"chars": 424,
"preview": "JSON to Tree Diagram Converter\n==============================\n\n> For Yakusugi\n\nThis tool converts JSON strings into tree"
},
{
"path": "css/custom.css",
"chars": 626,
"preview": "body {\r\n font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;\r\n background-color: #f8f9fa;\r\n display: "
},
{
"path": "css/vtree.css",
"chars": 210,
"preview": "svg.vtree {\n overflow: hidden;\n background: #ffffff;\n -webkit-box-shadow: 4px 4px 8px rgba(0,0,0,0.5);\n -moz-box-sha"
},
{
"path": "dist/vtree.js",
"chars": 47876,
"preview": "var VTree =\n/******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModul"
},
{
"path": "index.html",
"chars": 4836,
"preview": "<!doctype html>\n<html lang=\"en\">\n\n<head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, i"
},
{
"path": "package.json",
"chars": 733,
"preview": "{\n \"name\": \"vtree\",\n \"version\": \"0.3.0\",\n \"description\": \"display json data in a tree diagram.\",\n \"main\": \"build/vtr"
},
{
"path": "src/decorator/linkName.js",
"chars": 744,
"preview": "const pad = 4;\n\nexport default class LinkNameDecorator {\n constructor(linkName) {\n this.linkName = linkName;\n }\n\n "
},
{
"path": "src/layout/array.js",
"chars": 2378,
"preview": "/* global d3 */\n\nconst DURATION = 1000;\n\nconst diagonal = d3.svg.diagonal();\n\n\nexport default class ArrayLayout {\n cons"
},
{
"path": "src/layout/tree.js",
"chars": 2392,
"preview": "/* global d3 */\n\nimport ArrayNode from '../node/array.js';\n\nconst MARGIN = 10;\nconst HEIGHT = 50;\nconst DURATION = 1000;"
},
{
"path": "src/node/README.md",
"chars": 528,
"preview": "# How to make a custom node\n\n1. extend the Node class\n\n```js\nexport default class MyNode extends Node {\n ...\n}\n```\n\n2. "
},
{
"path": "src/node/array.js",
"chars": 470,
"preview": "import Node from './node.js';\nimport ArrayLayout from '../layout/array.js';\n\nconst defaultLayout = new ArrayLayout();\n\nc"
},
{
"path": "src/node/dummy.js",
"chars": 382,
"preview": "import Node from './node.js';\n\n\nexport default class DummyNode extends Node {\n constructor(child) {\n super(null, [ch"
},
{
"path": "src/node/node.js",
"chars": 1291,
"preview": "/**\n * Node\n *\n * A tree consists of nodes and links.\n * A node consists of the following fields:\n *\n * - id : auto incr"
},
{
"path": "src/node/string.js",
"chars": 435,
"preview": "import Node from './node.js';\nimport { appendRectText } from './util.js';\n\n\nexport default class StringNode extends Node"
},
{
"path": "src/node/table.js",
"chars": 1927,
"preview": "import Node from './node.js';\nimport { appendRectText } from './util.js';\n\n\nexport default class TableNode extends Node "
},
{
"path": "src/node/util.js",
"chars": 1165,
"preview": "const MAX_LEN = 32;\n\nexport class BBox {\n constructor(x=0, y=0, width=0, height=0) {\n this.x = x;\n this.y = y;\n "
},
{
"path": "src/reader/object.js",
"chars": 1802,
"preview": "import StringNode from '../node/string.js';\nimport ArrayNode from '../node/array.js';\nimport TableNode from '../node/tab"
},
{
"path": "src/reader/test/object_reader_test.js",
"chars": 6064,
"preview": "/* eslint-disable no-undef */\n\nimport Reader from '../object.js';\n\nimport StringNode from '../../node/string.js';\nimport"
},
{
"path": "src/util.js",
"chars": 756,
"preview": "export function visitBefore(node, callback) {\n const nodes = [node];\n\n while (nodes.length !== 0) {\n node = nodes.p"
},
{
"path": "src/vtree.js",
"chars": 7292,
"preview": "/* global d3 */\n\nimport Node from './node/node.js';\nimport StringNode from './node/string.js';\nimport TableNode from './"
},
{
"path": "test.html",
"chars": 28524,
"preview": "<!doctype html>\n<html>\n<head>\n<meta charset=\"utf-8\">\n\n<title>vtree tests</title>\n\n<link rel=\"stylesheet\" href=\"https://m"
},
{
"path": "webpack.config.js",
"chars": 528,
"preview": "const path = require('path')\n\nconst config = {\n mode: 'development',\n\n entry: './src/vtree.js',\n\n output: {\n path:"
}
]
About this extraction
This page contains the full source code of the ivan111/vtree GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 25 files (120.1 KB), approximately 35.5k tokens, and a symbol index with 75 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.