JS file content found on my PC

5 views
Skip to first unread message

~BD~

unread,
Jul 23, 2008, 2:56:19 AM7/23/08
to
Hi - I'm still experimenting with this machine. I found a temp file which contains the information
listed below. Has anyone any idea what effect such a file will have on this PC? (XP Home, SP3 and
all updates).

Thank you in advance for any insight you may be able to provide.

Dave


/*
* ====================== dir.js ========================
* ====== Javascript include for director.hta ===========
* ======================================================
*/

// initialize global variables
var debug = new Boolean; // loaded from persist.
var hintsOpen = new Boolean; // loaded from persist.
var hintsWidth = 175;
var totalWidth = 0;
var currentDevice;
var windowHeight = 190; // set for current container app. HTA: 190, HTM/IE: 300
var minWindowWidth = 220; // w/o width of <select> and 'settings'
var widthAdjust = -27; /// set for current container app. HTA: 190, HTM/IE: -3
var updateInProgress = new Boolean;

//Added by Brent
var doubleClicked = false;
var currentButton;

window.onload=initialize

function initialize() {
updateInProgress = false;
debug = false;
initializeDevices();
loadPersist();

setCurrentDevice();
updateLayout();
}

function setCurrentDevice() {
// was app started with a context id
var ctxID = window.external.ContextID;
if (ctxID == "")
return;

for (var i = 0; i < oDevice.length; i++)
{
if (oDevice[i].devID == ctxID)
{
currentDevice = i;
break;
}
}
}

function changeDevice(device) {
currentDevice=device;
updateLayout();
savePersist();
}

function expandHints() {
if (updateInProgress)
return;

updateInProgress = true;
hintsOpen = !hintsOpen;
updateLayout();
savePersist();
}

function toggleDebug() {
// debug = !debug
// updateLayout()
}

function initializeDevices() {
// populate oDevice data structure from Devices.xml
oDevice = new Array;
var xml = new ActiveXObject("msxml");

//Get file path for devices.xml in User's App Data directory

//Start with 'file:///'
var devFilePath = new String("file:\/\/\/");
//Get the path for the file from call to COM code
devFilePath += window.external.GetAppDataPath();
//Replace all '\\' occurrences with '/'
devFilePath = devFilePath.replace(/\\/g,"\/");
//Replace spaces with '%20'
devFilePath = devFilePath.replace(/\s/g,"%20");
//Add the name of the file
devFilePath += "devices.xml"


xml.URL = devFilePath;

devicesXML = xml.root.children;
for ( var i=0; i<devicesXML.length; i++ ) { // could eliminate this intermediate data structure
oDevice[i] = new Object;
oDevice[i].devID = devicesXML.item(i).children.item(0).text;
oDevice[i].id = devicesXML.item(i).children.item(1).text;
oDevice[i].service = new Array;
services = devicesXML.item(i).children.item(2).children
for ( var j=0; j<services.length; j++ ) {
oDevice[i].service[j] = new Object;
oDevice[i].service[j].serviceID = services.item(j).children.item(0).text;
oDevice[i].service[j].action = services.item(j).children.item(1).text
oDevice[i].service[j].status = services.item(j).children.item(2).text
}

if ((devicesXML.item(i).children.length > 3) &&
(devicesXML.item(i).children.item(3).tagname == "STATUS"))
oDevice[i].statusmon = devicesXML.item(i).children.item(3).children.item(0).text;
else
oDevice[i].statusmon = null;
}

if ( debug ) { alert( "found "+ devicesXML.length +" devices")}


}

function externalGetData(name) {
return window.external.GetPersistentData(name);
}

function loadPersist() {
// replace with Persistence code
hintsOpen = true;
debug = false;
currentDevice = 0;

//var persistHints = window.external.GetPersistentData("hintsOpen");
var persistHints = externalGetData("hintsOpen");
if (persistHints != "")
{
hintsOpen = eval(unescape(persistHints));
}

//var persistDevice = window.external.GetPersistentData("currentDevice");
var persistDevice = externalGetData("currentDevice");
if (persistDevice != "")
{
var devID = unescape(persistDevice);
for (var j = 0; j < oDevice.length; j++)
{
if (oDevice[j].devID == devID)
{
currentDevice = j;
break;
}
}
}

window.resizeTo(663,windowHeight) //
}

