Skip to content

Commit

Permalink
An incomplete molecule viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
ToonTalk committed Dec 14, 2024
1 parent 50074f9 commit bd55e31
Showing 1 changed file with 148 additions and 0 deletions.
148 changes: 148 additions & 0 deletions apps/molecule-viewer-html.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>3D Molecule Viewer</title>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
max-width: 800px;
margin: 0 auto;
padding: 20px;
background-color: #f5f5f5;
}
.container {
background: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
h1 {
color: #333;
margin-bottom: 10px;
}
.description {
color: #666;
margin-bottom: 20px;
}
.form-group {
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 5px;
font-weight: 500;
}
input[type="text"] {
width: 100%;
padding: 8px;
border: 1px solid #ddd;
border-radius: 4px;
box-sizing: border-box;
font-size: 16px;
}
button {
background-color: #4CAF50;
color: white;
padding: 10px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
width: 100%;
}
button:hover {
background-color: #45a049;
}
#viewer {
width: 100%;
height: 400px;
background-color: #f8f8f8;
border: 1px solid #ddd;
border-radius: 4px;
margin-top: 20px;
display: flex;
align-items: center;
justify-content: center;
color: #666;
}
.error {
color: #d32f2f;
background-color: #ffebee;
padding: 10px;
border-radius: 4px;
margin-top: 10px;
display: none;
}
.instructions {
margin-top: 20px;
padding: 15px;
background-color: #f5f5f5;
border-radius: 4px;
}
.instructions h3 {
margin-top: 0;
}
.instructions ol {
margin: 0;
padding-left: 20px;
}
.instructions li {
margin-bottom: 8px;
}
</style>
</head>
<body>
<div class="container">
<h1>3D Molecule Viewer</h1>
<p class="description">Enter a SMILES string to generate a 3D molecular structure</p>

<form id="moleculeForm">
<div class="form-group">
<label for="smiles">SMILES String:</label>
<input type="text"
id="smiles"
name="smiles"
placeholder="e.g., CC(=O)O for acetic acid"
required>
</div>
<button type="submit">Generate 3D Structure</button>
</form>

<div id="error" class="error">
Error message will appear here
</div>

<div id="viewer">
3D visualization will appear here
</div>

<div class="instructions">
<h3>Implementation Guide</h3>
<ol>
<li>Set up a backend service that can convert SMILES to 3D coordinates (using RDKit or OpenBabel)</li>
<li>Add a molecular visualization library like 3Dmol.js or NGL Viewer</li>
<li>Update the form submission handler to call your backend API</li>
<li>Initialize the 3D viewer with the returned coordinates</li>
</ol>
</div>
</div>

<script>
document.getElementById('moleculeForm').addEventListener('submit', function(e) {
e.preventDefault();

const smilesInput = document.getElementById('smiles').value;
const errorDiv = document.getElementById('error');

// This is where you would typically make an API call
// For demo purposes, we'll just show an error message
errorDiv.style.display = 'block';
errorDiv.textContent = 'Note: This is a demo form. To make it functional, you need to:' +
'\n1. Add a backend service that converts SMILES to 3D coordinates' +
'\n2. Integrate a 3D visualization library like 3Dmol.js or NGL';
});
</script>
</body>
</html>

0 comments on commit bd55e31

Please sign in to comment.