王新阳

wangxinyang

artDialog 网页对话框插件

http://aui.github.io/artDialog/

通过预加载在图片加载前读取图片尺寸

/***************************************************************************************
 * 图片头数据加载就绪获取图片尺寸
 * @version	2011.05.27
 * @author	TangBin
 * @see		http://www.planeart.cn/?p=1121
 * @param	{String}	图片路径
 * @param	{Function}	尺寸就绪
 * @param	{Function}	加载完毕 (可选)
 * @param	{Function}	加载错误 (可选)
yundanran_imageSize('http://b.zol-img.com.cn/desk/bizhi/image/5/2560x1600/1409624254331.jpg', function ()
{
	alert('size ready: width=' + this.width + '; height=' + this.height);
});
*******************************************************************************************/
var yundanran_imageSize = (function () 
{
	var list = [], intervalId = null,

	// 用来执行队列
	tick = function () {
		var i = 0;
		for (; i < list.length; i++) {
			list[i].end ? list.splice(i--, 1) : list[i]();
		};
		!list.length && stop();
	},

	// 停止所有定时器队列
	stop = function () {
		clearInterval(intervalId);
		intervalId = null;
	};

	return function (url, ready, load, error) {
		var onready, width, height, newWidth, newHeight,
			img = new Image();
		
		img.src = url;

		// 如果图片被缓存,则直接返回缓存数据
		if (img.complete) {
			ready.call(img);
			load && load.call(img);
			return;
		};
		
		width = img.width;
		height = img.height;
		
		// 加载错误后的事件
		img.onerror = function () {
			error && error.call(img);
			onready.end = true;
			img = img.onload = img.onerror = null;
		};
		
		// 图片尺寸就绪
		onready = function () {
			newWidth = img.width;
			newHeight = img.height;
			if (newWidth !== width || newHeight !== height ||
				// 如果图片已经在其他地方加载可使用面积检测
				newWidth * newHeight > 1024
			) {
				ready.call(img);
				onready.end = true;
			};
		};
		onready();
		
		// 完全加载完毕的事件
		img.onload = function () {
			// onload在定时器时间差范围内可能比onready快
			// 这里进行检查并保证onready优先执行
			!onready.end && onready();
		
			load && load.call(img);
			
			// IE gif动画会循环执行onload,置空onload即可
			img = img.onload = img.onerror = null;
		};

		// 加入队列中定期执行
		if (!onready.end) {
			list.push(onready);
			// 无论何时只允许出现一个定时器,减少浏览器性能损耗
			if (intervalId === null) intervalId = setInterval(tick, 40);
		};
	};
})();

http://qianduanblog.com/post/js-learning-10-image-reload-size.html

AlloyImage 图像处理引擎

http://alloyteam.github.io/AlloyPhoto/

1.图层功能,提供图层的添加,删除,交换图层顺序等功能,且包含与PS相对应的17种图层混合模式
2.图像的基本调节功能,包括亮度、对比度,色相、饱和度、明度调节
3.多种滤镜功能,去色、反相、高斯模糊、锐化、浮雕效果、查找边缘、马赛克、腐蚀等
4.处理后文件的保存,处理完成之后,可以将文件输出为base64形式间接使用和保存
5.高级组合效果,如素描,lomo,复古,素描等复合效果 如一个素描效果的实现

jQuery Validation Engine 表单验证

中文:http://code.ciaoca.com/jquery/validation_engine/

https://github.com/posabsolute/jQuery-Validation-Engine

http://www.position-absolute.com/articles/jquery-form-validator-because-form-validation-is-a-mess/

学习这种通用的验证方式,不需要每个表单都那么麻烦地写一次验证

jQuery cxSelect 联动下拉菜单

中文:http://code.ciaoca.com/jquery/cxSelect/

https://github.com/ciaoca/cxSelect

jQuery Wookmark 瀑布流布局

中文:http://code.ciaoca.com/jquery/wookmark/demo/

http://www.wookmark.com/jquery-plugin

https://github.com/GBKS/Wookmark-jQuery

js生成二维码、条形码

QRCode.js 生成二维码

中文文档:http://code.ciaoca.com/javascript/qrcode/

http://github.com/davidshimjs/qrcodejs


jquery-barcode.js 生成条形码

http://www.cnblogs.com/yjmyzz/p/jquery-barcode.html

http://barcode-coder.com/en/barcode-jquery-plugin-201.html

<script>
var barcodeSettings = {
	output:'css',	//可选值:css/bmp/svg/canvas(后三种在IE9以下无效)
	bgColor: '#ffffff',	//背景色
	color: '#000000',	//前景色
	barWidth: 2,	//每单元宽度
	barHeight: 50,	//条码高度,对二维条码无效
	moduleSize: 5,	//仅类型为datamatrix(二维条码)时有效
	posX: 5,	//output=canvas时有效
	posY: 5,	//output=canvas时有效
	addQuietZone: 1	//仅类型为datamatrix(二维条码)时有效
},
type='code39',	//码制,可选值:ean8/ean1/upc/std25/int25/code11/code39/code93/code128/codebar/msi/datamatrix
str='0123456789';	//条码内容
$("#barcode").html("").show().barcode(str, type, barcodeSettings);
</script>

Exif.js 读取图像的元数据

中文文档:http://code.ciaoca.com/javascript/exif-js/

https://github.com/jseidelin/exif-js

Array.sort()

var arrDemo = new Array();
arrDemo[0] = 10;
arrDemo[1] = 50;
arrDemo[2] = 51;
arrDemo[3] = 100;
arrDemo.sort(); //调用sort方法后,数组本身会被改变,即影响原数组
alert(arrDemo); //10,100,50,51 默认情况下sort方法是按ascii字母顺序排序的,而非我们认为是按数字大小排序
arrDemo.sort(function(a,b){return a-b}); //从小到大排序
alert(arrDemo); //10,50,51,100
arrDemo.sort(function(a,b){return b-a}); //从大到小排序
alert(arrDemo); //100,51,50,10

1、数组调用sort方法后,会影响本身(而非生成新数组)
2、sort()方法默认是按字符来排序的,所以在对数字型数组排序时,不可想当然的以为会按数字大小排序!
3、要改变默认的sort行为(即按字符排序),可以自行指定排序规则函数(如本例所示)

jquery mobile动态添加元素

动态添加li

$('ul').append('<li>内容</li>').listview('refresh');

动态添加ul

$('div').append('<ul data-role="listview"><li>内容</li></ul>').trigger('create');

动态添加option

$('select').append('<option value="1">内容</option>').selectmenu('refresh');
2025-05-23 星期五 农历四月二十六