/**
* 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. 数据库基础——跟着【克里斯学SQL】哈哈。

    前言: 很多同学呀,对数据库的操作仅仅只能在于Navicat 等第三方可视化的工具上面!!!! 这是可怕的,数据库的操作十分的重要,甚至,他是程序最重要的部分. 面试经常问题, 了解那个数据? 写一个 ...

  2. mvn test报错

    1 Scenarios (1 passed) 4 Steps (4 passed) 0m11.846s [INFO] Tests run: 1, Failures: 0, Errors: 0, Ski ...

  3. 对于iOS架构的认识过程

    MVC 经典就是经典,没有之一.iOS中MVC架构,看懂斯坦福大学白胡子老头这张图基本上就可以了.   斯坦福大学MVC架构.png 简单理解,就是Controller对象拥有View和Model对象 ...

  4. linux下进入root用户登录

    1.打开终端,输入sudo passwd -u root 输入当前用户的登录密码,提示如下标红区域信息 解决方案: 1)直接输入命令:su,输入当前用户登录密码 2)添加sudoers文件的写权限,命 ...

  5. 简单的Web日志处理细节

  6. 读spring源码(一)-ClassPathXmlApplicationContext-初始化

    工作来几乎所有的项目都用到了spring,却一直没有系统的读下源码,从头开始系统的读下吧,分章也不那么明确,读到哪里记到哪里,仅仅作为个笔记吧. 先看ClassPathXmlApplicationCo ...

  7. git工具——对比文件的不同

    对比工作区和某个版本中文件的不同: (1)继续编辑文件code.txt,在其中添加一行内容: (2)现在要对比工作区中code.txt和head版本中code.txt的不同,使用如下命令: 前面没有出 ...

  8. C# 7.0特性

    一.out的形参变量无需再提前声明 befor: "; int numericResult; if (int.TryParse(input, out numericResult)) Cons ...

  9. 【原创】大数据基础之Impala(3)部分调优

    1)将coordinator和executor角色分离 By default, each host in the cluster that runs the impalad daemon can ac ...

  10. 从头开始学Maven【依赖范围】

    例如 <dependencies> <dependency> <groupId></groupId> <artifactId></ar ...