1 <SCRIPT type="text/javascript">
3 // From http://snipplr.com/view.php?codeview&id=1272
4 //----------------------------------------
5 //Wrapper function for constructing a request object.
7 // reqType: The HTTP request type, such as GET or POST.
8 // url: The URL of the server program.
9 // asynch: Whether to send the request asynchronously or not.
10 //----------------------------------------
12 function httpRequest(reqType,url,asynch,respHandle) {
14 // Mozilla-based browsers
15 if (window.XMLHttpRequest) {
16 request = new XMLHttpRequest();
17 } else if (window.ActiveXObject) {
18 request = new ActiveXObject("Msxml2.XMLHTTP");
20 request = new ActiveXObject("Microsoft.XMLHTTP");
24 // Request could still be null if neither ActiveXObject
25 // initialization succeeded
27 // If the reqType param is POST, then the fifth arg is the POSTed data
28 if (reqType.toLowerCase() != "post") {
29 initReq(reqType, url, asynch, respHandle);
32 var args = arguments[5];
33 if (args != null && args.length > 0) {
34 initReq(reqType, url, asynch, respHandle, args);
38 alert("Your browser does not permit the use of all " +
39 "of this application's features!");
44 //----------------------------------------
45 //Initialize a request object that is already constructed
46 //----------------------------------------
48 function initReq(reqType, url, bool, respHandle) {
50 // Specify the function that will handle the HTTP response
51 request.onreadystatechange = respHandle;
52 request.open(reqType, url, bool);
53 // If the reqType param is POST, then the
54 // fifth argument to the function is the POSTed data
55 if (reqType.toLowerCase() == "post") {
56 // Set the Content-Type header for a POST request
57 request.setRequestHeader("Content-Type", "application/x-ww-form-urlencoded; charset=UTF-8");
58 request.send(arguments[4]);
63 alert("The application cannot contact the server at the moment. " +
64 "Please try again in a few seconds.\n" +
65 "Error detail: " + errv.message);
69 // jalview launching with fetched data
71 function startJalview(aligURL,title,alwvar) {
73 httpRequest("get",aligURL,true,function() {
74 if (request.readyState == 4) {
75 alignment = request.responseText;
76 eval("var "+alwvar+" = document.JalviewLite.loadAlignment(alignment,title)");
85 <applet name="JalviewLite" code="jalview.bin.JalviewLite"
86 archive="${content.jvl}" width="0" height="0">
87 <param name="debug" value="true"/>
88 <param name="showbutton" value="false"/>
89 <#if (content.permissions?exists)>
90 <param name="permissions" value="${content.permissions}"/>
94 <h2>Javascript Launch Button</h2><p>The button below demonstrates how JalviewLite can be launched via a javascript action.</p>
96 <input type="button" name="Button1" value="Start"
97 onClick="startJalview('plantfdx.fa','Button1.alignment','alwvar')"/>