/**
* 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. Transformer【Attention is all you need】

    前言 Transfomer是一种encoder-decoder模型,在机器翻译领域主要就是通过encoder-decoder即seq2seq,将源语言(x1, x2 ... xn) 通过编码,再解码的 ...

  2. sass补充(2019-3-9)

    @each 输出 格式: @each $var in value,value1,value2{ } eg: @each $var1 in 100px,200px,300px{ .box{ width: ...

  3. torchvision 作用

    1. 提供主流的model,和常用数据集 2. 对 torch.utils.data.Dataset进行扩充,针对不同类别图像放入不同文件夹的数据进行读取, torchvision.datasets. ...

  4. Java(13) 抽象和封装

    一.简述从现实世界中抽象出类的步骤 第一:找出分类(分析出类) 第二:找出类的特征(分析类的相关属性) 第三:找出类的行为(分析类的方法) 二.常量(经常出现的变量值) 2.1 语法: public ...

  5. Python规范

    1.命名 Django文件命名 小写+下划线 类:驼峰 2.edit 执行环境 work direction 到当前项目目录 3.类要加注释 4.去数据库找数据时需要try捕获异常,防止数据库连接断掉 ...

  6. 编写MyCP.java 实现类似Linux下cp XXX1 XXX2的功能

    题目:编写MyCP.java 实现类似Linux下cp XXX1 XXX2的功能 要求:MyCP支持两个参数: java MyCP -tx XXX1.txt XXX2.bin 用来把文本文件(内容为十 ...

  7. Python——类的封装

    class Gun: def __init__(self, model): # 1. 枪的型号 self.model = model # 2. 子弹的数量 self.bullet_count = 0 ...

  8. 【转】ContextLoaderListener和DispatcherServlet加载内容的区别

    一.ContextLoaderListener加载内容 二.DispatcherServlet加载内容 ContextLoaderListener和DispatcherServlet都会在Web容器启 ...

  9. codeforces 813E 主席树

    题意: 一个数列多组询问,每次询问[l,r]中最多能选多少个数字,其中每个数字的出现次数不超过k次 题解: 我们保存对于每个位置上,出现超过k次的位置,那么对于每次询问,我们就变成了查询区间[l,r] ...

  10. jmeter创建时间函数

    固定格式的年月日 ${__time(yyyyMMdd,)} 20151214 //返回年月日 ${__time(HHmmss,)} 092816 //返回时分秒 ${__time(yyyyMMdd-H ...