User:Derik/javascript
From MediaWiki
Jump to navigationJump to searchHopefully this sandbox will eventually represent a documentation of the useful bits of our javascript; mediawiki-originated, cribbed from wikia and other sites, and original.
It is my fervent wish that by documenting it thus, redundant code can be minimized.
A-F
[edit]- IN: wikibits.js - Same as addHandler() (below) but a neater markup specific to click events.
- IN: wikibits.js - bind an elevent to an element. Same as hoolEvent() but on an element-level rather than window-level.
- IN: wikibits.js - Adds a function to an array of functions that will be executed once the page is fully loaded.
- IN: wikibits.js - replaces the inner text of an element el with the newText provided
Note: This function uses the element.innerText attribute to perform this replacement. It may mangle HTML?
- IN: wikibits.js - Just what you'd expect, escapes quotes with backslashes.
- IN: wikibits.js - Just what you'd expect, escapes quotes with HTML entities.
G-M
[edit]- IN: wikibits.js - returns an array of element nodes with the class found in classNameObj within the element node. tagName can also be used, or set to '*' to match all HTML tags. classNameObj can (apparently) be either an array (with multiple classes) or a string All variables are required.
- IN: Monacobook.js - Returns an element handle for the first H1 ont he page with a class 'firstHeading'. (The page title)
Note: Based on showEras() from Wookiepedia, but our implementation is cleaner!
- IN: wikibits.js - binds a function to a window-level event by hookName, where hookName is the common javascrit-internal name for that event-- minus the leading "on."
- IN: wikibits.js - Inserts an "in progress" spinner after the provided element for Ajax-y goodness. You can remove it later with removeSpinner()
Note: The spinner graphic is very gay.
- IN: wikibits.js - Adds text to the edit window (when in edit mode) at the point of the cursor.
To simply insert a tag, format is insertTags('disambig',,);
- IN: wikibits.js - Pops a notice box up at the top of the page. Functions just like you'd think...
N-S
[edit]- IN: wikibits.js - scrolls the window to an anchor anchorName.
- IN: wikibits.js - removes the "in progress" spinner added by injectSpinner()
- IN: Monacobook.js - Looks for an element with the provided idString, then clones it into the first heading and changes its display mode to "block." (Used to display faction symbols.)
Note: Based on showEras() from Wookiepedia.
T-Z
[edit]- IN: wikibits.js - given two html element id strings (not the elements themselves!,) disables the first element and enables the second. (Used for complicated forms.)
- IN: wikibits.js - given two element id strings that refer to checkboxes, checks the first element and unchecks the second. (Used for complicated forms.)
- IN: wikibits.js - toggles the element element in and out of visibility while alternately hiding/inlining the second two elements. Used for the "enhanced" version of the Special:RecentChanges page.

