"Do not spoil what you have by desiring what you have not; but remember that what you now have was once among the things you only hoped for." -Epicurus
JavaScript Manual: DLSupport

Object: AJAX

Since: 1.1

Description:

A wrapper for AJAX functionalities. Refer to link below to get more information on this object:

JavaScript Manual: DLSupport.AJAX

Object: Browser

Since: 0.1

Description:

Contains browser information. Refer to link below to get more information on this object:

JavaScript Manual: DLSupport.Browser

Object: Form

Since: 1.1

Description:

Provides support for a form. Refer to link below to get more information on this object:

JavaScript Manual: DLSupport.Form

Property: ErrorLog

Since: 1.3

Returns:

 Type
Description
 array
Contains a log of all the errors during the script execution.

Property: ModuleUrl

Since: 1.1

Returns:

 Type
Description
 string
The URL to the directory containing this module. This will be set dynamically after the script loads.

Method: addErrorLog

Since: 1.3

Parameters:

 Variable
Type
Description
 method
string
The name of the method that generated the error.
 parameters
array
The parameters that was given to the method that generated the error.
 message
string
The error message.

Description:

Add an message to the error log.

Method: checkboxSelectAllToggle

Since: 1.1

Parameters:

 Variable
Type
Description
 element
object
The DOM element in which if it is checked, all input boxes with the given class name, will be checked and vice versa.
 target
string
The class name of all input checkboxes that will be checked or unchecked.

Description:

Check or uncheck all input checkboxes with the same class name as the given target based on the current status of the given element.

Usage Examples:

<table>
    <tr>
        <td><input type="checkbox" onchange="javascript: DLSupport.checkboxSelectAllToggle(this, 'check_group');" /></td>
        <td>Value</td>
    </tr>
    <tr>
        <td><input type="checkbox" name="some_box[]" class="check_group" value="1" /></td>
        <td>Some Value</td>
    </tr>
    <tr>
        <td><input type="checkbox" name="some_box[]" class="check_group" value="2" /></td>
        <td>Another Value</td>
    </tr>
    <tr>
        <td><input type="checkbox" name="some_box[]" class="check_group" value="3" /></td>
        <td>You got it, another value</td>
    </tr>
</table>

Method: cloneArray

Since: 1.1

Parameters:

 Variable
Type
Description
 data
array
The array to be cloned.

Returns:

 Type
Description
 array
An array containing all of the data of the given array.

Description:

Create a copy of the given array.

Usage Examples:

var myarray = [1, 2, 3, 4];
var clonedarray = DLSupport.cloneArray(myarray);
clonedarray.pop();

window.alert(myarray[myarray.length-1]);
// -> 4
window.alert(clonedarray[clonedarray.length-1]);
// -> 3

Method: combineArray

Since: 1.1

Updated: 1.3

Parameters:

 Variable
Type
Description
 keys
array
The array to use as the keys.
 values
array
The array to use as the values.

Returns:

 Type
Description
 object
An object with the given keys as the property names and the given values as its corresponding value.

Description:

Create an associative array (object) by using the first given array as the keys and the second given array as the value. It is required that both arrays be of the same length. As of version 1.3, extra validation has been added so that no null objects will be a member of the resulting array.

Usuage Examples:

var keys = ['first_name', 'last_name', 'age'];
var values = ['Tim', 'Johnson', '10'];
var person = DLSupport.combineArray(keys, values);

document.write(person.first_name + ' ' + person.last_name + ': ' + person.age);
// -> Tim Johnson: 10

Method: curry

Since: 0.1

Updated: 1.1, 1.3

Parameters:

 Variable
Type
Description
 func
function
The function to currify.
 scope
object
The scope of the function.

Returns:

 Type
Description
 function
A function that wraps the given function with some of its parameters preset.

Description:

Currify the given function. With the release of version 1.1, the closure problem of this method has been fixed. As of 1.3, the function is returned directly instead of being assigned to a variable and then returned.

Usuage Examples:

<script type="text/javascript">
// some random function
function init(element, newId) {
    element.id = newId;
}

var myelement = document.getElementById('some_id');
var curried_function = DLSupport.curry(init, window, myelement, 'new_id');
window.onload = curried_function;
</script>

Method: defaultValues

