2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of
17 * the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
18 * The Jalview Authors are detailed in the 'AUTHORS' file.
22 $(document).ready(function() {
23 processAllAppletElements();
28 var currentPage = "applets";
30 function processAllAppletElements() {
31 var apps = document.getElementsByTagName("applet");
32 for (var i = apps.length; --i >= 0;) {
33 processAppletElement(apps[i]);
40 var element = e.target.appletElement;
41 var text = element.outerHTML;
44 var Info = self.JalviewInfo || {
46 main: "jalview.bin.Jalview",
53 serverURL: 'https://chemapps.stolaf.edu/jmol/jsmol/php/jsmol.php',
54 j2sPath: 'swingjs/j2s',
55 // console:'sysoutdiv',
59 var id = "JVApplet" + jvid++;
60 var args = text.replace(/[\n\t]/g, " ").split("<param ");
61 Info.j2sAppletID = id;
62 Info.jalview_SCREEN_WIDTH= 100, // desktop width -- 0 to hide
63 Info.jalview_SCREEN_HEIGHT= 70, // desktop height -- 0 to hide
64 Info.jalview_SCREEN_X= 10,
65 Info.jalview_SCREEN_Y= 10,
66 Info.jalview_EMBEDDED= true;
70 var v = ("" + Info[i] || "null").replace(/\"/g,"'");
71 args.push("name=\"Info." + i + "\" value=\"" + v + "\"");
74 SwingJS.getApplet(id, Info);
76 e.target.style.visibility="hidden";
80 function processAppletElement(element) {
81 var code = element.getAttribute("code");
82 var parent = element.parentElement;
83 if (code == "jalview.bin.JalviewLite") {
84 var text = element.outerHTML;
86 var btn = document.createElement("button");
87 btn.innerHTML = "Start Jalview";
88 var a = element.getAttribute("width");
89 btn.style.width = (a || 140) + "px";
90 a = element.getAttribute("height");
91 btn.style.height = (a || 25) + "px";
92 btn.appletElement = element;
93 parent.replaceChild(btn, element);
96 parent.removeElement(element);
102 * Generate an applet tag
110 * @returns a DOM APPLET element
112 function createAppletTag(code, name, archive, width, height, params){
113 var app = document.createElement('applet');
117 app.archive = archive;
119 var arrayLength = params.length;
120 for (var i = 0; i < arrayLength; i++) {
121 //console.log('name : '+ params[i][0] + ' code : '+ params[i][1]);
122 var param = document.createElement('param');
123 param.name = params[i][0];
124 param.value = params[i][1];
125 app.appendChild(param);
130 function readCookie(name) {
131 var nameEQ = name + "=";
132 var ca = document.cookie.split(';');
133 for(var i=0;i < ca.length;i++) {
135 while (c.charAt(0)==' ') c = c.substring(1,c.length);
136 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
141 function setOrUpdateCookie(name, value, days) {
144 var date = new Date();
145 date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
146 expires = "; expires=" + date.toGMTString();
151 document.cookie = name + "=" + value + expires + "; path=/";
155 var url = window.location.href;
156 var end = url.length;
157 var start = url.lastIndexOf("#");
158 var newPage = url.substring(start + 1, end);
159 var page = ((start === -1) ? currentPage : newPage);
160 //alert("page:" + page);
161 if(page === "embeddedWJmol"){
162 // do nothing embeddedWJmol page already include
164 $('#header').load("includes/header_jv.html");
165 //$('#content').load(page + ".html");
166 $('#nav').load("includes/nav_jv.html");
167 $('#footer').load("includes/footer_jv.html");
168 $('#'+ currentPage).addClass('active-trail active');
170 $('#header').load("includes/header_jv.html");
171 $('#content').load(page + ".html");
172 $('#nav').load("includes/nav_jv.html");
173 $('#footer').load("includes/footer_jv.html");
174 $('#'+ currentPage).addClass('active-trail active');
176 var e = document.getElementById("view_decorated");
177 e.style.display = 'none';
181 function doSubmit(target){
182 var currentPage = target+'.html';
183 //alert("page:" + target);
184 if(target == "embeddedWJmol"){
186 window.location.href = 'embeddedWJmol.html#' + target;
187 $('#content').load(currentPage);
189 window.location.href = 'index.html#' + target;
190 $('#content').load(currentPage);
197 function updateLinks(target) {
198 var ul = document.getElementById("menu");
199 var items = ul.getElementsByTagName("li");
200 for (var i = 0; i < items.length; ++i) {
201 removeClass(items[i], "active-trail active");
203 $('#'+ target).addClass('active-trail active');
206 function hasClass(ele,cls) {
207 return !!ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
210 function addClass(ele,cls) {
211 if (!hasClass(ele,cls)) ele.className += " "+cls;
214 function removeClass(ele,cls) {
215 if (hasClass(ele,cls)) {
216 var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
217 ele.className=ele.className.replace(reg,' ');