()
| 5 | export default class Wikipedia extends Media { |
| 6 | |
| 7 | _loadMedia() { |
| 8 | var api_url, |
| 9 | api_language, |
| 10 | self = this; |
| 11 | |
| 12 | // Create Dom element |
| 13 | this._el.content_item = this.domCreate("div", "tl-media-item tl-media-wikipedia", this._el.content); |
| 14 | this._el.content_container.className = "tl-media-content-container tl-media-content-container-text"; |
| 15 | |
| 16 | // Get Media ID |
| 17 | this.media_id = this.data.url.split("wiki\/")[1].split("#")[0].replace("_", " "); |
| 18 | this.media_id = this.media_id.replace(" ", "%20"); |
| 19 | api_language = this.data.url.split("//")[1].split(".wikipedia")[0]; |
| 20 | |
| 21 | // API URL |
| 22 | api_url = "https://" + api_language + ".wikipedia.org/w/api.php?action=query&prop=extracts|pageimages&redirects=&titles=" + this.media_id + "&exintro=1&format=json&callback=?"; |
| 23 | |
| 24 | // API Call |
| 25 | ajax({ |
| 26 | type: 'GET', |
| 27 | url: api_url, |
| 28 | dataType: 'json', //json data type |
| 29 | |
| 30 | success: function(d) { |
| 31 | self.createMedia(d); |
| 32 | }, |
| 33 | error: function(xhr, type) { |
| 34 | var error_text = ""; |
| 35 | error_text += self._("wikipedia_load_err") + "<br/>" + self.media_id + "<br/>" + type; |
| 36 | self.loadErrorDisplay(error_text); |
| 37 | } |
| 38 | }); |
| 39 | |
| 40 | } |
| 41 | |
| 42 | createMedia(d) { |
| 43 | var wiki = ""; |
nothing calls this directly
no test coverage detected