1/* 2* @Author: Alban Gaignard 3* @Date: 2020-03-01 15:55:48 4* @Last Modified by: Alban Gaignard 5* @Last Modified time: 2020-03-02 13:04:39 6*/ 7(function ($) { 8// var node_id = "1432" 9 //var node_id = "50"; 10 //var node_url = "http://test.biii.eu/node/" + node_id; 11 //var node_url = "http://biii.eu/node/" + node_id; 12//var node_url_json = node_url + "?_format=json " 13 14 var nodes = new Set(); 15 var edges = []; 16 17 var cyjs_nodes = []; 18 var cyjs_edges = []; 19 20 var get_node_id = function () { 21 var url = $("[rel='shortlink']").attr('href'); 22 var id = url.substring(url.lastIndexOf("/") + 1, url.length); 23 return id; 24 }; 25// 26// 27// 28 var node2cy = function (x) { 29 // console.log({data: {id: x} }) 30 return {data: {id: x, name: x}} 31 }; 32 33// 34// 35// 36 var edge2cy = function (x) { 37 // console.log({data: {source: x.source, target: x.target} }) 38 return {data: {source: x.source, target: x.target}} 39 }; 40 41 var updateWorkflowVis = function () { 42 43 // $.getJSON('http://test.biii.eu/wfsteps?_format=json', function(data) { 44 $.getJSON('//biii.eu/wfsteps?_format=json', function (data) { 45 46 // $.getJSON(json_node_url + "?_format=json ", function(data) { 47 //console.log(data); 48 49 $.each(data, function (key, value) { 50 51 //console.log( key + ": " + value["parent_id"] ); 52 if (value["parent_id"] == get_node_id()) { 53 54 nodes.add(value["field_current_workflow_step__1"]); 55 if (value["field_previous_workflow_step"].includes(", ")) { 56 57 $.each(value["field_previous_workflow_step"].split(", "), function (key, sub_value) { 58 nodes.add(sub_value); 59 edges.push({ 60 source: sub_value, 61 target: value["field_current_workflow_step__1"] 62 }) 63 }) 64 } 65 else { 66 67 nodes.add(value["field_previous_workflow_step"]); 68 edges.push({ 69 source: value["field_previous_workflow_step"], 70 target: value["field_current_workflow_step__1"] 71 }) 72 } 73 74 //console.log( value["field_current_workflow_step__1"] ); 75 //console.log( value["field_previous_workflow_step"] ); 76 } 77 }); 78 79 //console.log(nodes); 80 //console.log(edges); 81 82 cyjs_nodes = [...nodes].filter(x => x != "").map(node2cy); 83 cyjs_edges = [...edges].filter(x => x.source != "" && x.target != "").map(edge2cy); 84 85 var cy = window.cy = cytoscape({ 86 container: document.getElementById('WF_vis'), 87 88 boxSelectionEnabled: false, 89 autounselectify: true, 90 91 layout: { 92 name: 'dagre' 93 }, 94 95 style: [ 96 { 97 selector: 'node', 98 style: { 99 'border-color': '#11479e', 100 'border-width': '2px', 101 'background-color': 'white', 102 'content': 'data(name)', 103 'shape': 'roundrectangle', 104 'text-valign': 'center', 105 'text-halign': 'center', 106 'text-wrap': 'wrap', 107 'text-max-width': '130px', 108 'width': '150px', 109 'height': 'label', 110 'padding-left': '5px', 111 'padding-right': '5px', 112 'padding-top': '10px', 113 'padding-bottom': '10px', 114 } 115 }, 116 117 { 118 selector: 'edge', 119 style: { 120 'width': 4, 121 'target-arrow-shape': 'triangle', 122 'line-color': '#9dbaea', 123 'target-arrow-color': '#9dbaea', 124 'curve-style': 'bezier' 125 } 126 } 127 ], 128 129 elements: { 130 nodes: cyjs_nodes, 131 edges: cyjs_edges 132 } 133 }); 134 135 // cy.nodeHtmlLabel([ { 136 // query: 'node', // cytoscape query selector 137 // halign: 'center', // title vertical position. Can be 138 // 'left',''center, 'right' valign: 'center', // title vertical position. 139 // Can be 'top',''center, 'bottom' halignBox: 'center', // title vertical 140 // position. Can be 'left',''center, 'right' valignBox: 'center', // 141 // title relative box vertical position. Can be 'top',''center, 'bottom' 142 // cssClass: '', // any classes will be as attribute of <div> container 143 // for every title tpl(data) { return '<a href="node_url">' + data.name + 144 // '</a>'; // your html template here } } ]); 145 146 }); 147 }; 148 149 updateWorkflowVis(); 150})(jQuery); 151// console.log('NODES') 152// console.log(cyjs_nodes) 153// console.log('----') 154// console.log('EDGES') 155// console.log(cyjs_edges) 156// console.log('----') 157
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.