Hi my name is Chris, my home page is here.
I set up a thing so you can store/retrieve JSON on your page. Use it for whatever you want. This is a tweaked implementation of JSONP-DB-Redux.
Note: adding the same object twice will result in two entries (with the same content) with two different keys.
Example:
http://tilde-club-db.appspot.com/put/buckets/myFoo/{"foo":"bar","baz":9}?callback=myFunction
Response:
myFunction('agNpZWRyDQsSB2NvbnRhY3QYAQw');
(item key is unique to this object)
Example:
http://tilde-club-db.appspot.com/get/keys/agNpZWRyDQsSB2NvbnRhY3QYAQw?callback=myFunction
Response:
myFunction({"foo":"bar","baz":9});
Example:
http://tilde-club-db.appspot.com/get/buckets/myFoo/?callback=myFunction
Response:
myFunction([{"foo":"bar","baz":9},{"foo":"bar2","baz":10}]);
Example
You pass an object - all fields will have to match:
http://tilde-club-db.appspot.com/get/kind/myFoo/?filter={"foo":"bar2"}&callback=myFunction
Response:
myFunction([{"foo":"bar2","baz":10}]);
var putData = function (data) {
var jsonData = JSON.stringify(data)
var jsonpURL = 'http://tilde-club-db.appspot.com/put/buckets/my-bucket/' + jsonData + '?callback=myPutCallback';
var script = document.createElement('script');
script.src = jsonpURL;
document.head.appendChild(script);
};
var myPutCallback = function (id) {
alert('Data stored with id: ' + id);
};
document.getElementById('button').onclick = function () {
var text = document.getElementById('text').value.replace(/\"/g, '"'); // shrug emoji;
putData({"myText":text});
return false;
};
var getData = function () {
var jsonpURL = 'http://tilde-club-db.appspot.com/get/buckets/my-bucket/?callback=myGetCallback';
var script = document.createElement('script');
script.src = jsonpURL;
document.head.appendChild(script);
};
var myGetCallback = function (data) {
for (var i = 0; i < data.length; i++) {
console.log(data[i]);
}
};
getData();
It super-duper isn't!