Class Index | File Index

Classes


Class CeL.net.web

web 的 functions
Defined in: web.origin.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
null module constructor
Method Summary
Method Attributes Method Name and Description
<static>  
CeL.net.web.add_listener(type, listener, target_element, p_first)
bind/add listener.
<static>  
CeL.net.web.add_node(node, child_list)
append children node to specified element
<static>  
CeL.net.web.deal_barcode(callback)
條碼器(Barcode Scanner)/雷射讀碼器的輸入可用 onkeypress 取得
<static>  
CeL.net.web.get_element(id, flag)
簡化 document.getElementById 並配合 loadReference()
<static>  
CeL.net.web.get_node_offset(node)
get the actual position [left,top,width,height] of an HTML node object
<static>  
CeL.net.web.get_query(query_string, add_to)
Translate a query string to a native Object contains key/value pair set.
<static>  
CeL.net.web.get_selection(index)
獲取頁面上選中的選取區資訊。
<static>  
CeL.net.web.get_style(element, name, not_computed)
get current computed style property of specified HTML element.
<static>  
CeL.net.web.HTML_to_Unicode(HTML, only_digital)
Translate HTML code to Unicode text
<static>  
CeL.net.web.is_element_node(value)
判斷為 HTML Element。
<static>  
CeL.net.web.is_HTML_element(value)
判斷是否為 HTML Element。
<static>  
CeL.net.web.is_HTML_element_type(value, type)
判斷為指定 nodeType 之 HTML Element。
<static>  
CeL.net.web.on_load()
比較好點的 add onload。 比起 add_listener(),本函數在已經 load 時依然會執行,而 add_listener 因為是用榜定的方法,因此 load 完就不再觸發(?)。 這東西頂多只能擺在 include 的 JS file 中,不能 runtime include。
<static>  
CeL.net.web.parse_URI(URI)
Parses URI
<static>  
CeL.net.web.remove_node(o, tag)
移除 node.
<static>  
CeL.net.web.replace_HTML(o, html)
replace HTML
<static>  
CeL.net.web.set_attribute(_e, propertyO, ns)
set/get/remove attribute of a element
in IE: setAttribute does not work when used with the style attribute (or with event handlers, for that matter).
<static>  
CeL.net.web.set_class(element, class_name, flag)
Sets / adds class of specified element.
<static>  
CeL.net.web.set_cookie(name, value, config)
設定document.cookie.
<static>  
CeL.net.web.set_text(element, text)
設定 HTML element 的 text。 對付IE與Moz不同的text取得方法。現階段不應用innerText,應該用此函數來取得或設定內部text。 TODO: DOM: 用.nodeValue
<static>  
CeL.net.web.stop_event(e, c)
阻止 JavaScript 事件冒泡傳遞,使 event 不傳到 parentNode。
<static>  
CeL.net.web.table_list(data, table, header, do_clean)
fill data to table.
<static>  
CeL.net.web.to_HTML(text, mode)
Translate Unicode text to HTML
<static>  
CeL.net.web.to_query_string(query_Object)
Translate a native Object contains key/value pair set to a query string.
<static>  
CeL.net.web.toggle_display(element, type)
toggle/swap display and visibility.
<static>  
CeL.net.web.Unicode_to_HTML(text, flags, ignore_tags)
Translate Unicode text to HTML code
<static>  
CeL.net.web.XML_node(tag, propertyO, insertBeforeO, innerObj, styleO)
create new HTML/XML node(element)
Class Detail
CeL.net.web()
null module constructor
Method Detail
<static> CeL.net.web.add_listener(type, listener, target_element, p_first)
bind/add listener. register event control, setup code to run. listener 應該加上 try{}catch{},否則會搞不清楚哪裡出問題。 ** 對同樣的 object,事件本身還是會依照 call add_listener() 的順序跑,不會因為 p_first 而改變。 ** NOT TESTED!! TODO: removeEventListener, remove_listener(), default 'this' 自訂 event
Parameters:
{string} type
listen to what event type. event name/action
listener
listener function/function array/function string, 須 String 之 recursive function 時可 "(function(){return function f(){f();};})()" function(e){var target=e?e.target:(e=window.event).srcElement;if(e.stopPropagation)e.stopPropagation();else e.cancelBubble=true;if(e.preventDefault)e.preventDefault();else e.returnValue=false;return false;}
target_element Optional
bind/attach to what HTML element
p_first Optional
parentNode first
Since:
2010/1/20 23:42:51
Returns:
See:
c.f., GEvent.add_listener()

<static> CeL.net.web.add_node(node, child_list)
append children node to specified element
Parameters:
node
node / node id
child_list
children node array
Since:
2007/1/20 14:12
Returns:

