where is this function getting its values from

Posted by user295189 on Stack Overflow See other posts from Stack Overflow or by user295189
Published on 2010-04-16T20:54:08Z Indexed on 2010/04/16 21:03 UTC
Read the original article Hit count: 579

Filed under:
|
|

I have the JS file below that I am working on and I have a need to know this specific function pg.getRecord_Response = function(){ } within the file. I need to know where are the values are coming from in this function for example arguments[0].responseText? I am new to javascript so any help will be much appreciated. Thanks

var pg = new Object();
var da = document.body.all;

// ===== - EXPRESS BUILD [REQUEST] - ===== //
pg.expressBuild_Request = function(){
    var n = new Object();
    n.patientID = request.patientID;
    n.encounterID = request.encounterID;
    n.flowSheetID = request.flowSheetID;
    n.encounterPlan = request.encounterPlan;
    n.action = "/location/diagnosis/dsp_expressBuild.php";
    n.target = popWinCenterScreen("/common/html/empty.htm", 619, 757, "");
    myLocationDB.PostRequest(n);
}

// ===== - EXPRESS BUILD [RESPONSE] - ===== //
pg.expressBuild_Response = function(){
    pg.records.showHiddenRecords = 0;
    pg.loadRecords_Request(arguments.length ? arguments[0] : 0);
}

// ===== - GET RECORD [REQUEST] - ===== //
pg.getRecord_Request = function(){
    if(pg.records.lastSelected){
        pg.workin(true);

        pg.record.recordID = pg.records.lastSelected.i;

        var n = new Object();
        n.noheaders = 1;
        n.recordID = pg.record.recordID;
        myLocationDB.Ajax.Post("/location/diagnosis/get_record.php", n, pg.getRecord_Response);


    } else {
        pg.buttons.btnOpen.disable(true);
    }
}

// ===== - GET RECORD [RESPONSE] - ===== //
pg.getRecord_Response = function(){
    //alert(arguments[0].responseText);
    if(arguments.length && arguments[0].responseText){
                alert(arguments[0].responseText);
        // Refresh PQRI grid when encounter context
        if(request.encounterID && window.parent.frames['main']){
            window.parent.frames['main'].pg.loadQualityMeasureRequest();
        }

        var rec = arguments[0].responseText.split(pg.delim + pg.delim);

        if(rec.length == 20){
            // validate record values
            rec[0] = parseInt(rec[0]);
            rec[3] = parseInt(rec[3]);
            rec[5] = parseInt(rec[5]);
            rec[6] = parseInt(rec[6]);
            rec[7] = parseInt(rec[7]);
            rec[8] = parseInt(rec[8]);
            rec[9] = parseInt(rec[9]);
            rec[10] = parseInt(rec[10]);
            rec[11] = parseInt(rec[11]);
            rec[12] = parseInt(rec[12]);
            rec[15] = parseInt(rec[15]);

            // set record state
            pg.recordState = {
                recordID: pg.record.recordID,
                codeID: rec[0],
                description: rec[2],
                assessmentTypeID: rec[3],
                type: rec[4],
                onsetDateYear: rec[5],
                onsetDateMonth: rec[6],
                onsetDateDay: rec[7],
                onsetDateIsApproximate: rec[8],
                resolveDateYear: rec[9],
                resolveDateMonth: rec[10],
                resolveDateDay: rec[11],
                resolveDateIsApproximate: rec[12],
                commentsCount: rec[15],
                comments: rec[16]
            }

            // set record view
            pg.record.code.codeID = pg.recordState.codeID;
            pg.record.code.value = rec[1];

            pg.record.description.value = rec[2];

            for(var i=0; i<pg.record.type.options.length; i++){
                if(pg.record.type.options[i].value == rec[4]){
                    pg.record.type.selectedIndex = i;
                    break;
                }
            }

            for(var i=0; i<pg.record.assessmentType.options.length; i++){
                if(pg.record.assessmentType.options[i].value == rec[3]){
                    pg.record.assessmentType.selectedIndex = i;
                    break;
                }
            }

            if(rec[5]){
                if(rec[6] && rec[7]){
                    pg.record.onsetDateType.selectedIndex = 0;
                    pg.record.onsetDate.value = rec[6] + "/" + rec[7] + "/" + rec[5];
                    pg.record.onsetDate.format();
                } else {
                    pg.record.onsetDateType.selectedIndex = 1;

                    pg.record.onsetDateMonth.selectedIndex = rec[6];
                    for(var i=0; i<pg.record.onsetDateYear.options.length; i++){
                        if(pg.record.onsetDateYear.options[i].value == rec[5]){
                            pg.record.onsetDateYear.selectedIndex = i;
                            break;
                        }
                    }

                    if(rec[8]) pg.record.chkOnsetDateIsApproximate.checked = true;
                }
            } else {
                pg.record.onsetDateType.selectedIndex = 2;
            }

            if(rec[9]){
                if(rec[10] && rec[11]){
                    pg.record.resolveDateType.selectedIndex = 0;
                    pg.record.resolveDate.value = rec[10] + "/" + rec[11] + "/" + rec[9];
                    pg.record.resolveDate.format();
                } else {
                    pg.record.resolveDateType.selectedIndex = 1;

                    pg.record.resolveDateMonth.selectedIndex = rec[10];
                    for(var i=0; i<pg.record.resolveDateYear.options[i].length; i++){
                        if(pg.record.resolveDateYear.options.value == rec[9]){
                            pg.record.resolveDateYear.selectedIndex = i;
                            break;
                        }
                    }

                    if(rec[12]) pg.record.chkResolveDateIsApproximate.checked = true;
                }
            } else {
                pg.record.resolveDateType.selectedIndex = 2;
            }

            pg.record.lblCommentCount.innerHTML = rec[15];
            pg.record.comments.value = rec[16];

            pg.record.lblUpdatedBy.innerHTML = "* Last updated by " + rec[13] + " on " + rec[14];
            pg.record.lblUpdatedBy.title = "Updated by: " + rec[13] + "\nUpdated on: " + rec[14];

            pg.record.linkedNotes.setData(rec[18]);
            pg.record.linkedOrders.setData(rec[19]);
            pg.record.updates.setData(rec[17]);
            return;
        }
    }
    alert("An error occured while attempting to retrieve\ndetails for record #" + pg.record.recordID + ".\n\nPlease contact support if this problem persists.\nWe apologize for the inconvenience.");
    pg.hideRecordView();
}

