hiphop111 โพสต์ 2010-1-2 16:33:40

[GTH] สคริปท์ นับถอยหลัง สู่วันสงกรานต์+วาเลนไทน์ 7.0/7.1/7.2

แก้ไขล่าสุดโดย hiphop111 เมื่อ 2010-1-15 20:29

หุหุ นี่ก็เพื่งผ่านปีใหม่ไป แม๊บๆ นี่ก็ใกล้จะถึง วันสงกรานต์ อีกแล้วครับท่าน อิอิ (นานแค่ไหนก็จะรอครับอิอิ)
อ้างอิงจากกระทู้นี้
http://www.discuzthai.com/thread-15254-1-1.html
ผมก็เลยนำมาดัดแปลง นิดหน่อยนะครับ

Live Demo : bbs.1000gth.co.cc


วิธีติดตั้ง
เปิดไฟล์ ./plugins/natz_shoutbox/template/shoutbox.htm

ค้นหา :<span class="headactions">เพิ่มโค้ดนี้ลงด้านล้างครับ :<script language="JavaScript">
TargetDate = "04/12/2010 00:00 AM";
BackColor = "#CCCC99";
ForeColor = "black";
CountActive = true;
CountStepper = -1;
LeadingZero = true;
DisplayFormat = "อีกแค่ %%D%% วัน, %%H%% ชั่วโมง, %%M%% นาที, %%S%% วินาทีก็วันสงกรานต์แล้ว!";
FinishMessage = "วันสงกรานต์!";


function calcage(secs, num1, num2) {
s = ((Math.floor(secs/num1))%num2).toString();
if (LeadingZero && s.length < 2)
    s = "0" + s;
return "<b>" + s + "</b>";
}

function CountBack(secs) {
if (secs < 0) {
    document.getElementById("cntdwn").innerHTML = FinishMessage;
    return;
}
DisplayStr = DisplayFormat.replace(/%%D%%/g, calcage(secs,86400,100000));
DisplayStr = DisplayStr.replace(/%%H%%/g, calcage(secs,3600,24));
DisplayStr = DisplayStr.replace(/%%M%%/g, calcage(secs,60,60));
DisplayStr = DisplayStr.replace(/%%S%%/g, calcage(secs,1,60));

document.getElementById("cntdwn").innerHTML = DisplayStr;
if (CountActive)
    setTimeout("CountBack(" + (secs+CountStepper) + ")", SetTimeOutPeriod);
}

function putspan(backcolor, forecolor) {
document.write("<span id='cntdwn' style='background-color:" + backcolor +
                "; color:" + forecolor + "'></span>");
}

if (typeof(BackColor)=="undefined")
BackColor = "white";
if (typeof(ForeColor)=="undefined")
ForeColor= "black";
if (typeof(TargetDate)=="undefined")
TargetDate = "12/31/2020 5:00 AM";
if (typeof(DisplayFormat)=="undefined")
DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.";
if (typeof(CountActive)=="undefined")
CountActive = true;
if (typeof(FinishMessage)=="undefined")
FinishMessage = "";
if (typeof(CountStepper)!="number")
CountStepper = -1;
if (typeof(LeadingZero)=="undefined")
LeadingZero = true;


CountStepper = Math.ceil(CountStepper);
if (CountStepper == 0)
CountActive = false;
var SetTimeOutPeriod = (Math.abs(CountStepper)-1)*1000 + 990;
putspan(BackColor, ForeColor);
var dthen = new Date(TargetDate);
var dnow = new Date();
if(CountStepper>0)
ddiff = new Date(dnow-dthen);
else
ddiff = new Date(dthen-dnow);
gsecs = Math.floor(ddiff.valueOf()/1000);
CountBack(gsecs);

</script>
เสร็จแล้ว save เลยครับแล้วนำอัพไฟล์ไปยังตำแหน่งเดิม
แล้วทำการ อัพเดชแคช

ครับผม~






ปล. ใส่ที่ไหนก็ได้ครับผม ^^

xman โพสต์ 2010-1-2 16:58:11

