common/corpus-common-addon/addon/utils/utils.js
author ymh <ymh.work@gmail.com>
Sat, 10 Jun 2017 08:33:03 +0200
changeset 532 1190ea937f2d
parent 519 ef3e4841d506
permissions -rw-r--r--
make things work after node 8, npm 5 migration. Migrate to lodash 4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
392
4fbe94af93e8 Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents: 304
diff changeset
     1
/* eslint-disable no-magic-numbers, no-ternary */
4fbe94af93e8 Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents: 304
diff changeset
     2
135
66c1d31e2f97 first steps to add subject editing
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
import * as constants from 'corpus-common-addon/utils/constants';
532
1190ea937f2d make things work after node 8, npm 5 migration. Migrate to lodash 4
ymh <ymh.work@gmail.com>
parents: 519
diff changeset
     4
import _ from 'lodash';
135
66c1d31e2f97 first steps to add subject editing
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
141
c0e8626a271c literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents: 137
diff changeset
     6
export function isLexvoLink(s) {
c0e8626a271c literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents: 137
diff changeset
     7
  return s && typeof s === 'string' && s.startsWith(constants.LEXVO_BASE_URL);
392
4fbe94af93e8 Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents: 304
diff changeset
     8
}
141
c0e8626a271c literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents: 137
diff changeset
     9
135
66c1d31e2f97 first steps to add subject editing
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
export function isBnfLink(s) {
392
4fbe94af93e8 Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents: 304
diff changeset
    11
  return s &&
4fbe94af93e8 Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents: 304
diff changeset
    12
    typeof s === 'string' &&
4fbe94af93e8 Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents: 304
diff changeset
    13
    (s.startsWith(constants.BNF_BASE_URL) ||
4fbe94af93e8 Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents: 304
diff changeset
    14
    s.startsWith(constants.BNF_ARK_BASE_URL) ||
4fbe94af93e8 Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents: 304
diff changeset
    15
    s.startsWith(constants.BNF_ARK_BASE_ID));
4fbe94af93e8 Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents: 304
diff changeset
    16
}
137
1baa7c6bd370 add subject edition
ymh <ymh.work@gmail.com>
parents: 135
diff changeset
    17
1baa7c6bd370 add subject edition
ymh <ymh.work@gmail.com>
parents: 135
diff changeset
    18
export function isArkBnfLink(s) {
392
4fbe94af93e8 Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents: 304
diff changeset
    19
  return s &&
4fbe94af93e8 Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents: 304
diff changeset
    20
    typeof s === 'string' &&
4fbe94af93e8 Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents: 304
diff changeset
    21
    (s.startsWith(constants.BNF_BASE_URL + constants.BNF_ARK_BASE_ID) ||
4fbe94af93e8 Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents: 304
diff changeset
    22
    s.startsWith(constants.BNF_ARK_BASE_URL + constants.BNF_ARK_BASE_ID));
4fbe94af93e8 Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents: 304
diff changeset
    23
}
137
1baa7c6bd370 add subject edition
ymh <ymh.work@gmail.com>
parents: 135
diff changeset
    24
304
20071981ba2a add location and geonames resolvers and api
ymh <ymh.work@gmail.com>
parents: 141
diff changeset
    25
export function isGeonamesLink(s) {
20071981ba2a add location and geonames resolvers and api
ymh <ymh.work@gmail.com>
parents: 141
diff changeset
    26
  return (typeof s === 'string') && (s.match(constants.GEONAMES_BASE_URLS) !== null);
20071981ba2a add location and geonames resolvers and api
ymh <ymh.work@gmail.com>
parents: 141
diff changeset
    27
}
20071981ba2a add location and geonames resolvers and api
ymh <ymh.work@gmail.com>
parents: 141
diff changeset
    28
392
4fbe94af93e8 Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents: 304
diff changeset
    29
export function getGeonamesCode(s) {
4fbe94af93e8 Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents: 304
diff changeset
    30
  const m = s.match(constants.GEONAMES_BASE_URLS);
4fbe94af93e8 Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents: 304
diff changeset
    31
  let code = s;
4fbe94af93e8 Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents: 304
diff changeset
    32
4fbe94af93e8 Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents: 304
diff changeset
    33
  if (m) {
4fbe94af93e8 Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents: 304
diff changeset
    34
    code = s.slice(m[0].length);
4fbe94af93e8 Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents: 304
diff changeset
    35
  }
4fbe94af93e8 Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents: 304
diff changeset
    36
4fbe94af93e8 Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents: 304
diff changeset
    37
  return code.replace(/\/+$/, '');
4fbe94af93e8 Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents: 304
diff changeset
    38
}
4fbe94af93e8 Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents: 304
diff changeset
    39
447
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 392
diff changeset
    40
export function isViafLink(s) {
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 392
diff changeset
    41
  return (typeof s === 'string') && (s.match(constants.VIAF_URL_REGEXP) !== null);
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 392
diff changeset
    42
}
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 392
diff changeset
    43
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 392
diff changeset
    44
export function getViafCode(s) {
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 392
diff changeset
    45
  const m = s.match(constants.VIAF_URL_REGEXP);
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 392
diff changeset
    46
  let code = s;
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 392
diff changeset
    47
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 392
diff changeset
    48
  if (m) {
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 392
diff changeset
    49
    code = s.slice(m[0].length);
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 392
diff changeset
    50
  }
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 392
diff changeset
    51
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 392
diff changeset
    52
  return code.replace(/\/+$/, '');
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 392
diff changeset
    53
}
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 392
diff changeset
    54
137
1baa7c6bd370 add subject edition
ymh <ymh.work@gmail.com>
parents: 135
diff changeset
    55
export function switchArkBnfLink(s) {
304
20071981ba2a add location and geonames resolvers and api
ymh <ymh.work@gmail.com>
parents: 141
diff changeset
    56
  if (!s) {
137
1baa7c6bd370 add subject edition
ymh <ymh.work@gmail.com>
parents: 135
diff changeset
    57
    return s;
1baa7c6bd370 add subject edition
ymh <ymh.work@gmail.com>
parents: 135
diff changeset
    58
  }
304
20071981ba2a add location and geonames resolvers and api
ymh <ymh.work@gmail.com>
parents: 141
diff changeset
    59
  if (typeof s === 'string' && s.startsWith(constants.BNF_BASE_URL + constants.BNF_ARK_BASE_ID)) {
137
1baa7c6bd370 add subject edition
ymh <ymh.work@gmail.com>
parents: 135
diff changeset
    60
    return constants.BNF_ARK_BASE_URL + s.slice(constants.BNF_BASE_URL.length);
304
20071981ba2a add location and geonames resolvers and api
ymh <ymh.work@gmail.com>
parents: 141
diff changeset
    61
  } else if (typeof s === 'string' && s.startsWith(constants.BNF_ARK_BASE_URL + constants.BNF_ARK_BASE_ID)) {
137
1baa7c6bd370 add subject edition
ymh <ymh.work@gmail.com>
parents: 135
diff changeset
    62
    return constants.BNF_BASE_URL + s.slice(constants.BNF_ARK_BASE_URL.length);
1baa7c6bd370 add subject edition
ymh <ymh.work@gmail.com>
parents: 135
diff changeset
    63
  }
392
4fbe94af93e8 Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents: 304
diff changeset
    64
4fbe94af93e8 Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents: 304
diff changeset
    65
  return s;
4fbe94af93e8 Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents: 304
diff changeset
    66
}
137
1baa7c6bd370 add subject edition
ymh <ymh.work@gmail.com>
parents: 135
diff changeset
    67
1baa7c6bd370 add subject edition
ymh <ymh.work@gmail.com>
parents: 135
diff changeset
    68
