{"action":"created","comment":{"url":"https://api.github.com/repos/zotero/translators/pulls/comments/31881880","id":31881880,"diff_hunk":"@@ -0,0 +1,287 @@\n+{\n+\t\"translatorID\": \"fd8dc5f6-a6dd-42b2-948f-600f5da844ea\",\n+\t\"label\": \"WorldCat Discovery Service\",\n+\t\"creator\": \"Sebastian Karcher\",\n+\t\"target\": \"^https?://[^/]+\\\\.worldcat\\\\.org\",\n+\t\"minVersion\": \"3.0.9\",\n+\t\"maxVersion\": \"\",\n+\t\"priority\": 100,\n+\t\"inRepository\": true,\n+\t\"translatorType\": 4,\n+\t\"browserSupport\": \"gcsbv\",\n+\t\"lastUpdated\": \"2015-06-07 17:32:35\"\n+}\n+\n+function detectWeb(doc, url) {\n+\t\n+\tvar results = getSearchResults(doc);\n+\tif(results.length) {\n+\t\treturn \"multiple\";\n+\t}\n+\t\n+\n+\t//single result\n+\t// generate item and return type\n+\tvar co = getFirstContextObj(doc);\n+\tif(!co) return false;\n+\n+\treturn generateItem(doc, co).itemType;\n+}\n+\n+\n+/**\n+ * Gets Zotero item from a WorldCat icon src\n+ */\n+function getZoteroType(iconSrc) {\n+\t// only specify types not specified in COinS\n+\tif (iconSrc.indexOf(\"icon-rec\") != -1) {\n+\t\treturn \"audioRecording\";\n+\t}\n+\tif (iconSrc.indexOf(\"icon-com\") != -1) {\n+\t\treturn \"computerProgram\";\n+\t}\n+\tif (iconSrc.indexOf(\"icon-map\") != -1) {\n+\t\treturn \"map\";\n+\t}\n+\treturn false;\n+}\n+\n+/**\n+ * Generates a Zotero item from a single item WorldCat page,\n+ * or the first item on a multiple item page\n+ */\n+function generateItem(doc, co) {\n+\tvar item = new Zotero.Item();\n+\tZU.parseContextObject(co, item);\n+\t// item types not covered by COinS will still need to be covered. Leaving the corresponding code from open Worldcat\n+\t// here as a reminder.\n+\n+/*\n+\tvar type = ZU.xpathText(doc,\n+\t\t'//img[@class=\"icn\"][contains(@src, \"icon-\")][1]/@src');\n+\tif (type) {\n+\t\ttype = getZoteroType(type);\n+\t\tif (type) item.itemType = type;\n+\t} */\n+\t\n+\treturn item;\n+}\n+\n+function getSearchResults(doc) {\n+\tvar results = ZU.xpath(doc, '//ol[@class=\"results\"]/li[contains(@id, \"record\")]')\n+\treturn results;\n+}\n+\n+function getTitleNode(searchResult) {\n+\treturn ZU.xpath(searchResult, './div[@class=\"title\"]/a')[0];\n+}\n+\n+function getFirstContextObj(doc) {\n+\treturn ZU.xpathText(doc, '//span[@class=\"Z3988\"][1]/@title');\n+}\n+\n+\n+\n+/**\n+ * Given an item URL, extract OCLC ID\n+ */\n+function extractOCLCID(url) {\n+\tvar id = url.match(/\\/oclc\\/([^?]+)/);\n+\tif(!id) return false;\n+\treturn id[1];\n+}\n+\n+\n+/**\n+ * Given an item URL, extract database ID\n+ */\n+function extractDatabaseID(url) {\n+\tvar id = url.match(/databaseList=[^&#]+/);","path":"WorldCat Discovery Service.js","position":99,"original_position":99,"commit_id":"4911ca976183e0592538c3fed848a26e38529c97","original_commit_id":"4911ca976183e0592538c3fed848a26e38529c97","user":{"login":"aurimasv","id":1381759,"avatar_url":"https://avatars.githubusercontent.com/u/1381759?v=3","gravatar_id":"","url":"https://api.github.com/users/aurimasv","html_url":"https://github.com/aurimasv","followers_url":"https://api.github.com/users/aurimasv/followers","following_url":"https://api.github.com/users/aurimasv/following{/other_user}","gists_url":"https://api.github.com/users/aurimasv/gists{/gist_id}","starred_url":"https://api.github.com/users/aurimasv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aurimasv/subscriptions","organizations_url":"https://api.github.com/users/aurimasv/orgs","repos_url":"https://api.github.com/users/aurimasv/repos","events_url":"https://api.github.com/users/aurimasv/events{/privacy}","received_events_url":"https://api.github.com/users/aurimasv/received_events","type":"User","site_admin":false},"body":"I'm pretty sure you want to capture the ID here (in parentheses) and return just that part below, instead of the full match","created_at":"2015-06-07T23:05:52Z","updated_at":"2015-06-07T23:05:52Z","html_url":"https://github.com/zotero/translators/pull/902#discussion_r31881880","pull_request_url":"https://api.github.com/repos/zotero/translators/pulls/902","_links":{"self":{"href":"https://api.github.com/repos/zotero/translators/pulls/comments/31881880"},"html":{"href":"https://github.com/zotero/translators/pull/902#discussion_r31881880"},"pull_request":{"href":"https://api.github.com/repos/zotero/translators/pulls/902"}}},"pull_request":{"url":"https://api.github.com/repos/zotero/translators/pulls/902","id":37112529,"html_url":"https://github.com/zotero/translators/pull/902","diff_url":"https://github.com/zotero/translators/pull/902.diff","patch_url":"https://github.com/zotero/translators/pull/902.patch","issue_url":"https://api.github.com/repos/zotero/translators/issues/902","number":902,"state":"open","locked":false,"title":"add new WorldCat Discovery translator. Oddly, the RIS data appears fl…","user":{"login":"adam3smith","id":128986,"avatar_url":"https://avatars.githubusercontent.com/u/128986?v=3","gravatar_id":"","url":"https://api.github.com/users/adam3smith","html_url":"https://github.com/adam3smith","followers_url":"https://api.github.com/users/adam3smith/followers","following_url":"https://api.github.com/users/adam3smith/following{/other_user}","gists_url":"https://api.github.com/users/adam3smith/gists{/gist_id}","starred_url":"https://api.github.com/users/adam3smith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adam3smith/subscriptions","organizations_url":"https://api.github.com/users/adam3smith/orgs","repos_url":"https://api.github.com/users/adam3smith/repos","events_url":"https://api.github.com/users/adam3smith/events{/privacy}","received_events_url":"https://api.github.com/users/adam3smith/received_events","type":"User","site_admin":false},"body":"…awed in different ways, so I built in a number of additional clean-ups and removed some from OpenWorldcat. For the same reason, it almost certainly makes sense to keep the two separate.\r\n\r\nThis one is less urgent, so I can wait for review.","created_at":"2015-06-07T20:11:28Z","updated_at":"2015-06-07T23:05:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c71f818360b7fc48e64f45ea3f725a76775439ef","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/zotero/translators/pulls/902/commits","review_comments_url":"https://api.github.com/repos/zotero/translators/pulls/902/comments","review_comment_url":"https://api.github.com/repos/zotero/translators/pulls/comments{/number}","comments_url":"https://api.github.com/repos/zotero/translators/issues/902/comments","statuses_url":"https://api.github.com/repos/zotero/translators/statuses/4911ca976183e0592538c3fed848a26e38529c97","head":{"label":"adam3smith:worldcat-discovery2","ref":"worldcat-discovery2","sha":"4911ca976183e0592538c3fed848a26e38529c97","user":{"login":"adam3smith","id":128986,"avatar_url":"https://avatars.githubusercontent.com/u/128986?v=3","gravatar_id":"","url":"https://api.github.com/users/adam3smith","html_url":"https://github.com/adam3smith","followers_url":"https://api.github.com/users/adam3smith/followers","following_url":"https://api.github.com/users/adam3smith/following{/other_user}","gists_url":"https://api.github.com/users/adam3smith/gists{/gist_id}","starred_url":"https://api.github.com/users/adam3smith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adam3smith/subscriptions","organizations_url":"https://api.github.com/users/adam3smith/orgs","repos_url":"https://api.github.com/users/adam3smith/repos","events_url":"https://api.github.com/users/adam3smith/events{/privacy}","received_events_url":"https://api.github.com/users/adam3smith/received_events","type":"User","site_admin":false},"repo":{"id":2577651,"name":"translators","full_name":"adam3smith/translators","owner":{"login":"adam3smith","id":128986,"avatar_url":"https://avatars.githubusercontent.com/u/128986?v=3","gravatar_id":"","url":"https://api.github.com/users/adam3smith","html_url":"https://github.com/adam3smith","followers_url":"https://api.github.com/users/adam3smith/followers","following_url":"https://api.github.com/users/adam3smith/following{/other_user}","gists_url":"https://api.github.com/users/adam3smith/gists{/gist_id}","starred_url":"https://api.github.com/users/adam3smith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adam3smith/subscriptions","organizations_url":"https://api.github.com/users/adam3smith/orgs","repos_url":"https://api.github.com/users/adam3smith/repos","events_url":"https://api.github.com/users/adam3smith/events{/privacy}","received_events_url":"https://api.github.com/users/adam3smith/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/adam3smith/translators","description":"Zotero Translators","fork":true,"url":"https://api.github.com/repos/adam3smith/translators","forks_url":"https://api.github.com/repos/adam3smith/translators/forks","keys_url":"https://api.github.com/repos/adam3smith/translators/keys{/key_id}","collaborators_url":"https://api.github.com/repos/adam3smith/translators/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/adam3smith/translators/teams","hooks_url":"https://api.github.com/repos/adam3smith/translators/hooks","issue_events_url":"https://api.github.com/repos/adam3smith/translators/issues/events{/number}","events_url":"https://api.github.com/repos/adam3smith/translators/events","assignees_url":"https://api.github.com/repos/adam3smith/translators/assignees{/user}","branches_url":"https://api.github.com/repos/adam3smith/translators/branches{/branch}","tags_url":"https://api.github.com/repos/adam3smith/translators/tags","blobs_url":"https://api.github.com/repos/adam3smith/translators/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/adam3smith/translators/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/adam3smith/translators/git/refs{/sha}","trees_url":"https://api.github.com/repos/adam3smith/translators/git/trees{/sha}","statuses_url":"https://api.github.com/repos/adam3smith/translators/statuses/{sha}","languages_url":"https://api.github.com/repos/adam3smith/translators/languages","stargazers_url":"https://api.github.com/repos/adam3smith/translators/stargazers","contributors_url":"https://api.github.com/repos/adam3smith/translators/contributors","subscribers_url":"https://api.github.com/repos/adam3smith/translators/subscribers","subscription_url":"https://api.github.com/repos/adam3smith/translators/subscription","commits_url":"https://api.github.com/repos/adam3smith/translators/commits{/sha}","git_commits_url":"https://api.github.com/repos/adam3smith/translators/git/commits{/sha}","comments_url":"https://api.github.com/repos/adam3smith/translators/comments{/number}","issue_comment_url":"https://api.github.com/repos/adam3smith/translators/issues/comments{/number}","contents_url":"https://api.github.com/repos/adam3smith/translators/contents/{+path}","compare_url":"https://api.github.com/repos/adam3smith/translators/compare/{base}...{head}","merges_url":"https://api.github.com/repos/adam3smith/translators/merges","archive_url":"https://api.github.com/repos/adam3smith/translators/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/adam3smith/translators/downloads","issues_url":"https://api.github.com/repos/adam3smith/translators/issues{/number}","pulls_url":"https://api.github.com/repos/adam3smith/translators/pulls{/number}","milestones_url":"https://api.github.com/repos/adam3smith/translators/milestones{/number}","notifications_url":"https://api.github.com/repos/adam3smith/translators/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/adam3smith/translators/labels{/name}","releases_url":"https://api.github.com/repos/adam3smith/translators/releases{/id}","created_at":"2011-10-14T17:26:44Z","updated_at":"2015-04-06T06:35:46Z","pushed_at":"2015-06-07T20:10:47Z","git_url":"git://github.com/adam3smith/translators.git","ssh_url":"git@github.com:adam3smith/translators.git","clone_url":"https://github.com/adam3smith/translators.git","svn_url":"https://github.com/adam3smith/translators","homepage":"http://www.zotero.org/support/dev/translators","size":11530,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"zotero:master","ref":"master","sha":"9729b15e3c6a54769d9ad03b1194aced636290c8","user":{"login":"zotero","id":891917,"avatar_url":"https://avatars.githubusercontent.com/u/891917?v=3","gravatar_id":"","url":"https://api.github.com/users/zotero","html_url":"https://github.com/zotero","followers_url":"https://api.github.com/users/zotero/followers","following_url":"https://api.github.com/users/zotero/following{/other_user}","gists_url":"https://api.github.com/users/zotero/gists{/gist_id}","starred_url":"https://api.github.com/users/zotero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zotero/subscriptions","organizations_url":"https://api.github.com/users/zotero/orgs","repos_url":"https://api.github.com/users/zotero/repos","events_url":"https://api.github.com/users/zotero/events{/privacy}","received_events_url":"https://api.github.com/users/zotero/received_events","type":"Organization","site_admin":false},"repo":{"id":1991863,"name":"translators","full_name":"zotero/translators","owner":{"login":"zotero","id":891917,"avatar_url":"https://avatars.githubusercontent.com/u/891917?v=3","gravatar_id":"","url":"https://api.github.com/users/zotero","html_url":"https://github.com/zotero","followers_url":"https://api.github.com/users/zotero/followers","following_url":"https://api.github.com/users/zotero/following{/other_user}","gists_url":"https://api.github.com/users/zotero/gists{/gist_id}","starred_url":"https://api.github.com/users/zotero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zotero/subscriptions","organizations_url":"https://api.github.com/users/zotero/orgs","repos_url":"https://api.github.com/users/zotero/repos","events_url":"https://api.github.com/users/zotero/events{/privacy}","received_events_url":"https://api.github.com/users/zotero/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zotero/translators","description":"Zotero Translators","fork":false,"url":"https://api.github.com/repos/zotero/translators","forks_url":"https://api.github.com/repos/zotero/translators/forks","keys_url":"https://api.github.com/repos/zotero/translators/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zotero/translators/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zotero/translators/teams","hooks_url":"https://api.github.com/repos/zotero/translators/hooks","issue_events_url":"https://api.github.com/repos/zotero/translators/issues/events{/number}","events_url":"https://api.github.com/repos/zotero/translators/events","assignees_url":"https://api.github.com/repos/zotero/translators/assignees{/user}","branches_url":"https://api.github.com/repos/zotero/translators/branches{/branch}","tags_url":"https://api.github.com/repos/zotero/translators/tags","blobs_url":"https://api.github.com/repos/zotero/translators/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zotero/translators/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zotero/translators/git/refs{/sha}","trees_url":"https://api.github.com/repos/zotero/translators/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zotero/translators/statuses/{sha}","languages_url":"https://api.github.com/repos/zotero/translators/languages","stargazers_url":"https://api.github.com/repos/zotero/translators/stargazers","contributors_url":"https://api.github.com/repos/zotero/translators/contributors","subscribers_url":"https://api.github.com/repos/zotero/translators/subscribers","subscription_url":"https://api.github.com/repos/zotero/translators/subscription","commits_url":"https://api.github.com/repos/zotero/translators/commits{/sha}","git_commits_url":"https://api.github.com/repos/zotero/translators/git/commits{/sha}","comments_url":"https://api.github.com/repos/zotero/translators/comments{/number}","issue_comment_url":"https://api.github.com/repos/zotero/translators/issues/comments{/number}","contents_url":"https://api.github.com/repos/zotero/translators/contents/{+path}","compare_url":"https://api.github.com/repos/zotero/translators/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zotero/translators/merges","archive_url":"https://api.github.com/repos/zotero/translators/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zotero/translators/downloads","issues_url":"https://api.github.com/repos/zotero/translators/issues{/number}","pulls_url":"https://api.github.com/repos/zotero/translators/pulls{/number}","milestones_url":"https://api.github.com/repos/zotero/translators/milestones{/number}","notifications_url":"https://api.github.com/repos/zotero/translators/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zotero/translators/labels{/name}","releases_url":"https://api.github.com/repos/zotero/translators/releases{/id}","created_at":"2011-07-03T17:40:38Z","updated_at":"2015-06-05T15:14:53Z","pushed_at":"2015-06-07T20:11:28Z","git_url":"git://github.com/zotero/translators.git","ssh_url":"git@github.com:zotero/translators.git","clone_url":"https://github.com/zotero/translators.git","svn_url":"https://github.com/zotero/translators","homepage":"http://www.zotero.org/support/dev/translators","size":17002,"stargazers_count":145,"watchers_count":145,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":124,"mirror_url":null,"open_issues_count":126,"forks":124,"open_issues":126,"watchers":145,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/zotero/translators/pulls/902"},"html":{"href":"https://github.com/zotero/translators/pull/902"},"issue":{"href":"https://api.github.com/repos/zotero/translators/issues/902"},"comments":{"href":"https://api.github.com/repos/zotero/translators/issues/902/comments"},"review_comments":{"href":"https://api.github.com/repos/zotero/translators/pulls/902/comments"},"review_comment":{"href":"https://api.github.com/repos/zotero/translators/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/zotero/translators/pulls/902/commits"},"statuses":{"href":"https://api.github.com/repos/zotero/translators/statuses/4911ca976183e0592538c3fed848a26e38529c97"}}}}