{"action":"created","comment":{"url":"https://api.github.com/repos/PencilCode/pencilcode/pulls/comments/34965575","id":34965575,"diff_hunk":"@@ -1,20 +1,50 @@\n+var html2canvas = require('html2canvas');\n var THUMBNAIL_SIZE = 128;\n+var NUM_ATTEMPTS = 3;\n \n // Public functions\n var thumbnail = {\n-  generateThumbnailDataUrl: function(iframe) {\n+  generateThumbnailDataUrl: function(iframe, callback) {\n     // Get the canvas inside the iframe.\n     var innerDoc = iframe.contentDocument || iframe.contentWindow.document;\n-    // TODO: Add support for multiple turtle.\n-    var canvas = innerDoc.getElementsByTagName('canvas')[0];\n+    var innerBody = innerDoc.body;\n \n-    if (!canvas || canvas.id === 'turtle') { return; }\n+    // Hide the test panel and coordinates before capturing the thumbnail.\n+    for (var i = 0; i < innerBody.childElementCount; i++) {\n+      if (innerBody.children[i].tagName.toLowerCase() === 'samp' && (\n+          innerBody.children[i].className !== 'turtlefield' ||\n+          innerBody.children[i].id == '_testpanel')) {\n+        innerBody.children[i].style.display = 'none';","path":"content/src/thumbnail.js","position":21,"original_position":21,"commit_id":"604516f0e9a016e66f03cc3556af9fefc443cb5f","original_commit_id":"604516f0e9a016e66f03cc3556af9fefc443cb5f","user":{"login":"davidbau","id":3458792,"avatar_url":"https://avatars.githubusercontent.com/u/3458792?v=3","gravatar_id":"","url":"https://api.github.com/users/davidbau","html_url":"https://github.com/davidbau","followers_url":"https://api.github.com/users/davidbau/followers","following_url":"https://api.github.com/users/davidbau/following{/other_user}","gists_url":"https://api.github.com/users/davidbau/gists{/gist_id}","starred_url":"https://api.github.com/users/davidbau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidbau/subscriptions","organizations_url":"https://api.github.com/users/davidbau/orgs","repos_url":"https://api.github.com/users/davidbau/repos","events_url":"https://api.github.com/users/davidbau/events{/privacy}","received_events_url":"https://api.github.com/users/davidbau/received_events","type":"User","site_admin":false},"body":"Here maybe have a list of `hiddenElements`, and then accumulate the list as well as the old value of `elt.style.display` when you set each `elt.style.display = 'none'`.\r\n\r\nThen below in `onRendered`, you can go through the same list and restore all the old `elt.style.display` values.","created_at":"2015-07-20T01:53:22Z","updated_at":"2015-07-20T01:53:22Z","html_url":"https://github.com/PencilCode/pencilcode/pull/155#discussion_r34965575","pull_request_url":"https://api.github.com/repos/PencilCode/pencilcode/pulls/155","_links":{"self":{"href":"https://api.github.com/repos/PencilCode/pencilcode/pulls/comments/34965575"},"html":{"href":"https://github.com/PencilCode/pencilcode/pull/155#discussion_r34965575"},"pull_request":{"href":"https://api.github.com/repos/PencilCode/pencilcode/pulls/155"}}},"pull_request":{"url":"https://api.github.com/repos/PencilCode/pencilcode/pulls/155","id":39749034,"html_url":"https://github.com/PencilCode/pencilcode/pull/155","diff_url":"https://github.com/PencilCode/pencilcode/pull/155.diff","patch_url":"https://github.com/PencilCode/pencilcode/pull/155.patch","issue_url":"https://api.github.com/repos/PencilCode/pencilcode/issues/155","number":155,"state":"open","locked":false,"title":"Use `html2canvas` to assist thumbnail generation. ","user":{"login":"xinan","id":2834397,"avatar_url":"https://avatars.githubusercontent.com/u/2834397?v=3","gravatar_id":"","url":"https://api.github.com/users/xinan","html_url":"https://github.com/xinan","followers_url":"https://api.github.com/users/xinan/followers","following_url":"https://api.github.com/users/xinan/following{/other_user}","gists_url":"https://api.github.com/users/xinan/gists{/gist_id}","starred_url":"https://api.github.com/users/xinan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xinan/subscriptions","organizations_url":"https://api.github.com/users/xinan/orgs","repos_url":"https://api.github.com/users/xinan/repos","events_url":"https://api.github.com/users/xinan/events{/privacy}","received_events_url":"https://api.github.com/users/xinan/received_events","type":"User","site_admin":false},"body":"* Use `html2canvas` and use the old thumbnail functions to do cropping and resizing. \r\n - Able to capture html output (except cross-origin images)\r\n - Able to capture multiple turtles.\r\n - Able to capture turtle skins.\r\n\r\n\r\nNote: I reverted the camera button because it turns out to be more complicated than I thought. There are several severe bugs that needs to be solved. ","created_at":"2015-07-11T17:06:26Z","updated_at":"2015-07-20T01:53:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9ecd419ac803004d44c4cfb0c1209832d7466138","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/PencilCode/pencilcode/pulls/155/commits","review_comments_url":"https://api.github.com/repos/PencilCode/pencilcode/pulls/155/comments","review_comment_url":"https://api.github.com/repos/PencilCode/pencilcode/pulls/comments{/number}","comments_url":"https://api.github.com/repos/PencilCode/pencilcode/issues/155/comments","statuses_url":"https://api.github.com/repos/PencilCode/pencilcode/statuses/604516f0e9a016e66f03cc3556af9fefc443cb5f","head":{"label":"xinan:new_html2canvas","ref":"new_html2canvas","sha":"604516f0e9a016e66f03cc3556af9fefc443cb5f","user":{"login":"xinan","id":2834397,"avatar_url":"https://avatars.githubusercontent.com/u/2834397?v=3","gravatar_id":"","url":"https://api.github.com/users/xinan","html_url":"https://github.com/xinan","followers_url":"https://api.github.com/users/xinan/followers","following_url":"https://api.github.com/users/xinan/following{/other_user}","gists_url":"https://api.github.com/users/xinan/gists{/gist_id}","starred_url":"https://api.github.com/users/xinan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xinan/subscriptions","organizations_url":"https://api.github.com/users/xinan/orgs","repos_url":"https://api.github.com/users/xinan/repos","events_url":"https://api.github.com/users/xinan/events{/privacy}","received_events_url":"https://api.github.com/users/xinan/received_events","type":"User","site_admin":false},"repo":{"id":32626057,"name":"pencilcode","full_name":"xinan/pencilcode","owner":{"login":"xinan","id":2834397,"avatar_url":"https://avatars.githubusercontent.com/u/2834397?v=3","gravatar_id":"","url":"https://api.github.com/users/xinan","html_url":"https://github.com/xinan","followers_url":"https://api.github.com/users/xinan/followers","following_url":"https://api.github.com/users/xinan/following{/other_user}","gists_url":"https://api.github.com/users/xinan/gists{/gist_id}","starred_url":"https://api.github.com/users/xinan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xinan/subscriptions","organizations_url":"https://api.github.com/users/xinan/orgs","repos_url":"https://api.github.com/users/xinan/repos","events_url":"https://api.github.com/users/xinan/events{/privacy}","received_events_url":"https://api.github.com/users/xinan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/xinan/pencilcode","description":"An online IDE for kids: pencilcode.net.","fork":true,"url":"https://api.github.com/repos/xinan/pencilcode","forks_url":"https://api.github.com/repos/xinan/pencilcode/forks","keys_url":"https://api.github.com/repos/xinan/pencilcode/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xinan/pencilcode/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xinan/pencilcode/teams","hooks_url":"https://api.github.com/repos/xinan/pencilcode/hooks","issue_events_url":"https://api.github.com/repos/xinan/pencilcode/issues/events{/number}","events_url":"https://api.github.com/repos/xinan/pencilcode/events","assignees_url":"https://api.github.com/repos/xinan/pencilcode/assignees{/user}","branches_url":"https://api.github.com/repos/xinan/pencilcode/branches{/branch}","tags_url":"https://api.github.com/repos/xinan/pencilcode/tags","blobs_url":"https://api.github.com/repos/xinan/pencilcode/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xinan/pencilcode/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xinan/pencilcode/git/refs{/sha}","trees_url":"https://api.github.com/repos/xinan/pencilcode/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xinan/pencilcode/statuses/{sha}","languages_url":"https://api.github.com/repos/xinan/pencilcode/languages","stargazers_url":"https://api.github.com/repos/xinan/pencilcode/stargazers","contributors_url":"https://api.github.com/repos/xinan/pencilcode/contributors","subscribers_url":"https://api.github.com/repos/xinan/pencilcode/subscribers","subscription_url":"https://api.github.com/repos/xinan/pencilcode/subscription","commits_url":"https://api.github.com/repos/xinan/pencilcode/commits{/sha}","git_commits_url":"https://api.github.com/repos/xinan/pencilcode/git/commits{/sha}","comments_url":"https://api.github.com/repos/xinan/pencilcode/comments{/number}","issue_comment_url":"https://api.github.com/repos/xinan/pencilcode/issues/comments{/number}","contents_url":"https://api.github.com/repos/xinan/pencilcode/contents/{+path}","compare_url":"https://api.github.com/repos/xinan/pencilcode/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xinan/pencilcode/merges","archive_url":"https://api.github.com/repos/xinan/pencilcode/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xinan/pencilcode/downloads","issues_url":"https://api.github.com/repos/xinan/pencilcode/issues{/number}","pulls_url":"https://api.github.com/repos/xinan/pencilcode/pulls{/number}","milestones_url":"https://api.github.com/repos/xinan/pencilcode/milestones{/number}","notifications_url":"https://api.github.com/repos/xinan/pencilcode/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xinan/pencilcode/labels{/name}","releases_url":"https://api.github.com/repos/xinan/pencilcode/releases{/id}","created_at":"2015-03-21T08:58:50Z","updated_at":"2015-05-08T15:46:23Z","pushed_at":"2015-07-19T18:05:38Z","git_url":"git://github.com/xinan/pencilcode.git","ssh_url":"git@github.com:xinan/pencilcode.git","clone_url":"https://github.com/xinan/pencilcode.git","svn_url":"https://github.com/xinan/pencilcode","homepage":"http://dev.pencilcode.net/","size":18219,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"visual-thumbnail"}},"base":{"label":"PencilCode:master","ref":"master","sha":"1774fa32a38934490ab38e994c76f8306bd9d846","user":{"login":"PencilCode","id":6116232,"avatar_url":"https://avatars.githubusercontent.com/u/6116232?v=3","gravatar_id":"","url":"https://api.github.com/users/PencilCode","html_url":"https://github.com/PencilCode","followers_url":"https://api.github.com/users/PencilCode/followers","following_url":"https://api.github.com/users/PencilCode/following{/other_user}","gists_url":"https://api.github.com/users/PencilCode/gists{/gist_id}","starred_url":"https://api.github.com/users/PencilCode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PencilCode/subscriptions","organizations_url":"https://api.github.com/users/PencilCode/orgs","repos_url":"https://api.github.com/users/PencilCode/repos","events_url":"https://api.github.com/users/PencilCode/events{/privacy}","received_events_url":"https://api.github.com/users/PencilCode/received_events","type":"Organization","site_admin":false},"repo":{"id":15417810,"name":"pencilcode","full_name":"PencilCode/pencilcode","owner":{"login":"PencilCode","id":6116232,"avatar_url":"https://avatars.githubusercontent.com/u/6116232?v=3","gravatar_id":"","url":"https://api.github.com/users/PencilCode","html_url":"https://github.com/PencilCode","followers_url":"https://api.github.com/users/PencilCode/followers","following_url":"https://api.github.com/users/PencilCode/following{/other_user}","gists_url":"https://api.github.com/users/PencilCode/gists{/gist_id}","starred_url":"https://api.github.com/users/PencilCode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PencilCode/subscriptions","organizations_url":"https://api.github.com/users/PencilCode/orgs","repos_url":"https://api.github.com/users/PencilCode/repos","events_url":"https://api.github.com/users/PencilCode/events{/privacy}","received_events_url":"https://api.github.com/users/PencilCode/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/PencilCode/pencilcode","description":"An online IDE for kids: pencilcode.net.","fork":false,"url":"https://api.github.com/repos/PencilCode/pencilcode","forks_url":"https://api.github.com/repos/PencilCode/pencilcode/forks","keys_url":"https://api.github.com/repos/PencilCode/pencilcode/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PencilCode/pencilcode/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PencilCode/pencilcode/teams","hooks_url":"https://api.github.com/repos/PencilCode/pencilcode/hooks","issue_events_url":"https://api.github.com/repos/PencilCode/pencilcode/issues/events{/number}","events_url":"https://api.github.com/repos/PencilCode/pencilcode/events","assignees_url":"https://api.github.com/repos/PencilCode/pencilcode/assignees{/user}","branches_url":"https://api.github.com/repos/PencilCode/pencilcode/branches{/branch}","tags_url":"https://api.github.com/repos/PencilCode/pencilcode/tags","blobs_url":"https://api.github.com/repos/PencilCode/pencilcode/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PencilCode/pencilcode/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PencilCode/pencilcode/git/refs{/sha}","trees_url":"https://api.github.com/repos/PencilCode/pencilcode/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PencilCode/pencilcode/statuses/{sha}","languages_url":"https://api.github.com/repos/PencilCode/pencilcode/languages","stargazers_url":"https://api.github.com/repos/PencilCode/pencilcode/stargazers","contributors_url":"https://api.github.com/repos/PencilCode/pencilcode/contributors","subscribers_url":"https://api.github.com/repos/PencilCode/pencilcode/subscribers","subscription_url":"https://api.github.com/repos/PencilCode/pencilcode/subscription","commits_url":"https://api.github.com/repos/PencilCode/pencilcode/commits{/sha}","git_commits_url":"https://api.github.com/repos/PencilCode/pencilcode/git/commits{/sha}","comments_url":"https://api.github.com/repos/PencilCode/pencilcode/comments{/number}","issue_comment_url":"https://api.github.com/repos/PencilCode/pencilcode/issues/comments{/number}","contents_url":"https://api.github.com/repos/PencilCode/pencilcode/contents/{+path}","compare_url":"https://api.github.com/repos/PencilCode/pencilcode/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PencilCode/pencilcode/merges","archive_url":"https://api.github.com/repos/PencilCode/pencilcode/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PencilCode/pencilcode/downloads","issues_url":"https://api.github.com/repos/PencilCode/pencilcode/issues{/number}","pulls_url":"https://api.github.com/repos/PencilCode/pencilcode/pulls{/number}","milestones_url":"https://api.github.com/repos/PencilCode/pencilcode/milestones{/number}","notifications_url":"https://api.github.com/repos/PencilCode/pencilcode/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PencilCode/pencilcode/labels{/name}","releases_url":"https://api.github.com/repos/PencilCode/pencilcode/releases{/id}","created_at":"2013-12-24T12:08:52Z","updated_at":"2015-07-14T20:45:44Z","pushed_at":"2015-07-19T23:02:39Z","git_url":"git://github.com/PencilCode/pencilcode.git","ssh_url":"git@github.com:PencilCode/pencilcode.git","clone_url":"https://github.com/PencilCode/pencilcode.git","svn_url":"https://github.com/PencilCode/pencilcode","homepage":"http://dev.pencilcode.net/","size":24960,"stargazers_count":58,"watchers_count":58,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":46,"mirror_url":null,"open_issues_count":39,"forks":46,"open_issues":39,"watchers":58,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/PencilCode/pencilcode/pulls/155"},"html":{"href":"https://github.com/PencilCode/pencilcode/pull/155"},"issue":{"href":"https://api.github.com/repos/PencilCode/pencilcode/issues/155"},"comments":{"href":"https://api.github.com/repos/PencilCode/pencilcode/issues/155/comments"},"review_comments":{"href":"https://api.github.com/repos/PencilCode/pencilcode/pulls/155/comments"},"review_comment":{"href":"https://api.github.com/repos/PencilCode/pencilcode/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/PencilCode/pencilcode/pulls/155/commits"},"statuses":{"href":"https://api.github.com/repos/PencilCode/pencilcode/statuses/604516f0e9a016e66f03cc3556af9fefc443cb5f"}}}}