source: ISOcat/trunk/mod-ISOcat-interface-gi/interface/JSXAPPS/launcher.html @ 2029

Last change on this file since 2029 was 2029, checked in by mwindhouwer, 12 years ago

Initial import of all the *cats, i.e., ISOcat, RELcat and SCHEMAcat.

File size: 3.1 KB
Line 
1<!--
2  ~ Copyright (c) 2001-2011, TIBCO Software Inc.
3  ~ Use, modification, and distribution subject to terms of license.
4  -->
5<html>
6  <head>
7    <title>General Interface Application Launcher</title>
8    <script type="text/javascript">
9     
10function launchApp() {
11  var shellURL = "file:///D:/user/menwin/projects/ISOcat/src/mod-gi-1.0.0/gi/tibco-gi/shell.html";
12 
13  try {
14    var url = decodeURI(window.location.href);
15    url = url.replace(/\\/g, "/");
16   
17    var appPath = getURIParam(url, "jsxapppath");
18    if (appPath) {
19      if (getURIParam(url, "xhtml") == "true")
20        shellURL = shellURL.replace(".html", ".xhtml");
21      url = url.substring(0, url.indexOf("?"));
22      url = url.substring(0, url.lastIndexOf("/") + 1);
23     
24      var relPath = relativizeURI(shellURL.substring(0, shellURL.lastIndexOf("/")), url);
25      window.location.href = shellURL + "?jsxapppath=" + encodeURI(relPath + appPath);
26    } else {
27      window.alert("Error: no application specified.");
28    }
29  } catch (e) {
30    window.alert("Error: " + e.description);
31  }
32}
33function getURIParam(url, strParam) {
34  var regex = new RegExp("[\\?&]" + strParam + "=([^&]+)");
35  if (url.match(regex))
36    return RegExp.$1;
37  return null;
38};
39               
40function relativizeURI(from, to) {
41  var regex = /^(\w+):\/\/?\/?/;
42  if (from.match(regex)) {
43    var scheme = RegExp.$1;
44    if (to.match(regex)) {
45      if (scheme == RegExp.$1) {
46        from = from.replace(regex, "");
47        to = to.replace(regex, "");
48      }
49    }
50  }
51 
52  var thisTokens = from.split("/");
53  var thatTokens = to.split("/");
54 
55  var newTokens = [];
56   
57  var i = 0;
58  while (i < thisTokens.length && i < thatTokens.length) {
59    if (thisTokens[i] != thatTokens[i]) break;
60    i++;
61  }
62  for (var j = i; j < thisTokens.length; j++)
63    newTokens.push("..");
64   
65  for (var j = i; j < thatTokens.length; j++)
66    newTokens.push(thatTokens[j]);
67   
68  return newTokens.join("/");
69}
70function decodeURI(uri) {
71  var length = uri.length;
72  var decoded = new Array(length);
73  var j = 0;
74   
75  for (var i = 0; i < uri.length; i++) {
76    var chr = uri.charAt(i);
77    if (chr == "%") {
78      var octet = uri.substring(i+1, i+3);
79      decoded[j++] = String.fromCharCode(parseInt(octet, 16));
80      i += 2;
81    } else {
82      decoded[j++] = chr;
83    }
84  }
85   
86  return decoded.join(""); 
87}
88function encodeURI(uri) {
89  var strChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-!.~'()*%";
90  var length = uri.length;
91  var encoded = new Array(length);
92 
93  for (var i = 0; i < length; i++) {
94    var chr = uri.charAt(i);
95   
96    if (strChars.indexOf(chr) < 0) {
97      var code = chr.charCodeAt(0);
98     
99      if (code < 16) {
100        encoded[i] = "%" + "0" + code.toString(16).toUpperCase();
101      } else if (code < 256) {
102        encoded[i] = "%" + code.toString(16).toUpperCase();
103      } else {
104        encoded[i] = chr;
105      }
106    } else {
107      encoded[i] = chr;
108    }
109  }
110 
111  return encoded.join("");   
112}
113     
114    </script>
115  </head>
116  <body onload="launchApp();">
117 
118  <div id="title">
119 
120  </div>
121  <div id="error"> 
122 
123  </div>
124 
125  </body>
126</html>
Note: See TracBrowser for help on using the repository browser.