Форумы / Cotonti / Support / Plugin Stream => My nightmare

Harker
#39479 26.04.2014 14:58

Hello to all,

I created a plugin which allows me to see the status of the streams of my members. It works very well but I do not manage to have that I want in spite of my nights white and my liters of coffee.

At present, my page shows all the on-line and off-line streams. I would need your help so that my plugin shows only the on-line streams.

 

PHP

$sql = $db->query("SELECT * FROM cot_streams");
while ($data = $sql->fetch())
	{
	$data['teststream'] = '<a class="ltwitch" href="#" data-tnick="'.$data['streams_name'].'">'.$data['streams_name'].'</a> (<span>...</span>)';
	$t-> assign(array(
	'STREAMS_ID' => $data['id'],
	'STREAMS_USER_ID' => $data['userid'],
	'STREAMS_USER_TWITCHNAME' => $data['teststream']
		
	));

	$t->parse('MAIN.STREAM_ROW');
}

TPL

<!-- BEGIN: STREAM_ROW -->
	<div>{STREAMS_ID}</div>
	<div>{STREAMS_USER_ID}</div>
	<div>{STREAMS_USER_TWITCHNAME}</div>
<!-- END: STREAM_ROW -->

JS

jQuery(document).ready(function ($) {
    $('.ltwitch').each(function () {
        var tnick = $(this).data('tnick');
        var span = $(this).next();
        $.getJSON("https://api.twitch.tv/kraken/streams/" + tnick + ".json?callback=?", function (c) {
            if (c.stream == null) {
                span.html("Offline");
            } else {
                span.html("Online");
            }
        });
    });
});

 

PLLLLeeeeeaaassseeee Help me to transform my nightmares, I do not sleep any more ^^