??xml version="1.0" encoding="utf-8" standalone="yes"?>av亚洲在线观看,www.综合,91日韩一区二区三区 http://www.aygfsteel.com/hunteva/category/26501.html专注于Java EE企业U开?/description>zh-cn Mon, 05 Nov 2007 20:46:31 GMT Mon, 05 Nov 2007 20:46:31 GMT 60 Adobe AIR 初探 http://www.aygfsteel.com/hunteva/archive/2007/11/05/adobe_air.htmlKerwin Weng Kerwin Weng Mon, 05 Nov 2007 12:39:00 GMT http://www.aygfsteel.com/hunteva/archive/2007/11/05/adobe_air.html http://www.aygfsteel.com/hunteva/comments/158351.html http://www.aygfsteel.com/hunteva/archive/2007/11/05/adobe_air.html#Feedback 0 http://www.aygfsteel.com/hunteva/comments/commentRss/158351.html http://www.aygfsteel.com/hunteva/services/trackbacks/158351.html 好像国内对Adobe的新产品AIR反应q不?我个用了下觉得其实用处还是很大的,于是我就抛砖引玉写一相关介l文章吧
AIR其实是一套框架和一个VM,它允许用hJavascript,HTML,CSS集成到统一的客L(fng),在用h面运?避免了浏览器差异,q且实现了跨q_的通用?同时又对Javascript功能q行了很多扩?比如d本地盘文g,做跨域的q程讉K,使用多媒体文件等{?怿是flash的底层在支持),相对于两q前的Flex,AIR在RIA领域无疑又是一个跨?惌一?/span>以后我们可以用JS+HTML+CSS来写Zhttp的远E且防火墙安全的C/S应用?q是蛮爽?br />
Demo在这?http://labs.adobe.com/showcase/air/?promoid=BJXTF
用JS来写应用的文档在q里:http://livedocs.adobe.com/labs/air/1/devappshtml/
Adobe AIR出新版SDK?Z意料的是很多之前的Demo不能跑了,?x)?parsing disallowed",原因是adobe换用了新的安全框?止掉了Javascript中某些可能对其框架做出安全威胁的API,比如说JSON的命?-eval
Adobe的官方解释是在AIR2止掉了cMevalq种动态代码加载技术在其Application sandbox中的q行,解决办法是把你有eval的应用移到Browse sandbox中执?所谓的Browse sandbox意思是你的应用主页面是通过application.xml中配|的栚w面来用iframe引入?在iframe引入的页面中你就可以做eval,而把其他如跨域查询等AIR提供的高UAPI操作攑ֈ栚w面中d,然后通过一个parent/childSandboxBridge来做互相引用和传递数据的桥梁, 但是同时你在iframe中的js也不能直接用AIR所提供的一些高UAPI,比如air.trace(). 原文的解释在q里
,Adobe甚至q写了一?a target="_blank">文章来鼓吹这U方式其实更W合设计模式--栚w面负责数据传?iframe面负责业务逻辑.但是无论如何q篇文章作ؓ(f)Browse sandbox的入门来讲还是很值得l读?br />
于是l合自己当前的实际需?我写了一个批量查询airasia.com机票的小工具,因ؓ(f)airasia从来都是打广告说从多久到多久,从那里飞到那里才几块MYR?/span>! 是q个"?字相当关?.....直接造成每次我去查的时候发现因?已经快满??所以h(hun)格和qx的一?甚至更高,听同事说他们都是先一天一天去查看哪天便宜p快预?太辛苦了?那我要查2007-11-05?008-01-31日的机票要花多少旉?而且不查到最后一天还不知道是不是最便宜?嘲笑他们原始之后我就军_自己写个工具来查
所以我写的W一个AIR应用是q个AirAsiaTicketsSearch,可以扚w查询某个旉D去和某个时间段回的所有机?q且把机h(hun)格用jQuery.tablesortl排序出?q且用jQuery.tablesort.page做了分页(说句题外?jQuery的tablesort实很强?但是在排?1,280.00 CNY"q种数据的时候还是有问题).另外开发环境值得一?无论是eclipse+aptana或者aptana standalone都一L(fng),aptana是一个Eclipse的RCP,关键是aptana真的是很好用的工?目前不仅支持AIR,而且q支持开发Apple iPhone的应?只是专业版要收费.....
后面l出截图, l果发现昨天q有295.99的机?C今天涨?49.99?_-!
]]> 关于Javascript闭包学习(fn) http://www.aygfsteel.com/hunteva/archive/2007/10/18/153854.htmlKerwin Weng Kerwin Weng Thu, 18 Oct 2007 05:28:00 GMT http://www.aygfsteel.com/hunteva/archive/2007/10/18/153854.html http://www.aygfsteel.com/hunteva/comments/153854.html http://www.aygfsteel.com/hunteva/archive/2007/10/18/153854.html#Feedback 14 http://www.aygfsteel.com/hunteva/comments/commentRss/153854.html http://www.aygfsteel.com/hunteva/services/trackbacks/153854.html
l果今天l于看到一?em>Morris Johns 的文?用了不到5分钟把闭包是什么讲的清清楚?比如文章中有一句话:
In JavaScript, if you use the function
keyword inside another function, you are creating a closure.
妈的,q有比这更简单的解释?Z么那些国内所谓的牛h是写不U^实的?非要浪费自己和别h的时间讲一堆貌似Q云的定义,我觉得他们真的该思考下自己写技术文章的目的,是ؓ(f)了在传递知?q是在满q虚荣,如果是后?直接在Tag中注?自慰?,免得费大家的时?
在后面的文章?作者列举了很多生动的例?每个例子后面的解释都非常q_,没有MZ表现自己能力的华丽辞?通过他的例子,我很快理解的闭包的特?可以用来做什?前后不到30分钟,回想我几个月前光是找合适的解释找了近一个小?
当我寚w包的特点已经谙熟于心?作者再开始讲一些抽象的定义,让h感觉没有一炚w?如作者自q?
If everything seems completely unclear then
the best thing to do is to play with the examples. Reading an explanation is
much harder than understanding examples.
My explanations of closures and stack-frames etc are not technically correct
- they are gross simplifications intended to help understanding. Once the
basic idea is grokked, you can pick up the details later.
最后给出那文章的地址,怿不懂闭包的h也能像我一样很快就理解,同时也希望大家看完后别忘了别t实实写技术文章的态度
http://www.javascriptkit.com/javatutors/closures.shtml
]]> 用Javascript模拟Java的Set http://www.aygfsteel.com/hunteva/archive/2007/10/12/152282.htmlKerwin Weng Kerwin Weng Fri, 12 Oct 2007 03:46:00 GMT http://www.aygfsteel.com/hunteva/archive/2007/10/12/152282.html http://www.aygfsteel.com/hunteva/comments/152282.html http://www.aygfsteel.com/hunteva/archive/2007/10/12/152282.html#Feedback 2 http://www.aygfsteel.com/hunteva/comments/commentRss/152282.html http://www.aygfsteel.com/hunteva/services/trackbacks/152282.html
目前惛_可以实现的方?
add(o);
addAll(array)
contain(o);
getQint);
getAll();
sort(comparator); //传进ȝ是一个fn,q没有写例子....
size();
remove();
reverse();
基本数据l构是两个数l?一个是index数组,数组下标q箋,用来存放W二个数l的下标,另一个是存放对象的数l?不连l?下标是对象的id或者对象中其他M可以转换成唯一Integer的Field(Set也要求放q去的对象必要有hashCode?不然没法区别W一个和W二?
实现的API:
function Collection(){
this.chain=new Array();
this.table=new Array();
}
Collection.prototype.get=function(i){
return this.table[this.chain[i]];
}
Collection.prototype.add=function(o){
this.table[o.id]=o;
this.chain.push(o.id);
}
Collection.prototype.addAll=function(array){
for(var _i=0;_i<array.length;_i++){
this.add(array[_i]);
}
}
Collection.prototype.contain=function(o){
if(this.table[o.id]){
return true;
}else{
return false;
}
}
Collection.prototype.getAll=function(){
tempList=new Array();
for(var _i=0;_i<this.chain.length;_i++){
tempList.push(this.table[this.chain[_i]]);
}
return tempList;
}
Collection.prototype.sort=function(comparator){
this.chain.sort(comparator);
}
Collection.prototype.remove=function(o){
var _var = this.chain;
for(var _i=0;i<this.chain.length;i++){
if(this.table[this.chain[_i]].id==o.id){
this.table[this.chain[_i]]=null;
this.chain.splice(_i,1);
return;
}
}
}
Collection.prototype.size=function(){
return this.chain.length;
}
Collection.prototype.reverse=function(){
this.chain.reverse();
}
目前q有一个addAllҎ(gu)也是暂时没有惛_有什么不用遍历的好的实现
前同事提供了一U完全和Set一L(fng)实现,效率满高
function Map(){
this.obj = {};
this.count = 0;
}
Map.prototype.put = function(key, value){
var oldValue = this.obj[key];
if(oldValue == undefined){
this.count++;
}
this.obj[key] = value;
return oldValue;
}
Map.prototype.get = function(key){
return this.obj[key];
}
Map.prototype.remove = function(key){
var oldValue = this.obj[key];
if(oldValue != undefined){
this.count--;
delete this.obj[key];
}
return oldValue;
}
Map.prototype.size = function(){
return this.count;
}
function Set(getKey){
this.map = new Map();
this.getKey = getKey;
}
Set.prototype.add = function(value){
var key = this.getKey(value);
this.map.put(key, value);
}
Set.prototype.remove = function(value){
var key = this.getKey(value);
this.map.remove(key);
}
Set.protorype.getAll=function(){
tempArray=new Array();
for(var i in this.obj){
tempArray.push(i);
}
return tempArray;
}
Set.prototype.size = function(){
return this.map.size();
}
q有一个朋友的实现和我最初的差不?但是removeҎ(gu)相当有创?用正则表辑ּ来删?br />
Collection.prototype.remove=function(o){
var _var = this.chain;
this.table[o.id]=null;
var re = new RegExp("(^["+o.id+"]$)|(^["+o.id+"][,])|([,]["+o.id+"]$)","g");
var s = "["+this.chain.toString().replace(re,"").replace(","+o.id+",",",")+"]";
this.chain=eval(s)
}
有h回复说需要添加做验证,我觉得不必了,如果d的值和之前的一样就直接替换好了,如果希望不被replace,直接在添加新对象之前用contain判断一ơ就可以?毕竟在我的实C已不是完全在模拟Set?目前更們于设计一个更高效和强大的集合c?br />
]]>
վ֩ģ壺
˳ |
|
|
|
|
ԭ |
Ϸ |
|
ű |
|
|
¡ |
|
|
ȫ |
ൺ |
|
鱦 |
Դ |
Ͷ |
|
|
³ƶ |
|
־ |
ӳ |
ȫ |
|
ʹ |
½ |
崲 |
Ϻ |
|
ͩ |
ɽ |
|
Ʊ |
|
|
|
ɽ |