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 %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|
||||||
|
<%= link_to "Mute", '#', id: "mute", class: 'button tiny' %>
|
||||||
<% if cuser and cuser.admin? %>
|
<% if cuser and cuser.admin? %>
|
||||||
<%= link_to "Admin Page", edit_gather_url, class: 'admin button' %>
|
<%= link_to "Admin Page", edit_gather_url, class: 'admin button' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
<div id="jplayer"></div>
|
<div id="jplayer"></div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var played = false;
|
var played = false;
|
||||||
|
var muted = false;
|
||||||
var leave_confirm = true;
|
var leave_confirm = true;
|
||||||
<% if @gatherer and @gatherer.can_destroy? cuser %>
|
<% if @gatherer and @gatherer.can_destroy? cuser %>
|
||||||
var gatherer_id = <%= @gatherer.id %>;
|
var gatherer_id = <%= @gatherer.id %>;
|
||||||
|
var muted = false;
|
||||||
<% else %>
|
<% else %>
|
||||||
var gatherer_id = 0;
|
var gatherer_id = 0;
|
||||||
|
var muted = true;
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
function updateGathererStatus(status) {
|
function updateGathererStatus(status) {
|
||||||
|
@ -22,6 +25,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
init_mute();
|
||||||
$.PeriodicalUpdater("/gathers/" + <%= @gather.id %> + ".js", {
|
$.PeriodicalUpdater("/gathers/" + <%= @gather.id %> + ".js", {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
type: "script",
|
type: "script",
|
||||||
|
@ -55,9 +59,31 @@
|
||||||
else if (response.length > 10) {
|
else if (response.length > 10) {
|
||||||
$("#jplayer").jPlayer("stop");
|
$("#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() {
|
$(window).bind('unload', function() {
|
||||||
if (gatherer_id > 0 && leave_confirm) {
|
if (gatherer_id > 0 && leave_confirm) {
|
||||||
updateGathererStatus('leaving');
|
updateGathererStatus('leaving');
|
||||||
|
|
Loading…
Reference in a new issue