Since: 1.1

Updated: 1.3

Parameters:

 Variable
Type
Description
 source
object
The object being used to copy values over from.
 base
object
The object that contains the default values.

Returns:

 Type
Description
 object
The object containing values from both the source and base object with the source object's value replacing the base object's value if they have the same property name.

Description:

Using the given base values object, copy values from the source object if they have the same property name. As of 1.3, some of the data is used directly instead of being copied to a variable and then used to improve performance.

method: delayFunction

Since: 1.1

Updated: 1.3

Parameters:

 Variable
Type
Description
 func
function
The function whose execution will be delayed.
 delay
numeric
The number of seconds to wait before the given function is executed.

Description:

Delay the execution of the given function by the given number of seconds. As of 1.3, this function will not use window.setTimeout if the given delay is 0.

Method: hideLoadingImage

Since: 1.1

Description:

Hide the loading image.

Method: humanReadable

Since: 1.3

Parameters:

 Variable
Type
Description
 data
mixed
The data to be parsed and returned.

Returns:

 Type
Description
 string
The string representation of the given data.

Description:

Retrieves the given data into human readable format. Credits goes to Michael White & Ben Bryan.

Method: inArray

Since: 1.1

Updated: 1.3

Parameters:

 Variable
Type
Description
 item
mixed
The item to look for.
 haystack
array
The array to used for the search.
 strict
boolean
This is optional and defaults to true. If this is true, then the search will use === when comparing the data, otherwise, it will just use ==.

Returns:

 Type
Description
 boolean
Returns true if the given item is in the given array, falseotherwise.

Description:

Find out whether or not the given item is in the given array. As of 1.3, some of the data are used directly instead of being set to a variable and then used.

Usuage Examples:

var data = ['1.0', '2.0', '3.0', '4.0'];

window.alert(DLSupport.inArray(1, data, false));
// -> true

window.alert(DLSupport.inArray(1.0, data, false));
// -> true

window.alert(DLSupport.inArray(1.0, data));
// -> false

Method: isArray

Since: 1.1

Parameters:

 Variable
Type
Description
 item
mixed
The item to check.

Returns:

 Type
Description
 boolean
Returns true if the given item is an array, false otherwise.

Description:

Determine whether or not the given item is an array.

Usuage Examples:

var myarray = [];
var mysecondarray = new Array();
var myobject = {};

window.alert(DLSupport.isArray(myarray));
// -> true

window.alert(DLSupport.isArray(mysecondarray));
// -> true

window.alert(DLSupport.isArray(myobject));
// -> false

Method: isNumeric

Since: 1.1

Parameters:

 Variable
Type
Description
 item
mixed
The item to check.

Returns:

 Type
Description
 boolean
Returns true if the given item is a number, false otherwise.

Description:

Determine whether or not the given item is numeric.

Usuage Examples:

var myarray = [];
var mynumber = 1.3;
var mystringnumber = '-1.34';

window.alert(DLSupport.isNumeric(myarray));
// -> false

window.alert(DLSupport.isNumeric(mynumber));
// -> true

window.alert(DLSupport.isNumeric(mystringnumber));
// -> true

Method: newEvent

Since: 1.3

Parameters:

 Variable
Type
Description
 element
object
The element in which the event should be attached to.
 event
string
The event by which the given function should be executed. This should not include the text "on".
 func
function
The function to append to the list.
 delay
int
The time, in seconds, to delay the execution after the page has loaded. This is optional & defaults to 0.

Returns:

 Type
Description
 boolean
Returns true if successful, otherwise, false.

Description:

Attach a new event to the given element.

Method: propertyNames

Since: 1.1

Parameters:

 Variable
Type
Description
 item
object
The item to retrieve the property names.

Returns:

 Type
Description
 array
An array containing all the properties belonging to the given object. Note that this will only contain properties that the given object actually own.

Description:

Get the property names of the given object.

Usuage Examples:

var myobject = {
    first_name: 'Alex',
    last_name: 'Tanz',
    age: 23
};

var property_names = DLSupport.propertyNames(myobject);
// -> ['first_name', 'last_name', 'age'];

Method: removeElement

Since: 0.1

Updated: 1.3

Parameters:

 Variable
Type
Description
 element
