home *** CD-ROM | disk | FTP | other *** search
- function com_netobjects_objectsComponent(params) {
- this.isPropInObj = isPropInObj;
- this.viewObject = viewObject;
-
- this.name = (params.name+"" != "undefined" && params.name != null ? params.name : "objectsComponent1");
-
- /* ======================================================================
- FUNCTION: isPropInObj
-
- INPUT: str (string): the value to be compared
- partialMatch (boolean): (optional) should partial or exact matches be performed.
- Defaults to false if unspecified (i.e. does
- exact match, not partial match, by default).
-
- RETURN: true, if the value is found equal to or partially equal to a property of the object;
- false, otherwise;
- returns null if invalid arguments were passed
-
- DESC: This function loops through all of the properties in any JavaScript/JScript object
- and searches for a given property in the object. The function can be configured
- so that partial matches on a property name can be conducted.
- ====================================================================== */
- function isPropInObj ( str, obj, partialMatch ) {
- var result = false;
-
- // Return immediately if an invalid value was passed in
- if (str+"" == "undefined" || str+"" == "null")
- return null;
- if (obj+"" == "undefined" || obj+"" == "null")
- return null;
-
- // Default partialMatch to false if undefined or null
- if (partialMatch+"" == "undefined" || partialMatch+"" == "null")
- partialMatch = false;
-
- // Make sure the string argument is a string
- str += "";
-
- if (partialMatch)
- for (var firProp in obj) {
- if (firProp.indexOf(str) != -1) {
- result = true;
- }
- }
-
- else
- for (var firProp in obj) {
- if (firProp == str) {
- result = true;
- }
- }
- return result;
-
- } // end isPropInObj
-
- /* ======================================================================
- FUNCTION: viewObject
-
- INPUT: obj (object): the object to be viewed
- objName (string): the name of the object that corresponds to obj
-
- RETURN: A string containing HTML showing the list of object properties;
- returns null if invalid arguments were passed
-
- DESC: This function loops through any JavaScript/JScript object and
- and returns HTML that will display all properties of the object
- between two HTML horizontal rules.
- ====================================================================== */
- function viewObject (obj, objName) {
- var outputStr = "";
-
- // Return immediately if an invalid value was passed in
- if (obj+"" == "undefined" || obj+"" == "null")
- return null;
- // Set default object name if none is provided
- if (objName+"" == "undefined" || objName+"" == "null")
- objName = "[Object]";
-
- outputStr = "<BR><HR><BR>\n";
- outputStr += "\n<BR><B>"+objName+" Properties: </B><BR>";
- for (prop in obj) {
- outputStr += "\n<BR>"+objName+"."+prop+" = "+obj[prop];
- }
- outputStr += "<BR><HR><BR>\n";
-
- return outputStr;
- } // end viewObject
- }
-