JavaScript framework containing common functionalities.
This is used when we cannot use Prototype.
| DLSupport | JavaScript framework containing common functionalities. |
| Data | |
| Browser | Contains browser information. |
| ErrorLog | (array) Contains a log of all the errors during the script execution. |
| IdCounter | (int) Counter used for generating unqiue IDs. |
| ModuleUrl | (string) The URL to the directory containing this module. |
| Methods | |
| addClassName | Add the given class name ot the given DOM element. |
| addErrorLog | Add a message to the error log. |
| checboxSelectAllToggle | Check or uncheck all input checkboxes with the same class name as the given target based on the current status of the given element. |
| childElements | Retrieves an array of all direct child DOM elements of the given element. |
| cloneArray | Create a copy of the given array. |
| combineArray | Create an associative array (object) by using the first given array as the keys and the second given array as the value. |
| curry | Currify the given function. |
| defaultValues | Using the given base values object, copy values from the source object if they have the same property name. |
| delayFunction | Delay the execution of the given function by the given number of seconds. |
| getCookie | Get a value from the cookie. |
| getElement | If given is a string, this will try to get the object with the same ID as the string. |
| hasClassName | Determine whether or not the given DOM element has the given class name. |
| hideLoadingImage | Hide the loading image. |
| humanReadable | Retrieves the given data into human readable format. |
| identify | Retrieve the ID of the given object, creating one if it does not exist. |
| inArray | Find out whether or not the given item is in the given array. |
| isArray | Determine whether or not the given item is an array. |
| isNumeric | Determine whether or not the given item is numeric. |
| newEvent | Attach a new event to the given element. |
| PropertyNames | Get the property names of the given object. |
| removeClassName | Remove the given class name from the given DOM element. |
| removeCookie | Wrapper method around the method setCookie. |
| removeElement | This will remove the given element from the DOM structure of the web site. |
| reverseArray | Get the array that has the reverse order of the given array. |
| setCookie | Store the given value to cookie under the given key for the given number of days. |
| showLoadingImage | Fade out the entire page and show the loading image. |
| toggleDisplay | Toggle the display of the given DOM element. |
| toQueryString | Convert the given object to a query string. |
| uniqueArray | Get the array that has only the unique values of the given array. |
| windowOnload | 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). |
Contains browser information.
The stucture of this object will look something similar to the following:
Object(
Gecko: {
(boolean) Whether or not the current browser is Gecko based
like Firefox.
},
IE: {
(boolean) Whether or not the current browser is Internet
Explorer.
},
MobileSafari: {
(boolean) Whether or not the current browser is Mobile
Safari like the iPhone.
},
Opera: {
(boolean) Whether or not the current browser is Opera.
},
WebKit: {
(boolean) Whether or not the current browser is WebKit based
like Safari and Google Chrome.
}
)Check or uncheck all input checkboxes with the same class name as the given target based on the current status of the given element.
| 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. |
combineArray: function( keys, values )
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.
| keys | (array) The array to be used as the keys. |
| values | (array) The array to be used as the values. |
(object) An object with the given keys as the property names and the given values as its corresponding value.
curry: function( func, scope )
Currify the given function.
Don’t know what currify means? Google it.
| func | (function) The function to currify. |
| scope | (object) The scope of the function, namely, the object that will serve as the “this”. |
(function) A function that wraps the given function with some of its parameters preset.
defaultValues: function( source, base )
Using the given base values object, copy values from the source object if they have the same property name.
| source | (object) The object being used to copy values over from. |
| base | (object) The object that contains the default values. |
(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.
getElement: function( data )
If given is a string, this will try to get the object with the same ID as the string. Otherwise, this just returns back the given data if it is anything else.
| data | (mixed) A string representing the ID of a DOM element or anything else. |
(mixed) The DOM element with the given ID or whatever was given.
hasClassName: function( obj, class_name )
Determine whether or not the given DOM element has the given class name.
| obj | (object) The DOM element that will be tested. |
| class_name | (string) The class name to look for. |
(boolean) Whether or not the given class name exist in the given DOM element.
inArray: function( item, haystack )
Find out whether or not the given item is in the given array.
| 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 ==. |
(boolean) Returns true if the given item is in the given array, false otherwise.
newEvent: function( element, event, func, delay )
Attach a new event to the given element.
| 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. |
(boolean) Returns true if successful, otherwise, false.
removeCookie: function( key )
Wrapper method around the method setCookie. This method will set the expire time to the current time.
| key | (string) The key under which the cookie was stored. |
removeElement: function( element )
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.
| element | (object) The DOM element to remove. |
(boolean) Returns true if successful, false, otherwise.
reverseArray: function( data )
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.
| data | (array) The array to have it values reversed. |
| recursive | (boolean) Optional & defaults to false. If true, recur into an inner arrays. |
(array) The given array but its order in reverse.
setCookie: function( key, value, days )
Store the given value to cookie under the given key for the given number of days.
| key | (string) The key under which the cookie’s value is stored. |
| value | (string) The value to be stored in the cookie. |
| days | (int) The number of days until the cookie expires from the current date. |
uniqueArray: function( data )
Get the array that has only the unique values of the given array.
| 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 ==. |
(array) Returns the given array with repeated items removed.
windowOnload: function( func )
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.
| 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. |
(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.
Add the given class name ot the given DOM element.
addClassName: function( obj, class_name )
Add a message to the error log.
addErrorLog: function( method, parameters, message )
Retrieves an array of all direct child DOM elements of the given element.
childElements: function( parent )
Create a copy of the given array.
cloneArray: function( data )
Create an associative array (object) by using the first given array as the keys and the second given array as the value.
combineArray: function( keys, values )
Currify the given function.
curry: function( func, scope )
Using the given base values object, copy values from the source object if they have the same property name.
defaultValues: function( source, base )
Delay the execution of the given function by the given number of seconds.
delayFunction: function( func, delay )
Get a value from the cookie.
getCookie: function( key )
If given is a string, this will try to get the object with the same ID as the string.
getElement: function( data )
Determine whether or not the given DOM element has the given class name.
hasClassName: function( obj, class_name )
Hide the loading image.
hideLoadingImage: function()
Retrieves the given data into human readable format.
humanReadable: function( data )
Retrieve the ID of the given object, creating one if it does not exist.
identify: function( obj )
Find out whether or not the given item is in the given array.
inArray: function( item, haystack )
Determine whether or not the given item is an array.
isArray: function( item )
Determine whether or not the given item is numeric.
isNumeric: function( item )
Attach a new event to the given element.
newEvent: function( element, event, func, delay )
Remove the given class name from the given DOM element.
removeClassName: function( obj, class_name )
Wrapper method around the method setCookie.
removeCookie: function( key )
Store the given value to cookie under the given key for the given number of days.
setCookie: function( key, value, days )
This will remove the given element from the DOM structure of the web site.
removeElement: function( element )
Get the array that has the reverse order of the given array.
reverseArray: function( data )
Fade out the entire page and show the loading image.
showLoadingImage: function( color )
Toggle the display of the given DOM element.
toggleDisplay: function( element )
Convert the given object to a query string.
toQueryString: function( data )
Get the array that has only the unique values of the given array.
uniqueArray: function( data )
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).
windowOnload: function( func )