呵呵,半个小时的努力
终于把校历做好了。博客园的日历控件的id写的不是很全,做着好麻烦。不过还是做成了。
快毕业了,所以也没心思再写一个比较通用的代码~
能用到毕业就行了。
这样再也不用天天查校历看是第几周了。
呵呵。源代码(ECMAScript)如下:
快毕业了,所以也没心思再写一个比较通用的代码~
能用到毕业就行了。
这样再也不用天天查校历看是第几周了。
呵呵。源代码(ECMAScript)如下:
<Script>
<!--
function GetToday(table){
for(i=0; i< table.cells.length; i++){
var cell = table.cells.item(i);
if(cell.className == "CalTodayDay"){
return Number(cell.innerText);
}
}
return 0;
}
function GetCalTitleCell(table){
innerTable = table.cells.item(0).children[0];
return innerTable.cells.item(1);
}
function GetMonth(table){
cell = GetCalTitleCell(table);
Mon = cell.innerText.substr(5,1);
return Number(Mon);
}
function GetSchoolWeek(Month, Day){
var BaseDay = 3;
var BaseWeek = 7;
var days = 0;
switch(Month){
case 4:
days += Day - BaseDay;
break;
case 5:
days += Day + 30 - BaseDay;
break;
case 6:
days += Day + 31 + 30 - BaseDay;
break;
case 7:
days += Day + 30 + 31 + 30 - BaseDay;
break;
}
return Number((days / 7 + BaseWeek).toString().substr(0, 1));
}
function RenderCalTitleCell(Cell){
Mon = GetMonth(entryCal);
Day = GetToday(entryCal);
Cell.innerHTML += " <acronym title='校历'>第" + GetSchoolWeek(Mon, Day) + "周</acronym>";
}
RenderCalTitleCell(GetCalTitleCell(entryCal));
-->
</Script>
<!--
function GetToday(table){
for(i=0; i< table.cells.length; i++){
var cell = table.cells.item(i);
if(cell.className == "CalTodayDay"){
return Number(cell.innerText);
}
}
return 0;
}
function GetCalTitleCell(table){
innerTable = table.cells.item(0).children[0];
return innerTable.cells.item(1);
}
function GetMonth(table){
cell = GetCalTitleCell(table);
Mon = cell.innerText.substr(5,1);
return Number(Mon);
}
function GetSchoolWeek(Month, Day){
var BaseDay = 3;
var BaseWeek = 7;
var days = 0;
switch(Month){
case 4:
days += Day - BaseDay;
break;
case 5:
days += Day + 30 - BaseDay;
break;
case 6:
days += Day + 31 + 30 - BaseDay;
break;
case 7:
days += Day + 30 + 31 + 30 - BaseDay;
break;
}
return Number((days / 7 + BaseWeek).toString().substr(0, 1));
}
function RenderCalTitleCell(Cell){
Mon = GetMonth(entryCal);
Day = GetToday(entryCal);
Cell.innerHTML += " <acronym title='校历'>第" + GetSchoolWeek(Mon, Day) + "周</acronym>";
}
RenderCalTitleCell(GetCalTitleCell(entryCal));
-->
</Script>