X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=examples%2Fjavascript%2Fjalview.js;h=7995ddb787a766958c851102572ac3ec8e5614a0;hb=17e77c3f2949a0729322b4a8d907f3f34b6a9914;hp=293b73a0da00ce277828df6f53688076e5fecdab;hpb=b2f9a8d7bce642ff4011bc6d49e02bb0569fbb11;p=jalview.git diff --git a/examples/javascript/jalview.js b/examples/javascript/jalview.js index 293b73a..7995ddb 100644 --- a/examples/javascript/jalview.js +++ b/examples/javascript/jalview.js @@ -1,6 +1,6 @@ /** - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.1) - * Copyright (C) 2014 The Jalview Authors + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9) + * Copyright (C) 2015 The Jalview Authors * * This file is part of Jalview. * @@ -17,6 +17,14 @@ * The Jalview Authors are detailed in the 'AUTHORS' file. */ + + + + + + + + // default console to report messages var _console = document.getElementById("stdout"); var _jvapps = new Array(); @@ -27,6 +35,21 @@ var _modeltofiles = new Array(); // counter for jmol structures var mnum = 1; +function getDocumentBase() { + var dburi = document.baseURI; + // IE does not support document.baseURI + // logic from patch to TYPO3: + // http://forge.typo3.org/projects/typo3cms-core/repository/revisions/f61358afad28adb6dcaeb270ba480e998dfb0b79/diff/typo3/sysext/rtehtmlarea/htmlarea/htmlarea.js + if (!dburi) { + var baseTags = document.getElementsByTagName('base'); + if (baseTags.length > 0) { + dburi = baseTags[0].href; + } else { + dburi = document.URL; + } + } + return dburi.substring(0, dburi.lastIndexOf("/") + 1); +} function setConsole(console) { _console = console; } @@ -130,7 +153,7 @@ function linkJvJmol(applet, jmolView, modeltofiles) { var sep = applet.getSeparator(); var oldjm=jmolView; // recover full id of Jmol applet - jmolView=_jmolGetApplet(jmolView).id; + jmolView=jmolFindTarget(jmolView)._id; // Jmol 14.2.14 var jmbinding=_jvjmols.get(jmolView); if (!jmbinding) { @@ -147,7 +170,7 @@ function linkJvJmol(applet, jmolView, modeltofiles) { jmbinding._jmol=jmolView; // now update structureListener list mtf=""; - var dbase = document.baseURI.substring(0,document.baseURI.lastIndexOf("/")+1); + var dbase = getDocumentBase(); for (m in jmbinding._modelstofiles) { if (m>0) { mtf+=sep; } mtf+=jmbinding._modelstofiles[m]; @@ -190,10 +213,8 @@ function _structure(list1, list2, list3, list4) { ("" + list4)); // 1 is pdb file, 2 is residue number, 3 is chain // list1 = new Object(list1); - var base = list[1].indexOf(document.baseURI - .substring(0, document.baseURI.lastIndexOf('/')) - ); // .indexOf(_path); - if (base==0) { base = document.baseURI.lastIndexOf('/'); } + var base = list[1].indexOf(getDocumentBase()); // .indexOf(_path); + if (base==0) { base = getDocumentBase(); } var sid = list[1]; // .substring(base); base = list[1].substring(0, base); if (_console) { @@ -298,8 +319,7 @@ function _jmolhover(jmid, atomlabel, atomidx) { // use atomlabel[5] to look up model filename so we can highlight associated positions in any jalviews for (ap in _jvapps) { _jvapps[ap].mouseOverStructure(atomlabel[2], atomlabel[3], - document.baseURI - .substring(0, document.baseURI.lastIndexOf('/')) + getDocumentBase() + "/" + modeltofiles[atomlabel[5]]); msg = _jmolhovermsg; @@ -326,3 +346,37 @@ function _jmolMessagecallback(jmid, statmess) { } } + + + function lJvApp() { + setTimeout(function() { + //alert("in lJvApp"); + var jvapp = document.getElementById("jvapp"); + var jvfollower = document.getElementById("jvfollower"); + //console.log(">>>>>>>> lJvApp" + jvapp); + linkJvJmol(jvapp); + }, 200); + setConsole(document.getElementById("stdout")); + }; + + function lJvFollow() { + setTimeout(function() { + //alert("in lJvFollow"); + var jvapp = document.getElementById("jvapp"); + var jvfollower = document.getElementById("jvfollower"); + console.log(">>>>>>> lJvFollow" + jvfollower); + linkJvJmol(jvfollower); + }, 200); + }; + + function lJvA() { + setTimeout(function() { + //alert("lJvA"); + jvfollower = document.getElementById("jvA"); + setConsole(document.getElementById("stdout")); + //sep = jvfollower.getSeparator(); + //jvapp.setSeparator(""+jvapp.getSeparator()); + linkJvJmol(jvfollower, "jmolView", modeltofiles); + }, 100); + }; +