import { jsonpRequest } from '../util/jsonp_request';
import { utilQsString } from '../util';


var endpoint = 'https://www.wikidata.org/w/api.php?';

export default {

    init: function() {},
    reset: function() {},


    // Given a Wikipedia language and article title, return an array of
    // corresponding Wikidata entities.
    itemsByTitle: function(lang, title, callback) {
        if (!title) {
            callback('', {});
            return;
        }

        lang = lang || 'en';
        jsonpRequest(endpoint + utilQsString({
            action: 'wbgetentities',
            format: 'json',
            sites: lang.replace(/-/g, '_') + 'wiki',
            titles: title,
            languages: 'en', // shrink response by filtering to one language
            callback: '{callback}'
        }), function(data) {
            if (!data || data.error) {
                callback('', {});
            } else {
                callback(title, data.entities || {});
            }
        });
    }

};

@@ -10,39 +10,31 @@
 json
-pRequest %7D from '../util/jsonp_
+ as d3_json %7D from 'd3-
 requ
@@ -39,16 +39,17 @@
 quest';%0A
+%0A
 import %7B
@@ -496,20 +496,15 @@
     
+d3_
 json
-pRequest
 (end
@@ -764,29 +764,18 @@
     
-callback: '%7Bcallback%7D
+origin: '*
 '%0A  
@@ -793,16 +793,21 @@
 unction(
+err, 
 data) %7B%0A
@@ -822,16 +822,23 @@
     if (
+err %7C%7C 
 !data %7C%7C

Use XHR to access wikidata API instead of JSONP