...

View Full Version : [Paid (Negotiable)] Turning a countdown in to a live ticker...



MoreBloodWine
02-10-2011, 11:48 AM
** Note of interest as to not get anyone here in a hissy... It was suggested that I put this post here, so this is not a double post compared to my post in the JS board. **

1) Project Details: Check out turtle-tv.com

Notice the (Lights on/off ...) stuff above the chat and ustream windows. I would like to have it turned in to a live ticker that updates without needing to refrsh the page. It currently runs off of server time which is how I'd like it to stay.

So lets say the current time was 7:29:59am

The message in the parenthesis would read (Lights on in 1 Sec)

Then come 7:30am the message would read...

(Lights off in 12 Hrs, 30 Mins)

Ok, so you should now get the idea of how it works so I don't need an example of what it would read come 7:59:59pm etc etc etc.

2) Payment Amount: Negotiable

3) Payment Method: PayPal

4) Timeline: Done when it's done (no rush)

5) Additional Info:

The first block of code is what produces everything you see at turtle-tv.com...

The second block is something OldPedant hooked me up with a while back for a different project and is what I would like to have worked in since it's good, usable code. Obviously certain things will need to be removed / omitted since it doesnt apply to this project like the $contestend stuff and the bit that would display when the counter reaches 0.

Block 1

<?php
$lights_on = '7:30am';
$lights_off = '8pm';
$time = lights_on_off(time(), $lights_on, $lights_off);
?>

<head>
<title>Niko's Live 24/7 Video Broadcast</title>
</head>

<body background="./smalls_file_mainBg_1919366_7636654_l.jpg">
<font size="2" color="FFFF00" style="background: #181818;">Time Now: <?php echo date('g:ia'); ?></font>

<center>
<font size="5" color="FFFF00" style="background: #181818;">
Lights out from <?php echo $lights_off; ?> to <?php echo $lights_on; ?> <?php echo date('T'); ?>
(Lights <?php echo $time['n_state']; ?> in
<?php
$h = ($time['remaining']['m'] + 1 ==60) ? $time['remaining']['h'] + 1 : $time['remaining']['h'];
$m = ($time['remaining']['m'] + 1 ==60) ? 0 : $time['remaining']['m'];
$s = ($time['remaining']['m'] + 1 ==60) ? 0 : $time['remaining']['s'];
echo ($h>1) ? $h . ' Hrs, ' : (($h==1) ? $h . ' Hr, ' : ' ');
echo ($m>1) ? $m . ' Mins & ' : (($m==1) ? $m . ' Min & ' : ' ');
echo ($s>1) ? $s . ' Secs' : (($s==1) ? $s . ' Sec' : '0 Secs');
?>
) !
</font></center>

<?php

function lights_on_off($time, $lights_on, $lights_off){
$time = (isset($time)) ? $time : time();

$d_lights_on = strtotime($lights_on);
$d_lights_off = strtotime($lights_off);

$secs_lights_on = (date("G",$d_lights_on)*60 + date("i",$d_lights_on))*60 + date("s",$d_lights_on);
$secs_lights_off = (date("G",$d_lights_off)*60 + date("i",$d_lights_off))*60 + date("s",$d_lights_off);

$secs = (date("G",$time)*60 + date("i",$time))*60 + date("s",$time);

$c_state = ($secs_lights_on < $secs && $secs < $secs_lights_off) ? 'on' : 'off';
$n_state = ($secs_lights_on < $secs && $secs < $secs_lights_off) ? 'off' : 'on';

$next_switch = ($secs_lights_on < $secs && $secs_lights_off > $secs) ? $secs_lights_off : ($secs_lights_on + 60*60*24);
$next_switch = ($next_switch > ($secs+60*60*24)) ? $next_switch - (60*60*24) : $next_switch;
$time_rem = $next_switch - $secs;

$h = floor($time_rem/(60*60));
$m = floor(($time_rem-($h*60*60))/60);
$s = $time_rem-($h*60*60)-($m*60);

return array('c_state' => $c_state,'n_state' => $n_state, 'remaining' => array('secs' => $next_switch, 'h' => $h, 'm' => $m, 's' => $s));
}

?>

<center>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="600" height="523" id="utv451302">
<param name="flashvars" value="autoplay=false&amp;brand=embed&amp;cid=1919366"/><param name="allowfullscreen" value="true"/>
<param name="allowscriptaccess" value="always"/><param name="movie" value="http://www.ustream.tv/flash/live/1/1919366"/>
<embed flashvars="autoplay=false&amp;brand=embed&amp;cid=1919366" width="625" height="545" allowfullscreen="true" allowscriptaccess="always"
id="utv451302" name="utv_n_740840" src="http://www.ustream.tv/flash/live/1/1919366" type="application/x-shockwave-flash" /></object>
&nbsp;
<iframe scrolling="no" height="523" frameborder="0" width="576" src="./prochatrooms/index.php"></iframe>
</center>
</body>

Block 2a

<script type="text/javascript">
var curTime = <?php time() ?>;
var endTime = <?php $contestend ?>;
var tock = null;

