jmol-12.2.32+dfsg2.orig/0000775000175000017500000000000012050172543014033 5ustar mbanckmbanckjmol-12.2.32+dfsg2.orig/appletweb/0000755000175000017500000000000012050172536016016 5ustar mbanckmbanckjmol-12.2.32+dfsg2.orig/appletweb/chime2jmol_old.pl0000644000175000017500000002221411771706307021253 0ustar mbanckmbanckuse strict; use HTML::Parser; use Getopt::Std; use File::Find; use File::Copy; use File::Path; use Cwd; sub handleEmbed; sub handleEnd; sub usage; use vars qw/$opt_v $opt_a $opt_s $opt_c $opt_d $opt_b/; getopts('va:s:cd:b:') or usage(); ($opt_s && $opt_d) or usage(); my $pwd = cwd(); print "pwd is $pwd\n" if $opt_v; my $fullsrcpath = $opt_s; $fullsrcpath =~ s|(\./)+||; $fullsrcpath = $pwd . "/" . $fullsrcpath unless $fullsrcpath =~ m|^/|; $fullsrcpath = $fullsrcpath . "/" unless $fullsrcpath =~ m|/$|; my $fulldstpath = $opt_d; $fulldstpath =~ s|(\./)+||; $fulldstpath = $pwd . "/" . $fulldstpath unless $fulldstpath =~ m|^/|; $fulldstpath = $fulldstpath . "/" unless $fulldstpath =~ m|/$|; print "source directory $fullsrcpath\n" if $opt_v; (-d $fullsrcpath) or die "$fullsrcpath is not a directory"; if ($opt_c) { print "deleting directory tree $fulldstpath\n" if $opt_v; rmtree $fulldstpath; } if (-e $fulldstpath) { print "destination directory $fulldstpath exists\n" if $opt_v; -d $fulldstpath or die "$fulldstpath is not a directory"; } else { print "creating destination directory $fulldstpath\n" if $opt_v; mkdir($fulldstpath) or die "could not make directory $fulldstpath"; } my $archive = "JmolApplet.jar"; $archive = $opt_a if $opt_a; print "archive is $archive\n" if $opt_v; my $codebase = $opt_b; print "codebase is $codebase\n" if $codebase && $opt_v; my $baseDirectory; my @files; my @directories; sub accumulateFilename { if ($baseDirectory) { my $pathname = $File::Find::name; my $name = substr $pathname, length($baseDirectory); if (-f $pathname) { print "$pathname is a file\n"; push @files, $name if -f $pathname; } elsif (-d $pathname) { print "$pathname is a directory\n"; push @directories, $name if -d $pathname; } else { print "$pathname is neither fish nor fowl?\n"; print "but it exists!\n" if -e $pathname; } } else { $baseDirectory = $File::Find::name . "/"; print "baseDirectory=$baseDirectory\n" if $opt_v; } } find(\&accumulateFilename, $fullsrcpath); for my $directory (@directories) { print "mkdir $fulldstpath$directory\n" if $opt_v; mkdir "$fulldstpath$directory"; } for my $file (@files) { next if $file =~ /\~$/; # ignore emacs files print "processing $file\n" if $opt_v; processFile("$baseDirectory$file", "$fulldstpath$file"); } exit(); sub processFile { my ($src, $dst) = @_; if ($src =~ /html?$/i) { processHtmlFile($src, $dst); } else { copyFile($src, $dst); } } sub copyFile { my ($src, $dst) = @_; # print "copyFile $src -> $dst\n"; copy $src, $dst; } sub processHtmlFile { my ($src, $dst) = @_; open OUTPUT, ">$dst" or die "could not open $dst"; my $p = HTML::Parser->new(start_h => [\&handleEmbed, 'skipped_text,text,tokens'], end_document_h => [\&writePrevious, 'skipped_text']); $p->report_tags('embed'); $p->parse_file($src) || die $!; close OUTPUT; } my ($previous, $embed, $tokens); my $tokenCount; # common to both plugins and buttons my ($name, $width, $height, $bgcolor, $src, $script); # plug-in specific my ($preloadscript, $loadStructCallback, $messageCallback, $pauseCallback, $pickCallback); # button-specific my ($type, $button, $buttonCallback, $target, $altscript); sub handleEmbed { ($previous, $embed, $tokens) = @_; $tokenCount = scalar @$tokens; $name = getUnquotedParameter('name'); $width = getUnquotedParameter('width'); $height = getUnquotedParameter('height'); $bgcolor = getUnquotedParameter('bgcolor'); $src = getUnquotedParameter('src'); $loadStructCallback = getUnquotedParameter('LoadStructCallback'); $messageCallback = getUnquotedParameter('MessageCallback'); $pauseCallback = getUnquotedParameter('pauseCallback'); $pickCallback = getUnquotedParameter('pickCallback'); $type = getUnquotedParameter('type'); $button = getUnquotedParameter('button'); $buttonCallback = getUnquotedParameter('ButtonCallBack'); $target = getUnquotedParameter('target'); $preloadscript = checkPreloadScript(); $script = getRawParameter('script'); $script = convertSemicolonNewline($script); $altscript = convertSemicolonNewline(getRawParameter('altscript')); writePrevious($previous); writeCommentedEmbed(); # dumpVars(); writeJmolApplet() unless $button; writeButtonControl() if $button; } sub checkPreloadScript { my $spinX = getUnquotedParameter('spinx'); my $spinY = getUnquotedParameter('spiny'); my $spinZ = getUnquotedParameter('spinz'); my $startspin = getUnquotedParameter('startspin'); my $frank = getUnquotedParameter('frank'); my $debugscript = getUnquotedParameter('debugscript'); my $preloadscript = getUnquotedParameter('preloadscript'); $preloadscript = convertSemicolonNewline($preloadscript); $preloadscript .= "set spin x $spinX;" if $spinX; $preloadscript .= "set spin y $spinY;" if $spinY; $preloadscript .= "set spin z $spinZ;" if $spinZ; $preloadscript .= "set spin on;" if $startspin =~ /true|yes|on/i; $preloadscript .= "set frank $frank;" if $frank; $preloadscript .= "set debugscript $debugscript;" if $debugscript; return $preloadscript; } sub dumpVars { print <\n"; } sub writeJmolApplet { print OUTPUT " \n"; print OUTPUT " \n"; print OUTPUT " \n" if $bgcolor; print OUTPUT " \n" if $src; print OUTPUT " \n" if $preloadscript; print OUTPUT " \n" if $script; print OUTPUT " \n" if $loadStructCallback; print OUTPUT " \n" if $messageCallback; print OUTPUT " \n" if $pauseCallback; print OUTPUT " \n" if $pickCallback; print OUTPUT " \n"; } sub writeButtonControl { my ($controlType, $group); if ($button =~ /push/i) { $controlType = "chimePush"; } elsif ($button =~ /toggle/i) { $controlType = "chimeToggle"; } elsif ($button =~ /radio(\d+)/i) { $controlType = "chimeRadio"; $group = $1; } my $buttonScript = $script || $src; print OUTPUT " \n"; print OUTPUT " \n". " \n"; print OUTPUT " \n" if $group; print OUTPUT " \n" if $buttonScript; print OUTPUT " \n" if $altscript; print OUTPUT " \n" if $buttonCallback; print OUTPUT " \n"; } sub getRawParameter { my ($tag) = @_; for (my $i = 0; $i < $tokenCount; ++$i) { my $token = $tokens->[$i]; return $tokens->[$i + 1] if ($token =~ /$tag/i); } return undef; } sub getUnquotedParameter { my $value = getRawParameter(@_); return undef unless $value; $value =~ s/^[\'\"]//; $value =~ s/[\'\"]$//; return $value; } sub convertNewline { my ($text) = @_; $text =~ s/\r\n/\n/g; $text =~ s/\r/\n/g; return $text; } sub convertSemicolonNewline { my ($text) = @_; $text = convertNewline($text); $text =~ s/\n/;\n/g; return $text; } sub usage { print < -d {-c} {-a } -s -d -c Clear destination directory -a specify alternate archive name -b specify codebase -v Verbose END exit; } jmol-12.2.32+dfsg2.orig/appletweb/ChimeToJmol_old.js0000644000175000017500000002417411771706307021404 0ustar mbanckmbanck/* ChimeToJmol.js hansonr@stolaf.edu 8:07 AM 4/21/2010 Changes by A.Herraez 26 April 2010 A set of functions that will (when fully developed) allow the following on just about any Chime page to convert the Chime EMBED tags to Jmol applets and buttons. Also changes older Jmol "applet" code to use Jmol.js 1) add these lines to your page's section: 2) Set jmolDirectory (below) to the desired directory and load it with the standard Jmol files (Jmol.js, JmolApplet*.jar) and ChimeToJmol.js 3) If you are using a BODY onload="funcName()" attribute already, then add checkJmol() to it. 4) If you want to test your page, add NOJMOL to the page URL TODO: more script conversions needed for Chime. done # default Jmol Ball&Stick vs. defalt Chime wireframe # default orientation / axes - are different, but also depend on file format (Chime PDB, Chime MOL, Jmol both) done # embed tag options: display3d, color3d, bgcolor, hbonds, ssbonds, frank, hide popup menu, ... done # zoom (partially done, not foolproof; needs testing in different situations) done # Hbonds on , Hbonds N need previous calculate # external script files cannot be parsed and fixed: manual edit seems necessary */ // set this as desired var jmolDirectory = "./Jmol" /////////Jmol section ////////// function checkJmol() { if (document.location.search.indexOf("NOJMOL") >= 0)return var body = document.body.innerHTML if (body.indexOf("JmolApplet") >= 0) { if(body.indexOf("JmolAppletControl") >= 0)__fixJmol() return } if (body.indexOf("= 0 || body.indexOf("= 0) __fixChime() } window.onload = checkJmol function __fixJmol() { var body = document.body.innerHTML var ptAPPLET = -1 var Text = body.split("") if (text.indexOf("JmolAppletControl") >= 0) { Text[i] = __jmolFixJmolAppletControl(text.substring(0, pt)) + text.substring(pt + 9) } else if (text.indexOf("JmolApplet") >= 0) { Text[i] = __jmolFixJmolApplet(text.substring(0, pt)) + text.substring(pt + 9) } else { Text[i] = "" + jmolButton(A.script,"X",A.target) + "" } ///////// Chime section ////////// function __fixChime() { jmolInitialize(jmolDirectory, (document.location.protocol=="file:" ? "JmolAppletSigned0.jar" : "JmolApplet0.jar")) jmolSetDocument(0) jmolSetButtonCssClass("JmolChimeButton") var body = document.body.innerHTML var Text = body.split("") if (text.substring(0,pt).indexOf("src=") >= 0) { Text[i] = __jmolFixChimeApplet(text.substring(0, pt)) + text.substring(pt + 1) } else if (text.substring(0,pt).indexOf("button=") >= 0) { Text[i] = __jmolFixChimeButton(text.substring(0, pt)) + text.substring(pt + 1) } } document.body.innerHTML = Text.join("") } function __jmolFixChimeApplet(tag) { var A = __jmolGetAttributes(tag) var zoomSet = null var s = "spacefill off;wireframe on;" if (__jmolIsChimeFalse(A.frank)) s += "frank off;" if (__jmolIsChimeTrue(A.nomenus)) s += "set disablePopupMenu on;" if (A.display3d) s += __jmolFixChimeDisplay3d(A.display3d) if (A.color3d) s += __jmolFixChimeColor3d(A.color3d) if (A.bgcolor) s += __jmolFixChimeBgcolor(A.bgcolor) if (A.spinx || A.spiny || A.spinz) s += "set spinX 0; set spinY 0; set spinZ 0;" // in Chime, setting any spin cancels the default 0 10 0; in Jmol, it does not if (A.spinx) s += "set spinX " + A.spinx + ";" if (A.spiny) s += "set spinY " + A.spiny + ";" if (A.spinz) s += "set spinZ " + A.spinz + ";" if (A.spinfps) s += "set spinFps " + A.spinfps + ";" if (__jmolIsChimeTrue(A.startspin)) s += "spin on;" if (A.hbonds && A.hbonds!="off") s += "hbonds calculate; hbonds " + A.hbonds + ";" if (A.ssbonds) s += "ssbonds " + A.ssbonds + ";" if (A.animmode) s += "animation mode " + A.animmode + ";" if (A.animfps) s += "animation fps " + A.animfps + ";" if (__jmolIsChimeTrue(A.startanim)) s += "animation on;" // if Chime size was set in pixels, let's do an approximated zoom conversion: store width and pass it to the script parser if (A.width.indexOf("%")==-1) { A.width = parseInt(A.width); zoomSet = A.width } if (A.height.indexOf("%")==-1) { A.height = parseInt(A.height) } if (!A.script || A.script.indexOf("zoom ")==-1) { zoomSet=null } A.script = (A.script ? __jmolFixChimeScript(A.script,zoomSet) : "") return jmolApplet([A.width,A.height],"load \"" + A.src + "\";" + s + A.script, A.name) } function __jmolFixChimeButton(tag) { var A = __jmolGetAttributes(tag) A.script = (A.script ? __jmolFixChimeScript(A.script) : "") if(A.target) jmolSetTarget(A.target) A.button = A.button.toLowerCase() // 'button' may be push|pushed|radio#|toggle|followed if (A.button=="followed" || A.button=="push" || A.button=="pushed") { if (!A.height)A.height = 12 return '' + jmolButton(A.script,"X") + '' } if (A.button=="toggle") { A.altscript = (A.altscript ? __jmolFixChimeScript(A.altscript) : "") return jmolCheckbox(A.script,A.altscript,"") } if (A.button.indexOf("radio")!=-1) { return jmolRadio(A.script, "", false, "", "Chime"+A.button) } return jmolLink(A.script,"[x]") //this shouldn't be reached } function __jmolFixChimeScript(script,isZoomSet) { script = script//.replace(/\*\./g,"_") .replace(/hbonds /,"hbonds calculate;hbonds ") .replace(/\>/g, ">").replace(/\</g, "<") // angle brackets are read as & entities and may be used in scripts as less than / more than // if Chime size was set in pixels, we'll do an approximated zoom conversion: // Chime zoom value divided by Chime width gives an idea of the needed zoom value (percent) var j1 = script.indexOf("zoom ") if (j1!=-1 && isZoomSet) { var j2 = script.substring(j1).indexOf(";") if (j2==-1) { j2=script.length-j1 } var z = parseInt(script.substring(j1+5,j1+j2)) // this is the Chime zoom value script = script.substring(0,j1) + "zoom " + parseInt(z/isZoomSet*100) + script.substring(j1+j2) } return script } function __jmolFixChimeDisplay3d(v) { if (v=="spacefill") return "spacefill on;wireframe off;" if (v=="sticks") return "spacefill off;wireframe 0.15;" if (v=="wireframe") return "spacefill on;wireframe on;" if (v=="ball&stick") return "spacefill 30%;wireframe 0.15;" if (v=="cartoons") return "spacefill off;wireframe off;cartoons on;" if (v=="ribbons") return "spacefill off;wireframe off;ribbons on;" if (v=="strands") return "spacefill off;wireframe off;strands on;" } function __jmolFixChimeBgcolor(v) { if (v.charAt(0)=="#") v = "[x" + v.substring(1) + "]" return "color background " + v + ";" } function __jmolFixChimeColor3d(v) { if (v=="monochrome" || v=="user") v="white" return "color " + v + ";" //color3d = {chain|cpk|group|monochrome|shapely|structure|temperature|user} } function __jmolGetAttributes(tag) { var S = {} var name = "" var value = "" var inName = false var inValue = false if (tag.indexOf("= 0) tag = tag.replace(/\/g, " ") .replace(/\>/g, " ") .replace(/[\r|\n|\t]/g, " ") if (tag.substring(tag.length-1, tag.length) == "/") tag = tag.substring(0, tag.length-1) tag = tag.replace(/\/g, " ") tag = tag.replace(/\
/g, " ") tag = tag.replace(/\s+\=/g, "=") tag = tag.replace(/\=\s+/g, "=") tag += " =" for (var i = 0; i < tag.length - 2; i++) { switch(tag.charAt(i)) { case " ": case "\t": case "\n": case "\r": continue } var pts = tag.indexOf(" ", i) var pte = tag.indexOf("=", i) var ptq = tag.indexOf("'", pte + 1) var ptqq = tag.indexOf("\"", pte + 1) if (ptqq == pte + 1)ptq = ptqq var ptq2 = tag.indexOf((ptq == ptqq ? "\"" : "'"), ptq + 1) // .JmolChimeButton { background-color:#C0C0C0; border:1px outset #C0C0C0; padding:0; font:inherit; } <' + '/style>') jmol-12.2.32+dfsg2.orig/appletweb/SystemGetProperty.java0000644000175000017500000000224111771706307022361 0ustar mbanckmbanck/* $RCSfile$ * $Author: migueljmol $ * $Date: 2005-03-30 18:08:59 +0200 (mer., 30 mars 2005) $ * $Revision: 3483 $ * * Copyright (C) 2005 Miguel, The Jmol Development Team * * Contact: miguel@jmol.org * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * 02111-1307 USA. */ import java.applet.*; public class SystemGetProperty extends Applet { public String systemGetProperty(String propertyName) { return System.getProperty(propertyName); } } jmol-12.2.32+dfsg2.orig/appletweb/ChimeToJmol.js0000644000175000017500000002001711771706307020536 0ustar mbanckmbanck/* ChimeToJmol.js hansonr@stolaf.edu 8:07 AM 4/21/2010 # last update 10/18/2010 7:24:31 AM A set of functions that will (when fully developed) allow just about any Chime page to be converted automatically from Chime EMBED tags to Jmol applets and buttons. Also changes older Jmol "applet" code to use Jmol.js 1) Set jmolDirectory (below) to the desired directory to contain the standard Jmol files (Jmol.js, JmolApplet*.jar) as well as this file, ChimeToJmol.js and add those files to it. 2) add these lines to your page's section (with the appropriate directory, if needed): 3) If you are using a BODY onload="funcName()" attribute already, then add checkJmol() to it. 4) If you want to test your page, add "?NOJMOL" to the page URL TODO: more script conversions needed for Chime */ // set this as desired var jmolDirectory = "." var useSignedApplet = false // still, always uses signed applet for LOCAL testing //jmolDebugAlert() // You will probably have to adjust this next function // to include more cases. These are just an example of the sort // of fixes that need to be done to convert Chime scripts to Jmol scripts function __jmolFixChimeScript(script) { script = "set defaultLoadScript 'wireframe only;rotate x 180;';" + script //.replace(/\*\./g,"_") // as in *.C, *.H, for some small-molecular installations .replace(/stick on/g,"wireframe 0.15;") .replace(/ball\&\;stick off/g,"wireframe off;spacefill off") .replace(/select startanim\=false/g,"animation off") .replace(/select startanim\=true/g,"animation play") .replace(/set cartoon/g,"#set cartoon") .replace(/reset/g,"reset;rotate x 180") .replace(/rotate z\s+/g,"rotate z -") .replace(/ --/g," ") .replace(/set shadow/g,"#set shadow") return script } function __jmolGenericCallback(a, b, c, d, e) { b || (b = "") c || (c = "") d || (d = "") e || (e = "") alert([a, b, c, d, e].join("\n\n")) } /////////Jmol section ////////// function checkJmol() { if (top.location.search.indexOf("NOJMOL") >= 0)return var body = document.body.innerHTML if (body.indexOf("JmolApplet") >= 0) { if(body.indexOf("JmolAppletControl") >= 0)__fixJmol() return } if (body.indexOf("= 0 || body.indexOf("= 0) __fixChime() } window.onload = checkJmol function __fixJmol() { var body = document.body.innerHTML var ptAPPLET = -1 var Text = body.split("") if (text.indexOf("JmolAppletControl") >= 0) { Text[i] = __jmolFixJmolAppletControl(text.substring(0, pt)) + text.substring(pt + 9) } else if (text.indexOf("JmolApplet") >= 0) { Text[i] = __jmolFixJmolApplet(text.substring(0, pt)) + text.substring(pt + 9) } else { Text[i] = "" + jmolButton(A.script,"X",A.target) + "" } function __fixChime() { jmolInitialize(jmolDirectory, (document.location.protocol=="file:" || useSignedApplet ? "JmolAppletSigned0.jar" : "JmolApplet0.jar")) jmolSetDocument(0) var body = document.body.innerHTML body = body.replace(/XEMBED/g,"xembed") var Text = body.split("= 0;pt++) { switch (text.charAt(pt)) { case '"': case "'": iq += 1 break case '>': if (iq%2==0) { iq = -1 } } if (iq < 0) break; } var isButton = (text.indexOf("target=") >= 0) if (isButton) { Text[i] = __jmolFixChimeButton(text.substring(0, pt), i) + text.substring(pt + 1) } else { Text[i] = __jmolFixChimeApplet(text.substring(0, pt)) + text.substring(pt + 1) } } document.body.innerHTML = Text.join("") } function __jmolFixChimeApplet(tag) { var A = __jmolGetAttributes(tag) if (A.width.indexOf("%") < 0) A.width = parseInt(A.width) if (A.height.indexOf("%") < 0) A.height = parseInt(A.height) A.script = (A.script ? __jmolFixChimeScript(A.script) : "") if (A.animmode) A.script += ";animation mode " + A.animmode + ";" if (A.animfps) A.script += ";animation fps " + A.animfps + ";" if (A.startanim && A.startanim.toLowerCase() == "true") A.script += ";animation on;" if (A.src.indexOf(".spt")>= 0) { A.src = 'chimeScript = load("' + A.src + '"); javascript "__jmolRunChimeScript(\''+A.name+'\')";' } else { A.src = "load = \"" + A.src + "\";" } if (A.name) jmolSetTarget(A.name) var s = jmolApplet([A.width,A.height],A.src + A.script + ";set errorCallback '__jmolGenericCallback'", A.name) return s } function __jmolRunChimeScript(target) { var script = jmolEvaluate('chimeScript', target) script = __jmolFixChimeScript(script) jmolScript(script, target); } function __jmolFixChimeButton(tag, iBtn) { var A = __jmolGetAttributes(tag, iBtn) if (!A.width)A.width = 12 if (!A.height)A.height = 12 if (A.src) { A.script = 'chimeScript = load("' + A.src + '"); javascript "__jmolRunChimeScript(\''+A.target+'\')"' } else { A.script = __jmolFixChimeScript(A.script) } jmolSetTarget(A.target) var s = "" + jmolLink(A.script,"[x]", Math.random(), A.script.replace(/\"/g,"'")) + " " return s } function __jmolGetAttributes(tag, iBtn) { var S = {} var name = "" var value = "" var inName = false var inValue = false tag = tag.replace(/\/g, " ") tag = tag.replace(/\
/g, " ") if (tag.substring(tag.length-1, tag.length) == "/") tag = tag.substring(0, tag.length-1) if (tag.indexOf("= 0) tag = tag.replace(/\/g, " ") .replace(/\>/g, " ") tag = tag.replace(/\s+/g, " ") tag = tag.replace(/ \=/g, "=") tag = tag.replace(/\= /g, "=") tag += " =" for (var i = 0; i < tag.length - 2; i++) { if (tag.charAt(i) == " ") continue var pts = tag.indexOf(" ", i) var pte = tag.indexOf("=", i) var ptq = tag.indexOf("'", pte + 1) var ptqq = tag.indexOf("\"", pte + 1) if (ptqq == pte + 1)ptq = ptqq var ptq2 = tag.indexOf((ptq == ptqq ? "\"" : "'"), ptq + 1) if (pts < pte) { // param('url'); if (! $url) { print $cgi->header(-type=>'text/plain' -status=>'404 Not Found'); } my $userAgent = LWP::UserAgent->new; $userAgent->agent("JmolAppletProxy/1.0"); my $request = HTTP::Request->new(GET => $url); my $response = $userAgent->request($request); if ($response->is_success()) { print $cgi->header(-type=>'text/plain'), $response->content(); } else { print $cgi->header(-type=>'text/plain' -status=>$response->status_line); print $response->status_line; } jmol-12.2.32+dfsg2.orig/appletweb/Jmol-10.js0000644000175000017500000006532511771706307017516 0ustar mbanckmbanck/* $RCSfile$ * $Author: hansonr $ * $Date: 2006-09-14 19:13:51 +0200 (jeu., 14 sept. 2006) $ * $Revision: 5543 $ * * Copyright (C) 2004-2005 Miguel, Jmol Development, www.jmol.org * * Contact: miguel@jmol.org * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * 02111-1307 USA. */ // for documentation see www.jmol.org/jslibrary var undefined; // for IE 5 ... wherein undefined is undefined //////////////////////////////////////////////////////////////// // Basic Scripting infrastruture //////////////////////////////////////////////////////////////// function jmolInitialize(codebaseDirectory, useSignedApplet) { if (_jmol.initialized) { alert("jmolInitialize() should only be called *ONCE* within a page"); return; } if (! codebaseDirectory) { alert("codebaseDirectory is a required parameter to jmolInitialize"); codebaseDirectory = "."; } if (codebaseDirectory.indexOf("http://") == 0 || codebaseDirectory.indexOf("https://") == 0) alert("An absolute URL is not recommended for codebaseDirectory.\n" + "A directory or docroot relative reference is recommended.\n\n" + "If you are experienced enough to go 'off piste' then you\n" + "can override this warning by inserting a space before\n" + "http in your URL."); _jmolSetCodebase(codebaseDirectory); _jmolUseSignedApplet(useSignedApplet); _jmolOnloadResetForms(); _jmol.initialized = true; } function jmolSetDocument(doc) { _jmol.currentDocument = doc; } function jmolSetAppletColor(boxbgcolor, boxfgcolor, progresscolor) { _jmolInitCheck(); _jmol.boxbgcolor = boxbgcolor; if (boxfgcolor) _jmol.boxfgcolor = boxfgcolor else if (boxbgcolor == "white" || boxbgcolor == "#FFFFFF") _jmol.boxfgcolor = "black"; else _jmol.boxfgcolor = "white"; if (progresscolor) _jmol.progresscolor = progresscolor; if (_jmol.debugAlert) alert(" boxbgcolor=" + _jmol.boxbgcolor + " boxfgcolor=" + _jmol.boxfgcolor + " progresscolor=" + _jmol.progresscolor); } function jmolApplet(size, script, nameSuffix) { _jmolInitCheck(); return _jmolApplet(size, null, script, nameSuffix); } //////////////////////////////////////////////////////////////// // Basic controls //////////////////////////////////////////////////////////////// function jmolButton(script, label, id) { _jmolInitCheck(); if (id == undefined || id == null) id = "jmolButton" + _jmol.buttonCount; if (label == undefined || label == null) label = script.substring(0, 32); ++_jmol.buttonCount; var scriptIndex = _jmolAddScript(script); var t = ""; if (_jmol.debugAlert) alert(t); return _jmolDocumentWrite(t); } function jmolCheckbox(scriptWhenChecked, scriptWhenUnchecked, labelHtml, isChecked, id) { _jmolInitCheck(); if (id == undefined || id == null) id = "jmolCheckbox" + _jmol.checkboxCount; ++_jmol.checkboxCount; if (scriptWhenChecked == undefined || scriptWhenChecked == null || scriptWhenUnchecked == undefined || scriptWhenUnchecked == null) { alert("jmolCheckbox requires two scripts"); return; } if (labelHtml == undefined || labelHtml == null) { alert("jmolCheckbox requires a label"); return; } var indexChecked = _jmolAddScript(scriptWhenChecked); var indexUnchecked = _jmolAddScript(scriptWhenUnchecked); var t = "" + labelHtml; if (_jmol.debugAlert) alert(t); return _jmolDocumentWrite(t); } function jmolRadioGroup(arrayOfRadioButtons, separatorHtml, groupName) { _jmolInitCheck(); var type = typeof arrayOfRadioButtons; if (type != "object" || type == null || ! arrayOfRadioButtons.length) { alert("invalid arrayOfRadioButtons"); return; } if (separatorHtml == undefined || separatorHtml == null) separatorHtml = "  "; var length = arrayOfRadioButtons.length; var t = ""; jmolStartNewRadioGroup(); for (var i = 0; i < length; ++i) { var radio = arrayOfRadioButtons[i]; type = typeof radio; if (type == "object") { t += _jmolRadio(radio[0], radio[1], radio[2], separatorHtml, groupName); } else { t += _jmolRadio(radio, null, null, separatorHtml, groupName); } } if (_jmol.debugAlert) alert(t); return _jmolDocumentWrite(t); } function jmolLink(script, label, id) { _jmolInitCheck(); if (id == undefined || id == null) id = "jmolLink" + _jmol.linkCount; if (label == undefined || label == null) label = script.substring(0, 32); ++_jmol.linkCount; var scriptIndex = _jmolAddScript(script); var t = "" + label + ""; if (_jmol.debugAlert) alert(t); return _jmolDocumentWrite(t); } function jmolMenu(arrayOfMenuItems, size, id) { _jmolInitCheck(); if (id == undefined || id == null) id = "jmolMenu" + _jmol.menuCount; ++_jmol.menuCount; var type = typeof arrayOfMenuItems; if (type != null && type == "object" && arrayOfMenuItems.length) { var length = arrayOfMenuItems.length; if (typeof size != "number" || size == 1) size = null; else if (size < 0) size = length; var sizeText = size ? " size='" + size + "' " : ""; var t = "" + labelHtml + separatorHtml; } function _jmolFindApplet(target) { // first look for the target in the current window var applet = _jmolSearchFrames(window, target); if (applet == undefined) applet = _jmolSearchFrames(top, target); // look starting in top frame return applet; } function _jmolSearchFrames(win, target) { var applet; var frames = win.frames; if (frames && frames.length) { // look in all the frames below this window for (var i = 0; i < frames.length; ++i) { applet = _jmolSearchFrames(frames[i], target); if (applet) break; } } else { // look for the applet in this window var doc = win.document; // getElementById fails on MacOSX Safari & Mozilla if (_jmol.useHtml4Object || _jmol.useIEObject) applet = doc.getElementById(target); else if (doc.applets) applet = doc.applets[target]; else applet = doc[target]; } return applet; } function _jmolAddScript(script) { if (! script) return 0; var index = _jmol.scripts.length; _jmol.scripts[index] = script; return index; } function _jmolClick(scriptIndex, targetSuffix) { jmolScript(_jmol.scripts[scriptIndex], targetSuffix); } function _jmolMenuSelected(menuObject, targetSuffix) { var scriptIndex = menuObject.value; if (scriptIndex != undefined) { jmolScript(_jmol.scripts[scriptIndex], targetSuffix); return; } var length = menuObject.length; if (typeof length == "number") { for (var i = 0; i < length; ++i) { if (menuObject[i].selected) { _jmolClick(menuObject[i].value, targetSuffix); return; } } } alert("?Que? menu selected bug #8734"); } function _jmolCbClick(ckbox, whenChecked, whenUnchecked, targetSuffix) { _jmolClick(ckbox.checked ? whenChecked : whenUnchecked, targetSuffix); } function _jmolCbOver(ckbox, whenChecked, whenUnchecked) { window.status = _jmol.scripts[ckbox.checked ? whenUnchecked : whenChecked]; } function _jmolMouseOver(scriptIndex) { window.status = _jmol.scripts[scriptIndex]; } function _jmolMouseOut() { window.status = " "; return true; } function _jmolSetCodebase(codebase) { _jmol.codebase = codebase ? codebase : "."; if (_jmol.debugAlert) alert("jmolCodebase=" + _jmol.codebase); } function _jmolOnloadResetForms() { _jmol.previousOnloadHandler = window.onload; window.onload = function() { with (_jmol) { if (buttonCount+checkboxCount+menuCount+radioCount+radioGroupCount > 0) { var forms = document.forms; for (var i = forms.length; --i >= 0; ) forms[i].reset(); } if (previousOnloadHandler) previousOnloadHandler(); } } } jmol-12.2.32+dfsg2.orig/appletweb/Jmol.js0000644000175000017500000016463511771706307017304 0ustar mbanckmbanck/* Jmol 12.0 script library Jmol.js 9:48 PM 1/31/2011 Bob Hanson checkbox heirarchy -- see http://chemapps.stolaf.edu/jmol/docs/examples-11/check.htm based on: * * Copyright (C) 2004-2005 Miguel, Jmol Development, www.jmol.org * * Contact: hansonr@stolaf.edu * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * 02111-1307 USA. */ // for documentation see www.jmol.org/jslibrary try{if(typeof(_jmol)!="undefined")exit() // place "?NOAPPLET" on your command line to check applet control action with a textarea // place "?JMOLJAR=xxxxx" to use a specific jar file // bob hanson -- jmolResize(w,h) -- resizes absolutely or by percent (w or h 0.5 means 50%) // angel herraez -- update of jmolResize(w,h,targetSuffix) so it is not tied to first applet // bob hanson -- jmolEvaluate -- evaluates molecular math 8:37 AM 2/23/2007 // bob hanson -- jmolScriptMessage -- returns all "scriptStatus" messages 8:37 AM 2/23/2007 // bob hanson -- jmolScriptEcho -- returns all "scriptEcho" messages 8:37 AM 2/23/2007 // bob hanson -- jmolScriptWait -- 11:31 AM 5/2/2006 // bob hanson -- remove trailing separatorHTML in radio groups -- 12:18 PM 5/6/2006 // bob hanson -- adds support for dynamic DOM script nodes 7:04 AM 5/19/2006 // bob hanson -- adds try/catch for wiki - multiple code passes 7:05 AM 5/19/2006 // bob hanson -- auto-initiates to defaultdir/defaultjar -- change as desired. // bob hanson -- adding save/restore orientation w/ and w/o delay 11:49 AM 5/25/2006 // bob hanson -- adding AjaxJS service 11:16 AM 6/3/2006 // bob hanson -- fix for iframes not available for finding applet // bob hanson -- added applet fake ?NOAPPLET URL flag // bob hanson -- added jmolSetCallback(calbackName, funcName) 3:32 PM 6/13/2006 // used PRIOR to jmolApplet() or jmolAppletInline() // added 4th array element in jmolRadioGroup -- title // added and id around link, checkbox, radio, menu // fixing AJAX loads for MSIE/Opera-Mozilla incompatibility // -- renamed Jmol-11.js from Jmol-new.js; JmolApplet.jar from JmolAppletProto.jar // renamed Jmol.js for Jmol 11 distribution // -- modified jmolRestoreOrientation() to be immediate, no 1-second delay // bob hanson -- jmolScriptWait always returns a string -- 11:23 AM 9/16/2006 // bh -- jmolCommandInput() // bh -- jmolSetTranslation(TF) -- forces translation even if there might be message callback issues // bh -- minor fixes suggested by Angel // bh -- adds jmolSetSyncId() and jmolGetSyncId() // bh 3/2008 -- adds jmolAppendInlineScript() and jmolAppendInlineArray() // bh 3/2008 -- fixes IE7 bug in relation to jmolLoadInlineArray() // bh 6/2008 -- adds jmolSetAppletWindow() // Angel H. 6/2008 -- added html