|
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 < bmTotalallow; curTab++) {
bmReal[curTab] = new createBm(curTab, "empty", "empty");
}
}
function addBm() {
descNow = opener.document.title;
urlNow = opener.document.location.href
if (urlNow != urlLast) {
if (bmTotal == bmTotalallow) shiftBm();
if (bmTotal < bmTotalallow) bmTotal++;
bmReal[bmTotal - 1] = new createBm(bmTotal - 1, descNow, urlNow);
showBm();
}
urlLast = urlNow;
}
function shiftBm() {
for (i = 0; i < bmTotalallow - 1; i++) {
bmReal[i] = bmReal[i + 1];
bmReal[i].name = bmName + i;
}
}
function showBm() {
if (bmTotal > 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 < bmTotal; i++) {
options[i] = new Option((i + 1) + ". " + bmReal[revBm - i].desc);
}
}
}
else document.bmForm.bmSelect.options[0] = new Option ("You have No History as of Yet");
document.bmForm.bmSelect.options[0].selected = true;
}
}
function replayChange() {
if (opener.location != null) {
if (repBm < bmTotal) {
opener.top.location = bmReal[repBm].url;
document.bmForm.bmSelect.options[(bmTotal - 1) - repBm].selected = true;
repBm++;
}
else {
clearTimeout(replay);
bmReplayIP = false;
alert("Replay Finished.");
opener.top.location = startUrl;
checkLoop();
}
}
else window.close();
}
function replayLoop() {
if (bmReplayIP == true) {
replay = setTimeout("replayLoop()", 5000);
replayChange();
}
}
function replayBm(obj) {
if (bmReplayIP == true) replayStop();
else bmReplayIP = true;
clearTimeout(check);
startBm = obj.bmSelect.selectedIndex;
startUrl = opener.location.href;
if (startBm < bmTotal) {
repBm = (bmTotal - 1) - startBm;
replayLoop();
}
else {
bmReplayIP = false;
alert("Choose a starting page please.");
}
}
function replayStop() {
if (bmReplayIP == true) {
clearTimeout(replay);
bmReplayIP = false;
}
}
function clearBm() {
replayStop();
clearTimeout(check);
loadBm();
for (i = bmTotalallow; 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";
}
}
|