Any Bored Programmers?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Bama
    Confirmed User
    • Nov 2001
    • 2727

    #1

    Any Bored Programmers?

    So I was looking around for a script kinda' like the debt clock but on a much smaller scale and after a few hours of looking finally came across a thread that got close to what I wanted.

    Variables I'd like to have:

    Count up in cents and show that in the count
    Set how much (in dollars) it counts up every 24 hours (thinking around 5 or 6 bucks/day)
    Set starting amount (does this already)

    PHP Code:
    <html>
    <head>
    <script type="text/javascript">
    function startTime()
    {
       var today=new Date();
       var h=today.getHours();
       var m=today.getMinutes();
       var s=today.getSeconds();
       var ms=today.getTime();
       var moneySavedPerSecond = 5.47;/*in dollars*/
       var startDate = 1301802459944;/*In milliseconds from Jan 1, 1970*/
       var startSavings = 1000;
       var totalSaved=Math.round(((ms-startDate)/1000)*moneySavedPerSecond+startSavings);
       // add a zero in front of numbers<10
       m=checkTime(m);
       s=checkTime(s);
       
       totalString = totalSaved+''; //converts number into string
       totalString = addCommas(totalString); //calls the addCommas function and returns the value with the commas
       document.getElementById('txt').innerHTML="Our customers have saved $"+totalString+" with us.";
       t=setTimeout('startTime()',100);//time in milliseconds for the total to be updated
    }
    
    function checkTime(i)
    {
    if (i<10)
    {
       i="0" + i;
    }
    return i;
    }
    
    
    function addCommas(nStr) //function from http://www.mredkj.com/javascript/nfbasic.html
    {
    nStr += '';
    x = nStr.split('.');
    x1 = x[0];
    x2 = x.length > 1 ? '.' + x[1] : '';
    var rgx = /(\d+)(\d{3})/;
    while (rgx.test(x1)) {
    x1 = x1.replace(rgx, '$1' + ',' + '$2');
    }
    return x1 + x2;
    }
    
    </script>
    </head>
    
    <body onload="startTime()">
    <div id="txt">If you can read this something went wrong.</div>
    
    </body>
    </html> 
    
  • ThatOtherGuy - BANNED FOR LIFE
    So Fucking Banned
    • Apr 2011
    • 1241

    #2
    Oh wow that would be pretty cool.
    From what I see it already has those variables.

    you could make

    moneySavedPerSecond = 5.47

    to something like 0.00003 such that it would show slower on the count over time.

    you could also insert the variables via PHP so that it might show information that pertains to the visitors input on a previous form.

    I will play with it
    Last edited by ThatOtherGuy - BANNED FOR LIFE; 05-12-2011, 05:18 PM.

    Comment

    • blackmonsters
      Making PHP work
      • Nov 2002
      • 20966

      #3
      Originally posted by Bama
      So I was looking around for a script kinda' like the debt clock but on a much smaller scale and after a few hours of looking finally came across a thread that got close to what I wanted.

      Variables I'd like to have:

      Count up in cents and show that in the count
      Set how much (in dollars) it counts up every 24 hours (thinking around 5 or 6 bucks/day)
      Set starting amount (does this already)

      PHP Code:
      <html>
      <head>
      <script type="text/javascript">
      function startTime()
      {
         var today=new Date();
         var h=today.getHours();
         var m=today.getMinutes();
         var s=today.getSeconds();
         var ms=today.getTime();
         var moneySavedPerSecond = 5.47;/*in dollars*/
         var startDate = 1301802459944;/*In milliseconds from Jan 1, 1970*/
         var startSavings = 1000;
         var totalSaved=Math.round(((ms-startDate)/1000)*moneySavedPerSecond+startSavings);
         // add a zero in front of numbers<10
         m=checkTime(m);
         s=checkTime(s);
         
         totalString = totalSaved+''; //converts number into string
         totalString = addCommas(totalString); //calls the addCommas function and returns the value with the commas
         document.getElementById('txt').innerHTML="Our customers have saved $"+totalString+" with us.";
         t=setTimeout('startTime()',100);//time in milliseconds for the total to be updated
      }
      
      function checkTime(i)
      {
      if (i<10)
      {
         i="0" + i;
      }
      return i;
      }
      
      
      function addCommas(nStr) //function from http://www.mredkj.com/javascript/nfbasic.html
      {
      nStr += '';
      x = nStr.split('.');
      x1 = x[0];
      x2 = x.length > 1 ? '.' + x[1] : '';
      var rgx = /(\d+)(\d{3})/;
      while (rgx.test(x1)) {
      x1 = x1.replace(rgx, '$1' + ',' + '$2');
      }
      return x1 + x2;
      }
      
      </script>
      </head>
      
      <body onload="startTime()">
      <div id="txt">If you can read this something went wrong.</div>
      
      </body>
      </html> 
      

      I'm bored if you have $50.
      Free Open Source Live Aggregated Cams Script (FOSLACS)

      Comment

      • woj
        <&(©¿©)&>
        • Jul 2002
        • 47882

        #4
        If you are looking to invest a few bucks to have it fixed, hit me up, icq: 33375924
        Custom Software Development, email: woj#at#wojfun#.#com to discuss details or skype: wojl2000 or gchat: wojfun or telegram: wojl2000
        Affiliate program tools: Hosted Galleries Manager Banner Manager Video Manager
        Wordpress Affiliate Plugin Pic/Movie of the Day Fansign Generator Zip Manager

        Comment

        • fris
          Too lazy to set a custom title
          • Aug 2002
          • 55679

          #5
          woj is good coder, he can do it

          insert pic of rob shneider
          Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.

          Comment

          • blackmonsters
            Making PHP work
            • Nov 2002
            • 20966

            #6
            Here bro.

            I took out all that stuff in the other script that actually did nothing and
            this is all you need.

            It adds 1 cent every second.

            PHP Code:
            <html>
            <head>
            <script type="text/javascript">
            var cents=0;
            var dollars=0;
            function startTime()
            {
            
               var updatesecs = 1000;
               var strcents = 0;
               cents+= 1;
            
               if (cents>99) {
                cents= 0;
                dollars+=1;
               }
            
               if (cents<10) {
                strcents = "0" + cents;
               }else {
                strcents = cents;
               }
            
               document.getElementById('txt').innerHTML="I have lost $"+ dollars + "\." + strcents + " while reading this post on GFY.";
               t=setTimeout('startTime()',updatesecs);//time in milliseconds for the total to be updated
            }
            
            
            
            </script>
            </head>
            
            <body onload="startTime()">
            <div id="txt">If you can read this something went wrong.</div>
            
            </body>
            </html> 
            
            Free Open Source Live Aggregated Cams Script (FOSLACS)

            Comment

            • sarettah
              see you later, I'm gone
              • Oct 2002
              • 14297

              #7
              http://madspiders.com/testcounter.htm

              It is right now set to add .00006944 dollars every second which is about $6.00 a day. Pretty boring though because it only clicks off a cent every 2.5 minutes.

              PHP Code:
              <html> 
              <head> 
              <script type="text/javascript"> 
              function startTime() 
              { 
                 var today=new Date(); 
                 var h=today.getHours(); 
                 var m=today.getMinutes(); 
                 var s=today.getSeconds(); 
                 var ms=today.getTime(); 
                 //var moneySavedPerSecond = 5.47;/*in dollars*/ 
                 var moneySavedPerSecond = .00006944;/*in dollars*/
                 var startDate = 1301802459944;/*In milliseconds from Jan 1, 1970*/ 
                 var startSavings = 1000.00; 
                 //var totalSaved=Math.round(((ms-startDate)/1000)*moneySavedPerSecond+startSavings); 
                 var totalSaved=((ms-startDate)/1000)*moneySavedPerSecond+startSavings; 
                 // add a zero in front of numbers<10 
                 m=checkTime(m); 
                 s=checkTime(s);
                
                 totalString = formatNumber(totalSaved,2,',','.','$','','','');
                 //totalString = addCommas(totalString); //calls the addCommas function and returns the value with the commas 
                 document.getElementById('txt').innerHTML="Our customers have saved "+totalString+" with us."; 
                 t=setTimeout('startTime()',100);//time in milliseconds for the total to be updated 
              } 
              
              // number formatting function  
              // copyright Stephen Chapman 24th March 2006, 10th February 2007  
              // permission to use this function is granted provided  
              // that this copyright notice is retained intact  
              // from http://ntt.cc/2008/04/25/6-very-basic-but-very-useful-javascript-number-format-functions-for-web-developers.html
              function formatNumber(num,dec,thou,pnt,curr1,curr2,n1,n2)  
              {  
                var x = Math.round(num * Math.pow(10,dec));  
                if (x >= 0) n1=n2='';   
                var y = (''+Math.abs(x)).split('');  
                var z = y.length - dec;   
                  
                if (z<0) z--;   
                for(var i = z; i < 0; i++)  
                   y.unshift('0');   
                y.splice(z, 0, pnt);  
                if(y[0] == pnt) y.unshift('0');   
                while (z > 3)  
                {  
                     z-=3;  
                     y.splice(z,0,thou);  
                }   
                var r = curr1+n1+y.join('')+n2+curr2;  
              
                return r;  
              } 
              
              function checkTime(i) 
              { 
              if (i<10) 
              { 
                 i="0" + i; 
              } 
              return i; 
              } 
              
              
              function addCommas(nStr) //function from http://www.mredkj.com/javascript/nfbasic.html 
              { 
              nStr += ''; 
              x = nStr.split('.'); 
              x1 = x[0]; 
              x2 = x.length > 1 ? '.' + x[1] : ''; 
              var rgx = /(d+)(d{3})/; 
              while (rgx.test(x1)) { 
              x1 = x1.replace(rgx, '$1' + ',' + '$2'); 
              } 
              return x1 + x2; 
              } 
              
              </script> 
              </head> 
              
              <body onload="startTime()"> 
              <div id="txt">If you can read this something went wrong.</div> 
              
              </body> 
              </html> 
              
              All cookies cleared!

              Comment

              • blackmonsters
                Making PHP work
                • Nov 2002
                • 20966

                #8
                I forgot you needed that to be set by time of day each time.

                Here is the script :

                Just set "dailyamount" to the dollar amount you want total for the day.

                I have it set to 500 dollars a day now in the script :



                <html>
                <head>
                <script type="text/javascript">
                dailyamount = 500; // daily dollar amount. example 5 will equal 5 dollars per day

                // edit above only
                dailyamount=dailyamount*100;

                var cents=0;
                var dollars=0;
                function startTime()
                {

                var today=new Date();
                var h=today.getHours();
                var m=today.getMinutes();
                var s=today.getSeconds();

                dec=0;
                outx=new Array();
                var xx = new Array();
                h=h*3600;
                m=m*60
                tt = m+h+s;
                tt = Math.floor(dailyamount/86400 * tt);
                tt+="";
                xx = tt.split("");
                xx = xx.reverse();
                for (i=0;i<xx.length;i++) {
                if ((i>1) && (dec==0) ){dec=1; outx.push(".");}
                outx.push(xx[i]);
                }
                outx=outx.reverse();
                money = outx.join("");
                if (xx.length == 1) {money = "0.0" + money}
                if (xx.length == 2) {money = "0." + money}

                var updatesecs = 1000;
                var strcents = 0;

                document.getElementById('txt').innerHTML= "We have made "+ money + " today!";
                t=setTimeout('startTime()',updatesecs);//time in milliseconds for the total to be updated
                }



                </script>
                </head>

                <body onload="startTime()">
                <div id="txt">If you can read this something went wrong.</div>

                </body>
                </html>
                Last edited by blackmonsters; 05-12-2011, 06:51 PM.
                Free Open Source Live Aggregated Cams Script (FOSLACS)

                Comment

                • blackmonsters
                  Making PHP work
                  • Nov 2002
                  • 20966

                  #9
                  Wait!

                  Do you want the total to rollover to the next day?

                  I didn't do that.

                  Sorry.

                  But that's enough for free.
                  Free Open Source Live Aggregated Cams Script (FOSLACS)

                  Comment

                  • helterskelter808
                    So Fucking Banned
                    • Sep 2010
                    • 3405

                    #10
                    Rather than mess around with what you posted I wrote something that does what I think you're asking for. You can choose the amount per day and/or the start figure, and it increments in cents. And it's short (shorter than this post).

                    In the code below it's 1000 (or thereabouts) and 500 for the daily increase just to see it working, because $5/6 a day increases at a boring 1 cent every ~3 minutes.

                    BTW the higher the daily figure the higher the start figure, because it's client side script. Everyone's computer clock is different and it needs a fixed base time to compare to, long enough ago to be in the past for the whole world, and the number will be different for everyone in the world. This isn't an issue with $5 a day, but with 500, as below, you might be wondering why it's so much over 1000.

                    I must have misread your post because I thought you required commas. Rather than bloat it with another function I added a couple of lines for one comma, which is all you need for any number up to 999,999. If you start at $1000 and increase at $5 a day it will take about 550 years before that becomes an issue. I'll be happy to fix it if I'm around then.

                    As for people asking for money for a few lines of jabbascript... are you shitting me?

                    Hope it helps.

                    Code:
                    <html>
                    <head>
                    <script type="text/javascript">
                    function saved(){
                      var start = 1000; // start figure (appr)
                      var perday = 500; // amount per day increase
                      var spd = 86400000/perday;
                      var update = spd/100;
                      var now = +new Date();
                      var basetime = 1305100000000;
                      var dif = now - basetime;
                      var money = dif/spd + start;
                      var save = (Math.round(money*100)/100).toFixed(2);
                      var len = save.length;
                      var save = save.substring(0, len-6) + "," + save.substring(len-6);
                    
                      document.getElementById('txt').innerHTML="Our customers have saved $"+save+" with us. ";
                      t=setTimeout('saved()',update);
                    }
                      </script>
                    </head>
                    <body onload="saved()">
                    <div id="txt">If you can read this something went wrong.</div>
                    
                    </body>
                    </html>

                    Comment

                    • sabin
                      Registered User
                      • May 2011
                      • 60

                      #11
                      I'll take a look in the morning, bump this tomorrow to remind me.
                      Add to my Site: Add your URL | Add a Pornstar |

                      Comment

                      Working...