vis-chronicle 1.2.2 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/relativeDates.js +18 -2
- package/src/render.js +22 -10
- package/src/wikidata.js +1 -1
package/package.json
CHANGED
package/src/relativeDates.js
CHANGED
|
@@ -56,6 +56,23 @@ module.exports = function flattenRelativeDate(wikidataCache, dateString)
|
|
|
56
56
|
const cacheEntry = wikidataCache[relSplit[0]]
|
|
57
57
|
if (relSplit.length > 1)
|
|
58
58
|
{
|
|
59
|
+
// break up operators
|
|
60
|
+
const dateOperators = []
|
|
61
|
+
var opStartIndex = 0
|
|
62
|
+
const operatorString = relSplit[1]
|
|
63
|
+
if (operatorString.length > 0)
|
|
64
|
+
{
|
|
65
|
+
for (var i = 1; i < operatorString.length; i++)
|
|
66
|
+
{
|
|
67
|
+
if (operatorString[i] == '+' || operatorString[i] == '>')
|
|
68
|
+
{
|
|
69
|
+
dateOperators.push(operatorString.substring(opStartIndex, i))
|
|
70
|
+
opStartIndex = i
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
dateOperators.push(operatorString.substring(opStartIndex, i))
|
|
74
|
+
}
|
|
75
|
+
|
|
59
76
|
// handle relative segments of date
|
|
60
77
|
// About precision:
|
|
61
78
|
// - The actual value is assumed to lie in a range the size of the precision
|
|
@@ -64,9 +81,8 @@ module.exports = function flattenRelativeDate(wikidataCache, dateString)
|
|
|
64
81
|
var momentDate = moment(cacheEntry.value, 'YYYYYY-MM-DDThh:mm:ss')
|
|
65
82
|
var precision = cacheEntry.precision
|
|
66
83
|
//console.log(momentDate)
|
|
67
|
-
for (
|
|
84
|
+
for (const component of dateOperators)
|
|
68
85
|
{
|
|
69
|
-
const component = relSplit[i]
|
|
70
86
|
if (!component)
|
|
71
87
|
{
|
|
72
88
|
// empty group from regex
|
package/src/render.js
CHANGED
|
@@ -35,6 +35,18 @@ function momentSafeMax(a, b)
|
|
|
35
35
|
return a ? (b ? moment.max(a, b) : a) : b
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
// Copies properties that should be untouched by the renderer from 'from' to 'to'
|
|
39
|
+
function copyItemUntouchedProps(from, to)
|
|
40
|
+
{
|
|
41
|
+
to.align = from.align
|
|
42
|
+
to.selectable = from.selectable
|
|
43
|
+
to.style = from.style
|
|
44
|
+
to.title = from.title
|
|
45
|
+
to.limitSize = from.limitSize
|
|
46
|
+
to.editable = from.editable
|
|
47
|
+
to.wikidata = from.entity
|
|
48
|
+
}
|
|
49
|
+
|
|
38
50
|
const renderer = {}
|
|
39
51
|
|
|
40
52
|
renderer.getExpectation = function(item)
|
|
@@ -197,9 +209,9 @@ renderer.produceOutput = function(inputSpec, items)
|
|
|
197
209
|
content: item.label,
|
|
198
210
|
className: item.className,
|
|
199
211
|
comment: item.comment,
|
|
200
|
-
type: item.type
|
|
201
|
-
wikidata: item.entity
|
|
212
|
+
type: item.type
|
|
202
213
|
}
|
|
214
|
+
copyItemUntouchedProps(item, outputItem)
|
|
203
215
|
if (item.group)
|
|
204
216
|
{
|
|
205
217
|
outputItem.group = item.group
|
|
@@ -287,9 +299,9 @@ renderer.produceOutput = function(inputSpec, items)
|
|
|
287
299
|
start: uncertainMin,
|
|
288
300
|
end: item.end_max,
|
|
289
301
|
group: item.group,
|
|
290
|
-
subgroup: outputItem.subgroup
|
|
291
|
-
wikidata: item.entity
|
|
302
|
+
subgroup: outputItem.subgroup
|
|
292
303
|
}
|
|
304
|
+
copyItemUntouchedProps(item, uncertainElement)
|
|
293
305
|
outputObject.items.push(uncertainElement)
|
|
294
306
|
|
|
295
307
|
if (permitBgOverlay)
|
|
@@ -344,9 +356,9 @@ renderer.produceOutput = function(inputSpec, items)
|
|
|
344
356
|
start: outputItem.end,
|
|
345
357
|
end: tailEnd,
|
|
346
358
|
group: item.group,
|
|
347
|
-
subgroup: outputItem.subgroup
|
|
348
|
-
wikidata: item.entity
|
|
359
|
+
subgroup: outputItem.subgroup
|
|
349
360
|
})
|
|
361
|
+
copyItemUntouchedProps(item, outputObject)
|
|
350
362
|
|
|
351
363
|
outputItem.className = [ outputItem.className, 'visc-right-connection' ].join(' ')
|
|
352
364
|
}
|
|
@@ -367,9 +379,9 @@ renderer.produceOutput = function(inputSpec, items)
|
|
|
367
379
|
start: outputItem.end,
|
|
368
380
|
end: tailEnd,
|
|
369
381
|
group: item.group,
|
|
370
|
-
subgroup: outputItem.subgroup
|
|
371
|
-
wikidata: item.entity
|
|
382
|
+
subgroup: outputItem.subgroup
|
|
372
383
|
})
|
|
384
|
+
copyItemUntouchedProps(item, outputObject)
|
|
373
385
|
|
|
374
386
|
outputItem.className = [ outputItem.className, 'visc-right-connection' ].join(' ')
|
|
375
387
|
}
|
|
@@ -410,9 +422,9 @@ renderer.produceOutput = function(inputSpec, items)
|
|
|
410
422
|
start: item.start_min,
|
|
411
423
|
end: uncertainMax,
|
|
412
424
|
group: item.group,
|
|
413
|
-
subgroup: outputItem.subgroup
|
|
414
|
-
wikidata: item.entity
|
|
425
|
+
subgroup: outputItem.subgroup
|
|
415
426
|
}
|
|
427
|
+
copyItemUntouchedProps(item, uncertainElement)
|
|
416
428
|
outputObject.items.push(uncertainElement)
|
|
417
429
|
|
|
418
430
|
if (permitBgOverlay)
|
package/src/wikidata.js
CHANGED
|
@@ -41,7 +41,7 @@ const wikidata = module.exports = {
|
|
|
41
41
|
rankNormal: "http://wikiba.se/ontology#NormalRank",
|
|
42
42
|
rankPreferred: "http://wikiba.se/ontology#PreferredRank",
|
|
43
43
|
|
|
44
|
-
pathQueryRegex: /^(Q[0-9]+(?::P[0-9]+)?(?::Q[0-9]+:P[0-9]+)?)([\+>](?:[A-Za-z]+(?:![0-9]+)?|P\-?[0-9A-Z]+)+)
|
|
44
|
+
pathQueryRegex: /^(Q[0-9]+(?::P[0-9]+)?(?::Q[0-9]+:P[0-9]+)?)((?:[\+>](?:[A-Za-z]+(?:![0-9]+)?|P\-?[0-9A-Z]+)+)*)$/,
|
|
45
45
|
|
|
46
46
|
initialize: function()
|
|
47
47
|
{
|