Skip to content

Commit

Permalink
soda -> Socrata Open Data API
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasalmeida committed Sep 4, 2014
1 parent 06b8d55 commit c0d3ab2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
5 changes: 3 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<div class="container" id="openHealth">
<h3>Web Computing<a href="https://en.wikipedia.org/wiki/Web_computing" target=_blank>*</a> for openHealth<a href="https://github.com/mathbiol/openHealth" target=_blank>**</a></h3>
<div id="msg">There is nothing to see here, the action is in the <a href="https://developer.chrome.com/devtools/docs/console" target=_blank>browser's console</a>. Versioned source code + docs at <a href="https://github.com/mathbiol/openHealth" target=_blank>gitHub</a>.</div>
<div id="msg">There is nothing to see <a href="https://mathbiol.github.io/openHealth" target=_blank>here</a>, the action is in the <a href="https://developer.chrome.com/devtools/docs/console" target=_blank>browser's console</a>. Versioned source code + docs at <a href="https://github.com/mathbiol/openHealth" target=_blank>gitHub</a>.</div>
<hr>
</div>

Expand All @@ -22,4 +22,5 @@ <h3>Web Computing<a href="https://en.wikipedia.org/wiki/Web_computing" target=_b
</script>

</body>
</html>
</html>

16 changes: 16 additions & 0 deletions openHealth.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@ this.getScript=function(src,fun){
}
};

this.xhr=function(url,meth,fun){ // XMLHttpRequest
if(typeof(meth)=="function"){fun=meth;meth="GET"} // in case this is a regular GET call
var r = new XMLHttpRequest();
if(!!fun){r.onload=fun}; // calback
r.open(meth,url,true);
r.send();
return r
}

this.getJSON=function(url,fun){
this.xhr(url,function(x){fun(JSON.parse(x.target.responseText))});
}

this.sodaData={ // some reference SODA data links
/*
Jonas,
Expand All @@ -38,6 +51,9 @@ this.soda=function(url,q,fun){ // operate Socrata Open Data API (SODA), http://d
if(!url.match("http[s]{0,1}://")){ // if url is not a URL then assume it is an entry of openHealth.sodaData
url=this.sodaData[url];
}
if(typeof(q)=="function"){fun=q;q=""}
if(!fun){fun=function(x){console.log(x)}}
this.getJSON(url,fun);
return url
}
}
Expand Down

0 comments on commit c0d3ab2

Please sign in to comment.