Javascript Common (uty.js)
[Javascript code documentation]

Modules

 Javascript enum UTY_DIRTYPE
 Javascript enum UTY_SORT
 Javascript enum UTY_BROWSER

Functions

function uty_trim (str, chars)
function uty_ltrim (str, chars)
function uty_rtrim (str, chars)
function uty_starts (haystack, needle)
function uty_ends (haystack, needle)
function uty_aindex (array, value)
function uty_aremove (array, value, count)
function uty_select (input, start, end)
function uty_text (element, text)
function uty_window_x (elevent)
function uty_window_y (elevent)
function uty_window_scroll_x ()
function uty_window_scroll_y ()
function uty_page_x (elevent)
function uty_page_y (elevent)
function uty_window_width ()
function uty_window_height ()
function uty_center_in_window (element)
function uty_window_add_onload (func, code)
function uty_document_disable_onselectstart (disable)
function uty_post (url, content, callback)
function uty_selection_clear ()

Function Documentation

function uty_aindex (   array,
  value 
)

Return the index of an element in array.

Parameters:
array (array) the array to search in
value (string) the value to search for
Returns:
the index (int or key) of the value element or undefined if not found
function uty_aremove (   array,
  value,
  count 
)

Removes an element from array.

Parameters:
array (array) the array to search in
value (var) the value to search for
[count] (int) splice count elements in the array, default=1
Returns:
void
function uty_center_in_window (   element  ) 

Centers the element into the browser window.

Note:
will set element.style.position='fixed'!
Parameters:
element (domNode) the element to center
function uty_document_disable_onselectstart (   disable  ) 

Disable user selection in Internet Explorer.

Parameters:
disable (bool) if true store current handler and set it to "return false" else restore old handler (if any)
Note:
All other browser must handle mousedown event and return false. To get a cross browser effetct you must handle the onmousedown/onmouseup events:
                 function mousedown(){
                        uty_document_disable_onselectstart(true);
                        ...
                        return false;
                 }
                 function mouseup(){
                        ...
                        uty_document_disable_onselectstart(true);
                 }
function uty_ends (   haystack,
  needle 
)

Check if a string ends with a certain value.

Parameters:
haystack (string) the string to search in
needle (string) the string to search for
Returns:
true if haystack ends with needle, false otherwise
function uty_ltrim (   str,
  chars 
)

Left trim whitespaces.

Parameters:
str (string) the original string
[chars] (string) the charaters to trim, default="\\s"
Returns:
the left trimmed string
function uty_page_x (   elevent  ) 

Return e(lem|v)ent distance from the document body client left.

Parameters:
elevent (var) domNode or domEvent
Returns:
the e(lem|v)ent x document body position
function uty_page_y (   elevent  ) 

Return e(lem|v)ent distance from the document body client top.

Parameters:
elevent (var) domNode or domEvent
Returns:
the e(lem|v)vent y document body position
function uty_post (   url,
  content,
  callback 
)

Sends async post content to url via XMLHttpRequest. Calls callback on response completed.

Parameters:
url (string) the url to send request to
content (string) post parameters (&separated) NB: no starting '?' is required in post!
callback (pointer) callback function pointer, MUST have this signature: function(status, statusText, responseText)
Returns:
the local XMLHttpRequest instance
function uty_rtrim (   str,
  chars 
)

Right trim whitespaces.

Parameters:
str (string) the original string
[chars] (string) the charaters to trim, default="\\s"
Returns:
the right trimmed string
function uty_select (   input,
  start,
  end 
)

Focus an input element and select a portion of text inside.

Parameters:
input (domNode) the input element to focus
[start] (int) the text selection start index, default=undefined (no text selection)
[end] (int) the text selection end index, default=undefined (if start!==undefined select all text from start)
Returns:
void
function uty_selection_clear (  ) 

clear suser text selection

function uty_starts (   haystack,
  needle 
)

Check if a string starts with a certain value.

Parameters:
haystack (string) the string to search in
needle (string) the string to search for
Returns:
true if haystack starts with needle, false otherwise
function uty_text (   element,
  text 
)

get/set the html text content (escape html special chars).

Parameters:
element (domNode) the element to get/set the text content from/to
[text] (string) if!=undefined the text content will be set before returning
Returns:
the element text content
function uty_trim (   str,
  chars 
)

trim whitespaces

Parameters:
str (string) the original string
[chars] (string) the charaters to trim, default="\\s"
Returns:
the trimmed string
function uty_window_add_onload (   func,
  code 
)

Add a listener to the window onload event.

Parameters:
func (pointer) event handler function pointer
[code] javascript expression for older browsers, default=undefined

e.g.: uty_window_add_onload(function(){alert('hello');}, "alert('hello');");

function uty_window_height (  ) 
Returns:
the browser window client height
function uty_window_scroll_x (  ) 
Returns:
Window horizontal scroll pixels.
function uty_window_scroll_y (  ) 
Returns:
Window vertical scroll pixels.
function uty_window_width (  ) 
Returns:
the browser window client width
function uty_window_x (   elevent  ) 

Return e(lem|v)ent distance from the browser window client left.

Parameters:
elevent (var) domNode or domEvent
Returns:
the e(lem|v)ent x window position
function uty_window_y (   elevent  ) 

Return e(lem|v)ent distance from the browser window client top.

Parameters:
elevent (var) domNode or domEvent
Returns:
the e(lem|v)ent y window position
 All Classes Files Functions Variables Enumerations

Copyright © 2010 Attilio Pavone - www.utillyty.eu