绝对脚本noob在这里,但是我遇到了一个问题,这个问题一直困扰着我3天。
我试图创建一个像降临日历一样的脚本。
所以: 2014年12月1日门一开, 2014年12月2日门二开(门一开门) 等...
现在我可能已经完全错了,但我现在得到的是:
$(function(){
// Event handler to close the current popup when clicking on widgets with the "close_when_clicked" extra css class
$('body').on('click', '.boxy-content.close_when_clicked', function(e){
if (!$(e.target).is('a')){
e.preventDefault();
var boxy = Boxy.get(this);
boxy.hideAndUnload();
}
});
var i,
current_day,
day,
startDate;
var $cal = $('.calendar'),
$prizes = $('.prizes > *'),
$lockedMsg = $('.locked_msg');
var now = new Date(),
totalDays = $prizes.length;
// change # of days displayed
$('span.total_days').text(totalDays);
// check for date override
var timenow_re = window.location.href.match(/timenow=([\w%]+)/);
if (timenow_re) {
var parsed = Date.parse(decodeURIComponent(timenow_re[1]));
if (parsed) {
now = new Date(parsed);
}
}
var nowDate = new Date(now.getFullYear(), now.getMonth(), now.getDate());
startDate = new Date(startYear, startMonth - 1, startDay);
secsPerDay = 1000 * 60 * 60 * 24;
currentDay = Math.floor( (nowDate - startDate + 1) / secsPerDay ) + 1;
// setup links for each day
for (i=1; i<=totalDays; i++) {
$cal.append('<a class="day' + ((i > currentDay) ? " locked" : " unlocked") + '" href="#" data-day="' + i + '">' + i + '</a>');
}
// unlocked click handler
$('.calendar .unlocked').attr('target', '').click(function(event) {
var day = $(event.target).data('day');
var prize = $prizes.get(day-1);
if (prize) {
var config = SST.widget_config(prize);
SST.widget_popup(config, this);
}
else {
ss_alert('There is no popup configured for Day ' + day + '. Add a Rich Text, Image, Promotion or Custom Form widget configured to display as a popup, then add it to the Calendar Settings.');
}
event.preventDefault();
});
// locked click handler
$('.calendar .locked').attr('target', '').click(function(event) {
var config = SST.widget_config($lockedMsg.get(0));
SST.widget_popup(config, this);
event.preventDefault();
});
});
</script>
&#13;
<a class="day unlocked" href="#" data-day="1" target="">1</a>
<a class="day unlocked" href="#" data-day="2" target="">2</a>
<a class="day unlocked" href="#" data-day="3" target="">3</a>
<a class="day unlocked" href="#" data-day="4" target="">4</a>
<a class="day unlocked" href="#" data-day="5" target="">5</a>
<a class="day unlocked" href="#" data-day="6" target="">6</a>
<a class="day unlocked" href="#" data-day="7" target="">7</a>
<a class="day unlocked" href="#" data-day="8" target="">8</a>
<a class="day unlocked" href="#" data-day="9" target="">9</a>
<a class="day unlocked" href="#" data-day="10" target="">10</a>
<a class="day unlocked" href="#" data-day="11" target="">11</a>
<a class="day unlocked" href="#" data-day="12" target="">12</a>
<a class="day unlocked" href="#" data-day="13" target="">13</a>
<a class="day unlocked" href="#" data-day="14" target="">14</a>
<a class="day unlocked" href="#" data-day="15" target="">15</a>
<a class="day unlocked" href="#" data-day="16" target="">16</a>
<a class="day unlocked" href="#" data-day="17" target="">17</a>
<a class="day unlocked" href="#" data-day="18" target="">18</a>
<a class="day locked" href="#" data-day="19" target="">19</a>
<a class="day locked" href="#" data-day="20" target="">20</a>
<a class="day locked" href="#" data-day="21" target="">21</a>
<a class="day locked" href="#" data-day="22" target="">22</a>
<a class="day locked" href="#" data-day="23" target="">23</a>
<a class="day locked" href="#" data-day="24" target="">24</a>
</div>
&#13;
HTML的类应更改为&#34;日锁定&#34;当日期是在12月1日之前。 然后在1日代码应该改变date-dat =&#34; 1&#34;到了#34;解锁日#39;等等。
有人能指点我如何在特定日期改变课程吗? (而不是所有的一次,但一次只有一天?)
提前致谢!!
编辑:我也试过一些PHP,但是
<a class="day <?php if(date('z') == 304 ) echo 'unlocked' ?> href="#" data-day="1" target="" ">1</a>
似乎没有用......