//- Popup Console -// var g_PopupSelectList = new Object(); //- PopupConsole_BodyOnLoad -// function PopupConsole_Initialize() { g_PopupSelectList } //- PopupConsole_Add -// function PopupConsole_Add(cKey, cUrl, cWindowName, cStyle) { var nWindowKey = window.open(cUrl, cWindowName, cStyle); nWindowKey.focus(); } //- PopupConsole_AddItem -// function PopupConsole_AddItem(oForm, oField, oSelectField, cKey, cValue) { cKey = unescape(cKey).replace(/\+/, ' '); if ((',' + oField.value + ',').indexOf(',' + cKey + ',') == -1) { cValue = unescape(cValue).replace(/\+/, ' '); //+ oField.value += ',' + cKey; oSelectField.options.add(new Option(cValue, cKey, false, false)); } } //- PopupConsole_Remove -// function PopupConsole_Remove(oForm, oField, oSelectField, cRemoveKeyList) { cRemoveKeyList = unescape(cRemoveKeyList).replace(/\+/, ' '); var cKeyList = ',' + oField.value + ','; for (nOptionKey = oSelectField.options.length - 1; nOptionKey >= 0 ; nOptionKey--) { if (cRemoveKeyList.indexOf(',' + oSelectField.options[nOptionKey].value + ',') > -1) { cKeyList = cKeyList.replace(new RegExp(',' + oSelectField.options[nOptionKey].value + ',', 'gi'), ','); oSelectField.options[nOptionKey] = null; } } oField.value = CleanList(cKeyList); } //- PopupConsole_RemoveAll -// function PopupConsole_RemoveAll(oForm, oField, oSelectField) { oSelectField.options.length = 0; oField.value = ''; } //- PopupConsole_RemoveSelected -// function PopupConsole_RemoveSelected(oForm, oField, oSelectField) { for (nOptionKey = oSelectField.options.length - 1; nOptionKey >= 0; nOptionKey--) { if (oSelectField.options[nOptionKey].selected == true) { oSelectField.options[nOptionKey] = null; } } //+ var cKeyList = ''; for (nOptionKey = 0; nOptionKey < oSelectField.options.length; nOptionKey++) { cKeyList += ',' + oSelectField.options[nOptionKey].value; } oField.value = CleanList(cKeyList); } //- Select List -// function SelectSetAllCheck(oSetField, cId, bIsCheck, cCallBack) { if ((oSetField == null) || (cId == null)) { return; } //+ var bIsCallbackDefined = ((typeof(SelectSetAllCheckCallback) == 'undefined') ? false : true); //+ var oForm = oSetField.form; var nKey = 1; var cItemPrefix = 'Item' + cId; while (oForm[cItemPrefix + nKey] != null) { var oCheckbox = oForm[cItemPrefix + nKey]; var bIsChanged = (oCheckbox.checked != bIsCheck); oCheckbox.checked = bIsCheck; SelectListCheck(oSetField, oCheckbox); HighlightRow('Column' + cId + nKey, oCheckbox, 'SelectTdC', oForm['ItemClass' + cId + nKey].value); if (bIsCallbackDefined == true) { SelectSetAllCheckCallback(oCheckbox, bIsChanged); } nKey++; } } function SelectListCheck(oSetField, oCheckBox) { if ((oSetField == null) || (oCheckBox == null)) { return; } //+ var cSetValue = ',' + ((oSetField.value == null) ? '' : oSetField.value) + ','; var cCheckBoxValue = oCheckBox.value; if (oCheckBox.checked == true) { if (cSetValue == ',,') { cSetValue = cCheckBoxValue; } else if (cSetValue.indexOf(',' + cCheckBoxValue + ',') == -1) { cSetValue += cCheckBoxValue; } } else if (cSetValue.indexOf(',' + cCheckBoxValue + ',') > -1) { cSetValue = cSetValue.replace(new RegExp(',' + cCheckBoxValue + ',', 'gi'), ','); } oSetField.value = CleanList(cSetValue); } function SelectSingleCheck(oSetField, oCheckBox) { if ((oSetField == null) || (oCheckBox == null)) { return; } //+ var oForm = oCheckBox.form; var oFormElement = oForm.elements; for (nElementKey = 0; nElementKey < oFormElement.length; nElementKey++) { var oElement = oFormElement[nElementKey]; if ((oElement.name != oCheckBox.name) && (oElement.type == 'checkbox') && (oElement.name.substr(0, 5) == 'Item_') && (oElement.checked == true)) { oElement.checked = false; var cIdPrefix = oElement.name.replace(/Item_/i, 'Column_'); var cUncheckedClass = oForm[oElement.name.replace(/Item_/gi, 'ItemClass_')].value; HighlightRow(cIdPrefix, oElement, 'SelectTdC', cUncheckedClass); } } if (oCheckBox.checked == true) { oSetField.value = CleanList(oCheckBox.value); } else { oSetField.value = ''; } } function SelectAllOnPage(oSetField, oCheckBox) { if ((oSetField == null) || (oCheckBox == null)) { return; } //+ var oForm = oCheckBox.form; var oFormElement = oForm.elements; for (nElementKey = 0; nElementKey < oFormElement.length; nElementKey++) { var oElement = oFormElement[nElementKey]; if ((oElement.name != oCheckBox.name) && (oElement.type == 'checkbox') && (oElement.name.substr(0, 5) == 'Item_') && (oElement.checked == true)) { oElement.checked = false; var cIdPrefix = oElement.name.replace(/Item_/i, 'Column_'); var cUncheckedClass = oForm[oElement.name.replace(/Item_/gi, 'ItemClass_')].value; HighlightRow(cIdPrefix, oElement, 'SelectTdC', cUncheckedClass); } } if (oCheckBox.checked == true) { oSetField.value = CleanList(oCheckBox.value); } else { oSetField.value = ''; } } function SetPrimary(oField, oSelectField, oPrimaryKeyField, oPrimaryValueField) { if (oSelectField.selectedIndex == -1) { alert('Please select an item'); } else { var oOption = oSelectField.options[oSelectField.selectedIndex]; oPrimaryKeyField.value = oOption.value; oPrimaryValueField.value = oOption.text; oOption = null; } } function ValidatePrimary(oField, oSelectField, oPrimaryKeyField, oPrimaryValueField) { if ((oField == null) || (oPrimaryKeyField == null)) { return; } //+ if ((',' + oField.value + ',').indexOf(',' + oPrimaryKeyField.value + ',') == -1) { oPrimaryKeyField.value = ''; oPrimaryValueField.value = ''; } } function HighlightRow(cIdPrefix, oCheckBox, cCheckedClass, cUncheckedClass) { if (oCheckBox == null) { return; } //+ var cClass; if (oCheckBox.checked == true) { cClass = cCheckedClass; } else { cClass = cUncheckedClass; } var nColumn = 1; cIdPrefix += '_'; while (1 == 1) { var oCell = document.getElementById(cIdPrefix + nColumn); if (oCell == null) { break; } oCell.className = cClass; nColumn++; } oCell = null; } //- CleanList -// function CleanList(cList) { if (cList.substr(0, 1) == ',') { cList = cList.substr(1); } if (cList.substr(cList.length - 1, 1) == ',') { cList = cList.substr(0, cList.length - 1); } return cList.replace(/,,/gi, ','); }