/**
* jquery.string - Prototype string functions for jQuery
* version: 1.1.0
* (c) 2008-2011 David E. Still (http://stilldesigning.com)
* Original Prototype extensions (c) 2005-2011 Sam Stephenson (http://prototypejs.org)
*/
(function (f) {
f.extend({
__stringPrototype: function (h) {
function i(a) {
if (!a.source)return a;
return RegExp(a.source, "g" + (a.ignoreCase ? "i" : "") + (a.multiline ? "m" : ""))
} var j = "a b".split(/\w/)[0] == " ";
this.str = h;
this.JSONFilter = /^\/\*-secure-([\s\S]*)\*\/\s*$/;
this.ScriptFragment = "<script[^>]*>([\\S\\s]*?)<\/script>";
this.specialChar = {"\u0008": "\\b", "\t": "\\t", "\n": "\\n", "\u000c": "\\f", "\r": "\\r", "\\": "\\\\"};
this.blank = function (a) {
return /^\s*$/.test(this.s(a) || " ")
};
this.camelize = function (a) {
var b = this.s(a).split("-"),
c, a = [b[0]];
for (c = 1; c < b.length; c++)a.push(b[c].charAt(0).toUpperCase() + b[c].substring(1));
this.str = a.join("");
return this
};
this.capitalize = function (a) {
a = this.s(a);
this.str = a.charAt(0).toUpperCase() + a.substring(1).toLowerCase();
return this
};
this.dasherize = function (a) {
this.str = this.s(a).split("_").join("-");
return this
};
this.empty = function (a) {
return a ? a == "" : this.str == ""
};
this.endsWith = function (a, b) {
var b = this.s(b), c = b.length - a.length;
return c >= 0 && b.lastIndexOf(a) === c
};
this.escapeHTML = function (a) {
this.str =
this.s(a).split("&").join("&amp;").split("<").join("&lt;").split(">").join("&gt;");
return this
};
this.evalJSON = function (a, b) {
var b = this.s(b), c = this.unfilterJSON(!1, b).str;
try {
if (!a || this.isJSON(c))return eval("(" + c + ")")
} catch (d) {
}
throw new SyntaxError("Badly formed JSON string: " + b);
};
this.evalScripts = function (a) {
var a = this.extractScripts(this.s(a)), b = [];
if (a.length > 0)for (var c = 0; c < a.length; c++)b.push(eval(a[c]));
return b
};
this.extractScripts = function (a) {
var b = RegExp(this.ScriptFragment, "img"), c = RegExp(this.ScriptFragment,
"im"), a = this.s(a).match(b) || [], b = [];
if (a.length > 0)for (var d = 0; d < a.length; d++)b.push(a[d].match(c)[1] || "");
return b
};
this.gsub = function (a, b, c) {
c = this.s(c);
if (f.isFunction(b)) {
var d = c.match(i(a));
if (d == null)return this;
c = this.sub(a, b, d.length, c).str
} else c = c.split(a).join(b);
this.str = c;
return this
};
this.include = function (a, b) {
return this.s(b).indexOf(a) > -1
};
this.inspect = function (a, b) {
var b = this.s(b), c = this.specialChar, d = this.gsub(/[\x00-\x1f\\]/, function (a) {
var b = c[a[0]];
return b ? b : "\\u00" + a[0].charCodeAt().toPaddedString(2,
16)
}, b).str;
this.str = a ? '"' + d.replace(/"/g, '\\"') + '"' : "'" + d.replace(/'/g, "\\'") + "'";
return this
};
this.interpolate = function (a, b, c) {
c = this.s(c);
b || (b = /(^|.|\r|\n)(\#\{\s*(\w+)\s*\})/);
for (var d = 0, g = c.length, e; b.match(c) && d++ < g;)e = b.exec(c), c = this.gsub(e[2], a[e[3]], c).str;
this.str = c;
return this
};
this.isJSON = function (a) {
a = this.s(a);
if (this.blank(a))return !1;
a = a.replace(/\\./g, "@").replace(/"[^"\\\n\r]*"/g, "");
return /^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/.test(a)
};
this.scan = function (a, b, c) {
c = this.s(c);
this.gsub(a,
b, c).str = c;
return this
};
this.startsWith = function (a, b) {
return this.s(b).indexOf(a) === 0
};
this.strip = function (a) {
this.str = f.trim(this.s(a));
return this
};
this.stripScripts = function (a) {
this.str = this.s(a).replace(RegExp(this.ScriptFragment, "img"), "");
return this
};
this.stripTags = function (a) {
this.str = this.s(a).replace(/<\/?[^>]+>/gi, "");
return this
};
this.sub = function (a, b, c, d) {
d = this.s(d);
c = !c ? 1 : c;
if (c < 0 || isNaN(c))return this;
var a = i(a), g = d.split(a), e = d.match(a);
j && typeof a == "object" && (c == e.length && ++c, d.indexOf(e[0]) ==
0 && g.unshift(""), d.lastIndexOf(e[e.length - 1]) == d.length - e[e.length - 1].length && g.push(""));
d = g[0];
for (a = 1; a < g.length; a++)d += a <= c ? f.isFunction(b) ? b(e[a - 1] || e) + g[a] : b + g[a] : (e[a - 1] || e) + g[a];
this.str = d;
return this
};
this.succ = function (a) {
a = this.s(a);
this.str = a.slice(0, a.length - 1) + String.fromCharCode(a.charCodeAt(a.length - 1) + 1);
return this
};
this.times = function (a, b) {
this.str = a < 1 ? "" : Array(a + 1).join(this.s(b));
return this
};
this.toJSON = function (a) {
return this.inspect(!0, this.s(a))
};
this.toQueryParams = function (a,
b) {
var b = this.s(b), c = b.substring(b.indexOf("?") + 1).split("#")[0].split(a || "&"), d = {}, g, e, f;
for (g = 0; g < c.length; g++)f = c[g].split("="), e = decodeURIComponent(f[0]), f = f[1] ? decodeURIComponent(f[1]) : void 0, d[e] ? (typeof d[e] == "string" && (d[e] = [d[e]]), d[e].push(f)) : d[e] = f;
return d
};
this.truncate = function (a, b, c) {
c = this.s(c);
a = a || 30;
b = !b ? "..." : b;
this.str = c = c.length > a ? c.slice(0, a - b.length) + b : String(c);
return this
};
this.underscore = function (a) {
this.gsub(/[A-Z]/, function (a) {
return "_" + a.toLowerCase()
}, this.s(a));
if (this.str.substring(0,
1) == "_")this.str = this.str.substring(1);
return this
};
this.unescapeHTML = function (a) {
this.str = this.stripTags(this.s(a)).str.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">");
return this
};
this.unfilterJSON = function (a, b) {
var b = this.s(b), a = a || this.JSONFilter, c = b.match(a);
this.str = c !== null ? c[1] : b;
return this
};
this.value = function () {
return this.str
};
this.s = function (a) {
return a ? a : this.str
}
}, string: function (h) {
if (h === String.prototype)f.extend(String.prototype, new f.__stringPrototype); else return new f.__stringPrototype(h)
}
});
f.__stringPrototype.parseQuery = f.__stringPrototype.toQueryParams
})(jQuery);

jquery.string.js的更多相关文章

  1. 动态生成二维码插件 jquery.qrcode.js

    前段时间做项目,需要动态生成一个二维码,于是就在网上找了一下发现一个jquery插件jquery.qrcode.js,所以今天就简单说一下这个插件的使用: jquery.qrcode.js是依赖jqu ...

  2. jQuery插件 -- Cookie插件jquery.cookie.js(转)

    Cookie是网站设计者放置在客户端的小文本文件.Cookie能为用户提供很多的使得,例如购物网站存储用户曾经浏览过的产品列表,或者门户网站记住用户喜欢选择浏览哪类新闻. 在用户允许的情况下,还可以存 ...

  3. jQuery验证控件jquery.validate.js使用说明

    官网地址:http://bassistance.de/jquery-plugins/jquery-plugin-validation jQuery plugin: Validation 使用说明 转载 ...

  4. jquery.validate.js插件使用

    jQuery验证控件jquery.validate.js使用说明+中文API 官网地址:http://bassistance.de/jquery-plugins/jquery-plugin-valid ...

  5. jquery.validate.js表单验证

    一.用前必备官方网站:http://bassistance.de/jquery-plugins/jquery-plugin-validation/ API: http://jquery.bassist ...

  6. jquery.cookie.js && java后台代码 操作cookie实现记住当前用户输入信息代码

    下载jquery.cookie.js地址看这里:http://pan.baidu.com/s/1gdCPaN5 //初始化页面时验证是否记住了密码 $(document).ready(function ...

  7. 当 jquery.unobtrusive-ajax.js 遇上Web API

    最近在熟悉Abp框架,其基于DDD领域驱动设计...前段可以绕过mvc直接调用根据app层动态生成的webapi,有点神奇~,Web API之前有简单接触过,WCF的轻量级版,一般用于做一写开发性的服 ...

  8. jQuery String Functions

    In today's post, I have put together all jQuery String Functions. Well, I should say that these are ...

  9. Jquery.cookie.js 源码和使用方法

    jquery.cookie.js源码和使用方法 jQuery操作cookie的插件,大概的使用方法如下 $.cookie(‘the_cookie’); //读取Cookie值$.cookie(’the ...

随机推荐

  1. (七) UVC框架分析

    title: UVC框架分析 date: 2019/4/23 19:50:00 toc: true --- UVC框架分析 源码的位置在drivers\media\video\uvc,查看下Makef ...

  2. SQL两个事务update同一张表出现的死锁问题(waitfor delay)

    抄录网址:https://blog.csdn.net/qiumuxia0921/article/details/50574879 下面是我们的建表语句: SET ANSI_NULLS ON GO SE ...

  3. 图片下载、渲染操作 小例子 看多FutureTask

    并发执行下载图片操作 import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent. ...

  4. 转化.vdi到.vmdk

    OracleVirtualBox转化.vdi到.vmdk E:\Genymotion-deployed\CentOS_7_64>"D:/Program Files/Oracle/Vir ...

  5. VIM编辑器使用

  6. 20175333曹雅坤 实验二 Java面向对象程序设计

    实验二 Java面向对象程序设计 实验内容 1. 初步掌握单元测试和TDD 2. 理解并掌握面向对象三要素:封装.继承.多态 3. 初步掌握UML建模 4. 熟悉S.O.L.I.D原则 5. 了解设计 ...

  7. python中的operator.itemgetter函数

    operator.itemgetter函数operator模块提供的itemgetter函数用于获取对象的哪些维的数据,参数为一些序号.看下面的例子 a = [,,] >>> b=) ...

  8. java学习笔记05-运算符

    算数运算符 +:相加 -:相减 *:相乘 /:相除 %:取余 ++:自增 --:自减 public static void main(String[] args) { int i = 10; int ...

  9. RandomShuffleQueue

    一.几个函数 RandomShuffleQueue类 __init__(self, capacity, min_after_dequeue,dtypes, shapes=None,names=None ...

  10. 高可用Redis(十三):Redis缓存的使用和设计

    1.缓存的受益和成本 1.1 受益 1.可以加速读写:Redis是基于内存的数据源,通过缓存加速数据读取速度 2.降低后端负载:后端服务器通过前端缓存降低负载,业务端使用Redis降低后端数据源的负载 ...