Skip to content

Commit 271b4c8

Browse files
committed
fix arrow styles not being reset
1 parent fcf221c commit 271b4c8

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

index.html

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,14 @@
173173
function changeDataset() {
174174
if (this.selectedIndex > 0) {
175175
parser.readJson(`./data/data${this.selectedIndex}.json`, function() {
176-
console.log(parser);
177176
var words = parser.tokens.map((token, i) => new Word(token, i));
177+
[].concat(parser.data.entities, parser.data.triggers).forEach(el => {
178+
if (words[el.tokenIndex]) {
179+
words[el.tokenIndex].tag = el.type;
180+
}
181+
});
178182
resetDrawing(words, []);
183+
console.log(parser);
179184
});
180185
}
181186
};
@@ -184,11 +189,12 @@
184189
draw.clear();
185190
rowGroup = draw.group();
186191
groupAllElements = linkG = textG = arrowG = undefined;
187-
dragElem = null;
188192
isDragging = false;
189193
rowOffsetX = 0;
190194
rowOffsetWord = null;
191195
prevX = -1;
196+
styles = setupStyles(draw); //creates an associative array of whatever
197+
dragElem = null;
192198

193199
rows = [];
194200
wordObjs = words || createTestWords(5, 6, 10);

js/parser.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,23 @@ class Parser {
3939
parseData(data) {
4040
/* first get string tokens from the syntaxData */
4141
this.text = data.syntaxData.text;
42+
43+
const offsets = {};
4244
this.tokens = data.syntaxData.entities
4345
.map(x => x[2][0])
4446
.sort((a, b) => a[0] - b[0])
45-
.map(interval => this.text.substring(interval[0], interval[1]));
47+
.map((interval, i) => {
48+
offsets[interval[0]] = i;
49+
return this.text.substring(interval[0], interval[1]);
50+
});
4651

4752
/* parse the event data: entities, triggers, events, and relations */
4853
const e = data.eventData;
4954
const entities = e.entities.map(arr => {
5055
return {
5156
id: arr[0],
5257
type: arr[1],
53-
interval: arr[2][0],
58+
tokenIndex: offsets[arr[2][0][0]],
5459
string: e.text.substring(arr[2][0][0], arr[2][0][1])
5560
};
5661
});
@@ -59,7 +64,7 @@ class Parser {
5964
return {
6065
id: arr[0],
6166
type: arr[1],
62-
interval: arr[2][0],
67+
tokenIndex: offsets[arr[2][0][0]],
6368
string: e.text.substring(arr[2][0][0], arr[2][0][1])
6469
};
6570
});

0 commit comments

Comments
 (0)