");
//document.write("");
function _validateRadio(field,table){
var obj = document.getElementsByName(field);
var flag = false;
for(var i=0; i= 2) {
// 2 or more columns retuned
for (var j = 0; j < json.data[0].column.length; j++) {
for (var i = 0; i < length; i++) {
tmpCol = json.data[i].column[j];
if (Util.isUndefined(tmpCol)) {
tmp += '' + colSeparator; // "|" is a default column separator
} else {
tmp += tmpCol + colSeparator; // "|" is a default column separator
}
}
tmp = tmp.substring(0, (tmp.length - 1)) + rowSeparator; // "^" is a row separator
}
}
result = tmp.substring(0, (tmp.length - separatorLength)); // get rid of the last row separator (default: "^")
// Sort and/or remove duplicates
if (unique && sort) {
result = Util.Array.unique(result.split(rowSeparator).sort()).join(rowSeparator);
} else {
if (unique) {
result = Util.Array.unique(result.split(rowSeparator)).join(rowSeparator);
}
if (sort) {
result = result.split(rowSeparator).sort().join(rowSeparator);
}
}
// Assign result to a field or a DOM element
if (clearValueOnError || json.success) { // override field contect unless a clearValueOnError is set to false (default is true)
var eDOM = eQuery.get(0); // DOM object
if (eDOM.type === 'textarea' || eDOM.type === 'text') {
// input & textarea (text & rich-text fields)
eQuery.val(result);
} else if (eDOM.type === 'select-one' || eDOM.type === 'select-multiple') {
// select (combo box and dialog list - single & multi selection)
// (fyi... index starts with 1 vs. 0 to allow developers to set/over-ride the first option (e.g. '-- Select Manager --|N/A'))
eDOM.options.length = 0; // remove all option entries
result = result.split(rowSeparator); // split multi-value entries & create an array
$.each(result, function(i, n){
if (n.indexOf(colSeparator) === -1) {
eDOM.options[i + 1] = new Option(n, n); // without alias
}
else {
entry = n.split(colSeparator); // with alias
eDOM.options[i + 1] = new Option(entry[0], entry[1]);
}
});
// set a default keyword value/alias, if any
if (defaultValue !== '') {
eDOM.options[0] = new Option(defaultValue, defaultAlias);
eDOM.options.selectedIndex = 0;
}
} else {
// DOM object, but not a field (e.g. div, span, p, ...)
if (result.constructor.toString().indexOf("Array") === -1) {
eQuery.text(result);
} else {
eQuery.text(result.join(","));
}
}
}
} else { //*** do not process ajax request (assign a json string to a DOM object)
eQuery.val(json);
}
// Execute a callback function, if passed as a config object literal property
if (typeof callback === 'function') {
if (typeof json !== 'object') { // ensure that a json object is passed vs. a json string
json = eval(json);
}
callback(json, id); // pass json object and DOM's id attribute to the callback function
}
if (timeElapsed) {
var timeEnd = (new Date()).getTime();
window.status = 'dbQuery() completed in ' + (timeEnd - timeStart)/1000 +' second(s)';
} else {
window.status = '';
}
if (showError) {
if (!json.success) {
alert(json.error);
}
}
},
error: function(XMLHttpRequest, textStatus) {
if (timeElapsed) {
var timeEnd = (new Date()).getTime();
window.status = 'dbQuery() completed in ' + (timeEnd - timeStart)/1000 +' second(s)';
} else {
window.status = '';
}
if (showError) {
alert(textStatus);
}
}
});
}
/**
* Executes the DbLookup / DbColumn functions in the back-end using an Ajax request. It works with 'text' (text, number, date), 'textarea' (rich-text), select-one' (keyword), 'select-multiple' (keyword), and DOM objects
* (e.g. innerHTML, div, p, ...). It can return a single column, multiple columns, single field, multiple fields and any combination of the columns / fields in a single dbQuery() call. Also, it supports keyword fields with or without
* aliases. Default separator for multi-values is "^" (row separator), and a default separator for multiple columns/fields is "|" (column separator). NOTE: If a 'key' parameter is an empty string then a DbColumn will be executed, otherwise a DbLookup will be executed.
*
* @name Domino.Ajax.dbQuery
* @author Sasha Oros
* @param {String} server Notes server name, default to '' for the current server
* @param {String} db Notes database file path, default to '' for the current database
* @param {String} view The name of the view or folder in which to search
* @param {String} key Determines which document is actually read in order to retrieve value(s)
* @param {String} columns You can use column number(s) and/or Notes field name(s). Columns/fields should be separated by comma (,) without space between (e.g. '2,3,City,Province')
* @param {Object} options Object literal
* -
* [id] {String} , Notes field or HTML element where dbQuery result will be stored. Default is 'DominoAjaxResult' (Notes field), but it can be chnaged to any DOM 'id' attribute
*
-
* [protocol] {String} , Default is 'http', set to 'https' if you want to use SSL protocol
*
-
* [username] {String} , A username to be used in response to an HTTP access authentication request
*
-
* [password] {String} , A password to be used in response to an HTTP access authentication request
*
-
* [async] {Boolean} , Default is true, set to false if you want to make a synchronized call
*
-
* [unique] {Boolean} , Default is false, set to true if you want to return a unique list
*
-
* [sort] {Boolean} , Default is false, it gets original value returned by the DbLookup or DbColumn functions, set to true to sort the elements alphabetically
*
-
* [processJson] {Boolean} , Default is true, set to false if you want to receive an original JSON string from DbLookup/DbColumn (maybe you want to process it with your callback function instead, or to debug JSON string)
*
-
* [showError] {Boolean} , Default is false, set to true if you want to display an error when a request fails
*
-
* [clearValueOnError] {Boolean} , Default is true, set to false if you do not want to blank out a field value when Ajax call fails
*
-
* [rowSeparator] {String} , Default is '^'
*
-
* [colSeparator] {String} , Default is '|'
*
-
* [cache] {Boolean} , Default is false, set to true to cache the ajax calls
*
-
* [timeElapsed] {Boolean} , Default is false, set to true to display in window status how long each dbQuery() call takes
*
-
* [callback] {Function} , Callback function is executed after the successful ajax call (function has two parameters passed: 'json' and 'id'). Use these parameters in order to further process results (if necessary).
*
-
* json {Object} , (callback parameter) JSON literal object returned by the DbLookup / DbColumn functions
*
-
* id {String} , (callback parameter) Notes field or any other Notes/HTML element name where the results of the dbQuery() is stored
*
*
* @example Domino.Ajax.dbQuery('', '', 'viewUser', 'Steve Smith, '2', {id: 'UserName'}); // @DbLookup in the current database returns results that are assinged to a 'UserName' text field.
* @example Domino.Ajax.dbQuery('', '', 'viewContact', 'Steve, '2', {protocol: 'https', id: 'UserNames', unique: true}); // @DbLookup is made using an Ajax GET call over an 'https' protocol and a unique list is returned (duplicates removed)
* @example Domino.Ajax.dbQuery('', '', 'viewCustomer', 'Toronto, '2', {id: 'CustomerList', defaultValue: '--- Select Customer ---', defaultAlias: 'N/A'}); // @DbLookup assigns a customer list to a 'CustomerList' keyword field, and at the same time sets a default value/alias to the field
* @example Domino.Ajax.dbQuery('Toronto1/SRV/Honda', 'prod\Product.nsf', 'vwProducts', 'IBM', '2', {id: 'ProductList', callback: function(json, id){ if (!json.success) {alert(json.error);}}});
*
* @return {Object} XMLHttpRequest
*/
Domino.Ajax.dbQuery = function(server, db, view, key, columns, options) {
var url = "", id = "DominoAjaxDbQuery", protocol = "http", username = '', password = '', async = true, processJson = true, showError = false, clearValueOnError = true, cache = false, unique = false, sort = false;
var defaultValue = '', defaultAlias = '', callback = '', rowSeparator = '^', colSeparator = '|';
var timeElapsed = false, timeStart;
if (typeof server === 'undefined') {
alert("dbQuery() error: \n\n'server' - parameter is 'undefined'." );
return;
} else if (typeof db === 'undefined') {
alert("dbQuery() error: \n\n'db' - parameter is 'undefined'." );
return;
} else if (typeof view === 'undefined') {
alert("dbQuery() error: \n\n'view' - parameter is 'undefined'." );
return;
} else if (typeof key === 'undefined') {
alert("dbQuery() error: \n\n'key' - parameter is 'undefined'." );
return;
} else if (typeof columns === 'undefined') {
alert("dbQuery() error: \n\n'columns' - parameter is 'undefined'." );
return;
} else if (typeof options === 'object') {
if (typeof options.id === 'string' && options.id !== '') {
id = options.id;
}
if (typeof options.protocol === 'string' && options.protocol === 'https') {
protocol = options.protocol;
}
if (typeof options.username === 'string') {
username = options.username;
}
if (typeof options.password === 'string') {
password = options.password;
}
if (typeof options.async === 'boolean') {
async = options.async;
}
if (typeof options.cache === 'boolean') {
cache = options.cache;
}
if (typeof options.unique === 'boolean') {
unique = options.unique;
}
if (typeof options.sort === 'boolean') {
sort = options.sort;
}
if (typeof options.processJson === 'boolean') {
processJson = options.processJson;
}
if (typeof options.showError === 'boolean') {
showError = options.showError;
}
if (typeof options.clearValueOnError === 'boolean') {
clearValueOnError = options.clearValueOnError;
}
if (typeof options.defaultValue === 'string' && options.defaultValue !== '') {
defaultValue = options.defaultValue;
}
if (typeof options.defaultAlias === 'string' && options.defaultAlias !== '') {
defaultAlias = options.defaultAlias;
}
if (defaultAlias === "" && defaultValue !== '') {
defaultAlias = defaultValue;
} else if (defaultValue === "" && defaultAlias !== '') {
defaultValue = defaultAlias;
}
if (typeof options.callback === 'function') {
callback = options.callback;
}
if (typeof options.rowSeparator === 'string' && options.rowSeparator !== '') {
rowSeparator = options.rowSeparator;
}
if (typeof options.colSeparator === 'string' && options.colSeparator !== '') {
colSeparator = options.colSeparator;
}
if (typeof options.timeElapsed === 'boolean') {
timeElapsed = options.timeElapsed;
}
if (timeElapsed) {
timeStart = (new Date()).getTime();
}
}
if (key === '') {
// @DbColumn
url = dbQueryURL( protocol ) + "/dbQuery?OpenPage&server=" + $.trim( server ) + "&db=" + $.trim( db ) + "&view=" + $.trim( view ) + "&columns=" + $.trim( "" + columns ) + "&cache=" + cache;
} else {
// @DbLookup
url = dbQueryURL( protocol ) + "/dbQuery?OpenPage&server=" + $.trim( server ) + "&db=" + $.trim( db ) + "&view=" + $.trim( view ) + "&key=" + key + "&columns=" + $.trim( "" + columns ) + "&cache=" + cache;
}
if (clearValueOnError) { // default is true, which means the current field value (before lookup) will first be blanked out
$('#' + id).val(''); // clean-up/remove any old search values before a new lookup
}
// process ajax request & return XMLHttpRequest
return dbQueryAjaxRequest( async, url, username, password, id, processJson, showError, clearValueOnError, cache, unique, sort, defaultValue, defaultAlias, rowSeparator, colSeparator, timeElapsed, timeStart, callback );
};
/**
* @class Util
* Util core utilities and functions.
* @singleton
*/
/**
* Determines if an object is undefined or not
*
* @name Util.isUndefined
* @author Sasha Oros
* @param {Object} a Object, string, number, boolean
* @return {Boolean}
*/
Util.isUndefined = function(a) {
return typeof a === 'undefined';
};
/**
* @class Util.Array
* Util.Array core utilities and functions.
* @singleton
*/
/**
* Returns unique array
*
* @name Util.Array.unique
* @author Sasha Oros
* @param {Array} a Array to be processed
* @return {Array} Unique array
*/
Util.Array.unique = function(a) {
var b = [];
for (var i = 0, len = a.length; i