Showing posts with label 小楼听雨. Show all posts
Showing posts with label 小楼听雨. Show all posts
Thursday, October 30, 2008
JQuery 树插件介绍: jQuery SimpleTree Drag&Drop plugin
发现一个很好的树插件: jQuery SimpleTree Drag&Drop, 感觉很好, 代码质量不错, 支持拖拽, 风格清晰, 这里推荐一下. Demo看这里.
Wednesday, October 15, 2008
Tuesday, October 14, 2008
A ibatis code generator - iBATOR
iBATOR is a code generator for iBATIS. iBATOR will introspect a database table (or many tables) and will generate iBATIS artifacts that can be used to access the table(s). This abates some of the initial nuisance of setting up objects and configuration files to interact with database tables. iBATOR seeks to make a major impact on the large percentage of database operations that are simple CRUD (Create, Retrieve, Update, Delete). You will still need to hand code SQL and objects for custom queries, or stored procedures.
iBATOR will generate:
- SqlMap XML Files
- Java Classes to match the primary key and fields of the table(s)
- DAO Classes that use the above objects (optional)
I want to implement a ibatis code generator some day, But I find it "unfortunately".
Monday, October 13, 2008
Saturday, October 11, 2008
Get Computed Style Attribute
when a dom style has been setted more than one times in css file, the final style should be computed, such as:
css file:
#abc{
color: red;
}
div #abc{
color: red;
}
html file:
...
<div><span id='abc'>text in span...</span></div>
...
js code:
var spanEl = document.getElementById('abc');
var ret = document.defaultView.getComputedStyle( spanEl, null );
var color = ret.getPropertyValue("color");
so we can get the right style which appled to dom.
css file:
#abc{
color: red;
}
div #abc{
color: red;
}
html file:
...
<div><span id='abc'>text in span...</span></div>
...
js code:
var spanEl = document.getElementById('abc');
var ret = document.defaultView.getComputedStyle( spanEl, null );
var color = ret.getPropertyValue("color");
so we can get the right style which appled to dom.
Labels:
computed dom style,
getComputedStyle,
getPropertyValue,
小楼听雨
js简单继承的实现 - 网上做法修正篇
网上有些继承prototype实现上有bug例如:
function base() {this.member = ["dnnsun_Member",2,3,4];
}
var child=function(){
};
child.prototype=new base;
var c1 = new child();
var c2 = new child();
c1.member[1]=333;
alert(c2.member[1]);
结果是: 333
base中如果有集合, 对象属性, 这种简单继承导致的后果是所有的child的实例都共享了base的同一个member属性. 所以要尽量避免此种情况, 尽量在父类中只是定义方法, 变量改为传入的方式. 估计这也是为什么jquery, ext等框架不强制继承的子类必须subclass_instance instanceof superclass==true的原因.
Event driven web application - javascript event bus
I implemented a javascript event bus for asynchronized web application, and this article hasn't any relationship with Ajax and Dom events
Using Event bus benefit your web application development, such as:
I have two components in my web app, one is a tree, another is a grid list, when current highlighted tree node was been deleted, the grid list should load it's next sibling node's data.
normally, we could write in tree.js:
//delete current hightlighted tree node
...
GridList.clear();
GridList.load(next_sibling_node.name)
...
but GridList was defined in grid.js, so tree and grid moudle was high coupled.
in new asynchronized web application. we can write in tree.js:
//delete current hightlighted tree node
EventBus.publish("tree-node-deleted", node);
and write in grid.js:
EventBus.subscribe("tree-node-deleted", function(argObj){
GridList.clear();
GridList.load(argObj.name)
});
I think this is a good experence in web development.
Using Event bus benefit your web application development, such as:
- low coupling between moudles
- flexible event dispatcher
- partible bussiness logic
- consistent code style
I have two components in my web app, one is a tree, another is a grid list, when current highlighted tree node was been deleted, the grid list should load it's next sibling node's data.
normally, we could write in tree.js:
//delete current hightlighted tree node
...
GridList.clear();
GridList.load(next_sibling_node.name)
...
but GridList was defined in grid.js, so tree and grid moudle was high coupled.
in new asynchronized web application. we can write in tree.js:
//delete current hightlighted tree node
EventBus.publish("tree-node-deleted", node);
and write in grid.js:
EventBus.subscribe("tree-node-deleted", function(argObj){
GridList.clear();
GridList.load(argObj.name)
});
I think this is a good experence in web development.
Wednesday, October 08, 2008
利用event bus来降低前台业务代码耦合度, Event bus - javascript, js实现
/*
demo:
var observer = function(paramObj){
alert("bomb event comes!" + paramObj);
}
//add business event listener
EventBus.subscribe("tree-node-change",observer);
//remove business event listener
//EventBus.unsubscribe("tree-node-change",observer);
//publish business event
EventBus.publish("tree-node-change",{oldName:"abc", newName:"cdef", id: 123});
*/
/*
ReadMe:
Goal: Using business event dispatcher to reduce code couple between web moudle,
目标: 为了尽可能的减少模块之间业务逻辑的耦合度, 而开发了这个消息总线, 主要用于业务逻辑的事件传递
目标: 为了尽可能的减少模块之间业务逻辑的耦合度, 而开发了这个消息总线, 主要用于业务逻辑的事件传递
使用规范: 每个js模块尽可能通过事件去通信, 减少模块之间的直接调用和依赖(耦合)
*/
var EventBus = function(){
var observers={};
var publish=function(eventName, argObj){
var obs = observers[eventName];
if(!obs){
return;
}
for(var i=0;i<obs.length;i++){
obs[i](argObj);
}
}
var subscribe=function(eventName, observer){
var obs = observers[eventName];
if(!obs){
obs=[];
observers[eventName]=obs;
}
obs.push(observer);
}
var unsubscribe=function(eventName, observer){
var obs = observers[eventName];
if(!obs){
return;
}
for(var i=0;i<obs.length;i++){
if(obs[i]==observer){
obs.splice(i,1);
break;
}
}
}
var unsubscribeByObserver=function(observer){
for(var eventName in observers){
removeByName(eventName, observer);
}
}
return {
publish:publish,
subscribe:subscribe,
unsubscribe:unsubscribe,
subscribeByObserver:unsubscribeByObserver
}
}();
Labels:
decouple,
event bus,
javascript,
js,
js event bus,
xlty,
小楼听雨
Monday, October 06, 2008
[转] 小三的爱情扒皮必修课 - 画皮精彩影评
说是,小三必修课
其实,是所有情场中人的扒皮戏。
《画皮》是一个惊喜,有些是无心,有些是故意。
因为戏路太善良,我们总是忍不住笑场。
然而,面对,那些太刻意的真情告白……我们如果不笑,难道要跟着哭吗?
这场戏,需要些时间沉淀,然后,就有人像我们回忆八十年代的港片一样来回忆这张《画皮》。
不如把笑点抖一抖,顺便帮着大家扭曲一下逻辑。
这个故事告诉我们生活中的许多大道理。
故事的基本结构是这样的。
陈坤和甄子丹本来是战友,两个人都喜欢赵薇。赵薇选择了嫁给陈坤,甄子丹愤而远走。
画皮定律一:再好的朋友,抢一个心上人,也会翻脸。无论男女。
陈坤救了一个女人周迅回家。周迅其实是妖怪。
画皮定律二:如果一个有家的男人把一个单身女子带回家,这绝对是场冒险,不管这个姑娘会不会画皮。
赵薇怀疑陈坤喜欢周迅,进而发觉周迅来了之后,城里开始死人。认准周迅就是妖怪,
画皮定律三:如果一个女人发现自己的男人外面有了女人,那么到处跟人说那个女人是狐狸精,只能显得自己像个疯子,太小气。
但是没有人相信她。她写信喊来了甄子丹。
画皮定律四:还是去找自己的旧情人,是正路!(找旧情人来干什么,看你的兴趣)
周迅想嫁给陈坤,不是做妾,而是做夫人。
画皮定律五:如果一个小三,喜欢上了一个有妇之夫,又不像只是玩一玩就吃掉他,而是想要个名分,会搞得三个人都很凄惨。
甄子丹来了,降魔者孙丽也来了,孙丽看着甄子丹很有感觉,甄子丹对孙丽也有点感觉。
画皮定律六:男人终究是要变心的,不管他当初多么爱你,只不过是动手没动手的差别,而且,总是有更年轻的姑娘出现的!!
还有个蜥蜴精追随周迅而来,蜥蜴精爱着狐狸精周迅,周迅不喜欢他。
画皮定律七:讨厌长得不帅的男人,女人讨厌"长舌头"的男人,讨厌知道自己当年底细的男人,讨厌,吃的东西,跟自己口味不同的男人……之后数条,都是第一条的借口。
甄子丹表示自己相信赵薇,赵薇说甄子丹是个好人。
画皮定律八:如果一个人给你发了"好人卡",基本来说,这个人打算送死你去,吃定你一辈子了。不知道逃的,是傻瓜。
周迅想色诱陈坤,蜥蜴精吃醋,进攻陈坤,大闹府里。
画皮定律九:在两个女人之间摇摆的男人,比较吃香。在两个男人之间摇摆的女人,其实比较危险。女人斗心计,男人斗体力。
蜥蜴精又进攻赵薇,关键时刻,陈坤选择去保护赵薇。
画皮定律十:所有的男人,都会先考虑自己的老婆的,小三们的悲哀…… 其实,不是因为他更看重老婆,而是他的身份促使他必须先救自己的老婆,否则,会被人说,没有人味。
周迅终于明白,陈坤更在乎身为老婆的赵薇。
画皮定律十一:情人早晚会发现真相的,这个时候,怎么选择,能比较出一个人的智商。
于是周迅直接胁迫赵薇离开,逼赵薇服毒。
画皮定律十二:偷情的乐趣,就在于偷偷摸摸,有人争抢的感觉比较刺激,直接逼宫……注定是悲剧
…………正邪开始大决战!!
所谓,凡事,不能十三点。那就到此为止吧。
爱情这种事情,都不能仔细推敲,一推敲,就千疮百孔。
-- 爆音爆食 发布于:2008-09-23 22:37
其实,是所有情场中人的扒皮戏。
《画皮》是一个惊喜,有些是无心,有些是故意。
因为戏路太善良,我们总是忍不住笑场。
然而,面对,那些太刻意的真情告白……我们如果不笑,难道要跟着哭吗?
这场戏,需要些时间沉淀,然后,就有人像我们回忆八十年代的港片一样来回忆这张《画皮》。
不如把笑点抖一抖,顺便帮着大家扭曲一下逻辑。
这个故事告诉我们生活中的许多大道理。
故事的基本结构是这样的。
陈坤和甄子丹本来是战友,两个人都喜欢赵薇。赵薇选择了嫁给陈坤,甄子丹愤而远走。
画皮定律一:再好的朋友,抢一个心上人,也会翻脸。无论男女。
陈坤救了一个女人周迅回家。周迅其实是妖怪。
画皮定律二:如果一个有家的男人把一个单身女子带回家,这绝对是场冒险,不管这个姑娘会不会画皮。
赵薇怀疑陈坤喜欢周迅,进而发觉周迅来了之后,城里开始死人。认准周迅就是妖怪,
画皮定律三:如果一个女人发现自己的男人外面有了女人,那么到处跟人说那个女人是狐狸精,只能显得自己像个疯子,太小气。
但是没有人相信她。她写信喊来了甄子丹。
画皮定律四:还是去找自己的旧情人,是正路!(找旧情人来干什么,看你的兴趣)
周迅想嫁给陈坤,不是做妾,而是做夫人。
画皮定律五:如果一个小三,喜欢上了一个有妇之夫,又不像只是玩一玩就吃掉他,而是想要个名分,会搞得三个人都很凄惨。
甄子丹来了,降魔者孙丽也来了,孙丽看着甄子丹很有感觉,甄子丹对孙丽也有点感觉。
画皮定律六:男人终究是要变心的,不管他当初多么爱你,只不过是动手没动手的差别,而且,总是有更年轻的姑娘出现的!!
还有个蜥蜴精追随周迅而来,蜥蜴精爱着狐狸精周迅,周迅不喜欢他。
画皮定律七:讨厌长得不帅的男人,女人讨厌"长舌头"的男人,讨厌知道自己当年底细的男人,讨厌,吃的东西,跟自己口味不同的男人……之后数条,都是第一条的借口。
甄子丹表示自己相信赵薇,赵薇说甄子丹是个好人。
画皮定律八:如果一个人给你发了"好人卡",基本来说,这个人打算送死你去,吃定你一辈子了。不知道逃的,是傻瓜。
周迅想色诱陈坤,蜥蜴精吃醋,进攻陈坤,大闹府里。
画皮定律九:在两个女人之间摇摆的男人,比较吃香。在两个男人之间摇摆的女人,其实比较危险。女人斗心计,男人斗体力。
蜥蜴精又进攻赵薇,关键时刻,陈坤选择去保护赵薇。
画皮定律十:所有的男人,都会先考虑自己的老婆的,小三们的悲哀…… 其实,不是因为他更看重老婆,而是他的身份促使他必须先救自己的老婆,否则,会被人说,没有人味。
周迅终于明白,陈坤更在乎身为老婆的赵薇。
画皮定律十一:情人早晚会发现真相的,这个时候,怎么选择,能比较出一个人的智商。
于是周迅直接胁迫赵薇离开,逼赵薇服毒。
画皮定律十二:偷情的乐趣,就在于偷偷摸摸,有人争抢的感觉比较刺激,直接逼宫……注定是悲剧
…………正邪开始大决战!!
所谓,凡事,不能十三点。那就到此为止吧。
爱情这种事情,都不能仔细推敲,一推敲,就千疮百孔。
-- 爆音爆食 发布于:2008-09-23 22:37
Saturday, October 04, 2008
js简单继承的实现, 改进篇
前文表述: js简单继承的实现
前文问题:alert(child instanceof base); 打印false, 此处并没有实现真正的继承
改进:
function base() {
this.member = "dnnsun_Member";
this.test=function(){
window.alert('in base');
}
}
base.prototype.test= function() {
window.alert("base member "+this.member);
}
function extend(child, b) {
b.call(child);
child.prototype=new b;
}
var childclass=function(){
this.test=function(){
window.alert("in child");
}
};
extend(childclass, base);
child = new childclass;
window.alert(child.member);
window.alert(child.test);
child.test();
window.alert(child instanceof base);
不能没有doctype
* 有他的好处, 我这里放下不表, 今天就说说没有他时, 在开发中遇到的问题
* 在不同的浏览器下网页莫名其妙的布局问题
* document.body与document.documentElement谁的属性是准的?
* scrollLeft
* Right
* Top
* Bottom
Thursday, October 02, 2008
Friday, September 19, 2008
Monday, September 15, 2008
Thursday, August 14, 2008
Wednesday, July 30, 2008
备份, 同步svn版本库
初始化本地一个空的svn库: svnadmin create /home/lg/repo
从远程库初始化0版本: svnsync init file:///home/lg/repo remote_svn_repo
从远程库同步: svnsync sync file:///home/lg/repo
顺便看看svn的命令, 别整天被UI给宠坏了, 命令行也是很好用的, ^_^
注意:初始化过程中会有提示你要创建hook, 到/home/lg/repo下的hooks下创建相应的空文件改名为.sh(.bat)加入可执行权限即可
Sunday, July 27, 2008
Subscribe to:
Posts (Atom)
