From 84a6ff676f7652e9755b77baa4f0a8e8a7d4b3ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ho=CC=88rler?= Date: Sat, 14 Jul 2018 19:58:18 +0200 Subject: [PATCH] first basic test of alchemy --- EHEC_Server/EHEC_Server/EHEC_Server.csproj | 52 + EHEC_Server/EHEC_Server/Web.config | 4 +- .../EHEC_Server/alchemy/alchemy-white.css | 698 + EHEC_Server/EHEC_Server/alchemy/alchemy.css | 714 + EHEC_Server/EHEC_Server/alchemy/alchemy.js | 3153 +++ .../EHEC_Server/alchemy/alchemy.min.css | 1 + .../EHEC_Server/alchemy/alchemy.min.js | 3 + .../EHEC_Server/alchemy/scripts/vendor.js | 10 + .../alchemy/styles/fonts/FontAwesome.otf | Bin 0 -> 75188 bytes .../styles/fonts/fontawesome-webfont.eot | Bin 0 -> 72449 bytes .../styles/fonts/fontawesome-webfont.svg | 504 + .../styles/fonts/fontawesome-webfont.ttf | Bin 0 -> 141564 bytes .../styles/fonts/fontawesome-webfont.woff | Bin 0 -> 83760 bytes .../alchemy/styles/images/maze-black.png | Bin 0 -> 667 bytes .../EHEC_Server/alchemy/styles/vendor.css | 8 + .../EHEC_Server/alchemy/testdata/actors.json | 3588 ++++ .../alchemy/testdata/charlize.json | 767 + .../alchemy/testdata/prestocratics.json | 3412 +++ .../bootstrap/css/bootstrap-grid.css | 1912 ++ .../bootstrap/css/bootstrap-grid.css.map | 1 + .../bootstrap/css/bootstrap-grid.min.css | 7 + .../bootstrap/css/bootstrap-grid.min.css.map | 1 + .../bootstrap/css/bootstrap-reboot.css | 331 + .../bootstrap/css/bootstrap-reboot.css.map | 1 + .../bootstrap/css/bootstrap-reboot.min.css | 8 + .../css/bootstrap-reboot.min.css.map | 1 + .../EHEC_Server/bootstrap/css/bootstrap.css | 9023 ++++++++ .../bootstrap/css/bootstrap.css.map | 1 + .../bootstrap/css/bootstrap.min.css | 7 + .../bootstrap/css/bootstrap.min.css.map | 1 + .../bootstrap/js/bootstrap.bundle.js | 6461 ++++++ .../bootstrap/js/bootstrap.bundle.js.map | 1 + .../bootstrap/js/bootstrap.bundle.min.js | 7 + .../bootstrap/js/bootstrap.bundle.min.js.map | 1 + .../EHEC_Server/bootstrap/js/bootstrap.js | 3944 ++++ .../EHEC_Server/bootstrap/js/bootstrap.js.map | 1 + .../EHEC_Server/bootstrap/js/bootstrap.min.js | 7 + .../bootstrap/js/bootstrap.min.js.map | 1 + EHEC_Server/EHEC_Server/cluster.aspx | 60 + EHEC_Server/EHEC_Server/cluster.aspx.cs | 17 + .../EHEC_Server/cluster.aspx.designer.cs | 24 + EHEC_Server/EHEC_Server/d3/API.md | 1313 ++ EHEC_Server/EHEC_Server/d3/CHANGES.md | 1407 ++ EHEC_Server/EHEC_Server/d3/LICENSE | 27 + EHEC_Server/EHEC_Server/d3/README.md | 57 + EHEC_Server/EHEC_Server/d3/d3.js | 17813 ++++++++++++++++ EHEC_Server/EHEC_Server/d3/d3.min.js | 2 + .../EHEC_Server/jquery/jquery-3.3.1.min.js | 2 + EHEC_Server/EHEC_Server/lodash/lodash.js | 17105 +++++++++++++++ 49 files changed, 72456 insertions(+), 2 deletions(-) create mode 100644 EHEC_Server/EHEC_Server/alchemy/alchemy-white.css create mode 100644 EHEC_Server/EHEC_Server/alchemy/alchemy.css create mode 100644 EHEC_Server/EHEC_Server/alchemy/alchemy.js create mode 100644 EHEC_Server/EHEC_Server/alchemy/alchemy.min.css create mode 100644 EHEC_Server/EHEC_Server/alchemy/alchemy.min.js create mode 100644 EHEC_Server/EHEC_Server/alchemy/scripts/vendor.js create mode 100644 EHEC_Server/EHEC_Server/alchemy/styles/fonts/FontAwesome.otf create mode 100644 EHEC_Server/EHEC_Server/alchemy/styles/fonts/fontawesome-webfont.eot create mode 100644 EHEC_Server/EHEC_Server/alchemy/styles/fonts/fontawesome-webfont.svg create mode 100644 EHEC_Server/EHEC_Server/alchemy/styles/fonts/fontawesome-webfont.ttf create mode 100644 EHEC_Server/EHEC_Server/alchemy/styles/fonts/fontawesome-webfont.woff create mode 100644 EHEC_Server/EHEC_Server/alchemy/styles/images/maze-black.png create mode 100644 EHEC_Server/EHEC_Server/alchemy/styles/vendor.css create mode 100644 EHEC_Server/EHEC_Server/alchemy/testdata/actors.json create mode 100644 EHEC_Server/EHEC_Server/alchemy/testdata/charlize.json create mode 100644 EHEC_Server/EHEC_Server/alchemy/testdata/prestocratics.json create mode 100644 EHEC_Server/EHEC_Server/bootstrap/css/bootstrap-grid.css create mode 100644 EHEC_Server/EHEC_Server/bootstrap/css/bootstrap-grid.css.map create mode 100644 EHEC_Server/EHEC_Server/bootstrap/css/bootstrap-grid.min.css create mode 100644 EHEC_Server/EHEC_Server/bootstrap/css/bootstrap-grid.min.css.map create mode 100644 EHEC_Server/EHEC_Server/bootstrap/css/bootstrap-reboot.css create mode 100644 EHEC_Server/EHEC_Server/bootstrap/css/bootstrap-reboot.css.map create mode 100644 EHEC_Server/EHEC_Server/bootstrap/css/bootstrap-reboot.min.css create mode 100644 EHEC_Server/EHEC_Server/bootstrap/css/bootstrap-reboot.min.css.map create mode 100644 EHEC_Server/EHEC_Server/bootstrap/css/bootstrap.css create mode 100644 EHEC_Server/EHEC_Server/bootstrap/css/bootstrap.css.map create mode 100644 EHEC_Server/EHEC_Server/bootstrap/css/bootstrap.min.css create mode 100644 EHEC_Server/EHEC_Server/bootstrap/css/bootstrap.min.css.map create mode 100644 EHEC_Server/EHEC_Server/bootstrap/js/bootstrap.bundle.js create mode 100644 EHEC_Server/EHEC_Server/bootstrap/js/bootstrap.bundle.js.map create mode 100644 EHEC_Server/EHEC_Server/bootstrap/js/bootstrap.bundle.min.js create mode 100644 EHEC_Server/EHEC_Server/bootstrap/js/bootstrap.bundle.min.js.map create mode 100644 EHEC_Server/EHEC_Server/bootstrap/js/bootstrap.js create mode 100644 EHEC_Server/EHEC_Server/bootstrap/js/bootstrap.js.map create mode 100644 EHEC_Server/EHEC_Server/bootstrap/js/bootstrap.min.js create mode 100644 EHEC_Server/EHEC_Server/bootstrap/js/bootstrap.min.js.map create mode 100644 EHEC_Server/EHEC_Server/cluster.aspx create mode 100644 EHEC_Server/EHEC_Server/cluster.aspx.cs create mode 100644 EHEC_Server/EHEC_Server/cluster.aspx.designer.cs create mode 100644 EHEC_Server/EHEC_Server/d3/API.md create mode 100644 EHEC_Server/EHEC_Server/d3/CHANGES.md create mode 100644 EHEC_Server/EHEC_Server/d3/LICENSE create mode 100644 EHEC_Server/EHEC_Server/d3/README.md create mode 100644 EHEC_Server/EHEC_Server/d3/d3.js create mode 100644 EHEC_Server/EHEC_Server/d3/d3.min.js create mode 100644 EHEC_Server/EHEC_Server/jquery/jquery-3.3.1.min.js create mode 100644 EHEC_Server/EHEC_Server/lodash/lodash.js diff --git a/EHEC_Server/EHEC_Server/EHEC_Server.csproj b/EHEC_Server/EHEC_Server/EHEC_Server.csproj index b6df2d2..310d3a0 100644 --- a/EHEC_Server/EHEC_Server/EHEC_Server.csproj +++ b/EHEC_Server/EHEC_Server/EHEC_Server.csproj @@ -80,10 +80,55 @@ EntityModelCodeGenerator Model.Designer.cs + + + + + + + + + + + + + + + + + + + + + + + + Model.edmx + + + + + + + + + + + + + + + + + + + + + Web.config @@ -107,6 +152,13 @@ + + cluster.aspx + ASPXCodeBehind + + + cluster.aspx + diff --git a/EHEC_Server/EHEC_Server/Web.config b/EHEC_Server/EHEC_Server/Web.config index e2466e9..3fd839c 100644 --- a/EHEC_Server/EHEC_Server/Web.config +++ b/EHEC_Server/EHEC_Server/Web.config @@ -30,8 +30,8 @@ - - + + diff --git a/EHEC_Server/EHEC_Server/alchemy/alchemy-white.css b/EHEC_Server/EHEC_Server/alchemy/alchemy-white.css new file mode 100644 index 0000000..c48f614 --- /dev/null +++ b/EHEC_Server/EHEC_Server/alchemy/alchemy-white.css @@ -0,0 +1,698 @@ +@-webkit-keyframes fadeIn { + 0% { + opacity: 0; + } + + 25% { + opacity: .3; + } + + 50% { + opacity: .66; + } + + 75% { + opacity: 1; + } +} + +@keyframes fadeIn { + 0% { + opacity: 0; + } + + 25% { + opacity: .3; + } + + 50% { + opacity: .66; + } + + 75% { + opacity: 1; + } +} + +@-webkit-keyframes pulse { + 0% { + text-shadow: 0 0 10px rgba(255,255,255,0.2),0 0 12px rgba(255,255,255,0.2),0 0 16px rgba(255,255,255,0.2); + } + + 25% { + text-shadow: 0 0 12px rgba(255,255,255,0.2),0 0 15px rgba(255,255,255,0.2),0 0 20px rgba(255,255,255,0.2),0 0 6px rgba(104,185,254,0.7),0 0 10px rgba(104,185,254,0.7); + } + + 50% { + text-shadow: 0 0 12px rgba(255,255,255,0.2),0 0 15px rgba(255,255,255,0.2),0 0 20px rgba(255,255,255,0.2),0 0 8px rgba(104,185,254,0.7),0 0 10px rgba(104,185,254,0.7),0 0 15px rgba(104,185,254,0.7); + } + + 75% { + text-shadow: 0 0 12px rgba(255,255,255,0.2),0 0 15px rgba(255,255,255,0.2),0 0 25px rgba(255,255,255,0.2),0 0 8px rgba(104,185,254,0.7),0 0 12px rgba(104,185,254,0.7),0 0 15px rgba(104,185,254,0.7),0 0 20px rgba(104,185,254,0.7); + } +} + +@keyframes pulse { + 0% { + text-shadow: 0 0 10px rgba(255,255,255,0.2),0 0 12px rgba(255,255,255,0.2),0 0 16px rgba(255,255,255,0.2); + } + + 25% { + text-shadow: 0 0 12px rgba(255,255,255,0.2),0 0 15px rgba(255,255,255,0.2),0 0 20px rgba(255,255,255,0.2),0 0 6px rgba(104,185,254,0.7),0 0 10px rgba(104,185,254,0.7); + } + + 50% { + text-shadow: 0 0 12px rgba(255,255,255,0.2),0 0 15px rgba(255,255,255,0.2),0 0 20px rgba(255,255,255,0.2),0 0 8px rgba(104,185,254,0.7),0 0 10px rgba(104,185,254,0.7),0 0 15px rgba(104,185,254,0.7); + } + + 75% { + text-shadow: 0 0 12px rgba(255,255,255,0.2),0 0 15px rgba(255,255,255,0.2),0 0 25px rgba(255,255,255,0.2),0 0 8px rgba(104,185,254,0.7),0 0 12px rgba(104,185,254,0.7),0 0 15px rgba(104,185,254,0.7),0 0 20px rgba(104,185,254,0.7); + } +} + +@-webkit-keyframes slide-in { + 0% { + -webkit-transform: translate(-100%, 0); + transform: translate(-100%, 0); + } + + 100% { + -webkit-transform: translate(0%, 0); + transform: translate(0%, 0); + } +} + +@keyframes slide-in { + 0% { + -webkit-transform: translate(-100%, 0); + transform: translate(-100%, 0); + } + + 100% { + -webkit-transform: translate(0%, 0); + transform: translate(0%, 0); + } +} + +@-webkit-keyframes slide-out { + 0% { + -webkit-transform: translate(0%, 0); + transform: translate(0%, 0); + } + + 100% { + -webkit-transform: translate(-100%, 0); + transform: translate(-100%, 0); + } +} + +@keyframes slide-out { + 100% { + -webkit-transform: translate(-100%, 0); + transform: translate(-100%, 0); + } +} + +svg { + background: white; + position: absolute; + left: 0; + cursor: -webkit-grab; + height: 100%; + width: 100%; + color: #333; +} + +.edge path { + fill: none; +} + +.edge .edge-handler { + stroke: transparent; + fill: none; +} + +.edge text { + display: none; + fill: white; + font-weight: 200; + text-anchor: middle; + z-index: 1000; + text-shadow: 1px 1px #333, -1px 1px #333, 1px -1px #333, -1px -1px #333; +} + +.edge.active text { + display: none; + fill: white; + font-weight: 200; + text-anchor: middle; + z-index: 1000; + text-shadow: 1px 1px #333, -1px 1px #333, 1px -1px #333, -1px -1px #333; +} + +.edge.active:hover, +.edge.active.selected { + cursor: pointer; +} + +.edge.active:hover text, +.edge.active.selected text { + display: block; +} + +#zoom-controls { + background-color: rgba(0,0,0,0.3); + border-top-right-radius: 3px; + border-bottom-right-radius: 3px; + box-shadow: 0 0 5px rgba(255,255,255,0.3); + margin-top: 10%; + z-index: 5; + position: relative; + display: block; + width: 55px; +} + +#zoom-controls #zoom-in, +#zoom-controls #zoom-out, +#zoom-controls #zoom-reset { + padding: 12px; + margin: 0; + width: 100%; +} + +#zoom-controls #zoom-in i, +#zoom-controls #zoom-out i, +#zoom-controls #zoom-reset i { + color: #E89619; +} + +#zoom-controls #zoom-in:hover, +#zoom-controls #zoom-out:hover, +#zoom-controls #zoom-reset:hover { + background-color: rgba(255,255,255,0.2); +} + +#zoom-controls #zoom-in:active, +#zoom-controls #zoom-out:active, +#zoom-controls #zoom-reset:active { + border: none; +} + +.fa-caret-right, +.fa-caret-down { + margin: 0 5px; + color: #68b9fe; +} + +#search { + margin-top: 2em; + margin-bottom: 1em; + padding: .5em 1em; + width: 100%; +} + +#search span { + vertical-align: bottom; +} + +#search input { + background-color: transparent; + border: thin dashed #68B9FE; + font-size: 20px; + padding-left: 0.5em; + margin-top: -1px; +} + +#search input::-webkit-input-placeholder { + color: white; +} + +#search input:-moz-placeholder { + color: white; +} + +#search input::-moz-placeholder { + color: white; +} + +#search input:-ms-input-placeholder { + color: white; +} + +#search .search-icon { + height: 22px; + background-color: transparent; + border: thin dashed #68B9FE; + color: white; +} + +#stats { + padding: 0.5em 1em; + background-color: transparent; + border-bottom: thin dashed #68b9fe; +} + +#stats #stats-header { + padding: 10px; +} + +#stats #all-stats { + color: white; + border-radius: none; + border: none; + background: transparent; + overflow: auto; +} + +#stats #all-stats li { + padding: 3px; +} + +#stats #node-stats-graph, +#stats #edge-stats-graph { + height: 250px; +} + +#stats #node-stats-graph svg, +#stats #edge-stats-graph svg { + opacity: .6; + background: transparent; +} + +#stats #node-stats-graph text, +#stats #edge-stats-graph text { + font-size: 16px; + fill: white; + font-weight: 200; + text-anchor: middle; + z-index: 1000; +} + +#stats #node-stats-graph .no-data, +#stats #edge-stats-graph .no-data { + margin: 30px 0; + color: #68b9fe; +} + +#stats .badge { + border-radius: 0; + height: 100%; + background-color: rgba(104,185,254,0.6); +} + +#editor { + padding: 0.5em 1em; + background-color: transparent; + border-bottom: thin dashed #68b9fe; +} + +#editor h3 { + padding: 10px; +} + +#editor #element-options { + display: -webkit-flex; + display: flex; + -webkit-flex-direction: column; + flex-direction: column; + cursor: pointer; + margin-top: 10px; + margin-left: 2%; + color: white; +} + +#editor #element-options .node-property, +#editor #element-options #node-add-property { + display: -webkit-inline-flex; + display: inline-flex; + margin: 4px 0; + width: 100%; +} + +#editor #element-options .property-value, +#editor #element-options #node-add-property #add-property #node-add-prop-value { + border: thin rgba(255,255,255,0.2) solid; + border-left: none; + background-color: black; + color: white; + width: 100%; + border-top-left-radius: 0; + border-bottom-left-radius: 0; +} + +#editor #element-options .property-name, +#editor #element-options #node-add-property #add-property #node-add-prop-key { + text-align: center; + font-weight: 200; + cursor: default; + background: #2E2E2E; + border: thin transparent solid; + color: #68b9fe; + border-right: none; + border-top-right-radius: 0; + border-bottom-right-radius: 0; +} + +#editor #element-options #node-add-property #add-property { + display: -webkit-flex; + display: flex; + -webkit-flex-grow: 2; + flex-grow: 2; + -webkit-flex-direction: column; + flex-direction: column; +} + +#editor #element-options #node-add-property #add-property #node-add-prop-value { + text-align: center; + width: 100%; + border-top-right-radius: 0; + border-bottom-right-radius: 0; + border-bottom-left-radius: 4px; + border: thin rgba(255,255,255,0.2) solid; +} + +#editor #element-options #node-add-property #add-property #node-add-prop-key { + cursor: text; + width: 100%; + border-top-left-radius: 4px; + border-bottom-left-radius: 0; +} + +#editor #element-options input[type="submit"], +#editor #element-options #update-properties { + color: #68b9fe; + border-top-right-radius: 4px; + border-bottom-right-radius: 4px; + width: auto; + background: rgba(255,255,255,0.1); + border: thin solid #68b9fe; + text-align: center; +} + +#editor #element-options input[type="submit"]:active, +#editor #element-options #update-properties:active, +#editor #element-options input[type="submit"]:focus, +#editor #element-options #update-properties:focus { + outline: none; +} + +#editor #element-options input[type="submit"]:hover, +#editor #element-options #update-properties:hover { + color: white; + border: thin solid white; +} + +#editor #element-options #update-properties { + border-radius: 4px; + padding: 10px; + width: 100%; + margin-bottom: 20px; +} + +#editor #editor-interactions.active { + color: #68b9fe; +} + +#editor #editor-interactions.inactive { + color: white; +} + +#editor #node-editor.enabled { + -webkit-animation: fadeIn 1s linear; + animation: fadeIn 1s linear; +} + +#control-dash-wrapper { + font-family: 'Source Sans Pro', Helvetica, sans-serif; + letter-spacing: .05em; + height: inherit; + z-index: inherit; + padding: 0; +} + +#control-dash-wrapper.initial { + -webkit-transform: translate(-100%, 0); + transform: translate(-100%, 0); +} + +#control-dash-wrapper.initial #dash-toggle { + color: #68b9fe; + -webkit-animation: 4s pulse linear; + animation: 4s pulse linear; +} + +#control-dash-wrapper.off-canvas { + -webkit-transform: translate(-100%, 0); + transform: translate(-100%, 0); + -webkit-animation: slide-out .75s linear; + animation: slide-out .75s linear; +} + +#control-dash-wrapper.off-canvas #dash-toggle { + color: #68b9fe; + -webkit-animation: 4s pulse linear; + animation: 4s pulse linear; +} + +#control-dash-wrapper.on-canvas { + -webkit-animation: slide-in .75s ease-in-out; + animation: slide-in .75s ease-in-out; +} + +#control-dash-wrapper.on-canvas * { + box-shadow: none !important; +} + +#control-dash-wrapper.on-canvas #dash-toggle { + color: rgba(104,185,254,0.6); +} + +#control-dash-wrapper.on-canvas #dash-toggle:hover { + color: #68b9fe; + -webkit-animation: 4s pulse linear; + animation: 4s pulse linear; +} + +#control-dash-wrapper #control-dash { + overflow-x: hidden; + overflow-y: scroll; + background-color: rgba(0,0,0,0.3); + padding: 0; + height: inherit; + z-index: 5; +} + +#control-dash-wrapper #control-dash h3 { + display: inline; + margin: 0; +} + +#control-dash-wrapper #dash-toggle { + z-index: 5; + background-color: rgba(0,0,0,0.3); + border-top-right-radius: 3px; + border-bottom-right-radius: 3px; + box-shadow: 0 0 5px rgba(255,255,255,0.3); + position: absolute; + left: 0; + top: 50%; + font-size: 2.2em; + color: rgba(255,255,255,0.2); + padding: 10px; +} + +#control-dash-wrapper button { + border-radius: 0; + border: none; + background-color: transparent; +} + +#control-dash-wrapper button:active { + border: none; +} + +#control-dash-wrapper h3 { + font-weight: 200; + margin-top: 10px; + color: white; + cursor: pointer; + vertical-align: top; +} + +#control-dash-wrapper li { + cursor: pointer; + background: transparent; + border: none; + border-radius: 0; +} + +.node { + cursor: pointer; +} + +.node text.root { + font-size: 32px; +} + +.node text { + display: none; + fill: white; + font-weight: 200; + text-anchor: middle; + z-index: 1000; + text-shadow: 1px 1px #333, -1px 1px #333, 1px -1px #333, -1px -1px #333; +} + +.node.active { + opacity: 1; +} + +.node.active.selected text { + display: block; +} + +.node.active:hover text { + display: block; +} + +#filters { + padding: 0.5em 1em; + background-color: transparent; + border-bottom: thin dashed #68b9fe; + color: white; +} + +#filters form { + width: 100%; +} + +#filters #filter-header { + padding: 10px; +} + +#filters #filter-relationships, +#filters #filter-nodes { + background-color: transparent; + display: inline-block; + width: 45%; + margin-left: 2%; + overflow: auto; + text-align: center; + vertical-align: top; +} + +#filters #filter-relationships #filter-node-header, +#filters #filter-relationships #filter-rel-header, +#filters #filter-nodes #filter-node-header, +#filters #filter-nodes #filter-rel-header { + margin: 10px 0; + cursor: pointer; + background-color: transparent; + border: none; + border-radius: 0; + width: 100%; +} + +#filters #filter-relationships #filter-node-header h4, +#filters #filter-relationships #filter-rel-header h4, +#filters #filter-nodes #filter-node-header h4, +#filters #filter-nodes #filter-rel-header h4 { + font-weight: 200; + display: inline; + color: white; +} + +#filters #filter-relationships #filter-node-header:active, +#filters #filter-relationships #filter-rel-header:active, +#filters #filter-nodes #filter-node-header:active, +#filters #filter-nodes #filter-rel-header:active { + border: none; + box-shadow: none; +} + +#filters #filter-relationships #rel-dropdown, +#filters #filter-relationships #node-dropdown, +#filters #filter-nodes #rel-dropdown, +#filters #filter-nodes #node-dropdown { + margin: 20px 0; + border-radius: none; + border: none; + background: transparent; +} + +#filters #filter-relationships #rel-dropdown li, +#filters #filter-relationships #node-dropdown li, +#filters #filter-nodes #rel-dropdown li, +#filters #filter-nodes #node-dropdown li { + padding: 5px; +} + +#filters #filter-relationships #rel-dropdown li:hover, +#filters #filter-relationships #node-dropdown li:hover, +#filters #filter-nodes #rel-dropdown li:hover, +#filters #filter-nodes #node-dropdown li:hover { + background-color: rgba(255,255,255,0.2); +} + +#filters .disabled { + color: rgba(255,255,255,0.5); +} + +#filters .disabled:hover { + color: #68b9fe; +} + +.alchemy { + position: relative; +} + +.alchemy #search form { + z-index: 2; + display: inline; + margin-left: 100px; +} + +.alchemy #add-tag { + width: 300px; + display: inline-block; +} + +.alchemy #tags input { + max-width: 220px; +} + +.alchemy #tags-list { + padding: 0; +} + +.alchemy #tags-list .icon-remove-sign { + cursor: pointer; +} + +.alchemy #tags-list li { + display: inline-block; + margin-top: 5px; +} + +.alchemy #tags-list span { + background-color: #ccc; + color: #333; + border-radius: 10em; + display: inline-block; + padding: 1px 6px; +} + +.alchemy #filter-nodes label, +.alchemy #filter-relationships label { + font-weight: normal; + margin-right: 1em; +} + +.alchemy .clear { + clear: both; +} + +.alchemy text { + font-weight: 200; + text-anchor: middle; +} \ No newline at end of file diff --git a/EHEC_Server/EHEC_Server/alchemy/alchemy.css b/EHEC_Server/EHEC_Server/alchemy/alchemy.css new file mode 100644 index 0000000..6571ef0 --- /dev/null +++ b/EHEC_Server/EHEC_Server/alchemy/alchemy.css @@ -0,0 +1,714 @@ +@-webkit-keyframes fadeIn { + 0% { + opacity: 0; + } + + 25% { + opacity: .3; + } + + 50% { + opacity: .66; + } + + 75% { + opacity: 1; + } +} + +@keyframes fadeIn { + 0% { + opacity: 0; + } + + 25% { + opacity: .3; + } + + 50% { + opacity: .66; + } + + 75% { + opacity: 1; + } +} + +@-webkit-keyframes pulse { + 0% { + text-shadow: 0 0 10px rgba(255,255,255,0.2),0 0 12px rgba(255,255,255,0.2),0 0 16px rgba(255,255,255,0.2); + } + + 25% { + text-shadow: 0 0 12px rgba(255,255,255,0.2),0 0 15px rgba(255,255,255,0.2),0 0 20px rgba(255,255,255,0.2),0 0 6px rgba(104,185,254,0.7),0 0 10px rgba(104,185,254,0.7); + } + + 50% { + text-shadow: 0 0 12px rgba(255,255,255,0.2),0 0 15px rgba(255,255,255,0.2),0 0 20px rgba(255,255,255,0.2),0 0 8px rgba(104,185,254,0.7),0 0 10px rgba(104,185,254,0.7),0 0 15px rgba(104,185,254,0.7); + } + + 75% { + text-shadow: 0 0 12px rgba(255,255,255,0.2),0 0 15px rgba(255,255,255,0.2),0 0 25px rgba(255,255,255,0.2),0 0 8px rgba(104,185,254,0.7),0 0 12px rgba(104,185,254,0.7),0 0 15px rgba(104,185,254,0.7),0 0 20px rgba(104,185,254,0.7); + } +} + +@keyframes pulse { + 0% { + text-shadow: 0 0 10px rgba(255,255,255,0.2),0 0 12px rgba(255,255,255,0.2),0 0 16px rgba(255,255,255,0.2); + } + + 25% { + text-shadow: 0 0 12px rgba(255,255,255,0.2),0 0 15px rgba(255,255,255,0.2),0 0 20px rgba(255,255,255,0.2),0 0 6px rgba(104,185,254,0.7),0 0 10px rgba(104,185,254,0.7); + } + + 50% { + text-shadow: 0 0 12px rgba(255,255,255,0.2),0 0 15px rgba(255,255,255,0.2),0 0 20px rgba(255,255,255,0.2),0 0 8px rgba(104,185,254,0.7),0 0 10px rgba(104,185,254,0.7),0 0 15px rgba(104,185,254,0.7); + } + + 75% { + text-shadow: 0 0 12px rgba(255,255,255,0.2),0 0 15px rgba(255,255,255,0.2),0 0 25px rgba(255,255,255,0.2),0 0 8px rgba(104,185,254,0.7),0 0 12px rgba(104,185,254,0.7),0 0 15px rgba(104,185,254,0.7),0 0 20px rgba(104,185,254,0.7); + } +} + +@-webkit-keyframes slide-in { + 0% { + -webkit-transform: translate(-100%, 0); + transform: translate(-100%, 0); + } + + 100% { + -webkit-transform: translate(0%, 0); + transform: translate(0%, 0); + } +} + +@keyframes slide-in { + 0% { + -webkit-transform: translate(-100%, 0); + transform: translate(-100%, 0); + } + + 100% { + -webkit-transform: translate(0%, 0); + transform: translate(0%, 0); + } +} + +@-webkit-keyframes slide-out { + 0% { + -webkit-transform: translate(0%, 0); + transform: translate(0%, 0); + } + + 100% { + -webkit-transform: translate(-100%, 0); + transform: translate(-100%, 0); + } +} + +@keyframes slide-out { + 100% { + -webkit-transform: translate(-100%, 0); + transform: translate(-100%, 0); + } +} + +svg { + position: absolute; + left: 0; + cursor: -webkit-grab; + height: 100%; + width: 100%; + color: #333; +} + +.node { + cursor: pointer; +} + +.node text.root { + font-size: 32px; +} + +.node text { + display: none; + fill: white; + font-weight: 200; + text-anchor: middle; + z-index: 1000; + text-shadow: 1px 1px #333, -1px 1px #333, 1px -1px #333, -1px -1px #333; +} + +.node.active { + opacity: 1; +} + +.node.active.selected text { + display: block; +} + +.node.active:hover text { + display: block; +} + +defs #arrow path { + stroke: #CCC; + stroke-opacity: 0.2; + fill: #CCC; + opacity: 1; +} + +.edge text { + stroke-width: 0; +} + +.edge .edge-handler { + fill: none; + stroke: none; +} + +.edge .edge-line { + fill: none; +} + +.edge.active text { + display: none; + fill: white; + font-weight: 200; + text-anchor: middle; + text-shadow: 1px 1px #333, -1px 1px #333, 1px -1px #333, -1px -1px #333; + z-index: 1000; +} + +.edge.active:hover, +.edge.active.selected { + cursor: pointer; +} + +.edge.active:hover text, +.edge.active.selected text { + display: block; +} + +.edge.active.highlight text { + display: block; +} + +#zoom-controls { + background-color: transparent; + background-image: url("images/maze-black.png"); + border-top-right-radius: 3px; + border-bottom-right-radius: 3px; + box-shadow: 0 0 5px rgba(255,255,255,0.3); + margin-top: 10%; + z-index: 5; + position: relative; + display: block; + width: 55px; +} + +#zoom-controls #zoom-in, +#zoom-controls #zoom-out, +#zoom-controls #zoom-reset { + padding: 12px; + margin: 0; + width: 100%; +} + +#zoom-controls #zoom-in i, +#zoom-controls #zoom-out i, +#zoom-controls #zoom-reset i { + color: #E89619; +} + +#zoom-controls #zoom-in:hover, +#zoom-controls #zoom-out:hover, +#zoom-controls #zoom-reset:hover { + background-color: rgba(255,255,255,0.2); +} + +#zoom-controls #zoom-in:active, +#zoom-controls #zoom-out:active, +#zoom-controls #zoom-reset:active { + border: none; +} + +.fa-caret-right, +.fa-caret-down, +.fa-search { + margin: 0 5px; + color: #e89619; +} + +#search { + margin-top: 2em; + margin-bottom: 1em; + padding: .5em 1em; + width: 100%; +} + +#search span { + vertical-align: bottom; +} + +#search input { + background-color: black; + border: none; + font-size: 20px; + color: white; + padding-left: 0.5em; +} + +#search .search-icon { + height: 22px; + background-color: #000; + border-color: #000; + border-right-color: #111; +} + +#stats { + padding: 0.5em 1em; + background-color: transparent; + border-bottom: thin dashed #e89619; +} + +#stats #stats-header { + padding: 10px; +} + +#stats #all-stats { + color: white; + border-radius: none; + border: none; + background: transparent; + overflow: auto; +} + +#stats #all-stats li { + padding: 3px; +} + +#stats #node-stats-graph, +#stats #edge-stats-graph { + height: 250px; +} + +#stats #node-stats-graph svg, +#stats #edge-stats-graph svg { + opacity: .6; + background: transparent; +} + +#stats #node-stats-graph text, +#stats #edge-stats-graph text { + font-size: 16px; + fill: white; + font-weight: 200; + text-anchor: middle; + z-index: 1000; +} + +#stats #node-stats-graph .no-data, +#stats #edge-stats-graph .no-data { + margin: 30px 0; + color: #e89619; +} + +#stats .badge { + border-radius: 0; + height: 100%; + background-color: rgba(104,185,254,0.6); +} + +#editor { + padding: 0.5em 1em; + background-color: transparent; + border-bottom: thin dashed #e89619; +} + +#editor h3 { + padding: 10px; +} + +#editor #element-options { + display: -webkit-flex; + display: flex; + -webkit-flex-direction: column; + flex-direction: column; + cursor: pointer; + margin-top: 10px; + margin-left: 2%; + color: white; +} + +#editor #element-options .property, +#editor #element-options #add-property-form { + display: -webkit-inline-flex; + display: inline-flex; + margin: 4px 0; + width: 100%; +} + +#editor #element-options .property-value, +#editor #element-options #add-property-form #add-property #add-prop-value { + border: thin rgba(255,255,255,0.2) solid; + border-left: none; + background-color: black; + color: white; + width: 100%; + border-top-left-radius: 0; + border-bottom-left-radius: 0; +} + +#editor #element-options .property-name, +#editor #element-options #add-property-form #add-property #add-prop-key { + text-align: center; + font-weight: 200; + cursor: default; + background: #2E2E2E; + border: thin transparent solid; + color: #e89619; + border-right: none; + border-top-right-radius: 0; + border-bottom-right-radius: 0; +} + +#editor #element-options input[type="submit"], +#editor #element-options #update-properties { + color: #e89619; + border-top-right-radius: 4px; + border-bottom-right-radius: 4px; + width: auto; + background: rgba(255,255,255,0.1); + border: thin solid #e89619; + text-align: center; +} + +#editor #element-options input[type="submit"]:active, +#editor #element-options #update-properties:active, +#editor #element-options input[type="submit"]:focus, +#editor #element-options #update-properties:focus { + outline: none; +} + +#editor #element-options input[type="submit"]:hover, +#editor #element-options #update-properties:hover { + color: white; + border: thin solid white; +} + +#editor #element-options #update-properties { + border-radius: 4px; + padding: 10px; + width: 100%; + margin-bottom: 20px; +} + +#editor #element-options #add-property-form #add-property { + display: -webkit-flex; + display: flex; + -webkit-flex-grow: 2; + flex-grow: 2; + -webkit-flex-direction: column; + flex-direction: column; +} + +#editor #element-options #add-property-form #add-property #add-prop-value { + text-align: center; + width: 100%; + border-top-right-radius: 0; + border-bottom-right-radius: 0; + border-bottom-left-radius: 4px; + border: thin rgba(255,255,255,0.2) solid; +} + +#editor #element-options #add-property-form #add-property #add-prop-key { + cursor: text; + width: 100%; + border-top-left-radius: 4px; + border-bottom-left-radius: 0; +} + +#editor #editor-interactions.active { + color: #e89619; +} + +#editor #editor-interactions.inactive { + color: white; +} + +#editor #node-editor.enabled, +#editor #edge-editor.enabled { + -webkit-animation: fadeIn 1s linear; + animation: fadeIn 1s linear; +} + +#control-dash-wrapper { + font-family: 'Source Sans Pro', Helvetica, sans-serif; + letter-spacing: .05em; + height: inherit; + z-index: inherit; + padding: 0; +} + +#control-dash-wrapper.initial { + -webkit-transform: translate(-100%, 0); + transform: translate(-100%, 0); +} + +#control-dash-wrapper.initial #dash-toggle { + color: #e89619; + -webkit-animation: 4s pulse linear; + animation: 4s pulse linear; +} + +#control-dash-wrapper.off-canvas { + -webkit-transform: translate(-100%, 0); + transform: translate(-100%, 0); + -webkit-animation: slide-out .75s linear; + animation: slide-out .75s linear; +} + +#control-dash-wrapper.off-canvas #dash-toggle { + color: #e89619; + -webkit-animation: 4s pulse linear; + animation: 4s pulse linear; +} + +#control-dash-wrapper.on-canvas { + -webkit-animation: slide-in .75s ease-in-out; + animation: slide-in .75s ease-in-out; +} + +#control-dash-wrapper.on-canvas * { + box-shadow: none !important; +} + +#control-dash-wrapper.on-canvas #dash-toggle { + color: rgba(232,150,25,0.6); +} + +#control-dash-wrapper.on-canvas #dash-toggle:hover { + color: #e89619; + -webkit-animation: 4s pulse linear; + animation: 4s pulse linear; +} + +#control-dash-wrapper #control-dash { + overflow-x: hidden; + overflow-y: scroll; + background-color: transparent; + background-image: url("images/maze-black.png"); + padding: 0; + height: inherit; + z-index: 5; +} + +#control-dash-wrapper #control-dash h3 { + display: inline; + margin: 0; +} + +#control-dash-wrapper #dash-toggle { + z-index: 5; + background-color: transparent; + background-image: url("images/maze-black.png"); + border-top-right-radius: 3px; + border-bottom-right-radius: 3px; + box-shadow: 0 0 5px rgba(255,255,255,0.3); + position: absolute; + left: 0; + top: 50%; + font-size: 2.2em; + color: rgba(255,255,255,0.2); + padding: 10px; +} + +#control-dash-wrapper button { + border-radius: 0; + border: none; + background-color: transparent; +} + +#control-dash-wrapper button:active { + border: none; +} + +#control-dash-wrapper h3 { + font-weight: 200; + margin-top: 10px; + color: white; + cursor: pointer; + vertical-align: top; +} + +#control-dash-wrapper li { + cursor: pointer; + background: transparent; + border: none; + border-radius: 0; +} + +#clustering { + padding: 0.5em 1em; + cursor: pointer; + color: white; + border-bottom: thin dashed #E89619; +} + +#clustering #cluster_control_header, +#clustering #cluster-key-container { + padding: 10px 10px 0 10px; +} + +#clustering #cluster-key { + color: #333; + background-color: #000; + border-radius: 4px; + border: thin solid #333; + text-align: center; + display: inline-block; + width: 100%; +} + +#filters { + padding: 0.5em 1em; + background-color: transparent; + border-bottom: thin dashed #e89619; + color: white; +} + +#filters form { + width: 100%; +} + +#filters #filter-header { + padding: 10px; +} + +#filters #filter-relationships, +#filters #filter-nodes { + background-color: transparent; + display: inline-block; + width: 45%; + margin-left: 2%; + overflow: auto; + text-align: center; + vertical-align: top; +} + +#filters #filter-relationships #filter-node-header, +#filters #filter-relationships #filter-rel-header, +#filters #filter-nodes #filter-node-header, +#filters #filter-nodes #filter-rel-header { + margin: 10px 0; + cursor: pointer; + background-color: transparent; + border: none; + border-radius: 0; + width: 100%; +} + +#filters #filter-relationships #filter-node-header h4, +#filters #filter-relationships #filter-rel-header h4, +#filters #filter-nodes #filter-node-header h4, +#filters #filter-nodes #filter-rel-header h4 { + font-weight: 200; + display: inline; + color: white; +} + +#filters #filter-relationships #filter-node-header:active, +#filters #filter-relationships #filter-rel-header:active, +#filters #filter-nodes #filter-node-header:active, +#filters #filter-nodes #filter-rel-header:active { + border: none; + box-shadow: none; +} + +#filters #filter-relationships #rel-dropdown, +#filters #filter-relationships #node-dropdown, +#filters #filter-nodes #rel-dropdown, +#filters #filter-nodes #node-dropdown { + margin: 20px 0; + border-radius: none; + border: none; + background: transparent; +} + +#filters #filter-relationships #rel-dropdown li, +#filters #filter-relationships #node-dropdown li, +#filters #filter-nodes #rel-dropdown li, +#filters #filter-nodes #node-dropdown li { + padding: 5px; +} + +#filters #filter-relationships #rel-dropdown li:hover, +#filters #filter-relationships #node-dropdown li:hover, +#filters #filter-nodes #rel-dropdown li:hover, +#filters #filter-nodes #node-dropdown li:hover { + background-color: rgba(255,255,255,0.2); +} + +#filters .disabled { + color: rgba(255,255,255,0.5); +} + +#filters .disabled:hover { + color: #fdc670; +} + +.alchemy { + position: relative; +} + +.alchemy #search form { + z-index: 2; + display: inline; + margin-left: 100px; +} + +.alchemy #add-tag { + width: 300px; + display: inline-block; +} + +.alchemy #tags input { + max-width: 220px; +} + +.alchemy #tags-list { + padding: 0; +} + +.alchemy #tags-list .icon-remove-sign { + cursor: pointer; +} + +.alchemy #tags-list li { + display: inline-block; + margin-top: 5px; +} + +.alchemy #tags-list span { + background-color: #ccc; + color: #333; + border-radius: 10em; + display: inline-block; + padding: 1px 6px; +} + +.alchemy #filter-nodes label, +.alchemy #filter-relationships label { + font-weight: normal; + margin-right: 1em; +} + +.alchemy .clear { + clear: both; +} + +.alchemy text { + font-weight: 200; + text-anchor: middle; +} \ No newline at end of file diff --git a/EHEC_Server/EHEC_Server/alchemy/alchemy.js b/EHEC_Server/EHEC_Server/alchemy/alchemy.js new file mode 100644 index 0000000..9f88452 --- /dev/null +++ b/EHEC_Server/EHEC_Server/alchemy/alchemy.js @@ -0,0 +1,3153 @@ +(function() { + "Alchemy.js is a graph drawing application for the web.\nCopyright (C) 2014 GraphAlchemist, Inc.\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU Affero General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU Affero General Public License for more details.\n\nYou should have received a copy of the GNU Affero General Public License\nalong with this program. If not, see .\nlets"; + var Alchemy, Clustering, DrawEdge, DrawEdges, DrawNode, DrawNodes, Editor, EditorInteractions, EditorUtils, Layout, root, warnings, + __slice = [].slice, + __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; + + Alchemy = (function() { + function Alchemy(userConf) { + if (userConf == null) { + userConf = null; + } + this.a = this; + this.version = "0.4.1"; + this.get = new this.Get(this); + this.remove = new this.Remove(this); + this.create = new this.Create(this); + this.set = new this.Set(this); + this.drawing = { + DrawEdge: DrawEdge(this), + DrawEdges: DrawEdges(this), + DrawNode: DrawNode(this), + DrawNodes: DrawNodes(this), + EdgeUtils: this.EdgeUtils(this), + NodeUtils: this.NodeUtils(this) + }; + this.controlDash = this.controlDash(this); + this.stats = this.stats(this); + this.layout = Layout; + this.clustering = Clustering; + this.models = { + Node: this.Node(this), + Edge: this.Edge(this) + }; + this.utils = { + warnings: new warnings(this) + }; + this.filters = this.filters(this); + this.exports = this.exports(this); + this.visControls = {}; + this.styles = {}; + this.editor = {}; + this.log = {}; + this.state = { + "interactions": "default", + "layout": "default" + }; + this.startGraph = this.startGraph(this); + this.updateGraph = this.updateGraph(this); + this.generateLayout = this.generateLayout(this); + this.svgStyles = this.svgStyles(this); + this.interactions = this.interactions(this); + this.search = this.search(this); + this.plugins = this.plugins(this); + this._nodes = {}; + this._edges = {}; + this.getNodes = this.get.getNodes; + this.getEdges = this.get.getEdges; + this.allNodes = this.get.allNodes; + this.allEdges = this.get.allEdges; + if (userConf) { + this.begin(userConf); + } + } + + Alchemy.prototype.begin = function(userConf) { + var conf; + conf = this.setConf(userConf); + switch (typeof this.conf.dataSource) { + case 'string': + d3.json(this.a.conf.dataSource, this.a.startGraph); + break; + case 'object': + this.a.startGraph(this.a.conf.dataSource); + } + this.plugins.init(); + Alchemy.prototype.instances.push(this); + return this; + }; + + Alchemy.prototype.setConf = function(userConf) { + var key, val; + if (userConf.theme != null) { + userConf = _.merge(_.cloneDeep(this.defaults), this.a.themes["" + userConf.theme]); + } + for (key in userConf) { + val = userConf[key]; + switch (key) { + case "clusterColors": + userConf["clusterColours"] = val; + break; + case "backgroundColor": + userConf["backgroundColour"] = val; + break; + case "nodeColor": + userConf[nodeColour] = val; + } + } + return this.a.conf = _.merge(_.cloneDeep(this.defaults), userConf); + }; + + Alchemy.prototype.instances = []; + + Alchemy.prototype.getInst = function(svg) { + var instNumber; + instNumber = parseInt(d3.select(svg).attr("alchInst")); + return Alchemy.prototype.instances[instNumber]; + }; + + return Alchemy; + + })(); + + root = typeof exports !== "undefined" && exports !== null ? exports : this; + + root.Alchemy = Alchemy; + + root.alchemy = { + begin: function(config) { + return root.alchemy = new Alchemy(config); + } + }; + + Alchemy.prototype.Create = (function() { + function Create(instance) { + this.a = instance; + } + + Create.prototype.nodes = function() { + var a, n, nodeMap, nodeMaps, registerNode, _i, _len; + nodeMap = arguments[0], nodeMaps = 2 <= arguments.length ? __slice.call(arguments, 1) : []; + a = this.a; + registerNode = function(node) { + var aNode; + if (!a._nodes[node.id]) { + aNode = new a.models.Node(node); + a._nodes[node.id] = aNode; + return [aNode]; + } else { + return console.warn("A node with the id " + node.id + " already exists.\nConsider using the @a.get.nodes() method to \nretrieve the node and then using the Node methods."); + } + }; + nodeMaps = _.union(nodeMaps, nodeMap); + for (_i = 0, _len = nodeMaps.length; _i < _len; _i++) { + n = nodeMaps[_i]; + registerNode(n); + } + if (this.a.initial) { + return this.a.updateGraph(); + } + }; + + Create.prototype.edges = function() { + var a, allEdges, edgeMap, edgeMaps, registerEdge; + edgeMap = arguments[0], edgeMaps = 2 <= arguments.length ? __slice.call(arguments, 1) : []; + a = this.a; + registerEdge = function(edge) { + var aEdge, edgeArray; + if (edge.id && !a._edges[edge.id]) { + aEdge = new a.models.Edge(edge); + a._edges[edge.id] = [aEdge]; + return [aEdge]; + } else if (edge.id && a._edges[edge.id]) { + return console.warn("An edge with that id " + someEdgeMap.id + " already exists.\nConsider using the @a.get.edge() method to \nretrieve the edge and then using the Edge methods.\nNote: id's are not required for edges. Alchemy will create\nan unlimited number of edges for the same source and target node.\nSimply omit 'id' when creating the edge."); + } else { + edgeArray = a._edges["" + edge.source + "-" + edge.target]; + if (edgeArray) { + aEdge = new a.models.Edge(edge, edgeArray.length); + edgeArray.push(aEdge); + return [aEdge]; + } else { + aEdge = new a.models.Edge(edge, 0); + a._edges["" + edge.source + "-" + edge.target] = [aEdge]; + return [aEdge]; + } + } + }; + allEdges = _.uniq(_.flatten(arguments)); + _.each(allEdges, function(e) { + return registerEdge(e); + }); + if (this.a.initial) { + return this.a.updateGraph(); + } + }; + + return Create; + + })(); + + Alchemy.prototype.Get = function(instance) { + return { + a: instance, + _el: [], + _elType: null, + _makeChain: function(inp) { + var returnedGet; + returnedGet = this; + returnedGet.__proto__ = [].__proto__; + while (returnedGet.length) { + returnedGet.pop(); + } + _.each(inp, function(e) { + return returnedGet.push(e); + }); + return returnedGet; + }, + nodes: function() { + var a, allIDs, id, ids, nodeList; + id = arguments[0], ids = 2 <= arguments.length ? __slice.call(arguments, 1) : []; + if (id != null) { + allIDs = _.map(arguments, function(arg) { + return String(arg); + }); + a = this.a; + nodeList = (function(a) { + return _.filter(a._nodes, function(val, key) { + if (_.contains(allIDs, key)) { + return val; + } + }); + })(a); + } + this._elType = "node"; + this._el = nodeList; + return this._makeChain(nodeList); + }, + edges: function() { + var a, allIDs, edgeList, id, ids; + id = arguments[0], ids = 2 <= arguments.length ? __slice.call(arguments, 1) : []; + if (id != null) { + allIDs = _.map(arguments, function(arg) { + return String(arg); + }); + a = this.a; + edgeList = (function(a) { + return _.flatten(_.filter(a._edges, function(val, key) { + if (_.contains(allIDs, key)) { + return val; + } + })); + })(a); + } + this._elType = "edge"; + this._el = edgeList; + return this._makeChain(edgeList); + }, + all: function() { + var a, elType; + a = this.a; + elType = this._elType; + this._el = (function(elType) { + switch (elType) { + case "node": + return a.elements.nodes.val; + case "edge": + return a.elements.edges.flat; + } + })(elType); + return this._makeChain(this._el); + }, + elState: function(state) { + var elList; + elList = _.filter(this._el, function(e) { + return e._state === state; + }); + this._el = elList; + return this._makeChain(elList); + }, + state: function(key) { + if (this.a.state.key != null) { + return this.a.state.key; + } + }, + type: function(type) { + var elList; + elList = _.filter(this._el, function(e) { + return e._nodeType === type || e._edgeType === type; + }); + this._el = elList; + return this._makeChain(elList); + }, + activeNodes: function() { + return _.filter(this.a._nodes, function(node) { + if (node._state === "active") { + return node; + } + }); + }, + activeEdges: function() { + return _.filter(this.a.get.allEdges(), function(edge) { + if (edge._state === "active") { + return edge; + } + }); + }, + state: function(key) { + if (this.a.state.key != null) { + return this.a.state.key; + } + }, + clusters: function() { + var clusterMap, nodesByCluster; + clusterMap = this.a.layout._clustering.clusterMap; + nodesByCluster = {}; + _.each(clusterMap, function(key, value) { + return nodesByCluster[value] = _.select(this.a.get.allNodes(), function(node) { + return node.getProperties()[this.a.conf.clusterKey] === value; + }); + }); + return nodesByCluster; + }, + clusterColours: function() { + var clusterColoursObject, clusterMap; + clusterMap = this.a.layout._clustering.clusterMap; + clusterColoursObject = {}; + _.each(clusterMap, function(key, value) { + return clusterColoursObject[value] = this.a.conf.clusterColours[key % this.a.conf.clusterColours.length]; + }); + return clusterColoursObject; + }, + allEdges: function() { + return this.a.elements.nodes.flat; + }, + allNodes: function(type) { + if (type != null) { + return _.filter(this.a._nodes, function(n) { + if (n._nodeType === type) { + return n; + } + }); + } else { + return this.a.elements.nodes.val; + } + }, + getNodes: function() { + var a, id, ids; + id = arguments[0], ids = 2 <= arguments.length ? __slice.call(arguments, 1) : []; + a = this.a; + ids.push(id); + return _.map(ids, function(id) { + return a._nodes[id]; + }); + }, + getEdges: function(id, target) { + var a, edge_id; + if (id == null) { + id = null; + } + if (target == null) { + target = null; + } + a = this.a; + if ((id != null) && (target != null)) { + edge_id = "" + id + "-" + target; + return this.a._edges[edge_id]; + } else if ((id != null) && (target == null)) { + return this.a._nodes[id]._adjacentEdges; + } + } + }; + }; + + Alchemy.prototype.Remove = (function() { + function Remove(instance) { + this.a = instance; + } + + Remove.prototype.nodes = function(nodeMap) { + return _.each(nodeMap, function(n) { + if (n._nodeType != null) { + return n.remove(); + } + }); + }; + + Remove.prototype.edges = function(edgeMap) { + return _.each(edgeMap, function(e) { + if (e._edgeType != null) { + return e.remove(); + } + }); + }; + + return Remove; + + })(); + + Alchemy.prototype.Set = function(instance) { + return { + a: instance, + state: function(key, value) { + return this.a.state.key = value; + } + }; + }; + + Clustering = (function() { + function Clustering(instance) { + var clustering, conf, nodes, _charge, _friction, _gravity, _linkDistancefn, _linkStrength; + this.a = instance; + nodes = this.a._nodes; + conf = this.a.conf; + clustering = this; + this.clusterKey = conf.clusterKey; + this.identifyClusters(this.a); + _charge = -500; + _linkStrength = function(edge) { + var sourceCluster, targetCluster; + sourceCluster = nodes[edge.source.id]._properties[this.clusterKey]; + targetCluster = nodes[edge.target.id]._properties[this.clusterKey]; + if (sourceCluster === targetCluster) { + return 0.15; + } else { + return 0; + } + }; + _friction = function() { + return 0.7; + }; + _linkDistancefn = function(edge) { + nodes = edge.self.a._nodes; + if (nodes[edge.source.id]._properties.root || nodes[edge.target.id]._properties.root) { + return 300; + } else if (nodes[edge.source.id]._properties[this.clusterKey] === nodes[edge.target.id]._properties[this.clusterKey]) { + return 10; + } else { + return 600; + } + }; + _gravity = function(k) { + return 8 * k; + }; + this.layout = { + charge: _charge, + linkStrength: function(edge) { + return _linkStrength(edge); + }, + friction: function() { + return _friction(); + }, + linkDistancefn: function(edge) { + return _linkDistancefn(edge); + }, + gravity: function(k) { + return _gravity(k); + } + }; + } + + Clustering.prototype.identifyClusters = function(a) { + var clusters, nodes, _i, _ref, _results; + nodes = a.elements.nodes.val; + clusters = _.uniq(_.map(nodes, function(node) { + return node.getProperties()[a.conf.clusterKey]; + })); + return this.clusterMap = _.zipObject(clusters, (function() { + _results = []; + for (var _i = 0, _ref = clusters.length; 0 <= _ref ? _i <= _ref : _i >= _ref; 0 <= _ref ? _i++ : _i--){ _results.push(_i); } + return _results; + }).apply(this)); + }; + + Clustering.prototype.getClusterColour = function(clusterValue) { + var index; + index = this.clusterMap[clusterValue] % this.a.conf.clusterColours.length; + return this.a.conf.clusterColours[index]; + }; + + Clustering.prototype.edgeGradient = function(edges) { + var Q, defs, edge, endColour, gradient, gradient_id, id, ids, nodes, startColour, _i, _len, _ref, _results; + defs = this.a.vis.select("" + this.a.conf.divSelector + " svg"); + Q = {}; + nodes = this.a._nodes; + _ref = _.map(edges, function(edge) { + return edge._d3; + }); + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + edge = _ref[_i]; + if (nodes[edge.source.id]._properties.root || nodes[edge.target.id]._properties.root) { + continue; + } + if (nodes[edge.source.id]._properties[this.clusterKey] === nodes[edge.target.id]._properties[this.clusterKey]) { + continue; + } + if (nodes[edge.target.id]._properties[this.clusterKey] !== nodes[edge.source.id]._properties[this.clusterKey]) { + id = nodes[edge.source.id]._properties[this.clusterKey] + "-" + nodes[edge.target.id]._properties[this.clusterKey]; + if (id in Q) { + continue; + } else if (!(id in Q)) { + startColour = this.getClusterColour(nodes[edge.target.id]._properties[this.clusterKey]); + endColour = this.getClusterColour(nodes[edge.source.id]._properties[this.clusterKey]); + Q[id] = { + 'startColour': startColour, + 'endColour': endColour + }; + } + } + } + _results = []; + for (ids in Q) { + gradient_id = "cluster-gradient-" + ids; + gradient = defs.append("svg:linearGradient").attr("id", gradient_id); + gradient.append("svg:stop").attr("offset", "0%").attr("stop-color", Q[ids]['startColour']); + _results.push(gradient.append("svg:stop").attr("offset", "100%").attr("stop-color", Q[ids]['endColour'])); + } + return _results; + }; + + return Clustering; + + })(); + + Alchemy.prototype.clusterControls = { + init: function() { + var changeClusterHTML; + changeClusterHTML = ""; + this.a.dash.select("#clustering-container").append("div").attr("id", "cluster-key-container").attr('class', 'property form-inline form-group').html(changeClusterHTML).style("display", "none"); + this.a.dash.select("#cluster_control_header").on("click", function() { + var display, element; + element = this.a.dash.select("#cluster-key-container"); + return display = element.style("display"); + }); + element.style("display", function(e) { + if (display === "block") { + return "none"; + } else { + return "block"; + } + }); + if (this.a.dash.select("#cluster-key-container").style("display") === "none") { + this.a.dash.select("#cluster-arrow").attr("class", "fa fa-2x fa-caret-right"); + } else { + this.a.dash.select("#cluster-arrow").attr("class", "fa fa-2x fa-caret-down"); + } + return this.a.dash.select("#cluster-key").on("keydown", function() { + if (d3.event.keyIdentifier === "Enter") { + this.a.conf.cluster = true; + this.a.conf.clusterKey = this.value; + return this.a.generateLayout(); + } + }); + } + }; + + Alchemy.prototype.controlDash = function(instance) { + var a; + a = instance; + return { + init: function() { + var divSelector; + if (this.dashIsShown()) { + divSelector = a.conf.divSelector; + a.dash = d3.select("" + divSelector).append("div").attr("id", "control-dash-wrapper").attr("class", "col-md-4 initial"); + a.dash.append("i").attr("id", "dash-toggle").attr("class", "fa fa-flask col-md-offset-12"); + a.dash.append("div").attr("id", "control-dash").attr("class", "col-md-12"); + a.dash.select('#dash-toggle').on('click', a.interactions.toggleControlDash); + a.controlDash.zoomCtrl(); + a.controlDash.search(); + a.controlDash.filters(); + a.controlDash.stats(); + a.controlDash.clustering(); + return a.controlDash.exports(); + } + }, + search: function() { + if (a.conf.search) { + a.dash.select("#control-dash").append("div").attr("id", "search").html("
\n \n \n
"); + return a.search.init(); + } + }, + zoomCtrl: function() { + if (a.conf.zoomControls) { + a.dash.select("#control-dash-wrapper").append("div").attr("id", "zoom-controls").attr("class", "col-md-offset-12").html(" "); + a.dash.select('#zoom-in').on("click", function() { + return a.interactions.clickZoom('in'); + }); + a.dash.select('#zoom-out').on("click", function() { + return a.interactions.clickZoom('out'); + }); + return a.dash.select('#zoom-reset').on("click", function() { + return a.interactions.clickZoom('reset'); + }); + } + }, + filters: function() { + if (a.conf.nodeFilters || a.conf.edgeFilters) { + a.dash.select("#control-dash").append("div").attr("id", "filters"); + return a.filters.init(); + } + }, + stats: function() { + var stats_html; + if (a.conf.nodeStats || a.conf.edgeStats) { + stats_html = "
\n

\n Statistics\n

\n\n
\n
\n
    \n
      \n
      "; + a.dash.select("#control-dash").append("div").attr("id", "stats").html(stats_html).select('#stats-header').on('click', function() { + if (a.dash.select('#all-stats').classed("in")) { + return a.dash.select("#stats-header>span").attr("class", "fa fa-2x fa-caret-right"); + } else { + return a.dash.select("#stats-header>span").attr("class", "fa fa-2x fa-caret-down"); + } + }); + return a.stats.init(); + } + }, + exports: function() { + var exports_html; + if (a.conf.exportSVG) { + exports_html = "
      \n

      \n Exports\n

      \n \n
      \n
      "; + a.dash.select("#control-dash").append("div").attr("id", "exports").attr("style", "padding: 0.5em 1em; border-bottom: thin dashed #E89619; color: white;").html(exports_html).select("#exports-header"); + return a.exports.init(); + } + }, + clustering: function() { + var clusterControl_html; + if (a.conf.clusterControl) { + clusterControl_html = "
      \n
      \n

      Clustering

      \n \n
      \n
      "; + a.dash.select("#control-dash").append("div").attr("id", "clustering").html(clusterControl_html).select('#cluster_control_header'); + return a.clusterControls.init(); + } + }, + dashIsShown: function() { + var conf; + conf = a.conf; + return conf.showEditor || conf.captionToggle || conf.toggleRootNodes || conf.removeElement || conf.clusterControl || conf.nodeStats || conf.edgeStats || conf.edgeFilters || conf.nodeFilters || conf.edgesToggle || conf.nodesToggle || conf.search || conf.exportSVG; + } + }; + }; + + Alchemy.prototype.filters = (function(_this) { + return function(instance) { + var a; + a = instance; + return { + init: function() { + var caption, edgeType, edgeTypes, nodeKey, nodeType, nodeTypes, types, _i, _j, _len, _len1, _ref; + a.filters.show(); + if (a.conf.edgeFilters) { + a.filters.showEdgeFilters(); + } + if (a.conf.nodeFilters) { + a.filters.showNodeFilters(); + } + if (a.conf.nodeTypes) { + nodeKey = Object.keys(a.conf.nodeTypes); + nodeTypes = ''; + _ref = a.conf.nodeTypes[nodeKey]; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + nodeType = _ref[_i]; + caption = nodeType.replace('_', ' '); + nodeTypes += ""; + } + a.dash.select('#node-dropdown').html(nodeTypes); + } + if (a.conf.edgeTypes) { + if (_.isPlainObject(a.conf.edgeTypes)) { + types = _.values(a.conf.edgeTypes)[0]; + } else { + types = a.conf.edgeTypes; + } + edgeTypes = ''; + for (_j = 0, _len1 = types.length; _j < _len1; _j++) { + edgeType = types[_j]; + caption = edgeType.replace('_', ' '); + edgeTypes += ""; + } + a.dash.select('#rel-dropdown').html(edgeTypes); + } + if (a.conf.captionsToggle) { + a.filters.captionsToggle(); + } + if (a.conf.edgesToggle) { + a.filters.edgesToggle(); + } + if (a.conf.nodesToggle) { + a.filters.nodesToggle(); + } + return a.filters.update(); + }, + show: function() { + var filter_html; + filter_html = "
      \n

      Filters

      \n \n
      \n
      \n
      "; + a.dash.select('#control-dash #filters').html(filter_html); + a.dash.selectAll('#filter-header').on('click', function() { + if (a.dash.select('#filters>form').classed("in")) { + return a.dash.select("#filter-header>span").attr("class", "fa fa-2x fa-caret-right"); + } else { + return a.dash.select("#filter-header>span").attr("class", "fa fa-2x fa-caret-down"); + } + }); + return a.dash.select('#filters form'); + }, + showEdgeFilters: function() { + var rel_filter_html; + rel_filter_html = "
      \n

      \n Edge Types\n

      \n \n
      \n
        \n
      "; + a.dash.select('#filters form').append("div").attr("id", "filter-relationships").html(rel_filter_html); + return a.dash.select("#filter-rel-header").on('click', function() { + if (a.dash.select('#rel-dropdown').classed("in")) { + return a.dash.select("#filter-rel-header>span").attr("class", "fa fa-lg fa-caret-right"); + } else { + return a.dash.select("#filter-rel-header>span").attr("class", "fa fa-lg fa-caret-down"); + } + }); + }, + showNodeFilters: function() { + var node_filter_html; + node_filter_html = "
      \n

      \n Node Types\n

      \n \n
      \n
        \n
      "; + a.dash.select('#filters form').append("div").attr("id", "filter-nodes").html(node_filter_html); + return a.dash.select("#filter-node-header").on('click', function() { + if (a.dash.select('#node-dropdown').classed("in")) { + return a.dash.select("#filter-node-header>span").attr("class", "fa fa-lg fa-caret-right"); + } else { + return a.dash.select("#filter-node-header>span").attr("class", "fa fa-lg fa-caret-down"); + } + }); + }, + captionsToggle: function() { + return a.dash.select("#filters form").append("li").attr({ + "id": "toggle-captions", + "class": "list-group-item active-label toggle" + }).html("Show Captions").on("click", function() { + var isDisplayed; + isDisplayed = a.dash.select("g text").attr("style"); + if (isDisplayed === "display: block" || null) { + return a.dash.selectAll("g text").attr("style", "display: none"); + } else { + return a.dash.selectAll("g text").attr("style", "display: block"); + } + }); + }, + edgesToggle: function() { + return a.dash.select("#filters form").append("li").attr({ + "id": "toggle-edges", + "class": "list-group-item active-label toggle" + }).html("Toggle Edges").on("click", function() { + if (_.contains(_.pluck(_.flatten(_.values(a._edges)), "_state"), "active")) { + return _.each(_.values(a._edges), function(edges) { + return _.each(edges, function(e) { + if (e._state === "active") { + return e.toggleHidden(); + } + }); + }); + } else { + return _.each(_.values(a._edges), function(edges) { + return _.each(edges, function(e) { + var source, target; + source = a._nodes[e._properties.source]; + target = a._nodes[e._properties.target]; + if (source._state === "active" && target._state === "active") { + return e.toggleHidden(); + } + }); + }); + } + }); + }, + nodesToggle: function() { + return a.dash.select("#filters form").append("li").attr({ + "id": "toggle-nodes", + "class": "list-group-item active-label toggle" + }).html("Toggle Nodes").on("click", function() { + var nodes; + nodes = _.values(a._nodes); + if (_.contains(_.pluck(nodes, "_state"), "active")) { + return _.each(nodes, function(n) { + if (a.conf.toggleRootNodes && n._d3.root) { + return; + } + if (n._state === "active") { + return n.toggleHidden(); + } + }); + } else { + return _.each(_.values(a._nodes), function(n) { + if (a.conf.toggleRootNodes && n._d3.root) { + return; + } + return n.toggleHidden(); + }); + } + }); + }, + update: function() { + return a.dash.selectAll(".nodeType, .edgeType").on("click", function() { + var element, tag; + element = d3.select(this); + tag = element.attr("name"); + a.vis.selectAll("." + tag).each(function(d) { + var edge, node, source, target; + if (a._nodes[d.id] != null) { + node = a._nodes[d.id]; + return node.toggleHidden(); + } else { + edge = a._edges[d.id][0]; + source = a._nodes[edge._properties.source]; + target = a._nodes[edge._properties.target]; + if (source._state === "active" && target._state === "active") { + return edge.toggleHidden(); + } + } + }); + return a.stats.nodeStats(); + }); + } + }; + }; + })(this); + + Alchemy.prototype.Index = function(instance, all) { + var a, edges, elements, nodes; + a = instance; + elements = { + nodes: { + val: (function() { + return _.values(a._nodes); + })() + }, + edges: { + val: (function() { + return _.values(a._edges); + })() + } + }; + nodes = elements.nodes; + edges = elements.edges; + elements.edges.flat = (function() { + return _.flatten(edges.val); + })(); + elements.nodes.d3 = (function() { + return _.map(nodes.val, function(n) { + return n._d3; + }); + })(); + elements.edges.d3 = (function() { + return _.map(edges.flat, function(e) { + return e._d3; + }); + })(); + a.elements = elements; + return function() { + a.elements.nodes.svg = (function() { + return a.vis.selectAll('g.node'); + })(); + return a.elements.edges.svg = (function() { + return a.vis.selectAll('g.edge'); + })(); + }; + }; + + Alchemy.prototype.interactions = function(instance) { + var a; + a = instance; + return { + edgeClick: function(d) { + var edge; + if (d3.event.defaultPrevented) { + return; + } + d3.event.stopPropagation(); + edge = d.self; + if (typeof a.conf.edgeClick === 'function') { + a.conf.edgeClick(edge); + } + if (edge._state !== "hidden") { + edge._state = (function() { + if (edge._state === "selected") { + return "active"; + } + return "selected"; + })(); + return edge.setStyles(); + } + }, + edgeMouseOver: function(d) { + var edge; + edge = d.self; + if (edge._state !== "hidden") { + if (edge._state !== "selected") { + edge._state = "highlighted"; + } + return edge.setStyles(); + } + }, + edgeMouseOut: function(d) { + var edge; + edge = d.self; + if (edge._state !== "hidden") { + if (edge._state !== "selected") { + edge._state = "active"; + } + return edge.setStyles(); + } + }, + nodeMouseOver: function(n) { + var node; + node = n.self; + if (node._state !== "hidden") { + if (node._state !== "selected") { + node._state = "highlighted"; + node.setStyles(); + } + if (typeof a.conf.nodeMouseOver === 'function') { + return a.conf.nodeMouseOver(node); + } else if (typeof a.conf.nodeMouseOver === ('number' || 'string')) { + return node.properties[a.conf.nodeMouseOver]; + } + } + }, + nodeMouseOut: function(n) { + var node; + node = n.self; + a = node.a; + if (node._state !== "hidden") { + if (node._state !== "selected") { + node._state = "active"; + node.setStyles(); + } + if ((a.conf.nodeMouseOut != null) && typeof a.conf.nodeMouseOut === 'function') { + return a.conf.nodeMouseOut(n); + } + } + }, + nodeClick: function(n) { + var node; + if (d3.event.defaultPrevented) { + return; + } + d3.event.stopPropagation(); + node = n.self; + if (typeof a.conf.nodeClick === 'function') { + a.conf.nodeClick(node); + } + if (node._state !== "hidden") { + node._state = (function() { + if (node._state === "selected") { + return "active"; + } + return "selected"; + })(); + return node.setStyles(); + } + }, + zoom: function(extent) { + if (this._zoomBehavior == null) { + this._zoomBehavior = d3.behavior.zoom(); + } + return this._zoomBehavior.scaleExtent(extent).on("zoom", function(d) { + a = Alchemy.prototype.getInst(this); + return a.vis.attr("transform", "translate(" + d3.event.translate + ") scale(" + d3.event.scale + ")"); + }); + }, + clickZoom: function(direction) { + var scale, x, y, _ref; + _ref = a.vis.attr("transform").match(/(-*\d+\.*\d*)/g).map(function(a) { + return parseFloat(a); + }), x = _ref[0], y = _ref[1], scale = _ref[2]; + a.vis.attr("transform", function() { + if (direction === "in") { + if (scale < a.conf.scaleExtent[1]) { + scale += 0.2; + } + return "translate(" + x + "," + y + ") scale(" + scale + ")"; + } else if (direction === "out") { + if (scale > a.conf.scaleExtent[0]) { + scale -= 0.2; + } + return "translate(" + x + "," + y + ") scale(" + scale + ")"; + } else if (direction === "reset") { + return "translate(0,0) scale(1)"; + } else { + return console.log('error'); + } + }); + if (this._zoomBehavior == null) { + this._zoomBehavior = d3.behavior.zoom(); + } + return this._zoomBehavior.scale(scale).translate([x, y]); + }, + nodeDragStarted: function(d, i) { + d3.event.preventDefault; + d3.event.sourceEvent.stopPropagation(); + d3.select(this).classed("dragging", true); + return d.fixed = true; + }, + nodeDragged: function(d, i) { + var edges, node; + a = d.self.a; + d.x += d3.event.dx; + d.y += d3.event.dy; + d.px += d3.event.dx; + d.py += d3.event.dy; + node = d3.select(this); + node.attr("transform", "translate(" + d.x + ", " + d.y + ")"); + edges = d.self._adjacentEdges; + return _.each(edges, function(edge) { + var selection; + selection = a.vis.select("#edge-" + edge.id + "-" + edge._index); + return a._drawEdges.updateEdge(selection.data()[0]); + }); + }, + nodeDragended: function(d, i) { + a = d.self.a; + d3.select(this).classed({ + "dragging": false + }); + if (!a.conf.forceLocked) { + return a.force.start(); + } + }, + nodeDoubleClick: function(d) { + return null; + }, + deselectAll: function() { + var _ref; + a = Alchemy.prototype.getInst(this); + if ((_ref = d3.event) != null ? _ref.defaultPrevented : void 0) { + return; + } + if (a.conf.showEditor === true) { + a.modifyElements.nodeEditorClear(); + } + _.each(a._nodes, function(n) { + n._state = "active"; + return n.setStyles(); + }); + _.each(a._edges, function(edge) { + return _.each(edge, function(e) { + e._state = "active"; + return e.setStyles(); + }); + }); + if (a.conf.deselectAll && typeof (a.conf.deselectAll === 'function')) { + return a.conf.deselectAll(); + } + } + }; + }; + + Layout = (function() { + function Layout(instance) { + this.tick = __bind(this.tick, this); + this.linkStrength = __bind(this.linkStrength, this); + this.gravity = __bind(this.gravity, this); + var a, conf, nodes; + this.a = a = instance; + conf = this.a.conf; + nodes = this.a._nodes; + this.k = Math.sqrt(Math.log(_.size(this.a._nodes)) / (conf.graphWidth() * conf.graphHeight())); + this._clustering = new this.a.clustering(this.a); + this.d3NodeInternals = a.elements.nodes.d3; + if (conf.cluster) { + this._charge = function() { + return this._clustering.layout.charge; + }; + this._linkStrength = function(edge) { + return this._clustering.layout.linkStrength(edge); + }; + } else { + this._charge = function() { + return -10 / this.k; + }; + this._linkStrength = function(edge) { + if (nodes[edge.source.id].getProperties('root') || nodes[edge.target.id].getProperties('root')) { + return 1; + } else { + return 0.9; + } + }; + } + if (conf.cluster) { + this._linkDistancefn = function(edge) { + return this._clustering.layout.linkDistancefn(edge); + }; + } else if (conf.linkDistancefn === 'default') { + this._linkDistancefn = function(edge) { + return 1 / (this.k * 50); + }; + } else if (typeof conf.linkDistancefn === 'number') { + this._linkDistancefn = function(edge) { + return conf.linkDistancefn; + }; + } else if (typeof conf.linkDistancefn === 'function') { + this._linkDistancefn = function(edge) { + return conf.linkDistancefn(edge); + }; + } + } + + Layout.prototype.gravity = function() { + if (this.a.conf.cluster) { + return this._clustering.layout.gravity(this.k); + } else { + return 50 * this.k; + } + }; + + Layout.prototype.linkStrength = function(edge) { + return this._linkStrength(edge); + }; + + Layout.prototype.friction = function() { + return 0.9; + }; + + Layout.prototype.collide = function(node) { + var conf, nx1, nx2, ny1, ny2, r; + conf = this.a.conf; + r = 2 * (node.radius + node['stroke-width']) + conf.nodeOverlap; + nx1 = node.x - r; + nx2 = node.x + r; + ny1 = node.y - r; + ny2 = node.y + r; + return function(quad, x1, y1, x2, y2) { + var l, x, y; + if (quad.point && (quad.point !== node)) { + x = node.x - Math.abs(quad.point.x); + y = node.y - quad.point.y; + l = Math.sqrt(x * x + y * y); + r = r; + if (l < r) { + l = (l - r) / l * conf.alpha; + node.x -= x *= l; + node.y -= y *= l; + quad.point.x += x; + quad.point.y += y; + } + } + return x1 > nx2 || x2 < nx1 || y1 > ny2 || y2 < ny1; + }; + }; + + Layout.prototype.tick = function(draw) { + var a, edges, node, nodes, q, _i, _len, _ref; + a = this.a; + nodes = a.elements.nodes.svg; + edges = a.elements.edges.svg; + if (a.conf.collisionDetection) { + q = d3.geom.quadtree(this.d3NodeInternals); + _ref = this.d3NodeInternals; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + node = _ref[_i]; + q.visit(this.collide(node)); + } + } + nodes.attr("transform", function(d) { + return "translate(" + d.x + "," + d.y + ")"; + }); + this.drawEdge = a.drawing.DrawEdge; + this.drawEdge.styleText(edges); + return this.drawEdge.styleLink(edges); + }; + + Layout.prototype.positionRootNodes = function() { + var conf, container, i, n, rootNodes, _i, _len, _ref, _ref1, _results; + conf = this.a.conf; + container = { + width: conf.graphWidth(), + height: conf.graphHeight() + }; + rootNodes = _.filter(this.a.elements.nodes.val, function(node) { + return node.getProperties('root'); + }); + if (rootNodes.length === 1) { + n = rootNodes[0]; + _ref = [container.width / 2, container.width / 2], n._d3.x = _ref[0], n._d3.px = _ref[1]; + _ref1 = [container.height / 2, container.height / 2], n._d3.y = _ref1[0], n._d3.py = _ref1[1]; + n._d3.fixed = true; + } else { + _results = []; + for (i = _i = 0, _len = rootNodes.length; _i < _len; i = ++_i) { + n = rootNodes[i]; + n._d3.x = container.width / Math.sqrt(rootNodes.length * (i + 1)); + n._d3.y = container.height / 2; + _results.push(n._d3.fixed = true); + } + return _results; + } + }; + + Layout.prototype.chargeDistance = function() { + return 500; + }; + + Layout.prototype.linkDistancefn = function(edge) { + return this._linkDistancefn(edge); + }; + + Layout.prototype.charge = function() { + return this._charge(); + }; + + return Layout; + + })(); + + Alchemy.prototype.generateLayout = function(instance) { + var a; + a = instance; + return function(start) { + var conf; + if (start == null) { + start = false; + } + conf = a.conf; + a.layout = new Layout(a); + return a.force = d3.layout.force().size([conf.graphWidth(), conf.graphHeight()]).theta(1.0).gravity(a.layout.gravity()).friction(a.layout.friction()).nodes(a.elements.nodes.d3).links(a.elements.edges.d3).linkDistance(function(link) { + return a.layout.linkDistancefn(link); + }).linkStrength(function(link) { + return a.layout.linkStrength(link); + }).charge(a.layout.charge()).chargeDistance(a.layout.chargeDistance()); + }; + }; + + Alchemy.prototype.search = function(instance) { + var a; + a = instance; + return { + init: function() { + var searchBox; + searchBox = a.dash.select("#search input"); + return searchBox.on("keyup", function() { + var input; + input = searchBox[0][0].value.toLowerCase(); + a.vis.selectAll(".node").classed("inactive", false); + a.vis.selectAll("text").attr("style", function() { + if (input !== "") { + return "display: inline;"; + } + }); + return a.vis.selectAll(".node").classed("inactive", function(node) { + var DOMtext, hidden; + DOMtext = d3.select(this).text(); + switch (a.conf.searchMethod) { + case 'contains': + hidden = DOMtext.toLowerCase().indexOf(input) < 0; + break; + case 'begins': + hidden = DOMtext.toLowerCase().indexOf(input) !== 0; + } + if (hidden) { + a.vis.selectAll("[source-target*='" + node.id + "']").classed("inactive", hidden); + } else { + a.vis.selectAll("[source-target*='" + node.id + "']").classed("inactive", function(edge) { + var nodeIDs, sourceHidden, targetHidden; + nodeIDs = [edge.source.id, edge.target.id]; + sourceHidden = a.vis.select("#node-" + nodeIDs[0]).classed("inactive"); + targetHidden = a.vis.select("#node-" + nodeIDs[1]).classed("inactive"); + return targetHidden || sourceHidden; + }); + } + return hidden; + }); + }); + } + }; + }; + + Alchemy.prototype.startGraph = function(instance) { + var a; + a = instance; + return function(data) { + var conf, d3Edges, d3Nodes, defs, editor, editorInteractions; + conf = a.conf; + if (d3.select(conf.divSelector).empty()) { + console.warn(a.utils.warnings.divWarning()); + } + if (!data) { + data = { + nodes: [], + edges: [] + }; + a.utils.warnings.dataWarning(); + } + if (data.edges == null) { + data.edges = []; + } + a.create.nodes(data.nodes); + data.edges.forEach(function(e) { + return a.create.edges(e); + }); + a.vis = d3.select(conf.divSelector).attr("style", "width:" + (conf.graphWidth()) + "px; height:" + (conf.graphHeight()) + "px; background:" + conf.backgroundColour + ";").append("svg").attr("xmlns", "http://www.w3.org/2000/svg").attr("xlink", "http://www.w3.org/1999/xlink").attr("pointer-events", "all").attr("style", "background:" + conf.backgroundColour + ";").attr("alchInst", Alchemy.prototype.instances.length - 1).on('click', a.interactions.deselectAll).call(a.interactions.zoom(conf.scaleExtent)).on("dblclick.zoom", null).append('g').attr("transform", "translate(" + conf.initialTranslate + ") scale(" + conf.initialScale + ")"); + a.interactions.zoom().scale(conf.initialScale); + a.interactions.zoom().translate(conf.initialTranslate); + a.index = Alchemy.prototype.Index(a); + a.generateLayout(); + a.controlDash.init(); + d3Edges = a.elements.edges.d3; + d3Nodes = a.elements.nodes.d3; + a.layout.positionRootNodes(); + a.force.start(); + if (conf.forceLocked) { + while (a.force.alpha() > 0.005) { + a.force.tick(); + } + } + a._drawEdges = a.drawing.DrawEdges; + a._drawNodes = a.drawing.DrawNodes; + a._drawEdges.createEdge(d3Edges); + a._drawNodes.createNode(d3Nodes); + a.index(); + a.elements.nodes.svg.attr("transform", function(id, i) { + return "translate(" + id.x + ", " + id.y + ")"; + }); + console.log(Date() + ' completed initial computation'); + if (!conf.forceLocked) { + a.force.on("tick", a.layout.tick).start(); + } + if (conf.afterLoad != null) { + if (typeof conf.afterLoad === 'function') { + conf.afterLoad(); + } else if (typeof conf.afterLoad === 'string') { + a[conf.afterLoad] = true; + } + } + if (conf.cluster) { + defs = d3.select("" + a.conf.divSelector + " svg").append("svg:defs"); + } + if (conf.nodeStats) { + a.stats.nodeStats(); + } + if (conf.showEditor) { + editor = new a.editor.Editor; + editorInteractions = new a.editor.Interactions; + d3.select("body").on('keydown', editorInteractions.deleteSelected); + editor.startEditor(); + } + return a.initial = true; + }; + }; + + Alchemy.prototype.stats = function(instance) { + var a; + a = instance; + return { + init: function() { + return a.stats.update(); + }, + nodeStats: function() { + var activeNodes, allNodes, caption, inactiveNodes, nodeData, nodeGraph, nodeKeys, nodeNum, nodeStats, nodeType, nodeTypes, _i, _len, _ref; + nodeData = []; + allNodes = a.get.allNodes().length; + activeNodes = a.get.activeNodes().length; + inactiveNodes = allNodes - activeNodes; + nodeStats = "
    • Number of nodes: " + allNodes + "
    • Number of active nodes: " + activeNodes + "
    • Number of inactive nodes: " + inactiveNodes + "

    • "; + if (a.conf.nodeTypes) { + nodeKeys = Object.keys(a.conf.nodeTypes); + nodeTypes = ''; + _ref = a.conf.nodeTypes[nodeKeys]; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + nodeType = _ref[_i]; + caption = nodeType.replace('_', ' '); + nodeNum = a.vis.selectAll("g.node." + nodeType)[0].length; + nodeTypes += "
    • Number of " + caption + " nodes: " + nodeNum + "
    • "; + nodeData.push(["" + nodeType, nodeNum]); + } + nodeStats += nodeTypes; + } + nodeGraph = "
    • "; + nodeStats += nodeGraph; + a.dash.select('#node-stats').html(nodeStats); + return this.insertSVG("node", nodeData); + }, + edgeStats: function() { + var activeEdges, allEdges, caption, edgeData, edgeGraph, edgeKeys, edgeNum, edgeStats, edgeType, edgeTypes, inactiveEdges, _i, _len; + edgeData = []; + allEdges = a.get.allEdges().length; + activeEdges = a.get.activeEdges().length; + inactiveEdges = allEdges - activeEdges; + edgeStats = "
    • Number of relationships: " + allEdges + "
    • Number of active relationships: " + activeEdges + "
    • Number of inactive relationships: " + inactiveEdges + "

    • "; + if (a.conf.edgeTypes) { + edgeKeys = _.values(alchemy.conf.edgeTypes)[0]; + edgeTypes = ''; + for (_i = 0, _len = edgeKeys.length; _i < _len; _i++) { + edgeType = edgeKeys[_i]; + if (!edgeType) { + continue; + } + caption = edgeType.replace('_', ' '); + edgeNum = _.filter(a.get.allEdges(), function(edge) { + if (edge._edgeType === edgeType) { + return edge; + } + }).length; + edgeTypes += "
    • Number of " + caption + " relationships: " + edgeNum + "
    • "; + edgeData.push(["" + caption, edgeNum]); + } + edgeStats += edgeTypes; + } + edgeGraph = "
    • "; + edgeStats += edgeGraph; + a.dash.select('#rel-stats').html(edgeStats); + return this.insertSVG("edge", edgeData); + }, + insertSVG: function(element, data) { + var arc, arcs, color, height, pie, radius, svg, width; + if (data === null) { + return a.dash.select("#" + element + "-stats-graph").html("

      There are no " + element + "Types listed in your conf.

      "); + } else { + width = a.conf.graphWidth() * .25; + height = 250; + radius = width / 4; + color = d3.scale.category20(); + arc = d3.svg.arc().outerRadius(radius - 10).innerRadius(radius / 2); + pie = d3.layout.pie().sort(null).value(function(d) { + return d[1]; + }); + svg = a.dash.select("#" + element + "-stats-graph").append("svg").append("g").style({ + "width": width, + "height": height + }).attr("transform", "translate(" + width / 2 + "," + height / 2 + ")"); + arcs = svg.selectAll(".arc").data(pie(data)).enter().append("g").classed("arc", true).on("mouseover", function(d, i) { + return a.dash.select("#" + data[i][0] + "-stat").classed("hidden", false); + }).on("mouseout", function(d, i) { + return a.dash.select("#" + data[i][0] + "-stat").classed("hidden", true); + }); + arcs.append("path").attr("d", arc).attr("stroke", function(d, i) { + return color(i); + }).attr("stroke-width", 2).attr("fill-opacity", "0.3"); + return arcs.append("text").attr("transform", function(d) { + return "translate(" + arc.centroid(d) + ")"; + }).attr("id", function(d, i) { + return "" + data[i][0] + "-stat"; + }).attr("dy", ".35em").classed("hidden", true).text(function(d, i) { + return data[i][0]; + }); + } + }, + update: function() { + if (a.conf.nodeStats) { + this.nodeStats(); + } + if (a.conf.edgeStats) { + return this.edgeStats(); + } + } + }; + }; + + Alchemy.prototype.updateGraph = function(instance) { + var a; + a = instance; + return function() { + a.generateLayout(); + a._drawEdges.createEdge(a.elements.edges.d3); + a._drawNodes.createNode(a.elements.nodes.d3); + a.layout.positionRootNodes(); + a.force.start(); + while (a.force.alpha() > 0.005) { + a.force.tick(); + } + a.force.on("tick", a.layout.tick).start(); + return a.elements.nodes.svg.attr('transform', function(id, i) { + return "translate(" + id.x + ", " + id.y + ")"; + }); + }; + }; + + Alchemy.prototype.defaults = { + plugins: null, + renderer: "svg", + graphWidth: function() { + return d3.select(this.divSelector).node().parentElement.clientWidth; + }, + graphHeight: function() { + if (d3.select(this.divSelector).node().parentElement.nodeName === "BODY") { + return window.innerHeight; + } else { + return d3.select(this.divSelector).node().parentElement.clientHeight; + } + }, + alpha: 0.5, + collisionDetection: true, + nodeOverlap: 25, + fixNodes: false, + fixRootNodes: false, + forceLocked: true, + linkDistancefn: 'default', + nodePositions: null, + showEditor: false, + captionToggle: false, + toggleRootNodes: false, + removeElement: false, + cluster: false, + clusterKey: "cluster", + clusterColours: d3.shuffle(["#DD79FF", "#FFFC00", "#00FF30", "#5168FF", "#00C0FF", "#FF004B", "#00CDCD", "#f83f00", "#f800df", "#ff8d8f", "#ffcd00", "#184fff", "#ff7e00"]), + clusterControl: false, + nodeStats: false, + edgeStats: false, + edgeFilters: false, + nodeFilters: false, + edgesToggle: false, + nodesToggle: false, + zoomControls: false, + nodeCaption: 'caption', + nodeCaptionsOnByDefault: false, + nodeStyle: { + "all": { + "radius": 10, + "color": "#68B9FE", + "borderColor": "#127DC1", + "borderWidth": function(d, radius) { + return radius / 3; + }, + "captionColor": "#FFFFFF", + "captionBackground": null, + "captionSize": 12, + "selected": { + "color": "#FFFFFF", + "borderColor": "#349FE3" + }, + "highlighted": { + "color": "#EEEEFF" + }, + "hidden": { + "color": "none", + "borderColor": "none" + } + } + }, + nodeColour: null, + nodeMouseOver: 'caption', + nodeRadius: 10, + nodeTypes: null, + rootNodes: 'root', + rootNodeRadius: 15, + nodeClick: null, + edgeCaption: 'caption', + edgeCaptionsOnByDefault: false, + edgeStyle: { + "all": { + "width": 4, + "color": "#CCC", + "opacity": 0.2, + "directed": true, + "curved": true, + "selected": { + "opacity": 1 + }, + "highlighted": { + "opacity": 1 + }, + "hidden": { + "opacity": 0 + } + } + }, + edgeTypes: null, + curvedEdges: false, + edgeWidth: function() { + return 4; + }, + edgeOverlayWidth: 20, + directedEdges: false, + edgeArrowSize: 5, + edgeClick: null, + search: false, + searchMethod: "contains", + backgroundColour: "#000000", + theme: null, + afterLoad: 'afterLoad', + divSelector: '#alchemy', + dataSource: null, + initialScale: 1, + initialTranslate: [0, 0], + scaleExtent: [0.5, 2.4], + exportSVG: false, + dataWarning: "default", + warningMessage: "There be no data! What's going on?" + }; + + DrawEdge = function(instance) { + return { + a: instance, + createLink: function(edge) { + var conf; + conf = this.a.conf; + edge.append('path').attr('class', 'edge-line').attr('id', function(d) { + return "path-" + d.id; + }); + edge.filter(function(d) { + return d.caption != null; + }).append('text'); + return edge.append('path').attr('class', 'edge-handler').style('stroke-width', "" + conf.edgeOverlayWidth).style('opacity', "0"); + }, + styleLink: function(edge) { + var a, conf, utils; + a = this.a; + conf = this.a.conf; + utils = this.a.drawing.EdgeUtils; + return edge.each(function(d) { + var curve, curviness, edgeWalk, endx, endy, g, midpoint, startx, starty; + edgeWalk = utils.edgeWalk(d); + curviness = conf.curvedEdges ? 30 : 0; + curve = curviness / 10; + startx = d.source.radius + (d["stroke-width"] / 2); + starty = curviness / 10; + midpoint = edgeWalk.edgeLength / 2; + endx = edgeWalk.edgeLength - (d.target.radius - (d.target["stroke-width"] / 2)); + endy = curviness / 10; + g = d3.select(this); + g.style(utils.edgeStyle(d)); + g.attr('transform', "translate(" + d.source.x + ", " + d.source.y + ") rotate(" + edgeWalk.edgeAngle + ")"); + g.select('.edge-line').attr('d', (function() { + var arrow, line, w; + line = "M" + startx + "," + starty + "q" + midpoint + "," + curviness + " " + endx + "," + endy; + if (conf.directedEdges) { + w = d["stroke-width"] * 2; + arrow = "l" + (-w) + "," + (w + curve) + " l" + w + "," + (-w - curve) + " l" + (-w) + "," + (-w + curve); + return line + arrow; + } + return line; + })()); + return g.select('.edge-handler').attr('d', function(d) { + return g.select('.edge-line').attr('d'); + }); + }); + }, + classEdge: function(edge) { + return edge.classed('active', true); + }, + styleText: function(edge) { + var conf, curved, utils; + conf = this.a.conf; + curved = conf.curvedEdges; + utils = this.a.drawing.EdgeUtils; + return edge.select('text').each(function(d) { + var dx, edgeWalk; + edgeWalk = utils.edgeWalk(d); + dx = edgeWalk.edgeLength / 2; + return d3.select(this).attr('dx', "" + dx).text(d.caption).attr("xlink:xlink:href", "#path-" + d.source.id + "-" + d.target.id).style("display", function(d) { + if (conf.edgeCaptionsOnByDefault) { + return "block"; + } + }); + }); + }, + setInteractions: function(edge) { + var interactions; + interactions = this.a.interactions; + return edge.select('.edge-handler').on('click', interactions.edgeClick).on('mouseover', function(d) { + return interactions.edgeMouseOver(d); + }).on('mouseout', function(d) { + return interactions.edgeMouseOut(d); + }); + } + }; + }; + + DrawEdges = function(instance) { + return { + a: instance, + createEdge: function(d3Edges) { + var drawEdge, edge; + drawEdge = this.a.drawing.DrawEdge; + edge = this.a.vis.selectAll("g.edge").data(d3Edges); + edge.enter().append('g').attr("id", function(d) { + return "edge-" + d.id + "-" + d.pos; + }).attr('class', function(d) { + return "edge " + d.edgeType; + }).attr('source-target', function(d) { + return "" + d.source.id + "-" + d.target.id; + }); + drawEdge.createLink(edge); + drawEdge.classEdge(edge); + drawEdge.styleLink(edge); + drawEdge.styleText(edge); + drawEdge.setInteractions(edge); + edge.exit().remove(); + if (this.a.conf.directedEdges && this.a.conf.curvedEdges) { + return edge.select('.edge-line').attr('marker-end', 'url(#arrow)'); + } + }, + updateEdge: function(d3Edge) { + var drawEdge, edge; + drawEdge = this.a.drawing.DrawEdge; + edge = this.a.vis.select("#edge-" + d3Edge.id + "-" + d3Edge.pos); + drawEdge.classEdge(edge); + drawEdge.styleLink(edge); + drawEdge.styleText(edge); + return drawEdge.setInteractions(edge); + } + }; + }; + + DrawNode = function(instance) { + return { + a: instance, + styleText: function(node) { + var conf, nodes, utils; + conf = this.a.conf; + utils = this.a.drawing.NodeUtils; + nodes = this.a._nodes; + return node.selectAll("text").attr('dy', function(d) { + if (nodes[d.id].getProperties().root) { + return conf.rootNodeRadius / 2; + } else { + return conf.nodeRadius * 2 - 5; + } + }).attr('visibility', function(d) { + if (nodes[d.id]._state === "hidden") { + return "hidden"; + } else { + return "visible"; + } + }).text(function(d) { + return utils.nodeText(d); + }).style("display", function(d) { + if (conf.nodeCaptionsOnByDefault) { + return "block"; + } + }); + }, + createNode: function(node) { + node = _.difference(node, node.select("circle").data()); + node.__proto__ = d3.select().__proto__; + node.append('circle').attr('id', function(d) { + return "circle-" + d.id; + }); + return node.append('svg:text').attr('id', function(d) { + return "text-" + d.id; + }); + }, + styleNode: function(node) { + var utils; + utils = this.a.drawing.NodeUtils; + return node.selectAll('circle').attr('r', function(d) { + if (typeof d.radius === "function") { + return d.radius(); + } else { + return d.radius; + } + }).each(function(d) { + return d3.select(this).style(utils.nodeStyle(d)); + }); + }, + setInteractions: function(node) { + var conf, coreInteractions, drag, editorEnabled, editorInteractions, nonRootNodes, rootNodes; + conf = this.a.conf; + coreInteractions = this.a.interactions; + editorEnabled = this.a.get.state("interactions") === "editor"; + drag = d3.behavior.drag().origin(Object).on("dragstart", null).on("drag", null).on("dragend", null); + if (editorEnabled) { + editorInteractions = new this.a.editor.Interactions; + return node.on('mouseup', function(d) { + return editorInteractions.nodeMouseUp(d); + }).on('mouseover', function(d) { + return editorInteractions.nodeMouseOver(d); + }).on('mouseout', function(d) { + return editorInteractions.nodeMouseOut(d); + }).on('dblclick', function(d) { + return coreInteractions.nodeDoubleClick(d); + }).on('click', function(d) { + return editorInteractions.nodeClick(d); + }); + } else { + node.on('mouseup', null).on('mouseover', function(d) { + return coreInteractions.nodeMouseOver(d); + }).on('mouseout', function(d) { + return coreInteractions.nodeMouseOut(d); + }).on('dblclick', function(d) { + return coreInteractions.nodeDoubleClick(d); + }).on('click', function(d) { + return coreInteractions.nodeClick(d); + }); + drag = d3.behavior.drag().origin(Object).on("dragstart", coreInteractions.nodeDragStarted).on("drag", coreInteractions.nodeDragged).on("dragend", coreInteractions.nodeDragended); + if (!conf.fixNodes) { + nonRootNodes = node.filter(function(d) { + return d.root !== true; + }); + nonRootNodes.call(drag); + } + if (!conf.fixRootNodes) { + rootNodes = node.filter(function(d) { + return d.root === true; + }); + return rootNodes.call(drag); + } + } + } + }; + }; + + DrawNodes = function(instance) { + return { + a: instance, + createNode: function(d3Nodes) { + var drawNode, node; + drawNode = this.a.drawing.DrawNode; + node = this.a.vis.selectAll("g.node").data(d3Nodes, function(n) { + return n.id; + }); + node.enter().append("g").attr("class", function(d) { + var nodeType; + nodeType = d.self._nodeType; + return "node " + nodeType + " active"; + }).attr('id', function(d) { + return "node-" + d.id; + }).classed('root', function(d) { + return d.root; + }); + drawNode.createNode(node); + drawNode.styleNode(node); + drawNode.styleText(node); + drawNode.setInteractions(node); + return node.exit().remove(); + }, + updateNode: function(alchemyNode) { + var drawNode, node; + drawNode = this.a.drawing.DrawNode; + node = this.a.vis.select("#node-" + alchemyNode.id); + drawNode.styleNode(node); + drawNode.styleText(node); + return drawNode.setInteractions(node); + } + }; + }; + + Alchemy.prototype.EdgeUtils = function(instance) { + return { + a: instance, + edgeStyle: function(d) { + var clustering, conf, edge, nodes, styles; + conf = this.a.conf; + edge = this.a._edges[d.id][d.pos]; + styles = this.a.svgStyles.edge.update(edge); + nodes = this.a._nodes; + if (this.a.conf.cluster) { + clustering = this.a.layout._clustering; + styles.stroke = (function(d) { + var clusterKey, gid, id, index, source, target; + clusterKey = conf.clusterKey; + source = nodes[d.source.id]._properties; + target = nodes[d.target.id]._properties; + if (source.root || target.root) { + index = source.root ? target[clusterKey] : source[clusterKey]; + return "" + (clustering.getClusterColour(index)); + } else if (source[clusterKey] === target[clusterKey]) { + index = source[clusterKey]; + return "" + (clustering.getClusterColour(index)); + } else if (source[clusterKey] !== target[clusterKey]) { + id = "" + source[clusterKey] + "-" + target[clusterKey]; + gid = "cluster-gradient-" + id; + return "url(#" + gid + ")"; + } + })(d); + } + return styles; + }, + triangle: function(edge) { + var height, hyp, width; + width = edge.target.x - edge.source.x; + height = edge.target.y - edge.source.y; + hyp = Math.sqrt(height * height + width * width); + return [width, height, hyp]; + }, + edgeWalk: function(edge) { + var curveOffset, edgeLength, edgeWidth, height, hyp, startPathX, width, _ref; + _ref = this.triangle(edge), width = _ref[0], height = _ref[1], hyp = _ref[2]; + edgeWidth = edge['stroke-width']; + curveOffset = 2; + startPathX = edge.source.radius + edge.source['stroke-width'] - (edgeWidth / 2) + curveOffset; + edgeLength = hyp - startPathX - curveOffset * 1.5; + return { + edgeAngle: Math.atan2(height, width) / Math.PI * 180, + edgeLength: edgeLength + }; + }, + middleLine: function(edge) { + return this.curvedDirectedEdgeWalk(edge, 'middle'); + }, + startLine: function(edge) { + return this.curvedDirectedEdgeWalk(edge, 'linkStart'); + }, + endLine: function(edge) { + return this.curvedDirectedEdgeWalk(edge, 'linkEnd'); + }, + edgeLength: function(edge) { + var height, hyp, width; + width = edge.target.x - edge.source.x; + height = edge.target.y - edge.source.y; + return hyp = Math.sqrt(height * height + width * width); + }, + edgeAngle: function(edge) { + var height, width; + width = edge.target.x - edge.source.x; + height = edge.target.y - edge.source.y; + return Math.atan2(height, width) / Math.PI * 180; + }, + captionAngle: function(angle) { + if (angle < -90 || angle > 90) { + return 180; + } else { + return 0; + } + }, + middlePath: function(edge) { + var midPoint, pathNode; + pathNode = this.a.vis.select("#path-" + edge.id).node(); + midPoint = pathNode.getPointAtLength(pathNode.getTotalLength() / 2); + return { + x: midPoint.x, + y: midPoint.y + }; + }, + middlePathCurve: function(edge) { + var midPoint, pathNode; + pathNode = d3.select("#path-" + edge.id).node(); + midPoint = pathNode.getPointAtLength(pathNode.getTotalLength() / 2); + return { + x: midPoint.x, + y: midPoint.y + }; + } + }; + }; + + Alchemy.prototype.NodeUtils = function(instance) { + var a; + a = instance; + return { + nodeStyle: function(d) { + var conf, node; + conf = a.conf; + node = d.self; + if (conf.cluster && (node._state !== "hidden")) { + d.fill = (function(d) { + var clusterMap, clustering, colour, colourIndex, colours, key, nodeProp; + clustering = a.layout._clustering; + nodeProp = node.getProperties(); + clusterMap = clustering.clusterMap; + key = conf.clusterKey; + colours = conf.clusterColours; + colourIndex = clusterMap[nodeProp[key]] % colours.length; + colour = colours[colourIndex]; + return "" + colour; + })(d); + d.stroke = d.fill; + } + return d; + }, + nodeText: function(d) { + var caption, conf, nodeProps; + conf = a.conf; + nodeProps = a._nodes[d.id]._properties; + if (conf.nodeCaption && typeof conf.nodeCaption === 'string') { + if (nodeProps[conf.nodeCaption] != null) { + return nodeProps[conf.nodeCaption]; + } else { + return ''; + } + } else if (conf.nodeCaption && typeof conf.nodeCaption === 'function') { + caption = conf.nodeCaption(nodeProps); + if (caption === void 0 || String(caption) === 'undefined') { + a.log["caption"] = "At least one caption returned undefined"; + conf.caption = false; + } + return caption; + } + } + }; + }; + + Alchemy.prototype.svgStyles = function(instance) { + return { + a: instance, + node: { + a: this.a, + populate: function(node) { + var conf, d, defaultStyle, fill, nodeType, nodeTypeKey, radius, stroke, strokeWidth, style, svgStyles, toFunc, typedStyle; + conf = this.a.conf; + defaultStyle = _.omit(conf.nodeStyle.all, "selected", "highlighted", "hidden"); + d = node; + toFunc = function(inp) { + if (typeof inp === "function") { + return inp; + } + return function() { + return inp; + }; + }; + nodeTypeKey = _.keys(conf.nodeTypes)[0]; + nodeType = node.getProperties()[nodeTypeKey]; + if (conf.nodeStyle[nodeType] === void 0) { + nodeType = "all"; + } + typedStyle = _.assign(_.cloneDeep(defaultStyle), conf.nodeStyle[nodeType]); + style = _.assign(typedStyle, conf.nodeStyle[nodeType][node._state]); + radius = toFunc(style.radius); + fill = toFunc(style.color); + stroke = toFunc(style.borderColor); + strokeWidth = toFunc(style.borderWidth); + svgStyles = {}; + svgStyles["radius"] = radius(d); + svgStyles["fill"] = fill(d); + svgStyles["stroke"] = stroke(d); + svgStyles["stroke-width"] = strokeWidth(d, radius(d)); + return svgStyles; + } + }, + edge: { + a: this.a, + populate: function(edge) { + var color, conf, defaultStyle, edgeType, opacity, style, svgStyles, toFunc, typedStyle, width; + conf = this.a.conf; + defaultStyle = _.omit(conf.edgeStyle.all, "selected", "highlighted", "hidden"); + toFunc = function(inp) { + if (typeof inp === "function") { + return inp; + } + return function() { + return inp; + }; + }; + edgeType = edge._edgeType; + if (conf.edgeStyle[edgeType] === void 0) { + edgeType = "all"; + } + typedStyle = _.assign(_.cloneDeep(defaultStyle), conf.edgeStyle[edgeType]); + style = _.assign(typedStyle, conf.edgeStyle[edgeType][edge._state]); + width = toFunc(style.width); + color = toFunc(style.color); + opacity = toFunc(style.opacity); + svgStyles = { + "stroke": color(edge), + "stroke-width": width(edge), + "opacity": opacity(edge), + "fill": "none" + }; + return svgStyles; + }, + update: function(edge) { + var color, conf, opacity, style, svgStyles, toFunc, width; + conf = this.a.conf; + style = edge._style; + toFunc = function(inp) { + if (typeof inp === "function") { + return inp; + } + return function() { + return inp; + }; + }; + width = toFunc(style.width); + color = toFunc(style.color); + opacity = toFunc(style.opacity); + svgStyles = { + "stroke": color(edge), + "stroke-width": width(edge), + "opacity": opacity(edge), + "fill": "none" + }; + return svgStyles; + } + } + }; + }; + + Editor = (function() { + function Editor() { + this.nodeEditor = __bind(this.nodeEditor, this); + this.startEditor = __bind(this.startEditor, this); + this.utils = new alchemy.editor.Utils; + } + + Editor.prototype.editorContainerHTML = "
      \n

      Editor

      \n
      \n
      \n
        \n
      • Remove Selected
      • \n
      • Editor mode enabled, click to disable editor interactions
      • \n
      \n
      "; + + Editor.prototype.elementEditorHTML = function(type) { + return "

      " + type + " Editor

      \n
      \n
      \n \n \n
      \n \n
      \n
      \n \n
      "; + }; + + Editor.prototype.startEditor = function() { + var divSelector, editor, editor_interactions, html, utils; + divSelector = alchemy.conf.divSelector; + html = this.editorContainerHTML; + editor = alchemy.dash.select("#control-dash").append("div").attr("id", "editor").html(html); + editor.select('#editor-header').on('click', function() { + if (alchemy.dash.select('#element-options').classed("in")) { + return alchemy.dash.select("#editor-header>span").attr("class", "fa fa-2x fa-caret-right"); + } else { + return alchemy.dash.select("#editor-header>span").attr("class", "fa fa-2x fa-caret-down"); + } + }); + editor_interactions = editor.select('#element-options ul #editor-interactions').on('click', function() { + return d3.select(this).attr("class", function() { + if (alchemy.get.state() === 'editor') { + alchemy.set.state('interactions', 'default'); + return "inactive list-group-item"; + } else { + alchemy.set.state('interactions', 'editor'); + return "active list-group-item"; + } + }).html(function() { + if (alchemy.get.state() === 'editor') { + return "Disable Editor Interactions"; + } else { + return "Enable Editor Interactions"; + } + }); + }); + editor.select("#element-options ul #remove").on("click", function() { + return alchemy.editor.remove(); + }); + utils = this.utils; + return editor_interactions.on("click", function() { + if (!alchemy.dash.select("#editor-interactions").classed("active")) { + utils.enableEditor(); + return alchemy.dash.select("#editor-interactions").classed({ + "active": true, + "inactive": false + }).html("Editor mode enabled, click to disable editor interactions"); + } else { + utils.disableEditor(); + return alchemy.dash.select("#editor-interactions").classed({ + "active": false, + "inactive": true + }).html("Editor mode disabled, click to enable editor interactions"); + } + }); + }; + + Editor.prototype.nodeEditor = function(n) { + var add_property, divSelector, editor, elementEditor, html, nodeProperties, node_property, options, property, property_list, updateProperty, val; + divSelector = alchemy.conf.divSelector; + editor = alchemy.dash.select("#control-dash #editor"); + options = editor.select('#element-options'); + html = this.elementEditorHTML("Node"); + elementEditor = options.append('div').attr('id', 'node-editor').html(html); + elementEditor.attr("class", function() { + var active; + active = alchemy.dash.select("#editor-interactions").classed("active"); + if (active) { + return "enabled"; + } + return "hidden"; + }); + add_property = editor.select("#node-editor form #add-property"); + add_property.select("#node-add-prop-key").attr("placeholder", "New Property Name").attr("value", null); + add_property.select("#node-add-prop-value").attr("placeholder", "New Property Value").attr("value", null); + alchemy.dash.select("#add-property-form").on("submit", function() { + var key, value; + event.preventDefault(); + key = alchemy.dash.select('#add-prop-key').property('value'); + key = key.replace(/\s/g, "_"); + value = alchemy.dash.select('#add-prop-value').property('value'); + updateProperty(key, value, true); + alchemy.dash.selectAll("#add-property .edited-property").classed({ + "edited-property": false + }); + return this.reset(); + }); + nodeProperties = alchemy._nodes[n.id].getProperties(); + alchemy.vis.select("#node-" + n.id).classed({ + "editing": true + }); + property_list = editor.select("#node-editor #properties-list"); + for (property in nodeProperties) { + val = nodeProperties[property]; + node_property = property_list.append("div").attr("id", "node-" + property).attr("class", "property form-inline form-group"); + node_property.append("label").attr("for", "node-" + property + "-input").attr("class", "form-control property-name").text("" + property); + node_property.append("input").attr("id", "node-" + property + "-input").attr("class", "form-control property-value").attr("value", "" + val); + } + alchemy.dash.select("#properties-list").on("submit", function() { + var key, properties, selection, value, _i, _len, _ref; + event.preventDefault(); + properties = alchemy.dash.selectAll(".edited-property"); + _ref = properties[0]; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + property = _ref[_i]; + selection = alchemy.dash.select(property); + key = selection.select("label").text(); + value = selection.select("input").attr('value'); + updateProperty(key, value, false); + } + alchemy.dash.selectAll("#node-properties-list .edited-property").classed({ + "edited-property": false + }); + return this.reset(); + }); + d3.selectAll("#add-prop-key, #add-prop-value, .property").on("keydown", function() { + if (d3.event.keyCode === 13) { + event.preventDefault(); + } + return d3.select(this).classed({ + "edited-property": true + }); + }); + return updateProperty = function(key, value, newProperty) { + var drawNodes, nodeID; + nodeID = n.id; + if ((key !== "") && (value !== "")) { + alchemy._nodes[nodeID].setProperty("" + key, "" + value); + drawNodes = alchemy._drawNodes; + drawNodes.updateNode(alchemy.viz.select("#node-" + nodeID)); + if (newProperty === true) { + alchemy.dash.select("#node-add-prop-key").attr("value", "property added/updated to key: " + key); + return alchemy.dash.select("#node-add-prop-value").attr("value", "property at " + key + " updated to: " + value); + } else { + return alchemy.dash.select("#node-" + key + "-input").attr("value", "property at " + key + " updated to: " + value); + } + } else { + if (newProperty === true) { + alchemy.dash.select("#node-add-prop-key").attr("value", "null or invalid input"); + return alchemy.dash.select("#node-add-prop-value").attr("value", "null or invlid input"); + } else { + return alchemy.dash.select("#node-" + key + "-input").attr("value", "null or invalid input"); + } + } + }; + }; + + Editor.prototype.editorClear = function() { + alchemy.dash.selectAll(".node").classed({ + "editing": false + }); + alchemy.dash.selectAll(".edge").classed({ + "editing": false + }); + alchemy.dash.select("#node-editor").remove(); + alchemy.dash.select("#edge-editor").remove(); + return alchemy.dash.select("#node-add-prop-submit").attr("placeholder", function() { + if (alchemy.vis.selectAll(".selected").empty()) { + return "select a node or edge to edit properties"; + } + return "add a property to this element"; + }); + }; + + Editor.prototype.edgeEditor = function(e) { + var add_property, divSelector, edgeProperties, edge_property, editor, elementEditor, html, options, property, property_list, updateProperty, val; + divSelector = alchemy.conf.divSelector; + editor = alchemy.dash("#control-dash #editor"); + options = editor.select('#element-options'); + html = this.elementEditorHTML("Edge"); + elementEditor = options.append('div').attr('id', 'edge-editor').html(html); + elementEditor.attr("class", function() { + if (alchemy.dash.select("#editor-interactions").classed("active")) { + return "enabled"; + } + return "hidden"; + }); + add_property = editor.select("#edge-editor form #add-property"); + add_property.select("#add-prop-key").attr("placeholder", "New Property Name").attr("value", null); + add_property.select("#add-prop-value").attr("placeholder", "New Property Value").attr("value", null); + edgeProperties = alchemy._edges[e.id].getProperties(); + alchemy.vis.select("#edge-" + e.id).classed({ + "editing": true + }); + property_list = editor.select("#edge-editor #properties-list"); + for (property in edgeProperties) { + val = edgeProperties[property]; + edge_property = property_list.append("div").attr("id", "edge-" + property).attr("class", "property form-inline form-group"); + edge_property.append("label").attr("for", "edge-" + property + "-input").attr("class", "form-control property-name").text("" + property); + edge_property.append("input").attr("id", "edge-" + property + "-input").attr("class", "form-control property-value").attr("value", "" + val); + } + alchemy.dash.selectAll("#add-prop-key, #add-prop-value, .property").on("keydown", function() { + if (d3.event.keyCode === 13) { + event.preventDefault(); + } + return d3.select(this).classed({ + "edited-property": true + }); + }); + alchemy.dash.select("#add-property-form").on("submit", function() { + var key, value; + event.preventDefault(); + key = alchemy.dash.select("#add-prop-key").property('value'); + key = key.replace(/\s/g, "_"); + value = alchemy.dash.select("#add-prop-value").property('value'); + updateProperty(key, value, true); + alchemy.dash.selectAll("#add-property .edited-property").classed({ + "edited-property": false + }); + return this.reset(); + }); + d3.select("#properties-list").on("submit", function() { + var key, properties, selection, value, _i, _len, _ref; + event.preventDefault(); + properties = alchemy.dash.selectAll(".edited-property"); + _ref = properties[0]; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + property = _ref[_i]; + selection = alchemy.dash.select(property); + key = selection.select("label").text(); + value = selection.select("input").property('value'); + updateProperty(key, value, false); + } + alchemy.dash.selectAll("#properties-list .edited-property").classed({ + "edited-property": false + }); + return this.reset(); + }); + return updateProperty = function(key, value, newProperty) { + var drawEdges, edgeID, edgeSelection; + edgeID = e.id; + if ((key !== "") && (value !== "")) { + alchemy._edges[edgeID].setProperty("" + key, "" + value); + edgeSelection = alchemy.vis.select("#edge-" + edgeID); + drawEdges = new alchemy.drawing.DrawEdges; + drawEdges.updateEdge(alchemy.vis.select("#edge-" + edgeID)); + if (newProperty === true) { + alchemy.dash.select("#add-prop-key").attr("value", "property added/updated to key: " + key); + return alchemy.dash.select("#add-prop-value").attr("value", "property at " + key + " updated to: " + value); + } else { + return alchemy.dash.select("#edge-" + key + "-input").attr("value", "property at " + key + " updated to: " + value); + } + } else { + if (newProperty === true) { + alchemy.dash.select("#add-prop-key").attr("value", "null or invalid input"); + return alchemy.dash.select("#add-prop-value").attr("value", "null or invlid input"); + } else { + return alchemy.dash.select("#edge-" + key + "-input").attr("value", "null or invalid input"); + } + } + }; + }; + + return Editor; + + })(); + + EditorInteractions = (function() { + function EditorInteractions() { + this.reset = __bind(this.reset, this); + this.deleteSelected = __bind(this.deleteSelected, this); + this.addNodeDragended = __bind(this.addNodeDragended, this); + this.addNodeDragging = __bind(this.addNodeDragging, this); + this.addNodeStart = __bind(this.addNodeStart, this); + this.edgeClick = __bind(this.edgeClick, this); + this.nodeClick = __bind(this.nodeClick, this); + this.nodeMouseUp = __bind(this.nodeMouseUp, this); + this.editor = new alchemy.editor.Editor; + } + + EditorInteractions.prototype.nodeMouseOver = function(n) { + var radius; + if (!d3.select(this).select("circle").empty()) { + radius = d3.select(this).select("circle").attr("r"); + d3.select(this).select("circle").attr("r", radius * 3); + } + return this; + }; + + EditorInteractions.prototype.nodeMouseUp = function(n) { + if (this.sourceNode !== n) { + this.mouseUpNode = true; + this.targetNode = n; + this.click = false; + } else { + this.click = true; + } + return this; + }; + + EditorInteractions.prototype.nodeMouseOut = function(n) { + var radius; + if (!d3.select(this).select("circle").empty()) { + radius = d3.select(this).select("circle").attr("r"); + d3.select(this).select("circle").attr("r", radius / 3); + } + return this; + }; + + EditorInteractions.prototype.nodeClick = function(c) { + var selected; + d3.event.stopPropagation(); + if (!alchemy.vis.select("#node-" + c.id).empty()) { + selected = alchemy.vis.select("#node-" + c.id).classed('selected'); + alchemy.vis.select("#node-" + c.id).classed('selected', !selected); + } + this.editor.editorClear(); + return this.editor.nodeEditor(c); + }; + + EditorInteractions.prototype.edgeClick = function(e) { + d3.event.stopPropagation(); + this.editor.editorClear(); + return this.editor.edgeEditor(e); + }; + + EditorInteractions.prototype.addNodeStart = function(d, i) { + d3.event.sourceEvent.stopPropagation(); + this.sourceNode = d; + alchemy.vis.select('#dragline').classed({ + "hidden": false + }); + return this; + }; + + EditorInteractions.prototype.addNodeDragging = function(d, i) { + var x2coord, y2coord; + x2coord = d3.event.x; + y2coord = d3.event.y; + alchemy.vis.select('#dragline').attr("x1", this.sourceNode.x).attr("y1", this.sourceNode.y).attr("x2", x2coord).attr("y2", y2coord).attr("style", "stroke: #FFF"); + return this; + }; + + EditorInteractions.prototype.addNodeDragended = function(d, i) { + var dragline, targetX, targetY; + if (!this.click) { + if (!this.mouseUpNode) { + dragline = alchemy.vis.select("#dragline"); + targetX = dragline.attr("x2"); + targetY = dragline.attr("y2"); + this.targetNode = { + id: "" + (_.uniqueId('addedNode_')), + x: parseFloat(targetX), + y: parseFloat(targetY), + caption: "node added" + }; + } + this.newEdge = { + id: "" + this.sourceNode.id + "-" + this.targetNode.id, + source: this.sourceNode.id, + target: this.targetNode.id, + caption: "edited" + }; + alchemy.editor.update(this.targetNode, this.newEdge); + } + this.reset(); + return this; + }; + + EditorInteractions.prototype.deleteSelected = function(d) { + switch (d3.event.keyCode) { + case 8: + case 46: + if (!(d3.select(d3.event.target).node().tagName === ("INPUT" || "TEXTAREA"))) { + d3.event.preventDefault(); + return alchemy.editor.remove(); + } + } + }; + + EditorInteractions.prototype.reset = function() { + this.mouseUpNode = null; + this.sourceNode = null; + this.targetNode = null; + this.newEdge = null; + this.click = null; + alchemy.vis.select("#dragline").classed({ + "hidden": true + }).attr("x1", 0).attr("y1", 0).attr("x2", 0).attr("y2", 0); + return this; + }; + + EditorInteractions; + + return EditorInteractions; + + })(); + + EditorUtils = (function() { + function EditorUtils() { + this.enableEditor = __bind(this.enableEditor, this); + this.drawNodes = alchemy._drawNodes; + this.drawEdges = alchemy._drawEdges; + } + + EditorUtils.prototype.enableEditor = function() { + var dragLine, editor, selectedElements; + alchemy.set.state("interactions", "editor"); + dragLine = alchemy.vis.append("line").attr("id", "dragline"); + this.drawNodes.updateNode(alchemy.node); + this.drawEdges.updateEdge(alchemy.edge); + selectedElements = alchemy.vis.selectAll(".selected"); + editor = new alchemy.editor.Editor; + if ((!selectedElements.empty()) && (selectedElements.length === 1)) { + if (selectedElements.classed('node')) { + editor.nodeEditor(selectedElements.datum()); + return alchemy.dash.select("#node-editor").attr("class", "enabled").style("opacity", 1); + } else if (selectedElements.classed('edge')) { + editor.edgeEditor(selectedElements.datum()); + return alchemy.dash.select("#edge-editor").attr("class", "enabled").style("opacity", 1); + } + } else { + return selectedElements.classed({ + "selected": false + }); + } + }; + + EditorUtils.prototype.disableEditor = function() { + alchemy.setState("interactions", "default"); + alchemy.vis.select("#dragline").remove(); + alchemy.dash.select("#node-editor").transition().duration(300).style("opacity", 0); + alchemy.dash.select("#node-editor").transition().delay(300).attr("class", "hidden"); + this.drawNodes.updateNode(alchemy.node); + return alchemy.vis.selectAll(".node").classed({ + "selected": false + }); + }; + + EditorUtils.prototype.remove = function() { + var edge, node, nodeID, node_data, selectedNodes, _i, _j, _len, _len1, _ref, _ref1, _results; + selectedNodes = alchemy.vis.selectAll(".selected.node"); + _ref = selectedNodes[0]; + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + node = _ref[_i]; + nodeID = alchemy.vis.select(node).data()[0].id; + node_data = alchemy._nodes[nodeID]; + if (node_data != null) { + _ref1 = node_data.adjacentEdges; + for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { + edge = _ref1[_j]; + alchemy._edges = _.omit(alchemy._edges, "" + edge.id + "-" + edge._index); + alchemy.edge = alchemy.edge.data(_.map(alchemy._edges, function(e) { + return e._d3; + }), function(e) { + return e.id; + }); + alchemy.vis.select("#edge-" + edge.id + "-" + edge._index).remove(); + } + alchemy._nodes = _.omit(alchemy._nodes, "" + nodeID); + alchemy.node = alchemy.node.data(_.map(alchemy._nodes, function(n) { + return n._d3; + }), function(n) { + return n.id; + }); + alchemy.vis.select(node).remove(); + if (alchemy.get.state("interactions") === "editor") { + _results.push(alchemy.modifyElements.nodeEditorClear()); + } else { + _results.push(void 0); + } + } else { + _results.push(void 0); + } + } + return _results; + }; + + EditorUtils.prototype.addNode = function(node) { + var newNode; + newNode = alchemy._nodes[node.id] = new alchemy.models.Node({ + id: "" + node.id + }); + newNode.setProperty("caption", node.caption); + newNode.setD3Property("x", node.x); + newNode.setD3Property("y", node.y); + return alchemy.node = alchemy.node.data(_.map(alchemy._nodes, function(n) { + return n._d3; + }), function(n) { + return n.id; + }); + }; + + EditorUtils.prototype.addEdge = function(edge) { + var newEdge; + newEdge = alchemy._edges[edge.id] = new alchemy.models.Edge(edge); + return alchemy.edge = alchemy.edge.data(_.map(alchemy._edges, function(e) { + return e._d3; + }), function(e) { + return e.id; + }); + }; + + EditorUtils.prototype.update = function(node, edge) { + if (!this.mouseUpNode) { + alchemy.editor.addNode(node); + alchemy.editor.addEdge(edge); + this.drawEdges.createEdge(alchemy.edge); + this.drawNodes.createNode(alchemy.node); + } else { + alchemy.editor.addEdge(edge); + this.drawEdges.createEdge(alchemy.edge); + } + return alchemy.layout.tick(); + }; + + return EditorUtils; + + })(); + + Alchemy.prototype.Edge = function(instance) { + var Edge; + return Edge = (function() { + function Edge(edge, index) { + var conf; + if (index == null) { + index = null; + } + this.allNodesActive = __bind(this.allNodesActive, this); + this.setProperties = __bind(this.setProperties, this); + this.getStyles = __bind(this.getStyles, this); + this.setProperties = __bind(this.setProperties, this); + this.getProperties = __bind(this.getProperties, this); + this._setID = __bind(this._setID, this); + this._setD3Properties = __bind(this._setD3Properties, this); + this.a = instance; + conf = this.a.conf; + this.id = this._setID(edge); + this._index = index; + this._state = "active"; + this._properties = edge; + this._edgeType = this._setEdgeType(); + this._style = conf.edgeStyle[this._edgeType] != null ? _.merge(_.clone(conf.edgeStyle["all"]), conf.edgeStyle[this._edgeType]) : _.clone(conf.edgeStyle["all"]); + this._d3 = _.merge({ + 'id': this.id, + 'pos': this._index, + 'edgeType': this._edgeType, + 'source': this.a._nodes[this._properties.source]._d3, + 'target': this.a._nodes[this._properties.target]._d3, + 'self': this + }, this.a.svgStyles.edge.populate(this)); + this._setCaption(edge, conf); + this.a._nodes["" + edge.source]._addEdge(this); + this.a._nodes["" + edge.target]._addEdge(this); + } + + Edge.prototype._setD3Properties = function(props) { + return _.merge(this._d3, props); + }; + + Edge.prototype._setID = function(e) { + if (e.id != null) { + return e.id; + } else { + return "" + e.source + "-" + e.target; + } + }; + + Edge.prototype._setCaption = function(edge, conf) { + var cap, edgeCaption; + cap = conf.edgeCaption; + edgeCaption = (function(edge) { + switch (typeof cap) { + case 'string' || 'number': + return edge[cap]; + case 'function': + return cap(edge); + } + })(edge); + if (edgeCaption) { + return this._d3.caption = edgeCaption; + } + }; + + Edge.prototype._setEdgeType = function() { + var conf, edgeType, lookup; + conf = this.a.conf; + if (conf.edgeTypes) { + if (_.isPlainObject(conf.edgeTypes)) { + lookup = Object.keys(this.a.conf.edgeTypes); + edgeType = this._properties[lookup]; + } else if (_.isArray(conf.edgeTypes)) { + edgeType = this._properties["caption"]; + } else if (typeof conf.edgeTypes === 'string') { + edgeType = this._properties[conf.edgeTypes]; + } + } + if (edgeType === void 0) { + edgeType = "all"; + } + this._setD3Properties('edgeType', edgeType); + return edgeType; + }; + + Edge.prototype.getProperties = function() { + var key, keys, query; + key = arguments[0], keys = 2 <= arguments.length ? __slice.call(arguments, 1) : []; + if (key == null) { + key = null; + } + if ((key == null) && (keys.length === 0)) { + return this._properties; + } else if (keys.length !== 0) { + query = _.union([key], keys); + return _.pick(this._properties, query); + } else { + return this._properties[key]; + } + }; + + Edge.prototype.setProperties = function(property, value) { + if (value == null) { + value = null; + } + if (_.isPlainObject(property)) { + _.assign(this._properties, property); + if ('source' in property) { + this._setD3Properties({ + 'source': alchemy._nodes[property.source]._d3 + }); + } + if ('target' in property) { + this._setD3Properties({ + 'target': alchemy._nodes[property.target]._d3 + }); + } + } else { + this._properties[property] = value; + if ((property === 'source') || (property === 'target')) { + this._setD3Properties({ + property: alchemy._nodes[value]._d3 + }); + } + } + return this; + }; + + Edge.prototype.getStyles = function() { + var edge, key, keys; + key = arguments[0], keys = 2 <= arguments.length ? __slice.call(arguments, 1) : []; + edge = this; + if (key === void 0) { + return edge._style; + } + return _.map(arguments, function(arg) { + return edge._style[arg]; + }); + }; + + Edge.prototype.setProperties = function(property, value) { + if (value == null) { + value = null; + } + if (_.isPlainObject(property)) { + _.assign(this._properties, property); + if ('source' in property) { + this._setD3Properties({ + 'source': this.a._nodes[property.source]._d3 + }); + } + if ('target' in property) { + this._setD3Properties({ + 'target': this.a._nodes[property.target]._d3 + }); + } + } else { + this._properties[property] = value; + if ((property === 'source') || (property === 'target')) { + this._setD3Properties({ + property: this.a._nodes[value]._d3 + }); + } + } + return this; + }; + + Edge.prototype.setStyles = function(key, value) { + if (value == null) { + value = null; + } + if (key === void 0) { + key = this.a.svgStyles.edge.populate(this); + } + if (_.isPlainObject(key)) { + _.assign(this._style, key); + } else if (typeof key === "string") { + this._style[key] = value; + } + this._setD3Properties(this.a.svgStyles.edge.update(this)); + this.a._drawEdges.updateEdge(this._d3); + return this; + }; + + Edge.prototype.toggleHidden = function() { + this._state = this._state === "hidden" ? "active" : "hidden"; + return this.setStyles(); + }; + + Edge.prototype.allNodesActive = function() { + var sourceId, sourceNode, targetId, targetNode; + sourceId = this._properties.source; + targetId = this._properties.target; + sourceNode = alchemy.get.nodes(sourceId)[0]; + targetNode = alchemy.get.nodes(targetId)[0]; + return sourceNode._state === "active" && targetNode._state === "active"; + }; + + Edge.prototype.remove = function() { + var edge, filteredLinkList; + edge = this; + delete this.a._edges[edge.id]; + if (this.a._nodes[edge._properties.source] != null) { + _.remove(this.a._nodes[edge._properties.source]._adjacentEdges, function(e) { + if (e.id === edge.id) { + return e; + } + }); + } + if (this.a._nodes[edge._properties.target] != null) { + _.remove(this.a._nodes[edge._properties.target]._adjacentEdges, function(e) { + if (e.id === edge.id) { + return e; + } + }); + } + this.a.vis.select("#edge-" + edge.id + "-" + edge._index).remove(); + filteredLinkList = _.filter(this.a.force.links(), function(link) { + if (link.id !== edge.id) { + return link; + } + }); + return this.a.force.links(filteredLinkList); + }; + + return Edge; + + })(); + }; + + Alchemy.prototype.Node = function(instance) { + var Node; + return Node = (function() { + function Node(node) { + this.getStyles = __bind(this.getStyles, this); + this.setProperty = __bind(this.setProperty, this); + this.getProperties = __bind(this.getProperties, this); + this._setD3Properties = __bind(this._setD3Properties, this); + this._setNodeType = __bind(this._setNodeType, this); + var conf; + this.a = instance; + conf = this.a.conf; + this.id = node.id; + this._properties = node; + this._d3 = _.merge({ + 'id': this.id, + 'root': this._properties[conf.rootNodes], + 'self': this + }, this.a.svgStyles.node.populate(this)); + this._nodeType = this._setNodeType(); + this._style = conf.nodeStyle[this._nodeType] ? conf.nodeStyle[this._nodeType] : conf.nodeStyle["all"]; + this._state = "active"; + this._adjacentEdges = []; + } + + Node.prototype._setNodeType = function() { + var conf, lookup, nodeType, types; + conf = this.a.conf; + if (conf.nodeTypes) { + if (_.isPlainObject(conf.nodeTypes)) { + lookup = Object.keys(this.a.conf.nodeTypes); + types = _.values(conf.nodeTypes); + nodeType = this._properties[lookup]; + } else if (typeof conf.nodeTypes === 'string') { + nodeType = this._properties[conf.nodeTypes]; + } + } + if (nodeType === void 0) { + nodeType = "all"; + } + this._setD3Properties('nodeType', nodeType); + return nodeType; + }; + + Node.prototype._setD3Properties = function(props) { + return _.merge(this._d3, props); + }; + + Node.prototype._addEdge = function(edge) { + return this._adjacentEdges = _.union(this._adjacentEdges, [edge]); + }; + + Node.prototype.getProperties = function() { + var key, keys, query; + key = arguments[0], keys = 2 <= arguments.length ? __slice.call(arguments, 1) : []; + if (key == null) { + key = null; + } + if ((key == null) && (keys.length === 0)) { + return this._properties; + } else if (keys.length !== 0) { + query = _.union([key], keys); + return _.pick(this._properties, query); + } else { + return this._properties[key]; + } + }; + + Node.prototype.setProperty = function(property, value) { + if (value == null) { + value = null; + } + if (_.isPlainObject(property)) { + _.assign(this._properties, property); + } else { + this._properties[property] = value; + } + return this; + }; + + Node.prototype.removeProperty = function() { + var prop, properties, property, _i, _len; + property = arguments[0], properties = 2 <= arguments.length ? __slice.call(arguments, 1) : []; + for (_i = 0, _len = arguments.length; _i < _len; _i++) { + prop = arguments[_i]; + delete this._properties[prop]; + } + return this; + }; + + Node.prototype.getStyles = function() { + var key, keys, node; + key = arguments[0], keys = 2 <= arguments.length ? __slice.call(arguments, 1) : []; + node = this; + if (key === void 0) { + return node._style; + } + return _.map(arguments, function(arg) { + return node._style[arg]; + }); + }; + + Node.prototype.setStyles = function(key, value) { + if (value == null) { + value = null; + } + if (key === void 0) { + key = this.a.svgStyles.node.populate(this); + } else if (_.isPlainObject(key)) { + _.assign(this._style, key); + } else { + this._style[key] = value; + } + this._setD3Properties(this.a.svgStyles.node.populate(this)); + this.a._drawNodes.updateNode(this._d3); + return this; + }; + + Node.prototype.toggleHidden = function() { + var a; + a = this.a; + this._state = this._state === "hidden" ? "active" : "hidden"; + this.setStyles(); + return _.each(this._adjacentEdges, function(e) { + var source, sourceState, target, targetState, _ref; + _ref = e.id.split("-"), source = _ref[0], target = _ref[1]; + sourceState = a._nodes["" + source]._state; + targetState = a._nodes["" + target]._state; + if (e._state === "hidden" && (sourceState === "active" && targetState === "active")) { + return e.toggleHidden(); + } else if (e._state === "active" && (sourceState === "hidden" || targetState === "hidden")) { + return e.toggleHidden(); + } + }); + }; + + Node.prototype.outDegree = function() { + return this._adjacentEdges.length; + }; + + Node.prototype.remove = function() { + while (!_.isEmpty(this._adjacentEdges)) { + this._adjacentEdges[0].remove(); + } + delete this.a._nodes[this.id]; + return this.a.vis.select("#node-" + this.id).remove(); + }; + + return Node; + + })(); + }; + + Alchemy.prototype.plugins = function(instance) { + return { + init: function() { + return _.each(_.keys(instance.conf.plugins), function(key) { + instance.plugins[key] = Alchemy.prototype.plugins[key](instance); + if (instance.plugins[key].init != null) { + return instance.plugins[key].init(); + } + }); + } + }; + }; + + Alchemy.prototype.themes = { + "default": { + "backgroundColour": "#000000", + "nodeStyle": { + "all": { + "radius": function() { + return 10; + }, + "color": function() { + return "#68B9FE"; + }, + "borderColor": function() { + return "#127DC1"; + }, + "borderWidth": function(d, radius) { + return radius / 3; + }, + "captionColor": function() { + return "#FFFFFF"; + }, + "captionBackground": function() { + return null; + }, + "captionSize": 12, + "selected": { + "color": function() { + return "#FFFFFF"; + }, + "borderColor": function() { + return "#349FE3"; + } + }, + "highlighted": { + "color": function() { + return "#EEEEFF"; + } + }, + "hidden": { + "color": function() { + return "none"; + }, + "borderColor": function() { + return "none"; + } + } + } + }, + "edgeStyle": { + "all": { + "width": 4, + "color": "#CCC", + "opacity": 0.2, + "directed": true, + "curved": true, + "selected": { + "opacity": 1 + }, + "highlighted": { + "opacity": 1 + }, + "hidden": { + "opacity": 0 + } + } + } + }, + "white": { + "theme": "white", + "backgroundColour": "#FFFFFF", + "nodeStyle": { + "all": { + "radius": function() { + return 10; + }, + "color": function() { + return "#68B9FE"; + }, + "borderColor": function() { + return "#127DC1"; + }, + "borderWidth": function(d, radius) { + return radius / 3; + }, + "captionColor": function() { + return "#FFFFFF"; + }, + "captionBackground": function() { + return null; + }, + "captionSize": 12, + "selected": { + "color": function() { + return "#FFFFFF"; + }, + "borderColor": function() { + return "38DD38"; + } + }, + "highlighted": { + "color": function() { + return "#EEEEFF"; + } + }, + "hidden": { + "color": function() { + return "none"; + }, + "borderColor": function() { + return "none"; + } + } + } + }, + "edgeStyle": { + "all": { + "width": 4, + "color": "#333", + "opacity": 0.4, + "directed": false, + "curved": false, + "selected": { + "color": "#38DD38", + "opacity": 0.9 + }, + "highlighted": { + "color": "#383838", + "opacity": 0.7 + }, + "hidden": { + "opacity": 0 + } + } + } + } + }; + + Alchemy.prototype.exports = function(instance) { + var a; + a = instance; + return { + init: function() { + return a.exports.show(); + }, + show: function() { + return a.dash.select("#all-exports").append("li").attr({ + "class": "list-group-item active-label toggle" + }).html("SVG").on("click", function(e) { + var sanitizedUrl, str, svg, url, win; + svg = d3.select("" + a.conf.divSelector + " svg").node(); + str = (new XMLSerializer).serializeToString(svg); + url = "data:image/svg+xml;utf8," + str; + sanitizedUrl = url.replace("xlink:", ""); + win = window.open(sanitizedUrl); + return win.focus(); + }); + } + }; + }; + + warnings = (function() { + function warnings(instance) { + this.dataWarning = __bind(this.dataWarning, this); + this.a = instance; + } + + warnings.prototype.dataWarning = function() { + if (this.a.conf.dataWarning && typeof this.a.conf.dataWarning === 'function') { + return this.a.conf.dataWarning(); + } else if (this.a.conf.dataWarning === 'default') { + return console.log("No dataSource was loaded"); + } + }; + + warnings.prototype.divWarning = function() { + return "create an element that matches the value for 'divSelector' in your conf.\nFor instance, if you are using the default 'divSelector' conf, simply provide\n
      ."; + }; + + return warnings; + + })(); + +}).call(this); + +//# sourceMappingURL=alchemy.js.map diff --git a/EHEC_Server/EHEC_Server/alchemy/alchemy.min.css b/EHEC_Server/EHEC_Server/alchemy/alchemy.min.css new file mode 100644 index 0000000..c665783 --- /dev/null +++ b/EHEC_Server/EHEC_Server/alchemy/alchemy.min.css @@ -0,0 +1 @@ +@-webkit-keyframes fadeIn{0%{opacity:0}25%{opacity:.3}50%{opacity:.66}75%{opacity:1}}@keyframes fadeIn{0%{opacity:0}25%{opacity:.3}50%{opacity:.66}75%{opacity:1}}@-webkit-keyframes pulse{0%{text-shadow:0 0 10px rgba(255,255,255,.2),0 0 12px rgba(255,255,255,.2),0 0 16px rgba(255,255,255,.2)}25%{text-shadow:0 0 12px rgba(255,255,255,.2),0 0 15px rgba(255,255,255,.2),0 0 20px rgba(255,255,255,.2),0 0 6px rgba(104,185,254,.7),0 0 10px rgba(104,185,254,.7)}50%{text-shadow:0 0 12px rgba(255,255,255,.2),0 0 15px rgba(255,255,255,.2),0 0 20px rgba(255,255,255,.2),0 0 8px rgba(104,185,254,.7),0 0 10px rgba(104,185,254,.7),0 0 15px rgba(104,185,254,.7)}75%{text-shadow:0 0 12px rgba(255,255,255,.2),0 0 15px rgba(255,255,255,.2),0 0 25px rgba(255,255,255,.2),0 0 8px rgba(104,185,254,.7),0 0 12px rgba(104,185,254,.7),0 0 15px rgba(104,185,254,.7),0 0 20px rgba(104,185,254,.7)}}@keyframes pulse{0%{text-shadow:0 0 10px rgba(255,255,255,.2),0 0 12px rgba(255,255,255,.2),0 0 16px rgba(255,255,255,.2)}25%{text-shadow:0 0 12px rgba(255,255,255,.2),0 0 15px rgba(255,255,255,.2),0 0 20px rgba(255,255,255,.2),0 0 6px rgba(104,185,254,.7),0 0 10px rgba(104,185,254,.7)}50%{text-shadow:0 0 12px rgba(255,255,255,.2),0 0 15px rgba(255,255,255,.2),0 0 20px rgba(255,255,255,.2),0 0 8px rgba(104,185,254,.7),0 0 10px rgba(104,185,254,.7),0 0 15px rgba(104,185,254,.7)}75%{text-shadow:0 0 12px rgba(255,255,255,.2),0 0 15px rgba(255,255,255,.2),0 0 25px rgba(255,255,255,.2),0 0 8px rgba(104,185,254,.7),0 0 12px rgba(104,185,254,.7),0 0 15px rgba(104,185,254,.7),0 0 20px rgba(104,185,254,.7)}}@-webkit-keyframes slide-in{0%{-webkit-transform:translate(-100%,0);transform:translate(-100%,0)}100%{-webkit-transform:translate(0%,0);transform:translate(0%,0)}}@keyframes slide-in{0%{-webkit-transform:translate(-100%,0);transform:translate(-100%,0)}100%{-webkit-transform:translate(0%,0);transform:translate(0%,0)}}@-webkit-keyframes slide-out{0%{-webkit-transform:translate(0%,0);transform:translate(0%,0)}100%{-webkit-transform:translate(-100%,0);transform:translate(-100%,0)}}@keyframes slide-out{100%{-webkit-transform:translate(-100%,0);transform:translate(-100%,0)}}svg{position:absolute;left:0;cursor:-webkit-grab;height:100%;width:100%;color:#333}.node{cursor:pointer}.node text.root{font-size:32px}.node text{display:none;fill:#fff;font-weight:200;text-anchor:middle;z-index:1000;text-shadow:1px 1px #333,-1px 1px #333,1px -1px #333,-1px -1px #333}.node.active{opacity:1}.node.active.selected text,.node.active:hover text{display:block}defs #arrow path{stroke:#CCC;stroke-opacity:.2;fill:#CCC;opacity:1}.edge text{stroke-width:0}.edge .edge-handler{fill:none;stroke:none}.edge .edge-line{fill:none}.edge.active text{display:none;fill:#fff;font-weight:200;text-anchor:middle;text-shadow:1px 1px #333,-1px 1px #333,1px -1px #333,-1px -1px #333;z-index:1000}.edge.active.selected,.edge.active:hover{cursor:pointer}.edge.active.highlight text,.edge.active.selected text,.edge.active:hover text{display:block}#zoom-controls{background-color:transparent;background-image:url(images/maze-black.png);border-top-right-radius:3px;border-bottom-right-radius:3px;box-shadow:0 0 5px rgba(255,255,255,.3);margin-top:10%;z-index:5;position:relative;display:block;width:55px}#zoom-controls #zoom-in,#zoom-controls #zoom-out,#zoom-controls #zoom-reset{padding:12px;margin:0;width:100%}#zoom-controls #zoom-in i,#zoom-controls #zoom-out i,#zoom-controls #zoom-reset i{color:#E89619}#zoom-controls #zoom-in:hover,#zoom-controls #zoom-out:hover,#zoom-controls #zoom-reset:hover{background-color:rgba(255,255,255,.2)}#zoom-controls #zoom-in:active,#zoom-controls #zoom-out:active,#zoom-controls #zoom-reset:active{border:0}.fa-caret-down,.fa-caret-right,.fa-search{margin:0 5px;color:#e89619}#search{margin-top:2em;margin-bottom:1em;padding:.5em 1em;width:100%}#search span{vertical-align:bottom}#search input{background-color:#000;border:0;font-size:20px;color:#fff;padding-left:.5em}#search .search-icon{height:22px;background-color:#000;border-color:#000;border-right-color:#111}#stats{padding:.5em 1em;background-color:transparent;border-bottom:thin dashed #e89619}#stats #stats-header{padding:10px}#stats #all-stats{color:#fff;border-radius:none;border:0;background:0 0;overflow:auto}#stats #all-stats li{padding:3px}#stats #edge-stats-graph,#stats #node-stats-graph{height:250px}#stats #edge-stats-graph svg,#stats #node-stats-graph svg{opacity:.6;background:0 0}#stats #edge-stats-graph text,#stats #node-stats-graph text{font-size:16px;fill:#fff;font-weight:200;text-anchor:middle;z-index:1000}#stats #edge-stats-graph .no-data,#stats #node-stats-graph .no-data{margin:30px 0;color:#e89619}#stats .badge{border-radius:0;height:100%;background-color:rgba(104,185,254,.6)}#editor{padding:.5em 1em;background-color:transparent;border-bottom:thin dashed #e89619}#editor h3{padding:10px}#editor #element-options{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;cursor:pointer;margin-top:10px;margin-left:2%;color:#fff}#editor #element-options #add-property-form,#editor #element-options .property{display:-webkit-inline-flex;display:inline-flex;margin:4px 0;width:100%}#editor #element-options #add-property-form #add-property #add-prop-value,#editor #element-options .property-value{border:thin rgba(255,255,255,.2) solid;border-left:0;background-color:#000;color:#fff;width:100%;border-top-left-radius:0;border-bottom-left-radius:0}#editor #element-options #add-property-form #add-property #add-prop-key,#editor #element-options .property-name{text-align:center;font-weight:200;cursor:default;background:#2E2E2E;border:thin transparent solid;color:#e89619;border-right:0;border-top-right-radius:0;border-bottom-right-radius:0}#editor #element-options #update-properties,#editor #element-options input[type=submit]{color:#e89619;border-top-right-radius:4px;border-bottom-right-radius:4px;width:auto;background:rgba(255,255,255,.1);border:thin solid #e89619;text-align:center}#editor #element-options #update-properties:active,#editor #element-options #update-properties:focus,#editor #element-options input[type=submit]:active,#editor #element-options input[type=submit]:focus{outline:0}#editor #element-options #update-properties:hover,#editor #element-options input[type=submit]:hover{color:#fff;border:thin solid #fff}#editor #element-options #update-properties{border-radius:4px;padding:10px;width:100%;margin-bottom:20px}#editor #element-options #add-property-form #add-property{display:-webkit-flex;display:flex;-webkit-flex-grow:2;flex-grow:2;-webkit-flex-direction:column;flex-direction:column}#editor #element-options #add-property-form #add-property #add-prop-value{text-align:center;width:100%;border-top-right-radius:0;border-bottom-right-radius:0;border-bottom-left-radius:4px;border:thin rgba(255,255,255,.2) solid}#editor #element-options #add-property-form #add-property #add-prop-key{cursor:text;width:100%;border-top-left-radius:4px;border-bottom-left-radius:0}#editor #editor-interactions.active{color:#e89619}#editor #editor-interactions.inactive{color:#fff}#editor #edge-editor.enabled,#editor #node-editor.enabled{-webkit-animation:fadeIn 1s linear;animation:fadeIn 1s linear}#control-dash-wrapper{font-family:'Source Sans Pro',Helvetica,sans-serif;letter-spacing:.05em;height:inherit;z-index:inherit;padding:0}#control-dash-wrapper.initial{-webkit-transform:translate(-100%,0);transform:translate(-100%,0)}#control-dash-wrapper.initial #dash-toggle{color:#e89619;-webkit-animation:4s pulse linear;animation:4s pulse linear}#control-dash-wrapper.off-canvas{-webkit-transform:translate(-100%,0);transform:translate(-100%,0);-webkit-animation:slide-out .75s linear;animation:slide-out .75s linear}#control-dash-wrapper.off-canvas #dash-toggle{color:#e89619;-webkit-animation:4s pulse linear;animation:4s pulse linear}#control-dash-wrapper.on-canvas{-webkit-animation:slide-in .75s ease-in-out;animation:slide-in .75s ease-in-out}#control-dash-wrapper.on-canvas *{box-shadow:none!important}#control-dash-wrapper.on-canvas #dash-toggle{color:rgba(232,150,25,.6)}#control-dash-wrapper.on-canvas #dash-toggle:hover{color:#e89619;-webkit-animation:4s pulse linear;animation:4s pulse linear}#control-dash-wrapper #control-dash{overflow-x:hidden;overflow-y:scroll;background-color:transparent;background-image:url(images/maze-black.png);padding:0;height:inherit;z-index:5}#control-dash-wrapper #control-dash h3{display:inline;margin:0}#control-dash-wrapper #dash-toggle{z-index:5;background-color:transparent;background-image:url(images/maze-black.png);border-top-right-radius:3px;border-bottom-right-radius:3px;box-shadow:0 0 5px rgba(255,255,255,.3);position:absolute;left:0;top:50%;font-size:2.2em;color:rgba(255,255,255,.2);padding:10px}#control-dash-wrapper button{border-radius:0;border:0;background-color:transparent}#control-dash-wrapper button:active{border:0}#control-dash-wrapper h3{font-weight:200;margin-top:10px;color:#fff;cursor:pointer;vertical-align:top}#control-dash-wrapper li{cursor:pointer;background:0 0;border:0;border-radius:0}#clustering{padding:.5em 1em;cursor:pointer;color:#fff;border-bottom:thin dashed #E89619}#clustering #cluster-key-container,#clustering #cluster_control_header{padding:10px 10px 0}#clustering #cluster-key{color:#333;background-color:#000;border-radius:4px;border:thin solid #333;text-align:center;display:inline-block;width:100%}#filters{padding:.5em 1em;background-color:transparent;border-bottom:thin dashed #e89619;color:#fff}#filters form{width:100%}#filters #filter-header{padding:10px}#filters #filter-nodes,#filters #filter-relationships{background-color:transparent;display:inline-block;width:45%;margin-left:2%;overflow:auto;text-align:center;vertical-align:top}#filters #filter-nodes #filter-node-header,#filters #filter-nodes #filter-rel-header,#filters #filter-relationships #filter-node-header,#filters #filter-relationships #filter-rel-header{margin:10px 0;cursor:pointer;background-color:transparent;border:0;border-radius:0;width:100%}#filters #filter-nodes #filter-node-header h4,#filters #filter-nodes #filter-rel-header h4,#filters #filter-relationships #filter-node-header h4,#filters #filter-relationships #filter-rel-header h4{font-weight:200;display:inline;color:#fff}#filters #filter-nodes #filter-node-header:active,#filters #filter-nodes #filter-rel-header:active,#filters #filter-relationships #filter-node-header:active,#filters #filter-relationships #filter-rel-header:active{border:0;box-shadow:none}#filters #filter-nodes #node-dropdown,#filters #filter-nodes #rel-dropdown,#filters #filter-relationships #node-dropdown,#filters #filter-relationships #rel-dropdown{margin:20px 0;border-radius:none;border:0;background:0 0}#filters #filter-nodes #node-dropdown li,#filters #filter-nodes #rel-dropdown li,#filters #filter-relationships #node-dropdown li,#filters #filter-relationships #rel-dropdown li{padding:5px}#filters #filter-nodes #node-dropdown li:hover,#filters #filter-nodes #rel-dropdown li:hover,#filters #filter-relationships #node-dropdown li:hover,#filters #filter-relationships #rel-dropdown li:hover{background-color:rgba(255,255,255,.2)}#filters .disabled{color:rgba(255,255,255,.5)}#filters .disabled:hover{color:#fdc670}.alchemy{position:relative}.alchemy #search form{z-index:2;display:inline;margin-left:100px}.alchemy #add-tag{width:300px;display:inline-block}.alchemy #tags input{max-width:220px}.alchemy #tags-list{padding:0}.alchemy #tags-list .icon-remove-sign{cursor:pointer}.alchemy #tags-list li{display:inline-block;margin-top:5px}.alchemy #tags-list span{background-color:#ccc;color:#333;border-radius:10em;display:inline-block;padding:1px 6px}.alchemy #filter-nodes label,.alchemy #filter-relationships label{font-weight:400;margin-right:1em}.alchemy .clear{clear:both}.alchemy text{font-weight:200;text-anchor:middle} \ No newline at end of file diff --git a/EHEC_Server/EHEC_Server/alchemy/alchemy.min.js b/EHEC_Server/EHEC_Server/alchemy/alchemy.min.js new file mode 100644 index 0000000..5f43854 --- /dev/null +++ b/EHEC_Server/EHEC_Server/alchemy/alchemy.min.js @@ -0,0 +1,3 @@ +(function(){"Alchemy.js is a graph drawing application for the web.\nCopyright (C) 2014 GraphAlchemist, Inc.\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU Affero General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU Affero General Public License for more details.\n\nYou should have received a copy of the GNU Affero General Public License\nalong with this program. If not, see .\nlets";var a,b,c,d,e,f,g,h,i,j,k,l,m=[].slice,n=function(a,b){return function(){return a.apply(b,arguments)}};a=function(){function a(a){null==a&&(a=null),this.a=this,this.version="0.4.1",this.get=new this.Get(this),this.remove=new this.Remove(this),this.create=new this.Create(this),this.set=new this.Set(this),this.drawing={DrawEdge:c(this),DrawEdges:d(this),DrawNode:e(this),DrawNodes:f(this),EdgeUtils:this.EdgeUtils(this),NodeUtils:this.NodeUtils(this)},this.controlDash=this.controlDash(this),this.stats=this.stats(this),this.layout=j,this.clustering=b,this.models={Node:this.Node(this),Edge:this.Edge(this)},this.utils={warnings:new l(this)},this.filters=this.filters(this),this.exports=this.exports(this),this.visControls={},this.styles={},this.editor={},this.log={},this.state={interactions:"default",layout:"default"},this.startGraph=this.startGraph(this),this.updateGraph=this.updateGraph(this),this.generateLayout=this.generateLayout(this),this.svgStyles=this.svgStyles(this),this.interactions=this.interactions(this),this.search=this.search(this),this.plugins=this.plugins(this),this._nodes={},this._edges={},this.getNodes=this.get.getNodes,this.getEdges=this.get.getEdges,this.allNodes=this.get.allNodes,this.allEdges=this.get.allEdges,a&&this.begin(a)}return a.prototype.begin=function(b){var c;switch(c=this.setConf(b),typeof this.conf.dataSource){case"string":d3.json(this.a.conf.dataSource,this.a.startGraph);break;case"object":this.a.startGraph(this.a.conf.dataSource)}return this.plugins.init(),a.prototype.instances.push(this),this},a.prototype.setConf=function(a){var b,c;null!=a.theme&&(a=_.merge(_.cloneDeep(this.defaults),this.a.themes[""+a.theme]));for(b in a)switch(c=a[b],b){case"clusterColors":a.clusterColours=c;break;case"backgroundColor":a.backgroundColour=c;break;case"nodeColor":a[nodeColour]=c}return this.a.conf=_.merge(_.cloneDeep(this.defaults),a)},a.prototype.instances=[],a.prototype.getInst=function(b){var c;return c=parseInt(d3.select(b).attr("alchInst")),a.prototype.instances[c]},a}(),k="undefined"!=typeof exports&&null!==exports?exports:this,k.Alchemy=a,k.alchemy={begin:function(b){return k.alchemy=new a(b)}},a.prototype.Create=function(){function a(a){this.a=a}return a.prototype.nodes=function(){var a,b,c,d,e,f,g;for(c=arguments[0],d=2<=arguments.length?m.call(arguments,1):[],a=this.a,e=function(b){var c;return a._nodes[b.id]?console.warn("A node with the id "+b.id+" already exists.\nConsider using the @a.get.nodes() method to \nretrieve the node and then using the Node methods."):(c=new a.models.Node(b),a._nodes[b.id]=c,[c])},d=_.union(d,c),f=0,g=d.length;g>f;f++)b=d[f],e(b);return this.a.initial?this.a.updateGraph():void 0},a.prototype.edges=function(){var a,b,c,d,e;return c=arguments[0],d=2<=arguments.length?m.call(arguments,1):[],a=this.a,e=function(b){var c,d;return b.id&&!a._edges[b.id]?(c=new a.models.Edge(b),a._edges[b.id]=[c],[c]):b.id&&a._edges[b.id]?console.warn("An edge with that id "+someEdgeMap.id+" already exists.\nConsider using the @a.get.edge() method to \nretrieve the edge and then using the Edge methods.\nNote: id's are not required for edges. Alchemy will create\nan unlimited number of edges for the same source and target node.\nSimply omit 'id' when creating the edge."):(d=a._edges[""+b.source+"-"+b.target],d?(c=new a.models.Edge(b,d.length),d.push(c),[c]):(c=new a.models.Edge(b,0),a._edges[""+b.source+"-"+b.target]=[c],[c]))},b=_.uniq(_.flatten(arguments)),_.each(b,function(a){return e(a)}),this.a.initial?this.a.updateGraph():void 0},a}(),a.prototype.Get=function(a){return{a:a,_el:[],_elType:null,_makeChain:function(a){var b;for(b=this,b.__proto__=[].__proto__;b.length;)b.pop();return _.each(a,function(a){return b.push(a)}),b},nodes:function(){var a,b,c,d,e;return c=arguments[0],d=2<=arguments.length?m.call(arguments,1):[],null!=c&&(b=_.map(arguments,function(a){return String(a)}),a=this.a,e=function(a){return _.filter(a._nodes,function(a,c){return _.contains(b,c)?a:void 0})}(a)),this._elType="node",this._el=e,this._makeChain(e)},edges:function(){var a,b,c,d,e;return d=arguments[0],e=2<=arguments.length?m.call(arguments,1):[],null!=d&&(b=_.map(arguments,function(a){return String(a)}),a=this.a,c=function(a){return _.flatten(_.filter(a._edges,function(a,c){return _.contains(b,c)?a:void 0}))}(a)),this._elType="edge",this._el=c,this._makeChain(c)},all:function(){var a,b;return a=this.a,b=this._elType,this._el=function(b){switch(b){case"node":return a.elements.nodes.val;case"edge":return a.elements.edges.flat}}(b),this._makeChain(this._el)},elState:function(a){var b;return b=_.filter(this._el,function(b){return b._state===a}),this._el=b,this._makeChain(b)},state:function(){return null!=this.a.state.key?this.a.state.key:void 0},type:function(a){var b;return b=_.filter(this._el,function(b){return b._nodeType===a||b._edgeType===a}),this._el=b,this._makeChain(b)},activeNodes:function(){return _.filter(this.a._nodes,function(a){return"active"===a._state?a:void 0})},activeEdges:function(){return _.filter(this.a.get.allEdges(),function(a){return"active"===a._state?a:void 0})},state:function(){return null!=this.a.state.key?this.a.state.key:void 0},clusters:function(){var a,b;return a=this.a.layout._clustering.clusterMap,b={},_.each(a,function(a,c){return b[c]=_.select(this.a.get.allNodes(),function(a){return a.getProperties()[this.a.conf.clusterKey]===c})}),b},clusterColours:function(){var a,b;return b=this.a.layout._clustering.clusterMap,a={},_.each(b,function(b,c){return a[c]=this.a.conf.clusterColours[b%this.a.conf.clusterColours.length]}),a},allEdges:function(){return this.a.elements.nodes.flat},allNodes:function(a){return null!=a?_.filter(this.a._nodes,function(b){return b._nodeType===a?b:void 0}):this.a.elements.nodes.val},getNodes:function(){var a,b,c;return b=arguments[0],c=2<=arguments.length?m.call(arguments,1):[],a=this.a,c.push(b),_.map(c,function(b){return a._nodes[b]})},getEdges:function(a,b){var c,d;return null==a&&(a=null),null==b&&(b=null),c=this.a,null!=a&&null!=b?(d=""+a+"-"+b,this.a._edges[d]):null!=a&&null==b?this.a._nodes[a]._adjacentEdges:void 0}}},a.prototype.Remove=function(){function a(a){this.a=a}return a.prototype.nodes=function(a){return _.each(a,function(a){return null!=a._nodeType?a.remove():void 0})},a.prototype.edges=function(a){return _.each(a,function(a){return null!=a._edgeType?a.remove():void 0})},a}(),a.prototype.Set=function(a){return{a:a,state:function(a,b){return this.a.state.key=b}}},b=function(){function a(a){var b,c,d,e,f,g,h,i;this.a=a,d=this.a._nodes,c=this.a.conf,b=this,this.clusterKey=c.clusterKey,this.identifyClusters(this.a),e=-500,i=function(a){var b,c;return b=d[a.source.id]._properties[this.clusterKey],c=d[a.target.id]._properties[this.clusterKey],b===c?.15:0},f=function(){return.7},h=function(a){return d=a.self.a._nodes,d[a.source.id]._properties.root||d[a.target.id]._properties.root?300:d[a.source.id]._properties[this.clusterKey]===d[a.target.id]._properties[this.clusterKey]?10:600},g=function(a){return 8*a},this.layout={charge:e,linkStrength:function(a){return i(a)},friction:function(){return f()},linkDistancefn:function(a){return h(a)},gravity:function(a){return g(a)}}}return a.prototype.identifyClusters=function(a){var b,c,d;return c=a.elements.nodes.val,b=_.uniq(_.map(c,function(b){return b.getProperties()[a.conf.clusterKey]})),this.clusterMap=_.zipObject(b,function(){d=[];for(var a=0,c=b.length;c>=0?c>=a:a>=c;c>=0?a++:a--)d.push(a);return d}.apply(this))},a.prototype.getClusterColour=function(a){var b;return b=this.clusterMap[a]%this.a.conf.clusterColours.length,this.a.conf.clusterColours[b]},a.prototype.edgeGradient=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o;for(c=this.a.vis.select(""+this.a.conf.divSelector+" svg"),b={},j=this.a._nodes,n=_.map(a,function(a){return a._d3}),l=0,m=n.length;m>l;l++)if(d=n[l],!j[d.source.id]._properties.root&&!j[d.target.id]._properties.root&&j[d.source.id]._properties[this.clusterKey]!==j[d.target.id]._properties[this.clusterKey]&&j[d.target.id]._properties[this.clusterKey]!==j[d.source.id]._properties[this.clusterKey]){if(h=j[d.source.id]._properties[this.clusterKey]+"-"+j[d.target.id]._properties[this.clusterKey],h in b)continue;h in b||(k=this.getClusterColour(j[d.target.id]._properties[this.clusterKey]),e=this.getClusterColour(j[d.source.id]._properties[this.clusterKey]),b[h]={startColour:k,endColour:e})}o=[];for(i in b)g="cluster-gradient-"+i,f=c.append("svg:linearGradient").attr("id",g),f.append("svg:stop").attr("offset","0%").attr("stop-color",b[i].startColour),o.push(f.append("svg:stop").attr("offset","100%").attr("stop-color",b[i].endColour));return o},a}(),a.prototype.clusterControls={init:function(){var a;return a="",this.a.dash.select("#clustering-container").append("div").attr("id","cluster-key-container").attr("class","property form-inline form-group").html(a).style("display","none"),this.a.dash.select("#cluster_control_header").on("click",function(){var a,b;return b=this.a.dash.select("#cluster-key-container"),a=b.style("display")}),element.style("display",function(){return"block"===display?"none":"block"}),"none"===this.a.dash.select("#cluster-key-container").style("display")?this.a.dash.select("#cluster-arrow").attr("class","fa fa-2x fa-caret-right"):this.a.dash.select("#cluster-arrow").attr("class","fa fa-2x fa-caret-down"),this.a.dash.select("#cluster-key").on("keydown",function(){return"Enter"===d3.event.keyIdentifier?(this.a.conf.cluster=!0,this.a.conf.clusterKey=this.value,this.a.generateLayout()):void 0})}},a.prototype.controlDash=function(a){var b;return b=a,{init:function(){var a;return this.dashIsShown()?(a=b.conf.divSelector,b.dash=d3.select(""+a).append("div").attr("id","control-dash-wrapper").attr("class","col-md-4 initial"),b.dash.append("i").attr("id","dash-toggle").attr("class","fa fa-flask col-md-offset-12"),b.dash.append("div").attr("id","control-dash").attr("class","col-md-12"),b.dash.select("#dash-toggle").on("click",b.interactions.toggleControlDash),b.controlDash.zoomCtrl(),b.controlDash.search(),b.controlDash.filters(),b.controlDash.stats(),b.controlDash.clustering(),b.controlDash.exports()):void 0},search:function(){return b.conf.search?(b.dash.select("#control-dash").append("div").attr("id","search").html("
      \n \n \n
      "),b.search.init()):void 0},zoomCtrl:function(){return b.conf.zoomControls?(b.dash.select("#control-dash-wrapper").append("div").attr("id","zoom-controls").attr("class","col-md-offset-12").html(" "),b.dash.select("#zoom-in").on("click",function(){return b.interactions.clickZoom("in")}),b.dash.select("#zoom-out").on("click",function(){return b.interactions.clickZoom("out")}),b.dash.select("#zoom-reset").on("click",function(){return b.interactions.clickZoom("reset")})):void 0},filters:function(){return b.conf.nodeFilters||b.conf.edgeFilters?(b.dash.select("#control-dash").append("div").attr("id","filters"),b.filters.init()):void 0},stats:function(){var a;return b.conf.nodeStats||b.conf.edgeStats?(a='
      \n

      \n Statistics\n

      \n\n
      \n
      \n
        \n
          \n
          ',b.dash.select("#control-dash").append("div").attr("id","stats").html(a).select("#stats-header").on("click",function(){return b.dash.select("#all-stats").classed("in")?b.dash.select("#stats-header>span").attr("class","fa fa-2x fa-caret-right"):b.dash.select("#stats-header>span").attr("class","fa fa-2x fa-caret-down")}),b.stats.init()):void 0},exports:function(){var a;return b.conf.exportSVG?(a='
          \n

          \n Exports\n

          \n \n
          \n
          ',b.dash.select("#control-dash").append("div").attr("id","exports").attr("style","padding: 0.5em 1em; border-bottom: thin dashed #E89619; color: white;").html(a).select("#exports-header"),b.exports.init()):void 0},clustering:function(){var a;return b.conf.clusterControl?(a='
          \n
          \n

          Clustering

          \n \n
          \n
          ',b.dash.select("#control-dash").append("div").attr("id","clustering").html(a).select("#cluster_control_header"),b.clusterControls.init()):void 0},dashIsShown:function(){var a;return a=b.conf,a.showEditor||a.captionToggle||a.toggleRootNodes||a.removeElement||a.clusterControl||a.nodeStats||a.edgeStats||a.edgeFilters||a.nodeFilters||a.edgesToggle||a.nodesToggle||a.search||a.exportSVG}}},a.prototype.filters=function(){return function(a){var b;return b=a,{init:function(){var a,c,d,e,f,g,h,i,j,k,l,m;if(b.filters.show(),b.conf.edgeFilters&&b.filters.showEdgeFilters(),b.conf.nodeFilters&&b.filters.showNodeFilters(),b.conf.nodeTypes){for(e=Object.keys(b.conf.nodeTypes),g="",m=b.conf.nodeTypes[e],i=0,k=m.length;k>i;i++)f=m[i],a=f.replace("_"," "),g+="";b.dash.select("#node-dropdown").html(g)}if(b.conf.edgeTypes){for(h=_.isPlainObject(b.conf.edgeTypes)?_.values(b.conf.edgeTypes)[0]:b.conf.edgeTypes,d="",j=0,l=h.length;l>j;j++)c=h[j],a=c.replace("_"," "),d+="";b.dash.select("#rel-dropdown").html(d)}return b.conf.captionsToggle&&b.filters.captionsToggle(),b.conf.edgesToggle&&b.filters.edgesToggle(),b.conf.nodesToggle&&b.filters.nodesToggle(),b.filters.update()},show:function(){var a;return a='
          \n

          Filters

          \n \n
          \n
          \n
          ',b.dash.select("#control-dash #filters").html(a),b.dash.selectAll("#filter-header").on("click",function(){return b.dash.select("#filters>form").classed("in")?b.dash.select("#filter-header>span").attr("class","fa fa-2x fa-caret-right"):b.dash.select("#filter-header>span").attr("class","fa fa-2x fa-caret-down")}),b.dash.select("#filters form")},showEdgeFilters:function(){var a;return a='
          \n

          \n Edge Types\n

          \n \n
          \n',b.dash.select("#filters form").append("div").attr("id","filter-relationships").html(a),b.dash.select("#filter-rel-header").on("click",function(){return b.dash.select("#rel-dropdown").classed("in")?b.dash.select("#filter-rel-header>span").attr("class","fa fa-lg fa-caret-right"):b.dash.select("#filter-rel-header>span").attr("class","fa fa-lg fa-caret-down")})},showNodeFilters:function(){var a;return a='
          \n

          \n Node Types\n

          \n \n
          \n',b.dash.select("#filters form").append("div").attr("id","filter-nodes").html(a),b.dash.select("#filter-node-header").on("click",function(){return b.dash.select("#node-dropdown").classed("in")?b.dash.select("#filter-node-header>span").attr("class","fa fa-lg fa-caret-right"):b.dash.select("#filter-node-header>span").attr("class","fa fa-lg fa-caret-down")})},captionsToggle:function(){return b.dash.select("#filters form").append("li").attr({id:"toggle-captions","class":"list-group-item active-label toggle"}).html("Show Captions").on("click",function(){var a;return a=b.dash.select("g text").attr("style"),"display: block"===a?b.dash.selectAll("g text").attr("style","display: none"):b.dash.selectAll("g text").attr("style","display: block")})},edgesToggle:function(){return b.dash.select("#filters form").append("li").attr({id:"toggle-edges","class":"list-group-item active-label toggle"}).html("Toggle Edges").on("click",function(){return _.contains(_.pluck(_.flatten(_.values(b._edges)),"_state"),"active")?_.each(_.values(b._edges),function(a){return _.each(a,function(a){return"active"===a._state?a.toggleHidden():void 0})}):_.each(_.values(b._edges),function(a){return _.each(a,function(a){var c,d;return c=b._nodes[a._properties.source],d=b._nodes[a._properties.target],"active"===c._state&&"active"===d._state?a.toggleHidden():void 0})})})},nodesToggle:function(){return b.dash.select("#filters form").append("li").attr({id:"toggle-nodes","class":"list-group-item active-label toggle"}).html("Toggle Nodes").on("click",function(){var a;return a=_.values(b._nodes),_.contains(_.pluck(a,"_state"),"active")?_.each(a,function(a){return b.conf.toggleRootNodes&&a._d3.root?void 0:"active"===a._state?a.toggleHidden():void 0}):_.each(_.values(b._nodes),function(a){return b.conf.toggleRootNodes&&a._d3.root?void 0:a.toggleHidden()})})},update:function(){return b.dash.selectAll(".nodeType, .edgeType").on("click",function(){var a,c;return a=d3.select(this),c=a.attr("name"),b.vis.selectAll("."+c).each(function(a){var c,d,e,f;return null!=b._nodes[a.id]?(d=b._nodes[a.id],d.toggleHidden()):(c=b._edges[a.id][0],e=b._nodes[c._properties.source],f=b._nodes[c._properties.target],"active"===e._state&&"active"===f._state?c.toggleHidden():void 0)}),b.stats.nodeStats()})}}}}(this),a.prototype.Index=function(a){var b,c,d,e;return b=a,d={nodes:{val:function(){return _.values(b._nodes)}()},edges:{val:function(){return _.values(b._edges)}()}},e=d.nodes,c=d.edges,d.edges.flat=function(){return _.flatten(c.val)}(),d.nodes.d3=function(){return _.map(e.val,function(a){return a._d3})}(),d.edges.d3=function(){return _.map(c.flat,function(a){return a._d3})}(),b.elements=d,function(){return b.elements.nodes.svg=function(){return b.vis.selectAll("g.node")}(),b.elements.edges.svg=function(){return b.vis.selectAll("g.edge")}()}},a.prototype.interactions=function(b){var c;return c=b,{edgeClick:function(a){var b;if(!d3.event.defaultPrevented)return d3.event.stopPropagation(),b=a.self,"function"==typeof c.conf.edgeClick&&c.conf.edgeClick(b),"hidden"!==b._state?(b._state=function(){return"selected"===b._state?"active":"selected"}(),b.setStyles()):void 0},edgeMouseOver:function(a){var b;return b=a.self,"hidden"!==b._state?("selected"!==b._state&&(b._state="highlighted"),b.setStyles()):void 0},edgeMouseOut:function(a){var b;return b=a.self,"hidden"!==b._state?("selected"!==b._state&&(b._state="active"),b.setStyles()):void 0},nodeMouseOver:function(a){var b;if(b=a.self,"hidden"!==b._state){if("selected"!==b._state&&(b._state="highlighted",b.setStyles()),"function"==typeof c.conf.nodeMouseOver)return c.conf.nodeMouseOver(b);if("number"==typeof c.conf.nodeMouseOver)return b.properties[c.conf.nodeMouseOver]}},nodeMouseOut:function(a){var b;return b=a.self,c=b.a,"hidden"!==b._state&&("selected"!==b._state&&(b._state="active",b.setStyles()),null!=c.conf.nodeMouseOut&&"function"==typeof c.conf.nodeMouseOut)?c.conf.nodeMouseOut(a):void 0},nodeClick:function(a){var b;if(!d3.event.defaultPrevented)return d3.event.stopPropagation(),b=a.self,"function"==typeof c.conf.nodeClick&&c.conf.nodeClick(b),"hidden"!==b._state?(b._state=function(){return"selected"===b._state?"active":"selected"}(),b.setStyles()):void 0},zoom:function(b){return null==this._zoomBehavior&&(this._zoomBehavior=d3.behavior.zoom()),this._zoomBehavior.scaleExtent(b).on("zoom",function(){return c=a.prototype.getInst(this),c.vis.attr("transform","translate("+d3.event.translate+") scale("+d3.event.scale+")")})},clickZoom:function(a){var b,d,e,f;return f=c.vis.attr("transform").match(/(-*\d+\.*\d*)/g).map(function(a){return parseFloat(a)}),d=f[0],e=f[1],b=f[2],c.vis.attr("transform",function(){return"in"===a?(bc.conf.scaleExtent[0]&&(b-=.2),"translate("+d+","+e+") scale("+b+")"):"reset"===a?"translate(0,0) scale(1)":console.log("error")}),null==this._zoomBehavior&&(this._zoomBehavior=d3.behavior.zoom()),this._zoomBehavior.scale(b).translate([d,e])},nodeDragStarted:function(a){return d3.event.preventDefault,d3.event.sourceEvent.stopPropagation(),d3.select(this).classed("dragging",!0),a.fixed=!0},nodeDragged:function(a){var b,d;return c=a.self.a,a.x+=d3.event.dx,a.y+=d3.event.dy,a.px+=d3.event.dx,a.py+=d3.event.dy,d=d3.select(this),d.attr("transform","translate("+a.x+", "+a.y+")"),b=a.self._adjacentEdges,_.each(b,function(a){var b;return b=c.vis.select("#edge-"+a.id+"-"+a._index),c._drawEdges.updateEdge(b.data()[0])})},nodeDragended:function(a){return c=a.self.a,d3.select(this).classed({dragging:!1}),c.conf.forceLocked?void 0:c.force.start()},nodeDoubleClick:function(){return null},deselectAll:function(){var b;return c=a.prototype.getInst(this),(null!=(b=d3.event)?b.defaultPrevented:0)?void 0:(c.conf.showEditor===!0&&c.modifyElements.nodeEditorClear(),_.each(c._nodes,function(a){return a._state="active",a.setStyles()}),_.each(c._edges,function(a){return _.each(a,function(a){return a._state="active",a.setStyles()})}),c.conf.deselectAll?c.conf.deselectAll():void 0)}}},j=function(){function a(a){this.tick=n(this.tick,this),this.linkStrength=n(this.linkStrength,this),this.gravity=n(this.gravity,this);var b,c,d;this.a=b=a,c=this.a.conf,d=this.a._nodes,this.k=Math.sqrt(Math.log(_.size(this.a._nodes))/(c.graphWidth()*c.graphHeight())),this._clustering=new this.a.clustering(this.a),this.d3NodeInternals=b.elements.nodes.d3,c.cluster?(this._charge=function(){return this._clustering.layout.charge},this._linkStrength=function(a){return this._clustering.layout.linkStrength(a)}):(this._charge=function(){return-10/this.k},this._linkStrength=function(a){return d[a.source.id].getProperties("root")||d[a.target.id].getProperties("root")?1:.9}),c.cluster?this._linkDistancefn=function(a){return this._clustering.layout.linkDistancefn(a)}:"default"===c.linkDistancefn?this._linkDistancefn=function(){return 1/(50*this.k)}:"number"==typeof c.linkDistancefn?this._linkDistancefn=function(){return c.linkDistancefn}:"function"==typeof c.linkDistancefn&&(this._linkDistancefn=function(a){return c.linkDistancefn(a)})}return a.prototype.gravity=function(){return this.a.conf.cluster?this._clustering.layout.gravity(this.k):50*this.k},a.prototype.linkStrength=function(a){return this._linkStrength(a)},a.prototype.friction=function(){return.9},a.prototype.collide=function(a){var b,c,d,e,f,g;return b=this.a.conf,g=2*(a.radius+a["stroke-width"])+b.nodeOverlap,c=a.x-g,d=a.x+g,e=a.y-g,f=a.y+g,function(h,i,j,k,l){var m,n,o;return h.point&&h.point!==a&&(n=a.x-Math.abs(h.point.x),o=a.y-h.point.y,m=Math.sqrt(n*n+o*o),g=g,g>m&&(m=(m-g)/m*b.alpha,a.x-=n*=m,a.y-=o*=m,h.point.x+=n,h.point.y+=o)),i>d||c>k||j>f||e>l}},a.prototype.tick=function(){var a,b,c,d,e,f,g,h;if(a=this.a,d=a.elements.nodes.svg,b=a.elements.edges.svg,a.conf.collisionDetection)for(e=d3.geom.quadtree(this.d3NodeInternals),h=this.d3NodeInternals,f=0,g=h.length;g>f;f++)c=h[f],e.visit(this.collide(c));return d.attr("transform",function(a){return"translate("+a.x+","+a.y+")"}),this.drawEdge=a.drawing.DrawEdge,this.drawEdge.styleText(b),this.drawEdge.styleLink(b)},a.prototype.positionRootNodes=function(){var a,b,c,d,e,f,g,h,i,j;if(a=this.a.conf,b={width:a.graphWidth(),height:a.graphHeight()},e=_.filter(this.a.elements.nodes.val,function(a){return a.getProperties("root")}),1!==e.length){for(j=[],c=f=0,g=e.length;g>f;c=++f)d=e[c],d._d3.x=b.width/Math.sqrt(e.length*(c+1)),d._d3.y=b.height/2,j.push(d._d3.fixed=!0);return j}d=e[0],h=[b.width/2,b.width/2],d._d3.x=h[0],d._d3.px=h[1],i=[b.height/2,b.height/2],d._d3.y=i[0],d._d3.py=i[1],d._d3.fixed=!0},a.prototype.chargeDistance=function(){return 500},a.prototype.linkDistancefn=function(a){return this._linkDistancefn(a)},a.prototype.charge=function(){return this._charge()},a}(),a.prototype.generateLayout=function(a){var b;return b=a,function(a){var c;return null==a&&(a=!1),c=b.conf,b.layout=new j(b),b.force=d3.layout.force().size([c.graphWidth(),c.graphHeight()]).theta(1).gravity(b.layout.gravity()).friction(b.layout.friction()).nodes(b.elements.nodes.d3).links(b.elements.edges.d3).linkDistance(function(a){return b.layout.linkDistancefn(a)}).linkStrength(function(a){return b.layout.linkStrength(a)}).charge(b.layout.charge()).chargeDistance(b.layout.chargeDistance())}},a.prototype.search=function(a){var b;return b=a,{init:function(){var a;return a=b.dash.select("#search input"),a.on("keyup",function(){var c;return c=a[0][0].value.toLowerCase(),b.vis.selectAll(".node").classed("inactive",!1),b.vis.selectAll("text").attr("style",function(){return""!==c?"display: inline;":void 0}),b.vis.selectAll(".node").classed("inactive",function(a){var d,e;switch(d=d3.select(this).text(),b.conf.searchMethod){case"contains":e=d.toLowerCase().indexOf(c)<0;break;case"begins":e=0!==d.toLowerCase().indexOf(c)}return e?b.vis.selectAll("[source-target*='"+a.id+"']").classed("inactive",e):b.vis.selectAll("[source-target*='"+a.id+"']").classed("inactive",function(a){var c,d,e;return c=[a.source.id,a.target.id],d=b.vis.select("#node-"+c[0]).classed("inactive"),e=b.vis.select("#node-"+c[1]).classed("inactive"),e||d}),e})})}}},a.prototype.startGraph=function(b){var c;return c=b,function(b){var d,e,f,g,h,i;if(d=c.conf,d3.select(d.divSelector).empty()&&console.warn(c.utils.warnings.divWarning()),b||(b={nodes:[],edges:[]},c.utils.warnings.dataWarning()),null==b.edges&&(b.edges=[]),c.create.nodes(b.nodes),b.edges.forEach(function(a){return c.create.edges(a)}),c.vis=d3.select(d.divSelector).attr("style","width:"+d.graphWidth()+"px; height:"+d.graphHeight()+"px; background:"+d.backgroundColour+";").append("svg").attr("xmlns","http://www.w3.org/2000/svg").attr("xlink","http://www.w3.org/1999/xlink").attr("pointer-events","all").attr("style","background:"+d.backgroundColour+";").attr("alchInst",a.prototype.instances.length-1).on("click",c.interactions.deselectAll).call(c.interactions.zoom(d.scaleExtent)).on("dblclick.zoom",null).append("g").attr("transform","translate("+d.initialTranslate+") scale("+d.initialScale+")"),c.interactions.zoom().scale(d.initialScale),c.interactions.zoom().translate(d.initialTranslate),c.index=a.prototype.Index(c),c.generateLayout(),c.controlDash.init(),e=c.elements.edges.d3,f=c.elements.nodes.d3,c.layout.positionRootNodes(),c.force.start(),d.forceLocked)for(;c.force.alpha()>.005;)c.force.tick();return c._drawEdges=c.drawing.DrawEdges,c._drawNodes=c.drawing.DrawNodes,c._drawEdges.createEdge(e),c._drawNodes.createNode(f),c.index(),c.elements.nodes.svg.attr("transform",function(a){return"translate("+a.x+", "+a.y+")"}),console.log(Date()+" completed initial computation"),d.forceLocked||c.force.on("tick",c.layout.tick).start(),null!=d.afterLoad&&("function"==typeof d.afterLoad?d.afterLoad():"string"==typeof d.afterLoad&&(c[d.afterLoad]=!0)),d.cluster&&(g=d3.select(""+c.conf.divSelector+" svg").append("svg:defs")),d.nodeStats&&c.stats.nodeStats(),d.showEditor&&(h=new c.editor.Editor,i=new c.editor.Interactions,d3.select("body").on("keydown",i.deleteSelected),h.startEditor()),c.initial=!0}},a.prototype.stats=function(a){var b;return b=a,{init:function(){return b.stats.update()},nodeStats:function(){var a,c,d,e,f,g,h,i,j,k,l,m,n,o;if(f=[],c=b.get.allNodes().length,a=b.get.activeNodes().length,e=c-a,j="
        • Number of nodes: "+c+"
        • Number of active nodes: "+a+"
        • Number of inactive nodes: "+e+"

        • ",b.conf.nodeTypes){for(h=Object.keys(b.conf.nodeTypes),l="",o=b.conf.nodeTypes[h],m=0,n=o.length;n>m;m++)k=o[m],d=k.replace("_"," "),i=b.vis.selectAll("g.node."+k)[0].length,l+="
        • Number of "+d+" nodes: "+i+"
        • ",f.push([""+k,i]);j+=l}return g="
        • ",j+=g,b.dash.select("#node-stats").html(j),this.insertSVG("node",f)},edgeStats:function(){var a,c,d,e,f,g,h,i,j,k,l,m,n;if(e=[],c=b.get.allEdges().length,a=b.get.activeEdges().length,l=c-a,i="
        • Number of relationships: "+c+"
        • Number of active relationships: "+a+"
        • Number of inactive relationships: "+l+"

        • ",b.conf.edgeTypes){for(g=_.values(alchemy.conf.edgeTypes)[0],k="",m=0,n=g.length;n>m;m++)j=g[m],j&&(d=j.replace("_"," "),h=_.filter(b.get.allEdges(),function(a){return a._edgeType===j?a:void 0}).length,k+="
        • Number of "+d+" relationships: "+h+"
        • ",e.push([""+d,h]));i+=k}return f="
        • ",i+=f,b.dash.select("#rel-stats").html(i),this.insertSVG("edge",e)},insertSVG:function(a,c){var d,e,f,g,h,i,j,k;return null===c?b.dash.select("#"+a+"-stats-graph").html("

          There are no "+a+"Types listed in your conf.

          "):(k=.25*b.conf.graphWidth(),g=250,i=k/4,f=d3.scale.category20(),d=d3.svg.arc().outerRadius(i-10).innerRadius(i/2),h=d3.layout.pie().sort(null).value(function(a){return a[1]}),j=b.dash.select("#"+a+"-stats-graph").append("svg").append("g").style({width:k,height:g}).attr("transform","translate("+k/2+","+g/2+")"),e=j.selectAll(".arc").data(h(c)).enter().append("g").classed("arc",!0).on("mouseover",function(a,d){return b.dash.select("#"+c[d][0]+"-stat").classed("hidden",!1)}).on("mouseout",function(a,d){return b.dash.select("#"+c[d][0]+"-stat").classed("hidden",!0)}),e.append("path").attr("d",d).attr("stroke",function(a,b){return f(b)}).attr("stroke-width",2).attr("fill-opacity","0.3"),e.append("text").attr("transform",function(a){return"translate("+d.centroid(a)+")"}).attr("id",function(a,b){return""+c[b][0]+"-stat"}).attr("dy",".35em").classed("hidden",!0).text(function(a,b){return c[b][0]}))},update:function(){return b.conf.nodeStats&&this.nodeStats(),b.conf.edgeStats?this.edgeStats():void 0}}},a.prototype.updateGraph=function(a){var b;return b=a,function(){for(b.generateLayout(),b._drawEdges.createEdge(b.elements.edges.d3),b._drawNodes.createNode(b.elements.nodes.d3),b.layout.positionRootNodes(),b.force.start();b.force.alpha()>.005;)b.force.tick(); +return b.force.on("tick",b.layout.tick).start(),b.elements.nodes.svg.attr("transform",function(a){return"translate("+a.x+", "+a.y+")"})}},a.prototype.defaults={plugins:null,renderer:"svg",graphWidth:function(){return d3.select(this.divSelector).node().parentElement.clientWidth},graphHeight:function(){return"BODY"===d3.select(this.divSelector).node().parentElement.nodeName?window.innerHeight:d3.select(this.divSelector).node().parentElement.clientHeight},alpha:.5,collisionDetection:!0,nodeOverlap:25,fixNodes:!1,fixRootNodes:!1,forceLocked:!0,linkDistancefn:"default",nodePositions:null,showEditor:!1,captionToggle:!1,toggleRootNodes:!1,removeElement:!1,cluster:!1,clusterKey:"cluster",clusterColours:d3.shuffle(["#DD79FF","#FFFC00","#00FF30","#5168FF","#00C0FF","#FF004B","#00CDCD","#f83f00","#f800df","#ff8d8f","#ffcd00","#184fff","#ff7e00"]),clusterControl:!1,nodeStats:!1,edgeStats:!1,edgeFilters:!1,nodeFilters:!1,edgesToggle:!1,nodesToggle:!1,zoomControls:!1,nodeCaption:"caption",nodeCaptionsOnByDefault:!1,nodeStyle:{all:{radius:10,color:"#68B9FE",borderColor:"#127DC1",borderWidth:function(a,b){return b/3},captionColor:"#FFFFFF",captionBackground:null,captionSize:12,selected:{color:"#FFFFFF",borderColor:"#349FE3"},highlighted:{color:"#EEEEFF"},hidden:{color:"none",borderColor:"none"}}},nodeColour:null,nodeMouseOver:"caption",nodeRadius:10,nodeTypes:null,rootNodes:"root",rootNodeRadius:15,nodeClick:null,edgeCaption:"caption",edgeCaptionsOnByDefault:!1,edgeStyle:{all:{width:4,color:"#CCC",opacity:.2,directed:!0,curved:!0,selected:{opacity:1},highlighted:{opacity:1},hidden:{opacity:0}}},edgeTypes:null,curvedEdges:!1,edgeWidth:function(){return 4},edgeOverlayWidth:20,directedEdges:!1,edgeArrowSize:5,edgeClick:null,search:!1,searchMethod:"contains",backgroundColour:"#000000",theme:null,afterLoad:"afterLoad",divSelector:"#alchemy",dataSource:null,initialScale:1,initialTranslate:[0,0],scaleExtent:[.5,2.4],exportSVG:!1,dataWarning:"default",warningMessage:"There be no data! What's going on?"},c=function(a){return{a:a,createLink:function(a){var b;return b=this.a.conf,a.append("path").attr("class","edge-line").attr("id",function(a){return"path-"+a.id}),a.filter(function(a){return null!=a.caption}).append("text"),a.append("path").attr("class","edge-handler").style("stroke-width",""+b.edgeOverlayWidth).style("opacity","0")},styleLink:function(a){var b,c,d;return b=this.a,c=this.a.conf,d=this.a.drawing.EdgeUtils,a.each(function(a){var b,e,f,g,h,i,j,k,l;return f=d.edgeWalk(a),e=c.curvedEdges?30:0,b=e/10,k=a.source.radius+a["stroke-width"]/2,l=e/10,j=f.edgeLength/2,g=f.edgeLength-(a.target.radius-a.target["stroke-width"]/2),h=e/10,i=d3.select(this),i.style(d.edgeStyle(a)),i.attr("transform","translate("+a.source.x+", "+a.source.y+") rotate("+f.edgeAngle+")"),i.select(".edge-line").attr("d",function(){var d,f,i;return f="M"+k+","+l+"q"+j+","+e+" "+g+","+h,c.directedEdges?(i=2*a["stroke-width"],d="l"+-i+","+(i+b)+" l"+i+","+(-i-b)+" l"+-i+","+(-i+b),f+d):f}()),i.select(".edge-handler").attr("d",function(){return i.select(".edge-line").attr("d")})})},classEdge:function(a){return a.classed("active",!0)},styleText:function(a){var b,c,d;return b=this.a.conf,c=b.curvedEdges,d=this.a.drawing.EdgeUtils,a.select("text").each(function(a){var c,e;return e=d.edgeWalk(a),c=e.edgeLength/2,d3.select(this).attr("dx",""+c).text(a.caption).attr("xlink:xlink:href","#path-"+a.source.id+"-"+a.target.id).style("display",function(){return b.edgeCaptionsOnByDefault?"block":void 0})})},setInteractions:function(a){var b;return b=this.a.interactions,a.select(".edge-handler").on("click",b.edgeClick).on("mouseover",function(a){return b.edgeMouseOver(a)}).on("mouseout",function(a){return b.edgeMouseOut(a)})}}},d=function(a){return{a:a,createEdge:function(a){var b,c;return b=this.a.drawing.DrawEdge,c=this.a.vis.selectAll("g.edge").data(a),c.enter().append("g").attr("id",function(a){return"edge-"+a.id+"-"+a.pos}).attr("class",function(a){return"edge "+a.edgeType}).attr("source-target",function(a){return""+a.source.id+"-"+a.target.id}),b.createLink(c),b.classEdge(c),b.styleLink(c),b.styleText(c),b.setInteractions(c),c.exit().remove(),this.a.conf.directedEdges&&this.a.conf.curvedEdges?c.select(".edge-line").attr("marker-end","url(#arrow)"):void 0},updateEdge:function(a){var b,c;return b=this.a.drawing.DrawEdge,c=this.a.vis.select("#edge-"+a.id+"-"+a.pos),b.classEdge(c),b.styleLink(c),b.styleText(c),b.setInteractions(c)}}},e=function(a){return{a:a,styleText:function(a){var b,c,d;return b=this.a.conf,d=this.a.drawing.NodeUtils,c=this.a._nodes,a.selectAll("text").attr("dy",function(a){return c[a.id].getProperties().root?b.rootNodeRadius/2:2*b.nodeRadius-5}).attr("visibility",function(a){return"hidden"===c[a.id]._state?"hidden":"visible"}).text(function(a){return d.nodeText(a)}).style("display",function(){return b.nodeCaptionsOnByDefault?"block":void 0})},createNode:function(a){return a=_.difference(a,a.select("circle").data()),a.__proto__=d3.select().__proto__,a.append("circle").attr("id",function(a){return"circle-"+a.id}),a.append("svg:text").attr("id",function(a){return"text-"+a.id})},styleNode:function(a){var b;return b=this.a.drawing.NodeUtils,a.selectAll("circle").attr("r",function(a){return"function"==typeof a.radius?a.radius():a.radius}).each(function(a){return d3.select(this).style(b.nodeStyle(a))})},setInteractions:function(a){var b,c,d,e,f,g,h;return b=this.a.conf,c=this.a.interactions,e="editor"===this.a.get.state("interactions"),d=d3.behavior.drag().origin(Object).on("dragstart",null).on("drag",null).on("dragend",null),e?(f=new this.a.editor.Interactions,a.on("mouseup",function(a){return f.nodeMouseUp(a)}).on("mouseover",function(a){return f.nodeMouseOver(a)}).on("mouseout",function(a){return f.nodeMouseOut(a)}).on("dblclick",function(a){return c.nodeDoubleClick(a)}).on("click",function(a){return f.nodeClick(a)})):(a.on("mouseup",null).on("mouseover",function(a){return c.nodeMouseOver(a)}).on("mouseout",function(a){return c.nodeMouseOut(a)}).on("dblclick",function(a){return c.nodeDoubleClick(a)}).on("click",function(a){return c.nodeClick(a)}),d=d3.behavior.drag().origin(Object).on("dragstart",c.nodeDragStarted).on("drag",c.nodeDragged).on("dragend",c.nodeDragended),b.fixNodes||(g=a.filter(function(a){return a.root!==!0}),g.call(d)),b.fixRootNodes?void 0:(h=a.filter(function(a){return a.root===!0}),h.call(d)))}}},f=function(a){return{a:a,createNode:function(a){var b,c;return b=this.a.drawing.DrawNode,c=this.a.vis.selectAll("g.node").data(a,function(a){return a.id}),c.enter().append("g").attr("class",function(a){var b;return b=a.self._nodeType,"node "+b+" active"}).attr("id",function(a){return"node-"+a.id}).classed("root",function(a){return a.root}),b.createNode(c),b.styleNode(c),b.styleText(c),b.setInteractions(c),c.exit().remove()},updateNode:function(a){var b,c;return b=this.a.drawing.DrawNode,c=this.a.vis.select("#node-"+a.id),b.styleNode(c),b.styleText(c),b.setInteractions(c)}}},a.prototype.EdgeUtils=function(a){return{a:a,edgeStyle:function(a){var b,c,d,e,f;return c=this.a.conf,d=this.a._edges[a.id][a.pos],f=this.a.svgStyles.edge.update(d),e=this.a._nodes,this.a.conf.cluster&&(b=this.a.layout._clustering,f.stroke=function(a){var d,f,g,h,i,j;return d=c.clusterKey,i=e[a.source.id]._properties,j=e[a.target.id]._properties,i.root||j.root?(h=i.root?j[d]:i[d],""+b.getClusterColour(h)):i[d]===j[d]?(h=i[d],""+b.getClusterColour(h)):i[d]!==j[d]?(g=""+i[d]+"-"+j[d],f="cluster-gradient-"+g,"url(#"+f+")"):void 0}(a)),f},triangle:function(a){var b,c,d;return d=a.target.x-a.source.x,b=a.target.y-a.source.y,c=Math.sqrt(b*b+d*d),[d,b,c]},edgeWalk:function(a){var b,c,d,e,f,g,h,i;return i=this.triangle(a),h=i[0],e=i[1],f=i[2],d=a["stroke-width"],b=2,g=a.source.radius+a.source["stroke-width"]-d/2+b,c=f-g-1.5*b,{edgeAngle:Math.atan2(e,h)/Math.PI*180,edgeLength:c}},middleLine:function(a){return this.curvedDirectedEdgeWalk(a,"middle")},startLine:function(a){return this.curvedDirectedEdgeWalk(a,"linkStart")},endLine:function(a){return this.curvedDirectedEdgeWalk(a,"linkEnd")},edgeLength:function(a){var b,c,d;return d=a.target.x-a.source.x,b=a.target.y-a.source.y,c=Math.sqrt(b*b+d*d)},edgeAngle:function(a){var b,c;return c=a.target.x-a.source.x,b=a.target.y-a.source.y,Math.atan2(b,c)/Math.PI*180},captionAngle:function(a){return-90>a||a>90?180:0},middlePath:function(a){var b,c;return c=this.a.vis.select("#path-"+a.id).node(),b=c.getPointAtLength(c.getTotalLength()/2),{x:b.x,y:b.y}},middlePathCurve:function(a){var b,c;return c=d3.select("#path-"+a.id).node(),b=c.getPointAtLength(c.getTotalLength()/2),{x:b.x,y:b.y}}}},a.prototype.NodeUtils=function(a){var b;return b=a,{nodeStyle:function(a){var c,d;return c=b.conf,d=a.self,c.cluster&&"hidden"!==d._state&&(a.fill=function(){var a,e,f,g,h,i,j;return e=b.layout._clustering,j=d.getProperties(),a=e.clusterMap,i=c.clusterKey,h=c.clusterColours,g=a[j[i]]%h.length,f=h[g],""+f}(a),a.stroke=a.fill),a},nodeText:function(a){var c,d,e;return d=b.conf,e=b._nodes[a.id]._properties,d.nodeCaption&&"string"==typeof d.nodeCaption?null!=e[d.nodeCaption]?e[d.nodeCaption]:"":d.nodeCaption&&"function"==typeof d.nodeCaption?(c=d.nodeCaption(e),(void 0===c||"undefined"===String(c))&&(b.log.caption="At least one caption returned undefined",d.caption=!1),c):void 0}}},a.prototype.svgStyles=function(a){return{a:a,node:{a:this.a,populate:function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n;return b=this.a.conf,d=_.omit(b.nodeStyle.all,"selected","highlighted","hidden"),c=a,m=function(a){return"function"==typeof a?a:function(){return a}},g=_.keys(b.nodeTypes)[0],f=a.getProperties()[g],void 0===b.nodeStyle[f]&&(f="all"),n=_.assign(_.cloneDeep(d),b.nodeStyle[f]),k=_.assign(n,b.nodeStyle[f][a._state]),h=m(k.radius),e=m(k.color),i=m(k.borderColor),j=m(k.borderWidth),l={},l.radius=h(c),l.fill=e(c),l.stroke=i(c),l["stroke-width"]=j(c,h(c)),l}},edge:{a:this.a,populate:function(a){var b,c,d,e,f,g,h,i,j,k;return c=this.a.conf,d=_.omit(c.edgeStyle.all,"selected","highlighted","hidden"),i=function(a){return"function"==typeof a?a:function(){return a}},e=a._edgeType,void 0===c.edgeStyle[e]&&(e="all"),j=_.assign(_.cloneDeep(d),c.edgeStyle[e]),g=_.assign(j,c.edgeStyle[e][a._state]),k=i(g.width),b=i(g.color),f=i(g.opacity),h={stroke:b(a),"stroke-width":k(a),opacity:f(a),fill:"none"}},update:function(a){var b,c,d,e,f,g,h;return c=this.a.conf,e=a._style,g=function(a){return"function"==typeof a?a:function(){return a}},h=g(e.width),b=g(e.color),d=g(e.opacity),f={stroke:b(a),"stroke-width":h(a),opacity:d(a),fill:"none"}}}}},g=function(){function a(){this.nodeEditor=n(this.nodeEditor,this),this.startEditor=n(this.startEditor,this),this.utils=new alchemy.editor.Utils}return a.prototype.editorContainerHTML='
          \n

          Editor

          \n
          \n
          \n
            \n
          • Remove Selected
          • \n
          • Editor mode enabled, click to disable editor interactions
          • \n
          \n
          ',a.prototype.elementEditorHTML=function(a){return"

          "+a+' Editor

          \n
          \n
          \n \n \n
          \n \n
          \n
          \n \n
          '},a.prototype.startEditor=function(){var a,b,c,d,e;return a=alchemy.conf.divSelector,d=this.editorContainerHTML,b=alchemy.dash.select("#control-dash").append("div").attr("id","editor").html(d),b.select("#editor-header").on("click",function(){return alchemy.dash.select("#element-options").classed("in")?alchemy.dash.select("#editor-header>span").attr("class","fa fa-2x fa-caret-right"):alchemy.dash.select("#editor-header>span").attr("class","fa fa-2x fa-caret-down")}),c=b.select("#element-options ul #editor-interactions").on("click",function(){return d3.select(this).attr("class",function(){return"editor"===alchemy.get.state()?(alchemy.set.state("interactions","default"),"inactive list-group-item"):(alchemy.set.state("interactions","editor"),"active list-group-item")}).html(function(){return"editor"===alchemy.get.state()?"Disable Editor Interactions":"Enable Editor Interactions"})}),b.select("#element-options ul #remove").on("click",function(){return alchemy.editor.remove()}),e=this.utils,c.on("click",function(){return alchemy.dash.select("#editor-interactions").classed("active")?(e.disableEditor(),alchemy.dash.select("#editor-interactions").classed({active:!1,inactive:!0}).html("Editor mode disabled, click to enable editor interactions")):(e.enableEditor(),alchemy.dash.select("#editor-interactions").classed({active:!0,inactive:!1}).html("Editor mode enabled, click to disable editor interactions"))})},a.prototype.nodeEditor=function(a){var b,c,d,e,f,g,h,i,j,k,l,m;c=alchemy.conf.divSelector,d=alchemy.dash.select("#control-dash #editor"),i=d.select("#element-options"),f=this.elementEditorHTML("Node"),e=i.append("div").attr("id","node-editor").html(f),e.attr("class",function(){var a;return a=alchemy.dash.select("#editor-interactions").classed("active"),a?"enabled":"hidden"}),b=d.select("#node-editor form #add-property"),b.select("#node-add-prop-key").attr("placeholder","New Property Name").attr("value",null),b.select("#node-add-prop-value").attr("placeholder","New Property Value").attr("value",null),alchemy.dash.select("#add-property-form").on("submit",function(){var a,b;return event.preventDefault(),a=alchemy.dash.select("#add-prop-key").property("value"),a=a.replace(/\s/g,"_"),b=alchemy.dash.select("#add-prop-value").property("value"),l(a,b,!0),alchemy.dash.selectAll("#add-property .edited-property").classed({"edited-property":!1}),this.reset()}),g=alchemy._nodes[a.id].getProperties(),alchemy.vis.select("#node-"+a.id).classed({editing:!0}),k=d.select("#node-editor #properties-list");for(j in g)m=g[j],h=k.append("div").attr("id","node-"+j).attr("class","property form-inline form-group"),h.append("label").attr("for","node-"+j+"-input").attr("class","form-control property-name").text(""+j),h.append("input").attr("id","node-"+j+"-input").attr("class","form-control property-value").attr("value",""+m);return alchemy.dash.select("#properties-list").on("submit",function(){var a,b,c,d,e,f,g;for(event.preventDefault(),b=alchemy.dash.selectAll(".edited-property"),g=b[0],e=0,f=g.length;f>e;e++)j=g[e],c=alchemy.dash.select(j),a=c.select("label").text(),d=c.select("input").attr("value"),l(a,d,!1);return alchemy.dash.selectAll("#node-properties-list .edited-property").classed({"edited-property":!1}),this.reset()}),d3.selectAll("#add-prop-key, #add-prop-value, .property").on("keydown",function(){return 13===d3.event.keyCode&&event.preventDefault(),d3.select(this).classed({"edited-property":!0})}),l=function(b,c,d){var e,f;return f=a.id,""!==b&&""!==c?(alchemy._nodes[f].setProperty(""+b,""+c),e=alchemy._drawNodes,e.updateNode(alchemy.viz.select("#node-"+f)),d===!0?(alchemy.dash.select("#node-add-prop-key").attr("value","property added/updated to key: "+b),alchemy.dash.select("#node-add-prop-value").attr("value","property at "+b+" updated to: "+c)):alchemy.dash.select("#node-"+b+"-input").attr("value","property at "+b+" updated to: "+c)):d===!0?(alchemy.dash.select("#node-add-prop-key").attr("value","null or invalid input"),alchemy.dash.select("#node-add-prop-value").attr("value","null or invlid input")):alchemy.dash.select("#node-"+b+"-input").attr("value","null or invalid input")}},a.prototype.editorClear=function(){return alchemy.dash.selectAll(".node").classed({editing:!1}),alchemy.dash.selectAll(".edge").classed({editing:!1}),alchemy.dash.select("#node-editor").remove(),alchemy.dash.select("#edge-editor").remove(),alchemy.dash.select("#node-add-prop-submit").attr("placeholder",function(){return alchemy.vis.selectAll(".selected").empty()?"select a node or edge to edit properties":"add a property to this element"})},a.prototype.edgeEditor=function(a){var b,c,d,e,f,g,h,i,j,k,l,m;c=alchemy.conf.divSelector,f=alchemy.dash("#control-dash #editor"),i=f.select("#element-options"),h=this.elementEditorHTML("Edge"),g=i.append("div").attr("id","edge-editor").html(h),g.attr("class",function(){return alchemy.dash.select("#editor-interactions").classed("active")?"enabled":"hidden"}),b=f.select("#edge-editor form #add-property"),b.select("#add-prop-key").attr("placeholder","New Property Name").attr("value",null),b.select("#add-prop-value").attr("placeholder","New Property Value").attr("value",null),d=alchemy._edges[a.id].getProperties(),alchemy.vis.select("#edge-"+a.id).classed({editing:!0}),k=f.select("#edge-editor #properties-list");for(j in d)m=d[j],e=k.append("div").attr("id","edge-"+j).attr("class","property form-inline form-group"),e.append("label").attr("for","edge-"+j+"-input").attr("class","form-control property-name").text(""+j),e.append("input").attr("id","edge-"+j+"-input").attr("class","form-control property-value").attr("value",""+m);return alchemy.dash.selectAll("#add-prop-key, #add-prop-value, .property").on("keydown",function(){return 13===d3.event.keyCode&&event.preventDefault(),d3.select(this).classed({"edited-property":!0})}),alchemy.dash.select("#add-property-form").on("submit",function(){var a,b;return event.preventDefault(),a=alchemy.dash.select("#add-prop-key").property("value"),a=a.replace(/\s/g,"_"),b=alchemy.dash.select("#add-prop-value").property("value"),l(a,b,!0),alchemy.dash.selectAll("#add-property .edited-property").classed({"edited-property":!1}),this.reset()}),d3.select("#properties-list").on("submit",function(){var a,b,c,d,e,f,g;for(event.preventDefault(),b=alchemy.dash.selectAll(".edited-property"),g=b[0],e=0,f=g.length;f>e;e++)j=g[e],c=alchemy.dash.select(j),a=c.select("label").text(),d=c.select("input").property("value"),l(a,d,!1);return alchemy.dash.selectAll("#properties-list .edited-property").classed({"edited-property":!1}),this.reset()}),l=function(b,c,d){var e,f,g;return f=a.id,""!==b&&""!==c?(alchemy._edges[f].setProperty(""+b,""+c),g=alchemy.vis.select("#edge-"+f),e=new alchemy.drawing.DrawEdges,e.updateEdge(alchemy.vis.select("#edge-"+f)),d===!0?(alchemy.dash.select("#add-prop-key").attr("value","property added/updated to key: "+b),alchemy.dash.select("#add-prop-value").attr("value","property at "+b+" updated to: "+c)):alchemy.dash.select("#edge-"+b+"-input").attr("value","property at "+b+" updated to: "+c)):d===!0?(alchemy.dash.select("#add-prop-key").attr("value","null or invalid input"),alchemy.dash.select("#add-prop-value").attr("value","null or invlid input")):alchemy.dash.select("#edge-"+b+"-input").attr("value","null or invalid input")}},a}(),h=function(){function a(){this.reset=n(this.reset,this),this.deleteSelected=n(this.deleteSelected,this),this.addNodeDragended=n(this.addNodeDragended,this),this.addNodeDragging=n(this.addNodeDragging,this),this.addNodeStart=n(this.addNodeStart,this),this.edgeClick=n(this.edgeClick,this),this.nodeClick=n(this.nodeClick,this),this.nodeMouseUp=n(this.nodeMouseUp,this),this.editor=new alchemy.editor.Editor}return a.prototype.nodeMouseOver=function(){var a;return d3.select(this).select("circle").empty()||(a=d3.select(this).select("circle").attr("r"),d3.select(this).select("circle").attr("r",3*a)),this},a.prototype.nodeMouseUp=function(a){return this.sourceNode!==a?(this.mouseUpNode=!0,this.targetNode=a,this.click=!1):this.click=!0,this},a.prototype.nodeMouseOut=function(){var a;return d3.select(this).select("circle").empty()||(a=d3.select(this).select("circle").attr("r"),d3.select(this).select("circle").attr("r",a/3)),this},a.prototype.nodeClick=function(a){var b;return d3.event.stopPropagation(),alchemy.vis.select("#node-"+a.id).empty()||(b=alchemy.vis.select("#node-"+a.id).classed("selected"),alchemy.vis.select("#node-"+a.id).classed("selected",!b)),this.editor.editorClear(),this.editor.nodeEditor(a)},a.prototype.edgeClick=function(a){return d3.event.stopPropagation(),this.editor.editorClear(),this.editor.edgeEditor(a)},a.prototype.addNodeStart=function(a){return d3.event.sourceEvent.stopPropagation(),this.sourceNode=a,alchemy.vis.select("#dragline").classed({hidden:!1}),this},a.prototype.addNodeDragging=function(){var a,b;return a=d3.event.x,b=d3.event.y,alchemy.vis.select("#dragline").attr("x1",this.sourceNode.x).attr("y1",this.sourceNode.y).attr("x2",a).attr("y2",b).attr("style","stroke: #FFF"),this},a.prototype.addNodeDragended=function(){var a,b,c;return this.click||(this.mouseUpNode||(a=alchemy.vis.select("#dragline"),b=a.attr("x2"),c=a.attr("y2"),this.targetNode={id:""+_.uniqueId("addedNode_"),x:parseFloat(b),y:parseFloat(c),caption:"node added"}),this.newEdge={id:""+this.sourceNode.id+"-"+this.targetNode.id,source:this.sourceNode.id,target:this.targetNode.id,caption:"edited"},alchemy.editor.update(this.targetNode,this.newEdge)),this.reset(),this},a.prototype.deleteSelected=function(){switch(d3.event.keyCode){case 8:case 46:if("INPUT"!==d3.select(d3.event.target).node().tagName)return d3.event.preventDefault(),alchemy.editor.remove()}},a.prototype.reset=function(){return this.mouseUpNode=null,this.sourceNode=null,this.targetNode=null,this.newEdge=null,this.click=null,alchemy.vis.select("#dragline").classed({hidden:!0}).attr("x1",0).attr("y1",0).attr("x2",0).attr("y2",0),this},a}(),i=function(){function a(){this.enableEditor=n(this.enableEditor,this),this.drawNodes=alchemy._drawNodes,this.drawEdges=alchemy._drawEdges}return a.prototype.enableEditor=function(){var a,b,c;return alchemy.set.state("interactions","editor"),a=alchemy.vis.append("line").attr("id","dragline"),this.drawNodes.updateNode(alchemy.node),this.drawEdges.updateEdge(alchemy.edge),c=alchemy.vis.selectAll(".selected"),b=new alchemy.editor.Editor,c.empty()||1!==c.length?c.classed({selected:!1}):c.classed("node")?(b.nodeEditor(c.datum()),alchemy.dash.select("#node-editor").attr("class","enabled").style("opacity",1)):c.classed("edge")?(b.edgeEditor(c.datum()),alchemy.dash.select("#edge-editor").attr("class","enabled").style("opacity",1)):void 0},a.prototype.disableEditor=function(){return alchemy.setState("interactions","default"),alchemy.vis.select("#dragline").remove(),alchemy.dash.select("#node-editor").transition().duration(300).style("opacity",0),alchemy.dash.select("#node-editor").transition().delay(300).attr("class","hidden"),this.drawNodes.updateNode(alchemy.node),alchemy.vis.selectAll(".node").classed({selected:!1})},a.prototype.remove=function(){var a,b,c,d,e,f,g,h,i,j,k,l;for(e=alchemy.vis.selectAll(".selected.node"),j=e[0],l=[],f=0,h=j.length;h>f;f++)if(b=j[f],c=alchemy.vis.select(b).data()[0].id,d=alchemy._nodes[c],null!=d){for(k=d.adjacentEdges,g=0,i=k.length;i>g;g++)a=k[g],alchemy._edges=_.omit(alchemy._edges,""+a.id+"-"+a._index),alchemy.edge=alchemy.edge.data(_.map(alchemy._edges,function(a){return a._d3}),function(a){return a.id}),alchemy.vis.select("#edge-"+a.id+"-"+a._index).remove();alchemy._nodes=_.omit(alchemy._nodes,""+c),alchemy.node=alchemy.node.data(_.map(alchemy._nodes,function(a){return a._d3}),function(a){return a.id}),alchemy.vis.select(b).remove(),l.push("editor"===alchemy.get.state("interactions")?alchemy.modifyElements.nodeEditorClear():void 0)}else l.push(void 0);return l},a.prototype.addNode=function(a){var b;return b=alchemy._nodes[a.id]=new alchemy.models.Node({id:""+a.id}),b.setProperty("caption",a.caption),b.setD3Property("x",a.x),b.setD3Property("y",a.y),alchemy.node=alchemy.node.data(_.map(alchemy._nodes,function(a){return a._d3}),function(a){return a.id})},a.prototype.addEdge=function(a){var b;return b=alchemy._edges[a.id]=new alchemy.models.Edge(a),alchemy.edge=alchemy.edge.data(_.map(alchemy._edges,function(a){return a._d3}),function(a){return a.id})},a.prototype.update=function(a,b){return this.mouseUpNode?(alchemy.editor.addEdge(b),this.drawEdges.createEdge(alchemy.edge)):(alchemy.editor.addNode(a),alchemy.editor.addEdge(b),this.drawEdges.createEdge(alchemy.edge),this.drawNodes.createNode(alchemy.node)),alchemy.layout.tick()},a}(),a.prototype.Edge=function(a){var b;return b=function(){function b(b,c){var d;null==c&&(c=null),this.allNodesActive=n(this.allNodesActive,this),this.setProperties=n(this.setProperties,this),this.getStyles=n(this.getStyles,this),this.setProperties=n(this.setProperties,this),this.getProperties=n(this.getProperties,this),this._setID=n(this._setID,this),this._setD3Properties=n(this._setD3Properties,this),this.a=a,d=this.a.conf,this.id=this._setID(b),this._index=c,this._state="active",this._properties=b,this._edgeType=this._setEdgeType(),this._style=null!=d.edgeStyle[this._edgeType]?_.merge(_.clone(d.edgeStyle.all),d.edgeStyle[this._edgeType]):_.clone(d.edgeStyle.all),this._d3=_.merge({id:this.id,pos:this._index,edgeType:this._edgeType,source:this.a._nodes[this._properties.source]._d3,target:this.a._nodes[this._properties.target]._d3,self:this},this.a.svgStyles.edge.populate(this)),this._setCaption(b,d),this.a._nodes[""+b.source]._addEdge(this),this.a._nodes[""+b.target]._addEdge(this)}return b.prototype._setD3Properties=function(a){return _.merge(this._d3,a)},b.prototype._setID=function(a){return null!=a.id?a.id:""+a.source+"-"+a.target},b.prototype._setCaption=function(a,b){var c,d;return c=b.edgeCaption,d=function(a){switch(typeof c){case"string":return a[c];case"function":return c(a)}}(a),d?this._d3.caption=d:void 0},b.prototype._setEdgeType=function(){var a,b,c;return a=this.a.conf,a.edgeTypes&&(_.isPlainObject(a.edgeTypes)?(c=Object.keys(this.a.conf.edgeTypes),b=this._properties[c]):_.isArray(a.edgeTypes)?b=this._properties.caption:"string"==typeof a.edgeTypes&&(b=this._properties[a.edgeTypes])),void 0===b&&(b="all"),this._setD3Properties("edgeType",b),b},b.prototype.getProperties=function(){var a,b,c;return a=arguments[0],b=2<=arguments.length?m.call(arguments,1):[],null==a&&(a=null),null==a&&0===b.length?this._properties:0!==b.length?(c=_.union([a],b),_.pick(this._properties,c)):this._properties[a]},b.prototype.setProperties=function(a,b){return null==b&&(b=null),_.isPlainObject(a)?(_.assign(this._properties,a),"source"in a&&this._setD3Properties({source:alchemy._nodes[a.source]._d3}),"target"in a&&this._setD3Properties({target:alchemy._nodes[a.target]._d3})):(this._properties[a]=b,("source"===a||"target"===a)&&this._setD3Properties({property:alchemy._nodes[b]._d3})),this},b.prototype.getStyles=function(){var a,b,c;return b=arguments[0],c=2<=arguments.length?m.call(arguments,1):[],a=this,void 0===b?a._style:_.map(arguments,function(b){return a._style[b]})},b.prototype.setProperties=function(a,b){return null==b&&(b=null),_.isPlainObject(a)?(_.assign(this._properties,a),"source"in a&&this._setD3Properties({source:this.a._nodes[a.source]._d3}),"target"in a&&this._setD3Properties({target:this.a._nodes[a.target]._d3})):(this._properties[a]=b,("source"===a||"target"===a)&&this._setD3Properties({property:this.a._nodes[b]._d3})),this},b.prototype.setStyles=function(a,b){return null==b&&(b=null),void 0===a&&(a=this.a.svgStyles.edge.populate(this)),_.isPlainObject(a)?_.assign(this._style,a):"string"==typeof a&&(this._style[a]=b),this._setD3Properties(this.a.svgStyles.edge.update(this)),this.a._drawEdges.updateEdge(this._d3),this},b.prototype.toggleHidden=function(){return this._state="hidden"===this._state?"active":"hidden",this.setStyles()},b.prototype.allNodesActive=function(){var a,b,c,d;return a=this._properties.source,c=this._properties.target,b=alchemy.get.nodes(a)[0],d=alchemy.get.nodes(c)[0],"active"===b._state&&"active"===d._state},b.prototype.remove=function(){var a,b;return a=this,delete this.a._edges[a.id],null!=this.a._nodes[a._properties.source]&&_.remove(this.a._nodes[a._properties.source]._adjacentEdges,function(b){return b.id===a.id?b:void 0}),null!=this.a._nodes[a._properties.target]&&_.remove(this.a._nodes[a._properties.target]._adjacentEdges,function(b){return b.id===a.id?b:void 0}),this.a.vis.select("#edge-"+a.id+"-"+a._index).remove(),b=_.filter(this.a.force.links(),function(b){return b.id!==a.id?b:void 0}),this.a.force.links(b)},b}()},a.prototype.Node=function(a){var b;return b=function(){function b(b){this.getStyles=n(this.getStyles,this),this.setProperty=n(this.setProperty,this),this.getProperties=n(this.getProperties,this),this._setD3Properties=n(this._setD3Properties,this),this._setNodeType=n(this._setNodeType,this);var c;this.a=a,c=this.a.conf,this.id=b.id,this._properties=b,this._d3=_.merge({id:this.id,root:this._properties[c.rootNodes],self:this},this.a.svgStyles.node.populate(this)),this._nodeType=this._setNodeType(),this._style=c.nodeStyle[this._nodeType]?c.nodeStyle[this._nodeType]:c.nodeStyle.all,this._state="active",this._adjacentEdges=[]}return b.prototype._setNodeType=function(){var a,b,c,d;return a=this.a.conf,a.nodeTypes&&(_.isPlainObject(a.nodeTypes)?(b=Object.keys(this.a.conf.nodeTypes),d=_.values(a.nodeTypes),c=this._properties[b]):"string"==typeof a.nodeTypes&&(c=this._properties[a.nodeTypes])),void 0===c&&(c="all"),this._setD3Properties("nodeType",c),c},b.prototype._setD3Properties=function(a){return _.merge(this._d3,a)},b.prototype._addEdge=function(a){return this._adjacentEdges=_.union(this._adjacentEdges,[a])},b.prototype.getProperties=function(){var a,b,c;return a=arguments[0],b=2<=arguments.length?m.call(arguments,1):[],null==a&&(a=null),null==a&&0===b.length?this._properties:0!==b.length?(c=_.union([a],b),_.pick(this._properties,c)):this._properties[a]},b.prototype.setProperty=function(a,b){return null==b&&(b=null),_.isPlainObject(a)?_.assign(this._properties,a):this._properties[a]=b,this},b.prototype.removeProperty=function(){var a,b,c,d,e;for(c=arguments[0],b=2<=arguments.length?m.call(arguments,1):[],d=0,e=arguments.length;e>d;d++)a=arguments[d],delete this._properties[a];return this},b.prototype.getStyles=function(){var a,b,c;return a=arguments[0],b=2<=arguments.length?m.call(arguments,1):[],c=this,void 0===a?c._style:_.map(arguments,function(a){return c._style[a]})},b.prototype.setStyles=function(a,b){return null==b&&(b=null),void 0===a?a=this.a.svgStyles.node.populate(this):_.isPlainObject(a)?_.assign(this._style,a):this._style[a]=b,this._setD3Properties(this.a.svgStyles.node.populate(this)),this.a._drawNodes.updateNode(this._d3),this},b.prototype.toggleHidden=function(){var a;return a=this.a,this._state="hidden"===this._state?"active":"hidden",this.setStyles(),_.each(this._adjacentEdges,function(b){var c,d,e,f,g;return g=b.id.split("-"),c=g[0],e=g[1],d=a._nodes[""+c]._state,f=a._nodes[""+e]._state,"hidden"===b._state&&"active"===d&&"active"===f?b.toggleHidden():"active"!==b._state||"hidden"!==d&&"hidden"!==f?void 0:b.toggleHidden()})},b.prototype.outDegree=function(){return this._adjacentEdges.length},b.prototype.remove=function(){for(;!_.isEmpty(this._adjacentEdges);)this._adjacentEdges[0].remove();return delete this.a._nodes[this.id],this.a.vis.select("#node-"+this.id).remove()},b}()},a.prototype.plugins=function(b){return{init:function(){return _.each(_.keys(b.conf.plugins),function(c){return b.plugins[c]=a.prototype.plugins[c](b),null!=b.plugins[c].init?b.plugins[c].init():void 0})}}},a.prototype.themes={"default":{backgroundColour:"#000000",nodeStyle:{all:{radius:function(){return 10},color:function(){return"#68B9FE"},borderColor:function(){return"#127DC1"},borderWidth:function(a,b){return b/3},captionColor:function(){return"#FFFFFF"},captionBackground:function(){return null},captionSize:12,selected:{color:function(){return"#FFFFFF"},borderColor:function(){return"#349FE3"}},highlighted:{color:function(){return"#EEEEFF"}},hidden:{color:function(){return"none"},borderColor:function(){return"none"}}}},edgeStyle:{all:{width:4,color:"#CCC",opacity:.2,directed:!0,curved:!0,selected:{opacity:1},highlighted:{opacity:1},hidden:{opacity:0}}}},white:{theme:"white",backgroundColour:"#FFFFFF",nodeStyle:{all:{radius:function(){return 10 +},color:function(){return"#68B9FE"},borderColor:function(){return"#127DC1"},borderWidth:function(a,b){return b/3},captionColor:function(){return"#FFFFFF"},captionBackground:function(){return null},captionSize:12,selected:{color:function(){return"#FFFFFF"},borderColor:function(){return"38DD38"}},highlighted:{color:function(){return"#EEEEFF"}},hidden:{color:function(){return"none"},borderColor:function(){return"none"}}}},edgeStyle:{all:{width:4,color:"#333",opacity:.4,directed:!1,curved:!1,selected:{color:"#38DD38",opacity:.9},highlighted:{color:"#383838",opacity:.7},hidden:{opacity:0}}}}},a.prototype.exports=function(a){var b;return b=a,{init:function(){return b.exports.show()},show:function(){return b.dash.select("#all-exports").append("li").attr({"class":"list-group-item active-label toggle"}).html("SVG").on("click",function(){var a,c,d,e,f;return d=d3.select(""+b.conf.divSelector+" svg").node(),c=(new XMLSerializer).serializeToString(d),e="data:image/svg+xml;utf8,"+c,a=e.replace("xlink:",""),f=window.open(a),f.focus()})}}},l=function(){function a(a){this.dataWarning=n(this.dataWarning,this),this.a=a}return a.prototype.dataWarning=function(){return this.a.conf.dataWarning&&"function"==typeof this.a.conf.dataWarning?this.a.conf.dataWarning():"default"===this.a.conf.dataWarning?console.log("No dataSource was loaded"):void 0},a.prototype.divWarning=function(){return"create an element that matches the value for 'divSelector' in your conf.\nFor instance, if you are using the default 'divSelector' conf, simply provide\n
          ."},a}()}).call(this); \ No newline at end of file diff --git a/EHEC_Server/EHEC_Server/alchemy/scripts/vendor.js b/EHEC_Server/EHEC_Server/alchemy/scripts/vendor.js new file mode 100644 index 0000000..c4c3f2d --- /dev/null +++ b/EHEC_Server/EHEC_Server/alchemy/scripts/vendor.js @@ -0,0 +1,10 @@ +if(function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){function c(a){var b=a.length,c=_.type(a);return"function"===c||_.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}function d(a,b,c){if(_.isFunction(b))return _.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return _.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(hb.test(b))return _.filter(b,a,c);b=_.filter(b,a)}return _.grep(a,function(a){return U.call(b,a)>=0!==c})}function e(a,b){for(;(a=a[b])&&1!==a.nodeType;);return a}function f(a){var b=ob[a]={};return _.each(a.match(nb)||[],function(a,c){b[c]=!0}),b}function g(){Z.removeEventListener("DOMContentLoaded",g,!1),a.removeEventListener("load",g,!1),_.ready()}function h(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=_.expando+Math.random()}function i(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(ub,"-$1").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:tb.test(c)?_.parseJSON(c):c}catch(e){}sb.set(a,b,c)}else c=void 0;return c}function j(){return!0}function k(){return!1}function l(){try{return Z.activeElement}catch(a){}}function m(a,b){return _.nodeName(a,"table")&&_.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function n(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function o(a){var b=Kb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function p(a,b){for(var c=0,d=a.length;d>c;c++)rb.set(a[c],"globalEval",!b||rb.get(b[c],"globalEval"))}function q(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(rb.hasData(a)&&(f=rb.access(a),g=rb.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;d>c;c++)_.event.add(b,e,j[e][c])}sb.hasData(a)&&(h=sb.access(a),i=_.extend({},h),sb.set(b,i))}}function r(a,b){var c=a.getElementsByTagName?a.getElementsByTagName(b||"*"):a.querySelectorAll?a.querySelectorAll(b||"*"):[];return void 0===b||b&&_.nodeName(a,b)?_.merge([a],c):c}function s(a,b){var c=b.nodeName.toLowerCase();"input"===c&&yb.test(a.type)?b.checked=a.checked:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}function t(b,c){var d,e=_(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:_.css(e[0],"display");return e.detach(),f}function u(a){var b=Z,c=Ob[a];return c||(c=t(a,b),"none"!==c&&c||(Nb=(Nb||_("