???????????????????????????
???????????? ???????[ 2012/9/29 14:44:22 ] ????????
?????????????????????????????????в????????????д??????????????????????з?????????С??????????????????????????????????????????????????????????????????????????????????????????????
?????????????????????????????TDD??????????????Щ????????????????????????????????????????????????????沿????????????????β????“?????????????”??
?????? “???????????jQuery????????????????????????????????????”
?????? “?????????Щ????????????????????????????????”
?????? “?????????????????????????????д????”
??????????????????????
???????????????????????????????????????в?????????????м??????????????????????????????
?????? ?????????
?????? ???????
?????? ???????/??????
??????????У?????????????????????????仰???????????????????????????????????????bug???????????£????bug?????????????????????????Щ??Ч?????????bug?????????????????Bug??????
??????????????bug???
??????????????????????????????bug???????????????????????????????????alert???????????????????????????????????????????????????
????????????????????????????????????????????Щ?????????????????????????????ú???????????Firebug Lite???????????????????????е???console.log???????????????????????????????
????????????????
??????????????????????????jQuery?????????????????datetime?????HTML5?е?time????????????????????data-datetime?????????е?innerHTML????????????????????????????磺“3 hours ago”????
jQuery.fn.differenceInWords = (function () {
var units = {
second: 1000??
minute: 1000 * 60??
hour: 1000 * 60 * 60??
day: 1000 * 60 * 60 * 24??
week: 1000 * 60 * 60 * 24 * 7??
month: 1000 * 60 * 60 * 24 * 30
};
function format(num?? type) {
return num + " " + type + (num > 1 ? "s" : "");
}
return function () {
this.each(function () {
var datetime = this.getAttribute("datetime") ||
this.getAttribute("data-datetime");
var diff = new Date(datetime) - new Date();
if (diff > units.month) {
this.innerHTML = "more than a month ago";
} else if (diff > units.week) {
this.innerHTML = format(Math.floor(diff / units.week)?? "week") + " ago";
} else {
var pieces = []?? num?? consider = ["day"?? "hour"?? "minute"?? "second"]?? measure;
for (var i = 0?? l = consider.length; i < l; ++i) {
measure = units[consider[i]];
if (diff > measure) {
num = Math.floor(diff / measure);
pieces.push(format(num?? consider[i]));
}
}
this.innerHTML = (pieces.length == 1 ? pieces[0] :
pieces.slice(0?? pieces.length - 1).join("?? ") + " and " +
pieces[pieces.length - 1]) + " ago";
}
});
};
}());
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11