Linux中国  设为主页
 收藏本站
 
当前位置: > 首页 ->网站设计 ->AJAX教程 ->prototype.js 1.4 原代码阅读
  相关分类: 
AJAX教程
CSS/CSS2
Dreamweaver
Fireworks
Flash
HTML/DHTML
JavaScript
Phososhop
网页制作
  站内搜索: 
热门文章排行
热门文章排行 Ajax实现分页查询(06-04)
prototype.js 1.4 原代码阅读(04-24)
使用AjaxPro开发四级无刷新联动下拉(06-04)
在Struts应用中使用Ajax(04-24)
Ajax:拥抱JSON,让XML走开(04-24)
精采文章排行
精采文章排行 使用AjaxPro开发四级无刷新联动下拉(06-04)
微软Asp.net Ajax 1.0的AutoComplete(06-04)
Ajax实现分页查询(06-04)
Ajax实现不刷屏的前提下实现页面定时(06-04)
Ajax程序设计入门(06-04)
  ·微软Asp.net Ajax 1.0的AutoComplete控件·Ajax实现分页查询·Ajax实现不刷屏的前提下实现页面定时刷新·Ajax程序设计入门·微软的Ajax库客户端Bug总结·利用AJAX和ASP.NET实现简单聊天室 ·利用AJAX技术实现网页无刷新进度条显示·Ajax联动下拉框的实现例子·AJAX如何与后台交互

prototype.js 1.4 原代码阅读

作者:Webmaster   来源:Linux-cn.com   点击:   日期:2007-04-24 [收藏] [投稿]

  IE是否经常中毒?推荐您


 * 而使用了bind以后,该方法才能正确的找到this,也就是PeriodicalExecuter的当前实例。
 */
var PeriodicalExecuter = Class.create();
PeriodicalExecuter.prototype = {
  initialize: function(callback, frequency) {
    this.callback = callback;
    this.frequency = frequency;
    this.currentlyExecuting = false;

    this.registerCallback();
  },

  registerCallback: function() {
    setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);
  },

  onTimerEvent: function() {
    if (!this.currentlyExecuting) {
      try {
        this.currentlyExecuting = true;
        this.callback();
      } finally {
        this.currentlyExecuting = false;
      }
    }
  }
}
Object.extend(String.prototype, {
  gsub: function(pattern, replacement) {
    var result = '', source = this, match;
    replacement = arguments.callee.prepareReplacement(replacement);

    while (source.length > 0) {
      if (match = source.match(pattern)) {
        result += source.slice(0, match.index);
        result += (replacement(match) || '').toString();
        source  = source.slice(match.index + match[0].length);
      } else {
        result += source, source = '';
      }
    }
    return result;
  },

  sub: function(pattern, replacement, count) {
    replacement = this.gsub.prepareReplacement(replacement);
    count = count === undefined ? 1 : count;

    return this.gsub(pattern, function(match) {
      if (--count < 0) return match[0];
      return replacement(match);
    });
  },

  scan: function(pattern, iterator) {
    this.gsub(pattern, iterator);
    return this;
  },

  truncate: function(length, truncation) {
    length = length || 30;
    truncation = truncation === undefined ? '...' : truncation;
    return this.length > length ?
      this.slice(0, length - truncation.length) + truncation : this;
  },

  strip: function() {
    return this.replace(/^\s+/, '').replace(/\s+$/, '');
  },

  stripTags: function() {
    return this.replace(/<\/?[^>]+>/gi, '');
  },

  stripScripts: function() {
    return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), '');
  },



 如果您对本文有任何疑问或者建议,请到讨论区发表您的意见: >> 论坛入口 <<

上一页 1 2 34 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 下一页

上一篇:prototype.js1.4 版开发者手册   下一篇:prototype.js常用函数及其用法
文章评论】 【收藏本文】 【推荐好友】 【打印本文】 【我要投稿】 【论坛讨论

   相关文章:
·使用AjaxPro开发四级无刷新联动下拉框

   文章评论:(1条)
  
 请留名: 匿名评论   点击查看所有评论 论坛讨论
 

 声明:刊登此文章是为了传递更多信息,文章内容仅供参考,转载请注明出处。