Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…12cdd6b-5c7d-d5a7-a2ba-d0f0cdb91641
  • Loading branch information
FayCross committed Sep 14, 2011
1 parent bd9c796 commit 7a8bf6e
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 37 deletions.
120 changes: 95 additions & 25 deletions JMolViewer/jmol.htm
Expand Up @@ -2,9 +2,84 @@
<title>JMol Example</title>
<script src="jmol/Jmol.js" type="text/javascript"></script><!-- Use your own path here -->
<script type="text/javascript">
var setUpInfo = "load ";

var str = document.location.search.substr(1,document.location.search.length);
var modelFile = str.split('xyz=')[1];
//var modelFile = "jmol/models/DNEIBA_+H.mol2";
var modelFile = str.split(';')[0].split('xyz=')[1];
setUpInfo += modelFile + ";";

var spin = str.split(';')[1].split('spin=')[1];
var spinDefault = "";
if (spin == "true") {
spinDefault = "checked";
setUpInfo += " spin on;";
}

var controls = str.split(';')[2].split('controls=')[1];

var bgColour = str.split(';')[3].split('bgColour=')[1];
var selectedColour = new Array("", "", "");
if (bgColour == "undefined" || bgColour == "" || bgColour == "White") {
selectedColour[0] = "selected";
bgColour = "White"
} else if (bgColour == "Black") {
selectedColour[1] = "selected";
} else {
selectedColour[2] = "selected";
bgColour = "skyblue"
}
setUpInfo += " background " + bgColour + ";";

var initLook = str.split(';')[4].split('initLook=')[1];
var appearance = new Array("", "", "", "", "", "");
if (initLook == "CPK") {
appearance[0] = "selected";
setUpInfo += " spacefill on; wireframe off; backbone on; cartoon off; color cpk;";
} else if (initLook == "Ball and Stick") {
appearance[1] = "selected";
setUpInfo += " spacefill 25%; wireframe 35%; backbone on; cartoon off; color cpk;";
} else if (initLook == "Sticks") {
appearance[2] = "selected";
setUpInfo += " spacefill off; wireframe 20%; backbone on; cartoon off; color cpk;";
} else if (initLook == "Wireframe") {
appearance[3] = "selected";
setUpInfo += " spacefill off; wireframe on; backbone on; cartoon off; color cpk;";
} else if (initLook == "Cartoon") {
appearance[4] = "selected";
setUpInfo += " spacefill off; wireframe off; backbone on; cartoon on; color cartoon structure;";
} else if (initLook == "Backbone") {
appearance[5] = "selected";
setUpInfo += " spacefill off; wireframe off; backbone 0.4; cartoon off; color structure;";
}