// ===== - HIDE COMMENTS VIEW - ===== //
pg.hideCommentsView = function(){
    pg.recordComments.style.left = "";
    pg.recordComments.disabled = true;

    pg.recordComments.comments.value = "";

    pg.record.disabled = false;
    pg.record.style.zIndex = 5500;
}

// ===== - HIDE code SEARCH - ===== //
pg.hidecodeSearch = function(){
    pg.codeSearch.style.left = "";
    pg.codeSearch.disabled = true;

    pg.record.disabled = false;
    pg.record.style.zIndex = 5500;
}

// ===== - HIDE RECORD - ===== //
pg.hideRecord = function(){
    if(arguments.length){
        pg.loadRecords_Request();
    } else if(pg.records.lastSelected){
        var n = new Object();
        n.recordTypeID = 11;
        n.patientID = request.patientID;
        n.recordID = pg.records.lastSelected.i;
        n.action = "/location/hideRecord/dsp_hideRecord.php";
        n.target = popWinCenterScreen("/common/html/empty.htm", 164, 476);
        myLocationDB.PostRequest(n);
    }
}

// ===== - HIDE RECORD VIEW - ===== //
pg.hideRecordView = function(){
    pg.record.style.left = "";
    pg.record.disabled = true;

    // reset record grids
    pg.record.updates.state = "NO_RECORDS";
    pg.record.linkedNotes.state = "NO_RECORDS";
    pg.record.linkedOrders.state = "NO_RECORDS";

    // reset linked record tabs
    pg.record.tabs[0].click();
    pg.record.tabs[1].disable(true);
    pg.record.tabs[2].disable(true);
    pg.record.tabs[1].all[1].innerHTML = "Notes";
    pg.record.tabs[2].all[1].innerHTML = "Orders";

    // reset record state
    pg.recordState = null;

    // reset record view
    pg.record.recordID = 0;
    pg.record.code.value = "";
    pg.record.code.codeID = 0;
    pg.record.description.value = "";
    pg.record.type.selectedIndex = 0;
    pg.record.assessmentType.selectedIndex = 0;
    pg.record.onsetDateType.selectedIndex = 0;
    pg.record.chkOnsetDateIsApproximate.checked = false;
    pg.record.resolveDateType.selectedIndex = 0;
    pg.record.chkResolveDateIsApproximate.checked = false;
    pg.record.lblCommentCount.innerHTML = 0;
    pg.record.comments.value = "";
    pg.record.lblUpdatedBy.innerHTML = "";
    pg.record.lblUpdatedBy.title = "";

    pg.record.updateComment = "";
    pg.recordComments.comments.value = "";

    pg.record.active = false;
    pg.codeSearch.newRecord = true;

    pg.blocker.className = "";
    pg.workin(false);
}

