mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 17:23:02 +00:00
* One-shot development * Move jsonp to module * Tooltip -> module * Remove d3.jsonp * Fix tooltip lint * Load all libs but d3 itself with require * Add top-level brfs * Unformat intro graph
25 lines
820 B
JavaScript
25 lines
820 B
JavaScript
import { jsonpRequest } from '../util/jsonp_request';
|
|
import { qsString } from '../util/index';
|
|
|
|
var wikidata = {},
|
|
endpoint = 'https://www.wikidata.org/w/api.php?';
|
|
|
|
export function init() {
|
|
// Given a Wikipedia language and article title, return an array of
|
|
// corresponding Wikidata entities.
|
|
wikidata.itemsByTitle = function(lang, title, callback) {
|
|
lang = lang || 'en';
|
|
jsonpRequest(endpoint + qsString({
|
|
action: 'wbgetentities',
|
|
format: 'json',
|
|
sites: lang.replace(/-/g, '_') + 'wiki',
|
|
titles: title,
|
|
languages: 'en', // shrink response by filtering to one language
|
|
callback: '{callback}'
|
|
}), function(data) {
|
|
callback(title, data.entities || {});
|
|
});
|
|
};
|
|
return wikidata;
|
|
}
|