Merge pull request #2510 from iAmShorty/block-notification

Disable Sound in Dashboard
This commit is contained in:
Sebastian Grewe 2016-06-30 12:39:37 +02:00 committed by GitHub
commit 9e8caa57ca
6 changed files with 44 additions and 13 deletions

5
.gitignore vendored
View File

@ -37,4 +37,7 @@
/vendor/
tests/_output/*
tests/_output/*
# NetBeans Project Directory
/nbproject/*

View File

@ -18,7 +18,7 @@ branches:
install:
- wget http://selenium-release.storage.googleapis.com/2.42/selenium-server-standalone-2.42.2.jar
- composer global require "fxp/composer-asset-plugin:1.0.0-beta2"
- composer global require "fxp/composer-asset-plugin:~1.1.1"
- composer install
@ -38,4 +38,4 @@ script:
after_script:
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover tests/_output/coverage.xml
- php ocular.phar code-coverage:upload --format=php-clover tests/_output/coverage.xml

View File

@ -97,6 +97,13 @@ $aSettings['website'][] = array(
'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' ),

View File

@ -119,6 +119,7 @@ $aGlobal['website']['transactionexplorer']['disabled'] = $setting->getValue('web
$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';

View File

@ -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}

View File

@ -4,8 +4,11 @@
{literal}
$(document).ready(function(){
{/literal}
{if $GLOBAL.website.blockfindersound.enabled|default:"1"}
{literal}
var playSound = localStorage.getItem('playsound');
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();
@ -13,13 +16,25 @@ $(document).ready(function(){
} 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 == 'True') {
var audioPath = "{/literal}{$PATH}{literal}/audio/";
var sound = [ {id:"ding", src:"ding.mp3"} ];
var playSound = 'True';
createjs.Sound.alternateExtensionseExtensions = ["mp3"];
createjs.Sound.registerSounds(sound, audioPath);
canCreateSoundJS = true;
$("#muteButton").removeClass();
$('#muteButton').addClass("btn-xs btn-success toggleSoundButton");
$('#muteButton').find($(".fa")).removeClass('fa-volume-off').addClass('fa-volume-up');
} else {
$("#muteButton").removeClass();
$('#muteButton').addClass("btn-xs btn-danger toggleSoundButton");
$('#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}";
@ -272,13 +287,16 @@ $(document).ready(function(){
// Mute Button
$('#muteButton').click(function(){
if(muteFlag == 2) {
muteFlag = 1;
//alert(playSound);
if(playSound == 'False') {
localStorage.setItem('playsound', 'True');
playSound = 'True';
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 {
muteFlag = 2;
localStorage.setItem('playsound', 'False');
playSound = 'False';
createjs.Sound.setMute(true);
$(this).toggleClass("btn-xs btn-success").toggleClass("btn-xs btn-danger");
$(this).find($(".fa")).removeClass('fa-volume-up').addClass('fa-volume-off');