Search
10/30/2009
css - in the same line
http://chunghe.googlecode.com/svn/trunk/experiment/css.experiment/same.line.htm
<div class="meta">This article is public</div>
<div class="date">published on 2009.10.10</div>
<div class="navigate">
<a class="prev"></a>
<a class="next"></a>
</div>
meta{ float:left }
date{float:left}
now .navigate is the same line with meta and date.
.navigate{text-align:right} the all elements same line now
標籤: CSS
closure
YAHOO = {};
YAHOO.BasePanel = (function (id, config) {
var panel;
return {
build: function () {
if (panel) {
console.log('panel!');
}
panel = {'hello':'world'}
}
}
})();
YAHOO.BasePanel.build();
YAHOO.BasePanel.build();
10/26/2009
jslint - Require parens around immediate invocations
JavaScript: immediate function invocation syntax
ere is a JSLint option, one of The Good Parts in fact, that "[requires] parens around immediate invocations," meaning that the construction
(function () {
// ...
})();
would instead need to be written as
(function () {
// ...
}());
My question is this -- can anyone explain why this second form might be considered better? Is it more resilient? Less error-prone? What advantage does it have over the first form?
From Douglass Crockfords own PPT on the issue: (search for "require parens")
Makes more clearly the distinction between function values and the values of functions.
So, basically, he feels it makes more clear the distinction between function values, and the values of functions. So, it's an stylistic matter, not really a substantive difference in the code itself.
10/20/2009
10/18/2009
Nicholas C. Zakas — Scalable JavaScript Application Architecture
Nicholas C. Zakas — Scalable JavaScript Application Architecture
Sandbox Jobs
• Consistency
– Interface must be dependable
• Security
– Determine which parts of the framework a module
can access
• Communication
– Translate module requests into core actions
The application core manages modules
The application core tells a module when
it should initialize and when it should shutdown
Application Core Jobs
Manage module lifecycle
– Tell modules when to start and stop doing their job
• Enable inter-module communication
– Allow loose coupling between modules that are
related to one another
• General error handling
– Detect, trap, and report errors in the system
• Be extensible
– The first three jobs are not enough!
Ideally, only the application core has any idea what base library is being used
tight coupling
TimelineFilter = {
changeFilter: function (filter) {
Timeline.applyFilter(filter);
}
};
StatusPoster = {
postStatus: function (status) {
Timeline.post(status);
}
};
Timeline = {
applyFilter: function (filter) {
//implementation
},
post: function (status) {
//implementation
}
};
loose coupling
Core.register("timeline-filter", function (sandbox) {
return {
changeFilter: function (filter) {
sandbox.notify({
type: "timeline-filter-change",
data: filter
});
}
};
});
Core.register("status-poster", function (sandbox) {
return {
postStatus: function (statusText) {
sandbox.notify({
type: "new-status",
data: statusText
});
}
};
});
When modules are loosely coupled,
removing a module doesn't break the others
No direct access to another module = no breaking should the module disappear
10/15/2009
location
<protocol>//<host>[:<port>]/<pathname>[<hash>][<search>]
location.hostname和location.host有什么区别呢 - JavaScript & VBScript & DHTML 脚本技术讨论版
host 包含端口号,=host:port(当然是有端口号的时候);
hostname 不包含端口号;
10/13/2009
fireEvent
obj.fireEvent = function(el, E) {
if (document.createEvent) {
var ev = document.createEvent('Events');
ev.initEvent(E, true, true);
el.dispatchEvent(ev);
} else if (el.fireEvent) {
el.fireEvent('on'+E);
}
}
10/06/2009
Racklin's 阿土伯程式大觀園: Iterators in PHP5
Racklin's 阿土伯程式大觀園: Iterators in PHP5
上面是 php 中常見的 collections 或 datas 利用迴圈走訪每一筆資料的作法.. 它們看起來類似, 但是對於不同的資源(array, files, database) 又有些許的差異.
對於不同的物件及程式實作品, 你便需要知道每一個差異及輪巡的方式, 才能夠利用迴圈一一輪巡他們.
我們能夠提供一個標準的方式, 不論我們面對的是什麼資源(array, files, database, xml, ldap), 都只要使用相同且最直覺的方式輪巡嗎?
是的, 這就是 SPL 的 Iterator 的目的, 它不是解決您迴圈輪巡的效率問題, 它提供標準介面解決單一操作方式.
標籤: php
JavaScript: how to get private, privileged, public and static members (properties and methods) - Robert's talk
JavaScript inheritance - how and why
JavaScript namespacing - an alternative to JavaScript inheritance
JavaScript: how to get private, privileged, public and static members (properties and methods) - Robert's talk
JavaScript inheritance - experimenting with syntax alternatives and private variables
Explaining JavaScript scope and closures
td标签无法设置margin属性
td标签无法设置margin属性 - CSSLong
How do you set margin in a TD?
首先,我们需要知道的是:我们可以对表格table设置margin,而不能设置padding;对单元格td设置padding,而不能设置 margin。所以说,我们不能对单元格td设置margin属性来调整单元格与单元格之间的距离,但是我们可以使用一下方法来达到同样的效果。
1) 设置padding
就像刚才所说的那样,我们可以对单元格td设置padding属性来调整单元格之间的间隔
td{padding:5px 10px;}
2) 使用标签
我们可以在单元格td内添加标签,然后对
标签设置margin属性
p{margin:5px 10px;}这里写如文本内容
3) 对表格table设置border-spacing(IE不支持)
先让我们简单了解一下border-spacing属性。border-spacing:length;设置单元格td的边在横向和纵向上的间距。当您指定一个length值时,这个值将作用于横向和纵向上的间距;当您指定两个length值时,第一个将作用于横向间距,第二个值将作用于纵向间距。
table{border-spacing:5px 10px;}
標籤: CSS
石頭閒語:SPL:Use ArrayObject and ArrayIterator to Overload Operators of Array - 樂多日誌
SPL - Standard PHP Library
石頭閒語:SPL:Use ArrayObject and ArrayIterator to Overload Operators of Array - 樂多日誌
石頭閒語:為什麼還不升級PHP5 - 樂多日誌
舉例來說,ArrayAccess 中有4個方法, offsetGet, offsetSet, offsetExists, offsetUnset 。其中 offsetGet, offsetSet 按 C++ 觀點,其實就是 [] 運算子方法。 C++ 就直接寫成 operator[] 。 Ruby 寫成 [] 和 []= 。這一看就知道當我定義這方法後,便可像 primitive array 一樣用 [] 運算子存取內容。
我在 Google 上找到一個 ArrayAccess 的使用例子,結果作者全都寫成方法調用的形式 ($a->offsetGet(),...),而不是用 [] 運算子。似乎作者不知道可以這樣做, SPL 的優點完全沒有展現出來。
再說到 offsetExists, offsetUnset 。剛好在 magic methods 中也有一組 __isset, __unset 。問題就來了,為何 offsetExists, offsetUnset 不是 magic methods ;或者反過來說,為何要有 magic methods?
這不免令人感到混亂。
標籤: php