2Hi.Biz
Trang chủ | TWIG | Xtscript | Templates | Xtgem
[Chia sẻ] Code javascript sinh nhat theo tuần cho wapka | Wapka | Wapmaster - 2Hi.Biz
▼ [Chia sẻ] Code javascript sinh nhat theo tuần cho wapka
* Admin
- Cấp bậc: admin
19-03-2014
Code này đã sửa
hoàn chỉnh mọi người có thể edit theo ý với những từ tiếng việt và sửa %prvar-5% theo ngày
%prvar-8% là var tháng theo var của wap mình cho phù hợp
<div class="t"><head>
<script type="text/javascript">
//the bday array data can be generated from server-side
var arrBday = [:userstats:d=ru, l=50000, s=1, o=dl,::
  ['<a href="%urlprofile%">%name%</a>', '%prvar-8%/%prvar-5%'], ::  :/userstats: 
  ['Admin', '1/19']
  //...and so on (last entry must not have a trailing comma )
];

function getBdaysThisWeek(){
  var arrMonth = new Array("Tháng  1 ngày", "Tháng 2 ngày", "Tháng  3ngày", "Tháng 4 ngày", "Tháng 5 ngày", "Tháng 6 ngày", "Tháng 7 ngày","Tháng 8 ngày", "Tháng 9 ngày", "Tháng 10 ngày", "Tháng 11 ngày", "Tháng 12 ngày");
  var bday, idx;
  var bdayList = new Array();
  var today = new Date();

  for 0{
    var bday = new Date0);
    if (isNaN(bday)) continue;

    if ( isBdayInRange(bday, 7) ){
       idx = bdayList.length;
       bdayList[idx] = new Object();
       bdayList[idx].name = arrBday[i][0];
       bdayList[idx].bday = bday;
       bdayList[idx].month = arrMonth[bday.getMonth()];      
    }
  }
  if (bdayList.length > 0){ //sort asc by birthdate
     bdayList.sort(
       function(a, b){
         if (a.bday < b.bday) return -1
         if (a.bday > b.bday) return 1;
         return 0;
       }
     );
  }
  return bdayList;
}

function isBdayInRange(bday, interval){
//Idea for this function goes to:
//- http://van-thu.tk  coding
//
  var today = new Date(); 
  //have to override time so entire day will be valid
  today.setHours(0,0,0,0);
  //if the birthday has already occurred in the year, increment to the next year
  if (bday < today)
    bday.setFullYear(bday.getFullYear() + 1);
  
  // get ms between dates (UTC) and make into "difference" date
  var iDiffMS = bday.valueOf0;
  //divide iDiffMS by 1000, Seconds, Minutes, Hours
  nDays = parseInt0;
  
  if(parseInt(nDays) <= parseInt(interval))
    return true;
  else
    return false;
}

function displayBdayList(){
  var date = new Date().getDate(); 
  var bdayList = getBdaysThisWeek();
  var len = bdayList.length;
  var s = "<h1>Sinh nhật trong tuần:</h1>";
  if (len>0){
    s += '<ul>';
    for 0{
       //be mindful of the string-line continuation character (\) at the end of the first line
  s += '<li' + ((date == bdayList[i].bday.getDate())?' class="bdayToday"':'')+ '>\
     <strong>' + bdayList[i].name + '</strong> - ' 
     + bdayList[i].month + ' ' + bdayList[i].bday.getDate() + '</li>';       
    }
    s += '</ul>';
  }
  else{
    s += "No birthday";
  }
  document.write(s);
}
</script>
<style type="text/css">
body {
  font:14px Verdana;
}
/*display style when bday is today*/
.bdayToday {
  color: blue;
}
</style>
</head>
<body>
<script type="text/javascript">
displayBdayList();
</script></body></div>
▲ Tổng số: 1
- Share:
BBCode:

Link:
Online: Guests: 1

Từ khóa: wapka , tuần , [Chia , theo , cho