Skip to content

Commit

Permalink
Some webcam fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
janpaul123 committed Jan 11, 2010
1 parent 0f4e52c commit bfb3c0c
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 29 deletions.
5 changes: 3 additions & 2 deletions css/default.css
Expand Up @@ -275,7 +275,7 @@ img {

#webcams img {
z-index : 2;
opacity : 1;
opacity : 0;
}

#webcams img.error {
Expand All @@ -285,7 +285,8 @@ img {
left : 50%;
margin-top : -8px;
margin-left : -8px;
z-index : 5;
z-index : 5;
opacity : 1;
}

#webcams .shadow {
Expand Down
3 changes: 1 addition & 2 deletions index.php
Expand Up @@ -119,7 +119,6 @@
foreach ($settings['webcams.cams'] as $nr => $cam)
{
$styleDiv='';
$styleImage='';

foreach($styleDivAllowed as $element)
{
Expand All @@ -140,7 +139,7 @@
echo('<div class="holder">');
echo('<div class="border"></div>');
echo('<div id="webcam-' . $nr . '" >');
echo('<img class="webcam" style="' . $styleImage . '" src="' . $cam['url'] . '"/>');
echo('<img class="webcam" style="' . $styleImage . '"/>');
echo('</div>');
echo('<div class="title">' . $cam['title'] . '</div>');
echo('<div class="shadow" id="shadow-webcam-' . $nr . '"></div>');
Expand Down
63 changes: 42 additions & 21 deletions js/PhotoFrame.js
Expand Up @@ -254,25 +254,31 @@ var PhotoFrame = new function () {
}

this.updateWebcam = function(id) {
var url = PhotoFrame.makeDynamicUrl(PhotoFrame.webcams[id]);

var $newCam = $(new Image());
var style = $('#' + id + ' img').attr('style');

$newCam.attr('style', style);
$newCam.css('opacity', 1);
$newCam.load(function () {
$('#' + id + ' img').remove();
$('#' + id).append($(this));
$('#error-' + id).fadeOut('medium');
$('#shadow-' + id).fadeOut('medium');
});
$newCam.error(function () {
$('#error-' + id).fadeIn('medium');
$('#shadow-' + id).fadeIn('medium');
});

$newCam.attr('src', url);
if (!PhotoFrame.webcams[id].loading) {
PhotoFrame.webcams[id].loading = true;

var url = PhotoFrame.makeDynamicUrl(PhotoFrame.webcams[id].url);
var $newCam = $(new Image());
var style = $('#' + id + ' img').attr('style');

$newCam.attr('style', style);
$newCam.css('opacity', 1);
$newCam.load(function () {
PhotoFrame.webcams[id].loading = false;
$('#' + id + ' img').remove();
$('#' + id).show();
$('#' + id).append($(this));
$('#error-' + id).fadeOut('medium');
$('#shadow-' + id).fadeOut('medium');
});
$newCam.error(function () {
PhotoFrame.webcams[id].loading = false;
$('#error-' + id).fadeIn('medium');
$('#shadow-' + id).fadeIn('medium');
});

$newCam.attr('src', url);
}
}

this.updateWebcams = function() {
Expand All @@ -293,6 +299,18 @@ var PhotoFrame = new function () {
}
}

this.flushWebcams = function() {
if (PhotoFrame.webcamsFlushTimer!=null) {
clearTimeout(PhotoFrame.webcamsFlushTimer);
PhotoFrame.webcamsFlushTimer = null;
}
PhotoFrame.webcamsFlushTimer = setTimeout(function() { PhotoFrame.flushWebcams() }, 59000);

for (var id in PhotoFrame.webcams) {
PhotoFrame.webcams[id].loading = false;
}
}

this.toggleWebcams = function () {
if (PhotoFrame.webcamsShown) {
PhotoFrame.hideWebcams();
Expand Down Expand Up @@ -334,7 +352,7 @@ var PhotoFrame = new function () {
$('#connectionerror').fadeIn('medium');
});

$img.attr('src', PhotoFrame.makeDynamicUrl('http://www.nu.nl/images/logo_nu_nl.gif'));
$img.attr('src', PhotoFrame.makeDynamicUrl(PhotoFrame.connectionURL));

PhotoFrame.connectionTimer = setTimeout(PhotoFrame.checkConnection, 27000);
}
Expand Down Expand Up @@ -365,6 +383,9 @@ var PhotoFrame = new function () {
if (PhotoFrame.bar) PhotoFrame.updateTime();
PhotoFrame.updateTraffic();

PhotoFrame.flushWebcams();
PhotoFrame.updateWebcams();

setTimeout(function() {
PhotoFrame.hideAbout();
}, 4000);
Expand All @@ -391,7 +412,7 @@ var PhotoFrame = new function () {
}

this.addWebcam = function (id, url) {
PhotoFrame.webcams[id] = url;
PhotoFrame.webcams[id] = {url: url, loading: false};
}

this.setWebcamsInterval = function (value) {
Expand Down
10 changes: 6 additions & 4 deletions user/config.php.default
Expand Up @@ -78,12 +78,14 @@ $settings['connection.check'] = true;
// show a wifi error logo instead of a normal error logo
$settings['connection.wifi'] = true;

// image to check for the connection (must accept ?1298712 behind the url, therefore Google doesn't work..)
// image to check for the connection
// must accept ?<random number> (ie. ?1298712) behind the url, therefore Google doesn't work..
$settings['connection.url'] = 'http://www.nu.nl/images/logo_nu_nl.gif';

// RSS SETTINGS
// array of feeds
// required settings are 'url' (rss feed itself), 'cache' (filename) and 'logo' (path to image)
// optionally you can use 'all' (description instad of title) and 'width'
$settings['rss.feeds'][] = array(
'url' => 'http://www.nu.nl/deeplink_rss2/index.jsp?r=Algemeen',
'cache' => 'nu.nl.xml',
Expand All @@ -98,12 +100,12 @@ $settings['rss.feeds'][] = array(
'url' => 'http://rss.weeronline.nl/weernieuws/2/nederland.xml',
'cache' => 'weather.rss.xml',
'logo' => 'user/feedpics/weather.png',
'all' => true, // use description instead of title
'width' => '480px', // custom width
'all' => true,
'width' => '480px',
);

// error message to show when the downloading of a feeds fails
$settings['rss.error_message'] = 'De router faalt... alweer!';
$settings['rss.error_message'] = 'Connection error';

// skip randomly through the feeds
$settings['rss.random'] = false;
Expand Down

0 comments on commit bfb3c0c

Please sign in to comment.