{"action":"created","issue":{"url":"https://api.github.com/repos/mixxxdj/mixxx/issues/1556","repository_url":"https://api.github.com/repos/mixxxdj/mixxx","labels_url":"https://api.github.com/repos/mixxxdj/mixxx/issues/1556/labels{/name}","comments_url":"https://api.github.com/repos/mixxxdj/mixxx/issues/1556/comments","events_url":"https://api.github.com/repos/mixxxdj/mixxx/issues/1556/events","html_url":"https://github.com/mixxxdj/mixxx/pull/1556","id":308191335,"node_id":"MDExOlB1bGxSZXF1ZXN0MTc3MTkzNzkw","number":1556,"title":"Controller script js import","user":{"login":"ferranpujolcamins","id":6429775,"node_id":"MDQ6VXNlcjY0Mjk3NzU=","avatar_url":"https://avatars1.githubusercontent.com/u/6429775?v=4","gravatar_id":"","url":"https://api.github.com/users/ferranpujolcamins","html_url":"https://github.com/ferranpujolcamins","followers_url":"https://api.github.com/users/ferranpujolcamins/followers","following_url":"https://api.github.com/users/ferranpujolcamins/following{/other_user}","gists_url":"https://api.github.com/users/ferranpujolcamins/gists{/gist_id}","starred_url":"https://api.github.com/users/ferranpujolcamins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ferranpujolcamins/subscriptions","organizations_url":"https://api.github.com/users/ferranpujolcamins/orgs","repos_url":"https://api.github.com/users/ferranpujolcamins/repos","events_url":"https://api.github.com/users/ferranpujolcamins/events{/privacy}","received_events_url":"https://api.github.com/users/ferranpujolcamins/received_events","type":"User","site_admin":false},"labels":[{"id":518040308,"node_id":"MDU6TGFiZWw1MTgwNDAzMDg=","url":"https://api.github.com/repos/mixxxdj/mixxx/labels/controllers","name":"controllers","color":"009b95","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/mixxxdj/mixxx/milestones/3","html_url":"https://github.com/mixxxdj/mixxx/milestone/3","labels_url":"https://api.github.com/repos/mixxxdj/mixxx/milestones/3/labels","id":2936538,"node_id":"MDk6TWlsZXN0b25lMjkzNjUzOA==","number":3,"title":"2.2.0","description":"","creator":{"login":"uklotzde","id":1474154,"node_id":"MDQ6VXNlcjE0NzQxNTQ=","avatar_url":"https://avatars1.githubusercontent.com/u/1474154?v=4","gravatar_id":"","url":"https://api.github.com/users/uklotzde","html_url":"https://github.com/uklotzde","followers_url":"https://api.github.com/users/uklotzde/followers","following_url":"https://api.github.com/users/uklotzde/following{/other_user}","gists_url":"https://api.github.com/users/uklotzde/gists{/gist_id}","starred_url":"https://api.github.com/users/uklotzde/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uklotzde/subscriptions","organizations_url":"https://api.github.com/users/uklotzde/orgs","repos_url":"https://api.github.com/users/uklotzde/repos","events_url":"https://api.github.com/users/uklotzde/events{/privacy}","received_events_url":"https://api.github.com/users/uklotzde/received_events","type":"User","site_admin":false},"open_issues":28,"closed_issues":20,"state":"open","created_at":"2017-11-25T09:20:16Z","updated_at":"2018-06-07T18:22:51Z","due_on":"2018-09-30T07:00:00Z","closed_at":null},"comments":2,"created_at":"2018-03-23T22:01:56Z","updated_at":"2018-06-12T02:21:07Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/mixxxdj/mixxx/pulls/1556","html_url":"https://github.com/mixxxdj/mixxx/pull/1556","diff_url":"https://github.com/mixxxdj/mixxx/pull/1556.diff","patch_url":"https://github.com/mixxxdj/mixxx/pull/1556.patch"},"body":"This PR adds a new include function for JS controller scripts. It allows JS scripts to include other js files. This new function can work with the current way to include scripts by specifying them in the xml.\r\n\r\nThe include function takes a filename as only parameter and then loads and evaluates the content of that file:\r\n`include(\"commonFunctions.js\");`\r\n\r\nThe filename can be specified with an absolute path or a relative path. The relative path is taken relative to the importing file. The path syntax is the one specified for Qt (unix style).\r\n`include(\"../scripts/commonFunctions.js\");`\r\n`include(\"/home/ferran/mixxx_scripts/commonFunctions.js\");`\r\n\r\nFiles are only included once, so it's safe to include the same file from several sources. It is also safe to include a file that has been already included in the xml.\r\n\r\nIf a call to include is removed from a file while mixxx is running, mixxx reloads the including file live and the included file content is no longer available.\r\n\r\nJS snippets in the xml files can't include script files. Only JS loaded from a script file can include other files. (there is no unit test for this because ControllerEngine resets itself when a script file is updated, this makes the test difficult to implement. It has been manually tested in linux though).\r\n\r\nYou can see some simple examples in the unit tests.\r\n\r\n**Why this new way of including controller scripts?**\r\n\r\nIt's now easier to maintain complex mappings:\r\n- Script files can now be organized in folders and subfolders.\r\n- Now script files are included live: no need to re-apply the xml mapping to a controller to include/uninclude a new script file.\r\n- Only the main script file needs to be specified in the xml file: set and forget.\r\n\r\nEasy to share scripts:\r\n- Ben creates a complex controller script library that is written in several files. Mary downloads Ben's library. Before PR, Mary needed to manually specify every file of the library in her xml file. Now, she only needs to include the main file of Ben's library in her script file. The rest of the includes are handled by the library itself.\r\n\r\nKazakore recently [shared in the forums](https://www.mixxx.org/forums/viewtopic.php?f=7&t=11677&p=37502) a massive xml file with all the possible midi messages a controller can send. With that xml and this PR, a developer can now forget about the xml during script development, which greatly decreases the development time.\r\n\r\n**TODO:**\r\n- [ ] If a file specified with relative path is not found, search it relative to res/controllers/\r\n- [ ] Document in wiki"},"comment":{"url":"https://api.github.com/repos/mixxxdj/mixxx/issues/comments/396444550","html_url":"https://github.com/mixxxdj/mixxx/pull/1556#issuecomment-396444550","issue_url":"https://api.github.com/repos/mixxxdj/mixxx/issues/1556","id":396444550,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NjQ0NDU1MA==","user":{"login":"Be-ing","id":9455094,"node_id":"MDQ6VXNlcjk0NTUwOTQ=","avatar_url":"https://avatars3.githubusercontent.com/u/9455094?v=4","gravatar_id":"","url":"https://api.github.com/users/Be-ing","html_url":"https://github.com/Be-ing","followers_url":"https://api.github.com/users/Be-ing/followers","following_url":"https://api.github.com/users/Be-ing/following{/other_user}","gists_url":"https://api.github.com/users/Be-ing/gists{/gist_id}","starred_url":"https://api.github.com/users/Be-ing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Be-ing/subscriptions","organizations_url":"https://api.github.com/users/Be-ing/orgs","repos_url":"https://api.github.com/users/Be-ing/repos","events_url":"https://api.github.com/users/Be-ing/events{/privacy}","received_events_url":"https://api.github.com/users/Be-ing/received_events","type":"User","site_admin":false},"created_at":"2018-06-12T02:21:07Z","updated_at":"2018-06-12T02:21:07Z","author_association":"CONTRIBUTOR","body":"I think this will be obsoleted by [implementation of the feature upstream in Qt](https://bugreports.qt.io/browse/QTBUG-22356)."}}
{"actor":{"display_login":"Be-ing"}}