Permalink
Browse files

Disable Sound in Dashboard

- Admin Settings to disable Button and Notification on Dashboard
- Save Buttonstate even if you open another page and come back to Dashboard
  • Loading branch information...
iAmShorty committed Jun 30, 2016
1 parent f72d3f4 commit cf00271802efd240671e3b3e5aefa32b841b4485
View
@@ -37,4 +37,7 @@
/vendor/
tests/_output/*
tests/_output/*
# NetBeans Project Directory
/nbproject/*
@@ -97,6 +97,13 @@
'name' => 'website_notification_autohide', 'value' => $setting->getValue('website_notification_autohide'),
'tooltip' => 'Hides Notifications after 5 seconds.'
);
$aSettings['website'][] = array(
'display' => 'Disable Block Notification Sound', 'type' => 'select',
'options' => array( 0 => 'Do not notify', 1 => 'Notify when Block is found' ),
'default' => 0,
'name' => 'website_blockfinder_notification', 'value' => $setting->getValue('website_blockfinder_notification'),
'tooltip' => 'Enable/Disable Blockfinder Sound.'
);
$aSettings['blockchain'][] = array(
'display' => 'Disable Blockexplorer', 'type' => 'select',
'options' => array( 0 => 'No', 1 => 'Yes' ),
@@ -119,6 +119,7 @@
$aGlobal['website']['chaininfo']['disabled'] = $setting->getValue('website_chaininfo_disabled');
$aGlobal['website']['donors']['disabled'] = $setting->getValue('disable_donors');
$aGlobal['website']['about']['disabled'] = $setting->getValue('disable_about');
$aGlobal['website']['blockfindersound']['enabled'] = $setting->getValue('website_blockfinder_notification');
$setting->getValue('website_blockexplorer_url') ? $aGlobal['website']['blockexplorer']['url'] = $setting->getValue('website_blockexplorer_url') : $aGlobal['website']['blockexplorer']['url'] = 'http://explorer.litecoin.net/block/';
$setting->getValue('website_transactionexplorer_url') ? $aGlobal['website']['transactionexplorer']['url'] = $setting->getValue('website_transactionexplorer_url') : $aGlobal['website']['transactionexplorer']['url'] = 'http://explorer.litecoin.net/tx/';
$setting->getValue('website_chaininfo_url') ? $aGlobal['website']['chaininfo']['url'] = $setting->getValue('website_chaininfo_url') : $aGlobal['website']['chaininfo']['url'] = 'http://allchains.info';
@@ -37,11 +37,13 @@
</tbody>
</table>
</div>
{if $GLOBAL.website.blockfindersound.enabled|default:"1"}
<div id="togglesound" class="togglesound">
<div class="panel-footer text-right">
<button id="muteButton" type="button" class="btn-xs btn-success toggleSoundButton"><i class="fa fa-volume-up"></i></button>
</div>
</div>
{/if}
</div>
</div>
{/if}
@@ -4,22 +4,35 @@
{literal}
$(document).ready(function(){
{/literal}
{if $GLOBAL.website.blockfindersound.enabled|default:"1"}
{literal}
var playSound = localStorage.getItem('playsound') === 'False' ? false : true;
var canCreateSoundJS = false;
// check if the default plugins can be loaded, if not, disable button and don't load soundjs
if (!createjs.Sound.initializeDefaultPlugins()) {
$('#togglesound').hide();
// don't create object and hide toggle on mobile devices. must be started inside a touch event, else sound doesn't start
} else if (createjs.BrowserDetect.isIOS || createjs.BrowserDetect.isAndroid || createjs.BrowserDetect.isBlackberry) {
$('#togglesound').hide();
} else {
var audioPath = "{/literal}{$PATH}{literal}/audio/";
var sound = [ {id:"ding", src:"ding.mp3"} ];
var muteFlag = 1;
createjs.Sound.alternateExtensionseExtensions = ["mp3"];
createjs.Sound.registerSounds(sound, audioPath);
canCreateSoundJS = true;
if (playSound) {
var audioPath = "{/literal}{$PATH}{literal}/audio/";
var sound = [ {id:"ding", src:"ding.mp3"} ];
var muteFlag = 1;
createjs.Sound.alternateExtensionseExtensions = ["mp3"];
createjs.Sound.registerSounds(sound, audioPath);
canCreateSoundJS = true;
$('#muteButton').toggleClass("btn-xs btn-danger").toggleClass("btn-xs btn-success");
$('#muteButton').find($(".fa")).removeClass('fa-volume-off').addClass('fa-volume-up');
} else {
$('#muteButton').toggleClass("btn-xs btn-success").toggleClass("btn-xs btn-danger");
$('#muteButton').find($(".fa")).removeClass('fa-volume-up').addClass('fa-volume-off');
}
}
{/literal}
{/if}
{literal}
// Ajax API URL
var url_dashboard = "{/literal}{$smarty.server.SCRIPT_NAME}?page=api&action=getdashboarddata&api_key={$GLOBAL.userdata.api_key}&id={$GLOBAL.userdata.id}{literal}";
@@ -273,11 +286,13 @@ $(document).ready(function(){
// Mute Button
$('#muteButton').click(function(){
if(muteFlag == 2) {
localStorage.setItem('playsound', 'True');
muteFlag = 1;
createjs.Sound.setMute(false);
$(this).toggleClass("btn-xs btn-danger").toggleClass("btn-xs btn-success");
$(this).find($(".fa")).removeClass('fa-volume-off').addClass('fa-volume-up');
} else {
localStorage.setItem('playsound', 'False');
muteFlag = 2;
createjs.Sound.setMute(true);
$(this).toggleClass("btn-xs btn-success").toggleClass("btn-xs btn-danger");

0 comments on commit cf00271

Please sign in to comment.