| Tony Huang's profileSouline PLUS planBlogListsNetwork | Help |
|
22 September JavaScript小技巧 : sprintffunction sprintf(fmt, params)
{
var strOut = fmt;
for(var i in params)
{
var strTag = "{" + i + "}";
while(strOut.indexOf(strTag) >= 0)
{
strOut = strOut.replace(strTag, params[i]);
}
}
return strOut;
}
//Usage:
var strOut = sprintf("Hello, {0}", new Array("Tony Huang"));
var strOut = sprintf("Hello, {Name}", {Name : "Tony Huang"}); 21 September JavaScript小技巧 : 自动选择镜像由于中国当前的网络格局,对于大型网站来说,为了保证大部分用户能够快速地上网,必须要在不同的地方设置镜像,然而当用户面对如此大量的镜像的时候,很可能会茫然不知。所以如果系统能够根据访问的速度,自动得选择镜像,那就非常好了。
罗嗦的代码就不写了,写重点吧:
var arrMirrors = new Array( http://ctc.cuzone.org, http://edu.cuzone.org);
var curChoice = arrMirrors[0];
var xmlHttpObjects = new Array();
function AbortAll() //When one mirror return, abort all request
{
for(var i = 0; i < xmlHttpObjects.length; i++)
xmlHttpObjects.abort();
}
function OnReadyStateChange(id)
{
if(xmlHttpObjects[id].readyState == 4)
{
AbortAll();
curChoice = arrMirrow[id];
}
}
for(var i = 0; i < arrMirrors.length; i++)
{
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.onreadystatechange = eval("function() { OnReadyStateChange(" + i + "); }");
xmlhttp.open("GET", arrMirrors[i], true);
xmlhttp.send("");
xmlHttpObjects.push(xmlhttp);
} 19 September 发现自己有强迫症我似乎得了强迫症……
我现在几乎是在每一次出门的时候都会怀疑自己是否关好了煤气、窗户、是否锁好了门……
今天在报纸上看到才发现原来这就是强迫症
虽然我原来不知道它的名字,不过我自我的意识还是不错的,清醒地意识到这样会出问题,及早发现。
现在我每次出门的时候,先锁门,然后告诉自己“我在门口拿出过钥匙了,我已经锁过门了”,情况正在改善:)
大家不用担心。
留此文以志
17 September Microsoft Vista RC1 InstalledI've just installed Micrsofot Vista RC1, and try to install softwares that I was using.
I found some interesting things here:
1) Internet Explorer 7+
This beautiful browser made by Microsoft, integrated with Vista, with Tabed browsing function, supporting rss subscribing, integrated search box, is now call Internet Explorer 7+. Version: 7.0.5600.16384
2) "Windows *" in the Startup Menu
Windows Ultimate Extras, Windows Media Center, Windows Media Player, Windows Photo Gallery, Windows Live Messenger, Windows Meeting Space, Windows DVD Maker, ...
3) Strange Chinese Fonts
Windows no longer use SimSun as the default font of Chinese. It's a font that looks like SimMing or YouYuan now. However, it look beautiful :)
4) Switching among Windows
It's really an excellent change! If you move your mouse on the button on the taskbar, it will show the zoomed live picture of the window, and so dose the Alt-Tab window.
5) Sidebar and gadgets
Sidebar is quite a cool function, but I have to say Microsoft povides too few gadgets...
6) Software compability
Well, Vista will be a great and important milestone in the roadmap of Windows. It changes a lot, even more than from Windows 3.2 to Windows 95. A lot applications are not compable with Vista now. I have to download Pc-Cillin Internet Security 14 trail edition, cos. Synmtec AntiVirus Coorption doesn't support Vista and McAfee will cause blue screen...
I have installed Visual Studio 2005 and Sql Server 2005 Express Edition, and found they are working well! And also the develop edition of our website LifeDig cooperates well with the completely new operating system and the new browser.
And I've found Microsoft .Net Framework 3.0 in Vista!
---------------------Command Line Quotes Below-------------------------------------
C:\Windows\Microsoft.NET\Framework>dir/b/ad
v1.0.3705 v1.1.4322 v2.0.50727 v3.0 VJSharp -------------------------------------------------------------------------------------------
p.s. Microsoft removed Run menu from the start menu, I have to click "Windows Icon"->All Programs->Accessories->Command Prompt to start "cmd.exe" ... 09 September JavaScript动态加载现在的ajax应用越来越丰富,功能越来越强大,脚本文件的大小也……
所以,当用户浏览网站的时候,将会有一个非常长的等待时间……
废话不说啦,开工:
// mod_demo.js
mod_demo.OnInitialize = function() {
alert("hello");
}
// mod_core.js var mod_modlist = new Array();var mod_demo = {
Name : "Demo module",
File: "mod_demo.js",
Loaded: false
}
mod_modlist.push(mod_demo);
function GetXmlHttpRequest()
{
var xmlhttp;
try
{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e)
{
xmlhttp = new XMLHttpRequest();
}
}
function LoadFileSync(path)
{
var xmlhttp = GetXmlHttpRequest();
xmlhttp.open("GET", path, false);
xmlhttp.send("");
var strContent = xmlhttp.responseText;
xmlhttp.abort();
return strContent;
}
function LoadModule(obj_mod)
{
if(!obj_mod.Loaded)
{
eval(LoadFileSync(obj_mod.File));
obj_mod.OnInitialize(); obj_mod.Loaded = true; }
}
function LoadModules()
{
for(var i = 0; i < mod_modlist.length; i++)
LoadModule(mod_modlist[i]);
}
比较简陋:) 08 September My god! I'm "one" man!近日多思考,发现我根本就不认识自己
我太复杂了,我太矛盾了
我常对朋友说:女人的事情看开点,此出不开花,自有开花处。
而我自己却从来都放不开,放不下。
我常对朋友说:我很花心的,她不理我,我还可以找xxx
实际上,所谓的xxx或许我从来都没有考虑过 |
|
|