summaryrefslogtreecommitdiff
path: root/docs/index.js
diff options
context:
space:
mode:
authorRasmus Andersson <rasmus@notion.se>2018-02-18 11:28:23 +0300
committerRasmus Andersson <rasmus@notion.se>2018-02-18 11:28:23 +0300
commit360916d1ec97df6a92b0a41f6a12f42a15fe0cab (patch)
tree9c864c3ee44a6c5c083c34d8c2ce21716c1579b4 /docs/index.js
parentc551b9f66a6467e1a7104ae0aa7d99203bf331a3 (diff)
downloadinter-360916d1ec97df6a92b0a41f6a12f42a15fe0cab.tar.xz
Release v2.5v2.5
Diffstat (limited to 'docs/index.js')
-rw-r--r--docs/index.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/docs/index.js b/docs/index.js
index 23773e1bd..ea10bd6c3 100644
--- a/docs/index.js
+++ b/docs/index.js
@@ -1,5 +1,30 @@
var isMac = false
+// fetchjson(url string, cb (err Error, d Object)->nil)
+//
+var fetchjson = (
+ typeof window.fetch == 'function' ? (
+ function _fetchjson(url, cb) {
+ return window.fetch(url)
+ .then(function(r) { return r.json() })
+ .then(function(data) { cb(null, data) })
+ .catch(cb)
+ }
+ ) :
+ function _fetchjson(url, cb) {
+ var r = new XMLHttpRequest()
+ r.addEventListener("load", function(){
+ try {
+ cb(null, JSON.parse(r.responseText))
+ } catch (err) {
+ cb(err)
+ }
+ })
+ r.open("GET", url)
+ r.send()
+ }
+)
+
;(function(){
"use strict";