宁毅网络工作室

宁毅网络工作室提供专业的网站设计维护制作服务

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  18 随笔 :: 93 文章 :: 28 评论 :: 0 Trackbacks
/*+--------------------------------------------------+
  |文 件 名:CommonFuncs.js                           |
  |创 建 人:Simon.Ye                                 |
  |创建时间:2006-06-18                               |
  |说  明:JavaScript通用函数库                     |
  +--------------------------------------------------+*/
 
/*+--------------------------------------------------+
  |函 数 名:setHomePage(obj, uri)                    |
  |传入参数:obj(Object类型)                          |
  |         uri(String类型)                          |
  |返 回 值:无                                       |
  |创 建 人:Simon.Ye                                 |
  |创建时间:2006-06-18                               |
  |说  明:实现"设为首页"功能                       |
  +--------------------------------------------------+*/
function setHomePage(obj, uri)
{
    obj.style.behavior='url(#default#homepage)';
    obj.setHomePage(uri);
}
/*+--------------------------------------------------+
  |函 数 名:addFavorite(uri, siteName)               |
  |传入参数:uri(String类型)                          |
  |         siteName(String类型)                     |
  |返 回 值:无                                       |
  |创 建 人:Simon.Ye                                 |
  |创建时间:2006-06-18                               |
  |说  明:实现"加入收藏"功能                       |
  +--------------------------------------------------+*/
function addFavorite(uri, siteName)
{
    window.external.AddFavorite(uri, siteName);
}
/*+--------------------------------------------------+
  |函 数 名:OpenWin(uri, w, h)                       |
  |传入参数:uri(String类型)                          |
  |         w(Int类型)                               |
  |         h(Int类型)                               |
  |返 回 值:无                                       |
  |创 建 人:Simon.Ye                                 |
  |创建时间:2006-06-18                               |
  |说  明:打开新窗口                               |
  +--------------------------------------------------+*/
