{"id":245,"date":"2008-11-23T01:02:39","date_gmt":"2008-11-23T06:02:39","guid":{"rendered":"http:\/\/www.eligrey.com\/?p=245"},"modified":"2008-11-23T01:02:39","modified_gmt":"2008-11-23T06:02:39","slug":"jdata-publicly-share-data","status":"publish","type":"post","link":"https:\/\/eligrey.com\/blog\/jdata-publicly-share-data\/","title":{"rendered":"jData &#8211; publicly share data"},"content":{"rendered":"<p>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.<\/p>\n<p>What is jData? &#8211; Think of the data stored on jData like cookies with no size limit; cookies that can be accessed by <strong>any<\/strong> website on the internet. It&#8217;s so lightweight that the postMessage API is exactly 300 bytes.<br \/>\nWhy make this? &#8211; This would be a good resource for storing info about yourself that you are okay with any website on the internet knowing.<\/p>\n<p>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.<\/p>\n<p><!--more--><\/p>\n<p><strong>Update:<\/strong> I made a simple <a href=\"http:\/\/jdata.eligrey.com\/manage.html\">jData Manager<\/a> to manage your jData items.<\/p>\n<h2>How-to use the APIs:<\/h2>\n<p>postMessage (<a title=\"jData Example Using postMessage Interface\" href=\"http:\/\/code.eligrey.com\/jdata\/example2.html\">Example<\/a>):<\/p>\n<p>First of all, make an iframe with an src of <em>http:\/\/jdata.eligrey.com\/<\/em> and give it an id like jdataframe.\u00a0 Send the frame a message containing a <a href=\"http:\/\/www.whatwg.org\/specs\/web-apps\/current-work\/#storage-0\" target=\"_blank\">WhatWG Storage API<\/a> property. ( ie. getItem(&#8216;example&#8217;) or length ) &#8211; 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 <em>?hash<\/em> to the end of the jData URI and using the postMessage API changes and updates jData&#8217;s hash to the last postMessage every time it recieves a message. To get the hash via a browser that doesn&#8217;t aknowledge <em>Access-Control-Allow-Origin: *<\/em> (which should allow any website to view the hash), just send a postMessage containing the word hash.<\/p>\n<p>HTTP Query Parameters (<a title=\"jData Example Using HTTP Query Interface\" href=\"http:\/\/test.eligrey.com\/jdata\/example1.html\">Example<\/a>):<\/p>\n<ul>\n<li>item &#8211; The item being set\/read\/deleted (jData[<em>item<\/em>]).<\/li>\n<li>default for <em>item<\/em> &#8211; The hostname (domain) of the referring website.<\/li>\n<li>value &#8211; See <em>set<\/em>.<\/li>\n<li>Parameters that double as <em>item<\/em> &#8211; parameter=value sets <em>item<\/em> to the value of <em>parameter<\/em> and activates the parameter as a 2-in-1 function.<\/li>\n<li>set (doubles as <em>item<\/em>) &#8211; Sets jData[<em>item<\/em>] to <em>val<\/em>. Also sets JavaScript variable jdata to <em>val<\/em>.<\/li>\n<li>get (doubles as <em>item<\/em>) &#8211; Gets jData[<em>item<\/em>] 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 <em>value<\/em>.<\/li>\n<li>del (doubles as <em>item<\/em>) &#8211; Deletes jData[<em>item<\/em>].<\/li>\n<li>callback &#8211; JavaScript code to run at end of code. The variable, jdata, is available to the code.<\/li>\n<\/ul>\n<p>jData is <acronym title=\"Creative Commons GNU Lesser General Public License\">CC GNU LGPL<\/acronym> licensed and the source code is <a href=\"http:\/\/jdata.eligrey.com\/index.phps\">here<\/a>. 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.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[15,94,133],"class_list":["post-245","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-browsers","tag-jdata","tag-projects"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pfpUD-3X","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/eligrey.com\/blog\/wp-json\/wp\/v2\/posts\/245","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eligrey.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eligrey.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eligrey.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/eligrey.com\/blog\/wp-json\/wp\/v2\/comments?post=245"}],"version-history":[{"count":0,"href":"https:\/\/eligrey.com\/blog\/wp-json\/wp\/v2\/posts\/245\/revisions"}],"wp:attachment":[{"href":"https:\/\/eligrey.com\/blog\/wp-json\/wp\/v2\/media?parent=245"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eligrey.com\/blog\/wp-json\/wp\/v2\/categories?post=245"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eligrey.com\/blog\/wp-json\/wp\/v2\/tags?post=245"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}