mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-11-15 09:21:25 +00:00
Mute button for gather.
This commit is contained in:
parent
5a7c9f60d0
commit
6560fe18f9
2 changed files with 33 additions and 5 deletions
|
@ -67,6 +67,8 @@
|
|||
<% end %>
|
||||
<% end %>
|
||||
|
||||
|
||||
<%= link_to "Mute", '#', id: "mute", class: 'button tiny' %>
|
||||
<% if cuser and cuser.admin? %>
|
||||
<%= link_to "Admin Page", edit_gather_url, class: 'admin button' %>
|
||||
<% end %>
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
<div id="jplayer"></div>
|
||||
<script type="text/javascript">
|
||||
var played = false;
|
||||
var muted = false;
|
||||
var leave_confirm = true;
|
||||
<% if @gatherer and @gatherer.can_destroy? cuser %>
|
||||
var gatherer_id = <%= @gatherer.id %>;
|
||||
var muted = false;
|
||||
<% else %>
|
||||
var gatherer_id = 0;
|
||||
var muted = true;
|
||||
<% end %>
|
||||
|
||||
function updateGathererStatus(status) {
|
||||
|
@ -22,6 +25,7 @@
|
|||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
init_mute();
|
||||
$.PeriodicalUpdater("/gathers/" + <%= @gather.id %> + ".js", {
|
||||
method: "GET",
|
||||
type: "script",
|
||||
|
@ -55,9 +59,31 @@
|
|||
else if (response.length > 10) {
|
||||
$("#jplayer").jPlayer("stop");
|
||||
}
|
||||
init_mute();
|
||||
}
|
||||
});
|
||||
|
||||
function init_mute() {
|
||||
if(!muted){
|
||||
$("#mute").text("Mute");
|
||||
$("#jplayer").jPlayer("unmute");
|
||||
} else {
|
||||
$("#mute").text("Unmute");
|
||||
$("#jplayer").jPlayer("mute");
|
||||
}
|
||||
$("#mute").off("click");
|
||||
$("#mute").on("click", function() {
|
||||
if(muted){
|
||||
$(this).text("Mute");
|
||||
$("#jplayer").jPlayer("unmute");
|
||||
} else {
|
||||
$(this).text("Unmute");
|
||||
$("#jplayer").jPlayer("mute");
|
||||
}
|
||||
muted = !muted;
|
||||
return false;
|
||||
});
|
||||
}
|
||||
$(window).bind('unload', function() {
|
||||
if (gatherer_id > 0 && leave_confirm) {
|
||||
updateGathererStatus('leaving');
|
||||
|
|
Loading…
Reference in a new issue