JavaScript Tip of the Week for October 7, 1996: History Tracker | Source Code
for October 7, 1996: Source Code: History Tracker
Put this code in the head of the "tracker.html" document, where the Tracker resides:
/* This code is Copyright (c) 1996 Nick Heinle and Athenia Associates,
* all rights reserved. In order to receive the right to license this
* code for use on your site the original code must be copied from the
* Web site webreference.com/javascript/. License is granted to user to
* reuse this code on their own Web site if and only if this entire copyright
* notice is included. Code written by Nick Heinle of webreference.com.
*/
bmDomain = "webreference.com"; //domain where indexer works
bmReal = new Array();
bmName = "jtotwbm"; //name of bms
bmTotal = 0;
bmTotalallow = 25; //total number of bm allowed
bmReplayIP = false;
urlLast = "";
function createBm(ncur, ndesc, nurl) {
this.name = bmName + ncur;
this.desc = ndesc;
this.url = nurl;
this.comb = ndesc + "!~" + nurl;
}
function loadBm() {
curTab = 0;
bmTotal = 0;
bmRealdone = false;
for (curTab = 0; curTab 0) {
if (bmReal[bmTotal - 1].url != "empty") {
with (document.bmForm.bmSelect) {
revBm = bmTotal - 1;
for (i = bmTotal - 1; i >= 0; i--) options[i] = null;
for (i = 0; i 0; i--)
document.bmForm.bmSelect.options[i] = null;
with (document.bmForm.bmSelect) {
options[0] = new Option ("You have No History as of Yet");
options[0].selected = true;
}
checkLoop();
}
function changePage(obj) {
replayStop();
i = obj.bmSelect.selectedIndex
bmPlace = (bmTotal - 1) - i;
if (bmPlace != -1) opener.top.location = bmReal[bmPlace].url;
}
function checkPage() {
if (top != null) {
where = opener.location+ "";
if (where.indexOf(bmDomain) != -1 && opener.location != null) {
addBm();
}
}
else window.close();
}
function checkLoop() {
check = setTimeout("checkLoop()", 500);
checkPage();
}
Put this script in "tracker.html" where you the select menu and controls to be displayed:
with (document) {
writeln('<FORM NAME = "bmForm">');
writeln('<SELECT NAME = "bmSelect">');
for (i = 0; i < bmTotalallow; i++)
writeln('<OPTION>You have No History as of Yet');
writeln('</SELECT><BR>');
writeln('<INPUT TYPE = BUTTON VALUE = "Jump!" onClick = "changePage(this.form)">');
writeln('<INPUT TYPE = BUTTON VALUE = "Clear" onClick = "clearBm()">');
writeln('<INPUT TYPE = BUTTON VALUE = "Replay" onClick = "replayBm(this.form)">');
writeln('<INPUT TYPE = BUTTON VALUE = "Stop" onClick = "replayStop()">');
writeln('</FORM>');
}
for (i = bmTotalallow; i > 0; i--)
document.bmForm.bmSelect.options[i] = null;
loadBm();
showBm();
checkLoop();
Put this code in the page you want to launch the Tracker from:
var remoteWin = null;
function remoteStart() {
remoteWin = window.open('','htRemote',
'toolbar=0,width=380,height=100,directories=0,status=0,scrollbars=0,menubar=0');
if (remoteWin != null) {
if (remoteWin.opener == null) {
remoteWin.opener = self;
}
remoteWin.location.href = "tracker.html";
}
}


