分类目录归档:js专栏

网页刷新、离开时提示信息

在网页刷新、访问新的网址、关闭窗口、前进、后退时,要询问用户是否要离开此页面可以用以下方法,

window.onbeforeunload=function(){
return “确定要离开(刷新)吗?”;
}

确定后还可以做些操作,比如退出登录:

window.onbeforeunload=function(){

$.get(“http://localhost/logout.php”);

return “确定要离开(刷新)吗?”;
}

在某些系统中还可以用这段javascript禁止刷新页面。

50个必备的实用jQuery代码段

本文会给你们展示50个jquery代码片段,这些代码能够给你的javascript项目提供帮助。其中的一些代码段是从jQuery1.4.2才开始支持的做法,另一些则是真正有用的函数或方法,他们能够帮助你又快又好地把事情完成。如果你发现你任何可以做得更好的地方的话,欢迎把你的版本粘贴在评论中!

1. 如何修改jQuery默认编码(例如默认UTF-8改成改GB2312):

$.ajaxSetup({
ajaxSettings:{ contentType:”application/x-www-form-urlencoded;chartset=GB2312″}
});
2. 解决jQuery, prototype共存,$全局变量冲突问题:

<script src=”prototype.js”></script>
<script src=”http://blogbeta.blueidea.com/jquery.js”></script>
<script type=”text/javascript”>
jQuery.noConflict();
</script>
注意:一定要先引入prototype.js 再引入jquery.js,先后顺序不可错。

3. jQuery 判断元素上是否绑定了事件

//jQuery event封装支持判断元素上是否绑定了事件,此方法只适用于jQuery绑定的事件
var $events = $(“#foo”).data(“events”);
if( $events && $events[“click”] ){
//your code
}
4. 如何使用jQuery来切换样式表

//找出你希望切换的媒体类型(media-type),然后把href设置成新的样式表。
$(‘link[media=’screen’]’).attr(‘href’, ‘alternative.css’);
5. 如何限制选择范围(基于优化目的):

//尽可能使用标签名来作为类名的前缀,
//这样jQuery就不需要花费更多的时间来搜索
//你想要的元素。还要记住的一点是,
//针对于你的页面上的元素的操作越具体化,
//就越能降低执行和搜索的时间。
var in_stock = $(‘#shopping_cart_items input.is_in_stock’);

<ul id=”shopping_cart_items”>
<li><input type=”radio” value=”Item-X” name=”item” class=”is_in_stock” /> Item X</li>
<li><input type=”radio” value=”Item-Y” name=”item” class=”3-5_days” /> Item Y</li>
<li><input type=”radio” value=”Item-Z” name=”item” class=”unknown” /> Item Z</li>
</ul>
6. 如何正确地使用toggleClass:

//切换(toggle)类允许你根据某个类的
//是否存在来添加或是删除该类。
//这种情况下有些开发者使用:
a.hasClass(‘blueButton’) ? a.removeClass(‘blueButton’) : a.addClass(‘blueButton’);
//toggleClass允许你使用下面的语句来很容易地做到这一点
a.toggleClass(‘blueButton’);
7. 如何设置IE特有的功能:

if ($.browser.msie) {
// Internet Explorer就是个虐待狂
}
8. 如何使用jQuery来代替一个元素:

$(‘#thatdiv’).replaceWith(‘fnuh’);
9. 如何验证某个元素是否为空:

// 方法一
if (! $(‘#keks’).html()) {
//什么都没有找到;
}

// 方法二
if ($(‘#keks’).is(“:empty”)) {
//什么都没有找到;
}
10. 如何从一个未排序的集合中找出某个元素的索引号

$(“ul > li”).click(function () {
var index = $(this).prevAll().length; //prevAll([expr]): 查找当前元素之前所有的同辈元素
});
11. 如何把函数绑定到事件上:

//方法一
$(‘#foo’).click(function(event) {
alert(‘User clicked on “foo.”‘);
});

//方法二, 支持动态传参
$(‘#foo’).bind(‘click’, {test1:”abc”, test2:”123″}, function(event) {
alert(‘User clicked on “foo.”‘ + event.data.test1 + event.data.test2 );
});
12. 如何追加或是添加html到元素中:

$(‘#lal’).append(‘sometext’);
13. 在创建元素时,如何使用对象字面量(literal)来定义属性

var e = $(“”, { href: “#”, class: “a-class another-class”, title: “…” });
14. 如何使用多个属性来进行过滤

//在使用许多相类似的有着不同类型的input元素时,
//这种基于精确度的方法很有用
var elements = $(‘#someid input[type=sometype][value=somevalue]’).get();
15. 如何使用jQuery来预加载图像:

jQuery.preloadImages = function() {
for(var i = 0; i < arguments.length; i++) {
$(“<img />”).attr(‘src’, arguments[i]);
}
};
//用法
$.preloadImages(‘image1.gif’, ‘/path/to/image2.png’, ‘some/image3.jpg’);
16. 如何为任何与选择器相匹配的元素设置事件处理程序:

$(‘button.someClass’).live(‘click’, someFunction);
//注意,在jQuery 1.4.2中,delegate和undelegate选项
//被引入代替live,因为它们提供了更好的上下文支持
//例如,就table来说,以前你会用
$(“table”).each(function(){
$(“td”, this).live(“hover”, function(){
$(this).toggleClass(“hover”);
});
});
//现在用
$(“table”).delegate(“td”, “hover”, function(){
$(this).toggleClass(“hover”);
});
17. 如何找到一个已经被选中的option元素:

$(‘#someElement’).find(‘option:selected’);
18. 如何隐藏一个包含了某个值文本的元素:

$(“p.value:contains(‘thetextvalue’)”).hide();
19. 如何创建嵌套的过滤器:

//允许你减少集合中的匹配元素的过滤器,
//只剩下那些与给定的选择器匹配的部分。在这种情况下,
//查询删除了任何没(:not)有(:has)
//包含class为“selected”(.selected)的子节点。
.filter(“:not(:has(.selected))”)
20. 如何检测各种浏览器:

检测Safari (if( $.browser.safari)),
检测IE6及之后版本 (if ($.browser.msie && $.browser.version > 6 )),
检测IE6及之前版本 (if ($.browser.msie && $.browser.version <= 6 )),
检测FireFox 2及之后版本 (if ($.browser.mozilla && $.browser.version >= ‘1.8’ ))

 

21. 任何使用has()来检查某个元素是否包含某个类或是元素:

//jQuery 1.4.*包含了对这一has方法的支持。
//该方法找出某个元素是否包含了其他另一个元素类或是其他任何的你正在查找并要在其之上进行操作的东东。
$(“input”).has(“.email”).addClass(“email_icon”);
22. 如何禁用右键单击上下文菜单:

$(document).bind(‘contextmenu’,function(e){
return false;
});
23. 如何定义一个定制的选择器

$.expr[‘:’].mycustomselector = function(element, index, meta, stack){
// element- 一个DOM元素
// index – 栈中的当前循环索引
// meta – 有关选择器的元数据
// stack – 要循环的所有元素的栈
// 如果包含了当前元素就返回true
// 如果不包含当前元素就返回false };
// 定制选择器的用法:
$(‘.someClasses:test’).doSomething();
24. 如何检查某个元素是否存在

if ($(‘#someDiv’).length) {
//万岁!!!它存在……
}
25. 如何使用jQuery来检测右键和左键的鼠标单击两种情况:

$(“#someelement”).live(‘click’, function(e) {
if( (!$.browser.msie && e.button == 0) || ($.browser.msie && e.button == 1) ) {
alert(“Left Mouse Button Clicked”);
} else if(e.button == 2) {
alert(“Right Mouse Button Clicked”);
}
});
26. 如何替换串中的词

var el = $(‘#id’);
el.html(el.html().replace(/word/ig, ”));
27. 如何在一段时间之后自动隐藏或关闭元素(支持1.4版本):

//这是1.3.2中我们使用setTimeout来实现的方式
setTimeout(function() {
$(‘.mydiv’).hide(‘blind’, {}, 500)
}, 5000);
//而这是在1.4中可以使用delay()这一功能来实现的方式(这很像是休眠)
$(“.mydiv”).delay(5000).hide(‘blind’, {}, 500);
28. 如何把已创建的元素动态地添加到DOM中:

var newDiv = $(‘<div></div>’);
newDiv.attr(‘id’,’myNewDiv’).appendTo(‘body’);
29. 如何限制“Text-Area”域中的字符的个数:

jQuery.fn.maxLength = function(max){
return this.each(function(){
var type = this.tagName.toLowerCase();
var inputType = this.type? this.type.toLowerCase() : null;
if(type == “input” && inputType == “text” || inputType == “password”){
//Apply the standard maxLength
this.maxLength = max;
} else if(type == “textarea”){
this.onkeypress = function(e){
var ob = e || event;
var keyCode = ob.keyCode;
var hasSelection = document.selection? document.selection.createRange().text.length > 0 : this.selectionStart != this.selectionEnd;
return !(this.value.length >= max && (keyCode > 50 || keyCode == 32 || keyCode == 0 || keyCode == 13) && !ob.ctrlKey && !ob.altKey && !hasSelection);
};
this.onkeyup = function(){
if(this.value.length > max){
this.value = this.value.substring(0,max);
}
};
}
});
};
//用法
$(‘#mytextarea’).maxLength(500);
30. 如何jQuery注册和禁用jQuery全局事件

//jQuery注册ajax全局事件ajaxStart,ajaxStop:
$(document).ajaxStart(function(){
$(“#background,#progressBar”).show();
}).ajaxStop(function(){
$(“#background,#progressBar”).hide();
});
//ajax请求禁用全局事件:$.ajax() 有个参数global (默认: true) 是否触发全局 AJAX 事件.设置为 false 将不会触发全局 AJAX 事件,如 ajaxStart 或 ajaxStop 可用于控制不同的 Ajax 事件。
31. 如何在jQuery中克隆一个元素:

var cloned = $(‘#somediv’).clone();
32. 在jQuery中如何测试某个元素是否可见

if($(element).is(‘:visible’)) {
//该元素是可见的
}
33. 如何把一个元素放在屏幕的中心位置:

jQuery.fn.center = function () {
return this.each(function(){
$(this).css({
position:’absolute’,
top, ( $(window).height() – this.height() ) / 2 + $(window).scrollTop() + ‘px’,
left, ( $(window).width() – this.width() ) / 2 + $(window).scrollLeft() + ‘px’
});
});
}
//这样来使用上面的函数:
$(element).center();

34. 如何把有着某个特定名称的所有元素的值都放到一个数组中:

var arrInputValues = new Array();
$(“input[name=’xxx’]”).each(function(){
arrInputValues.push($(this).val());
});
35. 如何从元素中除去HTML

(function($) {
$.fn.stripHtml = function() {
var regexp = /<(“[^”]*”|'[^’]*’|[^'”>])*>/gi;
this.each(function() {
$(this).html( $(this).html().replace(regexp,”) );
});
return $(this);
}
})(jQuery);
//用法:
$(‘p’).stripHtml();
36. 如何使用closest来取得父元素:

$(‘#searchBox’).closest(‘div’);
37. 如何使用Firebug和Firefox来记录jQuery事件日志:

// 允许链式日志记录
jQuery.log = jQuery.fn.log = function (msg) {
if (console){
console.log(“%s: %o”, msg, this);
}
return this;
};
// 用法:
$(‘#someDiv’).hide().log(‘div hidden’).addClass(‘someClass’);
38. 如何强制在弹出窗口中打开链接:

$(‘a.popup’).live(‘click’, function(){
var newwindow = window.open($(this).attr(‘href’),”,’height=200,width=150′);
if (window.focus) {
newwindow.focus();
}
return false;
});
39. 如何强制在新的选项卡中打开链接:

$(‘a.newTab’).live(‘click’, function(){
var newwindow=window.open(this.href);
$(this).target = “_blank”;
return false;
});
40. 在jQuery中如何使用.siblings()来选择同辈元素

// 不这样做
$(‘#nav li’).click(function(){
$(‘#nav li’).removeClass(‘active’);
$(this).addClass(‘active’);
});
//替代做法是
$(‘#nav li’).click(function(){
$(this).addClass(‘active’).siblings().removeClass(‘active’);
});
41. 如何切换页面上的所有复选框:

var tog = false;
// 或者为true,如果它们在加载时为被选中状态的话
$(‘a’).click(function() {
$(“input[type=checkbox]”).attr(“checked”,!tog);
tog = !tog;
});
42. 如何基于一些输入文本来过滤一个元素列表:

//如果元素的值和输入的文本相匹配的话,该元素将被返回
$(‘.someClass’).filter(function() {
return $(this).attr(‘value’) == $(‘input#someId’).val();
})
43. 如何获得鼠标垫光标位置x和y

$(document).ready(function() {
$(document).mousemove(function(e){
$(’#XY’).html(”X Axis : ” + e.pageX + ” | Y Axis ” + e.pageY);
});
});
44. 如何扩展String对象的方法

$.extend(String.prototype, {
isPositiveInteger:function(){
return (new RegExp(/^[1-9]\d*$/).test(this));
},
isInteger:function(){
return (new RegExp(/^\d+$/).test(this));
},
isNumber: function(value, element) {
return (new RegExp(/^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/).test(this));
},
trim:function(){
return this.replace(/(^\s*)|(\s*$)|\r|\n/g, “”);
},
trans:function() {
return this.replace(/&lt;/g, ‘<‘).replace(/&gt;/g,’>’).replace(/&quot;/g, ‘”‘);
},
replaceAll:function(os, ns) {
return this.replace(new RegExp(os,”gm”),ns);
},
skipChar:function(ch) {
if (!this || this.length===0) {return ”;}
if (this.charAt(0)===ch) {return this.substring(1).skipChar(ch);}
return this;
},
isValidPwd:function() {
return (new RegExp(/^([_]|[a-zA-Z0-9]){6,32}$/).test(this));
},
isValidMail:function(){
return(new RegExp(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/).test(this.trim()));
},
isSpaces:function() {
for(var i=0; i<this.length; i+=1) {
var ch = this.charAt(i);
if (ch!=’ ‘&& ch!=”\n” && ch!=”\t” && ch!=”\r”) {return false;}
}
return true;
},
isPhone:function() {
return (new RegExp(/(^([0-9]{3,4}[-])?\d{3,8}(-\d{1,6})?$)|(^\([0-9]{3,4}\)\d{3,8}(\(\d{1,6}\))?$)|(^\d{3,8}$)/).test(this));
},
isUrl:function(){
return (new RegExp(/^[a-zA-z]+:\/\/([a-zA-Z0-9\-\.]+)([-\w .\/?%&=:]*)$/).test(this));
},
isExternalUrl:function(){
return this.isUrl() && this.indexOf(“://”+document.domain) == -1;
}
});
45. 如何规范化写jQuery插件:

(function($){
$.fn.extend({
pluginOne: function(){
return this.each(function(){
// my code
});
},
pluginTwo: function(){
return this.each(function(){
// my code
});
}
});
})(jQuery);
46. 如何检查图像是否已经被完全加载进来

$(‘#theImage’).attr(‘src’, ‘image.jpg’).load(function() {
alert(‘This Image Has Been Loaded’);
});
47. 如何使用jQuery来为事件指定命名空间:

//事件可以这样绑定命名空间
$(‘input’).bind(‘blur.validation’, function(e){
// …
});
//data方法也接受命名空间
$(‘input’).data(‘validation.isValid’, true);
48. 如何检查cookie是否启用

var dt = new Date();
dt.setSeconds(dt.getSeconds() + 60);
document.cookie = “cookietest=1; expires=” + dt.toGMTString();
var cookiesEnabled = document.cookie.indexOf(“cookietest=”) != -1;
if(!cookiesEnabled) {
//没有启用cookie
}
49. 如何让cookie过期:

var date = new Date();
date.setTime(date.getTime() + (x * 60 * 1000));
$.cookie(‘example’, ‘foo’, { expires: date });
50. 如何使用一个可点击的链接来替换页面中任何的URL

$.fn.replaceUrl = function() {
var regexp = /((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi;
return this.each(function() {
$(this).html(
$(this).html().replace(regexp,'<a href=”$1″>$1</a>’)
);
});
}
//用法
$(‘p’).replaceUrl();

jQuery的md5加密插件

下载:http://blog.greycode.cn/labs/jqmd5/jquery.md5.js

演示:http://blog.greycode.cn/labs/jqmd5/jquery.md5.html

/**
* jQuery MD5 hash algorithm function
*
* <code>
* Calculate the md5 hash of a String
* String $.md5 ( String str )
* </code>
*
* Calculates the MD5 hash of str using the » RSA Data Security, Inc. MD5 Message-Digest Algorithm, and returns that hash.
* MD5 (Message-Digest algorithm 5) is a widely-used cryptographic hash function with a 128-bit hash value. MD5 has been employed in a wide variety of security applications, and is also commonly used to check the integrity of data. The generated hash is also non-reversable. Data cannot be retrieved from the message digest, the digest uniquely identifies the data.
* MD5 was developed by Professor Ronald L. Rivest in 1994. Its 128 bit (16 byte) message digest makes it a faster implementation than SHA-1.
* This script is used to process a variable length message into a fixed-length output of 128 bits using the MD5 algorithm. It is fully compatible with UTF-8 encoding. It is very useful when u want to transfer encrypted passwords over the internet. If you plan using UTF-8 encoding in your project don’t forget to set the page encoding to UTF-8 (Content-Type meta tag).
* This function orginally get from the WebToolkit and rewrite for using as the jQuery plugin.
*
* Example
* Code
* <code>
* $.md5(“I’m Persian.”);
* </code>
* Result
* <code>
* “b8c901d0f02223f9761016cfff9d68df”
* </code>
*
* @alias Muhammad Hussein Fattahizadeh < muhammad [AT] semnanweb [DOT] com >
* @link http://www.semnanweb.com/jquery-plugin/md5.html
* @see http://www.webtoolkit.info/
* @license http://www.gnu.org/licenses/gpl.html [GNU General Public License]
* @param {jQuery} {md5:function(string))
* @return string
*/

(function($){

var rotateLeft = function(lValue, iShiftBits) {
return (lValue << iShiftBits) | (lValue >>> (32 – iShiftBits));
}

var addUnsigned = function(lX, lY) {
var lX4, lY4, lX8, lY8, lResult;
lX8 = (lX & 0x80000000);
lY8 = (lY & 0x80000000);
lX4 = (lX & 0x40000000);
lY4 = (lY & 0x40000000);
lResult = (lX & 0x3FFFFFFF) + (lY & 0x3FFFFFFF);
if (lX4 & lY4) return (lResult ^ 0x80000000 ^ lX8 ^ lY8);
if (lX4 | lY4) {
if (lResult & 0x40000000) return (lResult ^ 0xC0000000 ^ lX8 ^ lY8);
else return (lResult ^ 0x40000000 ^ lX8 ^ lY8);
} else {
return (lResult ^ lX8 ^ lY8);
}
}

var F = function(x, y, z) {
return (x & y) | ((~ x) & z);
}

var G = function(x, y, z) {
return (x & z) | (y & (~ z));
}

var H = function(x, y, z) {
return (x ^ y ^ z);
}

var I = function(x, y, z) {
return (y ^ (x | (~ z)));
}

var FF = function(a, b, c, d, x, s, ac) {
a = addUnsigned(a, addUnsigned(addUnsigned(F(b, c, d), x), ac));
return addUnsigned(rotateLeft(a, s), b);
};

var GG = function(a, b, c, d, x, s, ac) {
a = addUnsigned(a, addUnsigned(addUnsigned(G(b, c, d), x), ac));
return addUnsigned(rotateLeft(a, s), b);
};

var HH = function(a, b, c, d, x, s, ac) {
a = addUnsigned(a, addUnsigned(addUnsigned(H(b, c, d), x), ac));
return addUnsigned(rotateLeft(a, s), b);
};

var II = function(a, b, c, d, x, s, ac) {
a = addUnsigned(a, addUnsigned(addUnsigned(I(b, c, d), x), ac));
return addUnsigned(rotateLeft(a, s), b);
};

var convertToWordArray = function(string) {
var lWordCount;
var lMessageLength = string.length;
var lNumberOfWordsTempOne = lMessageLength + 8;
var lNumberOfWordsTempTwo = (lNumberOfWordsTempOne – (lNumberOfWordsTempOne % 64)) / 64;
var lNumberOfWords = (lNumberOfWordsTempTwo + 1) * 16;
var lWordArray = Array(lNumberOfWords – 1);
var lBytePosition = 0;
var lByteCount = 0;
while (lByteCount < lMessageLength) {
lWordCount = (lByteCount – (lByteCount % 4)) / 4;
lBytePosition = (lByteCount % 4) * 8;
lWordArray[lWordCount] = (lWordArray[lWordCount] | (string.charCodeAt(lByteCount) << lBytePosition));
lByteCount++;
}
lWordCount = (lByteCount – (lByteCount % 4)) / 4;
lBytePosition = (lByteCount % 4) * 8;
lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80 << lBytePosition);
lWordArray[lNumberOfWords – 2] = lMessageLength << 3;
lWordArray[lNumberOfWords – 1] = lMessageLength >>> 29;
return lWordArray;
};

var wordToHex = function(lValue) {
var WordToHexValue = “”, WordToHexValueTemp = “”, lByte, lCount;
for (lCount = 0; lCount <= 3; lCount++) {
lByte = (lValue >>> (lCount * 8)) & 255;
WordToHexValueTemp = “0” + lByte.toString(16);
WordToHexValue = WordToHexValue + WordToHexValueTemp.substr(WordToHexValueTemp.length – 2, 2);
}
return WordToHexValue;
};

var uTF8Encode = function(string) {
string = string.replace(/\x0d\x0a/g, “\x0a”);
var output = “”;
for (var n = 0; n < string.length; n++) {
var c = string.charCodeAt(n);
if (c < 128) {
output += String.fromCharCode(c);
} else if ((c > 127) && (c < 2048)) {
output += String.fromCharCode((c >> 6) | 192);
output += String.fromCharCode((c & 63) | 128);
} else {
output += String.fromCharCode((c >> 12) | 224);
output += String.fromCharCode(((c >> 6) & 63) | 128);
output += String.fromCharCode((c & 63) | 128);
}
}
return output;
};

$.extend({
md5: function(string) {
var x = Array();
var k, AA, BB, CC, DD, a, b, c, d;
var S11=7, S12=12, S13=17, S14=22;
var S21=5, S22=9 , S23=14, S24=20;
var S31=4, S32=11, S33=16, S34=23;
var S41=6, S42=10, S43=15, S44=21;
string = uTF8Encode(string);
x = convertToWordArray(string);
a = 0x67452301; b = 0xEFCDAB89; c = 0x98BADCFE; d = 0x10325476;
for (k = 0; k < x.length; k += 16) {
AA = a; BB = b; CC = c; DD = d;
a = FF(a, b, c, d, x[k+0], S11, 0xD76AA478);
d = FF(d, a, b, c, x[k+1], S12, 0xE8C7B756);
c = FF(c, d, a, b, x[k+2], S13, 0x242070DB);
b = FF(b, c, d, a, x[k+3], S14, 0xC1BDCEEE);
a = FF(a, b, c, d, x[k+4], S11, 0xF57C0FAF);
d = FF(d, a, b, c, x[k+5], S12, 0x4787C62A);
c = FF(c, d, a, b, x[k+6], S13, 0xA8304613);
b = FF(b, c, d, a, x[k+7], S14, 0xFD469501);
a = FF(a, b, c, d, x[k+8], S11, 0x698098D8);
d = FF(d, a, b, c, x[k+9], S12, 0x8B44F7AF);
c = FF(c, d, a, b, x[k+10], S13, 0xFFFF5BB1);
b = FF(b, c, d, a, x[k+11], S14, 0x895CD7BE);
a = FF(a, b, c, d, x[k+12], S11, 0x6B901122);
d = FF(d, a, b, c, x[k+13], S12, 0xFD987193);
c = FF(c, d, a, b, x[k+14], S13, 0xA679438E);
b = FF(b, c, d, a, x[k+15], S14, 0x49B40821);
a = GG(a, b, c, d, x[k+1], S21, 0xF61E2562);
d = GG(d, a, b, c, x[k+6], S22, 0xC040B340);
c = GG(c, d, a, b, x[k+11], S23, 0x265E5A51);
b = GG(b, c, d, a, x[k+0], S24, 0xE9B6C7AA);
a = GG(a, b, c, d, x[k+5], S21, 0xD62F105D);
d = GG(d, a, b, c, x[k+10], S22, 0x2441453);
c = GG(c, d, a, b, x[k+15], S23, 0xD8A1E681);
b = GG(b, c, d, a, x[k+4], S24, 0xE7D3FBC8);
a = GG(a, b, c, d, x[k+9], S21, 0x21E1CDE6);
d = GG(d, a, b, c, x[k+14], S22, 0xC33707D6);
c = GG(c, d, a, b, x[k+3], S23, 0xF4D50D87);
b = GG(b, c, d, a, x[k+8], S24, 0x455A14ED);
a = GG(a, b, c, d, x[k+13], S21, 0xA9E3E905);
d = GG(d, a, b, c, x[k+2], S22, 0xFCEFA3F8);
c = GG(c, d, a, b, x[k+7], S23, 0x676F02D9);
b = GG(b, c, d, a, x[k+12], S24, 0x8D2A4C8A);
a = HH(a, b, c, d, x[k+5], S31, 0xFFFA3942);
d = HH(d, a, b, c, x[k+8], S32, 0x8771F681);
c = HH(c, d, a, b, x[k+11], S33, 0x6D9D6122);
b = HH(b, c, d, a, x[k+14], S34, 0xFDE5380C);
a = HH(a, b, c, d, x[k+1], S31, 0xA4BEEA44);
d = HH(d, a, b, c, x[k+4], S32, 0x4BDECFA9);
c = HH(c, d, a, b, x[k+7], S33, 0xF6BB4B60);
b = HH(b, c, d, a, x[k+10], S34, 0xBEBFBC70);
a = HH(a, b, c, d, x[k+13], S31, 0x289B7EC6);
d = HH(d, a, b, c, x[k+0], S32, 0xEAA127FA);
c = HH(c, d, a, b, x[k+3], S33, 0xD4EF3085);
b = HH(b, c, d, a, x[k+6], S34, 0x4881D05);
a = HH(a, b, c, d, x[k+9], S31, 0xD9D4D039);
d = HH(d, a, b, c, x[k+12], S32, 0xE6DB99E5);
c = HH(c, d, a, b, x[k+15], S33, 0x1FA27CF8);
b = HH(b, c, d, a, x[k+2], S34, 0xC4AC5665);
a = II(a, b, c, d, x[k+0], S41, 0xF4292244);
d = II(d, a, b, c, x[k+7], S42, 0x432AFF97);
c = II(c, d, a, b, x[k+14], S43, 0xAB9423A7);
b = II(b, c, d, a, x[k+5], S44, 0xFC93A039);
a = II(a, b, c, d, x[k+12], S41, 0x655B59C3);
d = II(d, a, b, c, x[k+3], S42, 0x8F0CCC92);
c = II(c, d, a, b, x[k+10], S43, 0xFFEFF47D);
b = II(b, c, d, a, x[k+1], S44, 0x85845DD1);
a = II(a, b, c, d, x[k+8], S41, 0x6FA87E4F);
d = II(d, a, b, c, x[k+15], S42, 0xFE2CE6E0);
c = II(c, d, a, b, x[k+6], S43, 0xA3014314);
b = II(b, c, d, a, x[k+13], S44, 0x4E0811A1);
a = II(a, b, c, d, x[k+4], S41, 0xF7537E82);
d = II(d, a, b, c, x[k+11], S42, 0xBD3AF235);
c = II(c, d, a, b, x[k+2], S43, 0x2AD7D2BB);
b = II(b, c, d, a, x[k+9], S44, 0xEB86D391);
a = addUnsigned(a, AA);
b = addUnsigned(b, BB);
c = addUnsigned(c, CC);
d = addUnsigned(d, DD);
}
var tempValue = wordToHex(a) + wordToHex(b) + wordToHex(c) + wordToHex(d);
return tempValue.toLowerCase();
}
});
})(jQuery);