var cartoonOpt = str.split(';')[5].split('cartoonOpt=')[1];
var backOpt = str.split(';')[6].split('backOpt=')[1];
var displayOptions = [["spacefill on; wireframe off; backbone on; cartoon off; color cpk", "CPK", appearance[0]],
["spacefill 25%; wireframe 35%; backbone on; cartoon off; color cpk", "Ball and Stick", appearance[1]],
["spacefill off; wireframe 20%; backbone on; cartoon off; color cpk", "Sticks", appearance[2]],
["spacefill off; wireframe on; backbone on; cartoon off; color cpk", "Wireframe", appearance[3]],
["spacefill off; wireframe off; backbone 0.4; cartoon off; color structure", "Backbone", appearance[5]],
["spacefill off; wireframe off; backbone on; cartoon on; color cartoon structure", "Cartoon", appearance[4]]];
if (cartoonOpt == "false" && backOpt == "false") {
displayOptions = [["spacefill on; wireframe off; backbone on; cartoon off; color cpk", "CPK", appearance[0]],
["spacefill 25%; wireframe 35%; backbone on; cartoon off; color cpk", "Ball and Stick", appearance[1]],
["spacefill off; wireframe 20%; backbone on; cartoon off; color cpk", "Sticks", appearance[2]],
["spacefill off; wireframe on; backbone on; cartoon off; color cpk", "Wireframe", appearance[3]]];
} else if (cartoonOpt == "false") {
displayOptions = [["spacefill on; wireframe off; backbone on; cartoon off; color cpk", "CPK", appearance[0]],
["spacefill 25%; wireframe 35%; backbone on; cartoon off; color cpk", "Ball and Stick", appearance[1]],
["spacefill off; wireframe 20%; backbone on; cartoon off; color cpk", "Sticks", appearance[2]],
["spacefill off; wireframe on; backbone on; cartoon off; color cpk", "Wireframe", appearance[3]],
["spacefill off; wireframe off; backbone 0.4; cartoon off; color structure", "Backbone", appearance[5]]];
} else if (backOpt == "false") {
displayOptions = [["spacefill on; wireframe off; backbone on; cartoon off; color cpk", "CPK", appearance[0]],
["spacefill 25%; wireframe 35%; backbone on; cartoon off; color cpk", "Ball and Stick", appearance[1]],
["spacefill off; wireframe 20%; backbone on; cartoon off; color cpk", "Sticks", appearance[2]],
["spacefill off; wireframe on; backbone on; cartoon off; color cpk", "Wireframe", appearance[3]],
["spacefill off; wireframe off; backbone on; cartoon on; color cartoon structure", "Cartoon", appearance[4]]];
}

setUpInfo += " set antialiasDisplay true;";

</script>

Expand All @@ -15,8 +90,8 @@
}

.holder {
width: 400px;
height: 454px;
width: 370px;
height: 389px;
}

.header {
Expand Down Expand Up @@ -47,37 +122,30 @@
<form>

<div class="holder">

<!--<div class="header"><script type="text/javascript">document.write(modelTitle);</script></div>-->

<div class="model">
<script type="text/javascript">
jmolInitialize("jmol");
jmolSetAppletColor("white");
jmolApplet([375, 394], "load " + modelFile + "; set antialiasDisplay true;");
jmolSetAppletColor(bgColour);
jmolApplet([345, 309], setUpInfo);
jmolSetButtonCssClass("style1");
jmolSetCheckboxCssClass("style1");
jmolSetMenuCssClass("style1");
</script>
</div>

<div class="controls">
<script type="text/javascript">
<script type="text/javascript">
if (controls == "true") {
document.write('<div class="controls">');

jmolHtml("Display: ");
jmolMenu([
["spacefill on; wireframe off; backbone on; cartoon off; color cpk", "CPK"],
["spacefill 25%; wireframe 35%; backbone on; cartoon off; color cpk", "Ball and Stick", "selected"],
["spacefill off; wireframe 20%; backbone on; cartoon off; color cpk", "Sticks"],
["spacefill off; wireframe on; backbone on; cartoon off; color cpk", "Wireframe"],
["spacefill off; wireframe off; backbone on; cartoon on; color cartoon structure", "Cartoon"],
["spacefill off; wireframe off; backbone 0.4; cartoon off; color structure", "Backbone"]
]);
jmolMenu(displayOptions);
jmolHtml(" &nbsp;&nbsp;&nbsp;&nbsp;");
jmolHtml("Background: ");
jmolMenu([
["background white", "white", "selected"],
["background black", "black"],
["background skyblue", "blue"]
["background white", "White", selectedColour[0]],
["background black", "Black", selectedColour[1]],
["background skyblue", "Blue", selectedColour[2]]
]);
jmolBr();
jmolBr();
Expand All @@ -89,11 +157,13 @@
]);
jmolHtml(" &nbsp;&nbsp;&nbsp;&nbsp;");
jmolHtml("Spin: ");
jmolCheckbox("spin on", "spin off", "");
jmolCheckbox("spin on", "spin off", "", spinDefault);
jmolHtml(" &nbsp;&nbsp;&nbsp;&nbsp;");
jmolButton("load " + modelFile + "; background white", "Reset model"); // ** when clicked drop downs need to change **
</script>
</div>
jmolButton(setUpInfo, "Reset model");

