「使用者:Wade.fs/MOOzillaC/files js」修訂間的差異
出自 MozTW Wiki
< 使用者:Wade.fs | MOOzillaC
(→節次重排) |
|||
行 1: | 行 1: | ||
− | + | = utils.js = | |
− | + | # 來源為 JSIRC Library | |
− | + | # 定義變數: | |
var singleTags = new Array( | var singleTags = new Array( | ||
"br", "img", "hr", "li", "dt", "dd", "meta", "link", "base","isindex", | "br", "img", "hr", "li", "dt", "dd", "meta", "link", "base","isindex", | ||
"p", "nextid", "wbr", "option", "input", "area", "xmz_menu", "embed"); | "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 | |
− | + | # 需 utils.js | |
− | + | # 定義系統訊息代碼,如 NS_ERROR_, NS_NET_STATUS_ ... | |
− | + | # 函式: | |
− | + | #* toScriptableInputStream (i) | |
− | + | #* CBSConnection () | |
− | + | #* CBSConnection.prototype.connect = bc_connect(host, port, bind, tcp_flag, observer) | |
− | + | #* CBSConnection.prototype.disconnect = bc_disconnect() | |
− | + | #* CBSConnection.prototype.sendData = bc_senddata(str) | |
− | + | #* CBSConnection.prototype.readData = bc_readdata(timeout, count) | |
− | + | #* CBSConnection.prototype.startAsyncRead = bc_saread (observer) | |
− | + | #* CBSConnection.prototype.asyncWrite = bc_awrite (str) | |
− | + | #* CBSConnection.prototype.hasPendingWrite = bc_haspwrite () | |
− | + | #* CBSConnection.prototype.sendDataNow = bc_senddatanow(str) | |
− | + | #* StreamProvider(observer) | |
− | + | #* StreamListener(observer) | |
− | + | #* StreamProvider.prototype.onDataWritable = sp_datawrite (request, ctxt, ostream, offset, count) | |
− | + | #* StreamListener.prototype.onDataAvailable = sl_dataavail (request, ctxt, inStr, sourceOffset, count) | |
− | + | = entity.js = | |
− | + | # 將 HTML 的 entity 映射成 unicode 字元,例如: | |
htmlEntities.nbsp = "\u00a0"; | htmlEntities.nbsp = "\u00a0"; | ||
− | + | # 定義函式: getEntity(str) | |
− | + | = htmlRender.js = | |
− | + | # 定義所有用來分析、顯示內容的函式 | |
− | + | # 取得 prefs | |
const PREF_CTRID = "@mozilla.org/preferences-service;1"; | const PREF_CTRID = "@mozilla.org/preferences-service;1"; | ||
const nsIPrefBranch = Components.interfaces.nsIPrefBranch | const nsIPrefBranch = Components.interfaces.nsIPrefBranch | ||
var pref = Components.classes[PREF_CTRID].getService(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 重新包裝成較易用易讀的版本 | |
+ | <pre> | ||
var c = new CConnection('moo.ca', 7777); | var c = new CConnection('moo.ca', 7777); | ||
行 118: | 行 119: | ||
c.write("Hello!"); | c.write("Hello!"); | ||
c.close(); | c.close(); | ||
+ | </pre> | ||
+ | # 定義函式: | ||
+ | #* 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() | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
於 2005年7月29日 (五) 10:58 的修訂
內容大綱
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
- 需 utils.js
- 定義系統訊息代碼,如 NS_ERROR_, NS_NET_STATUS_ ...
- 函式:
- toScriptableInputStream (i)
- CBSConnection ()
- CBSConnection.prototype.connect = bc_connect(host, port, bind, tcp_flag, observer)
- CBSConnection.prototype.disconnect = bc_disconnect()
- CBSConnection.prototype.sendData = bc_senddata(str)
- CBSConnection.prototype.readData = bc_readdata(timeout, count)
- CBSConnection.prototype.startAsyncRead = bc_saread (observer)
- CBSConnection.prototype.asyncWrite = bc_awrite (str)
- CBSConnection.prototype.hasPendingWrite = bc_haspwrite ()
- CBSConnection.prototype.sendDataNow = bc_senddatanow(str)
- StreamProvider(observer)
- StreamListener(observer)
- StreamProvider.prototype.onDataWritable = sp_datawrite (request, ctxt, ostream, offset, count)
- StreamListener.prototype.onDataAvailable = sl_dataavail (request, ctxt, inStr, sourceOffset, count)
entity.js
- 將 HTML 的 entity 映射成 unicode 字元,例如:
htmlEntities.nbsp = "\u00a0";
- 定義函式: getEntity(str)
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()