Skip to content

Commit 040c71c

Browse files
committed
Fully hide structure output if the result of name interpretation is an error
1 parent 9418d7f commit 040c71c

File tree

2 files changed

+29
-18
lines changed

2 files changed

+29
-18
lines changed

src/main/webapp/index.html

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<link rel="stylesheet" href="opsin.css" type="text/css" media="all" />
1111
<title>OPSIN: Open Parser for Systematic IUPAC Nomenclature</title>
1212
<script src="jquery-1.12.4.min.js"></script>
13-
<script src="opsin.js?v=20221102"></script>
13+
<script src="opsin.js?v=20221102a"></script>
1414
<style media="all">
1515
div#content-primary img#depiction {
1616
display: inline;
@@ -82,29 +82,31 @@ <h1>OPSIN: Open Parser for Systematic IUPAC nomenclature</h1>
8282
The chemical structure described by the name, or why it could not be interpreted, will appear here.</p>
8383
</div>
8484
<div id="results" style="display:none">
85-
<p>
85+
<p class="structureOutput">
8686
<a id="depictionLink" href="" target="_blank">
8787
<img id="depiction" src="data:," alt="" />
8888
</a>
8989
</p>
9090
<h3 id="messagetype"></h3>
9191
<p id="message"></p>
92-
<h3 title="StdInChI aims to provide a canonical form for a chemical structure that is independent of the input tautomer/resonance form">StdInChI:</h3>
93-
<p>
94-
<span id="stdinchi"></span><button class="copyBtn" onclick="copyText(this, 'stdinchi')">Copy</button>
95-
</p>
96-
<h3 title="Hashed form of StdInChI. Multiple structures can have the same key (although this in practice occurs extremely rarely)">StdInChIKey:</h3>
97-
<p>
98-
<span id="stdinchikey"></span> (Click to search the internet for this structure)<button class="copyBtn" onclick="copyText(this, 'stdinchikey')">Copy</button>
99-
</p>
100-
<h3 title="Simplified Molecular Input Line Entry Specification (a machine-readable structure description)">SMILES:</h3>
101-
<p>
102-
<span id="smiles"></span><button class="copyBtn" onclick="copyText(this, 'smiles')">Copy</button>
103-
</p>
104-
<h3 title="Chemical Markup Language">CML:</h3>
105-
<p>
106-
<pre id="cml"></pre><button class="copyBtn" onclick="copyText(this, 'cml')">Copy</button>
107-
</p>
92+
<div class="structureOutput">
93+
<h3 title="StdInChI aims to provide a canonical form for a chemical structure that is independent of the input tautomer/resonance form">StdInChI:</h3>
94+
<p>
95+
<span id="stdinchi"></span><button class="copyBtn" onclick="copyText(this, 'stdinchi')">Copy</button>
96+
</p>
97+
<h3 title="Hashed form of StdInChI. Multiple structures can have the same key (although this in practice occurs extremely rarely)">StdInChIKey:</h3>
98+
<p>
99+
<span id="stdinchikey"></span> (Click to search the internet for this structure)<button class="copyBtn" onclick="copyText(this, 'stdinchikey')">Copy</button>
100+
</p>
101+
<h3 title="Simplified Molecular Input Line Entry Specification (a machine-readable structure description)">SMILES:</h3>
102+
<p>
103+
<span id="smiles"></span><button class="copyBtn" onclick="copyText(this, 'smiles')">Copy</button>
104+
</p>
105+
<h3 title="Chemical Markup Language">CML:</h3>
106+
<p>
107+
<pre id="cml"></pre><button class="copyBtn" onclick="copyText(this, 'cml')">Copy</button>
108+
</p>
109+
</div>
108110
</div>
109111
</div>
110112

src/main/webapp/opsin.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ $(document).ready(function() {
1111
$("#stdinchikey").text("");
1212
$("#smiles").text("");
1313
let chemicalNameUrlEncoded = encodeURIComponent($("#chemicalName").val());
14+
15+
let structureOutputEls = document.getElementsByClassName("structureOutput");
16+
for(let i = 0, len = structureOutputEls.length; i < len; i++) {
17+
structureOutputEls[i].style.display="none";
18+
}
19+
1420
$.ajax({
1521
beforeSend: function(req) {
1622
req.setRequestHeader("Accept", "application/json");
@@ -29,6 +35,9 @@ $(document).ready(function() {
2935
$("#stdinchi").text(response.stdinchi);
3036
$("#stdinchikey").html("<a href=\"http://www.google.com/search?q=&quot;"+ response.stdinchikey +"&quot;\" target=\"_blank\">" + response.stdinchikey + "</a>");
3137
$("#smiles").text(response.smiles);
38+
for(let i = 0, len = structureOutputEls.length; i < len; i++) {
39+
structureOutputEls[i].style.display="";
40+
}
3241
},
3342
error: function(xhr, textStatus, errorThrown){
3443
let errResp = JSON.parse(xhr.responseText)

0 commit comments

Comments
 (0)