From f4eb8dda340917de57f1487d6bd121d37b76c74f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georges=20Dup=C3=A9ron?= Date: Tue, 23 Aug 2016 14:19:07 +0200 Subject: [PATCH] Attempt to use new Travis API. --- script.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/script.js b/script.js index c3795ce..1a7786b 100644 --- a/script.js +++ b/script.js @@ -139,11 +139,21 @@ function getBuildDate(build) { } function getJSON(url, callback) { - return d3.xhr(url) - .header("Accept", "application/vnd.travis-ci.2+json") - // .mimeType("application/json") - .response(function(xhr) { return JSON.parse(xhr.responseText); }) - .get(callback); + return d3.xhr( + url, + "application/vnd.travis-ci.2+json", + function(xhr) { + if (xhr.readyState==4 && xhr.status==200) { + callback(JSON.parse(xhr.responseText)); + } + } + ); + // With d3 4.0: + //return d3.request(url) + // //.mimeType("application/json") + // .header("Accept", "application/vnd.travis-ci.2+json") + // .response(function(xhr) { return JSON.parse(xhr.responseText); }) + // .get(callback); } function updateChart() {