document.write('</div>');
}
</script>

</div>

Expand Down
17 changes: 12 additions & 5 deletions modules/xerte/parent_templates/Nottingham/data.xwd
Expand Up @@ -67,7 +67,7 @@


<links><![CDATA[<links name="Enter Page Title" text="Enter Page Text" cols="3" height="80"/>]]></links>
<jmol><![CDATA[<jmol name="JMOL VIewer" text="Enter text for the page" xyz="Select an XYZ file"/>]]></jmol>
<jmol><![CDATA[<jmol name="Enter Page Title" text="Enter text for the page" xyz="Select an XYZ file" initLook="Ball and Stick" controls="true"/>]]></jmol>
<perspectives><![CDATA[<perspectives name="Enter Page Title" />]]></perspectives>
<xerteModel><![CDATA[<xerteModel name="Enter Page Title" modelFile="Select a Model"/>]]></xerteModel>
<raptivity><![CDATA[<raptivity name="Enter Page Title" url="Select a Raptivity SWF File"/>]]></raptivity>
Expand Down Expand Up @@ -203,7 +203,6 @@
<name type="TextInput" label="Page Title"/>
<instruction type="TextArea" label="Instruction" height="100"/>


<narrationNavigate type="CheckBox" label="Navigate on narration" optional="true"/>
<playNarration type="CheckBox" label="Auto-play narration" optional="true"/>
<narration type="media" label="Narration" optional="true"/>
Expand All @@ -217,13 +216,21 @@

<name type="TextInput" label="Page Title"/>
<text type="TextArea" height="150" label="Text"/>
<xyz type="Media" label="XYZ File"/>


<xyz type="Media" label="Model File"/>
<initLook type="ComboBox" options="CPK,Ball and Stick,Sticks,Wireframe,Cartoon,Backbone" label="Initial Appearance" width="120"/>
<controls type="CheckBox" label="Show Control Bar"/>

<narrationNavigate type="CheckBox" label="Navigate on narration" optional="true"/>
<playNarration type="CheckBox" label="Auto-play narration" optional="true"/>
<narration type="media" label="Narration" optional="true"/>

<cartoonOpt type="CheckBox" label="Cartoon Option" defaultValue="true" optional="true"/>
<backOpt type="CheckBox" label="Backbone Option" defaultValue="true" optional="true"/>
<bgColour type="ComboBox" options="White,Black,Blue" label="Background Colour" width="120" optional="true"/>
<initSpin type="CheckBox" label="Spin" optional="true"/>
<xyz2 type="Media" label="2nd Model File" optional="true"/>


</jmol>


