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
This commit is contained in:
iAmShorty 2016-06-30 11:19:01 +02:00
parent f72d3f4a76
commit cf00271802
5 changed files with 36 additions and 8 deletions

3
.gitignore vendored
View File

@ -38,3 +38,6 @@
/vendor/ /vendor/
tests/_output/* tests/_output/*
# NetBeans Project Directory
/nbproject/*

View File

@ -97,6 +97,13 @@ $aSettings['website'][] = array(
'name' => 'website_notification_autohide', 'value' => $setting->getValue('website_notification_autohide'), 'name' => 'website_notification_autohide', 'value' => $setting->getValue('website_notification_autohide'),
'tooltip' => 'Hides Notifications after 5 seconds.' '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( $aSettings['blockchain'][] = array(
'display' => 'Disable Blockexplorer', 'type' => 'select', 'display' => 'Disable Blockexplorer', 'type' => 'select',
'options' => array( 0 => 'No', 1 => 'Yes' ), 'options' => array( 0 => 'No', 1 => 'Yes' ),

View File

@ -119,6 +119,7 @@ $aGlobal['website']['transactionexplorer']['disabled'] = $setting->getValue('web
$aGlobal['website']['chaininfo']['disabled'] = $setting->getValue('website_chaininfo_disabled'); $aGlobal['website']['chaininfo']['disabled'] = $setting->getValue('website_chaininfo_disabled');
$aGlobal['website']['donors']['disabled'] = $setting->getValue('disable_donors'); $aGlobal['website']['donors']['disabled'] = $setting->getValue('disable_donors');
$aGlobal['website']['about']['disabled'] = $setting->getValue('disable_about'); $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_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_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'; $setting->getValue('website_chaininfo_url') ? $aGlobal['website']['chaininfo']['url'] = $setting->getValue('website_chaininfo_url') : $aGlobal['website']['chaininfo']['url'] = 'http://allchains.info';

View File

@ -37,11 +37,13 @@
</tbody> </tbody>
</table> </table>
</div> </div>
{if $GLOBAL.website.blockfindersound.enabled|default:"1"}
<div id="togglesound" class="togglesound"> <div id="togglesound" class="togglesound">
<div class="panel-footer text-right"> <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> <button id="muteButton" type="button" class="btn-xs btn-success toggleSoundButton"><i class="fa fa-volume-up"></i></button>
</div> </div>
</div> </div>
{/if}
</div> </div>
</div> </div>
{/if} {/if}

View File

@ -4,8 +4,11 @@
{literal} {literal}
$(document).ready(function(){ $(document).ready(function(){
{/literal}
{if $GLOBAL.website.blockfindersound.enabled|default:"1"}
{literal}
var playSound = localStorage.getItem('playsound') === 'False' ? false : true;
var canCreateSoundJS = false; var canCreateSoundJS = false;
// check if the default plugins can be loaded, if not, disable button and don't load soundjs // check if the default plugins can be loaded, if not, disable button and don't load soundjs
if (!createjs.Sound.initializeDefaultPlugins()) { if (!createjs.Sound.initializeDefaultPlugins()) {
$('#togglesound').hide(); $('#togglesound').hide();
@ -13,13 +16,23 @@ $(document).ready(function(){
} else if (createjs.BrowserDetect.isIOS || createjs.BrowserDetect.isAndroid || createjs.BrowserDetect.isBlackberry) { } else if (createjs.BrowserDetect.isIOS || createjs.BrowserDetect.isAndroid || createjs.BrowserDetect.isBlackberry) {
$('#togglesound').hide(); $('#togglesound').hide();
} else { } else {
var audioPath = "{/literal}{$PATH}{literal}/audio/"; if (playSound) {
var sound = [ {id:"ding", src:"ding.mp3"} ]; var audioPath = "{/literal}{$PATH}{literal}/audio/";
var muteFlag = 1; var sound = [ {id:"ding", src:"ding.mp3"} ];
createjs.Sound.alternateExtensionseExtensions = ["mp3"]; var muteFlag = 1;
createjs.Sound.registerSounds(sound, audioPath); createjs.Sound.alternateExtensionseExtensions = ["mp3"];
canCreateSoundJS = true; 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 // 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}"; 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 // Mute Button
$('#muteButton').click(function(){ $('#muteButton').click(function(){
if(muteFlag == 2) { if(muteFlag == 2) {
localStorage.setItem('playsound', 'True');
muteFlag = 1; muteFlag = 1;
createjs.Sound.setMute(false); createjs.Sound.setMute(false);
$(this).toggleClass("btn-xs btn-danger").toggleClass("btn-xs btn-success"); $(this).toggleClass("btn-xs btn-danger").toggleClass("btn-xs btn-success");
$(this).find($(".fa")).removeClass('fa-volume-off').addClass('fa-volume-up'); $(this).find($(".fa")).removeClass('fa-volume-off').addClass('fa-volume-up');
} else { } else {
localStorage.setItem('playsound', 'False');
muteFlag = 2; muteFlag = 2;
createjs.Sound.setMute(true); createjs.Sound.setMute(true);
$(this).toggleClass("btn-xs btn-success").toggleClass("btn-xs btn-danger"); $(this).toggleClass("btn-xs btn-success").toggleClass("btn-xs btn-danger");