@knight-lab/timelinejs 3.8.15 → 3.8.19
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/API.md +1 -2
- package/{CHANGELOG → CHANGELOG.md} +70 -8
- package/DEPLOYING.md +4 -0
- package/README.md +21 -19
- package/RELEASING.md +4 -4
- package/dist/css/fonts/font.abril-droidsans.css +143 -0
- package/dist/css/fonts/font.amatic-andika.css +143 -0
- package/dist/css/fonts/font.bevan-pontanosans.css +141 -0
- package/dist/css/fonts/font.bitter-raleway.css +149 -0
- package/dist/css/fonts/font.clicker-garamond.css +141 -0
- package/dist/css/fonts/font.dancing-ledger.css +143 -0
- package/dist/css/fonts/font.default.css +155 -0
- package/dist/css/fonts/font.fjalla-average.css +141 -0
- package/dist/css/fonts/font.georgia-helvetica.css +123 -0
- package/dist/css/fonts/font.knightlab.css +125 -0
- package/dist/css/fonts/font.lustria-lato.css +147 -0
- package/dist/css/fonts/font.medula-lato.css +149 -0
- package/dist/css/fonts/font.oldstandard.css +135 -0
- package/dist/css/fonts/font.opensans-gentiumbook.css +155 -0
- package/dist/css/fonts/font.playfair-faunaone.css +156 -0
- package/dist/css/fonts/font.playfair.css +143 -0
- package/dist/css/fonts/font.pt.css +153 -0
- package/dist/css/fonts/font.roboto-megrim.css +143 -0
- package/dist/css/fonts/font.rufina-sintony.css +149 -0
- package/dist/css/fonts/font.ubuntu.css +145 -0
- package/dist/css/fonts/font.unicaone-vollkorn.css +143 -0
- package/dist/css/icons/tl-icons.eot +0 -0
- package/dist/css/icons/tl-icons.svg +63 -0
- package/dist/css/icons/tl-icons.ttf +0 -0
- package/dist/css/icons/tl-icons.woff +0 -0
- package/dist/css/icons/tl-icons.woff2 +0 -0
- package/dist/css/themes/timeline.theme.contrast.css +3125 -0
- package/dist/css/themes/timeline.theme.dark.css +3125 -0
- package/dist/css/timeline.css +3128 -0
- package/dist/css/timeline.css.map +1 -0
- package/dist/embed/compare.html +91 -0
- package/dist/embed/index.html +170 -0
- package/dist/embed/old-index.html +170 -0
- package/dist/embed/popular_timelines.json +1 -0
- package/dist/js/locale/af.json +75 -0
- package/dist/js/locale/ar.json +76 -0
- package/dist/js/locale/be.json +75 -0
- package/dist/js/locale/bg.json +75 -0
- package/dist/js/locale/ca.json +75 -0
- package/dist/js/locale/cz.json +108 -0
- package/dist/js/locale/da.json +75 -0
- package/dist/js/locale/de.json +76 -0
- package/dist/js/locale/el.json +75 -0
- package/dist/js/locale/en-24hr.json +75 -0
- package/dist/js/locale/en-week.json +75 -0
- package/dist/js/locale/en.json +152 -0
- package/dist/js/locale/eo.json +75 -0
- package/dist/js/locale/es.json +76 -0
- package/dist/js/locale/et.json +75 -0
- package/dist/js/locale/eu.json +75 -0
- package/dist/js/locale/fa.json +74 -0
- package/dist/js/locale/fi.json +95 -0
- package/dist/js/locale/fo.json +75 -0
- package/dist/js/locale/fr.json +119 -0
- package/dist/js/locale/fy.json +75 -0
- package/dist/js/locale/ga.json +75 -0
- package/dist/js/locale/gl.json +75 -0
- package/dist/js/locale/he.json +76 -0
- package/dist/js/locale/hi.json +76 -0
- package/dist/js/locale/hr.json +75 -0
- package/dist/js/locale/hu.json +114 -0
- package/dist/js/locale/hy.json +75 -0
- package/dist/js/locale/id.json +75 -0
- package/dist/js/locale/is.json +75 -0
- package/dist/js/locale/it.json +92 -0
- package/dist/js/locale/iw.json +76 -0
- package/dist/js/locale/ja.json +75 -0
- package/dist/js/locale/ka.json +75 -0
- package/dist/js/locale/ko.json +75 -0
- package/dist/js/locale/lb.json +75 -0
- package/dist/js/locale/lt.json +75 -0
- package/dist/js/locale/lv.json +75 -0
- package/dist/js/locale/ms.json +75 -0
- package/dist/js/locale/my.json +124 -0
- package/dist/js/locale/ne.json +75 -0
- package/dist/js/locale/nl.json +75 -0
- package/dist/js/locale/no.json +76 -0
- package/dist/js/locale/pl.json +75 -0
- package/dist/js/locale/pt-br.json +78 -0
- package/dist/js/locale/pt.json +78 -0
- package/dist/js/locale/rm.json +75 -0
- package/dist/js/locale/ro.json +75 -0
- package/dist/js/locale/ru.json +75 -0
- package/dist/js/locale/si.json +74 -0
- package/dist/js/locale/sk.json +75 -0
- package/dist/js/locale/sl.json +75 -0
- package/dist/js/locale/sr-cy.json +75 -0
- package/dist/js/locale/sr.json +75 -0
- package/dist/js/locale/sv.json +86 -0
- package/dist/js/locale/ta.json +75 -0
- package/dist/js/locale/te.json +74 -0
- package/dist/js/locale/th.json +108 -0
- package/dist/js/locale/tl.json +75 -0
- package/dist/js/locale/tr.json +75 -0
- package/dist/js/locale/uk.json +75 -0
- package/dist/js/locale/ur.json +123 -0
- package/dist/js/locale/vi.json +74 -0
- package/dist/js/locale/zh-cn.json +76 -0
- package/dist/js/locale/zh-tw.json +75 -0
- package/dist/js/timeline-min.js +12 -0
- package/dist/js/timeline.js +12 -0
- package/dist/js/timeline.js.map +1 -0
- package/dist/timeline3.zip +0 -0
- package/index.js +1 -0
- package/package.json +5 -5
- package/src/embed/old-index.html +128 -18
- package/src/js/core/Browser.js +19 -19
- package/src/js/index.js +1 -1
- package/src/js/language/locale/zh-cn.json +1 -1
- package/src/js/media/MediaType.js +1 -1
- package/src/js/media/types/Audio.js +9 -0
- package/src/js/media/types/Video.js +11 -0
- package/src/js/timeline/Timeline.js +25 -20
- package/src/less/fonts/font.knightlab.less +2 -2
- package/src/template/all-media-types.json +61 -24
- package/src/template/index.html +39 -19
- package/{contrib/women_in_computing.csv → src/template/my-own-timeline.csv} +5 -5
- package/contrib/README.md +0 -13
- package/contrib/csv_to_json.py +0 -106
- package/contrib/docs/ImageHosting.md +0 -120
- package/contrib/examples/autoload.html +0 -44
- package/contrib/examples/iBooksAuthor/README.md +0 -37
- package/contrib/examples/iBooksAuthor/TimelineJS.wdgt/Default.png +0 -0
- package/contrib/examples/iBooksAuthor/TimelineJS.wdgt/Info.plist +0 -27
- package/contrib/examples/iBooksAuthor/TimelineJS.wdgt/index.html +0 -13
- package/contrib/examples/react.html +0 -40
- package/contrib/examples/vue.html +0 -29
- package/contrib/fedorbeets/README.md +0 -3
- package/contrib/fedorbeets/timeline.py.txt +0 -56
- package/contrib/iamamoose/README.md +0 -3
- package/contrib/iamamoose/timeline.py.txt +0 -53
- package/contrib/women_in_computing.json +0 -263
- package/fabfile.py +0 -64
- package/requirements.txt +0 -29
- package/util/convert_json.py +0 -96
- package/website/__init__.py +0 -0
- package/website/app.py +0 -101
- package/website/core/__init__.py +0 -0
- package/website/core/settings/__init__.py +0 -0
- package/website/core/settings/base.py +0 -6
- package/website/core/settings/loc.py +0 -16
- package/website/examples.json +0 -114
- package/website/faq.json +0 -81
- package/website/static/css/desert.css +0 -34
- package/website/static/css/site.css +0 -74
- package/website/static/img/TimelineJSTags.jpg +0 -0
- package/website/static/img/examples/houston/eyesclosedftm_10001.jpg +0 -0
- package/website/static/img/examples/houston/family.jpg +0 -0
- package/website/static/img/examples/houston/family.png +0 -0
- package/website/static/img/examples/houston/wh1.jpg +0 -0
- package/website/static/img/examples/houston/wh2.jpg +0 -0
- package/website/static/img/examples/houston/wh3.jpg +0 -0
- package/website/static/img/examples/houston/whChild.jpg +0 -0
- package/website/static/img/examples/houston/whlead.jpg +0 -0
- package/website/static/img/examples/houston/young.jpg +0 -0
- package/website/static/img/examples/logos/Northwestern University.png +0 -0
- package/website/static/img/examples/logos/Social-Logos.png +0 -0
- package/website/static/img/examples/logos/knightlab-logo-background.png +0 -0
- package/website/static/img/examples/logos/knightlab-logo-small.png +0 -0
- package/website/static/img/examples/logos/knightlab-logo.png +0 -0
- package/website/static/img/examples/logos/less-small.png +0 -0
- package/website/static/img/examples/logos/logo_aljazeera.png +0 -0
- package/website/static/img/examples/logos/logo_arte.png +0 -0
- package/website/static/img/examples/logos/logo_beyondtheseal.png +0 -0
- package/website/static/img/examples/logos/logo_centerforpublicintegrity.png +0 -0
- package/website/static/img/examples/logos/logo_cnn.png +0 -0
- package/website/static/img/examples/logos/logo_denverpost.png +0 -0
- package/website/static/img/examples/logos/logo_engadget.png +0 -0
- package/website/static/img/examples/logos/logo_gigaom.png +0 -0
- package/website/static/img/examples/logos/logo_ibt.png +0 -0
- package/website/static/img/examples/logos/logo_knightlab.png +0 -0
- package/website/static/img/examples/logos/logo_ksat.png +0 -0
- package/website/static/img/examples/logos/logo_lemonde.png +0 -0
- package/website/static/img/examples/logos/logo_maneater.png +0 -0
- package/website/static/img/examples/logos/logo_mashable.png +0 -0
- package/website/static/img/examples/logos/logo_radiolab.png +0 -0
- package/website/static/img/examples/logos/logo_time.png +0 -0
- package/website/static/img/examples/logos/logo_vh1.png +0 -0
- package/website/static/img/examples/logos/logo_vinepair.png +0 -0
- package/website/static/img/examples/logos/logo_wbur.png +0 -0
- package/website/static/img/examples/thumbs/thumb_akira.jpg +0 -0
- package/website/static/img/examples/thumbs/thumb_aljazeera.jpg +0 -0
- package/website/static/img/examples/thumbs/thumb_artetv.jpg +0 -0
- package/website/static/img/examples/thumbs/thumb_banana.png +0 -0
- package/website/static/img/examples/thumbs/thumb_bulger.jpg +0 -0
- package/website/static/img/examples/thumbs/thumb_denver_shooting.jpg +0 -0
- package/website/static/img/examples/thumbs/thumb_houston.jpg +0 -0
- package/website/static/img/examples/thumbs/thumb_isis.jpg +0 -0
- package/website/static/img/examples/thumbs/thumb_lemonde.jpg +0 -0
- package/website/static/img/examples/thumbs/thumb_malaysia-airlines.jpg +0 -0
- package/website/static/img/examples/thumbs/thumb_mandela.jpg +0 -0
- package/website/static/img/examples/thumbs/thumb_mobile_device.jpg +0 -0
- package/website/static/img/examples/thumbs/thumb_northkorea.jpg +0 -0
- package/website/static/img/examples/thumbs/thumb_perpwalk.jpg +0 -0
- package/website/static/img/examples/thumbs/thumb_radiolab-colorwalking.jpg +0 -0
- package/website/static/img/examples/thumbs/thumb_republican.jpg +0 -0
- package/website/static/img/examples/thumbs/thumb_shtpeoplesay.jpg +0 -0
- package/website/static/img/examples/thumbs/thumb_supremecourt.jpg +0 -0
- package/website/static/img/examples/thumbs/thumb_univofmissouri.jpg +0 -0
- package/website/static/img/examples/thumbs/thumb_userinterface.png +0 -0
- package/website/static/img/examples/thumbs/thumb_wine.jpg +0 -0
- package/website/static/img/examples/user-interface/4s.jpg +0 -0
- package/website/static/img/examples/user-interface/apple.jpg +0 -0
- package/website/static/img/examples/user-interface/input.png +0 -0
- package/website/static/img/examples/user-interface/palm.png +0 -0
- package/website/static/img/examples/user-interface/pascaline.jpg +0 -0
- package/website/static/img/examples/user-interface/univac.JPG +0 -0
- package/website/static/img/font-options.png +0 -0
- package/website/static/img/kl-og.png +0 -0
- package/website/static/img/knightlab_logo.png +0 -0
- package/website/static/img/loading.gif +0 -0
- package/website/static/img/make/abril-droidsans.png +0 -0
- package/website/static/img/make/amatic-andika.png +0 -0
- package/website/static/img/make/bevan-pontanosans.png +0 -0
- package/website/static/img/make/bitter-raleway.png +0 -0
- package/website/static/img/make/clicker-garamond.png +0 -0
- package/website/static/img/make/dancing-ledger.png +0 -0
- package/website/static/img/make/default.png +0 -0
- package/website/static/img/make/fakedropdown.svg +0 -1
- package/website/static/img/make/fjalla-average.png +0 -0
- package/website/static/img/make/font-options.png +0 -0
- package/website/static/img/make/georgia-helvetica.png +0 -0
- package/website/static/img/make/lustria-lato.png +0 -0
- package/website/static/img/make/medula-lato.png +0 -0
- package/website/static/img/make/oldstandard.png +0 -0
- package/website/static/img/make/opensans-gentiumbook.png +0 -0
- package/website/static/img/make/playfair-faunaone.png +0 -0
- package/website/static/img/make/playfair.png +0 -0
- package/website/static/img/make/pt.png +0 -0
- package/website/static/img/make/publish_to_web_browser_url.png +0 -0
- package/website/static/img/make/publish_to_web_button_small-od1.png +0 -0
- package/website/static/img/make/publish_to_web_button_small.png +0 -0
- package/website/static/img/make/publish_to_web_small.png +0 -0
- package/website/static/img/make/publish_to_web_url_small.png +0 -0
- package/website/static/img/make/roboto-megrim.png +0 -0
- package/website/static/img/make/rufina-sintony.png +0 -0
- package/website/static/img/make/unicaone-vollkorn.png +0 -0
- package/website/static/img/make/v4_step_1.png +0 -0
- package/website/static/img/make/v4_step_2.png +0 -0
- package/website/static/img/timeline.png +0 -0
- package/website/static/img/timeline3_intro_image.png +0 -0
- package/website/static/js/faq-generator.js +0 -20
- package/website/static/js/main.js +0 -240
- package/website/static/welcome/step3.png +0 -0
- package/website/static/welcome/welcome.json +0 -266
- package/website/templates/_about.html +0 -23
- package/website/templates/_analytics.html +0 -10
- package/website/templates/_banner.html +0 -26
- package/website/templates/_demo.html +0 -5
- package/website/templates/_developers.html +0 -19
- package/website/templates/_examples.html +0 -156
- package/website/templates/_faq.html +0 -117
- package/website/templates/_footer.html +0 -54
- package/website/templates/_head.html +0 -38
- package/website/templates/_header.html +0 -18
- package/website/templates/_help.html +0 -50
- package/website/templates/_make.html +0 -291
- package/website/templates/_nav.html +0 -24
- package/website/templates/_overview.html +0 -32
- package/website/templates/_roadmap.html +0 -27
- package/website/templates/_storytelling_tools.html +0 -35
- package/website/templates/base.html +0 -37
- package/website/templates/docs/faq.html +0 -223
- package/website/templates/docs/index.html +0 -57
- package/website/templates/docs/instantiate-a-timeline.html +0 -207
- package/website/templates/docs/json-format.html +0 -477
- package/website/templates/docs/license.html +0 -29
- package/website/templates/docs/media-types.html +0 -82
- package/website/templates/docs/options.html +0 -472
- package/website/templates/docs/overriding-styles.html +0 -357
- package/website/templates/docs/using-spreadsheets.html +0 -94
- package/website/templates/error.html +0 -28
- package/website/templates/examples/_common_example_embed.html +0 -27
- package/website/templates/examples/embed-test/index.html +0 -41
- package/website/templates/examples/example.json +0 -328
- package/website/templates/examples/houston/index.html +0 -40
- package/website/templates/examples/houston/timeline2.json +0 -218
- package/website/templates/examples/houston/timeline3.json +0 -271
- package/website/templates/examples/mediatypes/index.html +0 -61
- package/website/templates/examples/mediatypes/timeline3.json +0 -421
- package/website/templates/examples/republican/index.html +0 -49
- package/website/templates/examples/republican/timeline2.json +0 -0
- package/website/templates/examples/republican/timeline3.json +0 -238
- package/website/templates/examples/shit-people-say/index.html +0 -39
- package/website/templates/examples/shit-people-say/timeline2.json +0 -243
- package/website/templates/examples/shit-people-say/timeline3.json +0 -336
- package/website/templates/examples/soundcite/index.html +0 -42
- package/website/templates/examples/soundcite/timeline3.json +0 -271
- package/website/templates/examples/timeline3.json +0 -271
- package/website/templates/examples/twain/index.html +0 -85
- package/website/templates/examples/twain/marktwain.json +0 -502
- package/website/templates/examples/user-interface/index.html +0 -40
- package/website/templates/examples/user-interface/timeline2.json +0 -260
- package/website/templates/examples/user-interface/timeline3.json +0 -327
- package/website/templates/index.html +0 -17
- package/website/templates/mediatype-tests.html +0 -121
- package/website/templates/test/GoogleSpreadsheetFeedLegacyFormat.json +0 -1
- package/website/templates/test/GoogleSpreadsheetFeedTJS3Format.json +0 -1
- package/website/templates/test/maps.html +0 -4
- package/website/templates/unit-tests.html +0 -775
|
@@ -1,775 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
|
|
4
|
-
<head>
|
|
5
|
-
<title>Unit Tests</title>
|
|
6
|
-
|
|
7
|
-
<link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-1.18.0.css" />
|
|
8
|
-
|
|
9
|
-
<script type="text/javascript" src="//cdn.jsdelivr.net/g/underscorejs@1.6.0"></script>
|
|
10
|
-
<script type="text/javascript" src="https://code.jquery.com/qunit/qunit-1.18.0.js"></script>
|
|
11
|
-
|
|
12
|
-
<!-- build:js https://cdn.knightlab.com/libs/timeline3/%(cdn)s/js/timeline-min.js -->
|
|
13
|
-
<script src="/dist/js/timeline.js"></script>
|
|
14
|
-
<!-- endbuild -->
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
<script type="text/javascript">
|
|
18
|
-
function date_dict(d) {
|
|
19
|
-
return {
|
|
20
|
-
'milliseconds': d.data.date_obj.getMilliseconds(),
|
|
21
|
-
'seconds': d.data.date_obj.getSeconds(),
|
|
22
|
-
'minutes': d.data.date_obj.getMinutes(),
|
|
23
|
-
'hours': d.data.date_obj.getHours(),
|
|
24
|
-
'day': d.data.date_obj.getDate(),
|
|
25
|
-
'month': d.data.date_obj.getMonth(), // 0-11 remember
|
|
26
|
-
'year': d.data.date_obj.getYear()
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function date_parts_match(a, b, parts) {
|
|
31
|
-
a = date_dict(a);
|
|
32
|
-
b = date_dict(b);
|
|
33
|
-
for (var i = 0; i < parts.length; i++) {
|
|
34
|
-
if (a[parts[i]] != b[parts[i]]) return false;
|
|
35
|
-
};
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
QUnit.module("TL.Util tests", {});
|
|
40
|
-
QUnit.test("TL.Util", function(assert) {
|
|
41
|
-
var test = [
|
|
42
|
-
[0, 1],
|
|
43
|
-
[2, 3],
|
|
44
|
-
[5, 7]
|
|
45
|
-
];
|
|
46
|
-
assert.equal(TL.Util.maxDepth(test), 1, "Max depth 1.")
|
|
47
|
-
|
|
48
|
-
var test = [
|
|
49
|
-
[0, 5],
|
|
50
|
-
[2, 8],
|
|
51
|
-
[9, 10]
|
|
52
|
-
];
|
|
53
|
-
assert.equal(TL.Util.maxDepth(test), 2, "Max depth 2.")
|
|
54
|
-
|
|
55
|
-
var test = [
|
|
56
|
-
[0, 3],
|
|
57
|
-
[5, 8],
|
|
58
|
-
[9, 10]
|
|
59
|
-
];
|
|
60
|
-
assert.equal(TL.Util.maxDepth(test), 1, "Max depth 1.")
|
|
61
|
-
|
|
62
|
-
var test = [
|
|
63
|
-
[0, 3],
|
|
64
|
-
[2, 8],
|
|
65
|
-
[4, 9],
|
|
66
|
-
[15, 20]
|
|
67
|
-
];
|
|
68
|
-
assert.equal(TL.Util.maxDepth(test), 2, "Max depth 2.")
|
|
69
|
-
|
|
70
|
-
var test = [
|
|
71
|
-
[0, 5],
|
|
72
|
-
[2, 8],
|
|
73
|
-
[4, 9],
|
|
74
|
-
[15, 20]
|
|
75
|
-
];
|
|
76
|
-
assert.equal(TL.Util.maxDepth(test), 3, "Max depth 3.")
|
|
77
|
-
|
|
78
|
-
var test = [
|
|
79
|
-
[0, 5],
|
|
80
|
-
[2, 8],
|
|
81
|
-
[10, 25],
|
|
82
|
-
[15, 20],
|
|
83
|
-
[18, 27],
|
|
84
|
-
[24, 28],
|
|
85
|
-
|
|
86
|
-
];
|
|
87
|
-
assert.equal(TL.Util.maxDepth(test), 3, "Max depth 3.")
|
|
88
|
-
|
|
89
|
-
assert.equal(TL.Util.trim(null), '', "null gets zero length string");
|
|
90
|
-
assert.equal(TL.Util.trim(' bob '), 'bob');
|
|
91
|
-
assert.equal(TL.Util.trim('bob '), 'bob');
|
|
92
|
-
assert.equal(TL.Util.trim('bob'), 'bob');
|
|
93
|
-
assert.ok(TL.Util.trim('bob'), "trimming a non-empty string returns a true value")
|
|
94
|
-
assert.ok(!(TL.Util.trim('')), "trimming an empty string returns a false value")
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
QUnit.test("TL.Util color tools", function(assert) {
|
|
98
|
-
assert.ok(TL.Util.rgbToHex({
|
|
99
|
-
r: 255,
|
|
100
|
-
g: 255,
|
|
101
|
-
b: 255
|
|
102
|
-
}).match(/^#ffffff$/i), "RGB white is Hex white");
|
|
103
|
-
assert.ok(TL.Util.rgbToHex('rgb(218,112,214)').match(/^#DA70D6$/i), "colors convert correctly from rgb string");
|
|
104
|
-
var rgb = TL.Util.hexToRgb('#DA70D6');
|
|
105
|
-
assert.equal(rgb.r, 218, "test hexToRgb red")
|
|
106
|
-
assert.equal(rgb.g, 112, "test hexToRgb green")
|
|
107
|
-
assert.equal(rgb.b, 214, "test hexToRgb blue")
|
|
108
|
-
throws(function(assert) {
|
|
109
|
-
TL.Util.rgbToHex("malformed string")
|
|
110
|
-
}, "make sure bad values throw exceptions 1");
|
|
111
|
-
throws(function(assert) {
|
|
112
|
-
TL.Util.rgbToHex("rgb(218,112)")
|
|
113
|
-
}, "make sure bad values throw exceptions 2");
|
|
114
|
-
throws(function(assert) {
|
|
115
|
-
TL.Util.rgbToHex({
|
|
116
|
-
r: 255,
|
|
117
|
-
g: 255,
|
|
118
|
-
c: 255
|
|
119
|
-
})
|
|
120
|
-
}, "make sure bad values throw exceptions 3");
|
|
121
|
-
var zero_test = TL.Util.rgbToHex({
|
|
122
|
-
r: 0,
|
|
123
|
-
g: 255,
|
|
124
|
-
b: 255
|
|
125
|
-
})
|
|
126
|
-
assert.ok(zero_test.match(/^#00FFFF$/i), "make sure a zero value doesn't throw an exception")
|
|
127
|
-
var from_name = TL.Util.hexToRgb('bisque');
|
|
128
|
-
var from_hex = TL.Util.hexToRgb('#ffe4c4');
|
|
129
|
-
assert.equal(from_name.r, from_hex.r, "named colors should work too... red")
|
|
130
|
-
assert.equal(from_name.g, from_hex.g, "named colors should work too... green")
|
|
131
|
-
assert.equal(from_name.b, from_hex.b, "named colors should work too... blue")
|
|
132
|
-
assert.equal(TL.Util.colorObjToHex(from_name), TL.Util.colorObjToHex(from_hex), "objects to hexes");
|
|
133
|
-
assert.ok(TL.Util.colorObjToHex(from_name).match(/^#ffe4c4$/i), "objects to hexes")
|
|
134
|
-
assert.ok(TL.Util.colorObjToHex(from_hex).match(/^#ffe4c4$/i), "objects to hexes")
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
QUnit.test("TL.Util.linkify", function(assert) {
|
|
138
|
-
var text = "This is some text with a URL in it http://knightlab.northwestern.edu and then some more text";
|
|
139
|
-
var linked = TL.Util.linkify(text);
|
|
140
|
-
assert.ok(linked.startsWith('This is some text with a URL in it <a'), "should start the same and then have a link -> " + linked);
|
|
141
|
-
assert.ok(linked.match(/href=['"]http:\/\/knightlab.northwestern.edu['"]/), "should have an href -> " + linked);
|
|
142
|
-
assert.ok(linked.match(/>knightlab.northwestern.edu<\/a>/), "should have an href " + linked);
|
|
143
|
-
|
|
144
|
-
text = "This is some text with www.google.com in it";
|
|
145
|
-
var linked = TL.Util.linkify(text);
|
|
146
|
-
assert.ok(linked.startsWith('This is some text with <a'), "should start the same and then have a link " + linked);
|
|
147
|
-
assert.ok(linked.match(/href=['"]http:\/\/www.google.com['"]/), "should have an href");
|
|
148
|
-
assert.ok(linked.match(/>www.google.com<\/a>/), "should have the right link text");
|
|
149
|
-
|
|
150
|
-
text = "This is some text with support@knightlab.zendesk.com in it";
|
|
151
|
-
var linked = TL.Util.linkify(text);
|
|
152
|
-
assert.ok(linked.startsWith('This is some text with <a'), "should start the same and then have a link " + linked);
|
|
153
|
-
assert.ok(linked.match(/href=['"]mailto:support@knightlab.zendesk.com['"]/), "should have an href " + linked);
|
|
154
|
-
assert.ok(linked.match(/>support@knightlab.zendesk.com<\/a>/), "should have the right link text " + linked);
|
|
155
|
-
|
|
156
|
-
text = "This is text which already has <a href='http://google.com'>a link</a> in it."
|
|
157
|
-
var not_linked = TL.Util.linkify(text);
|
|
158
|
-
assert.equal(not_linked, text, 'linkify should not have changed anything.')
|
|
159
|
-
|
|
160
|
-
text = 'This is text which already has <a href="http://google.com">a link</a> in it.'
|
|
161
|
-
var not_linked = TL.Util.linkify(text);
|
|
162
|
-
assert.equal(not_linked, text, 'linkify should not have changed anything.')
|
|
163
|
-
|
|
164
|
-
text = 'This is text which already has <a href=http://google.com>a link</a> in it.'
|
|
165
|
-
var not_linked = TL.Util.linkify(text);
|
|
166
|
-
assert.equal(not_linked, text, 'linkify should not have changed anything.')
|
|
167
|
-
|
|
168
|
-
})
|
|
169
|
-
|
|
170
|
-
QUnit.test("TL.Util.findNextGreater", function(assert) {
|
|
171
|
-
var l = [1, 5, 10, 20, 35];
|
|
172
|
-
assert.equal(TL.Util.findNextGreater(l, 1), 5, "5 is next greatest after 1");
|
|
173
|
-
assert.equal(TL.Util.findNextGreater(l, 5), 10, "10 is next greatest after 5");
|
|
174
|
-
assert.equal(TL.Util.findNextGreater(l, 10), 20, "20 is next greatest after 10");
|
|
175
|
-
assert.equal(TL.Util.findNextGreater(l, 15), 20, "correctly handle a curr val which isn't in the list");
|
|
176
|
-
assert.equal(TL.Util.findNextGreater(l, 35), 35, "handle value at end of list");
|
|
177
|
-
assert.equal(TL.Util.findNextGreater(l, 40), 40, "handle value greater than max in list");
|
|
178
|
-
assert.equal(TL.Util.findNextGreater(l, 40, 35), 35, "handle greater than max in list with default");
|
|
179
|
-
|
|
180
|
-
assert.equal(TL.Util.findNextLesser(l, 1), 1, "1 is least");
|
|
181
|
-
assert.equal(TL.Util.findNextLesser(l, 5), 1, "1 is least after 5");
|
|
182
|
-
assert.equal(TL.Util.findNextLesser(l, 10), 5, "20 is next greatest after 10");
|
|
183
|
-
assert.equal(TL.Util.findNextLesser(l, 15), 10, "10 is less than 15 (which isn't in list)");
|
|
184
|
-
assert.equal(TL.Util.findNextLesser(l, 35), 20, "20 less than 35");
|
|
185
|
-
assert.equal(TL.Util.findNextLesser(l, 40), 35, "35 is less than 40");
|
|
186
|
-
assert.equal(TL.Util.findNextLesser(l, 0, 0), 0, "handle less than min in list without default");
|
|
187
|
-
assert.equal(TL.Util.findNextLesser(l, 0, -10), -10, "handle less than min in list with default");
|
|
188
|
-
})
|
|
189
|
-
|
|
190
|
-
QUnit.test("TL.Util.isEmptyObject", function(assert) {
|
|
191
|
-
o = {}
|
|
192
|
-
assert.ok(TL.Util.isEmptyObject(o), "no keys should be empty");
|
|
193
|
-
o.foo = " ";
|
|
194
|
-
assert.ok(TL.Util.isEmptyObject(o), "empty string should be empty");
|
|
195
|
-
o.bar = "";
|
|
196
|
-
assert.ok(TL.Util.isEmptyObject(o), "2 empty strings should be empty");
|
|
197
|
-
o.baz = null;
|
|
198
|
-
assert.ok(TL.Util.isEmptyObject(o), "add null, still should be empty");
|
|
199
|
-
o.foo = " not empty ";
|
|
200
|
-
assert.equal(TL.Util.isEmptyObject(o), false, "adding a string ")
|
|
201
|
-
})
|
|
202
|
-
|
|
203
|
-
QUnit.test("TL.Util.parseYouTubeTime", function(assert) {
|
|
204
|
-
assert.equal(TL.Util.parseYouTubeTime('5s'), 5, "parse seconds only")
|
|
205
|
-
assert.equal(TL.Util.parseYouTubeTime('1m5s'), 65, "parse m/s")
|
|
206
|
-
assert.equal(TL.Util.parseYouTubeTime('2h4m5s'), 7445, "parse h/m/s")
|
|
207
|
-
assert.equal(TL.Util.parseYouTubeTime('5m'), 300, "parse minutes only")
|
|
208
|
-
assert.equal(TL.Util.parseYouTubeTime('1h'), 3600, "parse hours only")
|
|
209
|
-
assert.equal(TL.Util.parseYouTubeTime(''), 0, "handle empty string")
|
|
210
|
-
assert.equal(TL.Util.parseYouTubeTime(null), 0, "handle empty string")
|
|
211
|
-
assert.equal(TL.Util.parseYouTubeTime('4:55'), 0, "handle malformed string")
|
|
212
|
-
assert.equal(TL.Util.parseYouTubeTime(5), 5, "handle number")
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
QUnit.test("TL.Util.ensureUniqueKey", function(assert) {
|
|
216
|
-
var o = {
|
|
217
|
-
foo: 1,
|
|
218
|
-
bar: 2
|
|
219
|
-
}
|
|
220
|
-
assert.ok(!(TL.Util.ensureUniqueKey(o, 'foo') in o), "should be unique");
|
|
221
|
-
assert.equal(TL.Util.ensureUniqueKey(o, 'baz'), 'baz', "not in there, give it back");
|
|
222
|
-
assert.equal(TL.Util.ensureUniqueKey(o, 'foo'), 'foo-2', "treat existing as 1-based");
|
|
223
|
-
o['foo-2'] = 3;
|
|
224
|
-
assert.ok(!(TL.Util.ensureUniqueKey(o, 'foo') in o), "should be unique");
|
|
225
|
-
var random = TL.Util.ensureUniqueKey(o, '');
|
|
226
|
-
assert.ok(TL.Util.trim(random), "Should get a non-empty string");
|
|
227
|
-
assert.ok(!(random in o), "empty string should get non-empty unique");
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
QUnit.module("TL.Date tests", {});
|
|
232
|
-
|
|
233
|
-
QUnit.test("TL.Date", function(assert) {
|
|
234
|
-
var refdate = TL.Date.makeDate({
|
|
235
|
-
year: 2000,
|
|
236
|
-
month: 6,
|
|
237
|
-
day: 21
|
|
238
|
-
});
|
|
239
|
-
var jsdate = new Date();
|
|
240
|
-
throws(function(assert) {
|
|
241
|
-
refdate.isBefore(jsdate)
|
|
242
|
-
}, "Don't allow comparison with JS Dates");
|
|
243
|
-
jsdate = TL.Date.makeDate(new Date());
|
|
244
|
-
assert.ok(refdate.isBefore(jsdate), "refdate should be before any new date");
|
|
245
|
-
assert.ok(jsdate.isAfter(refdate), "any new date should be after refdate");
|
|
246
|
-
|
|
247
|
-
var smalldate = TL.Date.makeDate({
|
|
248
|
-
year: 2015
|
|
249
|
-
});
|
|
250
|
-
assert.ok(!isNaN(smalldate.getTime()), "small dates are human");
|
|
251
|
-
|
|
252
|
-
var bigdate = TL.Date.makeDate({
|
|
253
|
-
year: 1000000
|
|
254
|
-
});
|
|
255
|
-
assert.ok(!isNaN(bigdate.getTime()), "big dates are cosmological");
|
|
256
|
-
|
|
257
|
-
var cdate = TL.Date.makeDate({
|
|
258
|
-
year: 2014,
|
|
259
|
-
display_date: "hello"
|
|
260
|
-
});
|
|
261
|
-
assert.equal(cdate.getDisplayDate(), 'hello', 'display_text overrides other formatting')
|
|
262
|
-
|
|
263
|
-
var date = TL.Date.makeDate({
|
|
264
|
-
year: 75
|
|
265
|
-
});
|
|
266
|
-
assert.equal(date.getDisplayDate(), "75", "handle years in the first century CE correctly")
|
|
267
|
-
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
QUnit.test("TL.Date.parseDate", function(assert) {
|
|
271
|
-
var d = TL.Date.parseDate('2014-08-20');
|
|
272
|
-
assert.equal(d.year, '2014', 'three part date gets year 2014');
|
|
273
|
-
assert.equal(d.month, '08', 'three part date gets month 08');
|
|
274
|
-
assert.equal(d.day, '20', 'three part date gets day 20');
|
|
275
|
-
|
|
276
|
-
var d = TL.Date.parseDate('2014-08');
|
|
277
|
-
assert.equal(d.year, '2014', 'two part date gets year 2014');
|
|
278
|
-
assert.equal(d.month, '08', 'two part date gets month 08');
|
|
279
|
-
assert.ok(!(d.day), 'two-part date has no day');
|
|
280
|
-
|
|
281
|
-
var d = TL.Date.parseDate('2014');
|
|
282
|
-
assert.equal(d.year, '2014', 'year-only date gets 2014');
|
|
283
|
-
assert.ok(!(d.month), 'year only date has no month');
|
|
284
|
-
assert.ok(!(d.day), 'year only date has no day');
|
|
285
|
-
|
|
286
|
-
var d = TL.Date.parseDate('-6');
|
|
287
|
-
assert.equal(d.year, '-6', 'year-only date gets -6 (BC ok)');
|
|
288
|
-
assert.ok(!(d.month), 'year only date has no month');
|
|
289
|
-
assert.ok(!(d.day), 'year only date has no day');
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
QUnit.test("TL.Date.findBestFormat", function(assert) {
|
|
295
|
-
var date = new TL.Date({
|
|
296
|
-
'year': 1975,
|
|
297
|
-
month: 7
|
|
298
|
-
})
|
|
299
|
-
assert.equal(date.findBestFormat(), "month", "Expect a format key")
|
|
300
|
-
assert.equal(date.findBestFormat(true), "month_short", "Expect a different format key for short (legacy)")
|
|
301
|
-
assert.equal(date.findBestFormat('short'), "month_short", "Expect a different format key for short (explicit)")
|
|
302
|
-
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
QUnit.test("TL.Date.floor", function(assert) {
|
|
306
|
-
throws(function(assert) {
|
|
307
|
-
TL.Date.makeDate(new Date()).floor('foobar');
|
|
308
|
-
}, new RegExp(/invalid_scale_err/), "bad scale throws invalid_scale_err error.")
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
var d = TL.Date.makeDate(new Date(1407440158306)); // Thu Aug 07 2014 14:35:58 GMT-0500 (CDT)
|
|
312
|
-
var floored = d.floor('millisecond');
|
|
313
|
-
var date_obj = floored.data.date_obj;
|
|
314
|
-
assert.ok(date_parts_match(d, floored, ['year', 'month', 'date', 'hours', 'minutes', 'seconds', 'milliseconds']), 'millisecond rounding doesnt change others')
|
|
315
|
-
assert.equal(date_obj.getTime(), d.getTime(), 'rounds to millisecond')
|
|
316
|
-
|
|
317
|
-
var floored = d.floor('second');
|
|
318
|
-
var date_obj = floored.data.date_obj;
|
|
319
|
-
assert.ok(date_parts_match(d, floored, ['year', 'month', 'date', 'hours', 'minutes', 'seconds']), 'second rounding doesnt change others')
|
|
320
|
-
assert.equal(date_obj.getMilliseconds(), 0, 'seconds round to 0 millis ' + floored)
|
|
321
|
-
|
|
322
|
-
var floored = d.floor('minute');
|
|
323
|
-
var date_obj = floored.data.date_obj;
|
|
324
|
-
assert.ok(date_parts_match(d, floored, ['year', 'month', 'date', 'hours', 'minutes']), 'minute rounding doesnt change others')
|
|
325
|
-
assert.equal(date_obj.getMilliseconds(), 0, 'minutes round to 0 millis ' + floored)
|
|
326
|
-
assert.equal(date_obj.getSeconds(), 0, 'minutes round to 0 seconds ' + floored)
|
|
327
|
-
|
|
328
|
-
var floored = d.floor('hour');
|
|
329
|
-
var date_obj = floored.data.date_obj;
|
|
330
|
-
assert.ok(date_parts_match(d, floored, ['year', 'month', 'date', 'hours']), 'hour rounding doesnt change others')
|
|
331
|
-
assert.equal(date_obj.getMilliseconds(), 0, 'hours round to 0 millis ' + floored)
|
|
332
|
-
assert.equal(date_obj.getSeconds(), 0, 'hours round to 0 seconds ' + floored)
|
|
333
|
-
assert.equal(date_obj.getMinutes(), 0, 'hours round to 0 minutes ' + floored)
|
|
334
|
-
|
|
335
|
-
var floored = d.floor('day');
|
|
336
|
-
var date_obj = floored.data.date_obj;
|
|
337
|
-
assert.ok(date_parts_match(d, floored, ['year', 'month', 'date']), 'day rounding doesnt change others')
|
|
338
|
-
assert.equal(date_obj.getMilliseconds(), 0, 'days round to 0 millis ' + floored)
|
|
339
|
-
assert.equal(date_obj.getSeconds(), 0, 'days round to 0 seconds ' + floored)
|
|
340
|
-
assert.equal(date_obj.getMinutes(), 0, 'days round to 0 minutes ' + floored)
|
|
341
|
-
assert.equal(date_obj.getHours(), 0, 'days round to 0 hours ' + floored)
|
|
342
|
-
|
|
343
|
-
var floored = d.floor('month');
|
|
344
|
-
var date_obj = floored.data.date_obj;
|
|
345
|
-
assert.ok(date_parts_match(d, floored, ['year', 'month']), 'month rounding doesnt change others')
|
|
346
|
-
assert.equal(date_obj.getMilliseconds(), 0, 'months round to 0 millis ' + floored)
|
|
347
|
-
assert.equal(date_obj.getSeconds(), 0, 'months round to 0 seconds ' + floored)
|
|
348
|
-
assert.equal(date_obj.getMinutes(), 0, 'months round to 0 minutes ' + floored)
|
|
349
|
-
assert.equal(date_obj.getHours(), 0, 'months round to 0 hours ' + floored)
|
|
350
|
-
assert.equal(date_obj.getDate(), 1, 'months round to day 1 ' + floored)
|
|
351
|
-
|
|
352
|
-
var floored = d.floor('year');
|
|
353
|
-
var date_obj = floored.data.date_obj;
|
|
354
|
-
assert.ok(date_parts_match(d, floored, ['year']), 'year rounding doesnt change others')
|
|
355
|
-
assert.equal(date_obj.getMilliseconds(), 0, 'years round to 0 millis ' + floored)
|
|
356
|
-
assert.equal(date_obj.getSeconds(), 0, 'years round to 0 seconds ' + floored)
|
|
357
|
-
assert.equal(date_obj.getMinutes(), 0, 'years round to 0 minutes ' + floored)
|
|
358
|
-
assert.equal(date_obj.getHours(), 0, 'years round to 0 hours ' + floored)
|
|
359
|
-
assert.equal(date_obj.getDate(), 1, 'years round to day 1 ' + floored)
|
|
360
|
-
assert.equal(date_obj.getMonth(), 0, 'years round to month 0 ' + floored)
|
|
361
|
-
|
|
362
|
-
var floored = d.floor('decade');
|
|
363
|
-
var date_obj = floored.data.date_obj;
|
|
364
|
-
assert.equal(date_obj.getYear(), 110, "decade should round to 2010 " + floored)
|
|
365
|
-
|
|
366
|
-
var floored = d.floor('century');
|
|
367
|
-
var date_obj = floored.data.date_obj;
|
|
368
|
-
assert.equal(date_obj.getYear(), 100, "century should round to 2000 " + floored)
|
|
369
|
-
|
|
370
|
-
var floored = d.floor('millennium');
|
|
371
|
-
var date_obj = floored.data.date_obj;
|
|
372
|
-
assert.equal(date_obj.getYear(), 100, "Should round to 2000 " + floored)
|
|
373
|
-
|
|
374
|
-
var early_ce = TL.Date.makeDate(-59149708181438); // 8/14/95 (90 not 1995)
|
|
375
|
-
var floored = early_ce.floor('decade');
|
|
376
|
-
assert.equal(floored.getTime(), -59326970400000, 'Early floored dates should not go into the 20th Century')
|
|
377
|
-
|
|
378
|
-
var age_scale = TL.Date.makeDate({
|
|
379
|
-
year: 1500000
|
|
380
|
-
});
|
|
381
|
-
throws(function(assert) {
|
|
382
|
-
age_scale.floor('month');
|
|
383
|
-
}, /invalid_scale_err/, 'month not valid scale for cosmo');
|
|
384
|
-
assert.equal(age_scale.floor('age').getTime(), 1000000, 'Should floor to 1M years');
|
|
385
|
-
|
|
386
|
-
var cosmo_year = new TL.BigDate({
|
|
387
|
-
'year': 1945
|
|
388
|
-
});
|
|
389
|
-
assert.equal(cosmo_year.floor('decade').getTime(), 1940, 'decade should floor 1945 to 1940')
|
|
390
|
-
|
|
391
|
-
});
|
|
392
|
-
|
|
393
|
-
QUnit.test("TL.Date date formatting", function(assert) {
|
|
394
|
-
var msgs = TL.Language.default;
|
|
395
|
-
var d = TL.Date.makeDate({
|
|
396
|
-
year: '2014',
|
|
397
|
-
month: '1',
|
|
398
|
-
day: '1'
|
|
399
|
-
})
|
|
400
|
-
assert.equal(d.getDisplayDate(msgs), "January 1, 2014")
|
|
401
|
-
var d = TL.Date.makeDate({
|
|
402
|
-
year: '2014'
|
|
403
|
-
})
|
|
404
|
-
assert.equal(d.getDisplayDate(msgs), "2014")
|
|
405
|
-
});
|
|
406
|
-
|
|
407
|
-
QUnit.test("TL.Util.isTrue", function(assert) {
|
|
408
|
-
assert.ok(TL.Util.isTrue(true));
|
|
409
|
-
assert.notOk(TL.Util.isTrue(false));
|
|
410
|
-
assert.notOk(TL.Util.isTrue());
|
|
411
|
-
assert.notOk(TL.Util.isTrue(null));
|
|
412
|
-
assert.ok(TL.Util.isTrue('true'));
|
|
413
|
-
assert.ok(TL.Util.isTrue(1));
|
|
414
|
-
})
|
|
415
|
-
|
|
416
|
-
QUnit.module("TL.DateUtil tests", {});
|
|
417
|
-
QUnit.test("TL.DateUtil", function(assert) {
|
|
418
|
-
var a = {
|
|
419
|
-
start_date: TL.Date.makeDate({
|
|
420
|
-
year: 1999
|
|
421
|
-
})
|
|
422
|
-
} // will break when we have start dates
|
|
423
|
-
var b = {
|
|
424
|
-
start_date: TL.Date.makeDate({
|
|
425
|
-
year: 2000
|
|
426
|
-
})
|
|
427
|
-
}
|
|
428
|
-
var c = {
|
|
429
|
-
start_date: TL.Date.makeDate({
|
|
430
|
-
year: 2001
|
|
431
|
-
})
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
var ary = [c, b, a]
|
|
435
|
-
TL.DateUtil.sortByDate(ary);
|
|
436
|
-
assert.equal(ary[0], a, "A should sort first")
|
|
437
|
-
assert.equal(ary[1], b, "B should sort second")
|
|
438
|
-
assert.equal(ary[2], c, "C should sort third")
|
|
439
|
-
|
|
440
|
-
ary = [b, a, c];
|
|
441
|
-
TL.DateUtil.sortByDate(ary);
|
|
442
|
-
assert.equal(ary[0], a, "A should sort first")
|
|
443
|
-
assert.equal(ary[1], b, "B should sort second")
|
|
444
|
-
assert.equal(ary[2], c, "C should sort third")
|
|
445
|
-
|
|
446
|
-
ary = [b, c, a]
|
|
447
|
-
TL.DateUtil.sortByDate(ary);
|
|
448
|
-
assert.equal(ary[0], a, "A should sort first")
|
|
449
|
-
assert.equal(ary[1], b, "B should sort second")
|
|
450
|
-
assert.equal(ary[2], c, "C should sort third")
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
})
|
|
454
|
-
|
|
455
|
-
QUnit.test("TL.DateUtil.parseTime", function(assert) {
|
|
456
|
-
|
|
457
|
-
var test_date = function(time_str, expected_hour, expected_minute, expected_second, expected_milli) {
|
|
458
|
-
try {
|
|
459
|
-
var parsed = TL.DateUtil.parseTime(time_str);
|
|
460
|
-
assert.equal(parsed.hour, expected_hour, time_str + " expected hour " + expected_hour);
|
|
461
|
-
assert.equal(parsed.minute, expected_minute, time_str + " expected minute " + expected_minute);
|
|
462
|
-
assert.equal(parsed.second, expected_second, time_str + " expected second " + expected_second);
|
|
463
|
-
assert.equal(parsed.millisecond, expected_milli, time_str + " expected milli " + expected_milli);
|
|
464
|
-
} catch (e) {
|
|
465
|
-
assert.ok(false, "Failure testing " + time_str + " got " + e);
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
}
|
|
470
|
-
test_date('11:30:40.5', 11, 30, 40, 500);
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
test_date('11:30', 11, 30, null, null);
|
|
474
|
-
test_date('11.30', 11, 30, null, null);
|
|
475
|
-
test_date('1130', 11, 30, null, null);
|
|
476
|
-
test_date('11.30pm', 23, 30, null, null);
|
|
477
|
-
test_date('11:30 pm', 23, 30, null, null);
|
|
478
|
-
test_date('1130 pm', 23, 30, null, null);
|
|
479
|
-
test_date('11:30:40', 11, 30, 40, null);
|
|
480
|
-
test_date('23:30:40', 23, 30, 40, null);
|
|
481
|
-
test_date('11:30:40 pm', 23, 30, 40, null);
|
|
482
|
-
test_date('11:30:40pm', 23, 30, 40, null);
|
|
483
|
-
test_date("12:33 PM", 12, 33, null, null);
|
|
484
|
-
test_date("1233", 12, 33, null, null);
|
|
485
|
-
test_date("12:33 a.m.", 0, 33, null, null);
|
|
486
|
-
test_date("0033", 0, 33, null, null);
|
|
487
|
-
throws(function(assert) {
|
|
488
|
-
TL.DateUtil.parseTime('24:30')
|
|
489
|
-
}, /invalid_hour_err/i, "hour 24 throws invalid_hour_err error");
|
|
490
|
-
throws(function(assert) {
|
|
491
|
-
TL.DateUtil.parseTime('23:30pm')
|
|
492
|
-
}, /invalid_hour_err/i, 'hour 23 with pm throws invalid_hour_err error');
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
});
|
|
497
|
-
|
|
498
|
-
QUnit.module("TL.Language tests", {});
|
|
499
|
-
QUnit.test("TL.Language", function(assert) {
|
|
500
|
-
var msgs = new TL.Language();
|
|
501
|
-
assert.equal(msgs.name, "English", "English is default");
|
|
502
|
-
assert.equal(msgs.lang, "en", "en is default");
|
|
503
|
-
assert.equal(msgs._('loading'), "Loading", "get a message");
|
|
504
|
-
assert.equal(msgs._('foobar'), "foobar", "invalid keys should pass through");
|
|
505
|
-
|
|
506
|
-
var msgs = TL.Language.fallback;
|
|
507
|
-
assert.equal(msgs.name, "English", "English is default");
|
|
508
|
-
assert.equal(msgs.lang, "en", "en is default");
|
|
509
|
-
assert.equal(msgs._('loading'), "Loading", "get a message");
|
|
510
|
-
assert.equal(msgs._('foobar'), "foobar", "invalid keys should pass through");
|
|
511
|
-
|
|
512
|
-
assert.equal(TL.Language.formatNumber(18.54, '%.1f and some other stuff'), "18.5 and some other stuff", "check rounding and replacement")
|
|
513
|
-
|
|
514
|
-
assert.equal(TL.Language.formatNumber(18.54, 'a literal display year'), 'a literal display year', "pass through literals as display dates")
|
|
515
|
-
|
|
516
|
-
assert.equal(msgs.formatBigYear({
|
|
517
|
-
'year': 20000
|
|
518
|
-
}, 'foobar'), '20.0 thousand years ago', "use fallback bigdateformat")
|
|
519
|
-
})
|
|
520
|
-
|
|
521
|
-
QUnit.test("TL.Language test non-english", function(assert) {
|
|
522
|
-
var msgs = new TL.Language({
|
|
523
|
-
language: 'pl'
|
|
524
|
-
});
|
|
525
|
-
assert.equal(msgs.name, "English", "English is default and polish doesn't have one");
|
|
526
|
-
assert.equal(msgs.lang, "pl", "should have gotten 'pl'");
|
|
527
|
-
assert.equal(msgs._('loading'), "\u0141adowanie", "get a message for loading");
|
|
528
|
-
assert.equal(msgs._('foobar'), "foobar", "invalid keys should pass through");
|
|
529
|
-
});
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
QUnit.test("TL.Language date formatting", function(assert) {
|
|
533
|
-
var msgs = TL.Language.fallback;
|
|
534
|
-
var d = new Date(2014, 7, 7, 4, 5, 0);
|
|
535
|
-
assert.equal(msgs.formatDate(d, 'd'), '7', 'short day');
|
|
536
|
-
assert.equal(msgs.formatDate(d, 'dd'), '07', 'padded day');
|
|
537
|
-
assert.equal(msgs.formatDate(d, 'ddd'), 'Thurs.', 'short day of week');
|
|
538
|
-
assert.equal(msgs.formatDate(d, 'dddd'), 'Thursday', 'full day of week');
|
|
539
|
-
assert.equal(msgs.formatDate(d, 'm'), '8', 'month number');
|
|
540
|
-
assert.equal(msgs.formatDate(d, 'mm'), '08', 'padded month number');
|
|
541
|
-
assert.equal(msgs.formatDate(d, 'mmm'), 'Aug.', 'short month name');
|
|
542
|
-
assert.equal(msgs.formatDate(d, 'mmmm'), 'August', 'long month name');
|
|
543
|
-
assert.equal(msgs.formatDate(d, 'yy'), '14', 'short year');
|
|
544
|
-
assert.equal(msgs.formatDate(d, 'yyyy'), '2014', 'long year');
|
|
545
|
-
assert.equal(msgs.formatDate(d, 'h'), '4', 'hour');
|
|
546
|
-
assert.equal(msgs.formatDate(d, 'hh'), '04', 'padded hour');
|
|
547
|
-
assert.equal(msgs.formatDate(d, 'H'), '4', 'hour (24HR)');
|
|
548
|
-
assert.equal(msgs.formatDate(d, 'HH'), '04', 'padded hour (24HR)');
|
|
549
|
-
assert.equal(msgs.formatDate(d, 'M'), '5', 'minute');
|
|
550
|
-
assert.equal(msgs.formatDate(d, 'MM'), '05', 'padded minute');
|
|
551
|
-
var d2 = new Date(d.getTime() + (1000 * 60 * 60 * 12));
|
|
552
|
-
assert.equal(msgs.formatDate(d2, 'H'), '16', 'hour (24HR after noon)');
|
|
553
|
-
assert.equal(msgs.formatDate(d2, 'HH'), '16', 'padded hour (24HR after noon)');
|
|
554
|
-
assert.equal(msgs.formatDate(d, 's'), '0', 'second');
|
|
555
|
-
assert.equal(msgs.formatDate(d, 'ss'), '00', 'padded second');
|
|
556
|
-
|
|
557
|
-
var d = new Date(2014, 7, 7, 4, 5, 0);
|
|
558
|
-
d.setFullYear(-500);
|
|
559
|
-
assert.equal(msgs.formatDate(d, 'yyyy'), '500 <span>BCE</span>', 'BCE date');
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
});
|
|
563
|
-
|
|
564
|
-
// QUnit.test("TimeScale._assessGroups", function(assert){
|
|
565
|
-
// var slides = [{group: 'alice'}, { group: 'bob'}, {group: 'alice'}, {group: 'carol'}];
|
|
566
|
-
// var groups = TL.TimeScale._assessGroups(slides);
|
|
567
|
-
// assert.equal(groups.length,3);
|
|
568
|
-
// });
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
function asyncJSON(url) {
|
|
572
|
-
var data = TL.ajax({
|
|
573
|
-
url: url,
|
|
574
|
-
async: false
|
|
575
|
-
});
|
|
576
|
-
return JSON.parse(data.responseText);
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
QUnit.module("TL.ConfigFactory tests", {});
|
|
580
|
-
|
|
581
|
-
QUnit.test("TL.ConfigFactory", function(assert) {
|
|
582
|
-
var data = TL.ConfigFactory.googleFeedJSONtoTimelineJSON(asyncJSON('test/GoogleSpreadsheetFeedLegacyFormat.json'));
|
|
583
|
-
assert.equal(7, data.events.length, "7 entries in GoogleSpreadsheetFeedLegacyFormat");
|
|
584
|
-
assert.ok(data.title, "There should be a title.")
|
|
585
|
-
var data = TL.ConfigFactory.googleFeedJSONtoTimelineJSON(asyncJSON('test/GoogleSpreadsheetFeedTJS3Format.json'));
|
|
586
|
-
assert.equal(7, data.events.length, "7 events in GoogleSpreadsheetFeedTJS3Format (one title)");
|
|
587
|
-
assert.ok(data.title, "There should be a title.")
|
|
588
|
-
assert.equal(2012, data.events[0].start_date.year, "first non-title event is year 2012");
|
|
589
|
-
assert.equal(2011, data.events[6].start_date.year, "last non-title event is year 2011");
|
|
590
|
-
});
|
|
591
|
-
|
|
592
|
-
QUnit.test("TL.ConfigFactory.parseGoogleSpreadsheetURL", function(assert) {
|
|
593
|
-
var key = '1cWqQBZCkX9GpzFtxCWHoqFXCHg-ylTVUWlnrdYMzKUI';
|
|
594
|
-
var parts = TL.ConfigFactory.parseGoogleSpreadsheetURL(key);
|
|
595
|
-
assert.equal(key, parts.key, "Bare sheet ID should come back in key")
|
|
596
|
-
|
|
597
|
-
var url = 'https://docs.google.com/spreadsheets/d/1a8jYcSMWGXupicLJhtNAhkQfta8Fc5qKinDIJtroOAI/pubhtml'
|
|
598
|
-
var key = '1a8jYcSMWGXupicLJhtNAhkQfta8Fc5qKinDIJtroOAI';
|
|
599
|
-
var parts = TL.ConfigFactory.parseGoogleSpreadsheetURL(url);
|
|
600
|
-
assert.equal(key, parts.key, "new-ish url format should get the right key")
|
|
601
|
-
|
|
602
|
-
var url = 'https://docs.google.com/spreadsheets/d/1a8jYcSMWGXupicLJhtNAhkQfta8Fc5qKinDIJtroOAI/pubhtml?gid=2066744085'
|
|
603
|
-
var key = '1a8jYcSMWGXupicLJhtNAhkQfta8Fc5qKinDIJtroOAI';
|
|
604
|
-
var worksheet = '2066744085';
|
|
605
|
-
var parts = TL.ConfigFactory.parseGoogleSpreadsheetURL(url);
|
|
606
|
-
assert.equal(key, parts.key, "new-ish url format should get the right key")
|
|
607
|
-
assert.equal(worksheet, parts.worksheet, "new-ish url format should get the right worksheet")
|
|
608
|
-
|
|
609
|
-
var url = 'https://docs.google.com/spreadsheets/d/1_7l1RsxQIodkOuKguCPMVQWgmQLGoPr7nBQa9l1k5_4/pubhtml'
|
|
610
|
-
var key = '1_7l1RsxQIodkOuKguCPMVQWgmQLGoPr7nBQa9l1k5_4';
|
|
611
|
-
var parts = TL.ConfigFactory.parseGoogleSpreadsheetURL(url);
|
|
612
|
-
assert.equal(key, parts.key, "new-ish url format should get the right key")
|
|
613
|
-
});
|
|
614
|
-
|
|
615
|
-
QUnit.module("TimelineConfig ajax tests", {});
|
|
616
|
-
|
|
617
|
-
QUnit.test("Handling CDN 'preview' URLs", function(assert) {
|
|
618
|
-
assert.expect(2);
|
|
619
|
-
var bad_url = 'https://cdn.knightlab.com/libs/timeline3/latest/embed/index.html?source=1cWqQBZCkX9GpzFtxCWHoqFXCHg-ylTVUWlnrdYMzKUI&font=Default&lang=en&initial_zoom=2&height=650';
|
|
620
|
-
var done = assert.async();
|
|
621
|
-
var config = TL.ConfigFactory.makeConfig(bad_url, function(config) {
|
|
622
|
-
assert.notOk(config.isValid(), "Bad URL should result in invalid timeline config.");
|
|
623
|
-
var tl_error = config.messages.errors[0];
|
|
624
|
-
assert.equal(tl_error.message_key, 'invalid_url_err', "Expect 'invalid_url_err' in message key.");
|
|
625
|
-
done();
|
|
626
|
-
})
|
|
627
|
-
})
|
|
628
|
-
|
|
629
|
-
QUnit.module("user-interface JSON tests", {});
|
|
630
|
-
|
|
631
|
-
QUnit.test("TimelineConfig for user-interface", function(assert) {
|
|
632
|
-
|
|
633
|
-
var done = assert.async();
|
|
634
|
-
TL.ConfigFactory.makeConfig('/examples/user-interface/timeline3.json', function(config) {
|
|
635
|
-
assert.ok((typeof(config) != undefined), "config loaded")
|
|
636
|
-
console.log(config, " is null? ")
|
|
637
|
-
window.stash = config;
|
|
638
|
-
assert.ok((typeof(config.events) != undefined), "config has events")
|
|
639
|
-
var slides = config.events;
|
|
640
|
-
var sorted = true;
|
|
641
|
-
for (var i = 0; i < slides.length - 1; i++) {
|
|
642
|
-
var earlier = slides[i];
|
|
643
|
-
var later = slides[i + 1];
|
|
644
|
-
sorted = sorted && (earlier.start_date.data.date_obj <= later.start_date.data.date_obj);
|
|
645
|
-
};
|
|
646
|
-
assert.ok(sorted, "dates are sorted");
|
|
647
|
-
done();
|
|
648
|
-
});
|
|
649
|
-
|
|
650
|
-
});
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
QUnit.test("TimeScale", function(assert) {
|
|
655
|
-
var done = assert.async();
|
|
656
|
-
TL.ConfigFactory.makeConfig('/examples/user-interface/timeline3.json', function(config) {
|
|
657
|
-
assert.ok(config, "test data loaded");
|
|
658
|
-
var timescale = new TL.TimeScale(config, {
|
|
659
|
-
display_width: 2200,
|
|
660
|
-
screen_multiplier: 3
|
|
661
|
-
});
|
|
662
|
-
assert.equal(timescale.getMinorScale(), 'year', "timescale should be years");
|
|
663
|
-
assert.ok(timescale.getTicks().major.ticks.length > 0, "should be some major ticks")
|
|
664
|
-
assert.ok(timescale.getTicks().minor.ticks.length > 0, "should be some minor ticks")
|
|
665
|
-
assert.equal(timescale.getNumberOfRows(), 3, "Expecting 3 rows") // this will change if someone monkeys around with the config file!
|
|
666
|
-
assert.equal(timescale.getScale(), 'human', 'test case uses human dates')
|
|
667
|
-
done();
|
|
668
|
-
});
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
});
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
QUnit.module("marktwain.json tests", {});
|
|
675
|
-
|
|
676
|
-
QUnit.test("TimeScale", function(assert) {
|
|
677
|
-
var done = assert.async();
|
|
678
|
-
TL.ConfigFactory.makeConfig('/examples/twain/marktwain.json', function(config) {
|
|
679
|
-
var timescale = new TL.TimeScale(config);
|
|
680
|
-
assert.equal(timescale.getNumberOfRows(), 5, "expect 5 rows");
|
|
681
|
-
assert.equal(timescale._positions.length, config.events.length, "There should be the same number of positions (" + timescale._positions.length + ") as slides (" + config.events.length + ")")
|
|
682
|
-
var row_check = new Array(timescale.getNumberOfRows());
|
|
683
|
-
for (var i = 0; i < row_check.length; i++) {
|
|
684
|
-
row_check[i] = [];
|
|
685
|
-
};
|
|
686
|
-
var all_posinfos_defined = true;
|
|
687
|
-
|
|
688
|
-
for (var i = 0; i < config.events.length; i++) {
|
|
689
|
-
var pos_info = timescale.getPositionInfo(i);
|
|
690
|
-
all_posinfos_defined = all_posinfos_defined && (typeof(pos_info) != "undefined")
|
|
691
|
-
row_check[pos_info.row].push(pos_info);
|
|
692
|
-
};
|
|
693
|
-
assert.ok(all_posinfos_defined, "There should be a pos_info for every idx");
|
|
694
|
-
var slides_in_rows = 0;
|
|
695
|
-
for (var i = 0; i < timescale.getNumberOfRows(); i++) {
|
|
696
|
-
slides_in_rows += row_check[i].length;
|
|
697
|
-
var no_overlaps = true;
|
|
698
|
-
for (var j = 1; j < row_check[i].length; j++) {
|
|
699
|
-
no_overlaps = no_overlaps && (row_check[i][j - 1].end < row_check[i][j].start);
|
|
700
|
-
};
|
|
701
|
-
assert.ok(no_overlaps, "No overlaps in row " + i)
|
|
702
|
-
};
|
|
703
|
-
assert.equal(slides_in_rows, config.events.length, "In checking rows we should have seen all slides")
|
|
704
|
-
done();
|
|
705
|
-
});
|
|
706
|
-
})
|
|
707
|
-
|
|
708
|
-
QUnit.test("TimeScale max rows", function(assert) {
|
|
709
|
-
var config = new TL.TimelineConfig({
|
|
710
|
-
scale: 'cosmological',
|
|
711
|
-
events: [{
|
|
712
|
-
start_date: {
|
|
713
|
-
year: 1
|
|
714
|
-
},
|
|
715
|
-
end_date: {
|
|
716
|
-
year: 1000
|
|
717
|
-
}
|
|
718
|
-
}, {
|
|
719
|
-
start_date: {
|
|
720
|
-
year: 100
|
|
721
|
-
},
|
|
722
|
-
end_date: {
|
|
723
|
-
year: 1500
|
|
724
|
-
}
|
|
725
|
-
}, {
|
|
726
|
-
start_date: {
|
|
727
|
-
year: 200
|
|
728
|
-
},
|
|
729
|
-
end_date: {
|
|
730
|
-
year: 2000
|
|
731
|
-
}
|
|
732
|
-
}, {
|
|
733
|
-
start_date: {
|
|
734
|
-
year: 300
|
|
735
|
-
},
|
|
736
|
-
end_date: {
|
|
737
|
-
year: 2500
|
|
738
|
-
}
|
|
739
|
-
}, {
|
|
740
|
-
start_date: {
|
|
741
|
-
year: 400
|
|
742
|
-
},
|
|
743
|
-
end_date: {
|
|
744
|
-
year: 2600
|
|
745
|
-
}
|
|
746
|
-
}, {
|
|
747
|
-
start_date: {
|
|
748
|
-
year: 500
|
|
749
|
-
},
|
|
750
|
-
end_date: {
|
|
751
|
-
year: 4000
|
|
752
|
-
}
|
|
753
|
-
}, ]
|
|
754
|
-
})
|
|
755
|
-
var timescale = new TL.TimeScale(config, {
|
|
756
|
-
display_width: 600,
|
|
757
|
-
screen_multiplier: 3,
|
|
758
|
-
max_rows: 4
|
|
759
|
-
});
|
|
760
|
-
assert.equal(timescale.getNumberOfRows(), 4, "Max rows 4 should be honored.")
|
|
761
|
-
var timescale = new TL.TimeScale(config, {
|
|
762
|
-
display_width: 600,
|
|
763
|
-
screen_multiplier: 3,
|
|
764
|
-
max_rows: 3
|
|
765
|
-
});
|
|
766
|
-
assert.equal(timescale.getNumberOfRows(), 3, "Max rows 3 should be honored.")
|
|
767
|
-
});
|
|
768
|
-
</script>
|
|
769
|
-
</head>
|
|
770
|
-
|
|
771
|
-
<body>
|
|
772
|
-
<div id="qunit"></div>
|
|
773
|
-
</body>
|
|
774
|
-
|
|
775
|
-
</html>
|