object
The DOM element to remove.

Returns:

 Type
Description
 boolean
Returns true if successful, false, otherwise.

Description:

This will remove the given element from the DOM structure of the web site. Be careful when using this method because it is a mutation of the DOM structure. Removing the given element will also remove all of its children. AS of 1.3, the return value was added.

Usuage Examples:

<script type="text/javascript">
var element_to_remove = document.getElementById('hidden_div');
DLSupport.removeElement(element_to_remove);
</script>

Method: reverseArray

Since: 1.1

Parameters:

 Variable
Type
Description
 data
array
The array to have it values reversed.
 recursive
boolean
Optional & defaults to false. If true, recur into an inner arrays.

Returns:

 Type
Description
 array
The given array but its order in reverse.

Description:

Get the array that has the reverse order of the given array. This differs from the pre-defined reverse array function in that this can be set to be done recursively.

Usuage Examples:

var myarray = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];

var reverse_normal = DLSupport.reverseArray(myarray);
// -> [[7, 8, 9], [4, 5, 6], [1, 2, 3]];

var reverse_recur = DLSupport.reverseArray(myarray, true);
// -> [[9, 8, 7], [6, 5, 4], [3, 2, 1]];

Method: showLoadingImage

Since: 1.1

Parameters:

 Variable
Type
Description
 color
string
The color of the loading image. The possible values are: "black", "blue", "brown", "gold", "gray", "green", "navy", "orange", "purple", "red", "white", and "yellow".

Description:

Fade out the entire page and show the loading image. Note that this function should only be called after the page has finished loading.

Method: toggleDisplay

Since: 1.1

Parameters:

 Variable
Type
Description
 element
object
The DOM element whose display will be toggled.

Description:

Toggle the display of the given DOM element. If it is currently is hidden, then show it. If it is currently visibile, then hdie it.

Method: toQueryString

Since: 1.1

Parameters:

 Variable
Type
Description
 data
object
The object to be converted.

Returns:

 Type
Description
 string
The given data as a query string.

Description:

Convert the given object to a query string.

Method: uniqueArray

Since: 1.1

Parameters:

 Variable
Type
Description
 data
array
The array to use to create a unique array.
 strict
boolean
This is optional and defaults to true. If this is true, then the search will use === when comparing the data, otherwise, it will just use ==.

Returns:

 Type
Description
 array
Returns the given array with repeated items removed.

Description:

Get the array that has only the unique values of the given array.

Usuage Examples:

var myarray = [1, 2, 3, 4, 4, 5, 6, 7, 7, 7, 8, 9];

var myuniquearray = DLSupport.uniqueArray(myarray);
// -> [1, 2, 3, 4, 5, 6, 7, 8, 9];

Method: windowOnload

Since: 0.1

Updated: 1.1, 1.3

Parameters:

 Variable
Type
Description
 func
function
The function to append to the list.
 delay
int
The time, in seconds, to delay the execution after the page has loaded. This is optional & defaults to 0.

Returns:

 Type
Description
 boolean
Returns true if it was successful in adding the onload to the list. Returns false if it has to default to using window.setTimeout.

Description:

This will add a new event to the event listener that will run the given function after the window has finish loading (basically when all of the DOM structure has finish loading). Since this is adding to the list, you do not have to worry about overwriting someone else's events or theirs overwriting yours. The second parameter can futher delay the execution so you can pretty much sort the order of the execution of the function. It also allows you to wait for other javascript functions to finish running before yours can go. At worse case, it uses window.setTimeout. As of 1.1, the closure problem of this method has been fixed. AS of 1.3, this method makes use of the new method "newEvent". The return value was also added.

Usuage Examples:

<script type="text/javascript">
// Function to run after DOM is loaded
function init() {
    ... do something ...
}

// Function to run  3 seconds after DOM is loaded
function init2() {
    ... do something ...
}

DLSupport.windowOnload(init);
DLSupport.winodwOnload(init2, 3);
</script>

User Comments

  • Posted By
  • Posted On
  •  
  • Comment

Comment Submission

Found something wrong with the information or you just want to speak your mind? Send us a comment.

  • Nickname:
  • Comment:
  • Captcha:
  • Captcha
This page was last modified on: Jun 09, 2008.