{"action":"created","comment":{"url":"https://api.github.com/repos/peric/GetCountries/pulls/comments/30000226","id":30000226,"diff_hunk":"@@ -0,0 +1,548 @@\n+var OUTPUT_MYSQL = 'MySQL',\n+    OUTPUT_FIREBIRD = 'Firebird',\n+    OUTPUT_XML = 'XML',\n+    OUTPUT_JSON = 'JSON',\n+    OUTPUT_CSV = 'CSV',\n+    OUTPUT_YAML = 'YAML';\n+\n+var columns = {\n+    'countryCode': { name: 'countryCode', mysql: 'char(2) NOT NULL DEFAULT \\'\\'', firebird: 'char(3) NOT NULL', checked: true },\n+    'countryName': { name: 'countryName', mysql: 'varchar(45) NOT NULL DEFAULT \\'\\'', firebird: 'varchar(45) NOT NULL', checked: true },\n+    'currencyCode': { name: 'currencyCode', mysql: 'char(3) DEFAULT NULL', firebird: 'char(3) DEFAULT NULL', checked: false },\n+    'population': { name: 'population', mysql: 'varchar(20) DEFAULT NULL', firebird: 'varchar(20) DEFAULT NULL', checked: false },\n+    'fipsCode': { name: 'fipsCode', mysql: 'char(2) DEFAULT NULL', firebird: 'char(2) DEFAULT NULL', checked: false },\n+    'isoNumeric': { name: 'isoNumeric', mysql: 'char(4) DEFAULT NULL', firebird: 'char(4) DEFAULT NULL', checked: false },\n+    'north': { name: 'north', mysql: 'varchar(30) DEFAULT NULL', firebird: 'varchar(30) DEFAULT NULL', checked: false },\n+    'south': { name: 'south', mysql: 'varchar(30) DEFAULT NULL', firebird: 'varchar(30) DEFAULT NULL', checked: false },\n+    'east': { name: 'east', mysql: 'varchar(30) DEFAULT NULL', firebird: 'varchar(30) DEFAULT NULL', checked: false },\n+    'west': { name: 'west', mysql: 'varchar(30) DEFAULT NULL', firebird: 'varchar(30) DEFAULT NULL', checked: false },\n+    'capital': { name: 'capital', mysql: 'varchar(30) DEFAULT NULL', firebird: 'varchar(30) DEFAULT NULL', checked: false },\n+    'continentName': { name: 'continentName', mysql: 'varchar(15) DEFAULT NULL', firebird: 'varchar(15) DEFAULT NULL', checked: false },\n+    'continent': { name: 'continent', mysql: 'char(2) DEFAULT NULL', firebird: 'char(2) DEFAULT NULL', checked: false },\n+    'areaInSqKm': { name: 'areaInSqKm', mysql: 'varchar(20) DEFAULT NULL', firebird: 'varchar(20) DEFAULT NULL', checked: false },\n+    'languages': { name: 'languages', mysql: 'varchar(100) DEFAULT NULL', firebird: 'varchar(100) DEFAULT NULL', checked: false },\n+    'isoAlpha3': { name: 'isoAlpha3', mysql: 'char(3) DEFAULT NULL', firebird: 'char(3) DEFAULT NULL', checked: false },\n+    'geonameId': { name: 'geonameId', mysql: 'int(10) DEFAULT NULL', firebird: 'integer DEFAULT NULL', checked: false }\n+};\n+\n+var columnsLookup = [\n+    { name: 'countryCode', mysql: 'char(2) NOT NULL DEFAULT \\'\\'', firebird: 'char(3) NOT NULL', checked: true },\n+    { name: 'languages', mysql: 'varchar(100) DEFAULT NULL', firebird: 'varchar(100) DEFAULT NULL', checked: false }\n+];\n+\n+var settings = {\n+    'languagelookup': { name: 'languagelookup', longName: 'Language Lookup tables', checked: false, disabled: false, supportedOutputs: [OUTPUT_MYSQL, OUTPUT_FIREBIRD] }\n+};\n+\n+var outputTypes = {};\n+outputTypes[OUTPUT_MYSQL] = { name: OUTPUT_MYSQL };\n+outputTypes[OUTPUT_FIREBIRD] = { name: OUTPUT_FIREBIRD };\n+outputTypes[OUTPUT_XML] = { name: OUTPUT_XML };\n+outputTypes[OUTPUT_JSON] = { name: OUTPUT_JSON };\n+outputTypes[OUTPUT_CSV] = { name: OUTPUT_CSV };\n+outputTypes[OUTPUT_YAML] = { name: OUTPUT_YAML };\n+\n+var GeneratorApp = React.createClass({\n+    getInitialState: function() {\n+        return {\n+            columns: this.props.columns,\n+            settings: this.props.settings,\n+            outputTypes: this.props.outputTypes,\n+            selectedOutputType: OUTPUT_MYSQL,\n+            output: ''\n+        };\n+    },\n+    componentWillMount: function() {\n+        this.getOutput();\n+    },\n+    // handles changes for all the checkboxes and radio buttons\n+    toggleCheck: function(objectKey, type, data) {\n+        // radio buttons are handled different than checkboxes\n+        if (type === 'outputTypes') {\n+            var settings = this.state.settings;\n+\n+            // based on the selected, disable or enable 'languagelookup' setting\n+            for (var key in settings) {\n+                if (settings.hasOwnProperty(key) && settings[key].name === 'languagelookup') {\n+                    if (settings[key].supportedOutputs.indexOf(data[objectKey].name) === -1) {\n+                        settings[key].checked = false;\n+                        settings[key].disabled = true;\n+                    } else {\n+                        settings[key].disabled = false;\n+                    }\n+                }\n+            }\n+\n+            this.setState({selectedOutputType: data[objectKey].name});\n+        } else if (type === 'settings') {\n+            if (data[objectKey].name === 'languagelookup' && !data[objectKey].checked) {\n+                var columns = this.state.columns;\n+\n+                columns['languages'].checked = true;\n+            }\n+\n+            data[objectKey].checked = !data[objectKey].checked;\n+        } else {\n+            data[objectKey].checked = !data[objectKey].checked;\n+        }\n+\n+        this.forceUpdate();\n+\n+        // TODO: do I need this? How forceUpdate does updates based on references?\n+//        this.setState({type: data});\n+    },\n+    getOutput: function(e) {\n+        if (e) {\n+            e.preventDefault();\n+        }\n+\n+        // TODO: show loader on button\n+\n+        var source = 'http://api.geonames.org/countryInfoJSON?username=dperic';\n+        var columns = this.state.columns;\n+        var settings = this.state.settings;\n+        var selectedOutputType = this.state.selectedOutputType;\n+\n+        $.getJSON(source)\n+            .done(function(data) {\n+                var geonamesData = data.geonames;\n+\n+                this.setState({'output': generateOutput(selectedOutputType, columns, settings, geonamesData) });\n+        }.bind(this));\n+    },\n+    render: function() {\n+        var self = this;\n+        var columns = Object.keys(this.state.columns).map(function(key, index) {\n+            var column = self.state.columns[key];\n+            return (\n+                <Column\n+                    key={index + column.name}\n+                    objectKey={key}\n+                    data={self.state.columns}\n+                    name={column.name}\n+                    checked={column.checked}\n+                    onChange={self.toggleCheck} />\n+            )\n+        });\n+        var settings = Object.keys(this.state.settings).map(function(key, index) {\n+            var setting = self.state.settings[key];\n+            return (\n+                <Setting\n+                    key={index + key}\n+                    objectKey={key}\n+                    data={self.state.settings}\n+                    name={setting.name}\n+                    longName={setting.longName}\n+                    checked={setting.checked}\n+                    onChange={self.toggleCheck}\n+                    disabled={setting.disabled} />","path":"js/app.js","position":138,"original_position":138,"commit_id":"323ab130194fae21038f2011b5972725eb246fec","original_commit_id":"323ab130194fae21038f2011b5972725eb246fec","user":{"login":"zigomir","id":957321,"avatar_url":"https://avatars.githubusercontent.com/u/957321?v=3","gravatar_id":"","url":"https://api.github.com/users/zigomir","html_url":"https://github.com/zigomir","followers_url":"https://api.github.com/users/zigomir/followers","following_url":"https://api.github.com/users/zigomir/following{/other_user}","gists_url":"https://api.github.com/users/zigomir/gists{/gist_id}","starred_url":"https://api.github.com/users/zigomir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zigomir/subscriptions","organizations_url":"https://api.github.com/users/zigomir/orgs","repos_url":"https://api.github.com/users/zigomir/repos","events_url":"https://api.github.com/users/zigomir/events{/privacy}","received_events_url":"https://api.github.com/users/zigomir/received_events","type":"User","site_admin":false},"body":"props for using lots of `props` :+1: :)","created_at":"2015-05-10T09:12:37Z","updated_at":"2015-05-10T09:12:37Z","html_url":"https://github.com/peric/GetCountries/pull/24#discussion_r30000226","pull_request_url":"https://api.github.com/repos/peric/GetCountries/pulls/24","_links":{"self":{"href":"https://api.github.com/repos/peric/GetCountries/pulls/comments/30000226"},"html":{"href":"https://github.com/peric/GetCountries/pull/24#discussion_r30000226"},"pull_request":{"href":"https://api.github.com/repos/peric/GetCountries/pulls/24"}}},"pull_request":{"url":"https://api.github.com/repos/peric/GetCountries/pulls/24","id":35079518,"html_url":"https://github.com/peric/GetCountries/pull/24","diff_url":"https://github.com/peric/GetCountries/pull/24.diff","patch_url":"https://github.com/peric/GetCountries/pull/24.patch","issue_url":"https://api.github.com/repos/peric/GetCountries/issues/24","number":24,"state":"open","locked":false,"title":"Reactification","user":{"login":"peric","id":1193864,"avatar_url":"https://avatars.githubusercontent.com/u/1193864?v=3","gravatar_id":"","url":"https://api.github.com/users/peric","html_url":"https://github.com/peric","followers_url":"https://api.github.com/users/peric/followers","following_url":"https://api.github.com/users/peric/following{/other_user}","gists_url":"https://api.github.com/users/peric/gists{/gist_id}","starred_url":"https://api.github.com/users/peric/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peric/subscriptions","organizations_url":"https://api.github.com/users/peric/orgs","repos_url":"https://api.github.com/users/peric/repos","events_url":"https://api.github.com/users/peric/events{/privacy}","received_events_url":"https://api.github.com/users/peric/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-05-10T08:41:31Z","updated_at":"2015-05-10T09:12:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/peric/GetCountries/pulls/24/commits","review_comments_url":"https://api.github.com/repos/peric/GetCountries/pulls/24/comments","review_comment_url":"https://api.github.com/repos/peric/GetCountries/pulls/comments{/number}","comments_url":"https://api.github.com/repos/peric/GetCountries/issues/24/comments","statuses_url":"https://api.github.com/repos/peric/GetCountries/statuses/323ab130194fae21038f2011b5972725eb246fec","head":{"label":"peric:reactify","ref":"reactify","sha":"323ab130194fae21038f2011b5972725eb246fec","user":{"login":"peric","id":1193864,"avatar_url":"https://avatars.githubusercontent.com/u/1193864?v=3","gravatar_id":"","url":"https://api.github.com/users/peric","html_url":"https://github.com/peric","followers_url":"https://api.github.com/users/peric/followers","following_url":"https://api.github.com/users/peric/following{/other_user}","gists_url":"https://api.github.com/users/peric/gists{/gist_id}","starred_url":"https://api.github.com/users/peric/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peric/subscriptions","organizations_url":"https://api.github.com/users/peric/orgs","repos_url":"https://api.github.com/users/peric/repos","events_url":"https://api.github.com/users/peric/events{/privacy}","received_events_url":"https://api.github.com/users/peric/received_events","type":"User","site_admin":false},"repo":{"id":5925650,"name":"GetCountries","full_name":"peric/GetCountries","owner":{"login":"peric","id":1193864,"avatar_url":"https://avatars.githubusercontent.com/u/1193864?v=3","gravatar_id":"","url":"https://api.github.com/users/peric","html_url":"https://github.com/peric","followers_url":"https://api.github.com/users/peric/followers","following_url":"https://api.github.com/users/peric/following{/other_user}","gists_url":"https://api.github.com/users/peric/gists{/gist_id}","starred_url":"https://api.github.com/users/peric/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peric/subscriptions","organizations_url":"https://api.github.com/users/peric/orgs","repos_url":"https://api.github.com/users/peric/repos","events_url":"https://api.github.com/users/peric/events{/privacy}","received_events_url":"https://api.github.com/users/peric/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/peric/GetCountries","description":"Generates Countries table based on the selected fields. Supports MySQL, Firebird, XML, JSON, CSV or YAML.","fork":false,"url":"https://api.github.com/repos/peric/GetCountries","forks_url":"https://api.github.com/repos/peric/GetCountries/forks","keys_url":"https://api.github.com/repos/peric/GetCountries/keys{/key_id}","collaborators_url":"https://api.github.com/repos/peric/GetCountries/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/peric/GetCountries/teams","hooks_url":"https://api.github.com/repos/peric/GetCountries/hooks","issue_events_url":"https://api.github.com/repos/peric/GetCountries/issues/events{/number}","events_url":"https://api.github.com/repos/peric/GetCountries/events","assignees_url":"https://api.github.com/repos/peric/GetCountries/assignees{/user}","branches_url":"https://api.github.com/repos/peric/GetCountries/branches{/branch}","tags_url":"https://api.github.com/repos/peric/GetCountries/tags","blobs_url":"https://api.github.com/repos/peric/GetCountries/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/peric/GetCountries/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/peric/GetCountries/git/refs{/sha}","trees_url":"https://api.github.com/repos/peric/GetCountries/git/trees{/sha}","statuses_url":"https://api.github.com/repos/peric/GetCountries/statuses/{sha}","languages_url":"https://api.github.com/repos/peric/GetCountries/languages","stargazers_url":"https://api.github.com/repos/peric/GetCountries/stargazers","contributors_url":"https://api.github.com/repos/peric/GetCountries/contributors","subscribers_url":"https://api.github.com/repos/peric/GetCountries/subscribers","subscription_url":"https://api.github.com/repos/peric/GetCountries/subscription","commits_url":"https://api.github.com/repos/peric/GetCountries/commits{/sha}","git_commits_url":"https://api.github.com/repos/peric/GetCountries/git/commits{/sha}","comments_url":"https://api.github.com/repos/peric/GetCountries/comments{/number}","issue_comment_url":"https://api.github.com/repos/peric/GetCountries/issues/comments{/number}","contents_url":"https://api.github.com/repos/peric/GetCountries/contents/{+path}","compare_url":"https://api.github.com/repos/peric/GetCountries/compare/{base}...{head}","merges_url":"https://api.github.com/repos/peric/GetCountries/merges","archive_url":"https://api.github.com/repos/peric/GetCountries/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/peric/GetCountries/downloads","issues_url":"https://api.github.com/repos/peric/GetCountries/issues{/number}","pulls_url":"https://api.github.com/repos/peric/GetCountries/pulls{/number}","milestones_url":"https://api.github.com/repos/peric/GetCountries/milestones{/number}","notifications_url":"https://api.github.com/repos/peric/GetCountries/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/peric/GetCountries/labels{/name}","releases_url":"https://api.github.com/repos/peric/GetCountries/releases{/id}","created_at":"2012-09-23T20:03:33Z","updated_at":"2015-05-07T11:47:09Z","pushed_at":"2015-05-10T08:41:32Z","git_url":"git://github.com/peric/GetCountries.git","ssh_url":"git@github.com:peric/GetCountries.git","clone_url":"https://github.com/peric/GetCountries.git","svn_url":"https://github.com/peric/GetCountries","homepage":"http://peric.github.com/GetCountries","size":554,"stargazers_count":241,"watchers_count":241,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":39,"mirror_url":null,"open_issues_count":4,"forks":39,"open_issues":4,"watchers":241,"default_branch":"master"}},"base":{"label":"peric:master","ref":"master","sha":"01e797c950b1d28a5231132753dcaa2a9560a020","user":{"login":"peric","id":1193864,"avatar_url":"https://avatars.githubusercontent.com/u/1193864?v=3","gravatar_id":"","url":"https://api.github.com/users/peric","html_url":"https://github.com/peric","followers_url":"https://api.github.com/users/peric/followers","following_url":"https://api.github.com/users/peric/following{/other_user}","gists_url":"https://api.github.com/users/peric/gists{/gist_id}","starred_url":"https://api.github.com/users/peric/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peric/subscriptions","organizations_url":"https://api.github.com/users/peric/orgs","repos_url":"https://api.github.com/users/peric/repos","events_url":"https://api.github.com/users/peric/events{/privacy}","received_events_url":"https://api.github.com/users/peric/received_events","type":"User","site_admin":false},"repo":{"id":5925650,"name":"GetCountries","full_name":"peric/GetCountries","owner":{"login":"peric","id":1193864,"avatar_url":"https://avatars.githubusercontent.com/u/1193864?v=3","gravatar_id":"","url":"https://api.github.com/users/peric","html_url":"https://github.com/peric","followers_url":"https://api.github.com/users/peric/followers","following_url":"https://api.github.com/users/peric/following{/other_user}","gists_url":"https://api.github.com/users/peric/gists{/gist_id}","starred_url":"https://api.github.com/users/peric/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peric/subscriptions","organizations_url":"https://api.github.com/users/peric/orgs","repos_url":"https://api.github.com/users/peric/repos","events_url":"https://api.github.com/users/peric/events{/privacy}","received_events_url":"https://api.github.com/users/peric/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/peric/GetCountries","description":"Generates Countries table based on the selected fields. Supports MySQL, Firebird, XML, JSON, CSV or YAML.","fork":false,"url":"https://api.github.com/repos/peric/GetCountries","forks_url":"https://api.github.com/repos/peric/GetCountries/forks","keys_url":"https://api.github.com/repos/peric/GetCountries/keys{/key_id}","collaborators_url":"https://api.github.com/repos/peric/GetCountries/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/peric/GetCountries/teams","hooks_url":"https://api.github.com/repos/peric/GetCountries/hooks","issue_events_url":"https://api.github.com/repos/peric/GetCountries/issues/events{/number}","events_url":"https://api.github.com/repos/peric/GetCountries/events","assignees_url":"https://api.github.com/repos/peric/GetCountries/assignees{/user}","branches_url":"https://api.github.com/repos/peric/GetCountries/branches{/branch}","tags_url":"https://api.github.com/repos/peric/GetCountries/tags","blobs_url":"https://api.github.com/repos/peric/GetCountries/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/peric/GetCountries/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/peric/GetCountries/git/refs{/sha}","trees_url":"https://api.github.com/repos/peric/GetCountries/git/trees{/sha}","statuses_url":"https://api.github.com/repos/peric/GetCountries/statuses/{sha}","languages_url":"https://api.github.com/repos/peric/GetCountries/languages","stargazers_url":"https://api.github.com/repos/peric/GetCountries/stargazers","contributors_url":"https://api.github.com/repos/peric/GetCountries/contributors","subscribers_url":"https://api.github.com/repos/peric/GetCountries/subscribers","subscription_url":"https://api.github.com/repos/peric/GetCountries/subscription","commits_url":"https://api.github.com/repos/peric/GetCountries/commits{/sha}","git_commits_url":"https://api.github.com/repos/peric/GetCountries/git/commits{/sha}","comments_url":"https://api.github.com/repos/peric/GetCountries/comments{/number}","issue_comment_url":"https://api.github.com/repos/peric/GetCountries/issues/comments{/number}","contents_url":"https://api.github.com/repos/peric/GetCountries/contents/{+path}","compare_url":"https://api.github.com/repos/peric/GetCountries/compare/{base}...{head}","merges_url":"https://api.github.com/repos/peric/GetCountries/merges","archive_url":"https://api.github.com/repos/peric/GetCountries/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/peric/GetCountries/downloads","issues_url":"https://api.github.com/repos/peric/GetCountries/issues{/number}","pulls_url":"https://api.github.com/repos/peric/GetCountries/pulls{/number}","milestones_url":"https://api.github.com/repos/peric/GetCountries/milestones{/number}","notifications_url":"https://api.github.com/repos/peric/GetCountries/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/peric/GetCountries/labels{/name}","releases_url":"https://api.github.com/repos/peric/GetCountries/releases{/id}","created_at":"2012-09-23T20:03:33Z","updated_at":"2015-05-07T11:47:09Z","pushed_at":"2015-05-10T08:41:32Z","git_url":"git://github.com/peric/GetCountries.git","ssh_url":"git@github.com:peric/GetCountries.git","clone_url":"https://github.com/peric/GetCountries.git","svn_url":"https://github.com/peric/GetCountries","homepage":"http://peric.github.com/GetCountries","size":554,"stargazers_count":241,"watchers_count":241,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":39,"mirror_url":null,"open_issues_count":4,"forks":39,"open_issues":4,"watchers":241,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/peric/GetCountries/pulls/24"},"html":{"href":"https://github.com/peric/GetCountries/pull/24"},"issue":{"href":"https://api.github.com/repos/peric/GetCountries/issues/24"},"comments":{"href":"https://api.github.com/repos/peric/GetCountries/issues/24/comments"},"review_comments":{"href":"https://api.github.com/repos/peric/GetCountries/pulls/24/comments"},"review_comment":{"href":"https://api.github.com/repos/peric/GetCountries/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/peric/GetCountries/pulls/24/commits"},"statuses":{"href":"https://api.github.com/repos/peric/GetCountries/statuses/323ab130194fae21038f2011b5972725eb246fec"}}}}