Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- current_hash = '';
- var hashchange = function(){
- var body = document.getElementsByTagName('body');
- current_hash = window.location.hash;
- if( body.onHashChange != null ){//native support for hashchange
- hashchange = function(){
- hash = window.location.hash;
- if(hash != 'content' && hash != 'navigation')
- loadContent(revertHash());
- };
- body.onHashChange = hashchange();
- }else{
- hashchange = function(){
- hash = window.location.hash;
- if(hash != current_hash && hash != 'content' && hash != 'navigation')
- loadContent(revertHash());
- };
- setInterval ( hashchange, 1000);
- }
- }
- hashchange();
- function revertHash(){
- //given a formatted hash, unformat it.
- var hash = window.location.hash;
- if(hash.substring(0,1) == '#')
- hash = hash.substring(1,hash.length);//remove starting hash. browser quibbles.
- while(hash.substring(0,1) == '/')
- hash = hash.substring(1,hash.length);//remove all slashes, better safe.
- if(hash.substr(hash.length-1,hash.length) == '/')
- hash = hash.substr(0,hash.length-1)+'.php';
- return hash;
- }
- function loadContent(pagename) {
- //we want in the format /ispconfig/#/page/
- origional_pagename = pagename;
- if(pagename.substring(0,1) != '/')//if it doesn't start with a slash.
- pagename = '/'+pagename;//looks neater
- if(origional_pagename != '')//do not want #//
- pagename = pagename.substring(0,pagename.length-4)+'/';//removes .php, adds trailing slash.
- window.location.hash = pagename;
- current_hash = window.location.hash;
- pagename = origional_pagename;
- if(pagename == ''){
- loadInitContent();
- return;
- }
- var pageContentCallback2 = {
- success: function(o) {
- if(o.responseText.indexOf('HEADER_REDIRECT:') > -1) {
- var parts = o.responseText.split(':');
- loadContent(parts[1]);
- } else if (o.responseText.indexOf('URL_REDIRECT:') > -1) {
- var newUrl= o.responseText.substr(o.responseText.indexOf('URL_REDIRECT:') + "URL_REDIRECT:".length);
- document.location.href = newUrl;
- } else {
- document.getElementById('pageContent').innerHTML = o.responseText;
- }
- },
- failure: function(o) {
- alert('Ajax Request was not successful.');
- }
- }
- var pageContentObject2 = YAHOO.util.Connect.asyncRequest('GET', pagename, pageContentCallback2);
- }
- function loadInitContent() {
- if(window.location.hash != ''){
- pagename = revertHash();
- if( pagename != ''){//we have something!
- loadContent(pagename);//turn our hash into a page, then load.
- return;
- }
- }
- var pageContentCallback = {
- success: function(o) {
- if(o.responseText.indexOf('HEADER_REDIRECT:') > -1) {
- var parts = o.responseText.split(":");
- loadContent(parts[1]);
- } else {
- document.getElementById('pageContent').innerHTML = o.responseText;
- }
- /*
- var items = document.getElementsByTagName('input');
- for(i=0;i<items.length;i++) {
- //var oButton = new YAHOO.widget.Button(items[i].id);
- if(items[i].type == 'button') {
- //alert(items[i].id);
- var oButton = new YAHOO.widget.Button(items[i].id);
- oButton.addListener("click",submitLoginForm);
- }
- }
- //var oButton = new YAHOO.widget.Button("submit");
- */
- },
- failure: function(o) {
- alert('Ajax Request was not successful.');
- }
- }
- var pageContentObject = YAHOO.util.Connect.asyncRequest('GET', 'content.php?s_mod=login&s_pg=index', pageContentCallback);
- loadMenus();
- keepalive();
- setTimeout("setFocus()",1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement