Skip to content

Commit f4dd81f

Browse files
committed
refactor -- reorganize file structure, small fixes to interaction / link data
1 parent e8ba10f commit f4dd81f

File tree

9 files changed

+14
-17
lines changed

9 files changed

+14
-17
lines changed

index.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@
3131

3232
<script src="js/panel.js"></script>
3333
<script src="js2/parser.js"></script>
34-
<script src="js2/tooltip.js"></script>
3534
<script src="js2/main.js"></script>
35+
<script src="js2/managers/tooltip.js"></script>
3636
<script src="js2/managers/labelmanager.js"></script>
3737
<script src="js2/managers/rowmanager.js"></script>
38-
<script src="js2/row.js"></script>
39-
<script src="js2/tag.js"></script>
40-
<script src="js2/word.js"></script>
41-
<script src="js2/wordcluster.js"></script>
42-
<script src="js2/link.js"></script>
38+
<script src="js2/components/row.js"></script>
39+
<script src="js2/components/tag.js"></script>
40+
<script src="js2/components/word.js"></script>
41+
<script src="js2/components/wordcluster.js"></script>
42+
<script src="js2/components/link.js"></script>
4343

4444
<script type="text/javascript">
4545
Main.init();

js2/link.js renamed to js2/components/link.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ class Link {
33
this.eventId = eventId;
44
this.trigger = trigger;
55
this.arguments = args;
6-
// console.log('trigger\t\t',trigger);
7-
// console.log.apply(null, args);
8-
6+
console.log('trigger\t\t',trigger);
7+
console.log.apply(null, args);
98
}
109
}
File renamed without changes.

js2/tag.js renamed to js2/components/tag.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ class WordTag {
3131
}
3232
updateWordWidth() {
3333
let ww = this.entity.ww;
34-
let tw = this.ww;
35-
if (tw > ww - 5) {
34+
if (this.entity.val.length < 9) {
3635
this.line.plot('M0,25,l0,8');
3736
}
3837
else {
@@ -93,7 +92,6 @@ class WordTag {
9392
this.remove();
9493
}
9594
else {
96-
this.updateWordWidth();
9795
this.entity.setBoxWidth();
9896
}
9997
}
File renamed without changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class WordCluster {
5959
let svg = this.svgs[i] = word.svg.group()
6060
.addClass('word-cluster');
6161

62+
// TODO: recalculate offset when tag is added/removed
6263
if (this.words.find(word => word.tag)) {
6364
svg.y(this.tagOffset * 1.9);
6465
}

js2/main.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const Main = (function() {
3232
lm = new LabelManager(svg);
3333

3434
// load and render initial dataset by default
35-
changeDataset(4);
35+
changeDataset(2);
3636

3737
// svg event listeners
3838
svg.on('row-resize', function(e) {
@@ -133,13 +133,12 @@ const Main = (function() {
133133
console.log('unhandled argument type', argument);
134134
break;
135135
}
136-
return anchor;
136+
return { anchor, type: argument.type };
137137
}
138138

139139
// construct links from events and relations
140140
const links = [];
141141
parser.data.events.forEach(evt => {
142-
143142
// create a link between the trigger and each of its arguments
144143
const trigger = entities.find(word => word.eventId === evt.trigger);
145144
const arguments = evt.arguments.map(searchForEntity);

js2/managers/labelmanager.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ const LabelManager = (function() {
7575
}
7676
})
7777
document.addEventListener('keypress', function(e) {
78-
// console.log(String.fromCharCode(e.which), e.which);
78+
// console.log(String.fromCharCode(e.which), e.which, e.metaKey);
7979
if (activeObject && activeObject.isEditing) {
8080
if (e.which === 32) {
8181
e.preventDefault();
8282
}
83-
if (!e.ctrlKey && !e.metaKey && !e.altKey) {
83+
if (e.which > 31 && !e.ctrlKey && !e.metaKey && !e.altKey) {
8484
if (string === null) { string = ''; }
8585
updateString(string + String.fromCharCode(e.which));
8686
}
File renamed without changes.

0 commit comments

Comments
 (0)