Quellcode durchsuchen

added more ping options for sounds and auth

causefx vor 8 Jahren
Ursprung
Commit
1637d006c3

+ 4 - 1
api/config/default.php

@@ -151,6 +151,9 @@ return array(
 	'hideRegistration' => false,
 	'favIcon' => '',
 	'pingAuth' => '1',
+	'pingAuthMessage' => '1',
 	'adminPingRefresh' => '60000',
-	'otherPingRefresh' => '600000'
+	'otherPingRefresh' => '600000',
+	'pingOfflineSound' => 'plugins/sounds/default/open-ended.mp3',
+	'pingOnlineSound' => 'plugins/sounds/default/awareness.mp3'
 );

+ 47 - 0
api/functions/organizr-functions.php

@@ -39,6 +39,14 @@ function organizrSpecialSettings()
 				'enabled' => ($GLOBALS['ssoTautulli']) ? true : false,
 				'cookie' => !empty($tautulli) ? true : false,
 			),
+		),
+		'ping' => array(
+			'onlineSound' => $GLOBALS['pingOnlineSound'],
+			'offlineSound' => $GLOBALS['pingOfflineSound'],
+			'auth' => $GLOBALS['pingAuth'],
+			'authMessage' => $GLOBALS['pingAuthMessage'],
+			'adminRefresh' => $GLOBALS['adminPingRefresh'],
+			'everyoneRefresh' => $GLOBALS['otherPingRefresh'],
 		)
 	);
 }
@@ -448,6 +456,27 @@ function getSettingsMain()
 				'value' => $GLOBALS['pingAuth'],
 				'options' => groupSelect()
 			),
+			array(
+				'type' => 'select',
+				'name' => 'pingAuthMessage',
+				'label' => 'Minimum Authentication for Message and Sound',
+				'value' => $GLOBALS['pingAuthMessage'],
+				'options' => groupSelect()
+			),
+			array(
+				'type' => 'select',
+				'name' => 'pingOnlineSound',
+				'label' => 'Online Sound',
+				'value' => $GLOBALS['pingOnlineSound'],
+				'options' => getSounds()
+			),
+			array(
+				'type' => 'select',
+				'name' => 'pingOfflineSound',
+				'label' => 'Offline Sound',
+				'value' => $GLOBALS['pingOfflineSound'],
+				'options' => getSounds()
+			),
 			array(
 				'type' => 'select',
 				'name' => 'adminPingRefresh',
@@ -1038,6 +1067,24 @@ function getThemes()
 	return $themes;
 }
 
+function getSounds()
+{
+	$sounds = array();
+	foreach (glob(dirname(__DIR__, 2) . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . 'sounds' . DIRECTORY_SEPARATOR . 'default' . DIRECTORY_SEPARATOR . "*.mp3") as $filename) {
+		$sounds[] = array(
+			'name' => preg_replace('/\\.[^.\\s]{3,4}$/', '', basename($filename)),
+			'value' => preg_replace('/\\.[^.\\s]{3,4}$/', '', 'plugins/sounds/default/' . basename($filename) . '.mp3')
+		);
+	}
+	foreach (glob(dirname(__DIR__, 2) . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . 'sounds' . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR . "*.mp3") as $filename) {
+		$sounds[] = array(
+			'name' => preg_replace('/\\.[^.\\s]{3,4}$/', '', basename($filename)),
+			'value' => preg_replace('/\\.[^.\\s]{3,4}$/', '', 'plugins/sounds/custom/' . basename($filename) . '.mp3')
+		);
+	}
+	return $sounds;
+}
+
 function getBranches()
 {
 	return array(

+ 3 - 17
js/functions.js

@@ -3949,9 +3949,9 @@ function pingUpdate(pingList,timeout){
                 var previousState = (elm.attr('data-previous-state') == "") ? '' : elm.attr('data-previous-state');
                 var tabName = elm.attr('data-tab-name');
                 var status = (v == false) ? 'down' : 'up';
-                var sendMessage = (previousState !== status && previousState !== '') ? true : false;
-                var audioDown = new Audio('plugins/sounds/default/open-ended.mp3');
-                var audioUp = new Audio('plugins/sounds/default/awareness.mp3');
+                var sendMessage = (previousState !== status && previousState !== '' && activeInfo.user.groupID <= activeInfo.settings.ping.authMessage) ? true : false;
+                var audioDown = new Audio(activeInfo.settings.ping.offlineSound);
+                var audioUp = new Audio(activeInfo.settings.ping.onlineSound);
                 elm.attr('data-previous-state', status);
                 switch (status){
                     case 'down':
@@ -3978,20 +3978,6 @@ function pingUpdate(pingList,timeout){
     if(typeof timeouts[timeoutTitle] !== 'undefined'){ clearTimeout(timeouts[timeoutTitle]); }
     timeouts[timeoutTitle] = setTimeout(function(){ pingUpdate(pingList,timeout); }, timeout);
 }
-function sound(src) {
-    this.sound = document.createElement("audio");
-    this.sound.src = src;
-    this.sound.setAttribute("preload", "auto");
-    this.sound.setAttribute("controls", "none");
-    this.sound.style.display = "none";
-    document.body.appendChild(this.sound);
-    this.play = function(){
-        this.sound.play();
-    }
-    this.stop = function(){
-        this.sound.pause();
-    }
-}
 function launch(){
 	organizrConnect('api/?v1/launch_organizr').success(function (data) {
         try {

+ 0 - 0
plugins/sounds/custom/only-mp3s-here.txt