<static> CeL.net.web.deal_barcode(callback)
條碼器(Barcode Scanner)/雷射讀碼器的輸入可用 onkeypress 取得
//	usage:
deal_barcode(function(t) {
	if (t.length > 9 && t.length < 17)
		document.getElementById("p").value = t,
		document.forms[0].submit();
});
Parameters:
callback
callback
Since:
2008/8/26 23:10
Returns:

<static> {HTML Object} CeL.net.web.get_element(id, flag)
簡化 document.getElementById 並配合 loadReference()
Parameters:
id
所欲找尋之 element id
flag
{HTML Object} object: 參考此 document object {Number} flag: 參見 code
Since:
2004/6/25 19:33
Returns:
{HTML Object} Object
Requires:
referenceDoc,loadReferenceDone,`get_element();`

<static> CeL.net.web.get_node_offset(node)
get the actual position [left,top,width,height] of an HTML node object
Parameters:
node
HTML node object
Deprecated:
use get_style(), jQuery.offset(), jQuery.position()
Returns:
See:
http://en.wikipedia.org/wiki/Internet_Explorer_box_model_bug, http://www.comsharp.com/GetKnowledge/zh-CN/TeamBlogTimothyPage_K983.aspx, http://msdn.microsoft.com/library/en-us/dndude/html/dude04032000.asp, http://www.mail-archive.com/mochikit@googlegroups.com/msg00584.html, http://hartshorne.ca/2006/01/20/javascript_positioning/, http://www.jb51.net/article/18340.htm, http://blog.csdn.net/wangjj_016/archive/2010/04/09/5467507.aspx

<static> {Object} CeL.net.web.get_query(query_string, add_to)
Translate a query string to a native Object contains key/value pair set.
Parameters:
{String} query_string
query string. default: location.search
{Object} add_to
append to this object
Since:
2010/6/16 15:18:50
Returns:
key/value pairs
See:

<static> {Object, undefined} CeL.net.web.get_selection(index)
獲取頁面上選中的選取區資訊。
CeL.add_listener('mouseup', function (e) { var s = CeL.get_selection(); if (s && s.text) CeL.debug('select @' + this + '(' + s.element + ')' + ' (' + s.left + '+' + s.width + ',' + s.top + '+' + s.height + '), (' + e.pageX + ',' + e.pageY + '): ' + s.text); }, target_element);
Parameters:
{Number} index Optional
TODO: 第幾選取區, default: all or 0 if there's only ONE/ZERO selection
Returns:
{Object} { left: {Number} in px, top: {Number} in px, width: {Number} in px, height: {Number} in px, text: {String} 文字, element: {HTMLElement}, selection: selection object (browser dependent) }
{undefined} error.
See:
http://plugins.jquery.com/project/selectedText, Gecko: https://developer.mozilla.org/en/DOM/Selection

<static> CeL.net.web.get_style(element, name, not_computed)
get current computed style property of specified HTML element. TODO: 整合 get_node_offset, _.set_style
Parameters:
element
HTML element
name
W3C style property name (e.g., no '-webkit-background-clip')
not_computed
Since:
2010/4/2 00:14:09 rewrite
Returns:
See:
http://en.wikipedia.org/wiki/Internet_Explorer_box_model_bug, http://www.comsharp.com/GetKnowledge/zh-CN/TeamBlogTimothyPage_K983.aspx, curCSS @ jQuery, http://api.jquery.com/category/css/, JavaScript - Get Styles, style.display取值不对,难道是浏览器bug?讨论第2页: - JavaScript - web - JavaEye论坛 大體上,currentStyle 相當於 getComputedStyle,而 runtimeStyle 相當於 getOverrideStyle。但是它們還是有很重要的區別。那就是,IE的CSS計算步驟其實是不合標準的。 document.defaultView在mozilla中是指向window obj的,但是很有可能在其他broswer中就不指向window obj...因為w3c中沒有強行規定document.defaultView一定是一個global obj. 返回頁內樣式表定義的類,那麼可以使用DOM樣式表對象來訪問: var oCssRulers = document.styleSheets[0].cssRulers || document.styleSheets[0].rulers; (前者是DOM方法,後者是IE私有方法) alert(oCssRulers[0].style.display);

<static> CeL.net.web.HTML_to_Unicode(HTML, only_digital)
Translate HTML code to Unicode text
Parameters:
{String} HTML
HTML code
{Boolean} only_digital
Returns:

<static> {Boolean} CeL.net.web.is_element_node(value)
判斷為 HTML Element。
Parameters:
value
value to test
Since:
2010/6/23 02:32:41
Returns:
{Boolean} value is HTML Element
See:
http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-58190037, http://www.w3.org/DOM/

