JSFiddle - React, Tailwind, and code Playground
by Glutamat
HTML
<script>
//@author C5H8NNaO4 (http://stackoverflow.com/users/1487756/c5h8nnao4)
/*jshint forin:false, eqnull:true, latedef: nofunc, camelcase:true, boss:true, curly:true, eqeqeq: true, immed:true, indent: 4*/
var util = {
enforceSignature: function enforcesSignature(options, args, fn) { //This is mainly a debug validation function may be replaced by a simpler one. If you pass a functin, its parameters get parsed and outputted on a mismatch.
var params, i, l, j, k, res;
res = true;
for (i = 0, l = options.length; i < l; i++) {
var types = options[i] = Array.isArray(options[i]) ? options[i] : [options[i]];
var mismatch = true;
for (j = 0, k = types.length; j < k; j++) {
if ((args[i] && args[i].constructor === types[j]) || (types[j] === args[i])) {
mismatch = false;
break;
}
}
if (mismatch) {
res = false;
break;
}
}
j--;
if (!res) {
var err = [
i >= 0 ? i : "?",
options[i][j] && (options[i][j].name || "asd"),
args[i] && args[i].constructor && args[i].constructor.name || '"' + args[i] + '"'];
if ("function" === typeof fn) {
params = ("" + fn).match(/\((.*)\)/)[1].split(",");
err.push(params[i] || "unknown");
throw new TypeError("Type mismatch on " + fn.name + " " + err[0] + " (" + err[1] + "). Expected " + err[2] + ", got " + err[3] + " instead");
} else {
throw new TypeError("Type mismatch on parameter" + err[1] + ". Expected " + err[2] + ", got " + err[3] + " instead");
}
}
return true;
},
formatString: function() {
...
JavaScript
var access_token, key;
if (window.location.hash) {
access_token = window.location.hash.match(/access_token=(.+?)&/)[1];
key = "qUMaML9tYsoTYTzM2Z2E6w((";
StackApi.me.fetch({
site: "stackoverflow",
access_token: access_token,
key: key
}).success(function (response) {
var me = response.items[0];
var html = "";
html += "<h2>Thanks " + me.display_name + "! The response is:</h2>";
StackApi.questions.fetch({
ids: [102714,11227809],
site: "stackoverflow",
access_token: access_token,
key: key
}).success(function (response) {
html += JSON.stringify(response.items)
document.body.innerHTML = html;
})
});
} else {
window.location.href = "https://stackexchange.com/oauth/dialog?client_id=2125&redirect_uri=http://fiddle.jshell.net/Glutamat/sVuh8/show"
}