@@ -8,108 +8,114 @@ var TOOL_DESCRIPTIONS = {};
88const selected = [ ] ;
99
1010// If params are null, show a default message
11- function showDetails ( data , outgoers ) {
11+ function showDetails ( data , connected ) {
1212 // Show details about the simulator
13- const details = document . getElementById ( "details" ) ;
13+ const details_top = document . getElementById ( "details_top" ) ;
14+ const details_bottom = document . getElementById ( "details_bottom" ) ;
1415 // Basic description
1516 if ( data === null ) {
16- details . innerHTML = "<br />" ;
17- details . innerHTML += "<h2>Using this resource</h2>" ;
18- details . innerHTML += "<ul>" ;
19- details . innerHTML += "<li>Use the 'Toggle Filters' button to activate the simulation engine filter.</li>" ;
20- details . innerHTML += "<li>Select what simulation engines you would like to show in the graph.</li>" ;
21- details . innerHTML += "<li>Select a node/edge to see its ecosystem in the graph.</li>" ;
22- details . innerHTML += "<li>Double click/tap on a node/edge to see details of the tool.</li>" ;
23- details . innerHTML += "<li>Click outside to unselect nodes.</li>" ;
24- details . innerHTML += "</ul>" ;
25- details . innerHTML += "<h3 class='mt-3'>Contributing</h2>" ;
26- details . innerHTML += `<p>Contributions are welcome! If you have anything to add or correct in the data,
17+ details_top . innerHTML = "<br />" ;
18+ details_top . innerHTML += "<h2>Using this resource</h2>" ;
19+ details_top . innerHTML += "<ul>" ;
20+ details_top . innerHTML += "<li>Use the 'Toggle Filters' button to activate the simulation engine filter.</li>" ;
21+ details_top . innerHTML += "<li>Select what simulation engines you would like to show in the graph.</li>" ;
22+ details_top . innerHTML += "<li>Select a node/edge to see its ecosystem in the graph.</li>" ;
23+ details_top . innerHTML += "<li>Double click/tap on a node/edge to see details of the tool.</li>" ;
24+ details_top . innerHTML += "<li>Click outside to unselect nodes.</li>" ;
25+ details_top . innerHTML += "</ul>" ;
26+ details_top . innerHTML += "<h3 class='mt-3'>Contributing</h2>" ;
27+ details_top . innerHTML += `<p>Contributions are welcome! If you have anything to add or correct in the data,
2728 please follow the link at the end of the tool's details view to edit the data on GitHub.
2829 You can also open an <a href='${ REPO_URL } /issues'>issue on the GitHub repository</a>.</p>` ;
29- details . innerHTML + = "<h3 class='mt-3'>List of simulators</h2 >" ;
30- details . innerHTML += "<div class='d-flex' >" ;
30+ details_bottom . innerHTML = "<div class='d-flex' >" ;
31+ details_bottom . innerHTML += "<h3 class='mt-3'>List of simulators</h2 >" ;
3132 for ( const sim of SIMULATORS ) {
3233 const quoted_sim = `[id='${ sim } ']` ;
33- details . innerHTML += `<button class='btn btn-secondary m-1' onclick="cy.nodes('#simulators').unselect(); let node = cy.nodes('${ quoted_sim . replace ( / ' / g, "\\'" ) } '); node.select(); showNodeDetails(node);">${ TOOL_DESCRIPTIONS [ sim ] . short_name } </button>` ;
34+ details_bottom . innerHTML += `<button class='btn btn-secondary m-1' onclick="cy.nodes('#simulators').unselect(); let node = cy.nodes('${ quoted_sim . replace ( / ' / g, "\\'" ) } '); node.select(); showNodeDetails(node);">${ TOOL_DESCRIPTIONS [ sim ] . short_name } </button>` ;
3435 }
35- details . innerHTML += "</div>" ;
36-
36+ details_bottom . innerHTML += "</div>" ;
37+ window . history . pushState ( { } , "" , window . location . href . split ( "?" ) [ 0 ] ) ;
38+ return ;
3739 }
38- else {
39- if ( data [ "features" ] . includes ( "simulator" ) ) {
40- const quoted_sim = `[id=' ${ data . id } ']` ;
41- details . innerHTML = `<div class='d-flex justify-content-between align-items-center'>
42- <h2> ${ data [ "full_name" ] } </h2>
43- <button class='btn btn-outline-primary align-middle' title='Center ${ data [ "short_name" ] } in the graph' onclick="highlightNode(cy.nodes(' ${ quoted_sim . replace ( / ' / g , "\\'" ) } '));" >
44- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-bullseye" viewBox="0 0 16 16" >
45- <path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16"/ >
46- <path d="M8 13A5 5 0 1 1 8 3a5 5 0 0 1 0 10m0 1A6 6 0 1 0 8 2a6 6 0 0 0 0 12"/ >
47- <path d="M8 11a3 3 0 1 1 0-6 3 3 0 0 1 0 6m0 1a4 4 0 1 0 0-8 4 4 0 0 0 0 8 "/>
48- <path d="M9.5 8a1.5 1. 5 0 1 1-3 0 1.5 1.5 0 0 1 3 0 "/>
49- </svg >
50- </button >
51- </div>` ;
52- } else {
53- details . innerHTML = `<h2> ${ data [ "full_name" ] } </h2 >`;
54- }
55- details . innerHTML += "<p>" + data [ "description" ] + "</p>" ;
40+ details_top . innerHTML = "" ;
41+ details_bottom . innerHTML = "" ;
42+ let description = document . createElement ( "div" ) ;
43+ if ( data [ "features" ] . includes ( "simulator" ) ) {
44+ const quoted_sim = `[id=' ${ data . id } ']` ;
45+ description . innerHTML = `<div class='d-flex justify-content-between align-items-center' >
46+ <h2> ${ data [ "full_name" ] } </h2 >
47+ <button class='btn btn-outline-primary align-middle' title='Center ${ data [ "short_name" ] } in the graph' onclick="highlightNode(cy.nodes(' ${ quoted_sim . replace ( / ' / g , "\\'" ) } '));" >
48+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-bullseye" viewBox=" 0 0 16 16" >
49+ <path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16 "/>
50+ <path d="M8 13A5 5 0 1 1 8 3a5 5 0 0 1 0 10m0 1A6 6 0 1 0 8 2a6 6 0 0 0 0 12 "/>
51+ <path d="M8 11a3 3 0 1 1 0-6 3 3 0 0 1 0 6m0 1a4 4 0 1 0 0-8 4 4 0 0 0 0 8"/ >
52+ <path d="M9.5 8a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0"/ >
53+ </svg>
54+ </button>
55+ </div >` ;
56+ } else {
57+ description . innerHTML = `<h2> ${ data [ "full_name" ] } </h2>` ;
5658 }
59+ description . innerHTML += "<p>" + data [ "description" ] + "</p>" ;
5760 // Relations
58- if ( outgoers !== null ) {
59- if ( outgoers . length > 0 ) {
60- details . innerHTML += "<h3>Relations</h3>" ;
61+ if ( connected !== null ) {
62+ if ( connected . length > 0 ) {
63+ description . innerHTML += "<h3>Relations</h3>" ;
6164 const list = document . createElement ( "ul" ) ;
62- for ( let edge of outgoers ) {
65+ for ( let edge of connected ) {
66+ if ( edge [ "source" ] === "simulators" ) {
67+ continue ;
68+ }
6369 const listItem = document . createElement ( "li" ) ;
6470 const targetLink = document . createElement ( "a" ) ;
65- // targetLink.href = "#";
66- // targetLink.addEventListener("click",function(e) { node.unselect(); edge.target().select(); });
67- targetLink . innerHTML = edge [ "target" ] ;
68- const label = document . createElement ( "i" ) ;
71+ targetLink . href = "#" ;
72+ if ( edge [ "type" ] === "outgoing" ) {
73+ targetId = edge [ "target" ] ;
74+ } else {
75+ targetId = edge [ "source" ] ;
76+ }
77+ targetLink . addEventListener ( "click" , function ( e ) {
78+ console . log ( "Clicked on " + targetLink . innerHTML ) ;
79+ cy . nodes ( "[id='" + data . id + "']" ) . unselect ( ) ;
80+ cy . nodes ( "[id='" + targetLink . innerHTML + "']" ) . select ( ) ;
81+ } ) ;
82+ targetLink . innerHTML = targetId ;
83+ const simName = document . createElement ( "i" ) ;
84+ simName . innerHTML = data [ "short_name" ] ;
85+ const label = document . createElement ( "span" ) ;
6986 label . innerHTML = " " + edge [ "label" ] + " " ;
70- listItem . appendChild ( label ) ;
71- listItem . appendChild ( targetLink ) ;
72-
87+ if ( edge [ "type" ] === "outgoing" ) {
88+ listItem . append ( simName ) ;
89+ listItem . append ( label ) ;
90+ listItem . appendChild ( targetLink ) ;
91+ } else {
92+ listItem . appendChild ( targetLink ) ;
93+ listItem . append ( label ) ;
94+ listItem . append ( simName ) ;
95+ }
7396 list . appendChild ( listItem ) ;
7497 }
75- details . appendChild ( list ) ;
98+ description . appendChild ( list ) ;
7699 }
100+ details_top . appendChild ( description ) ;
77101 // URLs
78102 link_heading = document . createElement ( "h3" ) ;
79103 link_heading . innerHTML = "Links" ;
80- details . append ( link_heading ) ;
81- if ( data [ "urls" ] !== undefined ) {
82- for ( let [ text , url ] of Object . entries ( data [ "urls" ] ) ) {
83- details . appendChild ( urlButton ( text , url ) ) ;
104+ let tool_links = data [ "urls" ] ;
105+ details_bottom . appendChild ( link_heading ) ;
106+ for ( let row_idx = 0 ; row_idx < BUTTON_ROWS . length ; row_idx ++ ) {
107+ let row = document . createElement ( "div" ) ;
108+ row . classList . add ( "row" ) ;
109+ // Go through elements in BUTTON_ROWS
110+ for ( const button_type of BUTTON_ROWS [ row_idx ] ) {
111+ let col = document . createElement ( "div" ) ;
112+ col . classList . add ( "col-auto" ) ;
113+ let button = urlButton ( button_type , tool_links [ button_type ] ) ;
114+ col . appendChild ( button ) ;
115+ row . appendChild ( col ) ;
84116 }
117+ details_bottom . appendChild ( row ) ;
85118 }
86- // Back to simulators
87- back_p = document . createElement ( "p" ) ;
88- back_p . classList . add ( "mt-3" ) ;
89- back_button = document . createElement ( "a" ) ;
90- back_button . href = "#" ;
91- back_button . innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-counterclockwise" viewBox="0 0 16 16">
92- <path fill-rule="evenodd" d="M8 3a5 5 0 1 1-4.546 2.914.5.5 0 0 0-.908-.417A6 6 0 1 0 8 2z"/>
93- <path d="M8 4.466V.534a.25.25 0 0 0-.41-.192L5.23 2.308a.25.25 0 0 0 0 .384l2.36 1.966A.25.25 0 0 0 8 4.466"/>
94- </svg> Back to simulators` ;
95- back_button . classList . add ( "btn" , "btn-secondary" ) ;
96- back_button . onclick = function ( ) { cy . nodes ( `[id = '${ data . id } ']` ) . unselect ( ) ; cy . nodes ( "#simulators" ) . select ( ) ; unhighlightNode ( ) ; } ;
97- back_p . appendChild ( back_button ) ;
98- details . appendChild ( back_p ) ;
99- // Edit footer
100- edit_p = document . createElement ( "p" ) ;
101- edit_p . classList . add ( "mt-3" , "text-end" ) ;
102- edit_link = document . createElement ( "a" ) ;
103- edit_link . classList . add ( "link-secondary" ) ;
104- edit_link . href = `${ REPO_URL } /edit/${ GIT_BRANCH } /${ DATA_FOLDER } /${ data [ "short_name" ] . replaceAll ( " " , "-" ) } .yaml` ;
105- edit_link . innerHTML = "Edit this description on GitHub " ;
106- edit_link . innerHTML += `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-github" viewBox="0 0 16 16">
107- <path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27s1.36.09 2 .27c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8"/>
108- </svg>` ;
109- edit_link . target = "_blank" ;
110- edit_p . appendChild ( edit_link ) ;
111- details . appendChild ( edit_p ) ;
112-
113119 }
114120 // hide filter pane
115121 const filterPane = new bootstrap . Offcanvas ( '#filter_pane' ) ;
0 commit comments