Eli Grey

jData – publicly share data

jData is a new (extremely tiny) library for sharing data about yourself everywhere without a website needing permission/URIs/ect. It is like having a globally accessible localStorage. It is accessible at jdata.eligrey.com in two different API flavors: postMessage and HTTP queries. It only works in browsers that support window.postMessage (ie. advanced browsers like Firefox 3 and the WebKit nightlies) and sorta works in IE 8 beta 2. I may add Google Gears support someday.

What is jData? – Think of the data stored on jData like cookies with no size limit; cookies that can be accessed by any website on the internet. It’s so lightweight that the postMessage API is exactly 300 bytes.
Why make this? – This would be a good resource for storing info about yourself that you are okay with any website on the internet knowing.

Hypothetical situation: Facebook started storing your name (with your permission) to jData.fullname. Then the people who run MySpace think this is a good idea and implement it too. Then other websites start checking jData and see if jData.fullname has been set already and pre-fill the corresponding input text box with your name on a sign up page.

Update: I made a simple jData Manager to manage your jData items.

How-to use the APIs:

postMessage (Example):

First of all, make an iframe with an src of http://jdata.eligrey.com/ and give it an id like jdataframe.  Send the frame a message containing a WhatWG Storage API property. ( ie. getItem(‘example’) or length ) – It will send a postMessage back containing whatever the storage API function returned. In the case of removeItem and setItem it will either return undefined (via Firefox 3) or null (via WebKit nightlies) depending on the browser. Adding ?hash to the end of the jData URI and using the postMessage API changes and updates jData’s hash to the last postMessage every time it recieves a message. To get the hash via a browser that doesn’t aknowledge Access-Control-Allow-Origin: * (which should allow any website to view the hash), just send a postMessage containing the word hash.

HTTP Query Parameters (Example):

  • item – The item being set/read/deleted (jData[item]).
  • default for item – The hostname (domain) of the referring website.
  • value – See set.
  • Parameters that double as item – parameter=value sets item to the value of parameter and activates the parameter as a 2-in-1 function.
  • set (doubles as item) – Sets jData[item] to val. Also sets JavaScript variable jdata to val.
  • get (doubles as item) – Gets jData[item] and sends it as a message to the top frame (using top.postMessage). To use this, the message event listener must be in the top frame and jData must be in an iframe. Also sets JavaScript variable jdata to value.
  • del (doubles as item) – Deletes jData[item].
  • callback – JavaScript code to run at end of code. The variable, jdata, is available to the code.

jData is CC GNU LGPL licensed and the source code is here. If you register a website like jdata dot io or jdata dot info (or another semantic name), please email me or comment here to tell me. I will make jdata.eligrey.com permanently redirect to the new site. If this ever happens, the old jData website will check if any data is stored on it and move it all to the new jData site.

Leave a Reply