diff --git a/index_js.bootstrap.js b/index_js.bootstrap.js index 68518d1..e544cc4 100644 --- a/index_js.bootstrap.js +++ b/index_js.bootstrap.js @@ -35,7 +35,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \******************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _binding_pkg_binding_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../binding/pkg/binding.js */ \"../binding/pkg/binding.js\");\n\n\ndocument.getElementById(\"browse\").addEventListener(\"change\", handleFiles, false);\n\nvar context = undefined;\nconst update_button = document.getElementById(\"update\");\nconst input = document.getElementById('input');\nconst output = document.getElementById(\"output\");\nconst generate_button = document.getElementById(\"generate\");\nconst max_nodes = document.getElementById(\"max_nodes\");\nconst max_edges = document.getElementById(\"max_edges\");\nconst nodes_count = document.getElementById(\"nodes_count\");\nconst edges_count = document.getElementById(\"edges_count\");\nconst focus = document.getElementById(\"focus\");\nconst focus_options = document.getElementById(\"focus_options\");\nvar currentId = \"\";\nvar lastColor;\n\nfunction handleFiles() {\n const reader = new FileReader();\n reader.onload = (function (x) {\n input.value = x.target.result;\n update_button.click();\n });\n reader.readAsText(this.files[0]);\n}\n\nfunction update_render() {\n max_nodes.value = Math.min(max_nodes.value, max_nodes.max);\n max_edges.value = Math.min(max_edges.value, max_edges.max);\n output.innerHTML = context.render(currentId, max_nodes.value, max_edges.value);\n if (!context.is_error()) {\n svgPanZoom(output.childNodes[0], { controlIconsEnabled: true, zoomScaleSensitivity: .5, maxZoom: 20 });\n }\n}\n\nupdate_button.onclick = function () {\n focus_options.innerHTML = \"\"\n focus.value = \"\"\n currentId = \"\"\n context = _binding_pkg_binding_js__WEBPACK_IMPORTED_MODULE_0__.parse(input.value);\n update_render();\n}\n\ngenerate_button.onclick = function () {\n nodes_count.value = Math.min(nodes_count.value, nodes_count.max);\n edges_count.value = Math.min(edges_count.value, edges_count.max);\n input.value = _binding_pkg_binding_js__WEBPACK_IMPORTED_MODULE_0__.render_random(nodes_count.value, edges_count.value);\n document.getElementById('update').click();\n}\n\nfocus.addEventListener('input', _ => {\n if (!context) {\n return;\n }\n const items = context.find_nodes(focus.value);\n focus_options.innerHTML = items.splice(0, 10)\n .map(v => '
  • ' + v.id() + ' ' + v.label() + '
  • ')\n .join('');\n})\n\ndocument.outputClickHandler = id => {\n if (currentId) {\n document.getElementById(currentId).setAttribute('fill', lastColor);\n }\n currentId = id;\n focus.value = id.substr(4);\n update_render();\n const item = document.getElementById(id);\n lastColor = item.getAttribute('fill')\n currentId = id;\n item.setAttribute('fill', 'green')\n}\n\ndocument.visualize = data => {\n input.value = 'digraph g {' + data + '}'\n update_button.click()\n}\n\n// create graph on load if we have an input (nice for page reload)\nif (input.value.length != 0) {\n update_button.click();\n}\n\n//# sourceURL=webpack://create-wasm-app/./index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _binding_pkg_binding_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../binding/pkg/binding.js */ \"../binding/pkg/binding.js\");\n\n\nif (document.readyState != 'complete') {\n window.addEventListener(\"load\", _ => init());\n} else {\n init();\n}\n\nfunction init() {\n document.getElementById(\"browse\").addEventListener(\"change\", handleFiles, false);\n\n var context = undefined;\n const update_button = document.getElementById(\"update\");\n const input = document.getElementById('input');\n const output = document.getElementById(\"output\");\n const generate_button = document.getElementById(\"generate\");\n const max_nodes = document.getElementById(\"max_nodes\");\n const max_edges = document.getElementById(\"max_edges\");\n const nodes_count = document.getElementById(\"nodes_count\");\n const edges_count = document.getElementById(\"edges_count\");\n const focus = document.getElementById(\"focus\");\n const focus_options = document.getElementById(\"focus_options\");\n var currentId = \"\";\n var lastColor;\n\n function handleFiles() {\n const reader = new FileReader();\n reader.onload = (function (x) {\n input.value = x.target.result;\n update_button.click();\n });\n reader.readAsText(this.files[0]);\n }\n\n function update_render() {\n max_nodes.value = Math.min(max_nodes.value, max_nodes.max);\n max_edges.value = Math.min(max_edges.value, max_edges.max);\n output.innerHTML = context.render(currentId, max_nodes.value, max_edges.value);\n if (!context.is_error()) {\n svgPanZoom(output.childNodes[0], { controlIconsEnabled: true, zoomScaleSensitivity: .5, maxZoom: 20 });\n }\n }\n\n update_button.onclick = function () {\n focus_options.innerHTML = \"\"\n focus.value = \"\"\n currentId = \"\"\n context = _binding_pkg_binding_js__WEBPACK_IMPORTED_MODULE_0__.parse(input.value);\n update_render();\n }\n\n generate_button.onclick = function () {\n nodes_count.value = Math.min(nodes_count.value, nodes_count.max);\n edges_count.value = Math.min(edges_count.value, edges_count.max);\n input.value = _binding_pkg_binding_js__WEBPACK_IMPORTED_MODULE_0__.render_random(nodes_count.value, edges_count.value);\n document.getElementById('update').click();\n }\n\n focus.addEventListener('input', _ => {\n if (!context) {\n return;\n }\n const items = context.find_nodes(focus.value);\n focus_options.innerHTML = items.splice(0, 10)\n .map(v => '
  • ' + v.id() + ' ' + v.label() + '
  • ')\n .join('');\n })\n\n document.outputClickHandler = id => {\n if (currentId) {\n document.getElementById(currentId).setAttribute('fill', lastColor);\n }\n currentId = id;\n focus.value = id.substr(4);\n update_render();\n const item = document.getElementById(id);\n lastColor = item.getAttribute('fill')\n currentId = id;\n item.setAttribute('fill', 'green')\n }\n\n document.visualize = data => {\n input.value = 'digraph g {' + data + '}'\n update_button.click()\n }\n\n // create graph on load if we have an input (nice for page reload)\n if (input.value.length != 0) {\n update_button.click();\n }\n}\n\n//# sourceURL=webpack://create-wasm-app/./index.js?"); /***/ }),