注:本文使用的seajs版本是2.1.1
一、把Jquery封裝成seajs的模塊
//這里放置jquery代碼 把你喜歡的jquery版本放進來就好了
return $.noConflict();
});
調用方法:
這樣引進就可以像以前一樣使用jquery
// $(document).ready(function () {
// $("tr").wyhinterlaced({ "odd": "red", "even": "blue" });
// $("tr").wyhhover();
// })
});
var $ = require("../js/jquery");
var weekday = new Array(7)
weekday[0] = "星期一";
weekday[1] = "星期二";
weekday[2] = "星期三";
weekday[3] = "星期四";
weekday[4] = "星期五";
weekday[5] = "星期六";
weekday[6] = "星期日";
function GetType(arg) {
var today = new Date();
var year = today.getFullYear();
var month = today.getMonth() + 1;
var td = today.getDate();
var d = weekday[today.getDay() - 1];
var h = today.getHours();
var m = today.getMinutes();
var s = today.getSeconds();
switch (arg) {
case 1: //2013-09-09 09:31:56
return year + "-" + month + "-" + td + " " + h + ":" + m + ":" + s; break;
case 2: //2013-09-09 (星期一) 09:31:56
return year + "-" + month + "-" + td + " (" + d + ") " + h + ":" + m + ":" + s; break;
case 3: //09-09-2013 09:31:56
return month + "-" + td + "-" + year + " " + h + ":" + m + ":" + s; break;
case 4: //09-09-2013 星期一 09:31:56
return month + "-" + td + "-" + year + " (" + d + ") " + h + ":" + m + ":" + s; break;
case 5: //2013年09月09日 09時31分秒56
return year + "年" + month + "月" + td + "日 " + h + "時" + m + "分" + s + "秒"; break;
case 6: //2013年09月09日 星期一 09時31分秒56
return year + "年" + month + "月" + td + "日 (" + d + ") " + h + "時" + m + "分" + s + "秒"; break;
}
};
/*******************************************************
/*函數名:GetTime
/*參數:數值(包括整形浮點型都可以,浮點型會做四舍五入處理,如果不是數字,
函數將采用默認的時間格式返回!時間樣式有15【1-15是有效的時間樣式
超出或小于都將采用默認的樣式 樣式1】中)
/*功能 獲取當前的系統時間 可定制格式
*******************************************************/
function GetTime(arg) {
if (!isNaN(arg)) {
var num = Math.round(arg);
if (num < 7 && num > 0) {
return GetType(num);
}
else {
var str;
var str2;
switch (num) {
case 0: return GetType(1); break;
case 7: str = GetType(2); return str.replace(/星期/, ""); break;
case 8: str = GetType(1); return str.replace(/-/, "/").replace(/-/, "/"); break;
case 9: str = GetType(2); return str.replace(/-/, "/").replace(/-/, "/");
case 10: str = GetType(2); str2 = str.replace(/-/, "/").replace(/-/, "/"); return str2.replace(/星期/, ""); break;
case 11: str = GetType(4); return str.replace(/星期/, ""); break;
case 12: str = GetType(3); return str.replace(/-/, "/").replace(/-/, "/"); break;
case 13: str = GetType(4); return str.replace(/-/, "/").replace(/-/, "/");
case 14: str = GetType(4); str2 = str.replace(/-/, "/").replace(/-/, "/"); return str2.replace(/星期/, ""); break;
case 15: str = GetType(6); return str.replace(/星期/, "");
default: return GetType(1); break;
}
}
}
else {
return GetType(1);
}
};
/* 獲取系統的當前年數*/
function GetYear() {
var today = new Date();
return today.getFullYear();
};
/*獲取系統的當前的月數*/
function GetMonth() {
var today = new Date();
return today.getMonth() + 1; ;
};
/*獲取系統的當前的天數*/
function GetDay() {
var today = new Date();
return today.getDate(); ;
};
/*獲取系統的當前的小時*/
function GetHours() {
var today = new Date();
return today.getHours();
};
/*獲取系統的當前的分鐘*/
function GetMinute() {
var today = new Date();
return today.getMinutes();
};
/*獲取系統的當前的秒數*/
function GetSecond() {
var today = new Date();
return today.getSeconds();
};
/************************************************************
*函數名:TimeSubMillisecond
*參數:endtime(結束時間) starttime(起始時間)
*功能:獲取兩個時間的毫秒級的差值,必須寫一個參數 第二個參數(起始時間)可以
*不寫默認是系統當前時間
************************************************************/
function TimeSubMillisecond(endtime, starttime) {
var end = new Date(endtime).getTime();
if (!endtime) {
return -1;
}
if (!starttime) {
start = new Date().getTime();
}
else {
start = new Date(starttime).getTime();
}
if (start > end) {
return -1;
}
else {
return end - start;
}
};
/************************************************************
*函數名:TimeSubNormal
*參數:endtime(結束時間) starttime(起始時間)
*功能:獲取兩個時間的差值,必須寫一個參數 第二個參數(起始時間)可以
*不寫默認是系統當前時間
************************************************************/
function TimeSubNormal(endtime, starttime) {
var end = new Date(endtime).getTime();
var start;
if (!starttime) {
start = new Date().getTime();
}
else {
start = new Date(starttime).getTime();
}
if (start > end) {
return -1;
}
else {
var alltime = end - start;
var seconds = alltime / 1000;
var minutes = Math.floor(seconds / 60);
var hours = Math.floor(minutes / 60);
var days = Math.floor(hours / 24);
var CDay = days;
var CHour = hours % 24;
var CMinute = minutes % 60;
var CSecond = Math.floor(seconds % 60);
var str = "";
if (CDay > 0) {
str += CDay + "天";
}
if (CHour > 0) {
str += CHour + "小時";
}
if (CMinute > 0) {
str += CMinute + "分鐘";
}
if (CSecond > 0) {
str += CSecond + "秒";
}
return str;
}
};
exports.GetTime = GetTime;
exports.GetYear = GetYear;
exports.GetMonth = GetMonth;
exports.GetDay = GetDay;
exports.GetHours = GetHours;
exports.GetMinute = GetMinute;
exports.GetSecond = GetSecond;
exports.TimeSubMillisecond = TimeSubMillisecond;
exports.TimeSubNormal = TimeSubNormal;
})
調用方法:
alert(a.GetTime(3));
});
var obj = $.extend(defaultVal, options);
return this.each(function () {
var tabObject = $(this); //獲取當前對象
if(tabObject.index()%2==0)
{
tabObject.css("background-color", obj.odd);
}else
{
tabObject.css("background-color", obj.even);
}
});
}
})(jquery);
}
})
調用方法:
使用共享的方式調用插件
$(document).ready(function () {
$("tr").wyhinterlaced({ "odd": "red", "even": "blue" });
$("tr").wyhhover();
})
});
|
新聞熱點
疑難解答