function externalSaveData(name, value) {
window.external.SavePersistentData(name, value);
}

function savePersist() {
externalSaveData("hintsOpen", escape(hintsOpen));
externalSaveData("currentDevice", escape(oDevice[currentDevice].devID));
}


function updateLayout() {
// debug stuff ===================================
if ( debug ) {
oAllButtons.style.border = "1px solid black"
oIconBackground.style.border = "1px solid cyan"
oHintsTitle.style.border = "1px dashed black"
oHintsText.style.border = "1px dotted black"
oIconBackground.style.backgroundColor = "yellow"
oHintBackground.style.backgroundColor = "red"
oAllButtons.style.visibility = "visible"
// debug stuff ===================================

} else {
oAllButtons.style.visibility = "hidden"
}
// update Select
oSelect.options.length = 0;
for ( var i=0; i< devicesXML.length; i++ ) {
var oOption = document.createElement("OPTION");
oOption.text=oDevice[i].id;
oSelect.options.add(oOption);
}

// select the current device in the drop down combo box
oSelect.selectedIndex = currentDevice

// assign the access key to 'Select Device'
var selectText = tdcStrings.recordset("dir-label-select").value;
var selectAccKeyIndex = selectText.toLowerCase().indexOf("<u>");
if (selectAccKeyIndex >= 0)
{
oSelect.accessKey = selectText.substr(selectAccKeyIndex + 3, 1);
}

// assign the access key to 'Settings' menu item
var settingsText = tdcStrings.recordset("settings-title").value;
var settingsAccKeyIndex = settingsText.toLowerCase().indexOf("<u>");
if (settingsAccKeyIndex >= 0)
{
settingstitle.accessKey = settingsText.substr(settingsAccKeyIndex + 3, 1);
}

// assign the access key to 'Status' menu item
var statusText = tdcStrings.recordset("status-title").value;
var statusAccKeyIndex = statusText.toLowerCase().indexOf("<u>");
if (statusAccKeyIndex >= 0)
{
statustitle.accessKey = statusText.substr(statusAccKeyIndex + 3, 1);
}

// empty old buttons
oAllButtons.innerHTML="";

// add new button - hidden
for ( var j=0; j<oDevice[currentDevice].service.length; j++ ) {
button = oDevice[currentDevice].service[j].serviceID

var buttonText = tdcStrings.recordset("dir-btn-"+button).value;

var accKey = null;
var accKeyIndex = buttonText.toLowerCase().indexOf("<u>");
if (accKeyIndex >= 0)
{
accKey = buttonText.substr(accKeyIndex + 3, 1);
}

html=""
html+="<span id='oBtn" + button + "' "
html+="class = 'service-button' onMouseOver='showHint(this.id)' ";

//Updated by Brent
html+="onClick = 'fnSingleClick(\" " +button+ " \");' "
html+="onDblClick = 'fnDoubleClick(\" " +button+ " \");'> "


html+="<img id='oImg" + button + "' "
html+="style = 'margin-right:0' "
if ( oDevice[currentDevice].service[j].status=="ready" ) {
html+="class = 'rollover' src='img/" + button + ".bmp'></br>"
} else {
html+="src='img/" + button + "_f4.bmp'></br>"
}
html+="<a class='service-button' href=\"#\" accesskey=" + accKey + " style='text-decoration:none'>
";
html+="<label for=\"oImg"+button+"\" datasrc = '#tdcStrings' datafld = 'dir-btn-" + button + "'
"
html+="dataFormatAs = 'HTML'></label></a></span>"
oAllButtons.insertAdjacentHTML("beforeEnd", html)
}
window.setTimeout("finishLayout()" , 500);

}

//Single and Double click handlers added by Brent
function fnSingleClick(button)
{

//Take a little time first

currentButton = button;
timer = setTimeout("if (doubleClicked == false){runApp(currentButton);}doubleClicked = false;",500);
}

