Bugs item #1455866, was opened at 2006-03-22 06:52
Message generated for change (Settings changed) made by nicove
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=379133&aid=1455866&group_id=23629

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
>Status: Closed
Resolution: None
Priority: 5
Submitted By: Einar Coutin (einarc)
Assigned to: Nobody/Anonymous (nobody)
Summary: Jmol and Javascript

Initial Comment:
Hello.

Could it be posible to pass variables between
applications, like the actual script selected in a
JmolMenu object to a jmolLink. I've created a function
to make a clickable image in Jmol.js based on the
jmolLink function. I use it to load new data into the
applet, I would like to pass data from other controls,
like menus into this function along with the script I
use it for.

For example the value propertie from the select in the
jmolMenu function is an script Index instead of the
actual value.

I could do this by calling some objects in javascript
within a function:

document.myform.jmolMenux.options[document.myform.jmolMenux.selectedIndex].value;

 but that doesn't return anythin.

If for example i pass the document.myform.jmolMenux as
a variable to the new function, wheter in Jmol.js or in
the html page if I try to return the typeof that
variable, it says its an object, but If i try to read
the variable itself it says its am [object]

PLz need advice form someone with javascript experience.

It makes the same effect if I pass two variables with
the form and the select jmolMenu 


----------------------------------------------------------------------

Comment By: Einar Coutin (einarc)
Date: 2006-03-24 18:27

Message:
Logged In: YES 
user_id=1475990

Hey thanks for the suggestion, did this and guess what? It
worked!!!

<a name="imagen viagra" id="imagenviagra"
href='javascript:jmolScript("load
../jmol/datos/moleculas/viagra.xyz"+";"+jmolSelectValue(spacefiller,menu.selectedIndex))'><img
width=53 height=60 src="imagenes/viagra.jpeg"></a>

Tx a LOT.

the jmolSelectValue is in my Jmol.js

Anyway it'll be great to implement it using Jmol.js


----------------------------------------------------------------------

Comment By: Einar Coutin (einarc)
Date: 2006-03-24 16:25

Message:
Logged In: YES 
user_id=1475990

Hey thats great news... If you do know how to do it please
post it, it doesn't matter if is not using the Jmol.js
script file. 
Plese next time log in so I can directly email you. I know
the system has some missinterfaced linking but you can clik
in the lower parts of the email to get automatically logged in.

----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2006-03-24 02:46

Message:
Logged In: NO 

hi Einar,

I am not familiar with Jmol.js, so I can't be of much help here. (I could tell 
you 
how to do it without Jmol.js, but that may not be useful for you.)

I suggest that you post your question directly to the Jmol-users list; a lot of 
folks do use Jmol.js and you will probably find your answer quickly.

best,

tim d.

----------------------------------------------------------------------

Comment By: Einar Coutin (einarc)
Date: 2006-03-23 20:13

Message:
Logged In: YES 
user_id=1475990

Ok thanks for the tip, I did some reading and using an array
I managed to pass the selected value to the function.

Anyway Here is What I want.

I want to crate a clickable image that loads new data into
the applet and also sends some other configuration
parameters as scripts along with the load command. In this
particular case it'll be spacefill information coming from
another control (a JmolMenu):

 i.e.:

I create a jmolMenu instance on my html page by doin:
jmolMenu(array,1,"menuname"), then by using the
document.formname.menuname.selectedIndex propertie I can
pass to the image control wich option of the select is
actually selected so when I click on the image it will pass
that option to be added to the load script command for the
applet, so when I click the image it will send this:
load ../jmol/molecule.xyz;select option. Where select option
can be one of this: spacefill off, spacefill 20%, etc.

Here are the function and the call from the html page:

function jmolImageLoader3(script, src,id, list, value){
_jmolInitCheck();
var scriptIndex = _jmolAddScript(script);
if (id == undefined || id == null)
    id = "jmolImageLoader3" + _jmol.ImageLoader3Count;
    ++ _jmol.ImageLoader3Count;
    
var t = "<img width=53 height=60 name='" + id + "' id='" + id + 
          "' onclick='javascript:_jmolClick(" +
"_jmolAddScript(" + script + ";" + list[value][0] + ")"
          + _jmol.targetText +
          ");' onMouseover='_jmolMouseOver(" +
"_jmolAddScript(" + script + ";" + list[value][0] + ")"
          + _jmol.targetText +
          ");return true;' onMouseout='_jmolMouseOut()' " +
          _jmol.linkCssText + ">" + "src=" + src + ">"
     if (_jmol.debugAlert)
    alert(t);
  document.write(t);                    
}


and the call:
jmolImageLoader2("load
../jmol/datos/moleculas/viagra.xyz","imagenes/viagra.jpeg","imagenviagra",spacefiller,menu.selectedIndex);


Description as follows:

menu is declared as this:
 var menu =document.tamanos.menutam So tamanos is the form
name and menutam is the jmolMenu or actual select name and id.

spacefiller is an array containing the options for the jmolMenu.
i.e.
spacefiller = [["spacefill off","off"], ["spacefill 20%",
"20%"]]


The problem is when I do the onclik='javascript:_jmolClick
thingy...
it seems that you cant pass functions as variables inside
another function, like in C where I can go like.
function myfunction (anotherfunction(var1, var2))

I send a zip file with the site. (only the html, the images
and the Javascript file), the applet and data are missing.
Space reasons


----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2006-03-22 07:03

Message:
Logged In: NO 

hi,

it has been a while, but I think you need to do this with a loop.  something 
like this:

for (var i=0; i<document.myform.jmolMenux.options.length; i++) {
   if (document.myform.jmolMenux.options.selected) {
      value = document.myform.jmolMenux.options[i].value;
      break;
   }
}

hth,

tim d

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=379133&aid=1455866&group_id=23629


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Jmol-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-developers

Reply via email to