Overview

HTTPS SSH

Functions:

  • DOM
    • document
  • DOM.create(tagname)
    • document.createElement(tagname)
  • Array.unique()
    • Return set of an array, in sorted order
  • Array.each(handler)
    • handler in the form of function(value, index)
  • Element.ready(handler)
    • Set the onload function of an element
  • Element.html()
    • Return innerHTML
  • $(query)
    • Select elements using CSS styled queries
    • Returned as array
  • $$(query)
    • Select elements using CSS styled queries
    • Return as a single node or NULL if empty
  • ele.set(key, value)
    • $: altering the class of ele eg. set("$", "+firstClass -secondClass")
    • $cssStyle: alter CSS style eg. set("$display", "none")
    • @attribute: alter attributes eg. set("@href", "http://ongspxm.bitbucket.org")
    • html: alter innerHTML eg. set("html", "<h1>Success!</h1>")
    • click: set onClick function eg. set("click", callHandler)
    • over: set onMouseOver function eg. set("over", mouseOverHandler)
    • out: set onMouseOut function eg. set("out", mouseOutHandler)
  • ele.set("toggle", key, values)
    • key in form of the keys for set
    • values are the different states possible
    • eg. set("toggle", "$display", ["block", "none"])
  • ele.get(key)
    • $: return className of ele
    • $cssStyle: return CSS style
    • @attribute: return attribute
    • html: return innerHTML
    • click: return onClick handler
    • over: return onMouseOver handler
    • out: return onMouseOut handler
    • toggle: return the current toggle state of ele
  • ele.add(html)
    • Adds html to innerHTML
  • ele.toggle()
    • Change the fastToggle state
  • list.find(handler)
    • Return index where of first case where handler(value, index) returns true
    • [1, 2, -4, 5, 2, -1].find(function(val, index){ if(val<0) return index; }); // returns 2
  • list.find(Array)
    • Return index of the first item that is found in Array
  • list.find(value)
    • Return index of the first item that matches value
  • list.filter(handler)
    • Return a list where handler(value, index) returns true
    • [1, 2, -4, 5, 2, -1].filter(function(val, index){ if(val<0) return index; }); // returns [-4, -1]
  • list.filter(Array)
    • Return a list of items found in Array
  • list.filter(value)
    • Return a list of items that matches value
  • list.collect(handler)
    • Concats and returns the results of running each item through the handler
[3, 7, 11, 5, 19, 3].collect(function(number, index) {
    if (number > 10)
        return null;           // remove numbers >10
    else if (number > 5)
        return [5, number-5];  // replace with two entries
    else
        return number;         // keep lower numbers
});
  • request(method, url, data, callback, content)
    • method: GET | POST | PUT | DELETE
    • url: URL to visit
    • data: In form of object or encoded string
    • callback: function to call the data with
    • content: json | txt | xml (response to pass into callback)