home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2001 May
/
W2KPRK.iso
/
document.cab
/
regentry.chm
/
rkshared.js
< prev
next >
Wrap
Text File
|
1999-12-17
|
8KB
|
235 lines
var sActX_HH= " type='application/x-oleobject' classid='clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11' ";
var moniker= "ms-its:";
var numbers= /\d/g; //javascript regular expression
var spaces= /\s/g; //javascript regular expression
var semicolon= /;/g; //javascript regular expression
document.onclick= onclickTriage;
//****** insertImages *********************************************************************************************
// Inserts shared images in User-Defined Variables section and thumbnails.
function insertImages(){
// alert("insertImages");
if (oAnchor=="thumbnail" || oAnchor=="thumbnailweb"){
var sAltText = document.anchors[i].innerHTML;
var sThumbnailText = document.anchors[i].title;
var oImg = document.anchors[i].href.toLowerCase();
if (oAnchor=="thumbnail")
var sThumbnailImg= moniker + getURL(oImg);
else var sThumbnailImg = document.anchors[i].href.toLowerCase();
document.anchors[i].outerHTML = "<DIV id='thumbDiv' class='thumbnail'>"+document.anchors[i].outerHTML+"</div>";
document.anchors[i].innerHTML = "<img class='thumbnail' src='" + sThumbnailImg + "' alt= ' " + sAltText + "'><p>" +sThumbnailText+"</p>";
if (isRTL) thumbDiv.style.styleFloat= "right";
}
document.anchors[i].innerHTML = imgInsert + document.anchors[i].innerHTML;
if (isRTL) document.anchors[i].dir="rtl";
}
//***** onclickTriage ****************************************************************************************
// redirects to the appropriate function based on the ID of the clicked <A> tag.
function onclickTriage(){
// alert("onclickTriage");
var e= window.event.srcElement;
// if the innerHTML in the <a> tag is encapsulated by a style tag or hightlighted in the word seach,
// the parentElement is called.
for (var i=0; i < 5; i++)
if (e.tagName!="A" && e.parentElement!=null) e= e.parentElement;
eID= e.id.toLowerCase();
if (popupOpen) closePopup();
// expand image in a new window
if (eID=="thumbnail" || eID=="pophtm") popNewWindow(e);
else if (eID=="altloc") callAltLocation(e);
return;
}
function popNewWindow(eventSrc) {
// alert("popNewWindow");
var eH= eventSrc.href;
event.returnValue = false;
// extracts the thumbnail image URL from the <a> tag HREF
sParamFILE = getURL(eH);
if (sParamFILE=="") return;
// if the hhWindow object exists, clears it
if (document.hhWindow) document.hhWindow.outerHTML = "";
var h = "<object id='hhWindow'"+ sActX_HH +" STYLE='display:none'><param name='Command' value='Related Topics'>";
h = h + "<param name='Window' value='$global_largeart'><param name='Item1' value='$global_largeart;" + moniker + sParamFILE+ "'> </object>";
document.body.insertAdjacentHTML("beforeEnd", h);
document.hhWindow.hhclick();
}
var popupOpen= false; //state of popups
var posX, posY; //coordinates of popups
var oPopup; //object to be used as popup content
//**** callPopupWeb **************************************************************************************
// the web popups have been converted from the object winHelp popup for the web.
// called by: <A ID="wPopupWeb" HREF="#">@@Popup text@@</A>
// followed by: <div class="popup">Popup content</div>
function callPopupWeb(eventSrc) {
// alert("callPopupWeb");
var e= eventSrc;
// find the popup <div> that follows <a id="wPopupWeb"></a>
findPopup(e);
positionPopup(e)
oPopup.style.visibility = "visible";
popupOpen = true;
return;
}
//**** findPopup ****************************************************************************************
function findPopup(oX){
// alert("findPopup");
var e= oX;
var iNextTag;
for (var i=1;i<4; i++){
iNextTag= e.sourceIndex + i;
oPopup= document.all(iNextTag);
if (oPopup.className.toLowerCase()=="popup" || iNextTag == document.all.length)
break;
}
if (iNextTag != document.all.length) {
posX = window.event.clientX;
posY = window.event.clientY + document.body.scrollTop+10;
}
else closePopup();
}
//**** positionPopup ************************************************************************************
// Set size and position of popup.
// If it is off the page, move up, but not past the very top of the page.
function positionPopup(oX){
// alert("positionPopup");
var e= oX;
var popupOffsetWidth = oPopup.offsetWidth;
//determine if popup will be offscreen to right
var rightlimit = posX + popupOffsetWidth;
if (rightlimit >= document.body.clientWidth)
posX -= (rightlimit - document.body.clientWidth);
if (posX < 0) posX = 0;
//position popup
oPopup.style.top = posY;
oPopup.style.left = posX;
var pageBottom = document.body.scrollTop + document.body.clientHeight;
var popupHeight = oPopup.offsetHeight;
if (popupHeight + posY >= pageBottom) {
if (popupHeight <= document.body.clientHeight)
oPopup.style.top = pageBottom - popupHeight;
else
oPopup.style.top = document.body.scrollTop;
}
}
//**** closePopup ****************************************************************************************
// Close Popup
function closePopup() {
// alert("closePopup");
oPopup.style.visibility = "hidden";
popupOpen = false;
return;
}
//********************************************* GENERAL FUNCTIONS ************************************************
//**************************************************************************************************************************
//** getURL **************************************[used in callShortcut, popNewWindow& loadPage]********
// extracts the file location (CHM::/HTM) URL
function getURL(sHREF) {
// alert("getUrl");
var spaces= /\s/g
var eH = unescape(sHREF);
eH = eH.replace(spaces,"");
var eH_= eH.toLowerCase();
var sParamFILE= "";
var sParamCHM= "";
var iFILE= eH_.lastIndexOf("file=");
if (iFILE!=-1){
iEND= iFILE +1;
sParamFILE = eH.substring(iFILE+5,eH.length);
}
var iCHM = eH_.lastIndexOf("chm=");
if (iCHM!=-1){
iEND = iCHM +1; // iEND used by callShortcut
sParamCHM = eH.substring(iCHM+4, iFILE);
sParamFILE= sParamCHM+"::/"+sParamFILE;
}
return sParamFILE;
}
//**************************alt location routine***************
function callAltLocation(eventSrc) {
var e= eventSrc;
var eH= unescape(e.href);
var eH_= eH.toLowerCase();
var sFILEarray,sCHMarray;
event.returnValue = false;
var sParamTXT= e.innerHTML;
sParamTXT= sParamTXT.replace(semicolon,"");
var iFILE = eH_.lastIndexOf("file=");
if (iFILE==-1) return;
sParamFILE= eH.substring((iFILE+5),eH.length); // extracts the 2 HTM files
sParamFILE= sParamFILE.replace(spaces,"");
iSPLIT= sParamFILE.match(semicolon);
if (iSPLIT)
sFILEarray = sParamFILE.split(";"); // separates the 2 HTM files
else return;
var iCHM = eH_.lastIndexOf("chm=");
if(iCHM==-1) return;
else sParamCHM = eH.substring(iCHM+4,iFILE); // extracts the 2 CHM's
sParamCHM= sParamCHM.replace(spaces,"");
iSPLIT= sParamCHM.match(semicolon);
if (iSPLIT)
sCHMarray= sParamCHM.split(";"); // separates the 2 CHM's
else return;
sParamFILE= moniker + sCHMarray[0]+ "::/" + sFILEarray[0] + ";" + moniker + sCHMarray[1]+ "::/" + sFILEarray[1];
if (document.hhAlt) document.hhAlt.outerHTML = ""; // if hhAlt object exists, clears it
var h= "<object id='hhAlt'"+ sActX_HH + "STYLE='display:none'><PARAM NAME='Command' VALUE='Related Topics'>";
h= h + "<param name='Item1' value='" + sParamTXT +";" + sParamFILE + "'></object>";
document.body.insertAdjacentHTML("beforeEnd", h);
document.hhAlt.hhclick();
}