I am using the editor which is provided by the Web Screen Painter. Actually, when I add the condition in sitemod.js in notepad++, it doesn't comment out the function. But when I paste that in the editor of the Web Screen Painter, the function gets commented. It remains commented till I edit the condition upto a specific point. Kindly refer to the attached screenshots for more clarity.
Content of sitemode.js and autosuggest.js is as follows:
////////////////////////////////////////////////////////////////////////
// Copyright (C) 1999 Computer Associates International, Inc
// as an unpublished work. This notice does not imply unrestricted or public
// access to these materials which are a trade secret of Computer Associates
// International or its subsidiaries or affiliates (together referred to as
// CA), and which may not be reproduced, used, sold or
// transferred to any third party without CA's prior written consent.
//
// All Rights Reserved.
//
// RESTRICTED RIGHTS LEGEND
// Use, duplication, or disclosure by the Government is subject to
// restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
// Technical Data and Computer Software clause at DFARS 252.227-7013.
////////////////////////////////////////////////////////////////////////
// Module: sitemods.js
// Created: 06/08/01
////////////////////////////////////////////////////////////////////////
// Description:
// This file is provided to allow a customer site to add its own
// JavaScript functions to the AHD web interface. It is included in
// all AHD web pages as the last JavaScript include, and so can be
// used to provide site-written versions of standard functions.
//
// In addition to new functions, this file can be used to provide
// site versions of the menubar customization functions. This
// allows customization of the menubar without modifying menubar.js.
// The menubar customization functions are:
//
// siteMenuMod() - called once for each menubar item
// siteMenuAdd() - called once at the end of the menubar
// siteMenuitemMod() - called once for each menu item
// siteMenuitemAdd() - called once at the end of each menubar item
//
// siteContextMenuitemMod() - called once for each context menu item
// siteContextMenuitemAdd() - called once at the end of each context menu
//
// These functions can add, delete, and rename items in the menu.
// See comments on the functions themselves for usage.
////////////////////////////////////////////////////////////////////////
// $Header: /base/source/bp/freeaccess/jsdir/.RCS/sitemods.js,v 1.9 2005/01/14 00:29:45 jenji01 Exp $
////////////////////////////////////////////////////////////////////////
// siteMenuMod()
// Site-supplied function called once for each menubar item.
//
// Arguments:
// menuName - the name on the menu
//
// Return value:
// true - add the menubar item
// false - do not add the menubar item
// "xxxx" - rename the menubar item to xxxx
// Note: Legacy function for pre-R11. Use WSP for menu customization.
////////////////////////////////////////////////////////////////////////
//function siteMenuMod(menuName)
//{
// return true;
//}
////////////////////////////////////////////////////////////////////////
// siteMenuAdd()
// Site-supplied function to add new items to the end of the menubar
//
// To add a new menubar item or items, call functions as follows:
//
// addMenuItem(menuName[, accKey])
// addSubMenuItem(submenuName, script[, accKey])
// addSubMenuItem(submenuName, script[, accKey])
// ...
//
// where:
// menuName - is the name on the menubar
// submenuName - is the name of an item in the menu
// script - is a JavaScript function to call when the
// menu item is selected.
// accKey - an optional argument providing suggestions for
// the access key (alt+x) associated with this item.
// Normally, the access key is assigned automatically
// as the first letter in the name not already in use
// for an access key, with a preference for upper case.
// You can specify one or more letter or numbers, and
// the access key will be selected from the first one
// not in already in use that is also in the name.
// You can prefix the list with an exclamation point
// to indicate it is a list of letters not to use.
//
// The following predefined functions may be usefule for scripts:
// upd_frame(form)
// - load a new form into the main window content frame
// create_new(factory, use_template, width, height [,args])
// - popup a form to define a new record
// popup_window(name, form[, width, height [,features [,args]]])
// - popup a new window
// showDetailWithPersid(persid)
// - popup a detail record
//
// In the above functions:
// form - is either an HTMPL file name of the form ***.htmpl
// or an operation code (eg CREATE_NEW)
// factory - is the name of a database object
// use_template - is either true or false
// width - desired form width or zero for default
// height - desired form height or zero for defualt
// features - is a list of window features, in the same format
// used with the standard window.open function
// args - is one or more args of the form "keyword=value"
// for the operation specified for form
// persid - is a persistent ID in the form factory:id
//
// Arguments:
// none
//
// Return value:
// none
// Note: Legacy function for pre-R11. Use WSP for menu customization.
////////////////////////////////////////////////////////////////////////
//function siteMenuAdd()
//{
//}
////////////////////////////////////////////////////////////////////////
// siteMenuitemMod()
// Site-supplied function called once for each menu selection
//
// Arguments:
// menuName - the name on the menubar
// itemName - the item name on the menu
//
// Return value:
// true - add the menu item
// false - do not add the menu item
// "xxxx" - rename the menu item to xxxx
// Note: Legacy function for pre-R11. Use WSP for menu customization.
////////////////////////////////////////////////////////////////////////
//function siteMenuitemMod(menuName, itemName)
//{
// return true;
//}
////////////////////////////////////////////////////////////////////////
// siteMenuitemAdd()
// Site-supplied function to add new items to a menu
//
// To add a new menu item or items, call functions as follows:
//
// addSubMenuItem(submenuName, script[, accKey])
// addSubMenuItemLocal(submenuName, script[, accKey])
// ...
//
// where:
// submenuName - is the name of an item in the menu
// script - is a JavaScript function to call when the
// menu item is selected.
// accKey - an optional argument providing suggestions for
// the access key (alt+x) associated with this item.
// Normally, the access key is assigned automatically
// as the first letter in the name not already in use
// for an access key, with a preference for upper case.
// You can specify one or more letter or numbers, and
// the access key will be selected from the first one
// not in already in use that is also in the name.
// You can prefix the list with an exclamation point
// to indicate it is a list of letters not to use.
//
// Use addSubMenuItem() to specify a script that will be executed in the
// context of the main window (ahdtop); use addSubMenuItemLocal() to
// specify a script that will be executed in the context of the window
// containing the menubar from which the selection was made.
//
// The following predefined functions may be usefule for scripts:
// upd_frame(form)
// - load a new form into the main window content frame
// create_new(factory, use_template, width, height [,args])
// - popup a form to define a new record
// popup_window(name, form, width, height [,args])
// - popup a new window
// showDetailWithPersid(persid)
// - popup a detail record
//
// In the above functions:
// form - is either an HTMPL file name of the form ***.htmpl
// or an operation code (eg CREATE_NEW)
// factory - is the name of a database object
// use_template - is either true or false
// width - desired form width or zero for default
// height - desired form height or zero for defualt
// args - is one or more args of the form "keyword=value"
// for the operation specified for form
// persid - is a persistent ID in the form factory:id
//
//
// Arguments:
// menuName - the name on the menubar
//
// Return value:
// none
// Note: Legacy function for pre-R11. Use WSP for menu customization.
////////////////////////////////////////////////////////////////////////
//function siteMenuitemAdd(menuName)
//{
//}
////////////////////////////////////////////////////////////////////////
// siteContextMenuitemMod()
// Site-supplied function called once for each context menu selection
//
// Arguments:
// menuName - the name of the context menu
// itemName - the item name in the menu
//
// Some of the context menu names used in Service Desk are:
// "idGraphFolder" - the scoreboard folder menu
// "idGraphItem" - the scoreboard item menu
// "idGraphAll" - the scoreboard combined menu
// "idDetailsMenu" - the menu on a search results set
// "rClickMenu" - the right click menu on all forms
//
// Return value:
// true - add the menu item
// false - do not add the menu item
// "xxxx" - rename the menu item to xxxx
////////////////////////////////////////////////////////////////////////
//function siteContextMenuitemMod(menuName, itemName)
//{
// return true;
//}
////////////////////////////////////////////////////////////////////////
// siteContextMenuitemAdd()
// Site-supplied function called once for each context menu
//
// To add an item or items, issue one or more calls of the form:
//
// menu.addItem( text, script );
//
// where:
// text - is the text to go on the menu
// script - is a string containing JavaScript to execute when the
// menu item is selected.
//
// Note that your siteContextMenuItemMod() function will be called for
// each menu item you add.
//
// Arguments:
// menuName - the name of the context menu
// menu - a reference to the menu itself
//
// Return value:
// none
////////////////////////////////////////////////////////////////////////
//function siteContextMenuitemAdd(menuName,menu)
//{
//}
function popup_search(factory, backfill_field, backfill_form, extra,
is_3_field_contact, backfill_attr, callback )
{
if ( backfill_field == "requested_by" )
{
if (typeof jq('input[name="KEY.zlocation"]').parent().find('[name="SET.zlocation"]') == "object" && jq('input[name="KEY.zlocation"]').parent().find('[name="SET.zlocation"]').val() != ""){
extra += "+ADDITIONAL_WHERE=(location = U'" + jq('input[name="KEY.zlocation"]').parent().find('[name="SET.zlocation"]').val() + "' )";
}
}
// skip search for disabled detail form fields
if ( backfill_form != "tenant_form" &&
document.forms[backfill_form].elements[backfill_field] != null &&
document.forms[backfill_form].elements[backfill_field].disabled )
return;
// Call popup_search_text to form the URL used to launch the popup
var url = popup_search_text(factory, backfill_field, backfill_form, extra,
is_3_field_contact, backfill_attr, callback );
// If popup_search_text() returns null, then return
if(url == null)
return;
// Test for autofill; if not, popup a search form
if ( initiate_autofill( url, is_3_field_contact, backfill_form,
backfill_attr, backfill_field, callback ) )
return null;
return do_search_popup( url );
}
Autosuggest.js (It is not facing any such issue as in sitemode.js screenshots are showing):
////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2008 CA. All rights reserved.
//
// This software and all information contained therein is confidential and
// proprietary and shall not be duplicated, used, disclosed or disseminated
// in any way except as authorized by the applicable license agreement,
// without the express written permission of CA. All authorized
// reproductions must be marked with this language.
//
// EXCEPT AS SET FORTH IN THE APPLICABLE LICENSE AGREEMENT, TO THE EXTENT
// PERMITTED BY APPLICABLE LAW, CA PROVIDES THIS SOFTWARE WITHOUT WARRANTY
// OF ANY KIND, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL
// CA BE LIABLE TO THE END USER OR ANY THIRD PARTY FOR ANY LOSS OR DAMAGE,
// DIRECT OR INDIRECT, FROM THE USE OF THIS SOFTWARE, INCLUDING WITHOUT
// LIMITATION, LOST PROFITS, BUSINESS INTERRUPTION, GOODWILL, OR LOST DATA,
// EVEN IF CA IS EXPRESSLY ADVISED OF SUCH LOSS OR DAMAGE.
////////////////////////////////////////////////////////////////////////////
// Module: autosuggest.js
// Created: 2011/01/26 09:24:25
////////////////////////////////////////////////////////////////////////////
// Description:
//
// Code for AutoSuggest
//
////////////////////////////////////////////////////////////////////////////
// Parameter: element_id
// Return: url
// Generate a URL on the fly which will be used by
// Search as you Type feature to display the matching records
function generate_url(element_id)
{
var is_detail = false;
var extraQuery="";
if((typeof propFormName3 == "string" && propFormName3 == "edit") || typeof __search_filter == "undefined")
is_detail = true;
// In case of detail forms, construct a URL using the popup_search_text() and initiate_autofill_text()
// so that all the extra query parameters are also taken care of
// Check if this is really a detail form or some general form like the KT publish forms or ticket transfer form
// If it is not a detail form then set the form name to main_form
if(is_detail)
{
if(typeof propFormName3 == "string" && propFormName3 == "edit")
form_name_autoSuggest = detailCurrForm();
else
form_name_autoSuggest = "main_form";
}
else
{
n = __search_filter.form.length - 1;
form_name_autoSuggest = "fltrForm"+n;
}
if(autosuggest_arr[element_id].is_contact)
{
var backfill_field = autosuggest_arr[element_id].backfill_field;
}
else
{
if(is_detail)
var backfill_field = 'KEY.'+autosuggest_arr[element_id].backfill_field;
else
var backfill_field = 'QBE.IN.' + autosuggest_arr[element_id].backfill_field;
}
if(is_detail) {
var f=_dtl.form[0];
if ( backfill_field == "assignee" && typeof f.elements["SET.group"] == "object" &&
f.elements["SET.group"].value != "")
{
extraQuery = "+KEEP.in_group_id=" + f.elements["SET.group"].value;
}
}
var url_str = popup_search_text(autosuggest_arr[element_id].obj_type,backfill_field,form_name_autoSuggest,autosuggest_arr[element_id].extraURL,
autosuggest_arr[element_id].is_contact);
if( url_str.indexOf(extraQuery)== -1 && extraQuery!="")
url_str+=extraQuery;
url_str = initiate_autofill_text(url_str,autosuggest_arr[element_id].is_contact,form_name_autoSuggest,'',
backfill_field);
url_str += "+numAutosuggestRecords="+ahdtop.propMaxRecordsAutoSuggest+"+common_name="+autosuggest_arr[element_id].common_name;
if ( autosuggest_arr[element_id].backfill_field == "requested_by" )
{
if (typeof jq('input[name="KEY.zlocation"]').parent().find('[name="SET.zlocation"]') == "object" && jq('input[name="KEY.zlocation"]').parent().find('[name="SET.zlocation"]').val() != ""){
url_str += "+ADDITIONAL_WHERE=(location = U'" + jq('input[name="KEY.zlocation"]').parent().find('[name="SET.zlocation"]').val() + "' )";
}
}
return url_str;
}
// Function to escape any special characters in request.term
// which goes as a part of the URL
function escape_special_chars( term )
{
term = term.replace(/#/g, "%23");
term = term.replace(/%/g, "%25");
term = term.replace(/&/g, "%26");
// If there are any non-english characters, we have to encode
// the URL, to get the correct results back
return encodeURIComponent(term);
}
// The input event function. We use this function
// to catach user input in Firefox when using JP
// or CHS IME to input characters.
function track_input(event)
{
var obj = jq("#" + this.id);
if (obj != null)
obj.autocomplete("search", this.value);
}
// Do not execute this code for Read Only forms.
// autosuggest_arr is the master array containing all lookup elemets
// indexed on form name and element id
// We loop through the array and add AutoSuggest code for each lookup element
function appendAutoSuggestCode()
{
if (typeof autosuggest_arr != "undefined" && (typeof propFormName3 != "string" || propFormName3 != "ro"))
{
var item = "<SCR" + "IPT language=\"javascript\" type=\"text/javascript\">"
+"jq(document).ready(function() {";
for (element_id in autosuggest_arr)
{
// Only listen to the input event when it's JP
// or CHS and it's using Firefox.
if (!_browser.isIE && nonLatinFlag)
{
var obj = document.getElementById(element_id);
if (obj != null && obj.addEventListener != "undefined")
{
obj.addEventListener("input", track_input, false);
}
}
var is_detail = false;
var onchg = "";
if((typeof propFormName3 == "string" && propFormName3 == "edit") || typeof __search_filter == "undefined")
is_detail = true;
// Store the onChange events on a lookup element
if(document.getElementById(element_id) != null)
onchg = document.getElementById(element_id).onchange;
if(onchg == "")
onchg = null;
// is_open is a flag to indicate if autoSuggest options list was displayed or not
// called_chg is a flag to indicate if SDM's onchange event as been fired from autoSuggest's
// close event
item += "var is_open = false; var called_chg = false;"
+"jq('#" + element_id + "').autocomplete({"
+"source: function(request, response) {"
// Setting the flag is_from_autoSuggest to false by default
+"if("+is_detail+"){"
+"_dtl.is_from_autoSuggest = false;}"
+"else {"
+"__search_filter.is_from_autoSuggest = false;} "
// Escape any special characters entered in the request term
+"var term = nx_escape(request.term);"
+"jq.get(generate_url('"+element_id+"'),\""+ autosuggest_arr[element_id].autoComplete_parameter+"=\"+term+\"%25\","
+"function(data){"
// When IIS is used, webengine appends a junk character after '\n' in the response
// We have to strip that off the data or else the matching records are not displayed
// add try catch block to jQuery.parseJSON(data) and return empty string if the server sent
// error page instead of the data: aryni01
+"data = data.substring(0, data.lastIndexOf(\"\\\n\")-1); try{data = jQuery.parseJSON(data);}catch(e){return \"\";}"
+"return response(data);"
+"},\"html\");"
+"},"
+"open: function(event, ui) { "
// Suppressing the key events of SDM when autosuggest options are displayed
+"tempKeyDownHandler = null;"
// Setting the flag to TRUE, once the options list is displayed
+"is_open = true;"
// Setting called_chg to FALSE: This is the initial state of this flag
+"called_chg = false;"
// Suppressing the onChange events of SDM
+"document.getElementById('"+element_id+"').onchange = null;"
+"var widget = jq('#" + element_id + "').autocomplete('widget');"
// Check if the autoSuggest list overflows the current div. If so, then
// re-size the list so that it fits within the current div
+"if(jq('#" + element_id + "').autocomplete('widget').position().top < 0)"
+"setTimeout(function() { checkAutocompletePosition(widget); }, 0);"
+"},"
+"select: function(event, ui) { "
// On manually selecting an option from the auto suggest
// list, set the flag is_from_autoSuggest to SKIP_AUTO_FILL
// This is done so that '%25' is not appended to the selected
// option in popup_hier() and initiate_autofill_text()
// Save the id and the auto suggest value (common name) selected by the user.
+ "var last_autoSuggest_value = null;"
+ "var last_autoSuggest_id = null;"
+ "if ( typeof ui != 'undefined' && typeof ui.item != 'undefined' && "
+ " typeof ui.item.value == 'string' && ui.item.value.length > 0 &&"
+ " typeof ui.item.id == 'string' && ui.item.id.length > 0 )"
+ "{"
+ " last_autoSuggest_value = ui.item.value;"
+ " last_autoSuggest_id = ui.item.id;"
+ "}"
+"if("+is_detail+"){"
// The following saves the id and value selected by the user on the detail form.
+ "if ( last_autoSuggest_value != null && last_autoSuggest_id != null )"
+ "{"
+ " _dtl.last_autoSuggest_value = last_autoSuggest_value;"
+ " _dtl.last_autoSuggest_id = last_autoSuggest_id;"
+ "}"
// The following sets variable SET.x with the rel_attr value.
// Currently commented out as some work is needed on js code.
//+"var setField='SET." + autosuggest_arr[element_id].backfill_field + "';"
//+"var setFieldObj=_dtl.form[0].elements[setField];"
//+"if (typeof setFieldObj == 'object')"
//+"setFieldObj.value=ui.item.id;"
+"_dtl.is_from_autoSuggest = 'SKIP_AUTO_FILL';}"
+"else{ "
// The following saves the id and value selected by the user on the search form.
+ "if ( last_autoSuggest_value != null && last_autoSuggest_id != null )"
+ "{"
+ " __search_filter.last_autoSuggest_value = last_autoSuggest_value;"
+ " __search_filter.last_autoSuggest_id = last_autoSuggest_id;"
+ "}"
+"__search_filter.is_from_autoSuggest = 'SKIP_AUTO_FILL';}"
+"},"
+"change: function(event, ui) { "
+"if("+is_detail+"){"
// If any option was not selected manually from the
// auto suggest options list, then we have to launch the
// search popup.
// This is called only when some options were displayed (signified by checking is_open flag)
// but no options were selected by the user (signified by is_from_autoSuggest
// Also, we have to call SDM's onChange event only when it has not been called from
// close event of autoSuggest (signified by flag: called_chg)
+"if(_dtl.is_from_autoSuggest != 'SKIP_AUTO_FILL'){"
+"if(is_open && called_chg == false) {"
+"document.getElementById('"+element_id+"').onchange = "+onchg+";"
+"document.getElementById('"+element_id+"').onchange();"
+"}"
+"}"
+"}"
+"else {"
+"if(__search_filter.is_from_autoSuggest != 'SKIP_AUTO_FILL'){"
+"if(is_open && called_chg == false) {"
+"document.getElementById('"+element_id+"').onchange = "+onchg+";"
+"document.getElementById('"+element_id+"').onchange();"
+"}"
+"}"
+"}"
+"is_open = false;"
+"},"
+"close: function(event, ui) {"
// Once autocomplete suggestion list is closed,
// set back the SDM key events of SDM
+"if("+is_detail+"){"
+"setTempKeyDownHandler(detailKeyDown);"
+"if(_dtl.is_from_autoSuggest == 'SKIP_AUTO_FILL') {"
+"document.getElementById('"+element_id+"').onchange = "+onchg+";"
//In case of Firefox, just assigning back the change event invokes the function too.
//So, there is no need to explicitly call the onChange() again. Do it for all the
//other browsers though as it is needed.
+"if(!_browser.isFirefox)document.getElementById('"+element_id+"').onchange();"
// Setting called_chg to TRUE so that SDM's onChange events are not again called
// from change event of autoSuggest (note: change event of autosuggest always fired after
// close event
+"called_chg = true;"
+"}"
+"}"
+"else {"
+"setTempKeyDownHandler(searchFilterKeyDown);"
+"if(__search_filter.is_from_autoSuggest == 'SKIP_AUTO_FILL') {"
+"document.getElementById('"+element_id+"').onchange = "+onchg+";"
+"document.getElementById('"+element_id+"').onchange();"
+"called_chg = true;"
+"}"
+"}"
// Re-assigning back the original height to the autosuggest options list
+"jq('#" + element_id + "').autocomplete('widget').css('max-height', '196px');"
+"},"
// Appending the minimum number of characters required to enable autoSuggest
+"minLength: "+ ahdtop.propMinCharsAutoSuggest
+"}"
+");";
}
item += "});"
+"</SCR" + "IPT>";
docWriteln(item);
}
}
// checkAutocompletePosition()
// Function to re-size the autosuggest options list
// so that it fits in within the current div
checkAutocompletePosition = function(inputObj)
{
var offset = inputObj.position();
var heightComp = inputObj.outerHeight();
if(offset.top < 0)
{
// The list is going beyond the current div
// Re-size it, so that it fits within the div
inputObj.css('max-height', (heightComp + offset.top - 8) + 'px');
inputObj.css('top', '2px');
}
};