Guest User

Untitled

a guest
Jun 16th, 2010
126
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. current_hash = '';
  3.  
  4. var hashchange = function(){
  5.  
  6.     var body = document.getElementsByTagName('body');
  7.     current_hash = window.location.hash;
  8.    
  9.     if( body.onHashChange != null ){//native support for hashchange
  10.    
  11.         hashchange = function(){
  12.             hash = window.location.hash;
  13.             if(hash != 'content' && hash != 'navigation')
  14.                 loadContent(revertHash());
  15.         };
  16.         body.onHashChange = hashchange();
  17.    
  18.     }else{
  19.    
  20.         hashchange = function(){
  21.            
  22.             hash = window.location.hash;
  23.             if(hash != current_hash && hash != 'content' && hash != 'navigation')
  24.                 loadContent(revertHash());
  25.         };
  26.    
  27.         setInterval ( hashchange, 1000);
  28.    
  29.     }    
  30.  
  31. }
  32.  
  33. hashchange();
  34.  
  35. function revertHash(){
  36.    
  37.     //given a formatted hash, unformat it.
  38.     var hash = window.location.hash;
  39.    
  40.     if(hash.substring(0,1) == '#')
  41.         hash = hash.substring(1,hash.length);//remove starting hash. browser quibbles.
  42.    
  43.     while(hash.substring(0,1) == '/')
  44.         hash = hash.substring(1,hash.length);//remove all slashes, better safe.
  45.    
  46.     if(hash.substr(hash.length-1,hash.length) == '/')
  47.         hash = hash.substr(0,hash.length-1)+'.php';
  48.    
  49.     return hash;
  50.    
  51. }
  52.  
  53. function loadContent(pagename) {
  54.    
  55.     //we want in the format /ispconfig/#/page/
  56.    
  57.     origional_pagename = pagename;
  58.    
  59.     if(pagename.substring(0,1) != '/')//if it doesn't start with a slash.
  60.         pagename = '/'+pagename;//looks neater
  61.    
  62.     if(origional_pagename != '')//do not want #//
  63.         pagename = pagename.substring(0,pagename.length-4)+'/';//removes .php, adds trailing slash.
  64.    
  65.     window.location.hash = pagename;
  66.     current_hash = window.location.hash;
  67.    
  68.     pagename = origional_pagename;
  69.    
  70.     if(pagename == ''){
  71.         loadInitContent();
  72.         return;
  73.     }
  74.    
  75.     var pageContentCallback2 = {
  76.         success: function(o) {
  77.             if(o.responseText.indexOf('HEADER_REDIRECT:') > -1) {
  78.                 var parts = o.responseText.split(':');
  79.                 loadContent(parts[1]);
  80.             } else if (o.responseText.indexOf('URL_REDIRECT:') > -1) {
  81.                 var newUrl= o.responseText.substr(o.responseText.indexOf('URL_REDIRECT:') + "URL_REDIRECT:".length);
  82.                 document.location.href = newUrl;
  83.             } else {
  84.                 document.getElementById('pageContent').innerHTML = o.responseText;
  85.             }
  86.         },
  87.         failure: function(o) {
  88.             alert('Ajax Request was not successful.');
  89.         }
  90.     }
  91.    
  92.  
  93.   var pageContentObject2 = YAHOO.util.Connect.asyncRequest('GET', pagename, pageContentCallback2);
  94. }
  95.  
  96.  
  97. function loadInitContent() {
  98.  
  99.     if(window.location.hash != ''){
  100.        
  101.         pagename = revertHash();
  102.  
  103.         if( pagename != ''){//we have something!
  104.            
  105.             loadContent(pagename);//turn our hash into a page, then load.
  106.             return;
  107.         }
  108.    
  109.     }
  110.  
  111.     var pageContentCallback = {
  112.         success: function(o) {
  113.             if(o.responseText.indexOf('HEADER_REDIRECT:') > -1) {
  114.                 var parts = o.responseText.split(":");
  115.                 loadContent(parts[1]);
  116.             } else {
  117.                 document.getElementById('pageContent').innerHTML = o.responseText;
  118.             }
  119.            
  120.             /*
  121.             var items = document.getElementsByTagName('input');
  122.             for(i=0;i<items.length;i++) {
  123.                 //var oButton = new YAHOO.widget.Button(items[i].id);
  124.                 if(items[i].type == 'button') {
  125.                     //alert(items[i].id);
  126.                     var oButton = new YAHOO.widget.Button(items[i].id);
  127.                     oButton.addListener("click",submitLoginForm);
  128.                 }
  129.             }
  130.             //var oButton = new YAHOO.widget.Button("submit");
  131.             */
  132.         },
  133.         failure: function(o) {
  134.             alert('Ajax Request was not successful.');
  135.         }
  136.     }
  137.    
  138.     var pageContentObject = YAHOO.util.Connect.asyncRequest('GET', 'content.php?s_mod=login&s_pg=index', pageContentCallback);
  139.    
  140.     loadMenus();
  141.     keepalive();
  142.     setTimeout("setFocus()",1000);
  143.  
  144. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×