// ===== - HIDE UPDATE VIEW - ===== //
pg.hideUpdateView = function(){
    pg.recordUpdate.style.left = "";
    pg.recordUpdate.disabled = true;

    pg.recordUpdate.type.value = "";
    pg.recordUpdate.onsetDate.value = "";
    pg.recordUpdate.description.value = "";
    pg.recordUpdate.resolveDate.value = "";
    pg.recordUpdate.assessmentType.value = "";

    pg.record.disabled = false;
    pg.record.btnViewUpdate.setState();
    pg.record.style.zIndex = 5500;
}

// ===== - INIT - ===== //
pg.init = function(){
    var tab = 1;

    pg.delim = String.fromCharCode(127);
    pg.subDelim = String.fromCharCode(1);

    pg.blocker = da.blocker;
    pg.hourglass = da.hourglass;
    pg.pageContent = da.pageContent;
    pg.blocker.shim = da.blocker_shim;

    pg.activeTip = da.activeTip;
    pg.activeTip.anchor = null;
    pg.activeTip.shim = da.activeTip_shim;

    // PAGE TITLE
    pg.pageTitle = da.pageTitle;

    // TOTAL RECORDS
    pg.totalRecords = da.totalRecords[0];

    // START RECORD
    pg.startRecord = da.startRecord[0];
    pg.startRecord.onchange = function(){
        pg.records.startRecord = this.value;
        pg.loadRecords_Request();
    }

    // RECORD PANEL
    pg.recordPanel = myLocationDB.RecordPanel(pg.pageContent.all.recordPanel);
    for(var i=0; i<pg.recordPanel.buttons.length; i++){
        if(pg.recordPanel.buttons[i].orderBy){
            pg.recordPanel.buttons[i].onclick = pg.sortRecords;
        }
    }

    // RECORDS GRIDVIEW
    pg.records = pg.recordPanel.all.grid;
    alert(pg.recordPanel.all.grid);
    pg.records.sortOrder = "DESC";
    pg.records.lastExpanded = null;
    pg.records.attachEvent("onrowclick", pg.record_click);
    pg.records.orderBy = pg.recordPanel.buttons[0].orderBy;
    pg.records.attachEvent("onrowmouseout", pg.record_mouseOut);
    pg.records.attachEvent("onrowdblclick", pg.getRecord_Request);
    pg.records.attachEvent("onrowmouseover", pg.record_mouseOver);
    pg.records.attachEvent("onstateready", pg.loadRecords_Response);

    // BUTTON - TOGGLE HIDDEN RECORDS
    pg.btnHiddenRecords = myLocationDB.Custom.ImageButton(3, 751, 19, 19, "/common/images/hide.gif", 1, 1, "", "", da.pageContent);
    pg.btnHiddenRecords.setTitle("Show hidden records");
    pg.btnHiddenRecords.onclick = pg.toggleHiddenRecords;
    pg.btnHiddenRecords.setState = function(){
        this.disable(!pg.records.totalHiddenRecords);
    }

    // code SEARCH SUBWIN
    pg.codeSearch = da.subWin_codeSearch;
    pg.codeSearch.newRecord = true;
    pg.codeSearch.searchType = "code";
    pg.codeSearch.searchFavorites = true;
    pg.codeSearch.onkeydown = function(){
        if(window.event && window.event.keyCode && window.event.keyCode == 113){
            if(pg.codeSearch.searchType == "DESCRIPTION"){
                pg.codeSearch.searchType = "code";
                pg.codeSearch.lblSearchType.innerHTML = "ICD-9 Code";
            } else {
                pg.codeSearch.searchType = "DESCRIPTION";
                pg.codeSearch.lblSearchType.innerHTML = "Description";
            }
            pg.searchcodes_Request();
        }
    }

    // SEARCH TYPE
    pg.codeSearch.lblSearchType = pg.codeSearch.all.lblSearchType;

    // SEARCH STRING
    pg.codeSearch.searchString = pg.codeSearch.all.searchString;
    pg.codeSearch.searchString.tabIndex = 1;
    pg.codeSearch.searchString.onfocus = function(){ this.select(); }
    pg.codeSearch.searchString.onblur = function(){ this.value = this.value.trim(); }
    pg.codeSearch.searchString.onkeydown = function(){
        if(window.event && window.event.keyCode && window.event.keyCode == 13){
            pg.searchcodes_Request();
        }
    }

    // -- "SEARCH"
    pg.codeSearch.btnSearch = pg.codeSearch.all.btnSearch;
    pg.codeSearch.btnSearch.tabIndex = 2;
    pg.codeSearch.btnSearch.disable = myLocationDB.Disable;
    pg.codeSearch.btnSearch.onclick = pg.searchcodes_Request;
    pg.codeSearch.btnSearch.baseTitle = "Search diagnosis codes";
    pg.codeSearch.btnSearch.setState = function(){
        pg.codeSearch.btnSearch.disable(pg.codeSearch.searchString.value.trim().length < 2);
    }
    pg.codeSearch.searchString.onkeyup = pg.codeSearch.btnSearch.setState;

    // START RECORD / TOTAL RECORDS
    pg.codeSearch.startRecord = pg.codeSearch.all.startRecord;
    pg.codeSearch.totalRecords = pg.codeSearch.all.totalRecords;
    pg.codeSearch.startRecord.onchange = function(){
        pg.codeSearch.records.startRecord = this.value;
        pg.searchcodes_Request();
    }

    // RECORD PANEL
    pg.codeSearch.recordPanel = myLocationDB.RecordPanel(pg.codeSearch.all.recordPanel);
    pg.codeSearch.recordPanel.buttons[0].onclick = pg.sortcodeResults;
    pg.codeSearch.recordPanel.buttons[1].onclick = pg.sortcodeResults;

    // DATA GRIDVIEW
    pg.codeSearch.records = pg.codeSearch.all.grid;
    pg.codeSearch.records.orderBy = "code";
    pg.codeSearch.records.attachEvent("onrowdblclick", pg.updatecode);
    pg.codeSearch.records.attachEvent("onstateready", pg.searchcodes_Response);

    // BUTTON - "CANCEL"
    pg.codeSearch.btnCancel = pg.codeSearch.all.btnCancel;
    pg.codeSearch.btnCancel.tabIndex = 4;
    pg.codeSearch.btnCancel.onclick = pg.hidecodeSearch;
    pg.codeSearch.btnCancel.title = "Close this search area";

    // SEARCH FAVORITES / ALL
    pg.codeSearch.optSearch = myLocationDB.InputButton(pg.codeSearch.all.optSearch);
    pg.codeSearch.optSearch[0].onclick = function(){
        if(pg.codeSearch.searchFavorites){
            pg.codeSearch.searchString.focus();
        } else {
            pg.codeSearch.searchFavorites = true;
            pg.searchcodes_Request();
        }
    }
    pg.codeSearch.optSearch[1].onclick = function(){
        if(pg.codeSearch.searchFavorites){
            pg.codeSearch.searchFavorites = false;
            pg.searchcodes_Request();
        } else {
            pg.codeSearch.searchString.focus();
        }
    }

    // -- "USE SELECTED"
    pg.codeSearch.btnUseSelected = pg.codeSearch.all.btnUseSelected;
    pg.codeSearch.btnUseSelected.tabIndex = 3;
    pg.codeSearch.btnUseSelected.onclick = pg.updatecode;
    pg.codeSearch.btnUseSelected.disable = myLocationDB.Disable;
    pg.codeSearch.btnUseSelected.baseTitle = "Use the selected diagnosis code";
    pg.codeSearch.btnUseSelected.setState = function(){
        pg.codeSearch.btnUseSelected.disable(!pg.codeSearch.records.lastSelected);
    }
    pg.codeSearch.records.attachEvent("onrowclick", pg.codeSearch.btnUseSelected.setState);

    // RECORD STATE
    pg.recordState = null;

    // RECORD SUBWIN
    pg.record = da.subWin_record;
    pg.record.recordID = 0;
    pg.record.active = false;
    pg.record.updateComment = "";

    // -- TABS
    pg.record.tabs = myLocationDB.TabCollection(
        pg.record.all.tab,
        function(){
            if(pg.record.tabs[0].all[0].checked){
                pg.record.btnOpen.style.display = "none";
                pg.record.chkSelectAll.hitArea.style.display = "none";

                pg.record.btnSave.style.display = "block";
                pg.record.lblUpdatedBy.style.display = "block";

                pg.record.pnlRecord_shim.style.display = "none";
            } else {
                pg.record.pnlRecord_shim.style.display = "block";

                pg.record.btnSave.style.display = "none";
                pg.record.lblUpdatedBy.style.display = "none";

                pg.record.btnOpen.setState();
                pg.record.btnOpen.style.display = "block";

                if(pg.record.tabs[2].all[0].checked){
                    pg.record.chkSelectAll.hitArea.style.display = "none";
                    //pg.record.btnViewLabs.setState();
                    //pg.record.btnViewLabs.style.display = "block";
                } else {
                    pg.record.chkSelectAll.setState();
                    pg.record.chkSelectAll.hitArea.style.display = "block";
                    //pg.record.btnViewLabs.style.display = "none";
                }
            }
        }
    );
    pg.record.tabs[1].disable(true);
    pg.record.tabs[2].disable(true);

    pg.record.pnlRecord_shim = pg.record.all.pnlRecord_shim;

    pg.record.code = pg.record.all.code;
    pg.record.code.codeID = 0;
    pg.record.code.tabIndex = -1;

    // -- CHANGE code
    pg.record.btnChangecode = myLocationDB.Custom.ImageButton(6, 107, 22, 22, "/common/images/edit.gif", 2, 2, "", "", pg.record.all.pnlRecord);
    pg.record.btnChangecode.tabIndex = 1;
    pg.record.btnChangecode.onclick = pg.showcodeSearch;
    pg.record.btnChangecode.title = "Change the diagnosis code for this problem";

    pg.record.description = pg.record.all.description;
    pg.record.description.tabIndex = 2;

    pg.record.type = pg.record.all.type;
    pg.record.type.tabIndex = 3;

    pg.record.assessmentType = pg.record.all.assessmentType;
    pg.record.assessmentType.tabIndex = 9;

    // ONSET DATE
    pg.record.onsetDateType = pg.record.all.onsetDateType;
    pg.record.onsetDateType.tabIndex = 4;
    pg.record.onsetDateType.onchange = pg.record.onsetDateType.setState = function(){
        switch(this.selectedIndex){
            case 1: // PARTIAL
                pg.record.chkOnsetDateIsApproximate.disable(false);
                pg.record.onsetDate.style.visibility = "hidden";
                pg.record.onsetDateUnknown.style.visibility = "hidden";
                pg.record.onsetDate.datePicker.style.visibility = "hidden";

                pg.record.onsetDateMonth.style.visibility = "visible";
                pg.record.onsetDateYear.style.visibility = "visible";
                break;
            case 2: // UNKNOWN
                pg.record.chkOnsetDateIsApproximate.disable(true);
                pg.record.onsetDate.style.visibility = "hidden";
                pg.record.onsetDateYear.style.visibility = "hidden";
                pg.record.onsetDateMonth.style.visibility = "hidden";
                pg.record.onsetDate.datePicker.style.visibility = "hidden";

                pg.record.onsetDateUnknown.style.visibility = "visible";
                break;
            default: // "WHOLE"
                pg.record.chkOnsetDateIsApproximate.disable(true);
                pg.record.onsetDateMonth.style.visibility = "hidden";
                pg.record.onsetDateYear.style.visibility = "hidden";
                pg.record.onsetDateUnknown.style.visibility = "hidden";

                pg.record.onsetDate.style.visibility = "visible";
                pg.record.onsetDate.datePicker.style.visibility = "visible";
                break;
        }
    }

    pg.record.onsetDate = myLocationDB.Custom.DateInput(30, 364, 80, pg.record.all.pnlRecord, 1, 1, 0, params.todayDate, 1);
    pg.record.onsetDate.tabIndex = 5;
    pg.record.onsetDate.style.textAlign = "LEFT";
    pg.record.onsetDate.calendar.style.zIndex = 6000;
    pg.record.onsetDate.datePicker.style.left = "448px";
    pg.record.onsetDate.setDateRange(params.birthDate, params.todayDate);

    pg.record.onsetDateYear = pg.record.all.onsetDateYear;
    pg.record.onsetDateYear.tabIndex = 6;
    pg.record.onsetDateMonth = pg.record.all.onsetDateMonth
    pg.record.onsetDateMonth.tabIndex = 7;
    pg.record.onsetDateUnknown = pg.record.all.onsetDateUnknown;
    pg.record.onsetDateUnknown.tabIndex = 8;

    pg.record.chkOnsetDateIsApproximate = myLocationDB.InputButton(pg.record.all.chkOnsetDateIsApproximate);
    pg.record.chkOnsetDateIsApproximate.setTitle("Onset date is approximate");
    pg.record.chkOnsetDateIsApproximate.disable(true);

    // RESOLVE DATE
    pg.record.lblResolveDate = pg.record.all.lblResolveDate;
    pg.record.resolveDateType = pg.record.all.resolveDateType;
    pg.record.resolveDateType.tabIndex = 10;
    pg.record.resolveDateType.lastSelectedIndex = 0;
    pg.record.resolveDateType.setState = function(){
        switch(this.selectedIndex){
            case 1: // PARTIAL
                pg.record.chkResolveDateIsApproximate.disable(false);
                pg.record.resolveDate.style.visibility = "hidden";
                pg.record.resolveDateUnknown.style.visibility = "hidden";
                pg.record.resolveDate.datePicker.style.visibility = "hidden";

                pg.record.resolveDateMonth.style.visibility = "visible";
                pg.record.resolveDateYear.style.visibility = "visible";
                break;
            case 2: // UNKNOWN
                pg.record.chkResolveDateIsApproximate.disable(true);
                pg.record.resolveDate.style.visibility = "hidden";
                pg.record.resolveDateYear.style.visibility = "hidden";
                pg.record.resolveDateMonth.style.visibility = "hidden";
                pg.record.resolveDate.datePicker.style.visibility = "hidden";

                pg.record.resolveDateUnknown.style.visibility = "visible";
                break;
            default: // "WHOLE"
                pg.record.chkResolveDateIsApproximate.disable(true);
                pg.record.resolveDateMonth.style.visibility = "hidden";
                pg.record.resolveDateYear.style.visibility = "hidden";
                pg.record.resolveDateUnknown.style.visibility = "hidden";

                pg.record.resolveDate.style.visibility = "visible";
                pg.record.resolveDate.datePicker.style.visibility = "visible";
                break;
        }
    }
    pg.record.resolveDateType.onchange = function(){
        this.lastSelectedIndex = this.selectedIndex;
        this.setState();
    }

    pg.record.resolveDate = myLocationDB.Custom.DateInput(55, 364, 80, pg.record.all.pnlRecord, 1, 1, 0, params.todayDate, 1);
    pg.record.resolveDate.tabIndex = 11;
    pg.record.resolveDate.style.textAlign = "LEFT";
    pg.record.resolveDate.calendar.style.zIndex = 6000;
    pg.record.resolveDate.datePicker.style.left = "448px";
    pg.record.resolveDate.setDateRange(params.birthDate, params.todayDate);

    pg.record.resolveDate.setState = function(){
        if(pg.record.assessmentType.value == 15){
            pg.record.chkResolveDateIsApproximate.disable(pg.record.resolveDateType.value != "PARTIAL");

            pg.record.resolveDate.disabled = false;
            pg.record.lblResolveDate.disabled = false;
            pg.record.resolveDateType.selectedIndex = pg.record.resolveDateType.lastSelectedIndex;
            pg.record.resolveDateType.setState();
            pg.record.resolveDate.datePicker.disable(false);

            pg.record.resolveDateType.disabled = false;
            pg.record.resolveDateYear.disabled = false;
            pg.record.resolveDateMonth.disabled = false;
            pg.record.resolveDateUnknown.disabled = false;
        } else {
            pg.record.resolveDate.datePicker.disable(true);
            pg.record.chkResolveDateIsApproximate.disable(true);

            pg.record.resolveDateType.selectedIndex = 2;
            pg.record.resolveDateType.setState();

            pg.record.resolveDate.disabled = true;
            pg.record.lblResolveDate.disabled = true;
            pg.record.resolveDateType.disabled = true;
            pg.record.resolveDateYear.disabled = true;
            pg.record.resolveDateMonth.disabled = true;
            pg.record.resolveDateUnknown.disabled = true;
        }
    }
    pg.record.assessmentType.onchange = pg.record.resolveDate.setState;

    pg.record.resolveDateYear = pg.record.all.resolveDateYear;
    pg.record.resolveDateYear.tabIndex = 11;
    pg.record.resolveDateMonth = pg.record.all.resolveDateMonth
    pg.record.resolveDateMonth.tabIndex = 12;
    pg.record.resolveDateUnknown = pg.record.all.resolveDateUnknown;
    pg.record.resolveDateUnknown.tabIndex = 13;

    pg.record.chkResolveDateIsApproximate = myLocationDB.InputButton(pg.record.all.chkResolveDateIsApproximate);
    pg.record.chkResolveDateIsApproximate.setTitle("Resolve date is approximate");
    pg.record.chkResolveDateIsApproximate.disable(true);

    // -- UPDATES
    pg.record.updates = pg.record.all.pnlUpdates.all.grid;
    pg.record.lblUpdateCount = pg.record.all.lblUpdateCount;
    pg.record.updates.attachEvent("onstateready", pg.showRecordView);
    pg.record.updates.attachEvent("onrowdblclick", pg.showUpdateView);

    // -- "VIEW SELECTED"
    pg.record.btnViewUpdate = myLocationDB.PanelButton(pg.record.all.btnViewUpdate);
    pg.record.btnViewUpdate.setTitle("View details for the selected problem update");
    pg.record.btnViewUpdate.onclick = pg.showUpdateView;
    pg.record.btnViewUpdate.setState = function(){
        pg.record.btnViewUpdate.disable(!pg.record.updates.lastSelected);
    }
    pg.record.updates.attachEvent("onrowclick", pg.record.btnViewUpdate.setState);

    // -- COMMENTS
    pg.record.comments = pg.record.all.comments;
    pg.record.pnlComments = pg.record.all.pnlComments;
    pg.record.lblCommentCount = pg.record.all.lblCommentCount;

    // -- UPDATE COMMENTS
    pg.record.btnUpdateComments = myLocationDB.PanelButton(pg.record.all.btnUpdateComments);
    pg.record.btnUpdateComments.onclick = pg.showCommentView;
    pg.record.btnUpdateComments.title = "Update this record's comments";

    // -- LINKED NOTES
    pg.record.linkedNotes = pg.record.all.linkedNotes.all.grid;
    pg.record.linkedNotes.attachEvent("onrowclick", pg.linkedRecordClick);
    pg.record.linkedNotes.attachEvent("onrowdblclick", pg.openLinkedNote);
    pg.record.linkedNotes.attachEvent("onstateready", pg.setLinkedNotes_Count);

    // -- LINKED ORDERS
    pg.record.linkedOrders = pg.record.all.linkedOrders.all.grid;
    pg.record.linkedOrders.attachEvent("onrowclick", pg.linkedRecordClick);
    pg.record.linkedOrders.attachEvent("onrowdblclick", pg.openLinkedOrder);
    pg.record.linkedOrders.attachEvent("onstateready", pg.setLinkedOrders_Count);

    // -- "CLOSE"
    pg.record.btnClose = pg.record.all.btnClose;
    pg.record.btnClose.tabIndex = 15;
    pg.record.btnClose.onclick = pg.hideRecordView;
    pg.record.btnClose.title = "Close this record panel";

    //  -- LAST UPDATED BY
    pg.record.lblUpdatedBy = pg.record.all.lblUpdatedBy;

    // -- "SELECT ALL"
    pg.record.chkSelectAll = myLocationDB.InputButton(pg.record.all.chkSelectAll);
    pg.record.chkSelectAll.onclick = function(){
        if(pg.record.tabs[1].all[0].checked){
            if(pg.record.chkSelectAll.checked){
                pg.record.linkedNotes.selectAll();
            } else {
                pg.record.linkedNotes.deselectAll();
            }
        } else {
            if(pg.record.chkSelectAll.checked){
                pg.record.linkedOrders.selectAll();
            } else {
                pg.record.linkedOrders.deselectAll();
            }
        }
        pg.record.btnOpen.setState();
        //pg.record.btnViewLabs.setState();
    }
    pg.record.chkSelectAll.setState = function(){
        if(pg.record.tabs[1].all[0].checked){
            pg.record.chkSelectAll.checked = pg.record.linkedNotes.selectedRows.length == pg.record.linkedNotes.rows.length;
        } else {
            pg.record.chkSelectAll.checked = pg.record.linkedOrders.selectedRows.length == pg.record.linkedOrders.rows.length;
        }
    }



    // -- "OPEN SELECTED"
    pg.record.btnOpen = pg.record.all.btnOpenSelected;
    pg.record.btnOpen.tabIndex = 14;
    pg.record.btnOpen.disable = myLocationDB.Disable;
    pg.record.btnOpen.title = "Open the selected record";
    pg.record.btnOpen.onclick = function(){
        if(pg.record.tabs[1].all[0].checked){
            pg.openLinkedNote();
        } else if(pg.record.tabs[2].all[0].checked){
            pg.openLinkedOrder();
        } else {
            pg.record.btnOpen.disable(true);
        }
    }
    pg.record.btnOpen.setState = function(){
        if(pg.record.tabs[1].all[0].checked){
            pg.record.btnOpen.disable(!pg.record.linkedNotes.lastSelected);
        } else if(pg.record.tabs[2].all[0].checked){
            pg.record.btnOpen.disable(pg.record.linkedOrders.selectedRows.length != 1);
        } else {
            pg.record.btnOpen.disable(true);
        }
    }

    // -- "SAVE"
    pg.record.btnSave = pg.record.all.btnSave;
    pg.record.btnSave.tabIndex = 14;
    pg.record.btnSave.onclick = pg.updateRecord_Request;
    pg.record.btnSave.title = "Save changes to this record";

    // RECORD UPDATE SUBWIN
    pg.recordUpdate = da.subWin_update;
    pg.recordUpdate.lblUpdatedBy = pg.recordUpdate.all.lblUpdatedBy;
    pg.recordUpdate.lblUpdateDTS = pg.recordUpdate.all.lblUpdateDTS;

    pg.recordUpdate.type = pg.recordUpdate.all.type;
    pg.recordUpdate.onsetDate = pg.recordUpdate.all.onsetDate;
    pg.recordUpdate.description = pg.recordUpdate.all.description;
    pg.recordUpdate.resolveDate = pg.recordUpdate.all.resolveDate;
    pg.recordUpdate.assessmentType = pg.recordUpdate.all.assessmentType;

    // -- "CLOSE"
    pg.recordUpdate.btnClose = pg.recordUpdate.all.btnClose;
    pg.recordUpdate.btnClose.tabIndex = 1;
    pg.recordUpdate.btnClose.onclick = pg.hideUpdateView;
    pg.recordUpdate.btnClose.title = "Close this sub-window";

    // COMMENTS SUBWIN
    pg.recordComments = da.subWin_comments;
    pg.recordComments.comments = pg.recordComments.all.updateComments;
    pg.recordComments.comment

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery