Skip to content

Commit 6060314

Browse files
committed
set up js files for import/export
1 parent 671f3cf commit 6060314

17 files changed

Lines changed: 47 additions & 83 deletions

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# build files
2+
build/
3+
dist/
4+
15
# npm related
26

37
/node_modules/*

index.html

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,5 @@
5252
<script src="libs/jscolor.min.js"></script>
5353
<script src="dist/tag/js/tag.min.js"></script>
5454

55-
<script type="text/javascript">
56-
Main.init();
57-
</script>
58-
59-
6055
</body>
6156
</html>

src/js/components/link.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import WordTag from './tag.js';
2+
import Word from './word.js';
3+
import * as draggable from 'svg.draggable.js';
4+
15
class Link {
26
constructor(eventId, trigger, args, reltype, top = true) {
37
this.eventId = eventId;
@@ -572,3 +576,4 @@ class Link {
572576
return this.reltype || this.trigger.reltype || (this.trigger.tag && this.trigger.tag.val) || this.trigger.val;
573577
}
574578
}
579+
module.exports = Link;

src/js/components/row.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import * as draggable from 'svg.draggable.js';
2+
13
class Row {
24
constructor(svg, idx = 0, ry = 0, rh = 100) {
35
this.idx = idx;
@@ -139,3 +141,4 @@ class Row {
139141
return 60 + this.maxSlot * 15;
140142
}
141143
}
144+
module.exports = Row;

src/js/components/tag.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,4 @@ class WordTag {
105105
return this.position ? -28 : 20;
106106
}
107107
}
108+
module.exports = WordTag;

src/js/components/word.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import WordTag from './tag.js';
2+
import * as draggable from 'svg.draggable.js';
3+
14
class Word {
25
constructor(val, idx, tag, svg, row) {
36
this.eventIds = [];
@@ -172,3 +175,4 @@ class Word {
172175
return this.svgText.length();
173176
}
174177
}
178+
module.exports = Word;

src/js/components/wordcluster.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,4 @@ class WordCluster {
180180
return -28;
181181
}
182182
}
183+
module.exports = WordCluster;

src/js/main.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1+
import * as SVG from 'svg.js';
12
import Parser from './parser.js';
3+
import TreeLayout from './treelayout.js';
4+
import ymlToJson from './ymljson.js';
25
import LabelManager from './managers/labelmanager.js';
36
import RowManager from './managers/rowmanager.js';
47
import Taxonomy from './managers/taxonomy.js';
58
import Tooltip from './managers/tooltip.js';
9+
import Word from './components/word.js';
10+
import WordCluster from './components/wordcluster.js';
11+
import Link from './components/link.js';
612

713
const Main = (function() {
814
// classes
@@ -33,10 +39,9 @@ const Main = (function() {
3339
*/
3440
function init() {
3541
// setup
36-
body = document.body.getBoundingClientRect();
37-
svg = SVG('main')
42+
let body = document.body.getBoundingClientRect();
43+
svg = new SVG.Doc('main')
3844
.size(body.width, window.innerHeight - body.top - 10);
39-
4045
tooltip = new Tooltip('tooltip', svg);
4146
parser = new Parser();
4247
rm = new RowManager(svg);
@@ -317,7 +322,6 @@ const Main = (function() {
317322
w.setSyntaxId(token.id);
318323
return w;
319324
});
320-
console.log('words',words);
321325
const clusters = [];
322326

323327
[].concat(parser.data.entities, parser.data.triggers).forEach(el => {
@@ -360,7 +364,7 @@ const Main = (function() {
360364
parser.data.events.forEach(evt => {
361365
// create a link between the trigger and each of its args
362366
const trigger = entities.find(word => word.eventIds.indexOf(evt.trigger) > -1);
363-
const args = evt.args.map(searchForEntity);
367+
const args = evt.arguments.map(searchForEntity);
364368

365369
// create link
366370
const link = new Link(evt.id, trigger, args);
@@ -370,7 +374,7 @@ const Main = (function() {
370374
});
371375

372376
parser.data.relations.forEach(rel => {
373-
const args = rel.args.map(searchForEntity);
377+
const args = rel.arguments.map(searchForEntity);
374378
// create link
375379
const link = new Link(rel.id, null, args, rel.type);
376380

@@ -382,7 +386,7 @@ const Main = (function() {
382386
parser.data.syntax.forEach(syn => {
383387
// create a link between the trigger and each of its args
384388
const trigger = entities.find(word => word.syntaxId === syn.trigger);
385-
const args = syn.args.map(arg => {
389+
const args = syn.arguments.map(arg => {
386390
let anchor = words.find(w => w.syntaxId === arg.id);
387391
return { anchor, type: arg.type };
388392
});
@@ -491,6 +495,7 @@ const Main = (function() {
491495
// document.getElementById('pos--all').checked = true;
492496
// }
493497

498+
494499
// export public functions
495500
return {
496501
init,
@@ -500,4 +505,4 @@ const Main = (function() {
500505

501506
})();
502507

503-
Main.init();
508+
Main.init();

src/js/managers/index.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/js/managers/labelmanager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const LabelManager = (function() {
1+
module.exports = (function() {
22
let _svg;
33
let activeObject = null;
44
let string = null;

0 commit comments

Comments
 (0)