Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    May 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Count Up Script?

    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!!!
    Last edited by F0u4d; 05-26-2012 at 07:27 AM.

  • #2
    Regular Coder Krupski's Avatar
    Join Date
    Dec 2010
    Location
    United States of America
    Posts
    505
    Thanks
    39
    Thanked 47 Times in 46 Posts
    Quote Originally Posted by F0u4d View Post
    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)?
    "Anything that is complex is not useful and anything that is useful is simple. This has been my whole life's motto." -- Mikhail T. Kalashnikov

  • #3
    New to the CF scene
    Join Date
    May 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry mate i added PHP by mistake Sorry!

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,035
    Thanks
    203
    Thanked 2,539 Times in 2,517 Posts
    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.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #5
    New to the CF scene
    Join Date
    May 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    Code:
    // 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 :
    Code:
    <!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...

  • #6
    New to the CF scene
    Join Date
    May 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    @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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •