...

View Full Version : Count Up Script?



F0u4d
05-25-2012, 11:17 PM
Hey :( I searched a lot on Google and many other places but couldn't find what i want... It's simple..

I need a count up script for football that starts counting on a certain date i add... after it starts counting from 0' mins until 45' after that i want it to show a word "Half Time"...
if possible in the same script after 15 mins the script start counting from 45' to 90' after it reach minute 90 i want it to write "Finished" and stop..
but please i want it to keep counting even if i refresh the page not start over or something like that..
if making the script start counting again from 45 to 90 after 15 mins is impossible to do it then its ok with a script to count from 0 to 45 then show "HalfTime" and a script to count from 45 to 90 and show "Finished"

answers and help are much appreciated really!!!!! i found tons of coupt up scripts but couldn't be able to get it in the way i want coz of my lack in Javascript :(

Thanks in Advance!!!

Krupski
05-26-2012, 04:32 AM
Hey :( I searched a lot on Google and many other places but couldn't find what i want... It's simple..

I need a PHP count up script for football that starts counting on a certain date i add... after it starts counting from 0' mins until 45' after that i want it to show a word "Half Time"...
if possible in the same script after 15 mins the script start counting from 45' to 90' after it reach minute 90 i want it to write "Finished" and stop..
but please i want it to keep counting even if i refresh the page not start over or something like that..
if making the script start counting again from 45 to 90 after 15 mins is impossible to do it then its ok with a script to count from 0 to 45 then show "HalfTime" and a script to count from 45 to 90 and show "Finished"

answers and help are much appreciated really!!!!! i found tons of coupt up scripts but couldn't be able to get it in the way i want coz of my lack in Javascript :(

Thanks in Advance!!!

You posted in a Javascript forum, then asked for a PHP script, then mentioned a lack of knowledge in Javascript.

What exactly do you need (i.e. Javascript or PHP)?

F0u4d
05-26-2012, 07:27 AM
Sorry mate i added PHP by mistake :) Sorry!

Philip M
05-26-2012, 07:29 AM
This forum is not a free coding service. As a general rule, the people helping out in this forum don't write code for others, but try to help with fixing code that doesn't work. You may perhaps get someone to write this script for you, but you'll be far more likely to get help if you have made a substantial effort and written some code yourself. Then someone here will almost certainly help you correct/improve your work.


All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

F0u4d
05-26-2012, 07:53 AM
Well sorry, i posted my questions because i seen other threads with people asking for codes, so i thought that's how it works in here :)

Well I Have this Football Timer script

timer.js

// Class: Timer
var Timer = function (callback) {
// Property: Frequency of elapse event of the timer in milliseconds
this.Interval = 1000;

// Property: Whether the timer is enable or not
this.Enable = new Boolean(false);

// Event: Timer tick
this.Tick = callback;

// Member variable: Hold interval id of the timer
var timerId = 0;

// Member variable: Hold instance of this class
var thisObject;

// Function: Start the timer
this.Start = function () {
this.Enable = new Boolean(true);

thisObject = this;
if (thisObject.Enable) {
thisObject.timerId = setInterval(
function () {
thisObject.Tick();
}, thisObject.Interval);
}
};

// Function: Stops the timer
this.Stop = function () {
thisObject.Enable = new Boolean(false);
clearInterval(thisObject.timerId);
};

};

// Namespace: Match rules and timings
var Match = {

Timers: {
FirstHalf: new Timer(TimerTick),
HalfTime: new Timer(TimerTick),
SecondHalf: new Timer(TimerTick),
TickCount: -1
},

Strings: {
FirstHalf: 'First Half',
HalfTime: 'Half Time',
SecondHalf: 'Second Half',
FullTime: 'Finished'
},

DisplayTime: function (t) {
var m = parseInt(t / 60);
var s = t % 60;
return (m < 10 ? '0' + m : m) + ":" + (s < 10 ? '0' + s : s);
}
};

// Function: Tick Event Handler (callback function)
function TimerTick(timer) {

// Document elements used.
var TimerP = document.getElementById('time');
var DisplayP = document.getElementById('display');

// During First Half
if (Match.Timers.FirstHalf.Enable == true) {
if (Match.Timers.TickCount == -1) { Match.Timers.TickCount = 0 }
if (Match.Timers.TickCount == 2700) {
Match.Timers.FirstHalf.Stop();
Match.Timers.TickCount = -1;
Match.Timers.HalfTime.Start();
} else {
TimerP.innerHTML = Match.DisplayTime(Match.Timers.TickCount);
DisplayP.innerHTML = Match.Strings.FirstHalf;
Match.Timers.TickCount++;
}
}

// During Half Time
else if (Match.Timers.HalfTime.Enable == true) {
if (Match.Timers.TickCount == -1) { Match.Timers.TickCount = 0 }
if (Match.Timers.TickCount == 900) {
Match.Timers.HalfTime.Stop();
Match.Timers.TickCount = -1;
Match.Timers.SecondHalf.Start();
} else {
TimerP.innerHTML = '45:00';
DisplayP.innerHTML = Match.Strings.HalfTime + ' (' + Match.DisplayTime(900 - Match.Timers.TickCount) + ')';
Match.Timers.TickCount++;
}
}

// During Second Half
else if (Match.Timers.SecondHalf.Enable == true) {
if (Match.Timers.TickCount == -1) { Match.Timers.TickCount = 2700 }
if (Match.Timers.TickCount == 5400) {
TimerP.innerHTML = '90:00';
DisplayP.innerHTML = Match.Strings.FullTime;
Match.Timers.SecondHalf.Stop();
Match.Timers.TickCount = -1;
} else {
TimerP.innerHTML = Match.DisplayTime(Match.Timers.TickCount);
DisplayP.innerHTML = Match.Strings.SecondHalf;
Match.Timers.TickCount++;
}
}
}

function KickOff() {
var btn = document.getElementById('btnKickOff');
btn.setAttribute('style','display: none;');
Match.Timers.FirstHalf.Start();
}


HTML :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<!-- Start Meta Block -->
<meta content="text/html; charset=iso-8859-1" http-equiv="content-type" />
<meta content="Simple Football Match Timer" name="description" />
<meta content="Simple, Football, Match, Timer" name="keywords" />
<meta content="all,index,follow" name="robots" />
<meta content="noodp" name="msnbot" />
<meta content="global" name="distribution" />
<!-- End Meta Block-->
<title>Simple Football Match Timer</title>
<script src="timer.js" type="text/javascript"></script>
</head>

<body>
<form id="pageForm" runat="server">
<div>
<p id="display">Waiting for kick off.</p>
<p id="time">00:00</p>
<input id="btnKickOff" type="button" value="Kick Off!" onclick="KickOff();" />
</div>
</form>
</body>
</html>

I need help in making it count when i start it and keep counting even when i refresh the page, so i can let users visiting my site see the current games played with what time...

F0u4d
05-26-2012, 08:47 AM
@iBall Thanks man :)
this script i have works good but it restart all when i refresh the page.. i want to make it keep counting when i click the button so users that log my site will be able to see what time of the match is now..
I hope u got what i mean :)
Thanks



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum