身份证号码校验
function idCardValid(a) { var c, d, e, f, g, h, b = a; if ("" === b) return !1; if (/^\d{17}[\dXx]$/.test(b) === !1) return !1; if (c = [ 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 ], d = [ "1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2" ], e = 0, f = 0, 15 == b.length) { for (b = b.substr(0, 6) + "19" + b.substr(6), f = 0; 17 > f; f++) e += b.substr(f, 1) * c[f]; b += d[e % 11]; } if (g = { 11:"北京", 12:"天津", 13:"河北", 14:"山西", 15:"内蒙古", 21:"辽宁", 22:"吉林", 23:"黑龙江", 31:"上海", 32:"江苏", 33:"浙江", 34:"安徽", 35:"福建", 36:"江西", 37:"山东", 41:"河南", 42:"湖北", 43:"湖南", 44:"广东", 45:"广西", 46:"海南", 50:"重庆", 51:"四川", 52:"贵州", 53:"云南", 54:"西藏", 61:"陕西", 62:"甘肃", 63:"青海", 64:"宁夏", 65:"新疆", 71:"台湾", 81:"香港", 82:"澳门", 91:"国外" }, void 0 == g[b.substr(0, 2)]) return !1; if (h = [ b.substr(6, 4), b.substr(10, 2), b.substr(12, 2) ], h.push(new Date(h.join("-"))), h.push(new Date().getFullYear()), h[3].getFullYear() != h[0] || h[3].getMonth() + 1 != h[1] || h[3].getDate() != h[2]) return !1; if (h[4] - h[0] < 0 || h[4] - h[0] > 120) return !1; if (15 == a.length) return !0; for (f = 0; 17 > f; f++) e += b.substr(f, 1) * c[f]; return d[e % 11] == b.substr(17, 1); }
使用js获取用户openid
通过自定义菜单打开url,在网页中用js获取用户openid:
一、回复一条图文消息,将用户openid带在链接上
二、认证服务号可以使用高级接口。参考:
https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140842
http://blog.csdn.net/baronyang/article/details/44489841
http://blog.csdn.net/qq_30632003/article/details/52882592
jQueryUI拖拽排序部件 sortable
DEMO http://jqueryui.com/sortable/
API http://api.jqueryui.com/sortable/
KindEditor编辑器的bug
解决办法:/lang/zh-CN.js 或 kindeditor-all-min.js中把Microsoft Yahei直接替换为中文微软雅黑
2、响应式网站,后台发布新闻等内容时,通常不需要给图片设置宽度和高度,但编辑器图片插件中删除图片宽高中的一项,另一项会变为NaN,
修改kindeditor-all-min.js中的图片插件(或plugins/image/image.js中相应部分):
D.change(function(){J>0&&E.val(Math.round(K/J*parseInt(this.value,10)))}),E.change(function(){K>0&&D.val(Math.round(J/K*parseInt(this.value,10)))})
改为:
D.change(function(){this.value&&J>0&&E.val(Math.round(K/J*parseInt(this.value,10)))}),E.change(function(){this.value&&K>0&&D.val(Math.round(J/K*parseInt(this.value,10)))})
浏览器全屏
function fullscreen(){ elem=document.body; if(elem.webkitRequestFullScreen){ elem.webkitRequestFullScreen(); }else if(elem.mozRequestFullScreen){ elem.mozRequestFullScreen(); }else if(elem.requestFullScreen){ elem.requestFullscreen(); }else{ //浏览器不支持全屏API或已被禁用 } } function exitFullscreen(){ var elem=document; $("#fullscreen").show(); if(elem.webkitCancelFullScreen){ elem.webkitCancelFullScreen(); }else if(elem.mozCancelFullScreen){ elem.mozCancelFullScreen(); }else if(elem.cancelFullScreen){ elem.cancelFullScreen(); }else if(elem.exitFullscreen){ elem.exitFullscreen(); }else{ //浏览器不支持全屏API或已被禁用 } }
js基础知识
WINDOW对象的 postMessage() 方法用于安全地实现跨域通信。
otherWindow.postMessage(message, targetOrigin, [transfer]);
参考:
https://www.w3cschool.cn/fetch_api/fetch_api-lx142x8t.html
https://www.runoob.com/js/met-win-postmessage.html
https://www.jianshu.com/p/ae840f7d7f8b
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/
学习这种通用的验证方式,不需要每个表单都那么麻烦地写一次验证