<static> {Boolean} CeL.net.web.is_HTML_element(value)
判斷是否為 HTML Element。
Parameters:
value
value to test
Since:
2010/6/23 02:32:41
Returns:
{Boolean} value is HTML Element
See:
http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-58190037, http://www.w3.org/DOM/

<static> {Boolean} CeL.net.web.is_HTML_element_type(value, type)
判斷為指定 nodeType 之 HTML Element。
Parameters:
value
value to test
type
type
Since:
2010/6/23 02:32:41
Returns:
{Boolean} value is the type of HTML Element
See:
http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-58190037, http://www.w3.org/DOM/

<static> CeL.net.web.on_load()
比較好點的 add onload。 比起 add_listener(),本函數在已經 load 時依然會執行,而 add_listener 因為是用榜定的方法,因此 load 完就不再觸發(?)。 這東西頂多只能擺在 include 的 JS file 中,不能 runtime include。
CeL.use('net.web');
CeL.on_load(function(){sl(1);},'sl(2);');
Requires:
_.add_listener,_.DOM_loaded
See:
jQuery: $(document).ready(listener); DOMContentLoaded http://webdesign.piipo.com/jquery/jquery_events 可直接參考 SWFObject。 TODO: IEContentLoaded DOMContentLoaded是firefox下特有的Event, 當所有DOM解析完以後會觸發這個事件。 DOMContentLoaded與DOM中的onLoad事件與其相近。但onload要等到所有頁面元素加載完成才會觸發, 包括頁面上的圖片等等。 jQuery ready vs load - 黑暗執行緒 $(document).ready(fn)發生在"網頁本身的HTML"載入後就觸發,而$(window).load(fn)則會等到"網頁HTML 標籤中引用的圖檔、內嵌物件(如Flash)、IFrame"等拉哩拉雜的東西都載入後才會觸發。

<static> CeL.net.web.parse_URI(URI)
Parses URI
alert(parse_URI('ftp://user:cgh@dr.fxgv.sfdg:4231/3452/dgh.rar?fg=23#hhh').hostname);
Parameters:
{String} URI
URI to parse
Since:
2010/4/13 23:53:14 from parseURI+parseURL
Returns:
parsed object
See:
RFC 1738, RFC 2396, RFC 3986, Uniform Resource Identifier (URI): Generic Syntax, http://tools.ietf.org/html/rfc3987, http://flanders.co.nz/2009/11/08/a-good-url-regular-expression-repost/, http://www.mattfarina.com/2009/01/08/rfc-3986-url-validation, also see batURL.htm

<static> CeL.net.web.remove_node(o, tag)
移除 node. TODO: also remove event handlers
Parameters:
o
tag
tag===1: only child, undefined: remove only self, others: only child
Returns:

<static> CeL.net.web.replace_HTML(o, html)
replace HTML
Parameters:
o
html
Returns:

<static> CeL.net.web.set_attribute(_e, propertyO, ns)
set/get/remove attribute of a element
in IE: setAttribute does not work when used with the style attribute (or with event handlers, for that matter).
Parameters:
_e
element
propertyO
attributes object (array if you just want to get)
ns
Since:
2006/12/10 21:25 分離 separate from XML_node()
Returns:
Requires:
split_String_to_Object
See:
setAttribute,getAttribute,removeAttribute http://www.quirksmode.org/blog/archives/2006/04/ie_7_and_javasc.html

<static> CeL.net.web.set_class(element, class_name, flag)
Sets / adds class of specified element.
TODO:
1. 一次處理多個 className。
2. 以字串處理可能較快。
3. 用 +/- 設定。
4. https://developer.mozilla.org/en/DOM/element.classList
Parameters:
element
HTML elements
class_name
class name || {class name 1:, class name 2:, ..}
flag
default: just add the specified className (flag&1)==1: reset className (else just add) (flag&2)==1: return {className1:, className2:, ..} (flag&4)==1: remove className
Returns:
See:
className of type DOMString, element.className - MDC

<static> CeL.net.web.set_cookie(name, value, config)
設定document.cookie. You can store up to 20 name=value pairs in a cookie, and the cookie is always returned as a string of all the cookies that apply to the page. TODO: HTML5 localStorage (name/value item pairs). test various values. document.cookie.setPath("/");
	範例:
