{"action":"created","comment":{"url":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/comments/22760104","id":22760104,"diff_hunk":"@@ -0,0 +1,166 @@\n+/**\n+ * CodeOrgApp: Webapp\n+ *\n+ * Copyright 2014 Code.org\n+ *\n+ */\n+\n+'use strict';\n+\n+/**\n+ * Namespace for form storage.\n+ */ \n+var FormStorage = module.exports;\n+\n+\n+/**\n+ * Creates a new record in the specified table.\n+ * @param {string} record.tableName The name of the table to read from.\n+ * @param {Object} record Object containing other properties to store\n+ *     on the record.\n+ * @param {Function} callback Function to call with the resulting record.\n+ */\n+FormStorage.createRecord = function(record, callback) {\n+  var tableName = record.tableName;\n+  if (!tableName) {\n+    console.log('readRecords: missing required property \"tableName\"');\n+    return;\n+  }\n+  FormStorage.fetchTableSecret(\n+      tableName, \n+      putRecord.bind(this, record, callback));\n+};\n+\n+var putRecord = function(record, callback, tableSecret) {\n+  var req = new XMLHttpRequest();\n+  req.onreadystatechange = handlePutRecord.bind(req, record, callback, tableSecret);\n+  var url = '//' + getFormDataHost() + '/v2/forms/CspTable/' + tableSecret +\n+      '/children/CspRecord';\n+  delete record.tableName;\n+  var postData = {record_data_s: JSON.stringify(record)};\n+  req.open('POST', url);","path":"apps/src/webapp/formStorage.js","position":41,"original_position":41,"commit_id":"c27a82632205cd091cf9a9656699f6f32aa3a91d","original_commit_id":"c27a82632205cd091cf9a9656699f6f32aa3a91d","user":{"login":"cpirich","id":5429146,"avatar_url":"https://avatars.githubusercontent.com/u/5429146?v=3","gravatar_id":"","url":"https://api.github.com/users/cpirich","html_url":"https://github.com/cpirich","followers_url":"https://api.github.com/users/cpirich/followers","following_url":"https://api.github.com/users/cpirich/following{/other_user}","gists_url":"https://api.github.com/users/cpirich/gists{/gist_id}","starred_url":"https://api.github.com/users/cpirich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cpirich/subscriptions","organizations_url":"https://api.github.com/users/cpirich/orgs","repos_url":"https://api.github.com/users/cpirich/repos","events_url":"https://api.github.com/users/cpirich/events{/privacy}","received_events_url":"https://api.github.com/users/cpirich/received_events","type":"User","site_admin":false},"body":"third parameter (async) is missing - I assume it should be set to true since you are supplying an onreadystatechange function","created_at":"2015-01-10T16:44:39Z","updated_at":"2015-01-10T16:44:39Z","html_url":"https://github.com/code-dot-org/code-dot-org/pull/954#discussion_r22760104","pull_request_url":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/954","_links":{"self":{"href":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/comments/22760104"},"html":{"href":"https://github.com/code-dot-org/code-dot-org/pull/954#discussion_r22760104"},"pull_request":{"href":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/954"}}},"pull_request":{"url":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/954","id":27083485,"html_url":"https://github.com/code-dot-org/code-dot-org/pull/954","diff_url":"https://github.com/code-dot-org/code-dot-org/pull/954.diff","patch_url":"https://github.com/code-dot-org/code-dot-org/pull/954.patch","issue_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/954","number":954,"state":"open","locked":false,"title":"Implement storage support for CodeChat app in applab.","user":{"login":"davidsbailey","id":8001765,"avatar_url":"https://avatars.githubusercontent.com/u/8001765?v=3","gravatar_id":"","url":"https://api.github.com/users/davidsbailey","html_url":"https://github.com/davidsbailey","followers_url":"https://api.github.com/users/davidsbailey/followers","following_url":"https://api.github.com/users/davidsbailey/following{/other_user}","gists_url":"https://api.github.com/users/davidsbailey/gists{/gist_id}","starred_url":"https://api.github.com/users/davidsbailey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidsbailey/subscriptions","organizations_url":"https://api.github.com/users/davidsbailey/orgs","repos_url":"https://api.github.com/users/davidsbailey/repos","events_url":"https://api.github.com/users/davidsbailey/events{/privacy}","received_events_url":"https://api.github.com/users/davidsbailey/received_events","type":"User","site_admin":false},"body":"This adds support for basic CodeChat app:\r\n1. Implement rudimentary data browser UI on top of forms API.\r\n2. Implement Create and Read storage operations on top of v2 forms API. \r\n3. Add ability to set and get javascript attributes on HTML elements.\r\n\r\nThe data is structured as outlined in the CSP Data Storage Proposal doc (https://docs.google.com/a/code.org/document/d/1suoZsC0pbRKk6NYd0sTj6tvDNOy-yipbE-D9iES3CWY/edit#heading=h.b4qa11ojnntv):\r\n1. a code.org account has a collection of apps (not yet implemented)\r\n2. an app has a collection of tables\r\n3. a table has a collection of records\r\n4. a record has a collection of key-value pair fields, all stored in a single jSON string\r\n\r\n![heirarchy](https://cloud.githubusercontent.com/assets/8001765/5676310/b9647322-9788-11e4-86d6-93371f2d6a26.png)\r\n\r\nFuture work (incomplete list!):\r\n+ Search, Update and Delete operations\r\n+ schema enforcement (requiring a given field key to always have the same value type within a given table)\r\n+ associating a unique \"app id\" with each applab \"app\"\r\n+ simple key-value pair get/set operations\r\n+ login integration\r\n+ Same Origin Policy workaround for localhost development","created_at":"2015-01-09T07:09:17Z","updated_at":"2015-01-10T16:44:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6ac6f7a798b2774ae50151eda6205e4de9ce886a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/954/commits","review_comments_url":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/954/comments","review_comment_url":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/comments/{number}","comments_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/954/comments","statuses_url":"https://api.github.com/repos/code-dot-org/code-dot-org/statuses/c27a82632205cd091cf9a9656699f6f32aa3a91d","head":{"label":"code-dot-org:csp-data-storage","ref":"csp-data-storage","sha":"c27a82632205cd091cf9a9656699f6f32aa3a91d","user":{"login":"code-dot-org","id":5124627,"avatar_url":"https://avatars.githubusercontent.com/u/5124627?v=3","gravatar_id":"","url":"https://api.github.com/users/code-dot-org","html_url":"https://github.com/code-dot-org","followers_url":"https://api.github.com/users/code-dot-org/followers","following_url":"https://api.github.com/users/code-dot-org/following{/other_user}","gists_url":"https://api.github.com/users/code-dot-org/gists{/gist_id}","starred_url":"https://api.github.com/users/code-dot-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/code-dot-org/subscriptions","organizations_url":"https://api.github.com/users/code-dot-org/orgs","repos_url":"https://api.github.com/users/code-dot-org/repos","events_url":"https://api.github.com/users/code-dot-org/events{/privacy}","received_events_url":"https://api.github.com/users/code-dot-org/received_events","type":"Organization","site_admin":false},"repo":{"id":24250009,"name":"code-dot-org","full_name":"code-dot-org/code-dot-org","owner":{"login":"code-dot-org","id":5124627,"avatar_url":"https://avatars.githubusercontent.com/u/5124627?v=3","gravatar_id":"","url":"https://api.github.com/users/code-dot-org","html_url":"https://github.com/code-dot-org","followers_url":"https://api.github.com/users/code-dot-org/followers","following_url":"https://api.github.com/users/code-dot-org/following{/other_user}","gists_url":"https://api.github.com/users/code-dot-org/gists{/gist_id}","starred_url":"https://api.github.com/users/code-dot-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/code-dot-org/subscriptions","organizations_url":"https://api.github.com/users/code-dot-org/orgs","repos_url":"https://api.github.com/users/code-dot-org/repos","events_url":"https://api.github.com/users/code-dot-org/events{/privacy}","received_events_url":"https://api.github.com/users/code-dot-org/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/code-dot-org/code-dot-org","description":"The code powering code.org and studio.code.org","fork":false,"url":"https://api.github.com/repos/code-dot-org/code-dot-org","forks_url":"https://api.github.com/repos/code-dot-org/code-dot-org/forks","keys_url":"https://api.github.com/repos/code-dot-org/code-dot-org/keys{/key_id}","collaborators_url":"https://api.github.com/repos/code-dot-org/code-dot-org/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/code-dot-org/code-dot-org/teams","hooks_url":"https://api.github.com/repos/code-dot-org/code-dot-org/hooks","issue_events_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/events{/number}","events_url":"https://api.github.com/repos/code-dot-org/code-dot-org/events","assignees_url":"https://api.github.com/repos/code-dot-org/code-dot-org/assignees{/user}","branches_url":"https://api.github.com/repos/code-dot-org/code-dot-org/branches{/branch}","tags_url":"https://api.github.com/repos/code-dot-org/code-dot-org/tags","blobs_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/refs{/sha}","trees_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/trees{/sha}","statuses_url":"https://api.github.com/repos/code-dot-org/code-dot-org/statuses/{sha}","languages_url":"https://api.github.com/repos/code-dot-org/code-dot-org/languages","stargazers_url":"https://api.github.com/repos/code-dot-org/code-dot-org/stargazers","contributors_url":"https://api.github.com/repos/code-dot-org/code-dot-org/contributors","subscribers_url":"https://api.github.com/repos/code-dot-org/code-dot-org/subscribers","subscription_url":"https://api.github.com/repos/code-dot-org/code-dot-org/subscription","commits_url":"https://api.github.com/repos/code-dot-org/code-dot-org/commits{/sha}","git_commits_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/commits{/sha}","comments_url":"https://api.github.com/repos/code-dot-org/code-dot-org/comments{/number}","issue_comment_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/comments/{number}","contents_url":"https://api.github.com/repos/code-dot-org/code-dot-org/contents/{+path}","compare_url":"https://api.github.com/repos/code-dot-org/code-dot-org/compare/{base}...{head}","merges_url":"https://api.github.com/repos/code-dot-org/code-dot-org/merges","archive_url":"https://api.github.com/repos/code-dot-org/code-dot-org/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/code-dot-org/code-dot-org/downloads","issues_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues{/number}","pulls_url":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls{/number}","milestones_url":"https://api.github.com/repos/code-dot-org/code-dot-org/milestones{/number}","notifications_url":"https://api.github.com/repos/code-dot-org/code-dot-org/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/code-dot-org/code-dot-org/labels{/name}","releases_url":"https://api.github.com/repos/code-dot-org/code-dot-org/releases{/id}","created_at":"2014-09-20T00:46:11Z","updated_at":"2015-01-10T02:08:17Z","pushed_at":"2015-01-10T16:27:43Z","git_url":"git://github.com/code-dot-org/code-dot-org.git","ssh_url":"git@github.com:code-dot-org/code-dot-org.git","clone_url":"https://github.com/code-dot-org/code-dot-org.git","svn_url":"https://github.com/code-dot-org/code-dot-org","homepage":"http://code.org","size":1457814,"stargazers_count":20,"watchers_count":20,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":18,"mirror_url":null,"open_issues_count":22,"forks":18,"open_issues":22,"watchers":20,"default_branch":"staging"}},"base":{"label":"code-dot-org:staging","ref":"staging","sha":"3c6b90340550c14834035e665e51539aa7b0cab2","user":{"login":"code-dot-org","id":5124627,"avatar_url":"https://avatars.githubusercontent.com/u/5124627?v=3","gravatar_id":"","url":"https://api.github.com/users/code-dot-org","html_url":"https://github.com/code-dot-org","followers_url":"https://api.github.com/users/code-dot-org/followers","following_url":"https://api.github.com/users/code-dot-org/following{/other_user}","gists_url":"https://api.github.com/users/code-dot-org/gists{/gist_id}","starred_url":"https://api.github.com/users/code-dot-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/code-dot-org/subscriptions","organizations_url":"https://api.github.com/users/code-dot-org/orgs","repos_url":"https://api.github.com/users/code-dot-org/repos","events_url":"https://api.github.com/users/code-dot-org/events{/privacy}","received_events_url":"https://api.github.com/users/code-dot-org/received_events","type":"Organization","site_admin":false},"repo":{"id":24250009,"name":"code-dot-org","full_name":"code-dot-org/code-dot-org","owner":{"login":"code-dot-org","id":5124627,"avatar_url":"https://avatars.githubusercontent.com/u/5124627?v=3","gravatar_id":"","url":"https://api.github.com/users/code-dot-org","html_url":"https://github.com/code-dot-org","followers_url":"https://api.github.com/users/code-dot-org/followers","following_url":"https://api.github.com/users/code-dot-org/following{/other_user}","gists_url":"https://api.github.com/users/code-dot-org/gists{/gist_id}","starred_url":"https://api.github.com/users/code-dot-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/code-dot-org/subscriptions","organizations_url":"https://api.github.com/users/code-dot-org/orgs","repos_url":"https://api.github.com/users/code-dot-org/repos","events_url":"https://api.github.com/users/code-dot-org/events{/privacy}","received_events_url":"https://api.github.com/users/code-dot-org/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/code-dot-org/code-dot-org","description":"The code powering code.org and studio.code.org","fork":false,"url":"https://api.github.com/repos/code-dot-org/code-dot-org","forks_url":"https://api.github.com/repos/code-dot-org/code-dot-org/forks","keys_url":"https://api.github.com/repos/code-dot-org/code-dot-org/keys{/key_id}","collaborators_url":"https://api.github.com/repos/code-dot-org/code-dot-org/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/code-dot-org/code-dot-org/teams","hooks_url":"https://api.github.com/repos/code-dot-org/code-dot-org/hooks","issue_events_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/events{/number}","events_url":"https://api.github.com/repos/code-dot-org/code-dot-org/events","assignees_url":"https://api.github.com/repos/code-dot-org/code-dot-org/assignees{/user}","branches_url":"https://api.github.com/repos/code-dot-org/code-dot-org/branches{/branch}","tags_url":"https://api.github.com/repos/code-dot-org/code-dot-org/tags","blobs_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/refs{/sha}","trees_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/trees{/sha}","statuses_url":"https://api.github.com/repos/code-dot-org/code-dot-org/statuses/{sha}","languages_url":"https://api.github.com/repos/code-dot-org/code-dot-org/languages","stargazers_url":"https://api.github.com/repos/code-dot-org/code-dot-org/stargazers","contributors_url":"https://api.github.com/repos/code-dot-org/code-dot-org/contributors","subscribers_url":"https://api.github.com/repos/code-dot-org/code-dot-org/subscribers","subscription_url":"https://api.github.com/repos/code-dot-org/code-dot-org/subscription","commits_url":"https://api.github.com/repos/code-dot-org/code-dot-org/commits{/sha}","git_commits_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/commits{/sha}","comments_url":"https://api.github.com/repos/code-dot-org/code-dot-org/comments{/number}","issue_comment_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/comments/{number}","contents_url":"https://api.github.com/repos/code-dot-org/code-dot-org/contents/{+path}","compare_url":"https://api.github.com/repos/code-dot-org/code-dot-org/compare/{base}...{head}","merges_url":"https://api.github.com/repos/code-dot-org/code-dot-org/merges","archive_url":"https://api.github.com/repos/code-dot-org/code-dot-org/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/code-dot-org/code-dot-org/downloads","issues_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues{/number}","pulls_url":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls{/number}","milestones_url":"https://api.github.com/repos/code-dot-org/code-dot-org/milestones{/number}","notifications_url":"https://api.github.com/repos/code-dot-org/code-dot-org/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/code-dot-org/code-dot-org/labels{/name}","releases_url":"https://api.github.com/repos/code-dot-org/code-dot-org/releases{/id}","created_at":"2014-09-20T00:46:11Z","updated_at":"2015-01-10T02:08:17Z","pushed_at":"2015-01-10T16:27:43Z","git_url":"git://github.com/code-dot-org/code-dot-org.git","ssh_url":"git@github.com:code-dot-org/code-dot-org.git","clone_url":"https://github.com/code-dot-org/code-dot-org.git","svn_url":"https://github.com/code-dot-org/code-dot-org","homepage":"http://code.org","size":1457814,"stargazers_count":20,"watchers_count":20,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":18,"mirror_url":null,"open_issues_count":22,"forks":18,"open_issues":22,"watchers":20,"default_branch":"staging"}},"_links":{"self":{"href":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/954"},"html":{"href":"https://github.com/code-dot-org/code-dot-org/pull/954"},"issue":{"href":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/954"},"comments":{"href":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/954/comments"},"review_comments":{"href":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/954/comments"},"review_comment":{"href":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/954/commits"},"statuses":{"href":"https://api.github.com/repos/code-dot-org/code-dot-org/statuses/c27a82632205cd091cf9a9656699f6f32aa3a91d"}}}}