วันวาเลนไทน์ฮะ
ตัวอย่าง
http://asian-cafe.org/bbs/<script language="JavaScript">
TargetDate = "2/14/2010 00:00 AM";
BackColor = "#c0e9f8";
ForeColor = "black";
CountActive = true;
CountStepper = -1;
LeadingZero = true;
DisplayFormat = "อีกแค่ %%D%% วัน, %%H%% ชั่วโมง, %%M%% นาที, %%S%% วินาทีก็ถึงวันวาเลนไทน์แล้ว";
FinishMessage = "Happy Valentine Day!!!!!";


function calcage(secs, num1, num2) {
s = ((Math.floor(secs/num1))%num2).toString();
if (LeadingZero && s.length < 2)
    s = "0" + s;
return "<b>" + s + "</b>";
}

function CountBack(secs) {
if (secs < 0) {
    document.getElementById("cntdwn").innerHTML = FinishMessage;
    return;
}
DisplayStr = DisplayFormat.replace(/%%D%%/g, calcage(secs,86400,100000));
DisplayStr = DisplayStr.replace(/%%H%%/g, calcage(secs,3600,24));
DisplayStr = DisplayStr.replace(/%%M%%/g, calcage(secs,60,60));
DisplayStr = DisplayStr.replace(/%%S%%/g, calcage(secs,1,60));

document.getElementById("cntdwn").innerHTML = DisplayStr;
if (CountActive)
    setTimeout("CountBack(" + (secs+CountStepper) + ")", SetTimeOutPeriod);
}

function putspan(backcolor, forecolor) {
document.write("<span id='cntdwn' style='background-color:" + backcolor +
                "; color:" + forecolor + "'></span>");
}

if (typeof(BackColor)=="undefined")
BackColor = "white";
if (typeof(ForeColor)=="undefined")
ForeColor= "black";
if (typeof(TargetDate)=="undefined")
TargetDate = "12/31/2020 5:00 AM";
if (typeof(DisplayFormat)=="undefined")
DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.";
if (typeof(CountActive)=="undefined")
CountActive = true;
if (typeof(FinishMessage)=="undefined")
FinishMessage = "";
if (typeof(CountStepper)!="number")
CountStepper = -1;
if (typeof(LeadingZero)=="undefined")
LeadingZero = true;


CountStepper = Math.ceil(CountStepper);
if (CountStepper == 0)
CountActive = false;
var SetTimeOutPeriod = (Math.abs(CountStepper)-1)*1000 + 990;
putspan(BackColor, ForeColor);
var dthen = new Date(TargetDate);
var dnow = new Date();
if(CountStepper>0)
ddiff = new Date(dnow-dthen);
else
ddiff = new Date(dthen-dnow);
gsecs = Math.floor(ddiff.valueOf()/1000);
CountBack(gsecs);

</script>

hiphop111 โพสต์ 2010-1-2 17:01:33

ตอบกลับ 2# xman

ขอบคุณครับท่าน xman ^^

leonna โพสต์ 2010-1-2 19:17:29

ขอขอบคุณเเละขอเป็นกำลังใจในการโพสงานดีๆครับ

JARIRIS โพสต์ 2010-1-2 19:50:23

น่าสนใจมากค่ะ ขอบคุณมากๆ

tanachai โพสต์ 2010-1-4 01:54:31

น่าสนใจมาก

sutouch โพสต์ 2010-1-4 10:19:48

ขอบคุณมากคร้าบบบบบบบบ

nontawat1996 โพสต์ 2010-1-4 10:31:02

หวังว่าคงไม่เหมือนอันเก่า

ของผมมันเอาเวลาจากเครื่องอะ น่าจะเอาจากเซิฟเวอร์ ขอไปลองแล้วละกัน ^^

sam10102539 โพสต์ 2010-1-4 11:02:00

ดีครับ ขอบคุนคับ
fuffugugug

sam10102539 โพสต์ 2010-1-4 11:03:23

ggggggggooooooooooooooooooooooogddddddddddddddd
-v[86o8y[   =ขอบคุนคับ
หน้า: [1] 2 3
ดูในรูปแบบกติ: [GTH] สคริปท์ นับถอยหลัง สู่วันสงกรานต์+วาเลนไทน์ 7.0/7.1/7.2