export function calculateBnfArkControlChar(id) {
304
20071981ba2a add location and geonames resolvers and api
ymh <ymh.work@gmail.com>
parents: 141
diff changeset
    69
  if (!id) {
137
1baa7c6bd370 add subject edition
ymh <ymh.work@gmail.com>
parents: 135
diff changeset
    70
    return null;
1baa7c6bd370 add subject edition
ymh <ymh.work@gmail.com>
parents: 135
diff changeset
    71
  }
392
4fbe94af93e8 Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents: 304
diff changeset
    72
  const sum = _.reduce(id, function (s, c, i) {
304
20071981ba2a add location and geonames resolvers and api
ymh <ymh.work@gmail.com>
parents: 141
diff changeset
    73
    return s + (i + 1) * (c in constants.NOID_CHARS_POS ? constants.NOID_CHARS_POS[c] : 0);
137
1baa7c6bd370 add subject edition
ymh <ymh.work@gmail.com>
parents: 135
diff changeset
    74
  }, 0);
392
4fbe94af93e8 Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents: 304
diff changeset
    75
137
1baa7c6bd370 add subject edition
ymh <ymh.work@gmail.com>
parents: 135
diff changeset
    76
  return constants.NOID_CHARS[sum % constants.NOID_CHARS.length];
392
4fbe94af93e8 Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents: 304
diff changeset
    77
}
490
76da86cf9696 External OLAC links leads now to the OLAC documentation. Closes #0025936
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
    78
76da86cf9696 External OLAC links leads now to the OLAC documentation. Closes #0025936
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
    79
export function getOLACBaseUrl(literalVal) {
76da86cf9696 External OLAC links leads now to the OLAC documentation. Closes #0025936
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
    80
  let olacRes = null;
76da86cf9696 External OLAC links leads now to the OLAC documentation. Closes #0025936
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
    81
76da86cf9696 External OLAC links leads now to the OLAC documentation. Closes #0025936
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
    82
  if (!literalVal) {
76da86cf9696 External OLAC links leads now to the OLAC documentation. Closes #0025936
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
    83
    return null;
76da86cf9696 External OLAC links leads now to the OLAC documentation. Closes #0025936
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
    84
  }
76da86cf9696 External OLAC links leads now to the OLAC documentation. Closes #0025936
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
    85
  if (typeof literalVal !== 'object') {
76da86cf9696 External OLAC links leads now to the OLAC documentation. Closes #0025936
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
    86
    return null;
76da86cf9696 External OLAC links leads now to the OLAC documentation. Closes #0025936
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
    87
  }
76da86cf9696 External OLAC links leads now to the OLAC documentation. Closes #0025936
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
    88
  const datatype = literalVal.datatype;
76da86cf9696 External OLAC links leads now to the OLAC documentation. Closes #0025936
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
    89
76da86cf9696 External OLAC links leads now to the OLAC documentation. Closes #0025936
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
    90
  if (!datatype) {
76da86cf9696 External OLAC links leads now to the OLAC documentation. Closes #0025936
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
    91
    return null;
76da86cf9696 External OLAC links leads now to the OLAC documentation. Closes #0025936
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
    92
  }
76da86cf9696 External OLAC links leads now to the OLAC documentation. Closes #0025936
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
    93
76da86cf9696 External OLAC links leads now to the OLAC documentation. Closes #0025936
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
    94
  _.forEach(constants.OLAC_BASE_URL, function (olacDef, urlPrefix) {
76da86cf9696 External OLAC links leads now to the OLAC documentation. Closes #0025936
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
    95
    if (_.startsWith(datatype, urlPrefix)) {
76da86cf9696 External OLAC links leads now to the OLAC documentation. Closes #0025936
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
    96
      olacRes = olacDef;
502
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 490
diff changeset
    97
490
76da86cf9696 External OLAC links leads now to the OLAC documentation. Closes #0025936
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
    98
      return false; // we found it, we exit early
76da86cf9696 External OLAC links leads now to the OLAC documentation. Closes #0025936
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
    99
    }
76da86cf9696 External OLAC links leads now to the OLAC documentation. Closes #0025936
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
   100
76da86cf9696 External OLAC links leads now to the OLAC documentation. Closes #0025936
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
   101
    return true;
76da86cf9696 External OLAC links leads now to the OLAC documentation. Closes #0025936
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
   102
  });
76da86cf9696 External OLAC links leads now to the OLAC documentation. Closes #0025936
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
   103
76da86cf9696 External OLAC links leads now to the OLAC documentation. Closes #0025936
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
   104
  return olacRes;
76da86cf9696 External OLAC links leads now to the OLAC documentation. Closes #0025936
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
   105
}
76da86cf9696 External OLAC links leads now to the OLAC documentation. Closes #0025936
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
   106
