You are not logged in.

Announcement

Forum database was corrupt and an old backup was restored as temporary replacement. Registrations closed until the database is recovered. Please ask questions using the Contact form

#1 12-04-2014 14:48:03

AxfordA
Contributors
Registered: 17-02-2014
Posts: 3

Refresh a sign tile

Hi,

Is it possible to refresh a single tile? Say every 30 seconds, so that I can execute some php script and display the returned value?

Thanks Alan

Offline

#2 12-04-2014 18:14:58

chrismaliszewski
Contributors
From: Torun, Poland
Registered: 06-05-2013
Posts: 246
Website

Re: Refresh a sign tile

You'll need to create new type of tile to do it or modify already existing to add refreshing thing.

About refreshing read this and this (in Google and similar topics).

Maybe sb else will write some code for you...

Offline

#3 04-05-2014 12:17:19

henningbr
Contributors
From: Norway
Registered: 29-04-2014
Posts: 30
Website

Re: Refresh a sign tile

I have the same problem, I want to refresh the time in a tile.

Offline

#4 04-05-2014 13:11:11

Thomas
Administrator
Registered: 10-03-2013
Posts: 897

Re: Refresh a sign tile

To add something to this: you can also put it in an iframe and refresh that iframe or the better way:
use javascript to update the contents.

Offline

#5 04-05-2014 18:21:16

AxfordA
Contributors
Registered: 17-02-2014
Posts: 3

Re: Refresh a sign tile

We got it working. Ended up being fairly straightforward. We used some js script and ajax to refresh the tile. Works and looks great and its very flexible.
Not sure if its the correct way to do it or the best but this is what we did:
1. Index.php -- added a line in the <head> section to call our js (rides.js) to initialise the ajax triggers.
triggerEvent("headEnd");
        ?>
        <noscript><style>#tileContainer{display:block}</style></noscript>
        <script type="text/javascript" src="js/rides.js"></script>
    </head>

2. Within the javascript we defined the web services that we want to call. Web Service returns Jason string.
   We set up ajax to post to the web services and it worked.

jQuery(document).ready(function()
{
    setupOneService('URL to web service','Argument to Post to webservice...same text as defined for the tile');
    setupOneService('URL to 2nd web service','Argument to Post to 2nd webservice...same text as defined for the 2nd tile');
   .....and so on for as many tiles as you need
});

function setupOneService(url,text)
{
    setInterval(function()
    {
        oneRound(url,text);
    }, 5000);
    oneRound(url,text);
}

function oneRound(source_url,search_text)
{
    jQuery.ajax({
        url: 'index.php',
        dataType: 'json',
        method: 'post',
        data: {getJSON:'true',source_url:source_url},
        success: function(data)
        {
            var title = jQuery('.tileDesc:contains("'+search_text+'")');
            var time = data.Time.split(' on ');
            time = time[1].split(' - ');
            time = time[0].replace(',', ' ');
            title.parent().find('div.time').remove();
            var time_container = jQuery('<div><h1>' + data.Count + '</h1><p class="timeContainer"></p></div>').addClass('time');
            title.parent().append(time_container);
           
            /*thanks to this every tile within all services will display the same time*/
            jQuery('.timeContainer').html(time.replace(',', ' '));
        }
    });
}

3. in the config/tile.php we defined our tiles:
$tile[] = array(
    "type"=>"simple",
    "group"=>0,
    "x"=>0,
    "y"=>0,
    'width'=>1,
    'height'=>1,
    "background"=>"#000",
    "url"=>"",
    "title"=>"",
    "text"=>"Argument to Post to webservice...same text as in the tile");

Offline

#6 04-05-2014 18:49:41

Thomas
Administrator
Registered: 10-03-2013
Posts: 897

Re: Refresh a sign tile

AJAX is indeed the most clean and best way wink

Offline

Board footer

Powered by FluxBB