Created
September 28, 2017 13:24
-
-
Save selfsame/70f476be7797194f3c8da599e4c85295 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var get_json = function(url, cb){ | |
var xmlhttp = new XMLHttpRequest() | |
xmlhttp.onreadystatechange = function() { | |
if (this.readyState == 4 && this.status == 200) { | |
var res = JSON.parse(this.responseText) | |
cb(res)}} | |
xmlhttp.open("GET", url, true) | |
xmlhttp.send()} | |
var make_element = function(tag, opts){ | |
opts = opts || {} | |
var el = document.createElement(tag) | |
if (opts["class"]) {el.setAttribute("class", opts["class"])} | |
if (opts["id"]) {el.setAttribute("id", opts["id"])} | |
if (opts["href"]) {el.setAttribute("href", opts["href"])} | |
if (opts["text"]) {el.textContent = opts["text"]} | |
return el} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment