{"action":"created","comment":{"url":"https://api.github.com/repos/shardulc/apertium-html-tools/pulls/comments/100702140","pull_request_review_id":21415676,"id":100702140,"diff_hunk":"@@ -289,8 +296,302 @@ if(modeEnabled('translation')) {\n             }\n             return false;\n         });\n+\n+        initChainGraph();\n+    });\n+}\n+\n+function initChainGraph() {\n+    var choose = d3.select('#chooseModalBody');\n+    svg = choose\n+        .append('svg')\n+        .attr('width', '800px')\n+        .attr('height', '550px');\n+    var rect = d3.select('svg').node().getBoundingClientRect();\n+    width = 800;\n+    height = 550;\n+    nodeSize = 20;\n+    choose.append('br');\n+    choose.append('b').text('Valid Paths:');\n+    choose.append('div').attr('id', 'validPaths');\n+\n+    svg.append('svg:defs').append('svg:marker')\n+        .attr('id', 'end-arrow')\n+        .attr('viewBox', '0 -5 10 10')\n+        .attr('refX', 6)\n+        .attr('markerWidth', 3)\n+        .attr('markerHeight', 3)\n+        .attr('orient', 'auto')\n+      .append('svg:path')\n+        .attr('d', 'M0,-5L10,0L0,5')\n+        .attr('fill', '#999');\n+\n+    svg.append('svg:defs').append('svg:marker')\n+        .attr('id', 'start-arrow')\n+        .attr('viewBox', '0 -5 10 10')\n+        .attr('refX', 4)\n+        .attr('markerWidth', 3)\n+        .attr('markerHeight', 3)\n+        .attr('orient', 'auto')\n+      .append('svg:path')\n+        .attr('d', 'M10,-5L0,0L10,5')\n+        .attr('fill', '#999');\n+\n+    simulation = d3.forceSimulation()\n+        .force('link', d3.forceLink().id(function (d) { return d.id; }).distance(nodeSize * 10))\n+        .force('charge', d3.forceManyBody().strength(-700))\n+        .force('center', d3.forceCenter(width / 2, height / 2))\n+        .alphaDecay(0.018);\n+\n+    refreshChainGraph();\n+}\n+\n+function boundary(dist, max) {\n+    if (dist < nodeSize) return nodeSize;\n+    if (dist < max - nodeSize) return dist;\n+    return max - nodeSize;\n+}\n+\n+function clone(obj) {\n+    if (null == obj || 'object' != typeof obj) return obj;\n+    var copy = obj.constructor();\n+    for (var attr in obj) {\n+        if (obj.hasOwnProperty(attr)) copy[attr] = clone(obj[attr]);\n+    }\n+    return copy;\n+}\n+\n+function paths(src, trgt, curPath, seens) {\n+    if (!originalPairs[src]) return [];\n+    var rets = [];\n+    for (var i = 0; i < originalPairs[src].length; i++) {\n+        var lang = originalPairs[src][i];\n+        var newPath = curPath.slice();\n+        newPath.push(lang);\n+        var oldSeens = clone(seens);\n+        if (lang == trgt) rets.push(newPath);\n+        else if (!(lang in seens)) {\n+            seens[lang] = [];\n+            var recurse = paths(lang, trgt, newPath, seens);\n+            for (var j = 0; j < recurse.length; j++) {\n+                rets.push(recurse[j]);\n+                seens[lang].push(recurse[j].slice(recurse[j].indexOf(lang)));\n+            }\n+        }\n+        else {\n+            for (var j = 0; j < seens[lang].length; j++) {\n+                rets.push(newPath.concat(seens[lang][j]));\n+            }\n+        }\n+        seens = oldSeens;\n+    }\n+    return rets;\n+}\n+\n+function displayPaths(paths) {\n+    var graph = {};\n+    var nodes = [];\n+    var ids = [];\n+    var source = paths[0][0];\n+    var target = paths[0][paths[0].length - 1];\n+    for (var i = 0; i < paths.length; i++) {\n+        for (var j = 0; j < paths[i].length; j++) {\n+            var lang = paths[i][j];\n+            if (ids.indexOf(lang) == -1) {\n+                if (lang == source) nodes.push({'id': lang, 'fx': 3 * width / 10, 'fy': 350});\n+                else if (lang == target) nodes.push({'id': lang, 'fx': 7 * width / 10, 'fy': 350});\n+                else nodes.push({'id': lang});\n+                ids.push(lang);\n+            }\n+        }\n+    }\n+\n+    function backForth(src, trgt) {\n+        return (((src in originalPairs) ? (originalPairs[src].indexOf(trgt) != -1) : true) && ((trgt in originalPairs) ? (originalPairs[trgt].indexOf(src) != -1) : true));\n+    }\n+\n+    graph.nodes = nodes;\n+    graph.links = rawPairs.slice();\n+    var bfs = [];\n+    var i = 0;\n+    while (i < graph.links.length) {\n+        var link = graph.links[i];\n+        var src = link['sourceLanguage'];\n+        var trgt = link['targetLanguage'];\n+        if ((ids.indexOf(src) != -1) && (ids.indexOf(trgt) != -1)) {\n+            if (backForth(src, trgt)) {\n+                if ((bfs.indexOf(src + trgt) == -1) && (bfs.indexOf(trgt + src) == -1)) {\n+                    bfs.push(src + trgt);\n+                    graph.links[i] = {'source': src, 'target': trgt, 'right': true, 'left': true};\n+                    i++;\n+                }\n+                else graph.links.splice(i, 1);\n+            }\n+            else {\n+                graph.links[i] = {'source': src, 'target': trgt, 'right': true};\n+                i++;\n+            }\n+        }\n+        else graph.links.splice(i, 1);\n+    }\n+\n+    var link = svg.append('g')\n+        .attr('class', 'links')\n+      .selectAll('path')\n+      .data(graph.links)\n+      .enter().append('path')\n+      .style('marker-start', function (d) { return d.left ? 'url(#start-arrow)' : ''; })\n+      .style('marker-end', function (d) { return d.right ? 'url(#end-arrow)' : ''; })\n+      .attr('id', function (d) { return d.source + '-' + d.target; })\n+      .classed('some_path', false)\n+      .classed('all_path', false);\n+\n+    var node = svg.append('g')\n+        .attr('class', 'nodes')\n+      .selectAll('g')\n+      .data(graph.nodes)\n+      .enter().append('g');\n+\n+    var circ = node.append('circle');\n+    circ\n+        .attr('r', nodeSize)\n+        .attr('id', function (d) { return d.id; })\n+        .classed('endpoint', function (d) { return (d.id == source || d.id == target); })\n+        .call(d3.drag()\n+            .on('start', dragStarted)\n+            .on('drag', dragged)\n+            .on('end', dragEnded))\n+        .on('click', nodeClicked)\n+        .append('title').text(function (d) { return d.id; });","path":"assets/js/translator.js","position":223,"original_position":223,"commit_id":"d3e6aa98529a9968990eb486eac91946f83c44bb","original_commit_id":"d3e6aa98529a9968990eb486eac91946f83c44bb","user":{"login":"houndci-bot","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci-bot","html_url":"https://github.com/houndci-bot","followers_url":"https://api.github.com/users/houndci-bot/followers","following_url":"https://api.github.com/users/houndci-bot/following{/other_user}","gists_url":"https://api.github.com/users/houndci-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci-bot/subscriptions","organizations_url":"https://api.github.com/users/houndci-bot/orgs","repos_url":"https://api.github.com/users/houndci-bot/repos","events_url":"https://api.github.com/users/houndci-bot/events{/privacy}","received_events_url":"https://api.github.com/users/houndci-bot/received_events","type":"User","site_admin":false},"body":"Expected line break before `.text`                    newline-per-chained-call","created_at":"2017-02-12T19:47:37Z","updated_at":"2017-02-12T19:47:37Z","html_url":"https://github.com/shardulc/apertium-html-tools/pull/1#discussion_r100702140","pull_request_url":"https://api.github.com/repos/shardulc/apertium-html-tools/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/shardulc/apertium-html-tools/pulls/comments/100702140"},"html":{"href":"https://github.com/shardulc/apertium-html-tools/pull/1#discussion_r100702140"},"pull_request":{"href":"https://api.github.com/repos/shardulc/apertium-html-tools/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/shardulc/apertium-html-tools/pulls/1","id":105773040,"html_url":"https://github.com/shardulc/apertium-html-tools/pull/1","diff_url":"https://github.com/shardulc/apertium-html-tools/pull/1.diff","patch_url":"https://github.com/shardulc/apertium-html-tools/pull/1.patch","issue_url":"https://api.github.com/repos/shardulc/apertium-html-tools/issues/1","number":1,"state":"open","locked":false,"title":"Initial code for a visual chained translation path selector.","user":{"login":"shardulc","id":10349624,"avatar_url":"https://avatars.githubusercontent.com/u/10349624?v=3","gravatar_id":"","url":"https://api.github.com/users/shardulc","html_url":"https://github.com/shardulc","followers_url":"https://api.github.com/users/shardulc/followers","following_url":"https://api.github.com/users/shardulc/following{/other_user}","gists_url":"https://api.github.com/users/shardulc/gists{/gist_id}","starred_url":"https://api.github.com/users/shardulc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shardulc/subscriptions","organizations_url":"https://api.github.com/users/shardulc/orgs","repos_url":"https://api.github.com/users/shardulc/repos","events_url":"https://api.github.com/users/shardulc/events{/privacy}","received_events_url":"https://api.github.com/users/shardulc/received_events","type":"User","site_admin":false},"body":"Adds a button which opens a modal showing the path graph. Uses D3.","created_at":"2017-02-12T00:02:23Z","updated_at":"2017-02-12T19:47:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"407a2cd5f5d0d8f5fbb0c31f6cda12e2b7756092","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/shardulc/apertium-html-tools/pulls/1/commits","review_comments_url":"https://api.github.com/repos/shardulc/apertium-html-tools/pulls/1/comments","review_comment_url":"https://api.github.com/repos/shardulc/apertium-html-tools/pulls/comments{/number}","comments_url":"https://api.github.com/repos/shardulc/apertium-html-tools/issues/1/comments","statuses_url":"https://api.github.com/repos/shardulc/apertium-html-tools/statuses/d3e6aa98529a9968990eb486eac91946f83c44bb","head":{"label":"shardulc:chain-selector","ref":"chain-selector","sha":"d3e6aa98529a9968990eb486eac91946f83c44bb","user":{"login":"shardulc","id":10349624,"avatar_url":"https://avatars.githubusercontent.com/u/10349624?v=3","gravatar_id":"","url":"https://api.github.com/users/shardulc","html_url":"https://github.com/shardulc","followers_url":"https://api.github.com/users/shardulc/followers","following_url":"https://api.github.com/users/shardulc/following{/other_user}","gists_url":"https://api.github.com/users/shardulc/gists{/gist_id}","starred_url":"https://api.github.com/users/shardulc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shardulc/subscriptions","organizations_url":"https://api.github.com/users/shardulc/orgs","repos_url":"https://api.github.com/users/shardulc/repos","events_url":"https://api.github.com/users/shardulc/events{/privacy}","received_events_url":"https://api.github.com/users/shardulc/received_events","type":"User","site_admin":false},"repo":{"id":78226301,"name":"apertium-html-tools","full_name":"shardulc/apertium-html-tools","owner":{"login":"shardulc","id":10349624,"avatar_url":"https://avatars.githubusercontent.com/u/10349624?v=3","gravatar_id":"","url":"https://api.github.com/users/shardulc","html_url":"https://github.com/shardulc","followers_url":"https://api.github.com/users/shardulc/followers","following_url":"https://api.github.com/users/shardulc/following{/other_user}","gists_url":"https://api.github.com/users/shardulc/gists{/gist_id}","starred_url":"https://api.github.com/users/shardulc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shardulc/subscriptions","organizations_url":"https://api.github.com/users/shardulc/orgs","repos_url":"https://api.github.com/users/shardulc/repos","events_url":"https://api.github.com/users/shardulc/events{/privacy}","received_events_url":"https://api.github.com/users/shardulc/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/shardulc/apertium-html-tools","description":"Apertium Html-tools is a web application providing a fully localised interface for text/document translation, analysis and generation powered by Apertium.","fork":true,"url":"https://api.github.com/repos/shardulc/apertium-html-tools","forks_url":"https://api.github.com/repos/shardulc/apertium-html-tools/forks","keys_url":"https://api.github.com/repos/shardulc/apertium-html-tools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/shardulc/apertium-html-tools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/shardulc/apertium-html-tools/teams","hooks_url":"https://api.github.com/repos/shardulc/apertium-html-tools/hooks","issue_events_url":"https://api.github.com/repos/shardulc/apertium-html-tools/issues/events{/number}","events_url":"https://api.github.com/repos/shardulc/apertium-html-tools/events","assignees_url":"https://api.github.com/repos/shardulc/apertium-html-tools/assignees{/user}","branches_url":"https://api.github.com/repos/shardulc/apertium-html-tools/branches{/branch}","tags_url":"https://api.github.com/repos/shardulc/apertium-html-tools/tags","blobs_url":"https://api.github.com/repos/shardulc/apertium-html-tools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/shardulc/apertium-html-tools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/shardulc/apertium-html-tools/git/refs{/sha}","trees_url":"https://api.github.com/repos/shardulc/apertium-html-tools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/shardulc/apertium-html-tools/statuses/{sha}","languages_url":"https://api.github.com/repos/shardulc/apertium-html-tools/languages","stargazers_url":"https://api.github.com/repos/shardulc/apertium-html-tools/stargazers","contributors_url":"https://api.github.com/repos/shardulc/apertium-html-tools/contributors","subscribers_url":"https://api.github.com/repos/shardulc/apertium-html-tools/subscribers","subscription_url":"https://api.github.com/repos/shardulc/apertium-html-tools/subscription","commits_url":"https://api.github.com/repos/shardulc/apertium-html-tools/commits{/sha}","git_commits_url":"https://api.github.com/repos/shardulc/apertium-html-tools/git/commits{/sha}","comments_url":"https://api.github.com/repos/shardulc/apertium-html-tools/comments{/number}","issue_comment_url":"https://api.github.com/repos/shardulc/apertium-html-tools/issues/comments{/number}","contents_url":"https://api.github.com/repos/shardulc/apertium-html-tools/contents/{+path}","compare_url":"https://api.github.com/repos/shardulc/apertium-html-tools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/shardulc/apertium-html-tools/merges","archive_url":"https://api.github.com/repos/shardulc/apertium-html-tools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/shardulc/apertium-html-tools/downloads","issues_url":"https://api.github.com/repos/shardulc/apertium-html-tools/issues{/number}","pulls_url":"https://api.github.com/repos/shardulc/apertium-html-tools/pulls{/number}","milestones_url":"https://api.github.com/repos/shardulc/apertium-html-tools/milestones{/number}","notifications_url":"https://api.github.com/repos/shardulc/apertium-html-tools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/shardulc/apertium-html-tools/labels{/name}","releases_url":"https://api.github.com/repos/shardulc/apertium-html-tools/releases{/id}","deployments_url":"https://api.github.com/repos/shardulc/apertium-html-tools/deployments","created_at":"2017-01-06T17:48:00Z","updated_at":"2017-01-06T17:48:03Z","pushed_at":"2017-02-12T19:47:30Z","git_url":"git://github.com/shardulc/apertium-html-tools.git","ssh_url":"git@github.com:shardulc/apertium-html-tools.git","clone_url":"https://github.com/shardulc/apertium-html-tools.git","svn_url":"https://github.com/shardulc/apertium-html-tools","homepage":"http://wiki.apertium.org/wiki/Apertium-html-tools","size":2178,"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":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"shardulc:master","ref":"master","sha":"922e71196d2d157acdbf3a9f40897d2fd8a8788d","user":{"login":"shardulc","id":10349624,"avatar_url":"https://avatars.githubusercontent.com/u/10349624?v=3","gravatar_id":"","url":"https://api.github.com/users/shardulc","html_url":"https://github.com/shardulc","followers_url":"https://api.github.com/users/shardulc/followers","following_url":"https://api.github.com/users/shardulc/following{/other_user}","gists_url":"https://api.github.com/users/shardulc/gists{/gist_id}","starred_url":"https://api.github.com/users/shardulc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shardulc/subscriptions","organizations_url":"https://api.github.com/users/shardulc/orgs","repos_url":"https://api.github.com/users/shardulc/repos","events_url":"https://api.github.com/users/shardulc/events{/privacy}","received_events_url":"https://api.github.com/users/shardulc/received_events","type":"User","site_admin":false},"repo":{"id":78226301,"name":"apertium-html-tools","full_name":"shardulc/apertium-html-tools","owner":{"login":"shardulc","id":10349624,"avatar_url":"https://avatars.githubusercontent.com/u/10349624?v=3","gravatar_id":"","url":"https://api.github.com/users/shardulc","html_url":"https://github.com/shardulc","followers_url":"https://api.github.com/users/shardulc/followers","following_url":"https://api.github.com/users/shardulc/following{/other_user}","gists_url":"https://api.github.com/users/shardulc/gists{/gist_id}","starred_url":"https://api.github.com/users/shardulc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shardulc/subscriptions","organizations_url":"https://api.github.com/users/shardulc/orgs","repos_url":"https://api.github.com/users/shardulc/repos","events_url":"https://api.github.com/users/shardulc/events{/privacy}","received_events_url":"https://api.github.com/users/shardulc/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/shardulc/apertium-html-tools","description":"Apertium Html-tools is a web application providing a fully localised interface for text/document translation, analysis and generation powered by Apertium.","fork":true,"url":"https://api.github.com/repos/shardulc/apertium-html-tools","forks_url":"https://api.github.com/repos/shardulc/apertium-html-tools/forks","keys_url":"https://api.github.com/repos/shardulc/apertium-html-tools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/shardulc/apertium-html-tools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/shardulc/apertium-html-tools/teams","hooks_url":"https://api.github.com/repos/shardulc/apertium-html-tools/hooks","issue_events_url":"https://api.github.com/repos/shardulc/apertium-html-tools/issues/events{/number}","events_url":"https://api.github.com/repos/shardulc/apertium-html-tools/events","assignees_url":"https://api.github.com/repos/shardulc/apertium-html-tools/assignees{/user}","branches_url":"https://api.github.com/repos/shardulc/apertium-html-tools/branches{/branch}","tags_url":"https://api.github.com/repos/shardulc/apertium-html-tools/tags","blobs_url":"https://api.github.com/repos/shardulc/apertium-html-tools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/shardulc/apertium-html-tools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/shardulc/apertium-html-tools/git/refs{/sha}","trees_url":"https://api.github.com/repos/shardulc/apertium-html-tools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/shardulc/apertium-html-tools/statuses/{sha}","languages_url":"https://api.github.com/repos/shardulc/apertium-html-tools/languages","stargazers_url":"https://api.github.com/repos/shardulc/apertium-html-tools/stargazers","contributors_url":"https://api.github.com/repos/shardulc/apertium-html-tools/contributors","subscribers_url":"https://api.github.com/repos/shardulc/apertium-html-tools/subscribers","subscription_url":"https://api.github.com/repos/shardulc/apertium-html-tools/subscription","commits_url":"https://api.github.com/repos/shardulc/apertium-html-tools/commits{/sha}","git_commits_url":"https://api.github.com/repos/shardulc/apertium-html-tools/git/commits{/sha}","comments_url":"https://api.github.com/repos/shardulc/apertium-html-tools/comments{/number}","issue_comment_url":"https://api.github.com/repos/shardulc/apertium-html-tools/issues/comments{/number}","contents_url":"https://api.github.com/repos/shardulc/apertium-html-tools/contents/{+path}","compare_url":"https://api.github.com/repos/shardulc/apertium-html-tools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/shardulc/apertium-html-tools/merges","archive_url":"https://api.github.com/repos/shardulc/apertium-html-tools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/shardulc/apertium-html-tools/downloads","issues_url":"https://api.github.com/repos/shardulc/apertium-html-tools/issues{/number}","pulls_url":"https://api.github.com/repos/shardulc/apertium-html-tools/pulls{/number}","milestones_url":"https://api.github.com/repos/shardulc/apertium-html-tools/milestones{/number}","notifications_url":"https://api.github.com/repos/shardulc/apertium-html-tools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/shardulc/apertium-html-tools/labels{/name}","releases_url":"https://api.github.com/repos/shardulc/apertium-html-tools/releases{/id}","deployments_url":"https://api.github.com/repos/shardulc/apertium-html-tools/deployments","created_at":"2017-01-06T17:48:00Z","updated_at":"2017-01-06T17:48:03Z","pushed_at":"2017-02-12T19:47:30Z","git_url":"git://github.com/shardulc/apertium-html-tools.git","ssh_url":"git@github.com:shardulc/apertium-html-tools.git","clone_url":"https://github.com/shardulc/apertium-html-tools.git","svn_url":"https://github.com/shardulc/apertium-html-tools","homepage":"http://wiki.apertium.org/wiki/Apertium-html-tools","size":2178,"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":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/shardulc/apertium-html-tools/pulls/1"},"html":{"href":"https://github.com/shardulc/apertium-html-tools/pull/1"},"issue":{"href":"https://api.github.com/repos/shardulc/apertium-html-tools/issues/1"},"comments":{"href":"https://api.github.com/repos/shardulc/apertium-html-tools/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/shardulc/apertium-html-tools/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/shardulc/apertium-html-tools/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/shardulc/apertium-html-tools/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/shardulc/apertium-html-tools/statuses/d3e6aa98529a9968990eb486eac91946f83c44bb"}}}}
{"actor":{"display_login":"houndci-bot"}}