function tick( )
{
var msg = "";
var secs = endTime - curTime;
++curTime;

if ( secs <= 0 )
{
clearInterval(tock);
document.getElementById("remain").innerHTML = "------- Sorry, but this contest ended on <?php echo date('D. F jS, Y', strftime($contestend)); ?> -------";
return;
}

var show = false;
var days = Math.floor( secs / 86400 ); // 86400 seconds in a day
if ( days > 0 ) show = true;
if ( show ) msg += days + ( days != 1 ? " Days, " : " Day, " );

secs %= 86400;
var hrs = Math.floor( secs/ 3600 );
if ( hrs > 0 ) show = true;
if ( show ) msg += hrs + ( hrs != 1 ? " Hrs, " : " Hr, " );

secs %= 3600;
var mins = Math.floor( secs / 60 );
if ( mins > 0 ) show = true;
if ( show ) msg += mins + ( mins != 1 ? " Mins & " : " Min & " );

secs %= 60;
msg += secs + ( secs != 1 ? " Secs " : " Sec " );

var t = document.getElementById("ticker");
t.innerHTML = msg;
if ( ! show ) t.style.color = "red";
}
</script>


Block 2b (Not really needed since it's the display aspect but posting for the sake of completeness...)

<span id="ticker">Loading...</span>

Ps: One other thing that would obviously need to be omitted is the red text upon the final second being passed... since this will be a continual clock with roll over between lights on and off.

I'm guessing thats easily enough solved just by removing the below line of code...

if ( ! show ) t.style.color = "red";

MoreBloodWine
02-12-2011, 09:45 PM
Job more or less accepted by ThePHPSolution (http://www.codingforums.com/member.php?u=107640), just working out the particulars.

Will update upon job completion or help still needed...

MoreBloodWine
05-31-2011, 01:59 AM
Been paid ($20) for since Feb, no communication since 3/19 via this site and email.

Not feeling to good about this right now... I just emailed John saying the following... not sure if anything will come of it.


John, I really would like to try and finish this so when you can can you please message me so we can figure out those quirks I mentioned. If not then can you please refund my money, I don't mind being patient but not when there's no communication going on.

Ty !


Anyway, if someone wants to try and toss me a favor here and get this work done so I'm not at a total loss I'd appreciate it.

Thx...

MoreBloodWine
06-11-2011, 11:04 PM
Still no word via email or this site from ThePHPSolution, really feeling like I got ripped off now since this project has been paid for and past the PayPal dispute point.

kokjj87
06-15-2011, 04:16 AM
You actually trust him when he only got 1 post in this forum?

MoreBloodWine
06-15-2011, 12:32 PM
You actually trust him when he only got 1 post in this forum?

You actually felt the need to make that reply ?

Rowsdower!
06-15-2011, 01:17 PM
Well it does serve as a common sense check. Blunt, perhaps, but a valid point to clarify.

Anyway, I'd help you out but your page doesn't seem to use (or even contain) any of the javascript you have pasted in your initial message. Also, your "time now" block doesn't have an id, nor does your "lights out" message bar. These would be very basic steps to take to make this script easier to build/debug.

And, beyond that, you should add a doctype (http://www.w3schools.com/tags/tag_doctype.asp) and fix your HTML structure so that your page validates (http://validator.w3.org/check?uri=http%3A%2F%2Fwww.turtle-tv.com%2F&charset=%28detect+automatically%29&doctype=Inline&group=0&ss=1&verbose=1).

MoreBloodWine
06-15-2011, 01:48 PM
Well it does serve as a common sense check. Blunt, perhaps, but a valid point to clarify.

Anyway, I'd help you out but your page doesn't seem to use (or even contain) any of the javascript you have pasted in your initial message. Also, your "time now" block doesn't have an id, nor does your "lights out" message bar. These would be very basic steps to take to make this script easier to build/debug.

And, beyond that, you should add a doctype (http://www.w3schools.com/tags/tag_doctype.asp) and fix your HTML structure so that your page validates (http://validator.w3.org/check?uri=http%3A%2F%2Fwww.turtle-tv.com%2F&charset=%28detect+automatically%29&doctype=Inline&group=0&ss=1&verbose=1).

The JS is explained, as a different project the code was provided for NOT this one. Everything that seems is missing is infact not, so the only thing to really address would be validation which is not a big deal for me given that this isnt a production / professional site nor is it meant to me.

It's just there to serve a simple purpose.

Rowsdower!
06-15-2011, 05:24 PM
Can beggars be choosers, after all? I've always heard differently.

Look... Adding id attributes where I suggested you add them (and yes, they are missing) will make writing the javascript an easy job. Fixing the markup for validation is just good practice, and the DOM likes it, and - in cases where other people have to work around your mess - it's just polite to tidy up. Adding javascript to the head of the HTML document - even if it's not 100% correct code - will make tinkering with your page locally much easier when using Firebug. So all of the suggested changes make scripting the page easier.

You need to understand that for free help you need to make things as easy as possible. By even making me explain this to you, you have already made this harder than I care to deal with any further.

You'll be in a better position to get someone else to help you though, if you do what I suggested.

Either way, best of luck to you!

routerboy
06-27-2011, 02:10 AM
Did you find a programmer?

MoreBloodWine
06-27-2011, 02:16 AM
Did you find a programmer?

Ya, just waiting on some things to be finalized but keep a sub goin on this post just in case, Ty.

MoreBloodWine
07-04-2011, 08:18 AM
You actually trust him when he only got 1 post in this forum?




http://www.sneakersshoponline.com

As I told a few other people, he eactually completed the work except for fixing some bugs and before I could get the file he went MIA.

So I guess I'm 50/50 on him.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum