Skip to content

Commit

Permalink
Some polish
Browse files Browse the repository at this point in the history
  • Loading branch information
naelstrof committed Mar 19, 2016
1 parent ce703ab commit e77c9dc
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 13 deletions.
Binary file modified public/images/beaker.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 13 additions & 9 deletions public/scripts/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,28 @@ $(document).ready(function() {
shape = r.set().
push(ellipse).
push(r.text(0, 30, node.label || node.id));
shape.translate( $("#content").width()/2, 300 );
return shape;
}
$('.beaker-image').css( "background-color", $('color').text() );
$('edge').each( function( index ) {
var strings = $(this).text().split(",");
if ( $(this).attr("color_d") == "#333" ) {
g.addNode( strings[1], { color : getRandomColor(), render : render } );
} else {
g.addNode( strings[1], { color : $(this).attr("color_d"), render : render } );
}
if ( $(this).attr("color_s") == "#333" ) {
g.addNode( strings[0], { color : getRandomColor(), render : render } );
} else {
g.addNode( strings[0], { color : $(this).attr("color_s"), render : render } );
}
if ( $(this).attr("weight") != "1" ) {
g.addEdge( strings[1], strings[0], { directed: true, label: $(this).attr("weight") } );
} else {
g.addEdge( strings[1], strings[0], { directed: true } );
if ( strings[0] != strings[1] ) {
if ( $(this).attr("color_s") == "#333" ) {
g.addNode( strings[0], { color : getRandomColor(), render : render } );
} else {
g.addNode( strings[0], { color : $(this).attr("color_s"), render : render } );
}
if ( $(this).attr("weight") != "1" ) {
g.addEdge( strings[1], strings[0], { directed: true, label: $(this).attr("weight") } );
} else {
g.addEdge( strings[1], strings[0], { directed: true } );
}
}
} );
for(e in g.edges) {
Expand Down
14 changes: 14 additions & 0 deletions public/styles/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@ svg {
padding-top: 15px;
}

.beaker-image {
background: url(../images/beaker.png) left top;
display: block;
float: left;
margin-top: 5px;
width: 32px;
height: 32px;
}

.beaker-text {
display: block;
float: left;
}

.brand-image {
background: url(../images/mixer.gif) left top;
width: 32px;
Expand Down
18 changes: 15 additions & 3 deletions source/chemAPI.d
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,27 @@ class ChemAPI : IChemAPI {
}
if ( reagents[id].object.keys.canFind( "parents" ) ) {
foreach( j ; reagents[id]["parents"].array ) {
parents ~= `<a href="/reagent?id=` ~ reagents[j.str]["id"].str ~ `">` ~ reagents[j.str]["name"].str ~ `</a>`;
string rname;
if ( reagents[j.str].object.keys.canFind("name") ) {
rname = reagents[j.str]["name"].str;
} else {
rname = reagents[j.str]["id"].str;
}
parents ~= `<a href="/reagent?id=` ~ reagents[j.str]["id"].str ~ `">` ~ rname ~ `</a>`;
}
}
if ( parents.length <= 0 ) {
parents ~= "None!";
}
if ( reagents[id].object.keys.canFind( "required_reagents" ) ) {
foreach( j ; reagents[id]["required_reagents"].object.keys ) {
children ~= `<a href="/reagent?id=` ~ reagents[j]["id"].str ~ `">` ~ reagents[j]["name"].str ~ `</a>`;
string rname;
if ( reagents[j].object.keys.canFind("name") ) {
rname = reagents[j]["name"].str;
} else {
rname = reagents[j]["id"].str;
}
children ~= `<a href="/reagent?id=` ~ reagents[j]["id"].str ~ `">` ~ rname ~ `</a>`;
}
}
if ( children.length <= 0 ) {
Expand All @@ -84,7 +96,7 @@ class ChemAPI : IChemAPI {
children = ["Unknown"];
color = "#FFF";
}
render!("get.dt", html, name, description, parents, children );
render!("get.dt", html, name, description, parents, children, color );
}
void index() {
render!("index.dt", sorted_reagents);
Expand Down
4 changes: 3 additions & 1 deletion views/get.dt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
extends layout

block body
h1!= name
.beaker-image
h1.beaker-name != name
p!= description
hr
#canvas.canvas
Expand All @@ -18,6 +19,7 @@ block body
- foreach( str ; parents )
tr
td!= str
color(hidden)!= color
|!= html

block after
Expand Down

0 comments on commit e77c9dc

Please sign in to comment.