GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Any Bored Programmers? (https://gfy.com/showthread.php?t=1022313)

Bama 05-12-2011 06:02 PM

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 += '';
nStr.split('.');
x1 x[0];
x2 x.length '.' 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 05-12-2011 06:13 PM

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:)

blackmonsters 05-12-2011 06:15 PM

Quote:

Originally Posted by Bama (Post 18132663)
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 += '';
nStr.split('.');
x1 x[0];
x2 x.length '.' 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.

woj 05-12-2011 06:25 PM

If you are looking to invest a few bucks to have it fixed, hit me up, icq: 33375924

fris 05-12-2011 06:29 PM

woj is good coder, he can do it

insert pic of rob shneider

blackmonsters 05-12-2011 06:54 PM

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) {
    
cents0;
    
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> 


sarettah 05-12-2011 07:21 PM

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 
Math.round(num Math.pow(10,dec));  
  if (
>= 0n1=n2='';   
  var 
= (''+Math.abs(x)).split('');  
  var 
y.length dec;   
    
  if (
z<0z--;   
  for(var 
z0i++)  
     
y.unshift('0');   
  
y.splice(z0pnt);  
  if(
y[0] == pnty.unshift('0');   
  while (
3)  
  {  
       
z-=3;  
       
y.splice(z,0,thou);  
  }   
  var 
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 += ''
nStr.split('.'); 
x1 x[0]; 
x2 x.length '.' 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> 


blackmonsters 05-12-2011 07:49 PM

I forgot you needed that to be set by time of day each time. :1orglaugh

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 :



Quote:

<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>

blackmonsters 05-12-2011 07:55 PM

Wait!

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

I didn't do that.

Sorry.

But that's enough for free.

helterskelter808 05-13-2011 12:01 AM

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:upsidedow).

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. :winkwink:

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>


sabin 05-13-2011 12:24 AM

I'll take a look in the morning, bump this tomorrow to remind me.


All times are GMT -7. The time now is 04:26 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc