Effect of bad programming: Why Robots are killing Humans!

Advertisements

Developer Cheetsheet

Jquery 1.7

Core

jQuery function

$.jQuery( selector [, context] | element | elementArray |jQueryObject ), .jQuery( )
$.jQuery( html [, owner]  | html, props )
$.jQuery( fn )
def.when(deferreds)
$.holdReady( hold )

jQuery Object Accessors

$.each( fn(index, element) )
num.size( ), .length
$.eq( index )
jQuery.error( str )
[el],el.get( [index] )
num.index( ), .index( selector | element )
$jQuery.pushStack( elements, [name, args] )
arr.toArray( )

Interoperability

$jQuery.noConflict( [extreme] )

AJAX

Low-Level Interface

jqXHRjQuery.ajax( options, [settings] )

  • mapaccepts
  • boolasync = true
  • fnbeforeSend( jqXHR, config)
  • boolcache = true
  • fncomplete( jqXHR, status)
  • mapcontents
  • strcontentType
  • objcontext
  • mapconverters
  • boolcrossDomain
  • obj, strdata
  • fndataFilter( data, type )
  • boolglobal = true
  • mapheaders
  • boolifModified = false
  • strjsonp
  • fnjsonpCallback
  • strpassword
  • boolprocessData = true
  • strscriptCharset
  • mapstatusCode
  • numtimeout
  • booltraditional
  • strtype = ‘GET’
  • strurl = curr. page
  • strusername
  • fnxhr
  • strdataType ∈ {xml, json, script, html}
  • fnerror( jqXHR, status, errorThrown )
  • fnsuccess( data, status, jqXHR )
jQuery.ajaxSetup( options )

Miscellaneous

str.serialize(  )
[obj].serializeArray(  )
strjQuery.param( obj, [traditional] )

Shorthand Methods

$.load( url [, data] [, fn( responseText, status, XHR )] )
jqXHRjQuery.get( url [, data] [, fn( data, status, XHR )] [, type] )
jqXHRjQuery.getJSON( url [, data] [, fn( data, status )] )
jqXHRjQuery.getScript( url [, fn( data, status )] )
jqXHRjQuery.post( url [, data] [, fn( data, status )] [, type] )

Global Ajax Event Handlers

$.ajaxComplete( fn( event, XHR, options ) )
$.ajaxError( fn( event, XHR, options, thrownError ) )
$.ajaxSend( fn( event, XHR, options ) )
$.ajaxStart( fn(  ) )
$.ajaxStop( fn(  ) )
$.ajaxSuccess( fn(event, XHR, options) )

Events

Page Load

$.ready( fn() )

Event Handling

$.on( events [, selector] [, data], handler )1.7+
$.on( events-map [, selector] [, data] )1.7+
$.off( events [, selector] [, handler] )1.7+
$.off( events-map [, selector] )1.7+
$.bind( type [, data ], fn(eventObj) )
$.bind( type [, data], false )
$.bind( array )
$.unbind( [type] [, fn])
$.one( type [, data ], fn(eventObj) )
$.trigger( event [, data])
obj.triggerHandler( event [, data])
$.delegate( selector, type, [data], handler)
$.undelegate( [selector, type, [handler]]) | selector, events | namespace )

Live Events

$.live( eventType [, data], fn() )
$.die( ), .die( [eventType] [, fn() ])

Interaction Helpers

$.hover( fnIn(eventObj), fnOut(eventObj))
$.toggle( fn(eventObj), fn2(eventObj) [, …])

Event Helpers

function ( [data,] [fn] )

Effects

Basics

$.show( [ duration [, easing] [, fn] ]  )
$.hide( [ duration [, easing] [, fn] ]  )
$.toggle( [showOrHide] )
$.toggle( duration [, easing] [, fn] )

Sliding

$.slideDown( duration [, easing] [, fn] )
$.slideUp( duration [, easing] [, fn] )
$.slideToggle( [duration] [, easing] [, fn] )

Fading

$.fadeIn( duration [, easing] [, fn] )
$.fadeOut( duration [, easing] [, fn] )
$.fadeTo( [duration,] opacity [, easing] [, fn] )
$.fadeToggle( [duration,] [, easing] [, fn] )

Custom

$.animate( params [, duration] [, easing] [, fn] )
$.animate( params, options )
$.stop( [queue] [, clearQueue] [, jumpToEnd] )1.7*
$.delay( duration [, queueName] )

Attributes

Attributes

str.attr( name | name , value )
$.attr( name, val | map | name, fn(index, attr) )
$.removeAttr( name )
$.prop( name )
$.removeProp( name )

Class

$.addClass( class | fn(index, class) )
bool.hasClass( class )
$.removeClass( [class] | fn(index, class) )
$.toggleClass( class [, switch] | fn(index, class) [, switch] )

HTML, text

str.html( )
$.html( val | fn(index, html) )
str.text( )
$.text( val | fn(index, html) )

Value

str,arr.val( )
$.val( val | fn() )

CSS

CSS

str.css( name )
$.css( name, val | map | name, fn(index, val) )

Positioning

obj.offset( )
$.offset( coord | fn( index, coord ) )
obj.position( )
int.scrollTop( )
$.scrollTop( val )
int.scrollLeft( )
$.scrollLeft( val )

Height and Width

int.height( )
$.height( val | fn(index, height ) )
int.width( )
$.width( val | fn(index, height ) )
int.innerHeight( )
int.innerWidth( )
int.outerHeight( [includeMargin] )
$.outerHeight( val | fn(index, outerHeight ) ) 1.8+
int.outerWidth( [includeMargin] )
$.outerWidth( val | fn(index, outerWidth ) ) 1.8+

Traversing

Filtering

$.eq( index )
$.first( )
$.last( )
$.has( selector ), .has( element )
$.filter( selector ), .filter( fn(index) )
bool.is( selector | function(index) | jQuery object | element )1.7*
$.map( fn(index, element) )
$.not( selector ), .not( elements ), .not( fn( index ) )
$.slice( start [, end] )

Tree traversal

$.children( [selector] )
$.closest( selector [, context] | jQuery object | element )
arr.closest( selectors [, context] )removed
$.find( selector | jQuery object | element )
$.next( [selector] )
$.nextAll( [selector] )
$.nextUntil( [selector] )
$.parent( [selector] )
$.parents( [selector] )
$.parentsUntil( [selector] )
$.prev( [selector] )
$.prevAll( [selector] )
$.prevUntil( [selector] )
$.siblings( [selector] )

Miscellaneous

$.add( selector [, context] | elements | html )
$.andSelf( )
$.contents( )
$.end( )

Manipulation

Inserting Inside

$.append( content | fn( index, html ) )
$.appendTo( target )
$.prepend( content | fn( index, html ) )
$.prependTo( target )

Inserting Outside

$.after( content | fn() )
$.before( content | fn() )
$.insertAfter( target )
$.insertBefore( target )

Inserting Around

$.unwrap( )
$.wrap( wrappingElement | fn )
$.wrapAll( wrappingElement | fn )
$.wrapInner( wrappingElement | fn )

Replacing

$.replaceWith( content | fn )
$.replaceAll( selector )

Removing

$.detach( [selector] )
$.empty( )
$.remove( [selector] )

Copying

$.clone( [withDataAndEvents], [deepWithDataAndEvents] )

Deferred

deferred object = {

def.always(alwaysCallbacks [, alwaysCallbacks])
defdone(doneCallbacks)
deffail(failCallbacks)
boolisRejected()deprecated
boolisResolved()deprecated
strstate()1.8+
def.notify( args )1.7+
def.notifyWith(context, [args])1.7+
def.pipe([doneFilter] [, failFilter] [, progressFilter])1.7*
def.progress( progressCallbacks )1.7+
defreject([args])
defrejectWith(context, [args])
defresolve([args])
defresolveWith(context, [args])
strstate()
defthen(doneCallbacks, failCallbacks [, progressCallbacks])1.7*

}

def.promise([target])

Callbacks

callbacks object = {1.7+

und.add(callbacks)
und.disable()
und.empty()
und.fire(arguments)
bool.fired()
und.fireWith([context] [, args])
bool.has(callback)
und.lock()
bool.locked()
und.remove(callbacks)

}

cb $.Callbacks( flags )

Utilities

Browser and Feature Detection

objjQuery.browserdeprecated
booljQuery.boxModeldeprecated

Basic operations

objjQuery.each( obj, fn( i, valueOfElement ) )
objjQuery.extend( [deep,] target, obj1 [, objN] )
arrjQuery.grep( arr, fn( el, i ) [, invert] )
arrjQuery.makeArray( obj )
arrjQuery.map( arrayOrObject, fn( el, i ) )
numjQuery.inArray( val, arr )
arrjQuery.merge( first, second )
fnjQuery.proxy( fn, scope | scope, name )
arrjQuery.unique( arr )
strjQuery.trim( str )
objjQuery.parseJSON( str )

Data functions

