使用者:Wade.fs/MOOzillaC/files js
出自 MozTW Wiki
< 使用者:Wade.fs | MOOzillaC
內容大綱
utils.js
- 來源為 JSIRC Library
- 定義變數:
var singleTags = new Array( "br", "img", "hr", "li", "dt", "dd", "meta", "link", "base","isindex", "p", "nextid", "wbr", "option", "input", "area", "xmz_menu", "embed");
- 提供物件: 像 dd, jsenv 物件等
- 函式:
- dumpObject (o, pfx, sep);
- dumpObjectTree (o, recurse, compress, level), 用法 dumpObjectTree (o, 1);
- Clone (obj) 複製已存在的物件,用法: var c = Clone(obj); 或 var c = new Clone(obj);
- matchObject (o, pattern, negate);
- matchEntry (partialName, list)
- getCommonPfx (list)
- renameProperty (obj, oldname, newname)
- newObject(contractID, iface)
- getPriv (priv)
- keys (o)
- stringTrim (s)
- formatDateOffset (seconds, format)
- arrayContains (ary, elem)
- arrayIndexOf (ary, elem)
- arrayInsertAt (ary, i, o)
- arrayRemoveAt (ary, i)
- abbreviateWord (str, length)
- hyphenateWord (str, pos, hyphen)
- splitLongWord (str, pos)
- getRandomElement (ary)
- roundTo (num, prec)
- randomRange (min, max)
- getStackTrace ()
- getInterfaces (cls)
- mapObjFunc(ary, func_name, data)
- map(func, ary)
- lmth(str) : Inputs a string and parses it for any unclosed HTML tags.
connection-xpcom.js
- 源自 JSIRC Library,此為本擴充的 socket 核心
- 需 utils.js
- 定義系統訊息代碼,如 NS_ERROR_, NS_NET_STATUS_ ...
- 局部函式: toScriptableInputStream (i)
- 定義物件:CBSConnection StreamProvider StreamListener
entity.js
- 將 HTML 的 entity 映射成 unicode 字元,例如: htmlEntities.nbsp = "\u00a0";
- 定義函式: getEntity(str) 用來取得出現的 entity 字串的 unicode
- 定義物件 htmlEntities,取用時透過 getEntity(str) 較佳,亦可自行以 hash 取得
htmlRender.js
- 定義所有用來分析、顯示內容的函式
- 取得 prefs
const PREF_CTRID = "@mozilla.org/preferences-service;1"; const nsIPrefBranch = Components.interfaces.nsIPrefBranch var pref = Components.classes[PREF_CTRID].getService(nsIPrefBranch);
- 定義函式:
- createTextElement(str, literalText, returnEvenWithBlankStr)
- createMsgElement(str, optionObject)
- wrapInTable(element, optionObject)
- styleElementByClass(element, includePrefix, optionObject)
- doRecursiveHTMLMunge(str, parent, optionObject)
- recursiveTagEnder(right, tagName)
- mungeByAutohyperlink(str, parent, optionObject)
moozilla.js
- 用來控制主視窗
- 定義「每步時間」 var STEP_TIMEOUT = 500;
- 定義函式:
- onLoad()
- onHTMLKey()
- onHTMLClick()
- onUnLoad()
- onNextCmd()
- onPrevCmd()
- onWindowKeyPress(e)
- onPageDown()
- onPageUp()
- toggleMultiline()
- multilineInputMode(state)
- onMultilineInputKeyPress(e)
- completeInput(e)
- onInputKeyPress(e)
- displayLine(str, dataclass)
- mainStep()
- onClose(status, errStr)
- onRead(str)
- onConnect()
- connectionTerminated()
- onDisconnect()
- onSendtoinput()
- reverseString(str)
- commandLink(command)
- onSaveScrollback(continueLogging)
- onStartLogging()
- onStopLogging()
- onClearScrollback()
network.js
- 將 connection-xpcom.js 重新包裝成較易用易讀的版本
var c = new CConnection('moo.ca', 7777); c.onRead = function(str) { alert("connection sent us " + str); } c.open(); c.write("Hello!"); c.close();
- 定義函式:
- CConnection(host, port)
- CConnection.prototype.onStreamClose = connection_osr(status)
- CConnection.prototype.onStreamDataAvailable = connection_sda(request, inStream, sourceOffset, count)
- CConnection.prototype.connect = CConnection.prototype.open = connection_open()
- CConnection.prototype.write = connection_write(str)
- CConnection.prototype.close = CConnection.prototype.disconnect = connection_close()
newconn.js
- 給「連線」視窗用的函式
- 定義函式:
- onWindowKeyPress(e)
- onLoad()
- greyout() 用於讓 user name, passwd 欄位變灰色
- onSelect()
- saveData() 將對話框所選的內容存到 client 物件
- onNewConnection()
- onDeleteConnection()
- onOK()
- onCancel()