Name | Modified | Size | Downloads / Week |
---|---|---|---|
changelog.txt | 2015-07-11 | 623 Bytes | |
js-librarian_2015.07.11_v1.1.2.7z | 2015-07-11 | 3.3 kB | |
js-librarian_2014.09.11_v1.1.1.7z | 2014-09-11 | 3.3 kB | |
js-librarian_2014.09.10_v1.1.0.7z | 2014-09-10 | 3.2 kB | |
js-librarian.html | 2014-09-10 | 13.1 kB | |
README.md | 2014-09-10 | 9.4 kB | |
js-librarian_2014.09.03_v1.0.1.7z | 2014-09-03 | 2.7 kB | |
js-librarian_2014.09.03_v1.0.0.7z | 2014-09-03 | 2.7 kB | |
Totals: 8 Items | 38.4 kB | 0 |
js-librarian - v1.1.0
Set of javascript functions which simplify some common tasks.
- libCommon: Common javascript functions.
- libLogger: Logging with advanced options.
- libAjax: Ajax calls wrapper.
- libLocalStorage: localStorage with data caching.
libCommon
Common javascript functions.
Name: isTopWindow
Value: function(wnd)
Description: Checks if window is top window.
Parameters:
- wnd: Window to check. If not specified, it checks current window.
Returns: If window is top window it returns true
, otherwise it returns false
.
Name: getTopWindowSize
Value: function()
Description: Gets top window size.
Parameters: None.
Returns: { width: <Number>, height: <Number> }
Name: getAbsoluteOffset
Value: function(element)
Description: Get offset of an element from his top most parent.
Parameters:
- element:
HTMLElement
of which to calculate offset.
Returns: { left: <Number>, top: <Number> }
Name: addEventListener
Value: function(element, event, callback, capture)
Description: Adds event listener also for IE version prior to 10.
Parameters:
- element: Event target to which to bind event listener.
- event: Name of the event. The same name applies for IE version prior to 10.
- callback: Function to call when event fires.
- capture: Parameter which controls event propagation direction.
Returns: If event listener is added it returns true
, otherwise it returns false
.
Name: openPopup
Value: function(url, title, width, height)
Description: Opens popup window at the center.
Parameters:
- url: Url to show in the popup.
- title: Title of the popup.
- width: Width of the popup.
- height: Height of the popup.
Returns: Newly created window
object.
libLogger
Logging with advanced options.
Name: LoggingLevel
Value: { none: 0, debug: 1, trace: 2, info: 3, warning: 4, error: 5 }
Description: Defines possible logging levels.
Name: loggingLevel
Value: libLogger.LoggingLevel.info
Description: Sets or gets logging level for current instance.
Name: type
Value: function(loggingLevel)
Description: Defines an instance of libLoger.
Parameters:
- loggingLevel: Logging level for this instance.
Returns: None.
Name: instance
Value: function(loggingLevel)
Description: Creates an instance of libLogger.
Parameters:
- loggingLevel: Logging level for this instance.
Returns: Newly created instance.
Name: printVar
Value: function(value, recursionLevel)
Description: Outputs formated string of specified value.
Parameters:
- value: Input value to print.
- resursionLevel: Used internally to limit level to nested objects to print.
Returns: Printed output value.
Name: consoleLog
Value: function(value)
Description: If current window have console then outputs value to window console, otherwise outputs value to parent window console.
Parameters:
- value: Value to output.
Returns: None.
Name: write
Value: function(source, args)
Description: Writes preformated string to console if loggingLevel > libLogger.LoggingLevel.None
.
Parameters:
- source: String denoting source of log event.
- args: Object which contains additional data.
Returns: None.
Name: debug
Value: function(source, args)
Description: Writes debug level (temporary log) and greater log to console.
Parameters:
- source: String denoting source of log event.
- args: Object which contains additional data.
Returns: None.
Name: trace
Value: function(source, args)
Description: Writes trace level (program trace) and greater log to console.
Parameters:
- source: String denoting source of log event.
- args: Object which contains additional data.
Returns: None.
Name: info
Value: function(source, args)
Description: Writes info level (information) and greater log to console.
Parameters:
- source: String denoting source of log event.
- args: Object which contains additional data.
Returns: None.
Name: warning
Value: function(source, args)
Description: Writes warning level (errors not caused by bug in code) and greater log to console.
Parameters:
- source: String denoting source of log event.
- args: Object which contains additional data.
Returns: None.
Name: error
Value: function(source, args)
Description: Writes error level (bug in code) and greater log to console.
Parameters:
- source: String denoting source of log event.
- args: Object which contains additional data.
Returns: None.
libAjax
Ajax calls wrapper.
Name: RequestMethod
Value: { get: 'GET', post: 'POST' }
Description: Defines HTTP method used to send request.
Name: ReadyStateText
Value: [ 'Uninitialized', 'Open', 'Sent', 'Receiving', 'Loaded' ]
Description: Defines stages during request processing.
Name: RequestParams
Value: { resource: '', method: libAjax.RequestMethod.post, headers: [], data: {}, contentType: 'application/x-www-form-urlencoded', crossDomain: false, async: false, timeout: 20000, onSuccess: function(xmlHTTP) {}, onError: function(status) {}, loggingLevel: libLogger.LoggingLevel.warning }
Description: Defines default request parameter values when processing request method.
Parameters:
- resource: Request url.
- method: HTTP method.
- headers: Additional headers.
- data: Request data in the form of string or collection of key/value.
- contentType: Content-Type request header.
- crossDomain: Set to true if resource is hosted at another domain.
- async: Set to true to perform request asynchronously.
- timeout: Request timeout in milliseconds.
- onSuccess: Function to call when if request is successful.
- onError: Function to call when request is unsuccessful.
- loggingLevel: Console logging level for this request.
Returns: None.
Name: request
Value: function(params)
Description: Performs ajax request.
Parameters:
- params: Object which contains request parameters that should be used for request. For each parameter that is not specified, default value will be used.
Returns: If call was successful it returns true
, or false
if there was an error.
Name: requestText
Value: function(params)
Description: Performs ajax request and returns responseText
property of browser XMLHTTP component.
Parameters:
- params: Object which contains request parameters that should be used for request. For each parameter that is not specified, default value will be used.
Returns: If call was successful it returns true
, or false
if there was an error.
Name: requestXML
Value: function(params)
Description: Performs ajax request and returns responseXML
property of browser XMLHTTP component.
Parameters:
- params: Object which contains request parameters that should be used for request. For each parameter that is not specified, default value will be used.
Returns: If call was successful it returns true
, or false
if there was an error.
Name: requestJSON
Value: function(params)
Description: Performs ajax request and returns JSON object from parsed responseText
property of browser XMLHTTP component.
Parameters:
- params: Object which contains request parameters that should be used for request. For each parameter that is not specified, default value will be used.
Returns: If call was successful it returns true
, or false
if there was an error.
libLocalStorage
localStorage with data caching.
Name: data
Value: {}
Description: Contains cached values.
Name: getItem
Value: function(key, refresh)
Description: Gets an item from local storage.
Parameters:
- key: Item key.
- refresh: If specified and true, item will first be refreshed from localStorage to cache, then read from cache.
Returns: If call was successful it returns item object, or null
if item does not exists or there was an error.
Name: setItem
Value: function(key, item)
Description: Sets an item in local storage.
Parameters:
- key: Item key.
- item: An item to set.
Returns: If call was successful it returns item object, or null
if item is null
or undefined
.
Name: removeItem
Value: function(key)
Description: Removes item from local storage.
Parameters:
- key: Item key.
Returns: None.
Name: getWindow
Value: function()
Description: Used internally to get top most window for localStorage object.
Parameters: None.
Returns: Top most window object.