Expand Down
2 changes: 1 addition & 1 deletion modules/xerte/parent_templates/Nottingham/models/jmol.rlm
@@ -1 +1 @@
<PG name="JMol"> <SCR name="getPageID"><![CDATA[pageIcon = icon.parentNode.clip();if (extXML == undefined){ // Page Wizard pageIcon.templateData = pageIcon.extXML.toObject(); pageIcon.templateData = pageIcon.templateData.pageWizard[0];} else { // Toolkits myXML = new XML(extXML.firstChild.childNodes[rootIcon.getPageIndex() - pgOffset]); pageIcon.templateData = myXML.toObject(); rootIcon.setTitleText(templateData.learningObject[0].name);}if (pageIcon.templateData.jmol[0].narration != undefined){ narration = pageIcon.templateData.jmol[0].narration; rootIcon.broadcast('showAudio');}]]></SCR> <SCR name="JMol"><![CDATA[params = new Object();params.x = '85';params.y = '380';params.width = '400';params.height = '474';params.type = 'iframe';params.src = 'JMolViewer/jmol.htm?xyz=../' + expression(pageIcon.templateData.jmol[0].xyz, engine);params.bgColour = '#FFFFFF';params.borderColour = '#FFFFFF';callJS('makePopUp', params);popupActive = true;]]></SCR> <DIS scrolling="auto" h="474" name="text" x="20" y="20" w="340" type="text"><![CDATA[{pageIcon.templateData.jmol[0].text}]]></DIS> </PG>
<PG name="JMol"> <SCR name="getPageID"><![CDATA[pageIcon = icon.parentNode.clip();if (extXML == undefined){ // Page Wizard pageIcon.templateData = pageIcon.extXML.toObject(); pageIcon.templateData = pageIcon.templateData.pageWizard[0];} else { // Toolkits myXML = new XML(extXML.firstChild.childNodes[rootIcon.getPageIndex() - pgOffset]); pageIcon.templateData = myXML.toObject(); rootIcon.setTitleText(templateData.learningObject[0].name);}if (pageIcon.templateData.jmol[0].narration != undefined){ narration = pageIcon.templateData.jmol[0].narration; rootIcon.broadcast('showAudio');}]]></SCR> <SCR name="JMol"><![CDATA[if (pageIcon.templateData.jmol[0].xyz2 != undefined) { numXYZ = 2; textW = 760; textH = 80; windowH = 389;} else { numXYZ = 1; textW = 340; textH = 474; windowH = 474;}windowW = 370;for (i=0; i<numXYZ; i++) { params = new Object(); params.id = "popup"+i; //params.y = '85'; params.y = 85 * numXYZ; params.width = windowW; params.height = windowH; params.type = 'iframe'; if (i == 0) { myFile = pageIcon.templateData.jmol[0].xyz; } else { myFile = pageIcon.templateData.jmol[0].xyz2; } params.x = 800 - ((windowW+20)*(i+1)); params.src = 'JMolViewer/jmol.htm?xyz=../' + expression(myFile, engine) + ';spin=' + pageIcon.templateData.jmol[0].initSpin + ';controls=' + pageIcon.templateData.jmol[0].controls + ';bgColour=' + pageIcon.templateData.jmol[0].bgColour + ';initLook=' + pageIcon.templateData.jmol[0].initLook + ';cartoonOpt=' + pageIcon.templateData.jmol[0].cartoonOpt + ';backOpt=' + pageIcon.templateData.jmol[0].backOpt; params.bgColour = '#FFFFFF'; params.borderColour = '#FFFFFF'; callJS('makePopUp', params); popupActive = true;}]]></SCR> <DIS scrolling="auto" h="textH" name="text" x="20" y="20" w="textW" type="text"><![CDATA[{pageIcon.templateData.jmol[0].text}]]></DIS> </PG>
Expand Down
16 changes: 10 additions & 6 deletions modules/xerte/preview_xerte_top
Expand Up @@ -35,13 +35,13 @@ function makePopUp(params)
//make the div and style it...
var create_div = document.createElement("DIV");

create_div.id = 'popup';
create_div.id = params.id;
create_div.style.height = params.height + "px";
create_div.style.width = params.width + "px";
create_div.style.position = "absolute";

create_div.style.top = params.x + "px";
create_div.style.left = params.y + "px";
create_div.style.left = params.x + "px";
create_div.style.top = params.y + "px";
create_div.style.background = params.bgColour;
create_div.style.border = "1px solid " + params.borderColour;

Expand All @@ -64,10 +64,14 @@ function makePopUp(params)
}
function killPopUp()
{
var popup = document.getElementById("popup");
var parent = document.getElementById("popup_parent");

parent.removeChild(popup);
if ( parent.hasChildNodes() )
{
while ( parent.childNodes.length >= 1 )
{
parent.removeChild( parent.firstChild );
}
}
}

</script>
Expand Down

0 comments on commit 7a8bf6e

Please sign in to comment.