-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Watching page now polling for events.
- Added default poll time on client.
- Loading branch information
Showing
12 changed files
with
155 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 15 additions & 5 deletions
20
ted-server/src/test/java/nu/ted/domain/SeriesBackendWrapperTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,79 @@ | ||
<?php | ||
if (sizeof($watch_list) == 0) { | ||
echo "You are not watching any shows."; | ||
function createNotWatchingDiv() { | ||
return "<div id='not_watching'>You are not watching any shows.</div>"; | ||
} | ||
|
||
foreach ($watch_list as $series) { | ||
include 'watching_content.php'; | ||
// Create necessary JS functions. | ||
$script = " | ||
function showLocalDate(timestamp) | ||
{ | ||
var dt = new Date(timestamp); | ||
document.write(dt.toLocaleString()); | ||
} | ||
function process(data) { | ||
if (data.length <= 0) { | ||
poll(new Date().getTime()); | ||
return; | ||
} | ||
var lastPollTime = data.lastPolled; | ||
var i; | ||
var events = data.events; | ||
for (i in events) { | ||
// Watch added. | ||
if (1 == events[i].type) { | ||
if ($('#not_watching').length) { | ||
$('#not_watching').remove(); | ||
} | ||
$('#watch_list').append(events[i].seriesHtml); | ||
} | ||
// Remove series. | ||
else if (2 == events[i].type) { | ||
$('#' + events[i].uid ).remove(); | ||
if( $('#watch_list').children().length == 0) { | ||
$('#watch_list').append(\"" . createNotWatchingDiv() . "\"); | ||
} | ||
} | ||
// episode added. | ||
else if (3 == events[i].type) { | ||
if ($('#' + events[i].uid ).length) { | ||
$('#' + events[i].uid ).replaceWith(events[i].seriesHtml); | ||
} | ||
else { | ||
$('#watch_list').append(events[i].seriesHtml); | ||
} | ||
} | ||
} | ||
// Wait here. Since we share a connection to the ted | ||
// server, waiting on the server ties up the connection, | ||
// as the call is not asynchronous. | ||
setTimeout('poll(' + lastPollTime + ')', " . __POLL_INTERVAL ."); | ||
} | ||
function poll(lastPolled) { | ||
$.post('watching/poll/' + lastPolled, {}, process, 'json'); | ||
} | ||
"; | ||
include 'javascript.php'; | ||
|
||
echo "<div id='watch_list'>"; | ||
if (sizeof($watch_list) == 0) { | ||
echo createNotWatchingDiv(); | ||
} | ||
else { | ||
foreach ($watch_list as $series) { | ||
include 'watching_content.php'; | ||
} | ||
} | ||
echo "</div>"; | ||
?> | ||
|
||
<?php | ||
$script = "window.onload = poll(new Date().getTime());"; | ||
include 'javascript.php'; | ||
?> |
Oops, something went wrong.