function OpenWin(uri, w, h)
{
    var X = (screen.availWidth - w) / 2;
    X = parseInt(X, 10);
    var Y = (screen.availHeight - h) / 2;
    Y = parseInt(Y, 10);
    var newwin = window.open(uri, "newWin", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,top=0,left=0,width=" + w + ",height=" + h);
    newwin.focus();
    newwin.moveTo(X, Y);
}
/*+--------------------------------------------------+
  |函 数 名:openDialog(sURL, sArgs, sWidth, sHeight) |
  |传入参数:sURL(String类型)                         |
  |         sArgs(Mixed类型)                         |
  |         sWidth(Int类型)                          |
  |         sHeight(Int类型)                         |
  |返 回 值:无                                       |
  |创 建 人:Simon.Ye                                 |
  |创建时间:2006-06-18                               |
  |说  明:打开模式对话框                           |
  +--------------------------------------------------+*/
function openDialog(sURL, sArgs, sWidth, sHeight)
{
window.showModalDialog(sURL, sArgs, "dialogWidth:" + sWidth + "px;dialogHeight:" + sHeight + "px;Resizable:0;help:0;status:no;scroll:yes;center:yes;edge:Raised;");
}
/*+--------------------------------------------------+
  |函 数 名:objSelected(obj, str)                    |
  |传入参数:obj(Object类型)                          |
  |         str(String类型)                          |
  |返 回 值:无                                       |
  |创 建 人:Simon.Ye                                 |
  |创建时间:2006-06-18                               |
  |说  明:根据给定的值选定select对象的项           |
  +--------------------------------------------------+*/
function objSelected(obj, str)
{
    for(var i = 0; i < obj.options.length; i++)
    {
        if(obj.options.value == str)
        {
            obj.options.selected = true;
            break;
        }
    }
}
/*+--------------------------------------------------+
  |函 数 名:objChecked(obj, str)                     |
  |传入参数:obj(Object类型)                          |
  |         str(String类型)                          |
  |返 回 值:无                                       |
  |创 建 人:Simon.Ye                                 |
  |创建时间:2006-06-18                               |
  |说  明:根据给定的值选定radio对象的项            |
  +--------------------------------------------------+*/
function objChecked(obj, str)
{
    for(var i = 0; i < obj.length; i++)
    {
        if(obj.value == str)
        {
            obj.checked = true;
        }
        else
        {
            obj.checked = false;
        }
    }
}
/*+--------------------------------------------------+
  |函 数 名:resizeImage(obj, MaxW, MaxH)             |
  |传入参数:obj(Object类型)                          |
  |         MaxW(Int类型)                            |
  |         MaxH(Int类型)                            |
  |返 回 值:无                                       |
  |创 建 人:Simon.Ye                                 |
  |创建时间:2006-06-18                               |
  |说  明:缩放图片                                 |
  +--------------------------------------------------+*/
function resizeImage(obj, MaxW, MaxH)
{
    var imageObject;
  
    if (obj != null) imageObject = obj;
  
    var state = imageObject.readyState;
    var oldImage = new Image();
    oldImage.src = imageObject.src;
    var dW = oldImage.width;
    var dH = oldImage.height;
  
    if(dW>MaxW || dH>MaxH)
    {
        a = dW/MaxW;
        b=dH/MaxH;
       
        if(b > a) a = b;
       
        dW = dW / a;
        dH = dH / a;
    }
  
    if(dW > 0 && dH > 0) imageObject.width = dW;
  
    imageObject.Height = dH;
  
    if(state != 'complete' || imageObject.width > MaxW || imageObject.Height > MaxH)
    {
        setTimeout("ResizeImage(null, " + MaxW + ", " + MaxH + ")", 40);
    }
}
/*+--------------------------------------------------+
  |函 数 名:in_array(str, arr)                       |
  |传入参数:str(String类型)                          |
  |         arr(Array类型)                           |
  |返 回 值:(Bool)                                   |
  |创 建 人:Simon.Ye                                 |
  |创建时间:2006-06-18                               |
  |说  明:PHP的in_array函数的JavaScript实现        |
  +--------------------------------------------------+*/
function in_array(str, arr)
{
    for(var i = 0; i < arr.length; i++)
    {
        if(str == arr)
        {
            return true;
        }
       
        continue;
    }
  
    return false;
}
/*+--------------------------------------------------+
  |函 数 名:preg_match(regStr, str)                  |
  |传入参数:regStr(Object类型)                       |
  |         str(String类型)                          |
  |返 回 值:(Bool)                                   |
  |创 建 人:Simon.Ye                                 |
  |创建时间:2006-06-18                               |
  |说  明:PHP的preg_match函数的JavaScript实现      |
  +--------------------------------------------------+*/
function preg_match(regStr, str)
{
    var objRegExp = new RegExp(regStr);
    return objRegExp.test(str);
}

/*+--------------------------------------------------+
  |函 数 名:isEmail(email)                           |
  |传入参数:email(String类型)                        |
  |返 回 值:(Bool)                                   |
  |创 建 人:Simon.Ye                                 |
  |创建时间:2006-06-18                               |
  |说  明:Email检测函数                            |
  +--------------------------------------------------+*/
function isEmail(email)
{
    return preg_match(/^([\w\-\.]+)(@)([\w\-\.]+)(\.)([\w\-\.]+)$/, email);
}
/*+--------------------------------------------------+
  |函 数 名:isInt(str)                               |
  |传入参数:str(String类型)                          |
  |返 回 值:(Bool)                                   |
  |创 建 人:Simon.Ye                                 |
  |创建时间:2006-06-18                               |
  |说  明:判断是否有符号整数                       |
  +--------------------------------------------------+*/
function isInt(str)
{
    return preg_match(/^[\-|\+]?\d+$/, str);
}
/*+--------------------------------------------------+
  |函 数 名:isUInt(str)                              |
  |传入参数:str(String类型)                          |
  |返 回 值:(Bool)                                   |
  |创 建 人:Simon.Ye                                 |
  |创建时间:2006-06-18                               |
  |说  明:判断是否无符号整数                       |
  +--------------------------------------------------+*/
function isUInt(str)
{
    return preg_match(/^\d+$/, str);
}
/*+--------------------------------------------------+
  |函 数 名:isFloat(str)                             |
  |传入参数:str(String类型)                          |
  |返 回 值:(Bool)                                   |
  |创 建 人:Simon.Ye                                 |
  |创建时间:2006-06-18                               |
  |说  明:判断是否有符号小数                       |
  +--------------------------------------------------+*/
function isFloat(str)
{
    return preg_match(/^[\-|\+]?\d+\.{1}\d+$/, str);
}
/*+--------------------------------------------------+
  |函 数 名:isUFloat(str)                            |
  |传入参数:str(String类型)                          |
  |返 回 值:(Bool)                                   |
  |创 建 人:Simon.Ye                                 |
  |创建时间:2006-06-18                               |
  |说  明:判断是否无符号小数                       |
  +--------------------------------------------------+*/
function isUFloat(str)
{
    return preg_match(/^\d+\.{1}\d+$/, str);
}
/*+--------------------------------------------------+
  |函 数 名:isIDCard15(str)                          |
  |传入参数:str(String类型)                          |
  |返 回 值:(Bool)                                   |
  |创 建 人:Simon.Ye                                 |
  |创建时间:2006-06-18                               |
  |说  明:判断是否是15位身份证                     |
  +--------------------------------------------------+*/
function isIDCard15(str)
{
    return preg_match(/^\d{15}$/, str);
}
/*+--------------------------------------------------+
  |函 数 名:isIDCard18(str)                          |
  |传入参数:str(String类型)                          |
  |返 回 值:(Bool)                                   |
  |创 建 人:Simon.Ye                                 |
  |创建时间:2006-06-18                               |
  |说  明:判断是否是18位身份证                     |
  +--------------------------------------------------+*/
function isIDCard18(str)
{
    return preg_match(/^\d{17}[\d|x|X]{1}$/, str);
}
/*+--------------------------------------------------+
  |函 数 名:isDate(str)                              |
  |传入参数:str(String类型)                          |
  |返 回 值:(Bool)                                   |
  |创 建 人:Simon.Ye                                 |
  |创建时间:2006-06-18                               |
  |说  明:判断是否正确的日期格式                   |
  +--------------------------------------------------+*/
function isDate(str)
{
    if(!preg_match(/^\d{4}\-\d{1,2}\-\d{1,2}$/, str))
    {
        return false;
    }
    else
    {
        var arrMonth30 = new Array('4', '6', '9', '11');
        var arr = str.split('-');
        var YYYY = parseInt(arr[0], 10);
        var mm = parseInt(arr[1], 10);
        var dd = parseInt(arr[2], 10);
       
        if(YYYY < 1000 || mm < 1 || mm > 12 || dd < 1 || dd > 31)
        {
            return false;
        }
        else if(mm == 2 && dd > 29)
        {
            return false;
        }
        else if((YYYY % 4) != 0 && mm == 2 && dd > 28)
        {
            return false;
        }
        else if(in_array(mm, arrMonth30) && dd > 30)
        {
            return false;
        }
        else
        {
            return true;
        }
    }
}
/*+--------------------------------------------------+
  |函 数 名:isDateTime(str)                          |
  |传入参数:str(String类型)                          |
  |返 回 值:(Bool)                                   |
  |创 建 人:Simon.Ye                                 |
  |创建时间:2006-06-18                               |
  |说  明:判断是否正确的日期时间格式               |
  +--------------------------------------------------+*/
function isDateTime(str)
{
    if(!preg_match(/^\d{4}\-\d{1,2}\-\d{1,2} \d{1,2}:\d{1,2}:?\d{0,2}$/, str))
    {
        return false;
    }
    else
    {
        var arrMonth30 = new Array('4', '6', '9', '11');
        var arr = str.split(' ');
        var arrDate = arr[0].split('-');
        var arrTime = arr[1].split(':');
        var YYYY = parseInt(arrDate[0], 10);
        var mm = parseInt(arrDate[1], 10);
        var dd = parseInt(arrDate[2], 10);
        var HH = parseInt(arrTime[0], 10);
        var ii = parseInt(arrTime[1], 10);
        var ss = 0;
       
        if(arrTime.length == 3) ss = parseInt(arrTime[2], 10);
       
        if(YYYY < 1000 || mm < 1 || mm > 12 || dd < 1 || dd > 31 || HH > 23 || ii > 59)
        {
            return false;
        }
        else if(ss != 0 && ss > 59)
        {
            return false;
        }
        else if(mm == 2 && dd > 29)
        {
            return false;
        }
        else if((YYYY % 4) != 0 && mm == 2 && dd > 28)
        {
            return false;
        }
        else if(in_array(mm, arrMonth30) && dd > 30)
        {
            return false;
        }
        else
        {
            return true;
        }
    }
}
/*+--------------------------------------------------+
  |函 数 名:isMobile(str)                            |
  |传入参数:str(String类型)                          |
  |返 回 值:(Bool)                                   |
  |创 建 人:Simon.Ye                                 |
  |创建时间:2006-06-18                               |
  |说  明:判断是否正确的手机号码                   |
  +--------------------------------------------------+*/
function isMobile(str)
{
    return preg_match(/^(130|131|132|133|134|135|136|137|138|139)\d{8}$/, str);
}
/*+--------------------------------------------------+
  |函 数 名:isZipCode(str)                           |
  |传入参数:str(String类型)                          |
  |返 回 值:(Bool)                                   |
  |创 建 人:Simon.Ye                                 |
  |创建时间:2006-06-18                               |
  |说  明:判断是否正确的邮政编码                   |
  +--------------------------------------------------+*/
function isZipCode(str)
{
    return preg_match(/^\d{6}$/, str);
}
/*+--------------------------------------------------+
  |函 数 名:checkInput(regStr)                       |
  |传入参数:str(String类型)                          |
  |返 回 值:(Bool)                                   |
  |创 建 人:Simon.Ye                                 |
  |创建时间:2006-06-18                               |
  |说  明:限制用户的输入(例:<input type="text"     |
  |         >限制只能输入数字)              |
  +--------------------------------------------------+*/
function checkInput(regStr)
{
    var inputChar = String.fromCharCode(event.keyCode);
  
    if(!preg_match(regStr, inputChar)) return false;
  
    return true;
}
/*+--------------------------------------------------+
  |函 数 名:onlyEnglish()                            |
  |传入参数:str(String类型)                          |
  |返 回 值:(Bool)                                   |
  |创 建 人:Simon.Ye                                 |
  |创建时间:2006-06-18                               |
  |说  明:限制用户只能输入英文(用法同上)           |
  +--------------------------------------------------+*/
function onlyEnglish()
{
    return (event.keyCode < 128);
}


Ajax学习 网址备忘录一.资源类网站{网络收集}

1,国内网站
1)Ajax中国(推荐)
一个专业的ajax技术网站,分类清晰,有大量的电子版教程,以及AJAX源码下载!
www.okajax.com
2)ajaxcn.org
李琨老师的blog。李琨:《ajax实战》译者.
www.ajaxcn.org
2,国外网站
1)、Ajax 的诞生
Ajax: A New Approach to Web Applications
www.adaptivepath.com/publications/essays/archives/000385.php
2)、AJAX Matters
www.ajaxmatters.com
关于 Ajax 技术一个信息量非常大的网站,有点像 Ajax 世界中的 TSS。
3)、AJAX Patterns
与 AJAX 设计模式相关的资源。
www.ajaxpatterns.org
www.softwareas.com/ajax-patterns
4)、http://www.ajaxian.com
--------------------------------------------------------------------------------
二.热门文章
1.什么是AJAX
www.okajax.com/info/net/20060510.html
2.ajax技术简介
www.okajax.com/info/basic/200604654.html
3.ajax.net
www.okajax.com/info/basic/200604556.html
www.okajax.com/info/tech/200605589.html
weblogs.asp.net/mschwarz/archive/2005/04/11/399893.aspx(英文)
--------------------------------------------------------------------------------
三.ajax相关下载(电子书教程/源码)
1.Ajax基础教程电子版
www.okajax.com/info/bookdown/200604950.htm
2.《AJAX实战》ajax in action电子版
www.okajax.com/info/bookdown/200604366.htm
3.AJAX开发简略
www.okajax.com/info/bookdown/20060538.htm
4.AJAX版CD管理系统 (jsp)
www.okajax.com/info/codedown/200604327.htm
5.Alexa 查询系统 (Xmlhttp + Ajax)
www.okajax.com/info/codedown/200604982.htm
6.ASP.NET+AJAX解决网页打开等待问题
www.okajax.com/info/codedown/200604166.htm
7.Ajax技术简介 (ajax demo)
www.okajax.com/info/codedown/200604576.htm
--------------------------------------------------------------------------------
四.ajax相关图书
1.《Ajax实战》(目前Ajax领域最为全面深入的一本著作)
www.china-pub.com/computers/common/info.asp?id=28433
2.《Ajax基础教程》(亚马逊计算机榜首图书,国内第1本Ajax图书)
www.china-pub.com/computers/common/info.asp?id=28432
3.《Ajax 修炼之道-Web 2.0 入门》(Ajax从小工到专家的首选图书)
www.china-pub.com/computers/common/info.asp?id=29430
4.《征服Ajax+Lucene构建搜索引擎》
www.china-pub.com/computers/common/info.asp?id=29996
5.《征服Ajax--Web 2.0快速入门与项目实践(.net)》
www.china-pub.com/computers/common/info.asp?id=29995
6.《Ajax开发精要--概念、案例与框架》
www.china-pub.com/computers/common/info.asp?id=30006
--------------------------------------------------------------------------------
五.部分技术文章
www.dragonson.com/doc/ajax.html
Ajax内部交流文档
info96.k12studio.com/~nio/comments.php?id=242_0_1_0_C
简单地对 Ajax 进行描述介绍
www.adaptivepath.com/publications/essays/archives/000385.php
Ajax: A New Approach to Web Applications
jibbering.com/2002/4/httprequest.html
Using the XML HTTP Request object
developer.apple.com/internet/webcontent/xmlhttpreq.html
Dynamic HTML and XML: The XMLHttpRequest Object
del.icio.us/popular/ajax
del.icio.us / popular / ajax
www.fiftyfoureleven.com/resources/programming/xmlhttprequest/examples
XMLHttpRequest & Ajax Working Examples
www.xml.com/lpt/a/2005/02/09/xml-http-request.html
Very Dynamic Web Interfaces
www.standards-schmandards.com/index.php?2005/03/01/16-ajax-and-accessibility
AJAX and Accessibility
www.xml.com/lpt/a/2005/05/11/ajax-error.html
Errors and AJAX
www.softwareas.com/ajax-patterns
AJAX Patterns: Design Patterns for AJAX Usability
www.backbase.com/download/Whitepaper%20Backbase%20AJAX%20and%20Beyond.pdf
Whitepaper Backbase AJAX and Beyond
www.ajaxpatterns.org/index.php?title=Main_Page
AJAX patterns
www.onlamp.com/pub/a/onlamp/2005/05/19/xmlhttprequest.html


posted on 2007-07-13 08:32 宁毅网络工作室 阅读(266) 评论(0)  编辑  收藏 所属分类: 计算机基础知识