{"action":"created","comment":{"url":"https://api.github.com/repos/foosel/OctoPrint/pulls/comments/55034255","id":55034255,"diff_hunk":"@@ -252,11 +251,34 @@ $(function() {\n             // now try to instantiate every one of our as of yet unprocessed view model descriptors\n             while (unprocessedViewModels.length > 0){\n                 var viewModel = unprocessedViewModels.shift();\n-                var viewModelId = _getViewModelId(viewModel);\n+\n+                // wrap anything not object related into an object (use jQuery since lodash returns invalid results)\n+                if(!$.isPlainObject(viewModel)) {","path":"src/octoprint/static/js/app/main.js","position":80,"original_position":80,"commit_id":"0827ae10f206910b4fd82a5d987790f2fe784ae5","original_commit_id":"0827ae10f206910b4fd82a5d987790f2fe784ae5","user":{"login":"BillyBlaze","id":445608,"avatar_url":"https://avatars.githubusercontent.com/u/445608?v=3","gravatar_id":"","url":"https://api.github.com/users/BillyBlaze","html_url":"https://github.com/BillyBlaze","followers_url":"https://api.github.com/users/BillyBlaze/followers","following_url":"https://api.github.com/users/BillyBlaze/following{/other_user}","gists_url":"https://api.github.com/users/BillyBlaze/gists{/gist_id}","starred_url":"https://api.github.com/users/BillyBlaze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BillyBlaze/subscriptions","organizations_url":"https://api.github.com/users/BillyBlaze/orgs","repos_url":"https://api.github.com/users/BillyBlaze/repos","events_url":"https://api.github.com/users/BillyBlaze/events{/privacy}","received_events_url":"https://api.github.com/users/BillyBlaze/received_events","type":"User","site_admin":false},"body":"Note: Replace $.isPlainObject with _.isPlainObject","created_at":"2016-03-04T14:18:25Z","updated_at":"2016-03-04T14:18:25Z","html_url":"https://github.com/foosel/OctoPrint/pull/1232#discussion_r55034255","pull_request_url":"https://api.github.com/repos/foosel/OctoPrint/pulls/1232","_links":{"self":{"href":"https://api.github.com/repos/foosel/OctoPrint/pulls/comments/55034255"},"html":{"href":"https://github.com/foosel/OctoPrint/pull/1232#discussion_r55034255"},"pull_request":{"href":"https://api.github.com/repos/foosel/OctoPrint/pulls/1232"}}},"pull_request":{"url":"https://api.github.com/repos/foosel/OctoPrint/pulls/1232","id":59879704,"html_url":"https://github.com/foosel/OctoPrint/pull/1232","diff_url":"https://github.com/foosel/OctoPrint/pull/1232.diff","patch_url":"https://github.com/foosel/OctoPrint/pull/1232.patch","issue_url":"https://api.github.com/repos/foosel/OctoPrint/issues/1232","number":1232,"state":"open","locked":false,"title":"knockout: Multiple ways of registering your code + Optional dependencies","user":{"login":"BillyBlaze","id":445608,"avatar_url":"https://avatars.githubusercontent.com/u/445608?v=3","gravatar_id":"","url":"https://api.github.com/users/BillyBlaze","html_url":"https://github.com/BillyBlaze","followers_url":"https://api.github.com/users/BillyBlaze/followers","following_url":"https://api.github.com/users/BillyBlaze/following{/other_user}","gists_url":"https://api.github.com/users/BillyBlaze/gists{/gist_id}","starred_url":"https://api.github.com/users/BillyBlaze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BillyBlaze/subscriptions","organizations_url":"https://api.github.com/users/BillyBlaze/orgs","repos_url":"https://api.github.com/users/BillyBlaze/repos","events_url":"https://api.github.com/users/BillyBlaze/events{/privacy}","received_events_url":"https://api.github.com/users/BillyBlaze/received_events","type":"User","site_admin":false},"body":"Beside my commitment, I refactored a bit of the processing, so please double check the CR :smile: \r\n\r\n**Extending OCTOPRINT_VIEWMODELS**\r\n\r\n1. Allow multiple way's of registering your code to OctoPrint\r\n\r\n    1. Objects:\r\n         ````\r\n        OCTOPRINT_VIEWMODELS.push({\r\n             construct: function namedViewModel() {},\r\n             dependencies: [vm1, vm2],\r\n             elements: [el1, el2],\r\n             optional: [vm1, vm2],\r\n             returnObject: true\r\n       });\r\n         ````\r\n\r\n    1. Functions:\r\n\r\n       ````\r\n      OCTOPRINT_VIEWMODELS.push(function namedViewModel() {});\r\n       ````\r\n\r\n    1. Even anonymous:\r\n       ````\r\n      OCTOPRINT_VIEWMODELS.push(function() {});\r\n       ````\r\n1. Add optional dependencies:\r\n\r\n    - Allow an 4th parameter in the array OCTOPRINT_VIEWMODELS\r\n\r\n       ````\r\n      OCTOPRINT_VIEWMODELS.push([\r\n           function namedViewModel() {},\r\n           [vm1, vm2],\r\n           [el1, el2],\r\n           [vm1, vm2]\r\n      ]);\r\n       ````\r\n\r\n1. Add option `returnObject: true` to return an object instead of an array:\r\n    \r\n    ````\r\n    {\r\n        settingsViewModel: function settingsViewModel,\r\n        softwareUpdateViewModel: function softwareUpdateViewModel\r\n    }\r\n    ````\r\n\r\n1. All options (dependencies, elements, optional, returnObject) are optional. The constructor is required. (throws error when undefined)\r\n\r\n\r\n*TODO (Will create another PR after discussion/feedback/etc): Update ``docs/plugins/viewmodels.rst``*","created_at":"2016-02-18T23:14:37Z","updated_at":"2016-03-04T14:18:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e23c086e715c025201a41a518369ac82880d18da","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/foosel/OctoPrint/pulls/1232/commits","review_comments_url":"https://api.github.com/repos/foosel/OctoPrint/pulls/1232/comments","review_comment_url":"https://api.github.com/repos/foosel/OctoPrint/pulls/comments{/number}","comments_url":"https://api.github.com/repos/foosel/OctoPrint/issues/1232/comments","statuses_url":"https://api.github.com/repos/foosel/OctoPrint/statuses/0827ae10f206910b4fd82a5d987790f2fe784ae5","head":{"label":"BillyBlaze:devel-ko-rewrite-optional","ref":"devel-ko-rewrite-optional","sha":"0827ae10f206910b4fd82a5d987790f2fe784ae5","user":{"login":"BillyBlaze","id":445608,"avatar_url":"https://avatars.githubusercontent.com/u/445608?v=3","gravatar_id":"","url":"https://api.github.com/users/BillyBlaze","html_url":"https://github.com/BillyBlaze","followers_url":"https://api.github.com/users/BillyBlaze/followers","following_url":"https://api.github.com/users/BillyBlaze/following{/other_user}","gists_url":"https://api.github.com/users/BillyBlaze/gists{/gist_id}","starred_url":"https://api.github.com/users/BillyBlaze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BillyBlaze/subscriptions","organizations_url":"https://api.github.com/users/BillyBlaze/orgs","repos_url":"https://api.github.com/users/BillyBlaze/repos","events_url":"https://api.github.com/users/BillyBlaze/events{/privacy}","received_events_url":"https://api.github.com/users/BillyBlaze/received_events","type":"User","site_admin":false},"repo":{"id":43638247,"name":"OctoPrint","full_name":"BillyBlaze/OctoPrint","owner":{"login":"BillyBlaze","id":445608,"avatar_url":"https://avatars.githubusercontent.com/u/445608?v=3","gravatar_id":"","url":"https://api.github.com/users/BillyBlaze","html_url":"https://github.com/BillyBlaze","followers_url":"https://api.github.com/users/BillyBlaze/followers","following_url":"https://api.github.com/users/BillyBlaze/following{/other_user}","gists_url":"https://api.github.com/users/BillyBlaze/gists{/gist_id}","starred_url":"https://api.github.com/users/BillyBlaze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BillyBlaze/subscriptions","organizations_url":"https://api.github.com/users/BillyBlaze/orgs","repos_url":"https://api.github.com/users/BillyBlaze/repos","events_url":"https://api.github.com/users/BillyBlaze/events{/privacy}","received_events_url":"https://api.github.com/users/BillyBlaze/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/BillyBlaze/OctoPrint","description":"OctoPrint provides a snappy web interface for controlling a 3D printer (RepRap, Ultimaker, ...).","fork":true,"url":"https://api.github.com/repos/BillyBlaze/OctoPrint","forks_url":"https://api.github.com/repos/BillyBlaze/OctoPrint/forks","keys_url":"https://api.github.com/repos/BillyBlaze/OctoPrint/keys{/key_id}","collaborators_url":"https://api.github.com/repos/BillyBlaze/OctoPrint/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/BillyBlaze/OctoPrint/teams","hooks_url":"https://api.github.com/repos/BillyBlaze/OctoPrint/hooks","issue_events_url":"https://api.github.com/repos/BillyBlaze/OctoPrint/issues/events{/number}","events_url":"https://api.github.com/repos/BillyBlaze/OctoPrint/events","assignees_url":"https://api.github.com/repos/BillyBlaze/OctoPrint/assignees{/user}","branches_url":"https://api.github.com/repos/BillyBlaze/OctoPrint/branches{/branch}","tags_url":"https://api.github.com/repos/BillyBlaze/OctoPrint/tags","blobs_url":"https://api.github.com/repos/BillyBlaze/OctoPrint/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/BillyBlaze/OctoPrint/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/BillyBlaze/OctoPrint/git/refs{/sha}","trees_url":"https://api.github.com/repos/BillyBlaze/OctoPrint/git/trees{/sha}","statuses_url":"https://api.github.com/repos/BillyBlaze/OctoPrint/statuses/{sha}","languages_url":"https://api.github.com/repos/BillyBlaze/OctoPrint/languages","stargazers_url":"https://api.github.com/repos/BillyBlaze/OctoPrint/stargazers","contributors_url":"https://api.github.com/repos/BillyBlaze/OctoPrint/contributors","subscribers_url":"https://api.github.com/repos/BillyBlaze/OctoPrint/subscribers","subscription_url":"https://api.github.com/repos/BillyBlaze/OctoPrint/subscription","commits_url":"https://api.github.com/repos/BillyBlaze/OctoPrint/commits{/sha}","git_commits_url":"https://api.github.com/repos/BillyBlaze/OctoPrint/git/commits{/sha}","comments_url":"https://api.github.com/repos/BillyBlaze/OctoPrint/comments{/number}","issue_comment_url":"https://api.github.com/repos/BillyBlaze/OctoPrint/issues/comments{/number}","contents_url":"https://api.github.com/repos/BillyBlaze/OctoPrint/contents/{+path}","compare_url":"https://api.github.com/repos/BillyBlaze/OctoPrint/compare/{base}...{head}","merges_url":"https://api.github.com/repos/BillyBlaze/OctoPrint/merges","archive_url":"https://api.github.com/repos/BillyBlaze/OctoPrint/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/BillyBlaze/OctoPrint/downloads","issues_url":"https://api.github.com/repos/BillyBlaze/OctoPrint/issues{/number}","pulls_url":"https://api.github.com/repos/BillyBlaze/OctoPrint/pulls{/number}","milestones_url":"https://api.github.com/repos/BillyBlaze/OctoPrint/milestones{/number}","notifications_url":"https://api.github.com/repos/BillyBlaze/OctoPrint/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/BillyBlaze/OctoPrint/labels{/name}","releases_url":"https://api.github.com/repos/BillyBlaze/OctoPrint/releases{/id}","deployments_url":"https://api.github.com/repos/BillyBlaze/OctoPrint/deployments","created_at":"2015-10-04T13:59:42Z","updated_at":"2016-02-15T21:20:31Z","pushed_at":"2016-02-27T17:38:20Z","git_url":"git://github.com/BillyBlaze/OctoPrint.git","ssh_url":"git@github.com:BillyBlaze/OctoPrint.git","clone_url":"https://github.com/BillyBlaze/OctoPrint.git","svn_url":"https://github.com/BillyBlaze/OctoPrint","homepage":"http://octoprint.org","size":34421,"stargazers_count":0,"watchers_count":0,"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":0,"default_branch":"master"}},"base":{"label":"foosel:devel","ref":"devel","sha":"cb687f01f71ec64a3435b07dccb0547cc8691fc8","user":{"login":"foosel","id":83657,"avatar_url":"https://avatars.githubusercontent.com/u/83657?v=3","gravatar_id":"","url":"https://api.github.com/users/foosel","html_url":"https://github.com/foosel","followers_url":"https://api.github.com/users/foosel/followers","following_url":"https://api.github.com/users/foosel/following{/other_user}","gists_url":"https://api.github.com/users/foosel/gists{/gist_id}","starred_url":"https://api.github.com/users/foosel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/foosel/subscriptions","organizations_url":"https://api.github.com/users/foosel/orgs","repos_url":"https://api.github.com/users/foosel/repos","events_url":"https://api.github.com/users/foosel/events{/privacy}","received_events_url":"https://api.github.com/users/foosel/received_events","type":"User","site_admin":false},"repo":{"id":7386799,"name":"OctoPrint","full_name":"foosel/OctoPrint","owner":{"login":"foosel","id":83657,"avatar_url":"https://avatars.githubusercontent.com/u/83657?v=3","gravatar_id":"","url":"https://api.github.com/users/foosel","html_url":"https://github.com/foosel","followers_url":"https://api.github.com/users/foosel/followers","following_url":"https://api.github.com/users/foosel/following{/other_user}","gists_url":"https://api.github.com/users/foosel/gists{/gist_id}","starred_url":"https://api.github.com/users/foosel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/foosel/subscriptions","organizations_url":"https://api.github.com/users/foosel/orgs","repos_url":"https://api.github.com/users/foosel/repos","events_url":"https://api.github.com/users/foosel/events{/privacy}","received_events_url":"https://api.github.com/users/foosel/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/foosel/OctoPrint","description":"OctoPrint provides a snappy web interface for controlling a 3D printer (RepRap, Ultimaker, ...).","fork":false,"url":"https://api.github.com/repos/foosel/OctoPrint","forks_url":"https://api.github.com/repos/foosel/OctoPrint/forks","keys_url":"https://api.github.com/repos/foosel/OctoPrint/keys{/key_id}","collaborators_url":"https://api.github.com/repos/foosel/OctoPrint/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/foosel/OctoPrint/teams","hooks_url":"https://api.github.com/repos/foosel/OctoPrint/hooks","issue_events_url":"https://api.github.com/repos/foosel/OctoPrint/issues/events{/number}","events_url":"https://api.github.com/repos/foosel/OctoPrint/events","assignees_url":"https://api.github.com/repos/foosel/OctoPrint/assignees{/user}","branches_url":"https://api.github.com/repos/foosel/OctoPrint/branches{/branch}","tags_url":"https://api.github.com/repos/foosel/OctoPrint/tags","blobs_url":"https://api.github.com/repos/foosel/OctoPrint/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/foosel/OctoPrint/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/foosel/OctoPrint/git/refs{/sha}","trees_url":"https://api.github.com/repos/foosel/OctoPrint/git/trees{/sha}","statuses_url":"https://api.github.com/repos/foosel/OctoPrint/statuses/{sha}","languages_url":"https://api.github.com/repos/foosel/OctoPrint/languages","stargazers_url":"https://api.github.com/repos/foosel/OctoPrint/stargazers","contributors_url":"https://api.github.com/repos/foosel/OctoPrint/contributors","subscribers_url":"https://api.github.com/repos/foosel/OctoPrint/subscribers","subscription_url":"https://api.github.com/repos/foosel/OctoPrint/subscription","commits_url":"https://api.github.com/repos/foosel/OctoPrint/commits{/sha}","git_commits_url":"https://api.github.com/repos/foosel/OctoPrint/git/commits{/sha}","comments_url":"https://api.github.com/repos/foosel/OctoPrint/comments{/number}","issue_comment_url":"https://api.github.com/repos/foosel/OctoPrint/issues/comments{/number}","contents_url":"https://api.github.com/repos/foosel/OctoPrint/contents/{+path}","compare_url":"https://api.github.com/repos/foosel/OctoPrint/compare/{base}...{head}","merges_url":"https://api.github.com/repos/foosel/OctoPrint/merges","archive_url":"https://api.github.com/repos/foosel/OctoPrint/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/foosel/OctoPrint/downloads","issues_url":"https://api.github.com/repos/foosel/OctoPrint/issues{/number}","pulls_url":"https://api.github.com/repos/foosel/OctoPrint/pulls{/number}","milestones_url":"https://api.github.com/repos/foosel/OctoPrint/milestones{/number}","notifications_url":"https://api.github.com/repos/foosel/OctoPrint/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/foosel/OctoPrint/labels{/name}","releases_url":"https://api.github.com/repos/foosel/OctoPrint/releases{/id}","deployments_url":"https://api.github.com/repos/foosel/OctoPrint/deployments","created_at":"2012-12-31T12:20:57Z","updated_at":"2016-03-03T09:18:06Z","pushed_at":"2016-03-04T12:09:04Z","git_url":"git://github.com/foosel/OctoPrint.git","ssh_url":"git@github.com:foosel/OctoPrint.git","clone_url":"https://github.com/foosel/OctoPrint.git","svn_url":"https://github.com/foosel/OctoPrint","homepage":"http://octoprint.org","size":42100,"stargazers_count":1212,"watchers_count":1212,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":540,"mirror_url":null,"open_issues_count":175,"forks":540,"open_issues":175,"watchers":1212,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/foosel/OctoPrint/pulls/1232"},"html":{"href":"https://github.com/foosel/OctoPrint/pull/1232"},"issue":{"href":"https://api.github.com/repos/foosel/OctoPrint/issues/1232"},"comments":{"href":"https://api.github.com/repos/foosel/OctoPrint/issues/1232/comments"},"review_comments":{"href":"https://api.github.com/repos/foosel/OctoPrint/pulls/1232/comments"},"review_comment":{"href":"https://api.github.com/repos/foosel/OctoPrint/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/foosel/OctoPrint/pulls/1232/commits"},"statuses":{"href":"https://api.github.com/repos/foosel/OctoPrint/statuses/0827ae10f206910b4fd82a5d987790f2fe784ae5"}}}}