//	delete domain
set_cookie('domain',0);
//	一個月(30 days)
set_cookie('expires',30);
//	設定name之值為jj
set_cookie(name,'jj');
//	設定name之值為56
set_cookie(name,56);
//	除去name
set_cookie(name);
//	設給本host全部使用
set_cookie(_.set_cookie.f.set_root);
//	設給本domain使用
set_cookie(_.set_cookie.f.set_domain);
//	依現有設定除去所有值
set_cookie(_.set_cookie.f.delete_all);
//	除去所有值
set_cookie(_.set_cookie.f.delete_all_root);
//	永久儲存(千年)
set_cookie(_.set_cookie.f.forever);
//	準確設定這之後只在這次瀏覽使用這些cookie,也可用set_cookie('expires',-1);
set_cookie(_.set_cookie.f.moment);
//	將expires設定成forever或moment後再改回來(不加expires設定)
set_cookie('expires',0);
Parameters:
{String|Object|_module_.set_cookie.f} name
set_cookie.f flag | varoius name
value
varoius value
{Boolean|Object} config
若對於特殊設定僅暫時設定時,設定此項。
Returns:
See:
Chrome doesn't support cookies for local files unless you start it with the --enable-file-cookies flag. chrome.exe --allow-file-access-from-files --enable-extension-timeline-api --enable-file-cookies http://stackoverflow.com/questions/335244/why-does-chrome-ignore-local-jquery-cookies http://code.google.com/p/chromium/issues/detail?id=535

<static> CeL.net.web.set_text(element, text)
設定 HTML element 的 text。 對付IE與Moz不同的text取得方法。現階段不應用innerText,應該用此函數來取得或設定內部text。 TODO: DOM: 用.nodeValue
Parameters:
element
HTML element
{String} text
the text to be set
Returns:
See:
http://www.klstudio.com/post/94.html

<static> CeL.net.web.stop_event(e, c)
阻止 JavaScript 事件冒泡傳遞,使 event 不傳到 parentNode。
Parameters:
e
event handle
c
cancel bubble
See:
http://www.jb51.net/html/200705/23/9858.htm

<static> CeL.net.web.table_list(data, table, header, do_clean)
fill data to table. 增加 table 的列(row)
table_list([list1],[list2],..)
e.g.,	table_list([1,2,3,4],[4,5,3,4]);
table_list([[list1],[list2],..])
e.g.,	table_list( [ [1,2,3,4],[4,5,3,4] ] );
Parameters:
{Array|Object} data
data list
table
table element
{Array} header
header list
do_clean
Since:
2010/05/03 14:13:18
Returns:
See:
http://www.datatables.net/

<static> {String} CeL.net.web.to_HTML(text, mode)
Translate Unicode text to HTML
Parameters:
{String} text
Unicode text
mode
mode='x':&#xhhh;
Returns:
{String} HTML

<static> {String} CeL.net.web.to_query_string(query_Object)
Translate a native Object contains key/value pair set to a query string. TODO
Parameters:
{Object} query_Object
query Object.
Returns:
{String} query string
See:
jQuery.param

<static> CeL.net.web.toggle_display(element, type)
toggle/swap display and visibility. display:none or visibility:hidden. TODO: computed style
Parameters:
element
HTML element
{String|Number} type
show or hidden or set the status type: {Number} type: 0: hidden(→none), 1: show(→block), 2||undefined: switch, others: get status only with no change {String} type: set CSS: display type: none, '', block, inline, list-item. 其他恐造成 error?
Since:
2010/4/1 10:24:43 rewrite
Returns:
display status
Requires:
[_.get_element],[_.get_style]
See:
http://www.w3schools.com/CSS/pr_class_visibility.asp http://www.w3schools.com/css/pr_class_display.asp http://www.javaeye.com/topic/140784 通過element.style對象只能取得內聯的樣式,也就是說只能取得html標籤裡寫的屬性。

<static> CeL.net.web.Unicode_to_HTML(text, flags, ignore_tags)
Translate Unicode text to HTML code
Parameters:
text
Unicode text
flags
flags, f&1!=0: turn \t, (f&2)==0: \n→
, f==4: to quoted
ignore_tags
e.g., {object:{src:/^https?:\/\//},img:{src:/^https?:\/\//},a:{href:/^https?:\/\//}}
Returns:

<static> CeL.net.web.XML_node(tag, propertyO, insertBeforeO, innerObj, styleO)
create new HTML/XML node(element)
Parameters:
tag
tag name
propertyO
attributes object
insertBeforeO
object that we wnat to insert before it
innerObj
inner object(s)
styleO
style object
Since:
2006/9/6 20:29,11/12 22:13
Returns:
node object created
Requires:
set_attribute,add_node

Documentation generated by JsDoc Toolkit 2.4.0 on Fri Aug 05 2011 17:45:25 GMT+0800 (CST)