#记录&分享
欢迎小伙伴找我玩,我是前端女码农gigi ^_^ 这里会有我的学习历程和一些 文章。
其他联系方式
- twitter:@gigiovo
- 微博:gigi13164269
#记录&分享
欢迎小伙伴找我玩,我是前端女码农gigi ^_^ 这里会有我的学习历程和一些 文章。
其他联系方式
- twitter:@gigiovo
- 微博:gigi13164269
/**
02
* jQuery 扩展方法
03
*
04
* $.Object.count( p )
05
* 获取一个对象的长度,需要指定上下文,通过 call/apply 调用
06
* 示例: $.Object.count.call( obj, true );
07
* @param {p} 是否跳过 null / undefined / 空值
08
*
09
*/
10
$.extend({
// 获取对象的长度,需要指定上下文 this
Object: {
count: function( p ) {
p = p || false;
return $.map( this, function(o) {
if( !p ) return o;
return true;
} ).length;
}
}
});
// 示例
27
// ---------------------------------------------------------------------------
28
var obj = {
29
a: null,
30
b: undefined,
31
c: 1,
32
d: 2,
33
e: 'test'
34
};
35
36
// 不过滤空值
37
console.log( $.Object.count.call( obj ) );
38
39
// 过滤空值
40
console.log( $.Object.count.call( obj, true ) );
学习angularJs
<script type="text/javascript">
/*
* 获得时间差,时间格式为 年-月-日 小时:分钟:秒 或者 年/月/日 小时:分钟:秒
* 其中,年月日为全格式,例如 : 2010-10-12 01:00:00
* 返回精度为:秒,分,小时,天
*/
function GetDateDiff(startTime, endTime, diffType) {
//将xxxx-xx-xx的时间格式,转换为 xxxx/xx/xx的格式
startTime = startTime.replace(/\-/g, "/");
endTime = endTime.replace(/\-/g, "/");
//将计算间隔类性字符转换为小写
diffType = diffType.toLowerCase();
var sTime = new Date(startTime); //开始时间
var eTime = new Date(endTime); //结束时间
//作为除数的数字
var divNum = 1;
switch (diffType) {
case "second":
divNum = 1000;
break;
case "minute":
divNum = 1000 * 60;
break;
case "hour":
divNum = 1000 * 3600;
break;
case "day":
divNum = 1000 * 3600 * 24;
break;
default:
break;
}
return parseInt((eTime.getTime() - sTime.getTime()) / parseInt(divNum));
}
var result = GetDateDiff("2010-02-26 16:00:00", "2011-07-02 21:48:40", "day");
document.write("简明现代魔法 www.nowamagic.net 建站已有" + result + "天了。");
//alert(result);
</script>
两位小数: Math.round($('input[name=aaa]').val()*100)/100,
seajs.setLocale('zh-cn');//设置本地语言
markdown editor : http://25.io/mou/
正则去掉右侧逗号
var reg=/,$/gi;
orders=orders.replace(reg,"");
数组转字符串
需要将数组元素用某个字符连接成字符串,示例代码如下:
var a, b;
a = new Array(0,1,2,3,4);
b = a.join("-");
字符串转数组
实现方法为将字符串按某个字符切割成若干个字符串,并以数组形式返回,示例代码如下:
var s = "abc,abcd,aaa";
ss = s.split(",");// 在每个逗号(,)处进行分解。
参考cookie/session机制详解、COOKIE和SESSION有什么区别?
源起:跟踪用户的会话,HTTP协议为无状态协议
cookie:
session:
安全性(tocken相关):CSRF、防止表单重复提交
Zen Coding http://www.zhihu.com/question/20041681
某种文件类型语法高亮: view->sytax->选择一种文件类型
var selectLen= $('select[name=aa] option').length;
for(var i=0; i<selectLen; i++){
if($('select[name=aa] option').eq(i).val() == value){
$('select[name=aa]').get(0).options[i].selected = true;
}
}
function getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]); return null;
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.