home *** CD-ROM | disk | FTP | other *** search
- //
- // ⌐ 2002-2004, Microsoft Corporation. All rights reserved.
- // Developed By Shavlik Technologies, LLC
- //
-
- var comboBoxArray = new Array();
- var IPcomboBoxArray = new Array();
- var SUScomboBoxArray = new Array();
-
- function CreateComboBoxObject(strDropDownListID, strComboBoxName)
- {
- this.Mycmb = document.all[strDropDownListID];
- this.SetDefaultText = SetDefaultText;
- this.Mycmb.selectedIndex = -1;
- this.UseStateFunctions = false;
- this.Clear = Clear;
- this.GetSelectedText = GetSelectedText;
- this.AlignTextBoxOverDropDown = AlignTextBoxOverDropDown;
- this.cbo_OnChange = cbo_OnChange;
- this.txt_OnBlur = txt_OnBlur;
- this.txt_OnChange = txt_OnChange;
- this.setDefaultIndex = setDefaultIndex;
- this.txt_OnKeyUp = txt_OnKeyUp;
- this.focus = focus;
- //do lookup or not
- this.LookupValues = true;
- this.SetAccessKey = SetAccessKey;
- //case sensitivity
- this.LookupCaseInSensitive = true;
- //store the previous text for the lookup
- this.MytxtPreviousValue = "";
- //generate the text box on the fly
-
- var strMytxtID = "txtMytxt" + strDropDownListID;
-
- var strDummytxt = '<input type="text" ID="Text1" NAME="Text1" style="visibility: hidden; width:1"></input>';
- var strMytxt = strDummytxt + "<INPUT type='text' id=" + strMytxtID + " name=" + strMytxtID + " onblur='" + strComboBoxName + ".txt_OnBlur()' " +
- " onkeyup='" + strComboBoxName + ".txt_OnKeyUp()' " +
- " onchange='" + strComboBoxName + ".txt_OnChange()' " +
- " style='display: none;' value='' >";
-
- this.Mycmb.insertAdjacentHTML("afterEnd", strMytxt);
- //assign obj to new textbox
- this.Mytxt = document.all[strMytxtID];
-
- var strMyHiddentxtID = strDropDownListID + "_value";
-
- var strMyHiddentxt = "<INPUT type='hidden' " + " id=" + strMyHiddentxtID + " name=" + strMyHiddentxtID + " >";
-
- this.Mycmb.insertAdjacentHTML("afterEnd", strMyHiddentxt);
- this.MyHiddentxt = document.all[strMyHiddentxtID];
-
- this.AdjustingSize = false;
- this.AlignTextBoxOverDropDown();
-
- comboBoxArray[comboBoxArray.length] = this;
- }
-
- function SetAccessKey(Key)
- {
- this.Mytxt.accessKey = Key;
- }
-
- function CreateIPComboBoxObject(strDropDownListID, strComboBoxName)
- {
- this.MyIPcmb = document.all[strDropDownListID];
- this.MyIPcmb.selectedIndex = -1;
- this.UseStateFunctions = false;
- this.AlignIPCombo = AlignIPCombo;
- this.cboIP_OnChange = cboIP_OnChange;
- this.cboIPRange_OnChange = cboIPRange_OnChange;
- this.UseStateFunctions = false;
- this.AdjustingSize = false;
- this.IPAddressArrowUp = IPAddressArrowUp;
- this.IPAddressArrowDown = IPAddressArrowDown;
- this.IPRangeAddressArrowUp = IPRangeAddressArrowUp;
- this.IPRangeAddressArrowDown = IPRangeAddressArrowDown;
- this.AlignIPCombo();
-
- IPcomboBoxArray[IPcomboBoxArray.length] = this;
- }
-
- function CreateSUSComboBoxObject(strDropDownListID, strComboBoxName)
- {
- this.MySUScmb = document.all[strDropDownListID];
- this.MySUScmb.selectedIndex = -1;
- this.AlignSUSTextBoxOverDropDown = AlignSUSTextBoxOverDropDown;
- this.GetSUSSelectedText = GetSUSSelectedText;
- this.cboSUS_OnChange = cboSUS_OnChange;
- this.DisableSUS = DisableSUS;
- this.EnableSUS = EnableSUS;
- this.AdjustingSize = false;
- this.SetDefaultSUSText = SetDefaultSUSText;
- var strMytxtID = "txtMytxt" + strDropDownListID;
- var strMytxt = "<INPUT type='text' id=" + strMytxtID + " name=" + strMytxtID + " style='display: none; position: absolute' value='' >";
- this.MySUScmb.insertAdjacentHTML("afterEnd", strMytxt);
- //assign obj to new textbox
- this.MySUStxt = document.all[strMytxtID];
-
- this.AlignSUSTextBoxOverDropDown();
- SUScomboBoxArray[SUScomboBoxArray.length] = this;
- }
-
- function SetDefaultSUSText(Text)
- {
- this.MySUScmb.selectedIndex = -1;
- this.MySUStxt.value = Text;
- }
-
- function DisableSUS()
- {
- this.MySUScmb.disabled = true;
- this.MySUStxt.disabled = true;
- }
-
- function EnableSUS()
- {
- this.MySUScmb.disabled = false;
- this.MySUStxt.disabled = false;
- }
-
- function AlignIPCombos()
- {
- var iIndex;
- for (iIndex=0; iIndex < comboBoxArray.length; iIndex++)
- {
- IPcomboBoxArray[iIndex].AlignIPCombo();
- }
- }
-
- function AlignIPCombo()
- {
- if (!this.AdjustingSize)
- {
- var lastIPLeft = 0;
- var lastIPWidth = 0;
-
- this.AdjustingSize = true;
- this.MyIPcmb.style.width = 0; // let the combo not interfere on the window size
- this.MyIPcmb.style.position ="static";
- this.MyIPcmb.style.posLeft = GetAbsoluteXPosition(document.getElementById("IP1"));
- this.MyIPcmb.style.posTop = GetAbsoluteYPosition(document.getElementById("IP1"));
-
- this.MyIPcmb.style.position ="absolute";
-
- if(document.all["IP5"] != null && document.all["IP5"] != 'undefined')
- {//must be an IP Range
- lastIPLeft = GetAbsoluteXPosition(document.getElementById("IP8"));
- lastIPWidth = document.getElementById("IP8").clientWidth;
- }
- else
- {//single IP
- lastIPLeft = GetAbsoluteXPosition(document.getElementById("IP4"));
- lastIPWidth = document.getElementById("IP4").clientWidth;
- }
-
- this.MyIPcmb.style.width = (lastIPLeft + lastIPWidth) - this.MyIPcmb.style.posLeft + 20;
-
- var strClipRectangle = "rect(0 " +
- (this.MyIPcmb.offsetWidth) + " " +
- this.MyIPcmb.offsetHeight + " " +
- (this.MyIPcmb.offsetWidth - 18) + ")";
-
- this.MyIPcmb.style.clip = strClipRectangle;
- this.AdjustingSize = false;
- }
- }
-
- function AlignTextBoxesOverDropDowns()
- {
- var iIndex;
- for (iIndex=0; iIndex < comboBoxArray.length; iIndex++)
- {
- comboBoxArray[iIndex].AlignTextBoxOverDropDown();
- }
- }
-
- //sets the default option
- function SetDefaultText(Text)
- {
-
- this.Mycmb.selectedIndex = -1;
- this.Mytxt.value = Text;
- }
-
-
- //Move the textbox over the Combo
- function AlignTextBoxOverDropDown()
- {
- if (!this.AdjustingSize)
- {
- this.AdjustingSize = true;
- this.Mytxt.style.display="none";
- this.Mycmb.style.position="static";
-
- this.Mytxt.style.posLeft = GetAbsoluteXPosition(this.Mycmb);
- this.Mytxt.style.posTop = GetAbsoluteYPosition(this.Mycmb);
- this.Mytxt.style.posWidth = this.Mycmb.offsetWidth - 16; // 16 THIS IS THE WIDTH OF THE DROP DOWN ARROW
- this.Mytxt.style.posHeight = this.Mycmb.offsetHeight;
-
- this.Mycmb.style.position ="absolute";
- this.Mycmb.style.posLeft = this.Mytxt.style.posLeft;
- this.Mycmb.style.posTop = this.Mytxt.style.posTop;
-
- this.ComboWidth = this.Mycmb.offsetWidth;
- var strClipRectangle = "rect(0 " +
- (this.Mycmb.offsetWidth) + " " +
- this.Mycmb.offsetHeight + " " +
- (this.Mytxt.style.posWidth - 2 ) + ")";
-
- this.Mycmb.style.clip = strClipRectangle;
- this.Mytxt.style.display="";
- this.AdjustingSize = false;
- }
-
- }
-
- function AlignSUSCombos()
- {
- var iIndex;
- for (iIndex=0; iIndex < SUScomboBoxArray.length; iIndex++)
- {
- SUScomboBoxArray[iIndex].AlignSUSTextBoxOverDropDown();
- }
- }
-
- function AlignSUSTextBoxOverDropDown()
- {
- if (!this.AdjustingSize)
- {
- this.AdjustingSize = true;
- this.MySUStxt.style.display="none";
- this.MySUScmb.style.position="absolute";
-
- this.MySUStxt.style.posLeft = GetAbsoluteXPosition(document.getElementById("susMRUListContainer"));
- this.MySUStxt.style.posTop = GetAbsoluteYPosition(document.getElementById("susMRUListContainer")) + 3;
- this.MySUStxt.style.posWidth = this.MySUScmb.offsetWidth - 16; // 16 THIS IS THE WIDTH OF THE DROP DOWN ARROW
- this.MySUStxt.style.posHeight = this.MySUScmb.offsetHeight;
-
- this.MySUScmb.style.position ="absolute";
- this.MySUScmb.style.posLeft = this.MySUStxt.style.posLeft;
- this.MySUScmb.style.posTop = this.MySUStxt.style.posTop;
-
- this.ComboWidth = this.MySUScmb.offsetWidth;
- var strClipRectangle = "rect(0 " +
- (this.MySUScmb.offsetWidth) + " " +
- this.MySUScmb.offsetHeight + " " +
- (this.MySUStxt.style.posWidth - 2 ) + ")";
-
- this.MySUScmb.style.clip = strClipRectangle;
- this.MySUStxt.style.display="";
- this.AdjustingSize = false;
- }
-
- }
- function Clear()
- {
- this.Mytxt.value = "";
- this.Mycmb.selectedIndex = -1;
- }
-
- function GetAbsoluteXPosition(element)
- {
- var pos = 0;
- while (element != null)
- {
- pos += element.offsetLeft;
- element = element.offsetParent;
- }
-
- return pos;
- }
-
- function GetAbsoluteYPosition(element)
- {
- var pos = 0;
- while (element != null )
- {
- pos += element.offsetTop;
- element = element.offsetParent;
- }
-
- return pos;
- }
- function GetSUSSelectedText()
- {
- return this.MySUStxt.value;
- }
-
- function GetSelectedText()
- {
- return this.Mytxt.value;
- }
-
- function cboIP_OnChange()
- {
- var tmpIndex = this.MyIPcmb.selectedIndex;
- var tempOption = this.MyIPcmb.options[tmpIndex];
-
- var IPArr = tempOption.text.split(".")
- if( IPArr.length == 4 )
- {
- document.all["IP1"].value = IPArr["0"];
- document.all["IP2"].value = IPArr["1"];
- document.all["IP3"].value = IPArr["2"];
- document.all["IP4"].value = IPArr["3"];
- }
- else
- {
- document.all["IP1"].value = "";
- document.all["IP2"].value = "";
- document.all["IP3"].value = "";
- document.all["IP4"].value = "";
- }
-
- this.MyIPcmb.selectedIndex=-1;
- if(this.UseStateFunctions)
- {
- SetState("IP");
- }
- }
-
- function cboIPRange_OnChange()
- {
- var tmpIndex = this.MyIPcmb.selectedIndex;
- var tempOption = this.MyIPcmb.options[tmpIndex];
-
- var IPRange = tempOption.text;
- var IPArr = IPRange.split("to")
- var IP1 = IPArr["0"].split(".");
- var IP2 = IPArr["1"].split(".");
-
- if( IP1.length == 4 && IP2.length == 4 )
- {
- document.all["IP1"].value = IP1["0"];
- document.all["IP2"].value = IP1["1"];
- document.all["IP3"].value = IP1["2"];
- document.all["IP4"].value = IP1["3"].substring(0,IP1["3"].length-1);
- document.all["IP5"].value = IP2["0"].substring(1,IP2["0"].length);
- document.all["IP6"].value = IP2["1"];
- document.all["IP7"].value = IP2["2"];
- document.all["IP8"].value = IP2["3"];
- }
- else
- {
- document.all["IP1"].value = "";
- document.all["IP2"].value = "";
- document.all["IP3"].value = "";
- document.all["IP4"].value = "";
- document.all["IP5"].value = "";
- document.all["IP6"].value = "";
- document.all["IP7"].value = "";
- document.all["IP8"].value = "";
- }
-
- if(this.UseStateFunctions)
- {
- SetState("IP");
- }
- this.MyIPcmb.selectedIndex=-1;
- }
-
- function cbo_OnChange()
- {
- var tmpIndex = this.Mycmb.selectedIndex;
- var tempOption = this.Mycmb.options[tmpIndex];
- this.Mytxt.value = tempOption.text;
-
- this.Mytxt.focus();
- this.Mytxt.select();
-
- if(this.UseStateFunctions)
- {
- SetState("CPU");
- }
- this.Mycmb.selectedIndex=-1;
- test_ThisComputer(this.Mytxt);
- }
-
- function cboSUS_OnChange()
- {
-
- var tmpIndex = this.MySUScmb.selectedIndex;
- var tempOption = this.MySUScmb.options[tmpIndex];
-
- this.MySUStxt.value = tempOption.text;
-
- this.MySUStxt.focus();
- this.MySUStxt.select();
-
- this.MySUScmb.selectedIndex=-1;
- }
-
- // This method trims white space off both ends of this string and returns the result.
- function Trim(str)
- {
- return(str.replace(/^\s*/,'').replace(/\s*$/,''));
- }
-
- function test_ThisComputer(control)
- {
- if( ! document.all["thisComputerLabel"] )
- return;
-
- // assemble the domain\computername for this station
- thisComputerID = parent.Scanner.LocalDomain + "\\" + parent.Scanner.LocalMachine;
- isThisComputer = ( Trim(control.value.toUpperCase()) == Trim(thisComputerID.toUpperCase()) );
-
- if( isThisComputer )
- {
- document.all["thisComputerLabel"].value = Trim(parent.Scanner.ThisComputer);
- }
- else
- {
- document.all["thisComputerLabel"].value = "";
- }
- }
-
- function txt_OnKeyUp()
- {
- test_ThisComputer(this.Mytxt);
- if (this.LookupValues)
- {
- if (event.keyCode < 32)
- {
- return;
- }
- else if (event.keyCode == 46)
- {
- return;
- }
- else if (event.keyCode == 38)//up arrow
- {
- var len = this.Mycmb.options.length;
- if(len > 0)
- {
- var tempString;
- var curText = this.Mytxt.value;
- var FoundIndex = -1;
- for (var iIndex=0; iIndex<len; iIndex++)
- {
- tempString = this.Mycmb.options(iIndex).text;
-
- tempString = tempString.toUpperCase();
- curText = curText.toUpperCase();
- if (tempString == curText)
- {
- FoundIndex = iIndex;
- }
- }
- if(FoundIndex == -1)
- {
- //do nothing
- }
- else
- {
- if(FoundIndex > 0)
- {
- this.Mytxt.value = this.Mycmb.options(FoundIndex -1).text;
- var tmpRange = this.Mytxt.createTextRange();
- tmpRange.moveStart("character", this.Mytxt.length);
- tmpRange.select();
- SetState("CPU");
- }
- }
- }
- test_ThisComputer(this.Mytxt);
- return;
- }
- else if (event.keyCode == 40)//Down arrow
- {
- var len = this.Mycmb.options.length;
- if(len > 0)
- {
- var tempString;
- var curText = this.Mytxt.value;
- var FoundIndex = -1;
-
- for (var iIndex=0; iIndex<len; iIndex++)
- {
-
- tempString = this.Mycmb.options(iIndex).text;
- tempString = tempString.toUpperCase();
- curText = curText.toUpperCase();
- if (tempString == curText)
- {
- FoundIndex = iIndex;
- }
- }
- if(FoundIndex == -1)
- {
- this.Mytxt.value = this.Mycmb.options(0).text;
- var tmpRange = this.Mytxt.createTextRange();
- tmpRange.moveStart("character", this.Mytxt.length);
- tmpRange.select();
- SetState("CPU");
- }
- else
- {
- if(FoundIndex < this.Mycmb.options.length - 1)
- {
- this.Mytxt.value = this.Mycmb.options(FoundIndex + 1).text;
- var tmpRange = this.Mytxt.createTextRange();
- tmpRange.moveStart("character", this.Mytxt.length);
- tmpRange.select();
- SetState("CPU");
- }
- }
- }
- test_ThisComputer(this.Mytxt);
- return;
- }
- if(this.UseStateFunctions)
- {
- SetState("CPU");
- }
- var curText = this.Mytxt.value;
- var prevText = this.MytxtPreviousValue;
- var iIndex;
-
- if ((curText == "") || (curText == prevText))
- {
- this.MytxtPreviousValue = curText;
- return;
- }
-
- var len = this.Mycmb.options.length;
- var tempString;
-
- for (iIndex=0; iIndex<len; iIndex++)
- {
- tempString = this.Mycmb.options(iIndex).text;
-
- if (this.LookupCaseInSensitive)
- {
- tempString = tempString.toUpperCase();
- curText = curText.toUpperCase();
- }
-
- if (tempString.indexOf(curText) == 0)
- {
- var helperString = this.Mycmb.options(iIndex).text;
-
- this.Mytxt.value = this.Mytxt.value + helperString.substr(curText.length);
- this.Mycmb.selectedIndex = iIndex;
- this.MytxtPreviousValue = this.Mytxt.value;
-
- var tmpRange = this.Mytxt.createTextRange();
- tmpRange.moveStart("character", curText.length);
- tmpRange.select();
- test_ThisComputer(this.Mytxt);
- return;
- }
- }
- }
- }
-
- function txt_OnBlur()
- {
- var myDropDownList = this.Mycmb;
- var myEditCell = this.Mytxt;
- var myHiddenCell = this.MyHiddentxt;
- var iIndex;
-
- test_ThisComputer(this.Mytxt);
-
- myHiddenCell.value = myEditCell.value;
- myDropDownList.selectedIndex = -1;
-
- if (myEditCell.value == "")
- {
- return;
- }
-
- var len = myDropDownList.options.length;
- for (iIndex=0; iIndex<len; iIndex++)
- {
- var str1 = myDropDownList.options(iIndex).text;
- var str2 = myEditCell.value;
-
- if (this.LookupCaseInSensitive)
- {
- str1 = str1.toUpperCase();
- str2 = str2.toUpperCase();
- }
-
- if (str1 == str2)
- {
- myDropDownList.selectedIndex = iIndex;
- myHiddenCell.value = myDropDownList.options(iIndex).value;
- return;
- }
- }
-
- if (this._bOnlyAllowedEntries)
- {
- myDropDownList.focus();
-
- alert("\'" + myEditCell.value + "\' is not allowed");
- this.Mycmb.selectedIndex = -1;
- this.Mytxt.select();
-
- return;
- }
- }
-
- function txt_OnChange()
- {
- test_ThisComputer(this.Mytxt);
- if(this.UseStateFunctions)
- {
- SetState("CPU");
- }
- }
-
- function focus()
- {
- this.Mycmb.focus();
- }
-
- function setDefaultIndex(iIndex)
- {
- var len = this.Mycmb.options.length;
- if ((iIndex >=0) && (iIndex < len))
- {
- this.Mycmb.selectedIndex = iIndex;
- this.Mytxt.value = this.Mycmb.options(iIndex).text;
- this.MyHiddentxt.value = this.Mycmb.options(iIndex).value;
- return;
- }
-
- this.Mytxt.value = "";
- }
-
- function IPAddressArrowUp(curText)
- {
- var len = this.MyIPcmb.options.length;
- if(len > 0)
- {
- var tempString;
- var FoundIndex = -1;
- var NewValue = "";
- for (var iIndex=0; iIndex<len; iIndex++)
- {
- tempString = this.MyIPcmb.options(iIndex).text;
- if (tempString.toString() == curText.toString())
- {
- FoundIndex = iIndex;
- }
- }
- if(FoundIndex == -1)
- {
- //do nothing
- NewValue = curText;
- }
- else
- {
- if(FoundIndex > 0)
- {
- NewValue = this.MyIPcmb.options(FoundIndex -1).text;
- }
- }
- return NewValue;
- }
- else
- return "";
- }
- function IPAddressArrowDown(curText)
- {
- var len = this.MyIPcmb.options.length;
- if(len > 0)
- {
- var tempString;
- var NewValue = "";
- var FoundIndex = -1;
- for (var iIndex=0; iIndex<len; iIndex++)
- {
- tempString = this.MyIPcmb.options(iIndex).text;
-
- if (tempString.toString() == curText.toString())
- {
- FoundIndex = iIndex;
- }
- }
- if(FoundIndex == -1)
- {
- NewValue = this.MyIPcmb.options(0).text;
- }
- else
- {
- if(FoundIndex < this.MyIPcmb.options.length - 1)
- {
- NewValue = this.MyIPcmb.options(FoundIndex + 1).text;
- }
- }
-
- return NewValue;
- }
- else
- return "";
- }
-
- function IPRangeAddressArrowUp(curText)
- {
- var len = this.MyIPcmb.options.length;
-
- if(len > 0)
- {
- var curIPArr = curText.split("to");
- var curIP1 = curIPArr["0"].substring(0,curIPArr["0"].length -1);
- var curIP2 = curIPArr["1"].substring(1,curIPArr["1"].length -1);
-
- var tempString;
- var FoundIndex = -1;
- var NewValue = "";
- for (var iIndex=0; iIndex<len; iIndex++)
- {
- tempString = this.MyIPcmb.options(iIndex).text;
-
- var IPArr = tempString.split("to");
- var IP1 = IPArr["0"].substring(0,IPArr["0"].length -1);
- var IP2 = IPArr["1"].substring(1,IPArr["1"].length -1);
- if (curIP1.toString() == IP1.toString() && curIP2.toString() == IP2.toString())
- {
- FoundIndex = iIndex;
- }
- }
- if(FoundIndex == -1)
- {
- //do nothing
- NewValue = curText;
- }
- else
- {
- if(FoundIndex > 0)
- {
- NewValue = this.MyIPcmb.options(FoundIndex -1).text;
- }
- }
- return NewValue;
- }
- else
- return "";
- }
-
- function IPRangeAddressArrowDown(curText)
- {
- var len = this.MyIPcmb.options.length;
-
- if(len > 0)
- {
- var curIPArr = curText.split("to");
- var curIP1 = curIPArr["0"].substring(0,curIPArr["0"].length -1);
- var curIP2 = curIPArr["1"].substring(1,curIPArr["1"].length -1);
-
- var tempString;
- var FoundIndex = -1;
- var NewValue = "";
- for (var iIndex=0; iIndex<len; iIndex++)
- {
- tempString = this.MyIPcmb.options(iIndex).text;
-
- var IPArr = tempString.split("to");
- var IP1 = IPArr["0"].substring(0,IPArr["0"].length -1);
- var IP2 = IPArr["1"].substring(1,IPArr["1"].length -1);
- if (curIP1.toString() == IP1.toString() && curIP2.toString() == IP2.toString())
- {
- FoundIndex = iIndex;
- }
- }
- if(FoundIndex == -1)
- {
- //do nothing
- NewValue = curText;
- }
- else
- {
- if(FoundIndex < this.MyIPcmb.options.length - 1)
- {
- NewValue = this.MyIPcmb.options(FoundIndex + 1).text;
- }
- }
- return NewValue;
- }
- else
- return "";
-
- }
-