Commit 2f7722ea authored by fred's avatar fred

display chatrooms when open

parent 3a0bc4d7
...@@ -5,9 +5,9 @@ import os ...@@ -5,9 +5,9 @@ import os
import stat import stat
import time import time
from django.core.urlresolvers import reverse
from django.conf import settings from django.conf import settings
from django.http import Http404 from django.http import Http404
from django.views.decorators.cache import cache_control from django.views.decorators.cache import cache_control
from django.views.generic.base import TemplateView from django.views.generic.base import TemplateView
from django.views.generic.detail import DetailView from django.views.generic.detail import DetailView
...@@ -627,9 +627,13 @@ def onair(request): ...@@ -627,9 +627,13 @@ def onair(request):
'url': d['episode'].get_absolute_url() 'url': d['episode'].get_absolute_url()
} }
if d.get('emission'): if d.get('emission'):
chat_url = None
if d['emission'].chat_open:
chat_url = reverse('emission-chat', kwargs={'slug': d['emission'].slug})
d['emission'] = { d['emission'] = {
'title': d['emission'].title, 'title': d['emission'].title,
'url': d['emission'].get_absolute_url() 'url': d['emission'].get_absolute_url(),
'chat': chat_url,
} }
if d.get('nonstop'): if d.get('nonstop'):
d['nonstop'] = { d['nonstop'] = {
......
...@@ -1951,3 +1951,18 @@ div.top-logo img { ...@@ -1951,3 +1951,18 @@ div.top-logo img {
max-width: none; max-width: none;
} }
} }
div#CurrentlyChatting {
margin-top: 1em;
}
div#CurrentlyChatting a {
border-radius: 5px;
padding: 1ex 0 0.5ex 0;
display: block;
box-sizing: border-box;
text-align: center;
width: 100%;
background: #FF6633;
color: white !important;
}
...@@ -220,6 +220,12 @@ $(function() { ...@@ -220,6 +220,12 @@ $(function() {
else { else {
onairContainer = $('<span>Unknown (Probably Non-Stop)</span>'); onairContainer = $('<span>Unknown (Probably Non-Stop)</span>');
} }
if (onair.data.emission.chat) {
$('#CurrentlyChatting a').attr('href', onair.data.emission.chat);
$('#CurrentlyChatting').show();
} else {
$('#CurrentlyChatting').hide();
}
var current_html = WhatsOnAir.html(); var current_html = WhatsOnAir.html();
var new_html = '<span>' + onairContainer.html() + '</span>'; var new_html = '<span>' + onairContainer.html() + '</span>';
if (new_html !== current_html) { if (new_html !== current_html) {
...@@ -545,8 +551,7 @@ $(function() { ...@@ -545,8 +551,7 @@ $(function() {
}); });
/* CHAT */ /* CHAT */
var $chat = $('#chat'); if ($('#chat').length) {
if ($chat.length) {
var $msg = $('input#msg'); var $msg = $('input#msg');
var $send = $('button#send'); var $send = $('button#send');
var chat_roster = Object(); var chat_roster = Object();
...@@ -600,7 +605,7 @@ $(function() { ...@@ -600,7 +605,7 @@ $(function() {
} else { } else {
klass = 'msg-in'; klass = 'msg-in';
} }
var new_msg = $('<div class="msg new ' + klass + '"><span class="from">' + from + '</span> <span class="content">' + msg.textContent + '</span></div>').prependTo($chat); var new_msg = $('<div class="msg new ' + klass + '"><span class="from">' + from + '</span> <span class="content">' + msg.textContent + '</span></div>').prependTo($('#chat'));
new_msg[0].offsetHeight; /* trigger reflow */ new_msg[0].offsetHeight; /* trigger reflow */
new_msg.removeClass('new'); new_msg.removeClass('new');
$('div#chat div:nth-child(20)').remove() $('div#chat div:nth-child(20)').remove()
...@@ -619,7 +624,7 @@ $(function() { ...@@ -619,7 +624,7 @@ $(function() {
if (chat_roster[nick] == true) { if (chat_roster[nick] == true) {
for (contact in roster) { for (contact in roster) {
if (chat_roster[contact] !== true) { if (chat_roster[contact] !== true) {
var new_msg = $('<div class="msg info new"><span class="content">' + contact + ' est dans la place.</span></div>').prependTo($chat); var new_msg = $('<div class="msg info new"><span class="content">' + contact + ' est dans la place.</span></div>').prependTo($('#chat'));
new_msg[0].offsetHeight; /* trigger reflow */ new_msg[0].offsetHeight; /* trigger reflow */
new_msg.removeClass('new'); new_msg.removeClass('new');
} }
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
<div class="wrapper navigation"> <div class="wrapper navigation">
<div class=""> <div class="">
{% if emission.chat_open %}
<div class="chat-area"> <div class="chat-area">
<div class="nick">Pseudo ? <input name="nick"> <button>Se connecter</button></div> <div class="nick">Pseudo ? <input name="nick"> <button>Se connecter</button></div>
...@@ -37,6 +39,15 @@ ...@@ -37,6 +39,15 @@
<div id="chat" data-chatroom="{{emission.slug}}"> <div id="chat" data-chatroom="{{emission.slug}}">
</div> </div>
</div> <!-- .chat-area --> </div> <!-- .chat-area -->
{% else %}
<p class="info">
Ce chat n'est pour le moment pas ouvert.
</p>
{% endif %}
</div> <!-- .leftPart --> </div> <!-- .leftPart -->
</div> </div>
......
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
<span id="WhatsOnAir"></span> <span id="WhatsOnAir"></span>
<button class="icon-refresh" id="RefreshWhatsOnAir"></button> <button class="icon-refresh" id="RefreshWhatsOnAir"></button>
</div> </div>
<div id="CurrentlyChatting" style="display: none";>
<a href="">CHAT</a>
</div>
<audio <audio
id="DirectStreamPanik" id="DirectStreamPanik"
preload="none" preload="none"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment