{"action":"created","comment":{"url":"https://api.github.com/repos/google/personfinder/pulls/comments/36841144","id":36841144,"diff_hunk":"@@ -68,38 +69,74 @@\n     //find all languages that the user specified with \"Use?\" checkboxes and\n     //their associated titles.  Only allows titles from used languages.\n     var used_languages = [];\n-    var languages_to_titles = {}\n+\n     //there is a title row in the table, so the dropdowns are 1-indexed\n-    for (var dropdown_index = 1; $('language_selection_' + dropdown_index) !=\n+    for (var dropdown_index = 1; $('repo_titles_language_selection_' + dropdown_index) !=\n          null; dropdown_index++) {\n-      var language_code = $('language_selection_' + dropdown_index).value;\n-      var language_title = $('language_title_' + dropdown_index).value;\n+      var language_code = $('repo_titles_language_selection_' + \n+                             dropdown_index).value;\n       if (language_code === 'unused') {\n         continue;\n       }\n-      if (arr_contains(used_languages, language_code)) {\n-        alert(\"You entered the same language (\" + language_code + \") twice. \" +\n-              \"That's not allowed.\");\n-        return false;\n-      }\n       used_languages.push(language_code);\n-      languages_to_titles[language_code] = language_title;\n     }\n \n+    var filtered_index = [];\n+    used_languages.filter(function(element, index, self){\n+      if (self.indexOf(element) === index){\n+        filtered_index.push(index);\n+      } else {\n+        used_languages.splice(index, 1);\n+      }\n+    });\n+\n     // Copy the dropdowns and the titles into the text boxes that will\n     // actually be POSTed (language_menu_options and repo_titles).\n     $('language_menu_options').value = JSON.stringify(used_languages);\n-    $('repo_titles').value = JSON.stringify(languages_to_titles);\n+    var languages_to_values = {};\n+\n+    for (var id_num = 0; id_num < CUSTOM_MESSAGE_TABLE_IDS.length; id_num++){\n+      var table_name = CUSTOM_MESSAGE_TABLE_IDS[id_num];\n+      for (var i = 0; i < filtered_index.length; i++){\n+        var index = filtered_index[i];\n+        var language_value = $(table_name + '_language_value_' + (index+1)).value;\n+        var used_language = used_languages[index];\n+        languages_to_values[used_language] = language_value;\n+      }\n+      $(table_name).value = JSON.stringify(languages_to_values);\n+    }\n \n     return true;\n   }\n \n+  function check_language_selected(row_number) {\n+    var language_codes = $('repo_titles_language_selection_' + row_number);\n+    var selected_index = language_codes.selectedIndex;\n+    var language_code = language_codes[selected_index].value;\n+    var used_languages =\n+        {{view_config_json.language_menu_options|safe|default:'[]'}};\n+    if (used_languages.indexOf(language_code) >= 0) {\n+      alert('You entered the same language!!');\n+    }\n+  }\n+\n+  function update_language_selected(row_number) {\n+    var language_codes = $('repo_titles_language_selection_' + row_number);\n+    var selected_index = language_codes.selectedIndex;\n+    var language = language_codes[selected_index].text;\n+    var language_selected_elements = document.getElementsByClassName(\n+                                     'language_selected_' + row_number);\n+    for (var i = 0; i < language_selected_elements.length; i++) {\n+      language_selected_elements[i].innerHTML = language;\n+    }\n+  }\n+\n   /* Adds a row to the languages table so that the user can add a new language\n    * and give it a title.\n    * Returns the number of the row that was added\n    */\n   function add_language() {","path":"app/resources/admin.html.template","position":110,"original_position":110,"commit_id":"e6e5dc4f069e53ae16ba2a1434f735da9b8bd21b","original_commit_id":"e6e5dc4f069e53ae16ba2a1434f735da9b8bd21b","user":{"login":"prazuma","id":7258066,"avatar_url":"https://avatars.githubusercontent.com/u/7258066?v=3","gravatar_id":"","url":"https://api.github.com/users/prazuma","html_url":"https://github.com/prazuma","followers_url":"https://api.github.com/users/prazuma/followers","following_url":"https://api.github.com/users/prazuma/following{/other_user}","gists_url":"https://api.github.com/users/prazuma/gists{/gist_id}","starred_url":"https://api.github.com/users/prazuma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prazuma/subscriptions","organizations_url":"https://api.github.com/users/prazuma/orgs","repos_url":"https://api.github.com/users/prazuma/repos","events_url":"https://api.github.com/users/prazuma/events{/privacy}","received_events_url":"https://api.github.com/users/prazuma/received_events","type":"User","site_admin":false},"body":"done","created_at":"2015-08-12T09:30:11Z","updated_at":"2015-08-12T09:30:11Z","html_url":"https://github.com/google/personfinder/pull/116#discussion_r36841144","pull_request_url":"https://api.github.com/repos/google/personfinder/pulls/116","_links":{"self":{"href":"https://api.github.com/repos/google/personfinder/pulls/comments/36841144"},"html":{"href":"https://github.com/google/personfinder/pull/116#discussion_r36841144"},"pull_request":{"href":"https://api.github.com/repos/google/personfinder/pulls/116"}}},"pull_request":{"url":"https://api.github.com/repos/google/personfinder/pulls/116","id":41988025,"html_url":"https://github.com/google/personfinder/pull/116","diff_url":"https://github.com/google/personfinder/pull/116.diff","patch_url":"https://github.com/google/personfinder/pull/116.patch","issue_url":"https://api.github.com/repos/google/personfinder/issues/116","number":116,"state":"open","locked":false,"title":"change json fields in admin page #105","user":{"login":"prazuma","id":7258066,"avatar_url":"https://avatars.githubusercontent.com/u/7258066?v=3","gravatar_id":"","url":"https://api.github.com/users/prazuma","html_url":"https://github.com/prazuma","followers_url":"https://api.github.com/users/prazuma/followers","following_url":"https://api.github.com/users/prazuma/following{/other_user}","gists_url":"https://api.github.com/users/prazuma/gists{/gist_id}","starred_url":"https://api.github.com/users/prazuma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prazuma/subscriptions","organizations_url":"https://api.github.com/users/prazuma/orgs","repos_url":"https://api.github.com/users/prazuma/repos","events_url":"https://api.github.com/users/prazuma/events{/privacy}","received_events_url":"https://api.github.com/users/prazuma/received_events","type":"User","site_admin":false},"body":"#105 \r\nchange json fields(before, we have to write json directly) to guest fields as below\r\nbefore: https://screenshot.googleplex.com/ai3wP0CGEm5\r\nafter: https://screenshot.googleplex.com/BKw6QSaOEfX\r\n","created_at":"2015-08-10T05:15:28Z","updated_at":"2015-08-12T09:30:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"78db70a84cc78d5d01939d8dfcfea3a32c45e5c4","assignee":{"login":"skywhale","id":872395,"avatar_url":"https://avatars.githubusercontent.com/u/872395?v=3","gravatar_id":"","url":"https://api.github.com/users/skywhale","html_url":"https://github.com/skywhale","followers_url":"https://api.github.com/users/skywhale/followers","following_url":"https://api.github.com/users/skywhale/following{/other_user}","gists_url":"https://api.github.com/users/skywhale/gists{/gist_id}","starred_url":"https://api.github.com/users/skywhale/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/skywhale/subscriptions","organizations_url":"https://api.github.com/users/skywhale/orgs","repos_url":"https://api.github.com/users/skywhale/repos","events_url":"https://api.github.com/users/skywhale/events{/privacy}","received_events_url":"https://api.github.com/users/skywhale/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/google/personfinder/pulls/116/commits","review_comments_url":"https://api.github.com/repos/google/personfinder/pulls/116/comments","review_comment_url":"https://api.github.com/repos/google/personfinder/pulls/comments{/number}","comments_url":"https://api.github.com/repos/google/personfinder/issues/116/comments","statuses_url":"https://api.github.com/repos/google/personfinder/statuses/e6e5dc4f069e53ae16ba2a1434f735da9b8bd21b","head":{"label":"google:mikahashimoto-better-adminPageUIforJson","ref":"mikahashimoto-better-adminPageUIforJson","sha":"e6e5dc4f069e53ae16ba2a1434f735da9b8bd21b","user":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":25369506,"name":"personfinder","full_name":"google/personfinder","owner":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/google/personfinder","description":"Person Finder is a searchable missing person database written in Python and hosted on App Engine.","fork":false,"url":"https://api.github.com/repos/google/personfinder","forks_url":"https://api.github.com/repos/google/personfinder/forks","keys_url":"https://api.github.com/repos/google/personfinder/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/personfinder/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/personfinder/teams","hooks_url":"https://api.github.com/repos/google/personfinder/hooks","issue_events_url":"https://api.github.com/repos/google/personfinder/issues/events{/number}","events_url":"https://api.github.com/repos/google/personfinder/events","assignees_url":"https://api.github.com/repos/google/personfinder/assignees{/user}","branches_url":"https://api.github.com/repos/google/personfinder/branches{/branch}","tags_url":"https://api.github.com/repos/google/personfinder/tags","blobs_url":"https://api.github.com/repos/google/personfinder/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/personfinder/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/personfinder/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/personfinder/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/personfinder/statuses/{sha}","languages_url":"https://api.github.com/repos/google/personfinder/languages","stargazers_url":"https://api.github.com/repos/google/personfinder/stargazers","contributors_url":"https://api.github.com/repos/google/personfinder/contributors","subscribers_url":"https://api.github.com/repos/google/personfinder/subscribers","subscription_url":"https://api.github.com/repos/google/personfinder/subscription","commits_url":"https://api.github.com/repos/google/personfinder/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/personfinder/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/personfinder/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/personfinder/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/personfinder/contents/{+path}","compare_url":"https://api.github.com/repos/google/personfinder/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/personfinder/merges","archive_url":"https://api.github.com/repos/google/personfinder/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/personfinder/downloads","issues_url":"https://api.github.com/repos/google/personfinder/issues{/number}","pulls_url":"https://api.github.com/repos/google/personfinder/pulls{/number}","milestones_url":"https://api.github.com/repos/google/personfinder/milestones{/number}","notifications_url":"https://api.github.com/repos/google/personfinder/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/personfinder/labels{/name}","releases_url":"https://api.github.com/repos/google/personfinder/releases{/id}","created_at":"2014-10-17T17:36:25Z","updated_at":"2015-08-05T02:18:37Z","pushed_at":"2015-08-12T07:08:23Z","git_url":"git://github.com/google/personfinder.git","ssh_url":"git@github.com:google/personfinder.git","clone_url":"https://github.com/google/personfinder.git","svn_url":"https://github.com/google/personfinder","homepage":"https://google.org/personfinder","size":235823,"stargazers_count":81,"watchers_count":81,"language":"Python","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":38,"mirror_url":null,"open_issues_count":60,"forks":38,"open_issues":60,"watchers":81,"default_branch":"master"}},"base":{"label":"google:master","ref":"master","sha":"4375e4dadd49438d4473029040a909c7aa95d836","user":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":25369506,"name":"personfinder","full_name":"google/personfinder","owner":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/google/personfinder","description":"Person Finder is a searchable missing person database written in Python and hosted on App Engine.","fork":false,"url":"https://api.github.com/repos/google/personfinder","forks_url":"https://api.github.com/repos/google/personfinder/forks","keys_url":"https://api.github.com/repos/google/personfinder/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/personfinder/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/personfinder/teams","hooks_url":"https://api.github.com/repos/google/personfinder/hooks","issue_events_url":"https://api.github.com/repos/google/personfinder/issues/events{/number}","events_url":"https://api.github.com/repos/google/personfinder/events","assignees_url":"https://api.github.com/repos/google/personfinder/assignees{/user}","branches_url":"https://api.github.com/repos/google/personfinder/branches{/branch}","tags_url":"https://api.github.com/repos/google/personfinder/tags","blobs_url":"https://api.github.com/repos/google/personfinder/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/personfinder/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/personfinder/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/personfinder/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/personfinder/statuses/{sha}","languages_url":"https://api.github.com/repos/google/personfinder/languages","stargazers_url":"https://api.github.com/repos/google/personfinder/stargazers","contributors_url":"https://api.github.com/repos/google/personfinder/contributors","subscribers_url":"https://api.github.com/repos/google/personfinder/subscribers","subscription_url":"https://api.github.com/repos/google/personfinder/subscription","commits_url":"https://api.github.com/repos/google/personfinder/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/personfinder/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/personfinder/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/personfinder/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/personfinder/contents/{+path}","compare_url":"https://api.github.com/repos/google/personfinder/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/personfinder/merges","archive_url":"https://api.github.com/repos/google/personfinder/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/personfinder/downloads","issues_url":"https://api.github.com/repos/google/personfinder/issues{/number}","pulls_url":"https://api.github.com/repos/google/personfinder/pulls{/number}","milestones_url":"https://api.github.com/repos/google/personfinder/milestones{/number}","notifications_url":"https://api.github.com/repos/google/personfinder/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/personfinder/labels{/name}","releases_url":"https://api.github.com/repos/google/personfinder/releases{/id}","created_at":"2014-10-17T17:36:25Z","updated_at":"2015-08-05T02:18:37Z","pushed_at":"2015-08-12T07:08:23Z","git_url":"git://github.com/google/personfinder.git","ssh_url":"git@github.com:google/personfinder.git","clone_url":"https://github.com/google/personfinder.git","svn_url":"https://github.com/google/personfinder","homepage":"https://google.org/personfinder","size":235823,"stargazers_count":81,"watchers_count":81,"language":"Python","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":38,"mirror_url":null,"open_issues_count":60,"forks":38,"open_issues":60,"watchers":81,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/google/personfinder/pulls/116"},"html":{"href":"https://github.com/google/personfinder/pull/116"},"issue":{"href":"https://api.github.com/repos/google/personfinder/issues/116"},"comments":{"href":"https://api.github.com/repos/google/personfinder/issues/116/comments"},"review_comments":{"href":"https://api.github.com/repos/google/personfinder/pulls/116/comments"},"review_comment":{"href":"https://api.github.com/repos/google/personfinder/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/google/personfinder/pulls/116/commits"},"statuses":{"href":"https://api.github.com/repos/google/personfinder/statuses/e6e5dc4f069e53ae16ba2a1434f735da9b8bd21b"}}}}