|
33 | 33 | <script src="js/enums.js"></script> |
34 | 34 | <script src="js/config.js"></script> |
35 | 35 | <script src="js/parser.js"></script> |
| 36 | +<script src="js/Panel.js"></script> |
36 | 37 | <script src="js/GraphLayout.js"></script> |
37 | 38 | <script src="js/style.js"></script> |
38 | 39 | <script src="js/annotate.js"></script> |
|
41 | 42 | <script src="js/utils.js"></script> |
42 | 43 |
|
43 | 44 | <script type="text/javascript"> |
44 | | - |
45 | 45 | /* a lot of these global vars should be wrapped eventually */ |
46 | 46 | var draw = SVG('drawing').size(Config.svgWidth, Config.svgHeight); |
47 | 47 | var rowGroup = draw.group(); |
|
77 | 77 | changeSizeOfSVGPanel(window.innerWidth - 16, (rows[rows.length - 1].lineBottom.y() ) + 1); |
78 | 78 |
|
79 | 79 | window.onload = function() { |
80 | | - var Panel = new GraphLayout(); |
81 | | - var parser = new Parser(); |
| 80 | + |
| 81 | + const panel = new Panel('graph', 'drawing'); |
| 82 | + const graph = new GraphLayout(panel.el); |
| 83 | + const parser = new Parser(); |
82 | 84 |
|
83 | 85 | var prevWidth = Config.svgWidth; |
84 | 86 | function svgResize() { |
|
95 | 97 | } |
96 | 98 |
|
97 | 99 | draw.on('wordSelected', function() { |
98 | | - Panel.graph(getSelectedObjects()); |
| 100 | + graph.graph(getSelectedObjects()); |
99 | 101 | }); |
100 | 102 |
|
101 | 103 | document.querySelector('#graph>button').onclick = function() { |
102 | 104 | let words = getSelectedObjects(); |
103 | 105 | if (words.length > 0) { |
104 | | - Panel.graph(words); |
| 106 | + graph.graph(words); |
105 | 107 | } |
106 | 108 | else { |
107 | | - Panel.clear(); |
| 109 | + graph.clear(); |
108 | 110 | } |
109 | 111 | }; |
110 | 112 |
|
111 | 113 | function changeDataset(index = 1) { |
112 | 114 | parser.readJson(`./data/data${index}.json`, function() { |
113 | | - Panel.clear(); |
| 115 | + graph.clear(); |
114 | 116 |
|
115 | 117 | // construct word objects and tags from tokens, entities, and triggers |
116 | 118 | const words = parser.tokens.map((token, i) => new Word(token, i)); |
|
224 | 226 | // linkObjs.forEach(link => link.style = styles[link.style]); |
225 | 227 | drawWords(wordObjs); |
226 | 228 | drawLinks(linkObjs); |
227 | | - if (Panel.isOpen) { Panel.close(); } |
228 | 229 | changeSizeOfSVGPanel(window.innerWidth - 16, (rows[rows.length - 1].lineBottom.y() ) + 1); |
229 | 230 | } |
230 | 231 |
|
231 | 232 | function resize() { |
232 | 233 | svgResize(); |
233 | | - Panel.resize(); |
| 234 | + graph.resize(); |
234 | 235 | } |
235 | 236 |
|
236 | 237 | document.getElementById('dataset').onchange = function() { |
|
0 commit comments