vis-chronicle 1.2.3 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vis-chronicle",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "description": "Generates JSON for populating a vis.js timeline from Wikidata queries.",
5
5
  "keywords": [
6
6
  "wikidata",
@@ -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 (var i = 1; i < relSplit.length; i++)
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/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
  {