function fnDoubleClick(button)
{
doubleClicked = true;
currentButton = button;
runApp(currentButton);
}

function finishLayout() {
// evaluate button kerning pairs
var kernWidth=0
var maxWidth=0;
var widths = " widths: "
for ( var i=0; i<oDevice[currentDevice].service.length - 1; i++ ) {
button = oDevice[currentDevice].service[i].serviceID
nextButton = oDevice[currentDevice].service[i+1].serviceID
kernWidth = Math.max(kernWidth, 0.5 * (eval("oBtn" + button + ".offsetWidth") + eval("oBtn" +
nextButton + ".offsetWidth")))
widths += " " + eval("oBtn" + button + ".offsetWidth")
}
if (debug) status = "kern:" + kernWidth + widths;
// kern each button (except last) & calculate total space needed to avoid wrap
totalWidth = 0;
for ( var i=0; i<oDevice[currentDevice].service.length - 1; i++ ) {
button = oDevice[currentDevice].service[i].serviceID
thisWidth = eval("oBtn" + button + ".offsetWidth")
nextButton = oDevice[currentDevice].service[i+1].serviceID
nextWidth = eval("oBtn" + nextButton + ".offsetWidth")
current = 0.5 * (thisWidth + nextWidth)
thisButton = eval("oBtn" + button)
thisKern = kernWidth - current
thisButton.style.marginRight = thisKern
totalWidth += thisWidth + thisKern + nextWidth * (i==oDevice[currentDevice].service.length -2)
}

settingstitle.style.width = settingstitle.offsetWidth;
statustitle.style.width = statustitle.offsetWidth;

// prepare to resize window
widthBySettings = minWindowWidth + settingstitle.offsetWidth + oSelect.offsetWidth +
statustitle.offsetWidth;
widthByButtons = totalWidth + 95;
widthBump = Math.max(0, widthBySettings - widthByButtons);
windowWidth = Math.max(widthBySettings, widthByButtons);
windowWidth = hintsOpen ? windowWidth + hintsWidth : windowWidth;
// resize
window.resizeTo(windowWidth + widthAdjust, windowHeight);
// position elements
rightSideButtons = oBtnhelp.offsetLeft + oBtnhelp.offsetWidth + 20;
oIconBackground.style.width = rightSideButtons + widthBump + 10;
oMenuMask.style.left = oSelect.offsetWidth + 60;

// position drop-down menu
if (document.all.menu1)
document.all.menu1.style.left = oMenuMask.style.left;
else
oMenuMask.style.visibility = "hidden";

if (oDevice[currentDevice].statusmon)
{
oMenuStatusMask.style.left = oSelect.offsetWidth + settingstitle.offsetWidth + 80;
oMenuStatusMask.style.visibility = "visible";
}
else
oMenuStatusMask.style.visibility = "hidden";
rightSideAnchor = rightSideButtons + widthBump + 10

// hints-specific
if ( hintsOpen ) {

oFilletTR.className="fillet-small-xlight-tr"
oFilletBR.className="fillet-small-xlight-br"

rightSideAnchor += hintsWidth;

oHintBackground.style.width = rightSideButtons + widthBump + hintsWidth + 10
oBtnHints.style.visibility = "hidden"
oBtnHintsOut.style.visibility = "visible"
oHintsTitle.style.left = rightSideButtons + widthBump + 25;
oHintsText.style.left = rightSideButtons + widthBump + 25;
oHintBackground.style.display = ""
oHintsTitle.style.display = ""
oHintsText.style.display = ""

} else {

oFilletTR.className="fillet-small-gray-tr"
oFilletBR.className="fillet-small-gray-br"

oBtnHintsOut.style.visibility = "hidden"
oBtnHints.style.visibility = "visible"
oHintBackground.style.display = "none"
oHintsTitle.style.display = "none"
oHintsText.style.display = "none"
oBtnHints.style.left = rightSideAnchor + 15;
}
// oBtnHints.style.left = rightSideAnchor + 15;
oBtnHintsOut.style.left = rightSideAnchor + 15;
oFilletTR.style.left = rightSideAnchor;
oFilletBR.style.left = rightSideAnchor;
oHPLogo.style.left = rightSideAnchor - 40;

// spread out buttons
if ( widthBump>0 ) {
for ( var i=0; i<oDevice[currentDevice].service.length ; i++ ) {
button = oDevice[currentDevice].service[i].serviceID
thisButton = eval("oBtn" + button)
thisButton.style.marginLeft = 0.5 * widthBump/oDevice[currentDevice].service.length
thisButton.style.marginRight = 0.5 * widthBump/oDevice[currentDevice].service.length
}
}
oAll.style.visibility = "visible";
oAllButtons.style.visibility = "visible";

// hide the drop-down list box and menu if no devices are installed
if ((oDevice.length == 1) && (oDevice[0].devID == "unknown"))
{
oSelectLabel.style.visibility = "hidden";
oSelect.style.visibility = "hidden";
oMenuMask.style.visibility = "hidden";
}

updateMenus();
updateInProgress = false;
}

function showHint(buttonID) {
service = buttonID.substring(4);
oHintsTitleLabel.dataFld="dir-hint-" + service.toLowerCase() + "-title";
oHintsLabel.dataFld="dir-hint-" + service.toLowerCase();
}

function runApp(buttonID){
//alert("run: "+buttonID + " for device:" + currentDevice)
//var shell = new ActiveXObject("WScript.Shell");
//shell.run(app,1,false);

btnID = buttonID.substring(1, buttonID.length - 1);
for (var i = 0; i < oDevice[currentDevice].service.length; i++)
{
if (btnID== oDevice[currentDevice].service[i].serviceID)
{
window.external.RunApp(btnID,
oDevice[currentDevice].service[i].action,
oDevice[currentDevice].devID);
break;
}
}
}

// Present Settings menu based on currentDevice
function processMenu() {
var menuStr = "show-menu=dev"+currentDevice+"-settings";

ShM=1;
popi(menuStr, 'menu1', 0);

window.event.cancelBubble = true;
}

function processStatusBtn() {
window.external.RunApp("status", oDevice[currentDevice].statusmon,
oDevice[currentDevice].devID);
}

function processKeyDown() {
//if ((window.event.altKey) && (window.event.keyCode >= 48))
//{
// alert("got key down: code="+window.event.keyCode);
//}

//else if (window.event.keyCode == 13)
//{
// alert("got key down: code=<ENTER>");
//}
//else
// alert("processKeydown");
}

function updateMenus() {
var maxMenuWidth = 0;
var menuNum = 1;
while(eval("window.menu"+menuNum))
{
maxMenuWidth = 0;

var dirMenu=eval("menu"+menuNum);
var menuName = dirMenu[0];
var menuStructIdx = getMenuStructIndex(dirMenu[0]);
if (menuStructIdx >= 0)
{
for (var i = 0; i < menuStruct[menuStructIdx].entry.length; i++)
{
var entryName = menuStruct[menuStructIdx].entry[i].name;
var elem = eval("document.all('"+entryName+"')");
maxMenuWidth = Math.max(maxMenuWidth, elem.offsetWidth);
}

if (maxMenuWidth > 0)
{
var ancestorElem = eval("document.all('menu"+menuNum+"')");

// add extra pixels for the border and submenu image (arrow bitmap)
maxMenuWidth += (dirMenu[4] * 2) + 8;
//if (maxMenuWidth > document.all('menu1').offsetLeft)
// maxMenuWidth = document.all('menu1').offsetLeft;

ancestorElem.style.width = maxMenuWidth+"px";

for (var j = 0; j < ancestorElem.children.length; j++)
{
var childElem = ancestorElem.children[j];
if ((childElem.children.length > 0) &&
(childElem.children[0].style.width))
childElem.children[0].style.width = maxMenuWidth+"px";
}
}
}

menuNum++;
}

sis();
}


David Brooks

unread,
Dec 30, 2020, 3:14:48 PM12/30/20
to
This is the earliest of my postings on ACV

Nobody responded. Maybe Mr Carroll will interpret?
Reply all
Reply to author
Forward
0 new messages