{"action":"created","comment":{"url":"https://api.github.com/repos/gmusic-utils/gmusic.js/pulls/comments/64869953","id":64869953,"diff_hunk":"@@ -239,6 +245,87 @@ proto.playback = {\n   }\n };\n \n+// Create a queue API\n+proto.queue = {\n+  _fireEvent: function (el, etype) {\n+    if (el.fireEvent) {\n+      el.fireEvent('on' + etype);\n+    } else {\n+      var evObj = document.createEvent('Events');\n+      evObj.initEvent(etype, true, false);\n+      el.dispatchEvent(evObj);\n+    }\n+  },\n+\n+  _render: function (container, force) {\n+    // DEV: The queue isn't rendered till a click event is fired on this element\n+    //      We must hide the queue during the 400ms animation and then reveal it\n+    //      once both the 400ms in and 400ms out animations are complete\n+    var table = container.querySelector('.queue-song-table');\n+    if (container.style.display === 'none' && (!table || force)) {\n+      // DEV: Hide the queue elements while we rapidly \"render\" the queue element\n+      //      We have to use a style element because inline styles are saved by GPM\n+      var style = document.createElement('style');\n+      style.innerHTML = SELECTORS.queue.container + '{left: 10000px !important}';\n+      document.body.appendChild(style);\n+\n+      // Render queue\n+      this.queue._fireEvent(document.querySelector(SELECTORS.queue.triggerButton), 'click');\n+      setTimeout(function () {\n+        // Return queue to intitial state\n+        this.queue._fireEvent(document.querySelector(SELECTORS.queue.triggerButton), 'click');\n+        setTimeout(function () {\n+          document.body.removeChild(style);\n+        }, 20);\n+      }.bind(this), 20);\n+    }\n+  },\n+\n+  clear: function (cb) {\n+    var clearButton = this.doc.querySelector(SELECTORS.queue.container + ' ' + SELECTORS.queue.clearButton);\n+    if (clearButton) {\n+      clearButton.click();\n+      setTimeout(function reRenderQueue () {\n+        this.queue._render(this.doc.querySelector(SELECTORS.queue.container), true);\n+        if (cb) {\n+          cb();\n+        }\n+      }.bind(this), 200);\n+    }\n+  },\n+\n+  getSongs: function () {\n+    var container = this.doc.querySelector(SELECTORS.queue.container);\n+    this.queue._render(container);\n+\n+    return Array.prototype.slice.call(\n+      container.querySelectorAll(SELECTORS.queue.songs)\n+    ).map(function mapRowToSong (row) {\n+      var timeString = row.querySelector('[data-col=\"duration\"]').textContent.trim().split(':');\n+      var details = row.querySelector('.song-details-wrapper');\n+      var defaultString = {\n+        textContent: null\n+      };\n+      var songObject = {\n+        id: row.getAttribute('data-id'),\n+        title: (details.querySelector('.song-title') || defaultString).textContent,\n+        artist: (details.querySelector('.song-artist') || defaultString).textContent,\n+        album: (details.querySelector('.song-album') || defaultString).textContent,\n+        art: row.querySelector('[data-col=\"song-details\"] img').src.replace('=s60-e100-c', ''),\n+        duration: 1000 * (parseInt(timeString[0], 10) * 60 + parseInt(timeString[1], 10)),\n+        playing: row.classList.contains('currently-playing')\n+      };\n+      return songObject;\n+    });\n+  },\n+\n+  playSong: function (id) {\n+    var songRow = this.doc.querySelector('[data-id=\"' + id + '\"]');","path":"dist/gmusic.js","position":92,"original_position":92,"commit_id":"2d564c3287269aac0544c21329dbc6364cdee120","original_commit_id":"2d564c3287269aac0544c21329dbc6364cdee120","user":{"login":"twolfson","id":902488,"avatar_url":"https://avatars.githubusercontent.com/u/902488?v=3","gravatar_id":"","url":"https://api.github.com/users/twolfson","html_url":"https://github.com/twolfson","followers_url":"https://api.github.com/users/twolfson/followers","following_url":"https://api.github.com/users/twolfson/following{/other_user}","gists_url":"https://api.github.com/users/twolfson/gists{/gist_id}","starred_url":"https://api.github.com/users/twolfson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twolfson/subscriptions","organizations_url":"https://api.github.com/users/twolfson/orgs","repos_url":"https://api.github.com/users/twolfson/repos","events_url":"https://api.github.com/users/twolfson/events{/privacy}","received_events_url":"https://api.github.com/users/twolfson/received_events","type":"User","site_admin":false},"body":"This is begging for an XSS attack. Can we escape the `id` somehow?","created_at":"2016-05-27T08:01:08Z","updated_at":"2016-05-27T08:01:08Z","html_url":"https://github.com/gmusic-utils/gmusic.js/pull/38#discussion_r64869953","pull_request_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/pulls/38","_links":{"self":{"href":"https://api.github.com/repos/gmusic-utils/gmusic.js/pulls/comments/64869953"},"html":{"href":"https://github.com/gmusic-utils/gmusic.js/pull/38#discussion_r64869953"},"pull_request":{"href":"https://api.github.com/repos/gmusic-utils/gmusic.js/pulls/38"}}},"pull_request":{"url":"https://api.github.com/repos/gmusic-utils/gmusic.js/pulls/38","id":71671978,"html_url":"https://github.com/gmusic-utils/gmusic.js/pull/38","diff_url":"https://github.com/gmusic-utils/gmusic.js/pull/38.diff","patch_url":"https://github.com/gmusic-utils/gmusic.js/pull/38.patch","issue_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/issues/38","number":38,"state":"open","locked":false,"title":"Feature/queue","user":{"login":"MarshallOfSound","id":6634592,"avatar_url":"https://avatars.githubusercontent.com/u/6634592?v=3","gravatar_id":"","url":"https://api.github.com/users/MarshallOfSound","html_url":"https://github.com/MarshallOfSound","followers_url":"https://api.github.com/users/MarshallOfSound/followers","following_url":"https://api.github.com/users/MarshallOfSound/following{/other_user}","gists_url":"https://api.github.com/users/MarshallOfSound/gists{/gist_id}","starred_url":"https://api.github.com/users/MarshallOfSound/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MarshallOfSound/subscriptions","organizations_url":"https://api.github.com/users/MarshallOfSound/orgs","repos_url":"https://api.github.com/users/MarshallOfSound/repos","events_url":"https://api.github.com/users/MarshallOfSound/events{/privacy}","received_events_url":"https://api.github.com/users/MarshallOfSound/received_events","type":"User","site_admin":false},"body":"As per #36 this PR adds in `queue` querying and controlling functionality.\r\n\r\nYou can now:\r\n\r\n* Clear the queue\r\n* Fetch all songs in the queue\r\n* Play any song in the queue\r\n* Listen for queue changes with `change:queue`\r\n\r\n/cc @gmusic-utils/gmusic-js @twolfson ","created_at":"2016-05-27T07:37:59Z","updated_at":"2016-05-27T08:01:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8f74e3eea1bfb7fc35762919e61a2f266566c821","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/pulls/38/commits","review_comments_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/pulls/38/comments","review_comment_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/issues/38/comments","statuses_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/statuses/2d564c3287269aac0544c21329dbc6364cdee120","head":{"label":"gmusic-utils:feature/queue","ref":"feature/queue","sha":"2d564c3287269aac0544c21329dbc6364cdee120","user":{"login":"gmusic-utils","id":16354163,"avatar_url":"https://avatars.githubusercontent.com/u/16354163?v=3","gravatar_id":"","url":"https://api.github.com/users/gmusic-utils","html_url":"https://github.com/gmusic-utils","followers_url":"https://api.github.com/users/gmusic-utils/followers","following_url":"https://api.github.com/users/gmusic-utils/following{/other_user}","gists_url":"https://api.github.com/users/gmusic-utils/gists{/gist_id}","starred_url":"https://api.github.com/users/gmusic-utils/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gmusic-utils/subscriptions","organizations_url":"https://api.github.com/users/gmusic-utils/orgs","repos_url":"https://api.github.com/users/gmusic-utils/repos","events_url":"https://api.github.com/users/gmusic-utils/events{/privacy}","received_events_url":"https://api.github.com/users/gmusic-utils/received_events","type":"Organization","site_admin":false},"repo":{"id":28583816,"name":"gmusic.js","full_name":"gmusic-utils/gmusic.js","owner":{"login":"gmusic-utils","id":16354163,"avatar_url":"https://avatars.githubusercontent.com/u/16354163?v=3","gravatar_id":"","url":"https://api.github.com/users/gmusic-utils","html_url":"https://github.com/gmusic-utils","followers_url":"https://api.github.com/users/gmusic-utils/followers","following_url":"https://api.github.com/users/gmusic-utils/following{/other_user}","gists_url":"https://api.github.com/users/gmusic-utils/gists{/gist_id}","starred_url":"https://api.github.com/users/gmusic-utils/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gmusic-utils/subscriptions","organizations_url":"https://api.github.com/users/gmusic-utils/orgs","repos_url":"https://api.github.com/users/gmusic-utils/repos","events_url":"https://api.github.com/users/gmusic-utils/events{/privacy}","received_events_url":"https://api.github.com/users/gmusic-utils/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gmusic-utils/gmusic.js","description":"Browser-side JS library for controlling Google Music","fork":false,"url":"https://api.github.com/repos/gmusic-utils/gmusic.js","forks_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/forks","keys_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/teams","hooks_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/hooks","issue_events_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/issues/events{/number}","events_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/events","assignees_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/assignees{/user}","branches_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/branches{/branch}","tags_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/tags","blobs_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/statuses/{sha}","languages_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/languages","stargazers_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/stargazers","contributors_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/contributors","subscribers_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/subscribers","subscription_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/subscription","commits_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/issues/comments{/number}","contents_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/contents/{+path}","compare_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/merges","archive_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/downloads","issues_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/issues{/number}","pulls_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/pulls{/number}","milestones_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/milestones{/number}","notifications_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/labels{/name}","releases_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/releases{/id}","deployments_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/deployments","created_at":"2014-12-29T07:12:46Z","updated_at":"2016-05-23T01:16:22Z","pushed_at":"2016-05-27T07:37:59Z","git_url":"git://github.com/gmusic-utils/gmusic.js.git","ssh_url":"git@github.com:gmusic-utils/gmusic.js.git","clone_url":"https://github.com/gmusic-utils/gmusic.js.git","svn_url":"https://github.com/gmusic-utils/gmusic.js","homepage":"","size":1804,"stargazers_count":30,"watchers_count":30,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":12,"forks":4,"open_issues":12,"watchers":30,"default_branch":"master"}},"base":{"label":"gmusic-utils:master","ref":"master","sha":"304d6c24d06f5dd3d07fece5ae872520905c7a21","user":{"login":"gmusic-utils","id":16354163,"avatar_url":"https://avatars.githubusercontent.com/u/16354163?v=3","gravatar_id":"","url":"https://api.github.com/users/gmusic-utils","html_url":"https://github.com/gmusic-utils","followers_url":"https://api.github.com/users/gmusic-utils/followers","following_url":"https://api.github.com/users/gmusic-utils/following{/other_user}","gists_url":"https://api.github.com/users/gmusic-utils/gists{/gist_id}","starred_url":"https://api.github.com/users/gmusic-utils/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gmusic-utils/subscriptions","organizations_url":"https://api.github.com/users/gmusic-utils/orgs","repos_url":"https://api.github.com/users/gmusic-utils/repos","events_url":"https://api.github.com/users/gmusic-utils/events{/privacy}","received_events_url":"https://api.github.com/users/gmusic-utils/received_events","type":"Organization","site_admin":false},"repo":{"id":28583816,"name":"gmusic.js","full_name":"gmusic-utils/gmusic.js","owner":{"login":"gmusic-utils","id":16354163,"avatar_url":"https://avatars.githubusercontent.com/u/16354163?v=3","gravatar_id":"","url":"https://api.github.com/users/gmusic-utils","html_url":"https://github.com/gmusic-utils","followers_url":"https://api.github.com/users/gmusic-utils/followers","following_url":"https://api.github.com/users/gmusic-utils/following{/other_user}","gists_url":"https://api.github.com/users/gmusic-utils/gists{/gist_id}","starred_url":"https://api.github.com/users/gmusic-utils/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gmusic-utils/subscriptions","organizations_url":"https://api.github.com/users/gmusic-utils/orgs","repos_url":"https://api.github.com/users/gmusic-utils/repos","events_url":"https://api.github.com/users/gmusic-utils/events{/privacy}","received_events_url":"https://api.github.com/users/gmusic-utils/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gmusic-utils/gmusic.js","description":"Browser-side JS library for controlling Google Music","fork":false,"url":"https://api.github.com/repos/gmusic-utils/gmusic.js","forks_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/forks","keys_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/teams","hooks_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/hooks","issue_events_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/issues/events{/number}","events_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/events","assignees_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/assignees{/user}","branches_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/branches{/branch}","tags_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/tags","blobs_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/statuses/{sha}","languages_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/languages","stargazers_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/stargazers","contributors_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/contributors","subscribers_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/subscribers","subscription_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/subscription","commits_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/issues/comments{/number}","contents_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/contents/{+path}","compare_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/merges","archive_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/downloads","issues_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/issues{/number}","pulls_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/pulls{/number}","milestones_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/milestones{/number}","notifications_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/labels{/name}","releases_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/releases{/id}","deployments_url":"https://api.github.com/repos/gmusic-utils/gmusic.js/deployments","created_at":"2014-12-29T07:12:46Z","updated_at":"2016-05-23T01:16:22Z","pushed_at":"2016-05-27T07:37:59Z","git_url":"git://github.com/gmusic-utils/gmusic.js.git","ssh_url":"git@github.com:gmusic-utils/gmusic.js.git","clone_url":"https://github.com/gmusic-utils/gmusic.js.git","svn_url":"https://github.com/gmusic-utils/gmusic.js","homepage":"","size":1804,"stargazers_count":30,"watchers_count":30,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":12,"forks":4,"open_issues":12,"watchers":30,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gmusic-utils/gmusic.js/pulls/38"},"html":{"href":"https://github.com/gmusic-utils/gmusic.js/pull/38"},"issue":{"href":"https://api.github.com/repos/gmusic-utils/gmusic.js/issues/38"},"comments":{"href":"https://api.github.com/repos/gmusic-utils/gmusic.js/issues/38/comments"},"review_comments":{"href":"https://api.github.com/repos/gmusic-utils/gmusic.js/pulls/38/comments"},"review_comment":{"href":"https://api.github.com/repos/gmusic-utils/gmusic.js/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gmusic-utils/gmusic.js/pulls/38/commits"},"statuses":{"href":"https://api.github.com/repos/gmusic-utils/gmusic.js/statuses/2d564c3287269aac0544c21329dbc6364cdee120"}}}}
{"actor":{"display_login":"twolfson"}}