Skip to content

Instantly share code, notes, and snippets.

View xxjinwei's full-sized avatar
💻
Working...

Celile Fulwood xxjinwei

💻
Working...
View GitHub Profile
@xxjinwei
xxjinwei / days.js
Created August 7, 2014 06:19
Number of days in any month
function numberOfDays(year, month) {
var d = new Date(year, month, 0);
return d.getDate();
}
http://10.129.157.3:88/s/2.3/projects/profile/styles/applist.css
C:\Users\jinwei>npm install totoro
npm http GET https://registry.npmjs.org/totoro
npm http 304 https://registry.npmjs.org/totoro
npm http GET https://registry.npmjs.org/commander/1.2.0
npm http GET https://registry.npmjs.org/express/3.1.0
npm http GET https://registry.npmjs.org/colorful/2.1.0
npm http GET https://registry.npmjs.org/tracer/0.5.1
npm http GET https://registry.npmjs.org/request/2.21.0
npm http GET https://registry.npmjs.org/socket.io-client/0.9.11
@xxjinwei
xxjinwei / isAtBotton.js
Last active January 3, 2016 08:19
detect whether the scroll bar is at the end of page
//http://stackoverflow.com/questions/3898130/how-to-check-if-a-user-has-scrolled-to-the-bottom/10795797#10795797
function isAtBottom () {
var getDocHeight = function() {
var D = document;
return Math.max(
Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
Math.max(D.body.clientHeight, D.documentElement.clientHeight)
);
}
@xxjinwei
xxjinwei / transiton.css
Created December 18, 2013 09:05
transition css
.transition {
-webkit-transition: background-color 500ms ease-out 1s;
-moz-transition: background-color 500ms ease-out 1s;
-o-transition: background-color 500ms ease-out 1s;
transition: background-color 500ms ease-out 1s;
}
@xxjinwei
xxjinwei / offset.js
Created December 17, 2013 03:29
get offset
function getOffset (ele) {
var box = ele.getBoundingClientRect();
return {
top: box.top + (window.pageYOffset || document.documentElement.scrollTop) - (document.documentElement.clientTop || 0),
left: box.left + (window.pageXOffset || document.documentElement.scrollLeft) - (document.documentElement.clientLeft || 0)
};
};
@xxjinwei
xxjinwei / text-overflow.css
Created December 11, 2013 10:02
css text overflow
/**
referrence:http://leeiio.me/text-overflow-ellipsis/
*/
.overflow {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
-o-text-overflow: ellipsis;
@xxjinwei
xxjinwei / req.js
Last active December 29, 2015 15:09
ie6 http url max length
//Fuck ie6!!!!
//url length >= 2084 returns error code 0x7a
(function(length) {
var url = "http://zhushou.sogou.com/data/data.html?",
len = url.length,
str = new Array(length+1-len).join("u"),
img = new Image();
img.src = url+str;
@xxjinwei
xxjinwei / detect ie 8 and less.js
Last active December 27, 2015 23:49
ie浏览器检测
//ie8及以下浏览器
if (window.attachEvent && !window.addEventListener) {
// "bad" IE
}
//ie7及以下浏览器
if (window.attachEvent && !document.querySelector) {
// "bad" IE
}
@xxjinwei
xxjinwei / clone.js
Last active December 27, 2015 09:09
deepcopy from Snap.svg
/**
https://github.com/adobe-webplatform/Snap.svg/blob/master/src/svg.js#L214
*/
function clone(obj) {
if (typeof obj == "function" || Object(obj) !== obj) {
return obj;