MCPcopy
hub / github.com/NUKnightLab/TimelineJS3 / createMedia

Method createMedia

src/js/media/types/Wikipedia.js:42–97  ·  view source on GitHub ↗
(d)

Source from the content-addressed store, hash-verified

40 }
41
42 createMedia(d) {
43 var wiki = "";
44
45 if (d.query) {
46 var content = "",
47 wiki = {
48 entry: {},
49 title: "",
50 text: "",
51 extract: "",
52 paragraphs: 1,
53 page_image: "",
54 text_array: []
55 };
56
57 wiki.entry = getObjectAttributeByIndex(d.query.pages, 0);
58 wiki.extract = wiki.entry.extract || "";
59 wiki.title = wiki.entry.title;
60 wiki.page_image = wiki.entry.thumbnail;
61
62 if (wiki.extract.match("<p>")) {
63 wiki.text_array = wiki.extract.split("<p>");
64 } else {
65 wiki.text_array.push(wiki.extract);
66 }
67
68 for (var i = 0; i < wiki.text_array.length; i++) {
69 if (i + 1 <= wiki.paragraphs && i + 1 < wiki.text_array.length) {
70 wiki.text += "<p>" + wiki.text_array[i + 1];
71 }
72 }
73
74
75 content += "<span class='tl-icon-wikipedia'></span>";
76 content += "<div class='tl-wikipedia-title'><h4><a href='" + this.data.url + "' target='_blank' rel='noopener'>" + wiki.title + "</a></h4>";
77 content += "<span class='tl-wikipedia-source'>" + this._('wikipedia') + "</span></div>";
78
79 if (wiki.page_image) {
80 //content += "<img class='tl-wikipedia-pageimage' src='" + wiki.page_image.source +"'>";
81 }
82
83 content += wiki.text;
84
85 if (wiki.extract.match("REDIRECT")) {
86
87 } else {
88 // Add to DOM
89 this._el.content_item.innerHTML = content;
90 // After Loaded
91 this.onLoaded();
92 }
93
94
95 }
96
97 }
98
99 updateMediaDisplay() {

Callers 1

_loadMediaMethod · 0.45

Calls 3

_Method · 0.45
onLoadedMethod · 0.45

Tested by

no test coverage detected