$.clearQueue( [name] )
$.dequeue( [name] ), jQuery.dequeue([name] )
objjQuery.data( el, key ), jQuery.data(  )
obj.data(  ), .data( key )
$.data( key, val | obj )
$.removeData( [name] |[list])1.7*
[fn].queue( [name] )jQuery.queue( [name] )
$.queue( [name,] fn( next ) ), jQuery.queue([name,] fn(  ) )
$.queue( [name,] queue ), jQuery.queue([name,] queue )

Test operations

strjQuery.type( obj )
booljQuery.isArray( obj )
booljQuery.isFunction( obj )
booljQuery.isWindow( obj )
booljQuery.isNumeric( val )

Javascript

Form Events

Event Object Constant

  • AT_TARGET
  • BUBBLING_PHASE
  • CAPTURING_PHASE

Event Object Properties

Event Object Methods

  • initEvent()
  • preventDefault()
  • stopPropagation()

EventTarget Object

  • addEventListener()
  • dispatchEvent()
  • removeEventListener()

EventListener Object

  • handleEvent()

MouseEvent/KeyboardEvent Object

MouseEvent/KeyboardEvent Methods

  • initMouseEvent()
  • initKeyboardEvent()

DOM Node

Node Types

  • Element1
  • Attr2
  • Text3
  • CDATASection4
  • EntityReference5
  • Entity6
  • ProcessingInstruction7
  • Comment8
  • Document9
  • DocumentType10
  • DocumentFragment11
  • Notation12

nodeName Returns

  • Element
  • element name
  • Attr
  • attribute name
  • Text
  • #text
  • CDATASection
  • #cdata-section
  • EntityReference
  • entity reference name
  • Entity
  • entity name
  • ProcessingInstruction
  • target
  • Comment
  • #comment
  • Document
  • #document
  • DocumentType
  • doctype name
  • DocumentFragment
  • #document fragment
  • Notation
  • notation name

nodeValue Returns

  • Element
  • null
  • Attr
  • attribute value
  • Text
  • content of node
  • CDATASection
  • content of node
  • EntityReference
  • null
  • Entity
  • null
  • ProcessingInstruction
  • content of node
  • Comment
  • comment text
  • Document
  • null
  • DocumentType
  • null
  • DocumentFragment
  • null
  • Notation
  • null

RegExp

Modifiers

  • i
  • Perform case-insensitive matching
  • g
  • Perform a global match (find all matches rather than stopping after the first match)
  • m
  • Perform multiline matching

Brackets

  • [abc]
  • Find any character between the brackets
  • [^abc]
  • Find any character not between the brackets
  • [0-9]
  • Find any digit from 0 to 9
  • [A-Z]
  • Find any character from uppercase A to uppercase Z
  • [a-z]
  • Find any character from lowercase a to lowercase z
  • [A-z]
  • Find any character from uppercase A to lowercase z
  • [adgk]
  • Find any character in the given set
  • [^adgk]
  • Find any character outside the given set
  • (red|blue|green)
  • Find any of the alternatives specified

Metacharacters

  • .
  • Find a single character, except newline or line terminator
  • \w
  • Find a word character
  • \W
  • Find a non-word character
  • \d
  • Find a digit
  • \D
  • Find a non-digit character
  • \s
  • Find a whitespace character
  • \S
  • Find a non-whitespace character
  • \b
  • Find a match at the beginning/end of a word
  • \B
  • Find a match not at the beginning/end of a word
  • \0
  • Find a NUL character
  • \n
  • Find a new line character
  • \f
  • Find a form feed character
  • \r
  • Find a carriage return character
  • \t
  • Find a tab character
  • \v
  • Find a vertical tab character
  • \xxx
  • Find the character specified by an octal number xxx
  • \xdd
  • Find the character specified by a hexadecimal number dd
  • \uxxxx
  • Find the Unicode character specified by a hexadecimal number xxxx

Quantifiers

  • n+
  • Matches any string that contains at least one n
  • n*
  • Matches any string that contains zero or more occurrences of n
  • n?
  • Matches any string that contains zero or one occurrences of n
  • n{X}
  • Matches any string that contains a sequence of X n‘s
  • n{X,Y}
  • Matches any string that contains a sequence of X to Y n‘s
  • n{X,}
  • Matches any string that contains a sequence of at least X n‘s
  • n$
  • Matches any string with n at the end of it
  • ^n
  • Matches any string with n at the beginning of it
  • ?=n
  • Matches any string that is followed by a specific string n
  • ?!n
  • Matches any string that is not followed by a specific string n

RegExp Methods

Core DOM

Nodelist Properties

Nodelist Methods

NamedNodeMap Properties

NamedNodeMap Methods

Element Properties

Attr Properties