76da86cf9696 External OLAC links leads now to the OLAC documentation. Closes #0025936
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
   107
export function isOLACLiteral(literalDef) {
76da86cf9696 External OLAC links leads now to the OLAC documentation. Closes #0025936
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
   108
  const olacDef = getOLACBaseUrl(literalDef);
76da86cf9696 External OLAC links leads now to the OLAC documentation. Closes #0025936
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
   109
76da86cf9696 External OLAC links leads now to the OLAC documentation. Closes #0025936
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
   110
  return Boolean(olacDef);
76da86cf9696 External OLAC links leads now to the OLAC documentation. Closes #0025936
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
   111
}
502
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 490
diff changeset
   112
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 490
diff changeset
   113
export function isDCMILink(s) {
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 490
diff changeset
   114
  return s && typeof s === 'string' && s.startsWith(constants.DCMI_BASE_URL);
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 490
diff changeset
   115
}
519
ef3e4841d506 Correct bug #0026428 - in notice filter on creation date for period
ymh <ymh.work@gmail.com>
parents: 502
diff changeset
   116
ef3e4841d506 Correct bug #0026428 - in notice filter on creation date for period
ymh <ymh.work@gmail.com>
parents: 502
diff changeset
   117
export function getPeriodMatches(periodStr) {
ef3e4841d506 Correct bug #0026428 - in notice filter on creation date for period
ymh <ymh.work@gmail.com>
parents: 502
diff changeset
   118
ef3e4841d506 Correct bug #0026428 - in notice filter on creation date for period
ymh <ymh.work@gmail.com>
parents: 502
diff changeset
   119
  let dateStr = periodStr;
ef3e4841d506 Correct bug #0026428 - in notice filter on creation date for period
ymh <ymh.work@gmail.com>
parents: 502
diff changeset
   120
ef3e4841d506 Correct bug #0026428 - in notice filter on creation date for period
ymh <ymh.work@gmail.com>
parents: 502
diff changeset
   121
  if (!dateStr) {
ef3e4841d506 Correct bug #0026428 - in notice filter on creation date for period
ymh <ymh.work@gmail.com>
parents: 502
diff changeset
   122
    return null;
ef3e4841d506 Correct bug #0026428 - in notice filter on creation date for period
ymh <ymh.work@gmail.com>
parents: 502
diff changeset
   123
  }
ef3e4841d506 Correct bug #0026428 - in notice filter on creation date for period
ymh <ymh.work@gmail.com>
parents: 502
diff changeset
   124
  dateStr = dateStr.trim();
ef3e4841d506 Correct bug #0026428 - in notice filter on creation date for period
ymh <ymh.work@gmail.com>
parents: 502
diff changeset
   125
ef3e4841d506 Correct bug #0026428 - in notice filter on creation date for period
ymh <ymh.work@gmail.com>
parents: 502
diff changeset
   126
  const m = dateStr.match(/^(\d{4})-(\d{4})$/) ||
ef3e4841d506 Correct bug #0026428 - in notice filter on creation date for period
ymh <ymh.work@gmail.com>
parents: 502
diff changeset
   127
    dateStr.match(/^start\s*=\s*([^\s]+)\s*;\s*end\s*=\s*([^\s]+)$/) ||
ef3e4841d506 Correct bug #0026428 - in notice filter on creation date for period
ymh <ymh.work@gmail.com>
parents: 502
diff changeset
   128
    dateStr.match(/^end\s*=\s*([^\s]+)\s*;\s*start\s*=\s*([^\s]+)$/);
ef3e4841d506 Correct bug #0026428 - in notice filter on creation date for period
ymh <ymh.work@gmail.com>
parents: 502
diff changeset
   129
ef3e4841d506 Correct bug #0026428 - in notice filter on creation date for period
ymh <ymh.work@gmail.com>
parents: 502
diff changeset
   130
  if (!m) {
ef3e4841d506 Correct bug #0026428 - in notice filter on creation date for period
ymh <ymh.work@gmail.com>
parents: 502
diff changeset
   131
    return null;
ef3e4841d506 Correct bug #0026428 - in notice filter on creation date for period
ymh <ymh.work@gmail.com>
parents: 502
diff changeset
   132
  }
ef3e4841d506 Correct bug #0026428 - in notice filter on creation date for period
ymh <ymh.work@gmail.com>
parents: 502
diff changeset
   133
ef3e4841d506 Correct bug #0026428 - in notice filter on creation date for period
ymh <ymh.work@gmail.com>
parents: 502
diff changeset
   134
  const [, dateStr1, dateStr2] = m;
ef3e4841d506 Correct bug #0026428 - in notice filter on creation date for period
ymh <ymh.work@gmail.com>
parents: 502
diff changeset
   135
  let date1 = new Date(dateStr1);
ef3e4841d506 Correct bug #0026428 - in notice filter on creation date for period
ymh <ymh.work@gmail.com>
parents: 502
diff changeset
   136
  let date2 = new Date(dateStr2);
ef3e4841d506 Correct bug #0026428 - in notice filter on creation date for period
ymh <ymh.work@gmail.com>
parents: 502
diff changeset
   137
ef3e4841d506 Correct bug #0026428 - in notice filter on creation date for period
ymh <ymh.work@gmail.com>
parents: 502
diff changeset
   138
  if (isNaN(date1.getTime()) || isNaN(date2.getTime())) {
ef3e4841d506 Correct bug #0026428 - in notice filter on creation date for period
ymh <ymh.work@gmail.com>
parents: 502
diff changeset
   139
    return null;
ef3e4841d506 Correct bug #0026428 - in notice filter on creation date for period
ymh <ymh.work@gmail.com>
parents: 502
diff changeset
   140
  }
ef3e4841d506 Correct bug #0026428 - in notice filter on creation date for period
ymh <ymh.work@gmail.com>
parents: 502
diff changeset
   141
  if (date2 < date1) {
ef3e4841d506 Correct bug #0026428 - in notice filter on creation date for period
ymh <ymh.work@gmail.com>
parents: 502
diff changeset
   142
    [date1, date2] = [date2, date1];
ef3e4841d506 Correct bug #0026428 - in notice filter on creation date for period
ymh <ymh.work@gmail.com>
parents: 502
diff changeset
   143
  }
ef3e4841d506 Correct bug #0026428 - in notice filter on creation date for period
ymh <ymh.work@gmail.com>
parents: 502
diff changeset
   144
ef3e4841d506 Correct bug #0026428 - in notice filter on creation date for period
ymh <ymh.work@gmail.com>
parents: 502
diff changeset
   145
  return {
ef3e4841d506 Correct bug #0026428 - in notice filter on creation date for period
ymh <ymh.work@gmail.com>
parents: 502
diff changeset
   146
    start: {str: dateStr1, date: date1},
ef3e4841d506 Correct bug #0026428 - in notice filter on creation date for period
ymh <ymh.work@gmail.com>
parents: 502
diff changeset
   147
    end: {str: dateStr2, date: date2}
ef3e4841d506 Correct bug #0026428 - in notice filter on creation date for period
ymh <ymh.work@gmail.com>
parents: 502
diff changeset
   148
  };
ef3e4841d506 Correct bug #0026428 - in notice filter on creation date for period
ymh <ymh.work@gmail.com>
parents: 502
diff changeset
   149
ef3e4841d506 Correct bug #0026428 - in notice filter on creation date for period
ymh <ymh.work@gmail.com>
parents: 502
diff changeset
   150
}