Author: tyrell
Date: Sun Jun  1 23:27:28 2008
New Revision: 17748
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=17748

Log:
Adding context awareness to redirection functions.

Modified:
   trunk/mashup/java/modules/www/js/utils.js

Modified: trunk/mashup/java/modules/www/js/utils.js
URL: 
http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/www/js/utils.js?rev=17748&r1=17747&r2=17748&view=diff
==============================================================================
--- trunk/mashup/java/modules/www/js/utils.js   (original)
+++ trunk/mashup/java/modules/www/js/utils.js   Sun Jun  1 23:27:28 2008
@@ -94,19 +94,19 @@
 
         //Re-direct to https
         var redirectUrl = "https://"; + self.location.hostname;
-        
-        if(!(URL.indexOf('://') == URL.lastIndexOf(':'))){
-           redirectUrl += ":" + HTTPS_PORT;
+
+        if (!(URL.indexOf('://') == URL.lastIndexOf(':'))) {
+            redirectUrl += ":" + HTTPS_PORT;
         }
 
-        redirectUrl += "/" + decodeURI(bounceback);
+        redirectUrl += getRootContext() + decodeURI(bounceback);
 
         window.location = redirectUrl;
     }
 }
 
 function redirectToHttp(bounceback) {
-    
+
     wso2.wsf.Util.initURLs();
     var locationString = self.location.href;
     var _tmpURL = locationString.substring(0, locationString.lastIndexOf('/'));
@@ -115,11 +115,11 @@
         //Re-direct to http
         var redirectUrlHttp = "http://"; + self.location.hostname;
 
-        if(!(URL.indexOf('://') == URL.lastIndexOf(':'))){
-           redirectUrlHttp += ":" + HTTP_PORT;
+        if (!(URL.indexOf('://') == URL.lastIndexOf(':'))) {
+            redirectUrlHttp += ":" + HTTP_PORT;
         }
 
-        redirectUrlHttp += "/" + decodeURI(bounceback);
+        redirectUrlHttp += getRootContext() + decodeURI(bounceback);
 
         window.location = redirectUrlHttp;
     }
@@ -146,44 +146,55 @@
     return greeting;
 }
 
-function showHideCommon(divxName){
-   divx=document.getElementById(divxName);
+function showHideCommon(divxName) {
+    divx = document.getElementById(divxName);
 
-   /* show the intialy hidden object */
-   if(divx.style.display=='none'){
-       if(divx.nodeName == 'DIV')
-           divx.style.display='block';
-       if(divx.nodeName == 'IMG')
-           try {
-               divx.style.display='inline';
-           } catch(e) {
-               divx.style.display = 'block';
-           }
-
-       if(divx.nodeName == 'TR'){
-           try {
-               divx.style.display='table-row';
-           } catch(e) {
-               divx.style.display = 'block';
-           }
-       }
-       if(divx.nodeName == 'TD')
-           divx.style.display='table-cell';
-       if(divx.nodeName == 'A')
-           divx.style.display='inline';
-       if(divx.nodeName == 'SPAN')
-           divx.style.display='inline';
-       if(divx.nodeName == 'INPUT')
-           divx.style.display='inline';
-       if(divx.nodeName == 'P')
-           divx.style.display='block';
-       if(divx.nodeName == 'TABLE')
-           divx.style.display='block';
+    /* show the intialy hidden object */
+    if (divx.style.display == 'none') {
+        if (divx.nodeName == 'DIV')
+            divx.style.display = 'block';
+        if (divx.nodeName == 'IMG')
+            try {
+                divx.style.display = 'inline';
+            } catch(e) {
+                divx.style.display = 'block';
+            }
+
+        if (divx.nodeName == 'TR') {
+            try {
+                divx.style.display = 'table-row';
+            } catch(e) {
+                divx.style.display = 'block';
+            }
+        }
+        if (divx.nodeName == 'TD')
+            divx.style.display = 'table-cell';
+        if (divx.nodeName == 'A')
+            divx.style.display = 'inline';
+        if (divx.nodeName == 'SPAN')
+            divx.style.display = 'inline';
+        if (divx.nodeName == 'INPUT')
+            divx.style.display = 'inline';
+        if (divx.nodeName == 'P')
+            divx.style.display = 'block';
+        if (divx.nodeName == 'TABLE')
+            divx.style.display = 'block';
        //link.innerHTML=textHidden;
-   }
-   /* hide the initaly shown object */
-   else
-   {
-       divx.style.display='none';
-   }
-} 
\ No newline at end of file
+    }
+        /* hide the initaly shown object */
+    else
+    {
+        divx.style.display = 'none';
+    }
+}
+
+function getRootContext() {
+    var len = ROOT_CONTEXT.length;
+    var position = eval(len - 1);
+    var lastChar = ROOT_CONTEXT.substring(position, len);    
+    if (lastChar == "/") {
+        return ROOT_CONTEXT;
+    } else {
+        return ROOT_CONTEXT + "/";
+    }
+}
\ No newline at end of file

_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev

Reply via email to