Commit d0d15c0d by Carlos Andrés Rocha Committed by Victor Shnayder

Import edit-a-molecule resources

parent 739938f3
<!doctype html>
<html>
<head>
<title>Edit A Molecule</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<link type="text/css" rel="stylesheet" href="JsMolCalc.css"/>
<script type="text/javascript" src="jsmolcalc/jsmolcalc.nocache.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="http://underscorejs.org/underscore-min.js"></script>
<script type="text/template" id="task-template">
<li class="task">
<label><%= task %></label>&nbsp;<button>Check</button>&nbsp;<span class="result"></span>
</li>
</script>
<script src="edit-a-molecule.js" type="text/javascript"></script>
</head>
<body>
<h1>Edit A Molecule</h1>
<p>The molecule Dopamine is shown below. Dopamine is a neurotransmitter.</p>
<object type="application/x-java-applet" id="JME" height="400" width="500">
<param name="archive" value="JME.jar" />
<param name="code" value="JME.class" />
Applet failed to run. No Java plug-in was found.
</object>
<div id="properties"></div>
<button id="update">Update</button>
<p>Edit the molecule to complete each one of the following the tasks. Click the check button to check your answer for that. Click submit when you are done.</p>
<ul id="tasks"></ul>
</body>
</html>
/** Add css rules here for your application. */
/** Example rules used by the template application (remove for your app) */
h1 {
font-size: 2em;
font-weight: bold;
color: #777777;
margin: 40px 0px 70px;
}
.calculateButton {
display: block;
font-size: 16pt;
}
.newMoleculeButton {
display: block;
font-size: 16pt;
}
/** Most GWT widgets already have a style name defined */
.gwt-DialogBox {
width: 400px;
}
.dialogVPanel {
margin: 5px;
}
.serverResponseLabelError {
color: red;
}
/** Set ids using widget.getElement().setId("idOfElement") */
#closeButton {
margin: 15px 6px 6px;
}
$(document).ready(function(){
var applet = $("#JME")[0];
var template = _.template($("#task-template").text());
var timeout = 1000;
function waitForApplet() {
if (applet.isActive && applet.isActive()) {
console.log("Applet is ready.");
loadInitialData();
} else if (timeout > 30 * 1000) {
console.error("Applet did not load on time.");
} else {
console.log("Waiting for applet...");
setTimeout(waitForApplet, timeout);
}
}
function loadInitialData() {
console.log("Loading mol data...");
jQuery.ajax({
url: "dopamine.mol",
dataType: "text",
success: function(data) {
console.log("Done.");
setup(data);
},
error: function() {
console.error("Cannot load mol data.");
}
});
}
function setup(data) {
applet.readMolFile(data);
setupTasks();
$("#update").click(updateInfo);
updateInfo();
}
function setupTasks() {
console.log("Getting initial tasks...");
var tasks = getTasks();
jQuery.each(tasks, function(index, task) {
var value = task.toString();
var fragment = $(template({task:value}));
$("#tasks").append(fragment);
fragment.find("button").click(function() {
checkTask(task, index);
});
});
console.log("Done.");
}
function updateInfo() {
var info = getInfo();
$("#properties").html(info.toString());
return info;
}
function checkTask(task, index) {
var info = updateInfo();
var value = task.check(info);
$("#tasks li span.result").eq(index).html(value);
}
function getInfo() {
var mol = applet.molFile();
var smiles = applet.smiles();
var jme = applet.jmeFile();
return jsmol.API.getInfo(mol, smiles, jme);
}
function getTasks() {
var mol = applet.molFile();
var smiles = applet.smiles();
var jme = applet.jmeFile();
return jsmol.API.getTasks(mol, smiles, jme);
}
waitForApplet();
});
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment