{"action":"created","comment":{"url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/pulls/comments/128564872","pull_request_review_id":51257360,"id":128564872,"diff_hunk":"@@ -1,118 +1,176 @@\n-let jsonEditor = require('jsoneditor'),\n-theme = require('../themes/tomorrow_night_bright'),\n-$ = require('jquery');\n-\n+const JsonEditor = require('jsoneditor');\n+const $ = require('jquery');\n+const Ajv = require('ajv');\n+const metaSchema = require('ajv/lib/refs/json-schema-draft-04.json');\n+\n+require('../themes/tomorrow_night_bright');\n+\n+/**\n+ * Represents an instance of the Advanced Editor.\n+ * @typedef {Object} AdvancedJSONEditor\n+ * @class AdvancedJSONEditor\n+ */\n class AdvancedJSONEditor {\n-\n-  \tconstructor({target, schema, data, helpText, validate, onChange, jsonErrorMessage}) {\n-  \t\t// set constant for advanced mode element id, to be uses all through.\n-  \t\tthis.advanced_el_id = \"advanced_editor\";\n-\n-  \t\t// create advanced mode element with jQuery and insert into the DOM\n-    \tthis.element = $(`\n-    \t\t<div class=\"advanced_editor_container full-screen\">\n-    \t\t\t<div id='${this.advanced_el_id}' class=\"advanced-mode\"></div>\n-    \t\t</div>`);\n-\t    this.element.insertBefore($(target));\n-\n-\t    // set message to be used to alertwrong json\n-\t    this.setJsonErrorMessage(jsonErrorMessage);\n-\t    // disable validation if not required\n-\t    this.validate = validate;\n-\t    schema = validate? schema: {};\n-\t    // build options for advanced mode\n-\t    let options = {\n-\t        mode:'code',\n-\t        theme: 'ace/theme/tomorrow_night_bright',\n-\t        indentation: 4,\n-\t        onEditable: (node) => {\n-\t            return true;\n-\t        },\n-\t        onChange: () => {\n-\t           $(target).val(this.editor.getText());\n-\t           onChange();\n-\t        },\n-\t        schema: schema\n-\t    }\n-\t    this.render({helpText, options, data});\n-  \t}\n-\n-  \trender({helpText, options, data}){\n-\t    \n-\t    this.editor = new jsonEditor(document.getElementById(this.advanced_el_id), options, data);\n-\t    this.editor.aceEditor.setOptions({\n-\t        fontSize: 14,\n-\t        showInvisibles: true\n-\t    });\n-\t\t// remove powered by ace link\n-\t    this.element.find('.jsoneditor-menu a').remove();\n-\n-\t    let that = this;\n-\n-\t    // add controls to the editor header\n-\t    this.element.find('.jsoneditor-menu')\n-\t        .append($(`<a href=\"javascript:;\" class=\"jsoneditor-exit\">\n-\t\t        \t\t\t<img class=\"icon\" src=\"../assets/img/icon-deletelink.svg\" />\n-\t\t        \t\t\tback to normal mode\n-\t\t        \t\t</a>`\n-\t\t        \t).click((e) => {\n-\t\t        \t\tthat.closeEditor();\n-\t\t        \t}))\n-\t        .append(`\n-\t        \t<label id=\"netjsonconfig-hint\">\n-\t\t\t\t   ${helpText}\n-\t\t\t\t</label>\n-\t        \t`);\n-        $('body').addClass('editor-full');\n-\n-        $(window).resize(function(){\n-            this.element.height($(window).height()).width(window.outerWidth);\n-        });\n-\n-\t    this.show();\n-  \t}\n-\n-  \tshow(){\n-  \t\tthis.element.show();\n-  \t}\n-\n-  \thide(){\n-  \t\tthis.element.hide();\n-  \t}\n-\n-  \tchangeSchema(schema){\n-\t\tthis.editor.setSchema(schema);\n-\t}\n-\n-\tsetJson(json){\n-\t\tthis.editor.set(json);\n-\t}\n-\n-\tget schemaValid(){\n-\t\treturn this.editor.validateSchema();\n-\t}\n-\n-\tcloseEditor(){\n-\t\tif(this.validate && this.schemaValid){\n-\t\t\tthis.hide();\n-\t\t}else{\n-\t\t\tthis.alertInvalidJSON();\n-\t\t}\n-\n-\t}\n-\t/*\n-\t* Send an aler to indicate json entered is either invalid or does not match the schema\n-\t*/\n-\talertInvalidJSON(){\n-\t\talert(this.jsonErrorMessage);\n-\t}\n-\n-\t/*\n-\t* set invalid json error message\n-\t*/\n-\tsetJsonErrorMessage(jsonErrorMessage){\n-\t\tthis.jsonErrorMessage = jsonErrorMessage;\n-\t}\n-};\n+  /**\n+   * Represents an instance of the Advanced Editor.\n+   * @constructor\n+   * @param {object} props - propts containing the configs for the editor\n+   */\n+  constructor({target, schema, data, helpText, validate,\n+            onChange, jsonErrorMessage, swapOut}) {\n+    this.swapOut = swapOut;\n+        // set message to be used to alertwrong json\n+    this.setJsonErrorMessage(jsonErrorMessage);\n+        // disable validation if not required\n+    this.validate = validate;\n+\n+    schema = validate ? schema : {};\n+        // build options for advanced mode","path":"src/js/advanced/index.js","position":143,"original_position":143,"commit_id":"d2e5bd4d91836e217a8f98d02c43ab4f408cdea2","original_commit_id":"d2e5bd4d91836e217a8f98d02c43ab4f408cdea2","user":{"login":"nemesisdesign","id":841044,"avatar_url":"https://avatars3.githubusercontent.com/u/841044?v=4","gravatar_id":"","url":"https://api.github.com/users/nemesisdesign","html_url":"https://github.com/nemesisdesign","followers_url":"https://api.github.com/users/nemesisdesign/followers","following_url":"https://api.github.com/users/nemesisdesign/following{/other_user}","gists_url":"https://api.github.com/users/nemesisdesign/gists{/gist_id}","starred_url":"https://api.github.com/users/nemesisdesign/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nemesisdesign/subscriptions","organizations_url":"https://api.github.com/users/nemesisdesign/orgs","repos_url":"https://api.github.com/users/nemesisdesign/repos","events_url":"https://api.github.com/users/nemesisdesign/events{/privacy}","received_events_url":"https://api.github.com/users/nemesisdesign/received_events","type":"User","site_admin":false},"body":"this line?","created_at":"2017-07-20T16:26:51Z","updated_at":"2017-07-20T16:31:27Z","html_url":"https://github.com/openwisp/netjsonconfig-editor.js/pull/11#discussion_r128564872","pull_request_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/pulls/11","_links":{"self":{"href":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/pulls/comments/128564872"},"html":{"href":"https://github.com/openwisp/netjsonconfig-editor.js/pull/11#discussion_r128564872"},"pull_request":{"href":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/pulls/11"}}},"pull_request":{"url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/pulls/11","id":130625775,"html_url":"https://github.com/openwisp/netjsonconfig-editor.js/pull/11","diff_url":"https://github.com/openwisp/netjsonconfig-editor.js/pull/11.diff","patch_url":"https://github.com/openwisp/netjsonconfig-editor.js/pull/11.patch","issue_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/issues/11","number":11,"state":"open","locked":false,"title":"[Basic Editor] -  fully integrated the basic editor ","user":{"login":"gastonche","id":11961056,"avatar_url":"https://avatars2.githubusercontent.com/u/11961056?v=4","gravatar_id":"","url":"https://api.github.com/users/gastonche","html_url":"https://github.com/gastonche","followers_url":"https://api.github.com/users/gastonche/followers","following_url":"https://api.github.com/users/gastonche/following{/other_user}","gists_url":"https://api.github.com/users/gastonche/gists{/gist_id}","starred_url":"https://api.github.com/users/gastonche/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gastonche/subscriptions","organizations_url":"https://api.github.com/users/gastonche/orgs","repos_url":"https://api.github.com/users/gastonche/repos","events_url":"https://api.github.com/users/gastonche/events{/privacy}","received_events_url":"https://api.github.com/users/gastonche/received_events","type":"User","site_admin":false},"body":"I have successfully integrated the  basic UI editor (first part of #5 ) for the library and also done the following:\r\n\r\n- [X] changed the whole build process to use webpack instead of browserfy\r\n\r\n- [X] succeeded to make the library a js only library, such that the user only needs to include the js file and it generates the css\r\n\r\n- [X] corrected the travis build to enable linting before install and tests after builds effectively:  fixing issue #7 \r\n\r\n- [X] Enabled json-schema changing with a changeSchema method for developers #3 \r\n\r\n- [X] added more tests for advanced module and corrected failing tests","created_at":"2017-07-14T16:28:06Z","updated_at":"2017-07-20T16:31:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"242975456b6c7845080eb101b8bc2995677667f2","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/pulls/11/commits","review_comments_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/pulls/11/comments","review_comment_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/issues/11/comments","statuses_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/statuses/d2e5bd4d91836e217a8f98d02c43ab4f408cdea2","head":{"label":"openwisp:basic","ref":"basic","sha":"d2e5bd4d91836e217a8f98d02c43ab4f408cdea2","user":{"login":"openwisp","id":1150243,"avatar_url":"https://avatars1.githubusercontent.com/u/1150243?v=4","gravatar_id":"","url":"https://api.github.com/users/openwisp","html_url":"https://github.com/openwisp","followers_url":"https://api.github.com/users/openwisp/followers","following_url":"https://api.github.com/users/openwisp/following{/other_user}","gists_url":"https://api.github.com/users/openwisp/gists{/gist_id}","starred_url":"https://api.github.com/users/openwisp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openwisp/subscriptions","organizations_url":"https://api.github.com/users/openwisp/orgs","repos_url":"https://api.github.com/users/openwisp/repos","events_url":"https://api.github.com/users/openwisp/events{/privacy}","received_events_url":"https://api.github.com/users/openwisp/received_events","type":"Organization","site_admin":false},"repo":{"id":92436654,"name":"netjsonconfig-editor.js","full_name":"openwisp/netjsonconfig-editor.js","owner":{"login":"openwisp","id":1150243,"avatar_url":"https://avatars1.githubusercontent.com/u/1150243?v=4","gravatar_id":"","url":"https://api.github.com/users/openwisp","html_url":"https://github.com/openwisp","followers_url":"https://api.github.com/users/openwisp/followers","following_url":"https://api.github.com/users/openwisp/following{/other_user}","gists_url":"https://api.github.com/users/openwisp/gists{/gist_id}","starred_url":"https://api.github.com/users/openwisp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openwisp/subscriptions","organizations_url":"https://api.github.com/users/openwisp/orgs","repos_url":"https://api.github.com/users/openwisp/repos","events_url":"https://api.github.com/users/openwisp/events{/privacy}","received_events_url":"https://api.github.com/users/openwisp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openwisp/netjsonconfig-editor.js","description":"[GSOC 2017] Work in progress","fork":false,"url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js","forks_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/forks","keys_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/teams","hooks_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/hooks","issue_events_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/issues/events{/number}","events_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/events","assignees_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/assignees{/user}","branches_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/branches{/branch}","tags_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/tags","blobs_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/statuses/{sha}","languages_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/languages","stargazers_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/stargazers","contributors_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/contributors","subscribers_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/subscribers","subscription_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/subscription","commits_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/issues/comments{/number}","contents_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/contents/{+path}","compare_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/merges","archive_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/downloads","issues_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/issues{/number}","pulls_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/pulls{/number}","milestones_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/milestones{/number}","notifications_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/labels{/name}","releases_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/releases{/id}","deployments_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/deployments","created_at":"2017-05-25T19:21:15Z","updated_at":"2017-07-05T09:23:25Z","pushed_at":"2017-07-20T16:09:10Z","git_url":"git://github.com/openwisp/netjsonconfig-editor.js.git","ssh_url":"git@github.com:openwisp/netjsonconfig-editor.js.git","clone_url":"https://github.com/openwisp/netjsonconfig-editor.js.git","svn_url":"https://github.com/openwisp/netjsonconfig-editor.js","homepage":"","size":2564,"stargazers_count":2,"watchers_count":2,"language":"CSS","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":8,"forks":0,"open_issues":8,"watchers":2,"default_branch":"master"}},"base":{"label":"openwisp:master","ref":"master","sha":"d642eca7289542ca1483d2d51523b8fa0294bdcc","user":{"login":"openwisp","id":1150243,"avatar_url":"https://avatars1.githubusercontent.com/u/1150243?v=4","gravatar_id":"","url":"https://api.github.com/users/openwisp","html_url":"https://github.com/openwisp","followers_url":"https://api.github.com/users/openwisp/followers","following_url":"https://api.github.com/users/openwisp/following{/other_user}","gists_url":"https://api.github.com/users/openwisp/gists{/gist_id}","starred_url":"https://api.github.com/users/openwisp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openwisp/subscriptions","organizations_url":"https://api.github.com/users/openwisp/orgs","repos_url":"https://api.github.com/users/openwisp/repos","events_url":"https://api.github.com/users/openwisp/events{/privacy}","received_events_url":"https://api.github.com/users/openwisp/received_events","type":"Organization","site_admin":false},"repo":{"id":92436654,"name":"netjsonconfig-editor.js","full_name":"openwisp/netjsonconfig-editor.js","owner":{"login":"openwisp","id":1150243,"avatar_url":"https://avatars1.githubusercontent.com/u/1150243?v=4","gravatar_id":"","url":"https://api.github.com/users/openwisp","html_url":"https://github.com/openwisp","followers_url":"https://api.github.com/users/openwisp/followers","following_url":"https://api.github.com/users/openwisp/following{/other_user}","gists_url":"https://api.github.com/users/openwisp/gists{/gist_id}","starred_url":"https://api.github.com/users/openwisp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openwisp/subscriptions","organizations_url":"https://api.github.com/users/openwisp/orgs","repos_url":"https://api.github.com/users/openwisp/repos","events_url":"https://api.github.com/users/openwisp/events{/privacy}","received_events_url":"https://api.github.com/users/openwisp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openwisp/netjsonconfig-editor.js","description":"[GSOC 2017] Work in progress","fork":false,"url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js","forks_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/forks","keys_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/teams","hooks_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/hooks","issue_events_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/issues/events{/number}","events_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/events","assignees_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/assignees{/user}","branches_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/branches{/branch}","tags_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/tags","blobs_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/statuses/{sha}","languages_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/languages","stargazers_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/stargazers","contributors_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/contributors","subscribers_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/subscribers","subscription_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/subscription","commits_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/issues/comments{/number}","contents_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/contents/{+path}","compare_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/merges","archive_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/downloads","issues_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/issues{/number}","pulls_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/pulls{/number}","milestones_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/milestones{/number}","notifications_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/labels{/name}","releases_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/releases{/id}","deployments_url":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/deployments","created_at":"2017-05-25T19:21:15Z","updated_at":"2017-07-05T09:23:25Z","pushed_at":"2017-07-20T16:09:10Z","git_url":"git://github.com/openwisp/netjsonconfig-editor.js.git","ssh_url":"git@github.com:openwisp/netjsonconfig-editor.js.git","clone_url":"https://github.com/openwisp/netjsonconfig-editor.js.git","svn_url":"https://github.com/openwisp/netjsonconfig-editor.js","homepage":"","size":2564,"stargazers_count":2,"watchers_count":2,"language":"CSS","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":8,"forks":0,"open_issues":8,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/pulls/11"},"html":{"href":"https://github.com/openwisp/netjsonconfig-editor.js/pull/11"},"issue":{"href":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/issues/11"},"comments":{"href":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/issues/11/comments"},"review_comments":{"href":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/pulls/11/comments"},"review_comment":{"href":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/pulls/11/commits"},"statuses":{"href":"https://api.github.com/repos/openwisp/netjsonconfig-editor.js/statuses/d2e5bd4d91836e217a8f98d02c43ab4f408cdea2"}}}}
{"actor":{"display_login":"nemesisdesign"}}