home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2007 March / PCpro_2007_03.ISO / files / browser / msie7 / IE7Setup.exe / ieframe.dll / HTML / HTTPERRORPAGESSCRIPTS.JS < prev    next >
Encoding:
Text File  |  2006-10-27  |  6.8 KB  |  211 lines

  1. ∩╗┐//Need to include errorPageStrings.js when you include this file
  2.  
  3. function isExternalUrlSafeForNavigation(urlStr)
  4. {
  5.     var regEx = new RegExp("^(http(s?)|ftp|file)://", "i");
  6.     return regEx.exec(urlStr);
  7. }
  8.  
  9. function navCancelInit()
  10. {
  11.     var location = window.location.href;
  12.     var poundIndex = location.indexOf('#');
  13.     
  14.     if (poundIndex != -1 && poundIndex+1 < location.length && isExternalUrlSafeForNavigation(location.substring(poundIndex+1)))
  15.     {
  16.         var bElement = document.createElement("A");
  17.         bElement.innerText = L_REFRESH_TEXT;
  18.         bElement.href = 'javascript:location.replace(\"'+ location.substring(poundIndex+1) +'\");';
  19.         navCancelContainer.appendChild(bElement);
  20.     }
  21.     else
  22.     {
  23.         var textNode = document.createTextNode(L_RELOAD_TEXT);
  24.         navCancelContainer.appendChild(textNode);
  25.     }
  26. }
  27.  
  28. function expandCollapse(elem, changeImage)
  29. {
  30.     if (document.getElementById)
  31.     {
  32.         ecBlock = document.getElementById(elem);
  33.  
  34.         if (ecBlock != undefined && ecBlock != null)
  35.         {
  36.             if (changeImage)
  37.             {
  38.                 //gets the image associated
  39.                 elemImage = document.getElementById(elem + "Image");
  40.             }
  41.  
  42.             //make sure elemImage is good
  43.             if (!changeImage || (elemImage != undefined && elemImage != null))
  44.             {
  45.                 if (ecBlock.currentStyle.display == "none" || ecBlock.currentStyle.display == null || ecBlock.currentStyle.display == "")
  46.                 {
  47.                     //shows the info.
  48.                     ecBlock.style.display = "block";
  49.                     if (changeImage)
  50.                     {
  51.                         //Just got in expanded mode. Thus, change image to "collapse"
  52.                         elemImage.src = "up.png";
  53.                     }
  54.                 }
  55.                 else if (ecBlock.currentStyle.display == "block")
  56.                 {
  57.                     //hide info
  58.                     ecBlock.style.display = "none";
  59.                     if (changeImage)
  60.                     {
  61.                         //Just got in collapsed mode. Thus, change image to "expand"
  62.                         elemImage.src = "down.png";
  63.                     }
  64.                 }
  65.                 else
  66.                 {
  67.                     //catch any weird circumstances.
  68.                     ecBlock.style.display = "block";
  69.                     if (changeImage)
  70.                     {
  71.                         elemImage.src = "up.png";
  72.                     }
  73.                 }
  74.             }//end check elemImage
  75.         }//end check ecBlock
  76.     }//end getElemById
  77. }//end expandCollapse
  78.  
  79.  
  80. function initHomepage()
  81. {
  82.     // in real bits, urls get returned to our script like this:
  83.     // res://shdocvw.dll/http_404.htm#http://www.DocURL.com/bar.htm
  84.  
  85.     //For testing use
  86.     //DocURL = "res://shdocvw.dll/http_404.htm#http://www.microsoft.com/bar.htm"
  87.     DocURL=document.location.href;
  88.  
  89.     //this is where the http or https will be, as found by searching for :// but skipping the res://
  90.     protocolIndex=DocURL.indexOf("://", 4);
  91.  
  92.     //this finds the ending slash for the domain server
  93.     serverIndex=DocURL.indexOf("/", protocolIndex + 3);
  94.  
  95.     //for the href, we need a valid URL to the domain. We search for the # symbol to find the begining
  96.     //of the true URL, and add 1 to skip it - this is the BeginURL value. We use serverIndex as the end marker.
  97.     //urlresult=DocURL.substring(protocolIndex - 4,serverIndex);
  98.     BeginURL=DocURL.indexOf("#",1) + 1;
  99.     urlresult=DocURL.substring(BeginURL, serverIndex);
  100.     if (protocolIndex - BeginURL > 7)
  101.         urlresult="";
  102.  
  103.      //for display, we need to skip after http://, and go to the next slash
  104.     displayresult=DocURL.substring(protocolIndex + 3, serverIndex);
  105.  
  106.     var aElement = document.createElement("A");
  107.  
  108.     aElement.innerText = displayresult;
  109.     aElement.href = urlresult;
  110.  
  111.     homepageContainer.appendChild(aElement);
  112. }
  113.  
  114.  
  115. function initGoBack()
  116. {
  117.     //fills in the span container for "back to previous page"
  118.     //Basically, makes "back to previous page" a clickable item IF there's something in the navstack.
  119.  
  120.     if (history.length < 1)
  121.     {
  122.         //this page is the only thing. Nothing in history.
  123.         var textNode = document.createTextNode(L_GOBACK_TEXT);
  124.         goBackContainer.appendChild(textNode);
  125.     }
  126.     else
  127.     {
  128.         var bElement = document.createElement("A");
  129.         bElement.innerText = L_GOBACK_TEXT ;
  130.         bElement.href = "javascript:history.back();";
  131.         goBackContainer.appendChild(bElement);
  132.     }                
  133. }
  134.  
  135. function initMoreInfo(infoBlockID)
  136. {
  137.     var bElement = document.createElement("A");
  138.     bElement.innerText = L_MOREINFO_TEXT;
  139.     bElement.href = "javascript:expandCollapse(\'infoBlockID\', true);";
  140.     moreInfoContainer.appendChild(bElement);                
  141. }
  142.  
  143. function initOfflineUser(offlineUserID)
  144. {
  145.     var bElement = document.createElement("A");
  146.     bElement.innerText = L_OFFLINE_USERS_TEXT;
  147.     bElement.href = "javascript:expandCollapse('offlineUserID', true);";
  148.     offlineUserContainer.appendChild(bElement);
  149. }
  150.  
  151. function setTabInfo(tabInfoBlockID)
  152. {
  153.     //removes the previous tabInfo text
  154.     var bPrevElement = document.getElementById("tabInfoTextID");
  155.     var bPrevImage   = document.getElementById("tabInfoBlockIDImage");
  156.  
  157.     if (bPrevElement != null)
  158.     {
  159.         tabInfoContainer.removeChild(bPrevElement);
  160.     }
  161.  
  162.     if (bPrevImage != null)
  163.     {
  164.         tabImageContainer.removeChild(bPrevImage);
  165.     }
  166.  
  167.     var bElement = document.createElement("A");
  168.     var bImageElement = document.createElement("IMG");
  169.  
  170.     var ecBlock = document.getElementById(tabInfoBlockID);
  171.  
  172.     //determines if the block is closed
  173.     if ((ecBlock != undefined && ecBlock != null) &&
  174.         (ecBlock.currentStyle.display == "none" || ecBlock.currentStyle.display == null || ecBlock.currentStyle.display == ""))
  175.     {
  176.         bElement.innerText = L_SHOW_HOTKEYS_TEXT;
  177.         bImageElement.alt = L_SHOW_HOTKEYS_TEXT;
  178.         bImageElement.src="down.png";
  179.     }
  180.     else
  181.     {
  182.         bElement.innerText = L_HIDE_HOTKEYS_TEXT;
  183.         bImageElement.alt = L_HIDE_HOTKEYS_TEXT;
  184.         bImageElement.src="up.png";
  185.     }
  186.  
  187.     bElement.id = "tabInfoTextID";
  188.     bElement.href = "javascript:expandCollapse(\'tabInfoBlockID\', false); setTabInfo('tabInfoBlockID');";
  189.  
  190.  
  191.     bImageElement.id="tabInfoBlockIDImage";
  192.     bImageElement.border="0";
  193.     bImageElement.className="actionIcon";
  194.  
  195.     tabInfoContainer.appendChild(bElement);
  196.     tabImageContainer.appendChild(bImageElement);
  197. }
  198.  
  199.  
  200. function skipTabCheck(skipTabFrom)
  201. {
  202.     if (skipTabFrom.skipTabCheckbox.checked)
  203.     {
  204.         window.external.SkipTabsWelcome();
  205.     }
  206. }
  207.  
  208. function diagnoseConnection()
  209. {
  210.     window.external.DiagnoseConnection();
  211. }