mini.js documentation
Source Browser
Select a Function
Globals Vars
IE: True in IE, false elsewhere. Try to use only to work around bugs
FF: A number, the major version in FireFox, false otherwise. (!FF && !IE) mostly means webkit since opera cheats
Tag Functions
el(id): gets an element by id. if passed an element, it returns the element. old entries are cached, repeat calls are almost instantaneous.
els(id): gets an element's style object by the element's id
tags(elm, id): get tags into array by tag name elm. if id is passed, only elements of tag elm under element id are returned.
dom : several methods to simplify working with the dom:
dom.div(nodeName, content) - quickly creates a new element with the value/innerHTML of content
dom.attribs(elm, attribOb) - binds an object of attribs and properties to an element
dom.create(nodeName, content, attribs) - a new element filled with content and bound to attribs object
dom.prependChild(newChild, parentElement) - makes newChild the first sub-tag inside parentElement
dom.text(elm) - returns the text content of an element. handles inputs and regular tags.
dom.kill(elm) - removes an element from the document
dom.encodeHTML(str) - allows source code to be displayed without parsing it as tags
dom.getParent(elm, tagName) - finds the first tagName tag wrapping the element
dom.replace(newNode, oldNode) - replaces one element with another
Array Extras
.map(fn,this) : applies a function to each index of an array
.filter(fn,this) : filters array elements according to truthfulness of function's return
.indexOf(var2match, numStartSlot) : gives arrays an indexOf feature
.pluck(arrayKeys): build a new array of objects from another array of objects based upon the passed array of key names
.random(): a random element of an array
.unique(): returns a duplicate-free array
.valids(): array stripped of undefined elements
._(strKey): a property of each element
.bind: adds propert(y/ies) /methods to each element
.iif(strExpression): a conditional to filter an array of objects ex: tags("*").iif(".className=='active' ")
Data Handling Functions
ping(url): send a GET request to any URL on any domain
store(key, val): client-side persistence. if val is passed then sets the data, else returns key's data (aka foxStore)
getCookie(strName): loads the cookie named in the argument and returns it as a string
setCookie(strName, strValue): saves a cookie named by the 1st argument with the data in the 2nd arg.
IO(url, data) : file saving and loading. loads synchronous, saves asynch
jsGet(url): simple remote scripting tag adder (aka inject)
tmpl8(objData, strTemplate): a substitution template using json: **key**- tmpl8( [{a:1},{a:4}] , "#: **a**\t") ="#: 1 #: 4 "
Object.toSource() : json serializer for all browsers
Rake Functions
obKeys(obj): array of object's key names
obVals(obj): array of object's values
obValsl(obj): returns an array of objects from objects with native .length properties (like nodeLists and collections)
obMap(obj): 2 column array from objects key and values : {k:v, k2:v2} => [ [k,v], [k2,v2] ]
Misc Functions
aCSS(strCssCode): adds a new stylesheet from a string containing css text (like the content of a style tag)
defer(code): Slightly delays the function or string code to free the CPU to handle the stack. also allows a small window for user input to be processed.
F$(str): turns a string into a function with three named args: a,b, and c.