杂记

今天应网友的要求,把AJAX留言板加了留言时间间隔设置,并更新了样式,与官方版本一致。下载链接:http://www.hopesoft.org/bbs/viewthread.php?tid=228&extra=page%3D1

不经意间才发现,已经好久没有更新网站的程序了。留言板上次更新还是去年的四月份。

想想正是去年母亲来北京看病的时间,去年发生了太多的事,也成熟了许多,代价是巨大的,现实是残酷的。

去年后半年换了一份工作,视野进一步开阔,也做了一些复杂的JS应用,相对来说,对性能的要求比较高,因访问量比较大。

1.传统的AJAX应用:
用户访问网页→JS脚本访问服务器端动态程序→返回结果→JS脚本更新网页内容

2.优化后的AJAX应用:
用户访问网页→JS脚本访问服务器端静态数据→返回结果→JS脚本更新网页内容

主要区别在于服务器端数据的提供方式上,变动态程序为生成静态数据,比如JSON格式的数据。在载入数据及载入后的触发更新上,需要一些技巧。

回头我写个简单的Demo详细说明一下,希望抛砖引玉,一起讨论讨论。

最近开始做Java项目,刚上手,今年年底左右,可能就得从.Net平台转到Java平台开发了。最近一年的时间,掌握的东西比较杂,确实需要静下心来梳理一下。

 

利用Ajax.Net读写Cookie

Ajax.Net是Michael Schwarz写的一个.Net的AJAX框架,使用非常方便。在ASP.Net AJAX出现以前,一直是.Net平台开发AJAX应用的首选。

这两天在用Ajax.Net开发一个小的Ajax应用,其中要在Ajax Method中读写Cookie。利用Request.Cookies[“xxx”]遇到了问题。

后来经过Google,找到解决方案,需要使用HttpContext.Current来读写Cookie。

比如读取:
string CookieName=”demo”;
HttpCookie Cookie =  HttpContext.Current.Request.Cookies[CookieName];

写:
string CookieName=”demo”;
string Value=”ok”
HttpCookie Cookie = new HttpCookie(CookieName, Value);
HttpContext.Current.Response.Cookies.Add(Cookie);

参考链接:cookie info within ajax method

AJAX案例:gotAPI.com

gotAPI.com,收集了我们在编程、设计中常用到的语言、标准、常用框架、程序集的API,包括html、javascript、CSS、PHP、Java、数据库等等,甚至包括了prototype.js,呵呵。

共有两种方式来查找这些API:

1.http://www.goapi.com

顶部是API的分类,默认有HTML、JavaScript Dom、CSS、PHP,可以添加更多;左侧是API列表,右侧是具体内容。

2.start.gotapi.com
可以对平时经常用到的API进行快速搜索点,搜索时有下拉提示,会自动根据你的输入提示匹配结果。

有保存历史记录功能,查询过的词会出现在页面左上角。

目前支持HTML、CSS、JavaScript/HTML DOM、XML、Druapl CMS、PHP、Ruby/Rails、Python、Perl、Marcomedia、C/C++,Libraries、Databases、Java,且将来会支持更多的API。

gotapi.com

Dojo之路:如何利用Dojo实现Drag and Drop效果

  如今各种使用AJAX技术的站点都实现了Drag and Drop(拖动)效果,利用Dojo框架也可以很方便的实现,相比较其它框架,代码更少,且对浏览器的兼容性支持比较好。

  先看一下效果,以下是51AJAX.com站点首页的效果,其中各个模块是可以任意拖动的:

  

  如何来实现呢?以下是具体步骤。为简单起见,做了一个Drag and Drop的Demo页面:

  

  以下是具体步骤:

  1.html部分
  要实现拖动,首先要有容器,其次要有可拖动的元素。在这里我们设置了三个Div作为容器,ID分别是container1,container2,container3,每个容器中各放置了一个Div作为可拖动元素,它们的class是divdrag。

  2.javascript代码  
  首先在头部加入对dojo.js的引用,然后根据获取class为divdrag的元素,把它们注册为dojo.dnd.HtmlDragSource对象,再将container1,container2,container3注册为三个容器,且指定容器中的可拖动元素可以被拖动到的容器,以上事件封装成一个函数,增加至window.onload事件中。
  

 //引用以下两个dojo包
 dojo.require(“dojo.style”);
 dojo.require(“dojo.dnd.*”);
 
 function init(){
  //利用classname取到元素列表,将其注册为dojo.dnd.HtmlDragSour
  var arr=dojo.html.getElementsByClass(‘divdrag’)
  for(var i=0;i

Dojo推出0.4.0

今天在坛子里,看到有朋友用到了Dojo 0.4.0,遂上Dojo的官网看了下,果然已经推出了0.4.0。

Available for download (Ajax build, others) The 0.4 release contains many exciting new features, a whopping 529 bugs closed, and the initial release of the long-awaited documentation tool, with inline API documentation that will continue to improve with follow-on releases. These improvements will make Dojo appealing to entirely new audiences and will bring Ajax applications to a new level of acceptance as a first-class user environment. Some of the highlights include:

1.dojo.a11y: the foundation for accessibility (a11y), implemented in some of Dojo’s widgets in 0.4 with more to follow in 0.5. Dojo strives to provide keyboard function as well as integration with high-contrast mode and screen readers for the visually impaired.

2.dojo.charting: A charting engine to implement a variety of chart types using vector graphics

3.dojo.gfx: a 2D vector graphics API which renders natively to browsers as SVG or VML

4.dojo.i18n: a follow on to the translation support in 0.3.1, there is now build support for collecting localized resources in a single file as well as support for localized date and time formatting. More formatting types and more localization to come in 0.5.

5.dojo.lfx: major improvements, such as chainable animations

6.dojo.namespaces: support for extensible widget namespaces and an automatic widget manifest loading feature.

7.dojo.widget: new widgets like Clock, FilteringTable, ProgressBar, plus enhancements to Editor2 and the AccordionContainer. Also localization of some widgets, such as DatePicker.

8.AOL’s contribution of a linker for Javascript, not yet integrated into the build.

可以看出修复了不少Bug,增加了很多新的器件,及新的模块,又得学习了,不知稳定性如何,还有待检测。要是实际开发,最好用低一些的版本,因毕竟经过时间检验,bug比较少。

AJAX架构之Dojo篇

作者:hopesoft
出处:http://www.hopesoft.org

一、前言
自去年开始,AJAX一下成了关注的技术热点,各种AJAX框架迅速的发展了起来,其中又分为客户端AJAX架构,服务器端AJAX架构等,其中DojoToolkit做为一个优秀的客户端AJAX架构,被越来越多的人所关注,学习。自去年开始,AJAX一下成了关注的技术热点,各种AJAX框架迅速的发展了起来,其中又分为客户端AJAX架构,服务器端AJAX架构等,其中DojoToolkit做为一个优秀的客户端AJAX架构,被越来越多的人所关注,学习。

二、Dojo简介

作为早期的开源AJAX架构之一,Dojo开始于2004年9月,网址是 http://www.dojotoolkit.org,由JotSpot的Alex Russell所领导。

Dojo是一个开源的JavaScript工具包,本身预置了很多模块,可以实现完整的轻量级窗口组件及很多功能。Dojo的包加载机制(Package System)可以实现动态加载所需模块,而且用户可以编写自己的Dojo扩展模块,有很好的灵活性。

继续阅读