add cache and rename some files

This commit is contained in:
2026-01-15 15:41:19 +01:00
parent 7879f15726
commit b64815d9ab
4753 changed files with 931902 additions and 1 deletions

View File

@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="6" viewBox="0 0 12 6">
<polygon fill="#8E8E92" fill-rule="evenodd" points="5 4 9 0 10 1 5 6 0 1 1 0"/>
</svg>

After

Width:  |  Height:  |  Size: 176 B

View File

@@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" width="7" height="12" viewBox="0 0 7 12">
<g fill="#8E8E92" transform="translate(4, 5) rotate(-90) translate(-4, -5) translate(-2, 2)">
<polygon id="Path" points="5 4 9 0 10 1 5 6 0 1 1 0"></polygon>
</g>
</svg>

After

Width:  |  Height:  |  Size: 273 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 234 B

View File

@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="10" viewBox="0 0 12 10">
<polygon fill="#FFF" points="7.2 7.5 7.2 -1.3 8.7 -1.3 8.6 9.1 2.7 8.7 2.7 7.2" transform="rotate(37 5.718 3.896)"/>
</svg>

After

Width:  |  Height:  |  Size: 215 B

View File

@@ -0,0 +1,25 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<g fill="none" fill-rule="evenodd">
<path fill="#9C9C9C" fill-rule="nonzero"
d="M1,5 L1,14 L14,14 L14,5 L1,5 Z M0,1 L15,1 L15,15 L0,15 L0,1 Z M14,4 L14,2 L1,2 L1,4 L14,4 Z"/>
<rect width="1" height="1" x="2" fill="#9C9C9C" fill-rule="nonzero"/>
<rect width="1" height="1" x="12" fill="#9C9C9C" fill-rule="nonzero"/>
<g transform="translate(3 7)">
<rect width="1" height="1" x="2" fill="#9C9C9C"/>
<rect width="1" height="1" fill="#666"/>
<rect width="1" height="1" x="4" fill="#9C9C9C"/>
<rect width="1" height="1" x="6" fill="#9C9C9C"/>
<rect width="1" height="1" x="8" fill="#9C9C9C"/>
<rect width="1" height="1" y="2" fill="#9C9C9C"/>
<rect width="1" height="1" x="2" y="2" fill="#9C9C9C"/>
<rect width="1" height="1" x="4" y="2" fill="#9C9C9C"/>
<rect width="1" height="1" x="6" y="2" fill="#9C9C9C"/>
<rect width="1" height="1" x="8" y="2" fill="#9C9C9C"/>
<rect width="1" height="1" y="4" fill="#9C9C9C"/>
<rect width="1" height="1" x="2" y="4" fill="#9C9C9C"/>
<rect width="1" height="1" x="4" y="4" fill="#9C9C9C"/>
<rect width="1" height="1" x="6" y="4" fill="#9C9C9C"/>
<rect width="1" height="1" x="8" y="4" fill="#666"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -0,0 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<g fill="#9C9C9C">
<path d="M15,15 L1.77635684e-15,15 L1.77635684e-15,1 L15,1 L15,15 Z M5,7 L5,8 L6,8 L6,7 L5,7 Z M3,7 L3,8 L4,8 L4,7 L3,7 Z M7,7 L7,8 L8,8 L8,7 L7,7 Z M9,7 L9,8 L10,8 L10,7 L9,7 Z M11,7 L11,8 L12,8 L12,7 L11,7 Z M3,9 L3,10 L4,10 L4,9 L3,9 Z M5,9 L5,10 L6,10 L6,9 L5,9 Z M7,9 L7,10 L8,10 L8,9 L7,9 Z M9,9 L9,10 L10,10 L10,9 L9,9 Z M11,9 L11,10 L12,10 L12,9 L11,9 Z M3,11 L3,12 L4,12 L4,11 L3,11 Z M5,11 L5,12 L6,12 L6,11 L5,11 Z M7,11 L7,12 L8,12 L8,11 L7,11 Z M9,11 L9,12 L10,12 L10,11 L9,11 Z M11,11 L11,12 L12,12 L12,11 L11,11 Z M14,4 L14,2 L1,2 L1,4 L14,4 Z"/>
<rect width="1" height="1" x="2"/>
<rect width="1" height="1" x="12"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 787 B

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="6" height="6" viewBox="0 0 6 6">
<circle cx="3" cy="3" r="3" fill="#FFF"/>
</svg>

After

Width:  |  Height:  |  Size: 136 B

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,290 @@
.sdpi-item-group.folder {
width: 232px;
display: flex;
align-items: center;
}
.sdpi-folder-info{
overflow-y:auto;
overflow-wrap: break-word;
word-wrap: break-word;
hyphens: auto;
min-width: 100px;
max-width: 123px;
max-height: 32px;
margin-top: 0px;
margin-left: 5px;
margin-right: 3px;
display: inline-block;
/*overflow:hidden;*/
padding: 6px 4px;
background-color: var(--sdpi-background);
cursor:text;
}
label.sdpi-folder-label {
color: var(--sdpi-color);
font-size: 8pt;
background-color: var(--sdpi-background);
border: 1pt solid var(--sdpi-buttonbordercolor);
border-radius: var(--sdpi-borderradius);
border-color: var(--sdpi-buttonbordercolor);
min-height: 23px !important;
height: 23px !important;
margin-right: 0px;
cursor: pointer;
user-select: none;
display: inline-block;
line-height: 20px;
padding: 0px 4px;
margin: auto;
float: right;
}
label.sdpi-folder-label:active{
background-color: var(--sdpi-color);
color:#303030;
}
#showInfoDiv {
overflow: hidden;
}
#infoDl {
cursor: text;
user-select: text;
overflow-y: auto;
overflow-wrap: break-word;
word-wrap: break-word;
}
#infoDl > dd {
margin-bottom: 3px;
}
#infoDl > #showPath {
padding-bottom: 8px; /*workaround to fix overflow bug*/
}
#timestampFormat{
font-size:95%;
}
.nonDisplayed{
display: none;
}
#filename{
min-width: 150px;
max-width: 175px;
}
#addVariable_btn{
width:30px;
background-image: url("../icons/pi_icons/button_addVariables_active.svg");
background-repeat: no-repeat;
background-position: center;
background-size: contain;
}
#addVariable:active{
background-image: url("../icons/pi_icons/button_addVariables_pressed.svg");
}
#showInfoDiv .sdpi-item {
min-height: 0px;
max-height: 32px;
margin: 0px;
padding: 0px;
}
#showInfoDiv p{
word-wrap: break-word;
vertical-align: middle;
margin-bottom: 4px;
max-width: 220px;
}
#statusInfo{
color:#3281a8;
}
#text{
min-width: 150px;
max-width: 175px;
}
#marker_context-menu{
min-width:175px;
}
.soundboard-item {
height: 32px;
overflow: hidden;
text-overflow: ellipsis;
width: 150px;
white-space: wrap;
display: flex;
flex-direction: row;
font-size: 11px;
vertical-align: middle;
align-items: center;
justify-content: center;
gap: 5px;
flex: 1;
}
.sb-img {
float: left;
width: 24px;
height: 24px;
}
.sb-emoji {
float: left;
width: 24px;
height: 24px;
font-size: 18px;
}
#soundboard-table {
border: none;
border-spacing: 5px 5px;
}
#soundboard-container {
max-width: none;
overflow-y: auto;
}
/* override spdi.css */
#soundboard tr {
background-color: rgba(0, 0, 0, 0);
}
#soundboard tr td.interactive{
background-color: rgba(0, 0, 0, .2);
border-radius: 8px;
transition: 0.1s;
-webkit-user-drag: none;
border: 1px solid rgba(255,255,255,0);
max-width: 50%;
}
#soundboard tr td.dummy span{
width: 150px;
display: inline-block;
margin-left: 2px;
}
#soundboard tr td.dummy:hover{
background-color: rgba(255, 255, 255, 0);
}
#soundboard tr td.interactive:hover{
background-color: rgba(255, 255, 255, .2);
}
#soundboard tr td.interactive:active{
background-color: rgba(255, 255, 255, .1);
}
#soundboard tr td.interactive.picked{
background-color: rgba(255, 255, 255, .1);
border: 1px solid rgba(255,255,255,.2);
}
#soundboard tr td.interactive.picked:hover{
background-color: rgba(255, 255, 255, .2);
border: 1px solid rgba(255,255,255,.3);
}
#soundboard tr td.interactive.picked:active{
background-color: rgba(255, 255, 255, .1);
border: 1px solid rgba(255,255,255,.3);
}
#soundboard tr.sb-label {
background-color: rgba(0, 0, 0, 0);
}
#soundboard tr.sb-label td:hover {
background-color: rgba(0,0,0, 0);
}
#searchbar-container {
}
#searchbar {
max-width: none;
border-bottom: 1px solid rgba(255, 255, 255, .1);
}
#searcher::placeholder {
color: #AAA;
}
#placeholder {
display: flex;
flex-direction: column;
max-height: 100%;
}
.message {
display: block;
position: relative;
padding: 0.25rem;
font-size: 1.15rem;
font-weight: normal;
font-style: italic;
line-height: 1.0em;
text-align: left;
margin-left: calc(100px);
max-width: 230px;
min-height: 26px;
}
.message:before {
content: " ";
display: block;
position: absolute;
left: -2.0rem;
top: 0.25rem;
font-size: 1.5rem;
width: 1.2em;
height: 1.2em;
background-repeat: no-repeat;
}
.message.hint:before {
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'%3E%3Cpath fill='%23999' d='M10,18 C5.581722,18 2,14.418278 2,10 C2,5.581722 5.581722,2 10,2 C14.418278,2 18,5.581722 18,10 C18,14.418278 14.418278,18 10,18 Z M10,8 C9.44771525,8 9,8.42137906 9,8.94117647 L9,14.0588235 C9,14.5786209 9.44771525,15 10,15 C10.5522847,15 11,14.5786209 11,14.0588235 L11,8.94117647 C11,8.42137906 10.5522847,8 10,8 Z M10,5 C9.44771525,5 9,5.44082732 9,5.98461538 L9,6.01538462 C9,6.55917268 9.44771525,7 10,7 C10.5522847,7 11,6.55917268 11,6.01538462 L11,5.98461538 C11,5.44082732 10.5522847,5 10,5 Z'/%3E%3C/svg%3E%0A");
}
.message.warning:before {
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'%3E%3Cpath fill='%23999' fill-rule='evenodd' d='M9.03952676,0.746646542 C9.57068894,-0.245797319 10.4285735,-0.25196227 10.9630352,0.746646542 L19.7705903,17.2030214 C20.3017525,18.1954653 19.8777595,19 18.8371387,19 L1.16542323,19 C0.118729947,19 -0.302490098,18.2016302 0.231971607,17.2030214 L9.03952676,0.746646542 Z M10,2.25584053 L1.9601405,17.3478261 L18.04099,17.3478261 L10,2.25584053 Z M10,5.9375 C10.531043,5.9375 10.9615385,6.37373537 10.9615385,6.91185897 L10.9615385,11.6923077 C10.9615385,12.2304313 10.531043,12.6666667 10,12.6666667 C9.46895697,12.6666667 9.03846154,12.2304313 9.03846154,11.6923077 L9.03846154,6.91185897 C9.03846154,6.37373537 9.46895697,5.9375 10,5.9375 Z M10,13.4583333 C10.6372516,13.4583333 11.1538462,13.9818158 11.1538462,14.6275641 L11.1538462,14.6641026 C11.1538462,15.3098509 10.6372516,15.8333333 10,15.8333333 C9.36274837,15.8333333 8.84615385,15.3098509 8.84615385,14.6641026 L8.84615385,14.6275641 C8.84615385,13.9818158 9.36274837,13.4583333 10,13.4583333 Z'/%3E%3C/svg%3E%0A");
right: 10px;
}
a {
color:rgb(177, 177, 177);
}
a:hover {
color:rgb(255, 255, 255);
cursor:pointer;
}
a:active {
color:rgb(167, 167, 167);
}

View File

@@ -0,0 +1,11 @@
/*!
@file deafenPI.js
@brief Contains PI for Toggle Deafen action
@author Valentin Reinbold
@copyright (c) 2021, Corsair Memory, Inc. All Rights Reserved.
*/
function DeafenPI(inContext, inLanguage) {
// Inherit from PI
PI.call(this, inContext, inLanguage);
}

View File

@@ -0,0 +1,65 @@
<!--Twemoji by Twitter is licensed under the MIT license (code) and CC-BY 4.0 (graphics)
The graphics have been repackaged as data URIs in a JSON file but are otherwise unchanged.-->
<!DOCTYPE html>
<html>
<head>
<title>com.elgato.discord.pi</title>
<meta charset="UTF-8" />
<!-- Import style sheets -->
<link rel="stylesheet" href="css/sdpi.css">
<link rel="stylesheet" href="css/stylesheet.css">
<!-- Import scripts -->
<script type="text/javascript" src="lib/twemoji.14.0.2.min.js" ></script>
<script type="text/javascript" src="lib/fuzzysort.min.js" ></script>
<script type="text/javascript" src="main.js" ></script>
<script type="text/javascript" src="pi.js" ></script>
<script type="text/javascript" src="mutePI.js" ></script>
<script type="text/javascript" src="deafenPI.js" ></script>
<script type="text/javascript" src="voiceChannelPI.js" ></script>
<script type="text/javascript" src="textChannelPI.js" ></script>
<script type="text/javascript" src="pushToTalkPI.js" ></script>
<script type="text/javascript" src="pushToMutePI.js" ></script>
<script type="text/javascript" src="volumePI.js" ></script>
<script type="text/javascript" src="volumeButtonPI.js" ></script>
<script type="text/javascript" src="userVolumeButtonPI.js" ></script>
<script type="text/javascript" src="userVolumeDialPI.js" ></script>
<script type="text/javascript" src="pttTogglePI.js" ></script>
<script type="text/javascript" src="notificationsPI.js" ></script>
<script type="text/javascript" src="setAudioDevicePI.js" ></script>
<script type="text/javascript" src="serverStatsPI.js" ></script>
<script type="text/javascript" src="soundboardPI.js" ></script>
</head>
<body>
<!-- Property Inspector -->
<div class="sdpi-wrapper" id="pi">
<!-- Placeholder for more UI elements -->
<div id="placeholder"></div>
<!-- App warning message -->
<div id="app-warning-message" style="display: none">
<div class='sdpi-item'>
<details class='message'>
<summary id='app-warning'></summary>
</details>
</div>
</div>
<!-- Auth warning message & button -->
<div id="auth-warning-message" style="display: none">
<div class='sdpi-item'>
<details class='message'>
<summary id='auth-warning'></summary>
</details>
</div>
<div class="sdpi-item">
<div class='sdpi-item-label' id='access-label'></div>
<button class="sdpi-item-value" id='access-button'></button>
</div>
</div>
</div>
</body>
</html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,189 @@
/*!
@file main.js
@brief Handles SD behavior
@author Valentin Reinbold
@copyright (c) 2021, Corsair Memory, Inc. All Rights Reserved.
*/
// Global web socket
var websocket = null;
// Global plugin settings
var globalSettings = {};
// Global settings
var settings = {};
// Setup the websocket and handle communication
function connectElgatoStreamDeckSocket(inPort, inUUID, inRegisterEvent, inInfo, inActionInfo) {
// Parse parameter from string to object
var actionInfo = JSON.parse(inActionInfo);
var info = JSON.parse(inInfo);
console.log("actionInfo", actionInfo);
console.log("info", info);
// Save global settings
settings = actionInfo['payload']['settings'];
// Retrieve language
var language = info['application']['language'];
// Retrieve action identifier
var action = actionInfo['action'];
// Open the web socket to Stream Deck
// Use 127.0.0.1 because Windows needs 300ms to resolve localhost
websocket = new WebSocket("ws://127.0.0.1:" + inPort);
// WebSocket is connected, send message
websocket.onopen = function () {
// Register property inspector to Stream Deck
registerPI(inRegisterEvent, inUUID);
// Request the global settings of the plugin
requestGlobalSettings(inUUID);
};
// Create actions
if (action == "com.elgato.discord.mute") {
var pi = new MutePI(inUUID, language);
}
else if (action == "com.elgato.discord.deafen") {
var pi = new DeafenPI(inUUID, language);
}
else if (action == "com.elgato.discord.channel.voice") {
var pi = new VoiceChannelPI(inUUID, language);
}
else if (action == "com.elgato.discord.channel.text") {
var pi = new TextChannelPI(inUUID, language);
}
else if (action == "com.elgato.discord.pushto.talk") {
var pi = new PushToTalkPI(inUUID, language);
}
else if (action == "com.elgato.discord.pushto.mute") {
var pi = new PushToMutePI(inUUID, language);
}
else if (action == "com.elgato.discord.volumecontrol") {
var pi = new VolumePI(inUUID, language);
}
else if (action == "com.elgato.discord.volumecontrolbutton") {
var pi = new VolumeButtonPI(inUUID, language);
}
else if (action == "com.elgato.discord.uservolumecontrolbutton") {
var pi = new UserVolumeButtonPI(inUUID, language);
}
else if (action == "com.elgato.discord.uservolumecontroldial") {
var pi = new UserVolumeDialPI(inUUID, language);
}
else if (action == "com.elgato.discord.pushtotalktoggle") {
var pi = new PushToTalkTogglePI(inUUID, language);
}
else if (action == "com.elgato.discord.notifications") {
var pi = new NotificationsPI(inUUID, language);
}
else if (action == "com.elgato.discord.setaudiodevice") {
var pi = new SetAudioDevicePI(inUUID, language);
}
else if (action == "com.elgato.discord.serverstats") {
var pi = new ServerStatsPI(inUUID, language);
}
else if (action == "com.elgato.discord.soundboard") {
var pi = new SoundboardPI(inUUID, language);
}
websocket.onmessage = function (evt) {
// Received message from Stream Deck
var jsonObj = JSON.parse(evt.data);
var event = jsonObj['event'];
var jsonPayload = jsonObj['payload'];
if(event == "didReceiveGlobalSettings") {
// Set global plugin settings
globalSettings = jsonPayload['settings'];
}
else if(event == "didReceiveSettings") {
// Save global settings after default was set
settings = jsonPayload['settings'];
}
else if(event == "sendToPropertyInspector") {
// Initialize & receive the new data
var data = jsonPayload ?? {};
// Load Property Inspector
pi.load(data);
}
};
}
// Register property inspector
function registerPI(inEvent, inUUID) {
if (websocket) {
const json = {
"event": inEvent,
"uuid": inUUID
};
websocket.send(JSON.stringify(json));
}
}
// Set data to plugin
function sendToPlugin(inAction, inContext, inData) {
if (websocket) {
const json = {
"action": inAction,
"event": "sendToPlugin",
"context": inContext,
"payload": inData
};
websocket.send(JSON.stringify(json));
}
}
// Save settings
function saveSettings(inUUID, inSettings) {
if (websocket) {
const json = {
"event": "setSettings",
"context": inUUID,
"payload": inSettings
};
websocket.send(JSON.stringify(json));
}
}
// Save global settings
function saveGlobalSettings(inUUID) {
if (websocket) {
const json = {
"event": "setGlobalSettings",
"context": inUUID,
"payload": globalSettings
};
websocket.send(JSON.stringify(json));
}
}
// Request global settings
function requestGlobalSettings(inUUID) {
if (websocket) {
const json = {
"event": "getGlobalSettings",
"context": inUUID
};
websocket.send(JSON.stringify(json));
}
}
//
function openURL(url) {
if (websocket) {
const json = {
"event": "openUrl",
"payload": {
"url": url
}
};
websocket.send(JSON.stringify(json));
}
}

View File

@@ -0,0 +1,11 @@
/*!
@file mutePI.js
@brief Contains PI for Toggle Mute action
@author Valentin Reinbold
@copyright (c) 2021, Corsair Memory, Inc. All Rights Reserved.
*/
function MutePI(inContext, inLanguage) {
// Inherit from PI
PI.call(this, inContext, inLanguage);
}

View File

@@ -0,0 +1,57 @@
/*!
@file pushToTalkPI.js
@brief Contains PI for Push to Talk action
@author Valentin Reinbold
@copyright (c) 2021, Corsair Memory, Inc. All Rights Reserved.
*/
function NotificationsPI(inContext, inLanguage) {
// Inherit from PI
PI.call(this, inContext, inLanguage);
// Save a copy of a method
var piSaveSettings = this.saveSettings;
// Temporarily(?) disable configuration
return;
// Add fields
var fields =`
<div class="sdpi-item" id="on-press">
<div class="sdpi-item-label translated" x-text="OnPress"></div>
<select class="sdpi-item-value select" id="select-press">
<option value="nothing" class="translated" x-text="DoNothing"></option>
<option value="open" class="translated" x-text="OnPressNotification"></option>
<option value="clear" class="translated" x-text="OnPressClearNotification"></option>
</select>
</div>
<div class="sdpi-item" id="on-longpress">
<div class="sdpi-item-label translated" x-text="OnLongPress"></div>
<select class="sdpi-item-value select" id="select-longpress">
<option value="nothing" class="translated" x-text="DoNothing"></option>
<option value="open" class="translated" x-text="OnPressNotification"></option>
<option value="clear" class="translated" x-text="OnPressClearNotification"></option>
</select>
</div>
`;
document.getElementById('placeholder').innerHTML = fields;
this.initField('select-press');
this.initField('select-longpress');
// Before overwriting parrent method, save a copy of it
var piLoad = this.load;
// Public function called to load the fields
this.load = function (data) {
// Call PI load method
piLoad.call(this, data);
// Enable / Disable the fields
document.getElementById('select-press').disabled = data.disabled || data.unauthorized;
document.getElementById('select-longpress').disabled = data.disabled || data.unauthorized;
// Show PI
document.getElementById('pi').style.display = "block";
}
}

View File

@@ -0,0 +1,387 @@
/*!
@file pi.js
@brief Contains PI for base action
@author Valentin Reinbold
@copyright (c) 2021, Corsair Memory, Inc. All Rights Reserved.
*/
function PI(inContext, inLanguage) {
// Init PI
var instance = this;
var appWarningMessage = document.getElementById('app-warning-message');
var authWarningMessage = document.getElementById('auth-warning-message');
var accessButton = document.getElementById('access-button');
// Add event listener
accessButton.addEventListener("click", () => {
instance.sendToPlugin({ 'grantAccess': true });
});
// Private function to return the action identifier
function getAction() {
// Find out type of action
if (instance instanceof MutePI)
return "com.elgato.discord.mute";
if (instance instanceof DeafenPI)
return "com.elgato.discord.deafen";
if (instance instanceof VoiceChannelPI)
return "com.elgato.discord.channel.voice";
if (instance instanceof TextChannelPI)
return "com.elgato.discord.channel.text";
if (instance instanceof PushToTalkPI)
return "com.elgato.discord.pushto.talk";
if (instance instanceof PushToMutePI)
return "com.elgato.discord.pushto.mute";
if (instance instanceof VolumePI)
return "com.elgato.discord.volumecontrol";
if (instance instanceof VolumeButtonPI)
return "com.elgato.discord.volumecontrolbutton";
if (instance instanceof UserVolumeButtonPI)
return "com.elgato.discord.uservolumecontrolbutton";
if (instance instanceof UserVolumeDialPI)
return "com.elgato.discord.uservolumecontroldial";
if (instance instanceof PushToTalkTogglePI)
return "com.elgato.discord.pushtotalktoggle";
if (instance instanceof NotificationsPI)
return "com.elgato.discord.notifications";
if (instance instanceof SetAudioDevicePI)
return "com.elgato.discord.setaudiodevice";
if (instance instanceof ServerStatsPI)
return "com.elgato.discord.serverstats";
if (instance instanceof SoundboardPI)
return "com.elgato.discord.soundboard";
}
// Public function called to initialize field
this.initField = function(key) {
// Init data
updateField(key, settings[key]);
// Add event listener
document.getElementById(key).addEventListener("input", fieldChanged);
}
// Private function called to update field
function updateField(key, value) {
value = value || "";
// Update field content
document.getElementById(key).value = value;
}
// Field changed
function fieldChanged(event) {
var key = event.srcElement.id;
var value = (event ? event.target.value : undefined);
// Update data
updateField(key, value);
// Update settings
settings[key] = value;
instance.saveSettings();
}
// Public function called to load the fields
this.load = function (data) {
if (data.disabled) {
// Show app warning message
appWarningMessage.style.display = "block";
authWarningMessage.style.display = "none";
}
else if (data.unauthorized) {
// Show auth warning message
appWarningMessage.style.display = "none";
authWarningMessage.style.display = "block";
}
else {
// Hide warning messages
appWarningMessage.style.display = "none";
authWarningMessage.style.display = "none";
}
}
// Public function to send data to the plugin
this.sendToPlugin = function (inData) {
sendToPlugin(getAction(), inContext, inData);
};
// Public function to save the settings
this.saveSettings = function () {
saveSettings(inContext, settings);
};
setTimeout(()=>this.saveSettings(), 1000);
/* --- Localization --- */
this.localization = {};
var finished = false;
loadLocalization(inLanguage);
loadLocalization("en");
function loadLocalization(language) {
getLocalization(language, function(inStatus, inLocalization) {
if (inStatus) {
instance.localization[language] = inLocalization['PI'];
if (!finished) {
finished = true;
}
else {
instance.localize(function (key) {
// Actual localization
var value = instance.localization[inLanguage][key];
if (value != undefined && value != "") {
return value;
}
// Default localization
value = instance.localization["en"][key];
if (value != undefined && value != "") {
return value;
}
return key;
});
}
}
else {
console.log(inLocalization);
}
});
}
// Localize the UI
this.localize = function (tr) {
// Check if localizations were loaded
if (instance.localization == null) {
return;
}
// Localize the warning message select
document.getElementById("app-warning").innerHTML = tr("AppWarning");
document.getElementById("auth-warning").innerHTML = tr("AuthWarning");
document.getElementById("access-label").innerHTML = tr("AccessLabel");
document.getElementById("access-button").innerHTML = tr("AccessButton");
const nodes = document.getElementsByClassName('translated');
for(const node of nodes){
const text = node.getAttribute("x-text");
//if(text){
// If the node has a dummy span child, we need to recreate it
let hasSpan = false;
const spans = node.getElementsByTagName("span");
if(spans.length > 0){
hasSpan = true;
}
const translated = tr(text);
node.innerHTML = translated ? translated : text;
if(hasSpan){
node.prepend(document.createElement("span"));
}
//}
}
};
// Load the localizations
function getLocalization(inLanguage, inCallback) {
var url = "../" + inLanguage + ".json";
var xhr = new XMLHttpRequest();
xhr.open("GET", url, true);
xhr.onload = function () {
if (xhr.readyState == XMLHttpRequest.DONE) {
try {
data = JSON.parse(xhr.responseText);
var localization = data['Localization'];
inCallback(true, localization);
}
catch(e) {
inCallback(false, 'Localizations is not a valid json.');
}
}
else {
inCallback(false, 'Could not load the localizations.');
}
};
xhr.onerror = function () {
inCallback(false, 'An error occurred while loading the localizations.');
};
xhr.ontimeout = function () {
inCallback(false, 'Localization timed out.');
};
xhr.send();
}
this.setAndValidateField = function(input, key, value){
if(!input || !input.type){
return;
}
if (value === undefined){
value = settings[key];
}
switch(input.type){
//case "range": case "select-one":
case "radio": case "checkbox":
break;
case "range":
input.value = parseInt(value);
if( input.value != settings[key]){
settings[key] = parseInt(input.value);
}
break;
default:
input.value = value;
if( input.value != settings[key]){
settings[key] = input.value;
}
break;
}
}
this.addSliderTooltip = function (slider, textFn) {
if (typeof textFn != "function"){
textFn = (value)=>{
return value;
}
}
const adjustSlider = slider;
const tooltip = document.querySelector('.sdpi-info-label');
// Add clickable labels
const parent = slider.parentNode;
if (parent){
const clickables = parent.getElementsByClassName("clickable");
for( const clickable of clickables){
const value = clickable.getAttribute("x-value");
if (value){
clickable.addEventListener('click', (event)=>{
slider.value = value;
let ev = new Event("change", { "bubbles": true, "cancelable": true });
slider.dispatchEvent(ev);
})
}
}
}
tooltip.textContent = textFn(parseFloat(adjustSlider.value));
const fn = () => {
const tw = tooltip.getBoundingClientRect().width;
const rangeRect = adjustSlider.getBoundingClientRect();
const w = rangeRect.width - tw / 2;
const percnt = (adjustSlider.value - adjustSlider.min) / (adjustSlider.max - adjustSlider.min);
if (tooltip.classList.contains('hidden')) {
tooltip.style.top = '-1000px';
} else {
tooltip.style.left = `${rangeRect.left + Math.round(w * percnt) - tw / 4}px`;
tooltip.textContent = textFn(parseFloat(adjustSlider.value));
tooltip.style.top = `${rangeRect.top - 30}px`;
}
}
if (adjustSlider) {
adjustSlider.addEventListener(
'mouseenter',
function() {
tooltip.classList.remove('hidden');
tooltip.classList.add('shown');
fn();
},
false
);
adjustSlider.addEventListener(
'mouseout',
function() {
tooltip.classList.remove('shown');
tooltip.classList.add('hidden');
fn();
},
false
);
adjustSlider.addEventListener('input', fn, false);
}
}
// function called to empty the field options
this.emptyField = function (key) {
var options = document.getElementsByClassName(key);
while (options.length > 0) {
options[0].parentNode.removeChild(options[0]);
}
}
this.updateName = function(settingsField, nameField, node){
if (settings[settingsField] && node.selectedIndex >= 0){
// Ensure we actually have a nick for the user
let selectedOption = node.options[node.selectedIndex];
if (selectedOption){
settings[nameField] = selectedOption.innerText;
}
}
}
/** function called to load the field options
* @param {{key: any, value: any}} defaults
*/
this.loadField = function(key, list, defaults) {
// Remove previously shown options
this.emptyField(key);
if(Array.isArray(list)){
const newList = {};
for(const item of list){
if(item && item.id){
newList[item.id] = item;
}
}
list = newList;
}
if(defaults !== undefined){
if (typeof list !== "object"){
list = {};
}
if(defaults.value){
list[defaults.key] = {name: defaults.value};
}
}
// If there is no element
if (list == undefined || Object.keys(list).length == 0) {
// Show & Select the 'Nothing' option
document.getElementById('no-' + key).style.display = "block";
document.getElementById(key).value = 'no-' + key;
return;
}
// Hide the 'Nothing' option
document.getElementById('no-' + key).style.display = "none";
// Sort the elements alphabatically
var IDsSorted = Object.keys(list).sort((a, b) => {
return list[a].name.localeCompare(list[b].name);
});
// Add the options
IDsSorted.forEach(id => {
var option = "<option value='" + id + "' class='" + key + "'>" + list[id].name + "</option>";
document.getElementById('no-' + key).insertAdjacentHTML("beforebegin", option);
});
// If no existing element configured
if (settings[key] == undefined || !(settings[key] in list)) {
// If a default wasn't provided
if (!defaults || !defaults.key){
// Choose the first option in the list
settings[key] = IDsSorted[0];
}
else {
// Choose the default option
settings[key] = defaults.key;
}
this.saveSettings();
}
// Select the currently configured element
document.getElementById(key).value = settings[key];
}
}

View File

@@ -0,0 +1,11 @@
/*!
@file pushToTalkPI.js
@brief Contains PI for Push to Talk action
@author Valentin Reinbold
@copyright (c) 2021, Corsair Memory, Inc. All Rights Reserved.
*/
function PushToTalkTogglePI(inContext, inLanguage) {
// Inherit from PI
PI.call(this, inContext, inLanguage);
}

View File

@@ -0,0 +1,11 @@
/*!
@file pushToMutePI.js
@brief Contains PI for Push to Mute action
@author Valentin Reinbold
@copyright (c) 2021, Corsair Memory, Inc. All Rights Reserved.
*/
function PushToMutePI(inContext, inLanguage) {
// Inherit from PI
PI.call(this, inContext, inLanguage);
}

View File

@@ -0,0 +1,11 @@
/*!
@file pushToTalkPI.js
@brief Contains PI for Push to Talk action
@author Valentin Reinbold
@copyright (c) 2021, Corsair Memory, Inc. All Rights Reserved.
*/
function PushToTalkPI(inContext, inLanguage) {
// Inherit from PI
PI.call(this, inContext, inLanguage);
}

View File

@@ -0,0 +1,113 @@
/*!
@file pushToTalkPI.js
@brief Contains PI for Push to Talk action
@author Valentin Reinbold
@copyright (c) 2021, Corsair Memory, Inc. All Rights Reserved.
*/
function ServerStatsPI(inContext, inLanguage) {
// Inherit from PI
PI.call(this, inContext, inLanguage);
// Save a copy of a method
var piSaveSettings = this.saveSettings;
// Add fields
var fields =`
<div class='sdpi-item'>
<div class='sdpi-item-label translated' id='server-label' x-text="Server"></div>
<select class='sdpi-item-value select' id='server'>
<option disabled id='no-server' class="translated" value='no-server' x-text="NoServer"></option>
</select>
</div>
<div class="sdpi-item" id="display-messages">
<div class="sdpi-item-label translated" x-text="SrvStatMsg"></div>
<select class="sdpi-item-value select" id="select-messages">
<option value="nothing" class="translated" x-text="DontDisplay"></option>
<option value="display" class="translated" x-text="SrvStatMsgDisplayNew"></option>
</select>
</div>
<div class="sdpi-item" id="display-users">
<div class="sdpi-item-label translated" x-text="Users"></div>
<select class="sdpi-item-value select" id="select-users">
<option value="nothing" class="translated" x-text="DontDisplay" selected></option>
<option value="online" class="translated" x-text="SrvStatUsrOnline"></option>
<option value="active" class="translated" x-text="SrvStatUsrActive"></option>
</select>
</div>
<div class="message warning" id="widget-not-enabled" >
<a href="#" id="warn-link"><span class="translated" x-text="SrvWidgetWarn"></span></a></div>
<div class="sdpi-item" id="on-press">
<div class="sdpi-item-label translated" x-text="OnPress"></div>
<select class="sdpi-item-value select" id="select-press">
<option value="nothing" class="translated" x-text="DoNothing"></option>
<option value="open" class="translated" x-text="OnPressRecentMsg"></option>
<option value="clear" class="translated" x-text="OnPressClearMsg"></option>
</select>
</div>
<div class="sdpi-item" id="on-longpress">
<div class="sdpi-item-label translated" x-text="OnLongPress"></div>
<select class="sdpi-item-value select" id="select-longpress">
<option value="nothing" class="translated" x-text="DoNothing"></option>
<option value="open" class="translated" x-text="OnPressRecentMsg"></option>
<option value="clear" class="translated" x-text="OnPressClearMsg"></option>
</select>
</div>
`;
document.getElementById('placeholder').innerHTML = fields;
// Temporarily(?) disable press/long press customization
document.getElementById('on-press').style.display = "none";
document.getElementById('on-longpress').style.display = "none";
document.getElementById('warn-link').onclick = ()=>{
openURL("https://discord.com/blog/add-the-discord-widget-to-your-site");
}
this.initField('server');
const serverEl = document.getElementById("server");
serverEl.addEventListener("change", () => {
settings['serverName'] = serverEl.options[serverEl.selectedIndex].innerText;
piSaveSettings();
});
this.initField('select-messages');
this.initField('select-users');
this.initField('select-press');
this.initField('select-longpress');
document.getElementById('widget-not-enabled').style.display = "none";
// Before overwriting parrent method, save a copy of it
var piLoad = this.load;
// Public function called to load the fields
this.load = function (data) {
// Call PI load method
piLoad.call(this, data);
// If action enabled
if (!data.disabled && !data.unauthorized) {
// Load all servers
let defaultsServer = {key: settings["server"], value: settings["serverName"]};
this.loadField('server', data.servers, defaultsServer);
document.getElementById('widget-not-enabled').style.display = "none";
if(data.warning){
document.getElementById(data.warning).style.removeProperty("display");
}
}
// Enable / Disable the fields
document.getElementById('server').disabled = data.disabled || data.unauthorized;
document.getElementById('select-messages').disabled = data.disabled || data.unauthorized;
document.getElementById('select-users').disabled = data.disabled || data.unauthorized;
document.getElementById('select-press').disabled = data.disabled || data.unauthorized;
document.getElementById('select-longpress').disabled = data.disabled || data.unauthorized;
// Show PI
document.getElementById('pi').style.display = "block";
}
}

View File

@@ -0,0 +1,149 @@
/*!
@file textChannelPI.js
@brief Contains PI for Text Channel action
@author Andrew story
@copyright (c) 2023, Corsair Memory, Inc. All Rights Reserved.
*/
function SetAudioDevicePI(inContext, inLanguage) {
// Inherit from PI
PI.call(this, inContext, inLanguage);
// Save a copy of a method
var piSaveSettings = this.saveSettings;
this.defaultName = "Default";
// Add fields
var fields =`
<div class="sdpi-item" id="mode">
<div class="sdpi-item-label translated" x-text="IODeviceMode"></div>
<select class="sdpi-item-value select" id="select-mode">
<option value="input" class="translated" x-text="IODeviceModeInput"></option>
<option value="output" class="translated" x-text="IODeviceModeOutput"></option>
<option value="both" class="translated" x-text="IODeviceModeBoth"></option>
</select>
</div>
<div class="sdpi-item" id="input-selection" style="display:none">
<div class="sdpi-item-label translated" x-text="IODeviceInput"></div>
<select class="sdpi-item-value select" id="input">
<option disabled id='no-input' class="translated" value='no-input' x-text="IODeviceInputNotFound"></option>
</select>
</div>
<div class="sdpi-item" id="output-selection" style="display:none">
<div class="sdpi-item-label translated" x-text="IODeviceOutput"></div>
<select class="sdpi-item-value select" id="output">
<option disabled id='no-output' class="translated" value='no-output' x-text="IODeviceOutputNotFound"></option>
</select>
</div>`;
document.getElementById('placeholder').innerHTML = fields;
const els = {
"mode": document.getElementById('select-mode'),
"input": document.getElementById("input"),
"output": document.getElementById("output"),
};
const containers = {
"mode": document.getElementById("mode"),
"input": document.getElementById("input-selection"),
"output": document.getElementById("output-selection")
};
this.refreshElements = function(){
const modeSelected = els.mode.value;
if (!modeSelected){
containers.input.style.display = "none";
containers.output.style.display = "none";
return;
}
if( els.mode.value == "input"){
containers.input.style.removeProperty("display");
containers.output.style.display = "none";
}
else if (els.mode.value == "output"){
containers.output.style.removeProperty("display");
containers.input.style.display = "none";
}
else if (els.mode.value == "both") {
containers.output.style.removeProperty("display");
containers.input.style.removeProperty("display");
}
};
els.mode.addEventListener("change", () => {
settings['mode'] = els.mode.value;
this.refreshElements();
piSaveSettings();
});
els.output.addEventListener("change", () => {
settings['output'] = els.output.value;
settings['outputname'] = els.output.options[els.output.selectedIndex].innerText;
this.refreshElements();
piSaveSettings();
});
els.input.addEventListener("change", () => {
settings['input'] = els.input.value;
settings['inputname'] = els.input.options[els.input.selectedIndex].innerText;
piSaveSettings();
});
els.mode.value = settings['mode'];
els.output.value = settings['output'] || "no-output";
els.input.value = settings['input'] || "no-input";
this.refreshElements();
// Before overwriting parrent method, save a copy of it
var piLoad = this.load;
// Public function called to load the fields
this.load = function (data) {
// Call PI load method
piLoad.call(this, data);
// If action enabled
if (!data.disabled && !data.unauthorized) {
this.updateName("input", "inputname", els.input);
this.updateName("output", "outputname", els.output);
let defaultsInput = {key: "default", value: this.defaultName};
let defaultsOutput = {key: "default", value: this.defaultName};
if(settings["input"]){
defaultsInput = {key: settings["input"], value: settings["inputname"]};
}
if(settings["output"]){
defaultsOutput = {key: settings["output"], value: settings["outputname"]};
}
this.loadField('input', data.inputs, defaultsInput);
this.loadField('output', data.outputs, defaultsOutput);
els.mode.value = settings['mode'];
}
// Enable / Disable the fields
els.mode.disabled = data.disabled || data.unauthorized;
els.output.disabled = data.disabled || data.unauthorized;
els.input.disabled = data.disabled || data.unauthorized;
this.refreshElements();
// Show PI
document.getElementById('pi').style.display = "block";
}
/* --- Localization --- */
// Before overwriting parent method, save a copy of it
var piLocalize = this.localize;
// Localize the UI
this.localize = function (tr) {
// Call PIs localize method
piLocalize.call(this, tr);
// Capture default name for IO device
this.defaultName = tr("IODeviceDefault") || "Default";
};
}

View File

@@ -0,0 +1,335 @@
/*!
@file soundboardPI.js
@brief Contains PI for the Soundboard action
@author Andrew story
@copyright (c) 2023, Corsair Memory, Inc. All Rights Reserved.
*/
let EmojiData = null;
// Helper function to return the twemoji for a given unicode emoji. Strips off codepoints until the longest prefix is found.
function GetEmojiPath(emoji){
if(!emoji){
return "";
}
let name = twemoji.convert.toCodePoint(emoji);
let result = null;
let split = name.split("-");
while(!result && split.length > 0){
result = EmojiData[split.join("-")];
if(result){
return split.join("-");
}
split.pop();
}
return "";
}
function GetEmojiData(emoji){
if(!emoji){
return "";
}
result = EmojiData[GetEmojiPath(emoji)];
return result ? result : "";
}
function GetCustomEmojiLink(snowflake, size=128){
return "https://cdn.discordapp.com/emojis/" + snowflake + ".webp?size="+size+"&quality=lossless";
}
function SoundboardPI(inContext, inLanguage) {
// Inherit from PI
PI.call(this, inContext, inLanguage);
if(!EmojiData){
fetch("assets/emoji.json").then((data)=>{
data.json().then((data)=>{
EmojiData = data;
const searcher = document.getElementById("searcher");
this.filterData(searcher.value);
});
});
}
this.labelSearchResults = "Search Results";
this.labelSearchEmpty = "No Sounds Found";
this.labelDefaultSounds = "Discord Sounds";
const GUILDID_SEARCH = "SEARCH";
const GUILDID_DEFAULT = "DEFAULT";
const NITRO_NONE = 0;
const NITRO_CLASSIC = 1;
const NITRO_FULL = 2;
const NITRO_BASIC = 3;
// Save a copy of a method
var piSaveSettings = this.saveSettings;
let sounds = [];
let currentServer = "";
let premiumLevel = NITRO_NONE;
// Add fields
var fields =`
<div id="searchbar-container">
<div id="searchbar">
<div class="sdpi-item">
<div class="sdpi-item-label translated" x-text='Search'></div>
<input class="sdpi-item-value" type="text" name="team" id="searcher" />
</div>
</div>
</div>
</div>
<div class="sdpi-item" id="soundboard-container">
<div style="margin: auto">
<table class="sdpi-item-value single-select" width="100%" id="soundboard-table" >
<tbody id="soundboard">
</tbody>
</table>
</div>
</div>`;
document.getElementById('placeholder').innerHTML = fields;
const els = {
"searcher": document.getElementById('searcher'),
"body": document.getElementsByTagName("body")[0],
"soundboard": document.getElementById('soundboard'),
};
let selection = null;
if (settings["sound_id"]){
selection = settings["sound_id"];
els.searcher.setAttribute("placeholder", settings["sound_name"]);
}
this.filterData = (filter)=>{
while(els.soundboard.firstChild){
els.soundboard.removeChild(els.soundboard.firstChild);
}
const orderedGuilds = [];
let dataCount = 0;
const dataByGuild = {}
if (!filter){
if(sounds){
for( const d of sounds){
let guild_id = d.guild_id;
if (!dataByGuild[guild_id]){
dataByGuild[guild_id] = [];
}
dataByGuild[guild_id].push(d);
dataCount ++;
}
}
if(currentServer){
orderedGuilds.push(currentServer);
}
if(premiumLevel != NITRO_FULL ){
orderedGuilds.push(GUILDID_DEFAULT);
}
const guilds = [];
for(const gid in dataByGuild){
if( currentServer != gid && GUILDID_DEFAULT != gid){
guilds.push(gid);
}
}
guilds.sort((lhs,rhs)=>{
let a = dataByGuild[lhs];
let b = dataByGuild[rhs];
let nameA = "";
let nameB = "";
if( a && a[0] && a[0].guild_name && a[0].guild_name.toLowerCase ){
nameA = a[0].guild_name.toLowerCase();
}
if( b && b[0] && b[0].guild_name && b[0].guild_name.toLowerCase ){
nameB = b[0].guild_name.toLowerCase();
}
return nameA.localeCompare(nameB);
});
orderedGuilds.push(...guilds);
if(premiumLevel == NITRO_FULL ){
orderedGuilds.push(GUILDID_DEFAULT);
}
} else {
orderedGuilds.push(GUILDID_SEARCH);
const results = fuzzysort.go(filter, sounds, {
keys:["name", "guild_name"],
all: true
});
const trimmed = [];
for(const sound of results){
trimmed.push(sound.obj);
}
dataByGuild[GUILDID_SEARCH] = trimmed;
dataCount = trimmed.length;
}
if(dataCount == 0 ){
const labelRow = document.createElement("tr");
labelRow.className = "sb-label";
const labelData = document.createElement("td");
labelData.textContent = this.labelSearchEmpty;
labelData.colSpan = 2;
els.soundboard.appendChild(labelRow);
labelRow.appendChild(labelData);
return;
}
for(const gid of orderedGuilds){
const g = dataByGuild[gid];
if(!g){
continue;
}
if(g.length && g.length > 0){
const labelRow = document.createElement("tr");
labelRow.className = "sb-label";
const labelData = document.createElement("td");
if(gid == GUILDID_SEARCH){
labelData.textContent = this.labelSearchResults;
} else if(gid == GUILDID_DEFAULT){
labelData.textContent = this.labelDefaultSounds;
} else {
labelData.textContent = g[0].guild_name;
}
labelData.colSpan = 2;
els.soundboard.appendChild(labelRow);
labelRow.appendChild(labelData);
let offset = 0;
let currentRow = document.createElement("tr");
for(const sound of g){
const currentData = document.createElement("td");
currentData.className = "interactive";
currentData.id = "sound_id-" + sound.sound_id;
if( sound.sound_id == selection){
currentData.classList.add("picked");
}
const span = document.createElement("span");
const txt = document.createTextNode(sound.name);
span.className = "soundboard-item";
currentData.addEventListener("click", ()=>{
if(selection){
const other = document.getElementById("sound_id-" + selection);
if (other){
other.classList.remove("picked");
}
}
selection = sound.sound_id;
document.getElementById("sound_id-" + selection).classList.add("picked");
els.searcher.setAttribute("placeholder", sound.name);
els.searcher.value = "";
settings['sound_id'] = sound.sound_id;
settings['guild_id'] = sound.guild_id;
settings['sound_name'] = sound.name;
if(!sound.emoji_id){
settings['emoji_path'] = GetEmojiPath(sound.emoji_name);
} else {
settings['emoji_path'] = GetCustomEmojiLink(sound.emoji_id, 128);
}
piSaveSettings();
this.filterData();
})
if(!sound.emoji_id){
if(EmojiData){
if (sound.emoji_name){
const filename = GetEmojiData(sound.emoji_name);
const img = document.createElement("img");
img.className = "sb-img";
img.src = filename;
span.appendChild(img);
}
span.appendChild(txt);
currentData.appendChild(span);
}
} else {
const img = document.createElement("img");
img.className = "sb-img";
img.src = GetCustomEmojiLink(sound.emoji_id, 24);
span.appendChild(img);
span.appendChild(txt);
currentData.appendChild(span);
}
currentRow.appendChild(currentData);
if( ++offset == 2){
els.soundboard.appendChild(currentRow);
currentRow = document.createElement("tr");
offset = 0;
}
}
if(offset > 0){
while(offset++ < 2){
const currentData = document.createElement("td");
currentData.className = "dummy";
const span = document.createElement("span");
currentData.appendChild(span);
currentRow.appendChild(currentData);
}
els.soundboard.appendChild(currentRow);
currentRow = document.createElement("tr");
}
}
}
}
this.filterData();
els.body.addEventListener("keydown", ()=>{
if(document.activeElement != els.searcher){
els.searcher.focus();
}
});
els.searcher.addEventListener("input", (e)=>{
const searcher = els.searcher;
this.filterData(searcher.value);
});
// Before overwriting parrent method, save a copy of it
var piLoad = this.load;
// Public function called to load the fields
this.load = function (data) {
// Call PI load method
piLoad.call(this, data);
// If action enabled
if (!data.disabled && !data.unauthorized) {
sounds = data["sounds"];
for(const sound of sounds){
if(sound.guild_id == GUILDID_DEFAULT){
sound.guild_name = this.labelDefaultSounds + " default";
}
}
premiumLevel = data["premiumLevel"];
currentServer = data["serverId"];
this.filterData(els.searcher.value);
}
// Enable / Disable the fields
els.searcher.disabled = data.disabled || data.unauthorized;
if(data.disabled || data.unauthorized){
sounds = [];
this.filterData();
}
// Show PI
document.getElementById('pi').style.display = "block";
}
/* --- Localization --- */
// Before overwriting parent method, save a copy of it
var piLocalize = this.localize;
// Localize the UI
this.localize = function (tr) {
// Call PIs localize method
piLocalize.call(this, tr);
// Capture default labels
this.labelSearchResults = tr("SoundboardSearch");
this.labelSearchEmpty = tr("SoundboardSearchEmpty");
this.labelDefaultSounds = tr("SoundboardDefaults");
};
}

View File

@@ -0,0 +1,68 @@
/*!
@file textChannelPI.js
@brief Contains PI for Text Channel action
@author Valentin Reinbold
@copyright (c) 2021, Corsair Memory, Inc. All Rights Reserved.
*/
function TextChannelPI(inContext, inLanguage) {
// Inherit from PI
PI.call(this, inContext, inLanguage);
// Save a copy of a method
var piSaveSettings = this.saveSettings;
// Add fields
var fields =
"<div class='sdpi-item'> \
<div class='sdpi-item-label translated' id='server-label' x-text='Server'></div> \
<select class='sdpi-item-value select' id='server'> \
<option disabled id='no-server' class='translated' value='no-server' x-text='NoServer'></option> \
</select> \
</div> \
<div class='sdpi-item'> \
<div class='sdpi-item-label translated' id='channel-label' x-text='TextChannel'></div> \
<select class='sdpi-item-value select' id='channel'> \
<option disabled id='no-channel' class='translated' value='no-channel' x-text='NoChannel'></option> \
</select> \
</div>"
document.getElementById('placeholder').innerHTML = fields;
const serverEl = document.getElementById("server");
document.getElementById('server').addEventListener("input", () => {
settings['serverName'] = serverEl.options[serverEl.selectedIndex].innerText;
this.emptyField('channel');
settings['channel'] = "";
piSaveSettings();
});
this.initField('server');
this.initField('channel');
// Before overwriting parrent method, save a copy of it
var piLoad = this.load;
// Public function called to load the fields
this.load = function (data) {
// Call PI load method
piLoad.call(this, data);
// If action enabled
if (!data.disabled && !data.unauthorized) {
// Load all servers
let defaultsServer = {key: settings["server"], value: settings["serverName"]};
this.loadField('server', data.servers, defaultsServer);
// Load related channels
this.loadField('channel', data.channels);
}
// Enable / Disable the fields
document.getElementById('server').disabled = data.disabled || data.unauthorized;
document.getElementById('channel').disabled = data.disabled || data.unauthorized;
// Show PI
document.getElementById('pi').style.display = "block";
}
}

View File

@@ -0,0 +1,204 @@
/*!
@file textChannelPI.js
@brief Contains PI for Text Channel action
@author Andrew story
@copyright (c) 2023, Corsair Memory, Inc. All Rights Reserved.
*/
function UserVolumeButtonPI(inContext, inLanguage) {
// Inherit from PI
PI.call(this, inContext, inLanguage);
// Save a copy of a method
var piSaveSettings = this.saveSettings;
// Add fields
var fields =`
<div class="sdpi-item" id="user-selection">
<div class="sdpi-item-label translated" x-text="User">User</div>
<select class="sdpi-item-value select" id="user">
<option disabled id='no-user' class="translated" value='no-user' x-text="UsersNotFound"></option>
</select>
</div>
<div class="sdpi-item" id="volume-mode" style="display:none">
<div class="sdpi-item-label translated" x-text="UserVolumeMode"></div>
<select class="sdpi-item-value select" id="select-mode">
<option value="mute" class="translated" x-text="MuteUser"></option>
<option value="adjust" class="translated" x-text="AdjustUserVol"></option>
<option value="set" class="translated" x-text="SetUserVol"></option>
</select>
</div>
<div class="sdpi-item" id="mute-type" style="display:none">
<div class="sdpi-item-label translated" x-text="UserMuteType"></div>
<select class="sdpi-item-value select" id="select-mute-type">
<option value="toggle" class="translated" x-text="ToggleMuteUser"></option>
<option value="mute" class="translated" x-text="MuteUser"></option>
<option value="unmute" class="translated" x-text="UnmuteUser"></option>
</select>
</div>
<div class="sdpi-item" id="icon-mode" style="display:none">
<div class="sdpi-item-label translated" x-text="IconStyle"></div>
<select class="sdpi-item-value select" id="select-icon">
<option value="static" class="translated" x-text="IconStatic" selected>Static</option>
<option value="dynamic_h" class="translated" x-text="IconDynamicH"></option>
<option value="dynamic_v" class="translated" x-text="IconDynamicV"></option>
</select>
</div>
<div type="range" class="sdpi-item" id="volume-range-adjust" style="display:none">
<div class="sdpi-item-label translated" x-text="VolStepSize"></div>
<div class="sdpi-item-value">
<input class="floating-tooltip" data-suffix=" %" type="range" min="-25" max="24" id="vol-range-adjust">
</div>
</div>
<div type="range" class="sdpi-item" id="volume-range-set" style="display:none">
<div class="sdpi-item-label translated" x-text="VolSetValue"></div>
<div class="sdpi-item-value">
<input class="floating-tooltip" data-suffix=" %" type="range" min="0" max="200" id="vol-range-set">
</div>
</div>
<div class="sdpi-info-label hidden" style="top: -1000;" value="">TooltipText</div>`;
document.getElementById('placeholder').innerHTML = fields;
const els = {
"select_user": document.getElementById('user'),
"range_adjust": document.getElementById("vol-range-adjust"),
"range_set": document.getElementById("vol-range-set"),
"select_mode": document.getElementById("select-mode"),
"select_icon": document.getElementById("select-icon"),
"select_mute_type": document.getElementById("select-mute-type"),
};
const containers = {
"range_adjust": document.getElementById("volume-range-adjust"),
"range_set": document.getElementById("volume-range-set"),
"select_mode": document.getElementById("volume-mode"),
"select_icon": document.getElementById("icon-mode"),
"mute_type": document.getElementById("mute-type"),
};
this.refreshElements = function(){
const userSelected = els.select_user.value && els.select_user.value !== "no-user";
if (!userSelected){
containers.range_adjust.style.display = "none";
containers.range_set.style.display = "none";
containers.select_mode.style.display = "none";
containers.select_icon.style.display = "none";
containers.mute_type.style.display = "none";
return;
}
containers.select_mode.style.removeProperty("display");
if( els.select_mode.value == "adjust"){
containers.range_adjust.style.removeProperty("display");
if( settings.isInMultiAction){
containers.select_icon.style.display = "none";
} else {
containers.select_icon.style.removeProperty("display");
}
containers.range_set.style.display = "none";
containers.mute_type.style.display = "none";
}
else if (els.select_mode.value == "set"){
containers.range_set.style.removeProperty("display");
containers.select_icon.style.display = "none";
containers.range_adjust.style.display = "none";
containers.mute_type.style.display = "none";
}
else if (els.select_mode.value == "mute"){
containers.mute_type.style.removeProperty("display");
containers.range_set.style.display = "none";
containers.select_icon.style.display = "none";
containers.range_adjust.style.display = "none";
}else {
containers.range_set.style.display = "none";
containers.select_icon.style.display = "none";
containers.range_adjust.style.display = "none";
containers.mute_type.style.display = "none";
}
};
els.select_user.addEventListener("change", () => {
settings['user'] = els.select_user.value;
settings['usernick'] = els.select_user.options[els.select_user.selectedIndex].innerText;
this.refreshElements();
piSaveSettings();
});
els.select_mode.addEventListener("change", () => {
settings['mode'] = els.select_mode.value;
this.refreshElements();
piSaveSettings();
});
els.select_mute_type.addEventListener("change", () => {
settings['muteType'] = els.select_mute_type.value;
this.refreshElements();
piSaveSettings();
});
els.select_icon.addEventListener("change", () => {
settings['icon'] = els.select_icon.value;
piSaveSettings();
});
els.range_adjust.addEventListener("change", volumeChanged = (inEvent) => {
settings['volAdjustValue'] = parseInt(inEvent.target.value);
piSaveSettings();
});
els.range_set.addEventListener("change", volumeChanged = (inEvent) => {
settings['volSetValue'] = parseInt(inEvent.target.value);
piSaveSettings();
});
this.addSliderTooltip(els.range_adjust, (value)=>{
return (value >= 0 ? "+" + (value + 1) : value) + "%";
});
this.addSliderTooltip(els.range_set, (value)=>{
return value + "%";
});
els.select_user.value = settings['user'] || "no-user";
this.setAndValidateField(els.range_adjust, "volAdjustValue");
this.setAndValidateField(els.range_set, "volSetValue");
this.setAndValidateField(els.select_mode, "mode");
this.setAndValidateField(els.select_icon, "icon", settings['icon'] || "static");
this.refreshElements();
// Before overwriting parrent method, save a copy of it
var piLoad = this.load;
// Public function called to load the fields
this.load = function (data) {
// Call PI load method
piLoad.call(this, data);
// If action enabled
if (!data.disabled && !data.unauthorized) {
let defaults;
if (settings["user"] && els.select_user.selectedIndex >= 0){
// Ensure we actually have a nick for the user
let selectedOption = els.select_user.options[els.select_user.selectedIndex];
if (selectedOption && settings['usernick'] != selectedOption.innerText){
settings['usernick'] = selectedOption.innerText;
}
}
if(settings["user"] && settings["usernick"]){
defaults = {key: settings["user"], value: settings["usernick"]};
}
this.loadField('user', data.users, defaults);
this.setAndValidateField(els.range_adjust, "volAdjustValue");
this.setAndValidateField(els.range_set, "volSetValue");
this.setAndValidateField(els.select_mode, "mode");
this.setAndValidateField(els.select_icon, "icon", settings['icon'] || "static");
}
// Enable / Disable the fields
els.select_user.disabled = data.disabled || data.unauthorized;
els.range_adjust.disabled = data.disabled || data.unauthorized;
els.range_set.disabled = data.disabled || data.unauthorized;
els.select_mode.disabled = data.disabled || data.unauthorized;
els.select_icon.disabled = data.disabled || data.unauthorized;
this.refreshElements();
// Show PI
document.getElementById('pi').style.display = "block";
}
}

View File

@@ -0,0 +1,148 @@
/*!
@file textChannelPI.js
@brief Contains PI for Text Channel action
@author Andrew story
@copyright (c) 2023, Corsair Memory, Inc. All Rights Reserved.
*/
function UserVolumeDialPI(inContext, inLanguage) {
// Inherit from PI
PI.call(this, inContext, inLanguage);
// Save a copy of a method
var piSaveSettings = this.saveSettings;
// Add fields
var fields =`
<div type="radio" class="sdpi-item" id="user-mode">
<div class="sdpi-item-label translated" x-text="UserAdjustMode"></div>
<div class="sdpi-item-value ">
<span class="sdpi-item-child">
<input id="user_specific" type="radio" name="rdio">
<label for="user_specific" class="sdpi-item-label translated" x-text="UserAdjustSpecific"><span></span></label>
</span>
<span class="sdpi-item-child">
<input id="user_any" type="radio" name="rdio">
<label for="user_any" class="sdpi-item-label translated" x-text="UserAdjustAny"><span></span></label>
</span>
</div>
</div>
<div class="sdpi-item" id="user-selection">
<div class="sdpi-item-label translated" x-text="User"></div>
<select class="sdpi-item-value select" id="user">
<option disabled id='no-user' value='no-user' class="translated" x-text="UsersNotFound"></option>
</select>
</div>
<div type="range" class="sdpi-item" id="volume-range">
<div class="sdpi-item-label translated" x-text="VolStepSize"></div>
<div class="sdpi-item-value">
<input class="floating-tooltip" data-suffix=" %" type="range" min="1" max="5" id="vol-range">
</div>
</div>
<div class="sdpi-info-label hidden" style="top: -1000;" value="">TooltipText</div>`;
document.getElementById('placeholder').innerHTML = fields;
const els = {
"select_user": document.getElementById('user'),
"user_specific": document.getElementById("user_specific"),
"user_any": document.getElementById("user_any"),
"range": document.getElementById("vol-range"),
};
const containers = {
"range": document.getElementById("volume-range"),
"select_user": document.getElementById("user-selection"),
};
this.refreshElements = function(){
const pickedMode = els.user_any.checked || els.user_specific.checked;
if (!pickedMode){
containers.range.style.display = "none";
containers.select_user.style.display = "none";
return;
}
if (els.user_specific.checked){
containers.select_user.style.removeProperty("display");
const userSelected = els.select_user.value && els.select_user.value !== "no-user";
if( userSelected){
containers.range.style.removeProperty("display");
} else {
containers.range.style.display = "none";
}
} else {
containers.select_user.style.display = "none";
containers.range.style.removeProperty("display");
}
};
els.select_user.addEventListener("change", () => {
settings['user'] = els.select_user.value;
settings['usernick'] = els.select_user.options[els.select_user.selectedIndex].innerText;
this.refreshElements();
piSaveSettings();
});
els.user_specific.addEventListener("change", () => {
settings['user_mode'] = "specific";
this.refreshElements();
piSaveSettings();
});
els.user_any.addEventListener("change", () => {
settings['user_mode'] = "any";
this.refreshElements();
piSaveSettings();
});
els.range.addEventListener("change", volumeChanged = (inEvent) => {
settings['volume'] = parseInt(inEvent.target.value);
piSaveSettings();
});
this.addSliderTooltip(els.range, (value)=>{
return "+/- " + value + "%";
});
els.select_user.value = settings['user'] || "no-user";
els.user_specific.checked = settings['user_mode'] == "specific";
els.user_any.checked = settings['user_mode'] == "any";
this.setAndValidateField(els.range, "volume");
this.refreshElements();
// Before overwriting parrent method, save a copy of it
var piLoad = this.load;
// Public function called to load the fields
this.load = function (data) {
// Call PI load method
piLoad.call(this, data);
// If action enabled
if (!data.disabled && !data.unauthorized) {
let defaults;
if (settings["user"] && els.select_user.selectedIndex >= 0){
// Ensure we actually have a nick for the user
let selectedOption = els.select_user.options[els.select_user.selectedIndex];
if (selectedOption){
settings['usernick'] = selectedOption.innerText;
}
}
if(settings["user"] && settings["usernick"]){
defaults = {key: settings["user"], value: settings["usernick"]};
}
this.loadField('user', data.users, defaults);
els.user_specific.checked = settings['user_mode'] == "specific";
els.user_any.checked = settings['user_mode'] == "any";
els.range.value = settings['volume'];
}
// Enable / Disable the fields
els.select_user.disabled = data.disabled || data.unauthorized;
els.user_specific.disabled = data.disabled || data.unauthorized;
els.user_any.disabled = data.disabled || data.unauthorized;
els.range.disabled = data.disabled || data.unauthorized;
this.refreshElements();
// Show PI
document.getElementById('pi').style.display = "block";
}
}

View File

@@ -0,0 +1,95 @@
/*!
@file voiceChannelPI.js
@brief Contains PI for Voice Channel action
@author Valentin Reinbold
@copyright (c) 2021, Corsair Memory, Inc. All Rights Reserved.
*/
function VoiceChannelPI(inContext, inLanguage) {
// Inherit from PI
PI.call(this, inContext, inLanguage);
// Save a copy of a method
var piSaveSettings = this.saveSettings;
// Add fields
var fields =
"<div class='sdpi-item'> \
<div class='sdpi-item-label translated' id='server-label' x-text='Server'></div> \
<select class='sdpi-item-value select' id='server'> \
<option disabled id='no-server' class='translated' value='no-server' x-text='NoServer'></option> \
</select> \
</div> \
<div class='sdpi-item'> \
<div class='sdpi-item-label translated' id='channel-label' x-text='VoiceChannel'></div> \
<select class='sdpi-item-value select' id='channel'> \
<option disabled id='no-channel' class='translated' value='no-channel' x-text='NoChannel'></option> \
</select> \
</div> \
<div class='sdpi-item' id='icon-container'> \
<div class='sdpi-item-label translated' id='icon-label' x-text='IconStyle'></div> \
<select class='sdpi-item-value select' id='icon'> \
<option value='static' class='translated' x-text='IconStatic'></option> \
<option value='dynamic' class='translated' x-text='IconDynamic'></option> \
</select> \
</div>"
document.getElementById('placeholder').innerHTML = fields;
const serverEl = document.getElementById("server");
serverEl.addEventListener("input", () => {
settings['serverName'] = serverEl.options[serverEl.selectedIndex].innerText;
this.emptyField('channel');
settings['channel'] = "";
piSaveSettings();
});
this.initField('server');
this.initField('channel');
document.getElementById("icon").addEventListener("change", () => {
settings['icon'] = document.getElementById("icon").value;
piSaveSettings();
});
document.getElementById("icon").value = settings['icon'] || "static";
this.refreshElements = function(){
if (settings.isInMultiAction){
document.getElementById("icon-container").style.display = "none";
} else {
document.getElementById("icon-container").style.removeProperty("display");
}
};
this.refreshElements();
// Before overwriting parrent method, save a copy of it
var piLoad = this.load;
// Public function called to load the fields
this.load = function (data) {
// Call PI load method
piLoad.call(this, data);
// If action enabled
if (!data.disabled && !data.unauthorized) {
// Load all servers
let defaultsServer = {key: settings["server"], value: settings["serverName"]};
this.loadField('server', data.servers, defaultsServer);
// Load related channels
this.loadField('channel', data.channels);
document.getElementById("icon").value = settings['icon'] || "static";
this.refreshElements();
}
// Enable / Disable the fields
document.getElementById('server').disabled = data.disabled || data.unauthorized;
document.getElementById('channel').disabled = data.disabled || data.unauthorized;
document.getElementById('icon').disabled = data.disabled || data.unauthorized;
// Show PI
document.getElementById('pi').style.display = "block";
}
}

View File

@@ -0,0 +1,185 @@
/*!
@file textChannelPI.js
@brief Contains PI for Text Channel action
@author Andrew story
@copyright (c) 2023, Corsair Memory, Inc. All Rights Reserved.
*/
function VolumeButtonPI(inContext, inLanguage) {
// Inherit from PI
PI.call(this, inContext, inLanguage);
// Save a copy of a method
var piSaveSettings = this.saveSettings;
// Add fields
var fields =`
<div type="radio" class="sdpi-item" id="device">
<div class="sdpi-item-label translated" x-text="IODevice"></div>
<div class="sdpi-item-value ">
<span class="sdpi-item-child">
<input id="dev_output" type="radio" name="rdio">
<label for="dev_output" class="sdpi-item-label translated" x-text="IODeviceOutput"><span></span></label>
</span>
<span class="sdpi-item-child">
<input id="dev_input" type="radio" name="rdio">
<label for="dev_input" class="sdpi-item-label translated" x-text="IODeviceInput"><span></span></label>
</span>
</div>
</div>
<div class="sdpi-item" id="volume-mode" style="display:none">
<div class="sdpi-item-label translated" x-text="IODeviceMode"></div>
<select class="sdpi-item-value select" id="select-mode">
<option value="adjust" class="translated" x-text="AdjustDeviceVol"></option>
<option value="set" class="translated" x-text="SetDeviceVol"></option>
</select>
</div>
<div class="sdpi-item" id="icon-mode" style="display:none">
<div class="sdpi-item-label translated" x-text="IconStyle"></div>
<select class="sdpi-item-value select" id="select-icon">
<option value="static" class="translated" x-text="IconStatic" selected></option>
<option value="dynamic_h" class="translated" x-text="IconDynamicH"></option>
<option value="dynamic_v" class="translated" x-text="IconDynamicV"></option>
</select>
</div>
<div type="range" class="sdpi-item" id="volume-range-adjust" style="display:none">
<div class="sdpi-item-label translated" x-text="VolStepSize"></div>
<div class="sdpi-item-value">
<input class="floating-tooltip" data-suffix=" %" type="range" min="-25" max="24" id="vol-range-adjust">
</div>
</div>
<div type="range" class="sdpi-item" id="volume-range-set" style="display:none">
<div class="sdpi-item-label translated" x-text="VolSetValue"></div>
<div class="sdpi-item-value">
<input class="floating-tooltip" data-suffix=" %" type="range" min="0" max="200" id="vol-range-set">
</div>
</div>
<div class="sdpi-info-label hidden" style="top: -1000;" value="">TooltipText</div>`;
document.getElementById('placeholder').innerHTML = fields;
const els = {
"dev_input": document.getElementById('dev_input'),
"dev_output": document.getElementById('dev_output'),
"range_adjust": document.getElementById("vol-range-adjust"),
"range_set": document.getElementById("vol-range-set"),
"select_mode": document.getElementById("select-mode"),
"select_icon": document.getElementById("select-icon"),
};
const containers = {
"range_adjust": document.getElementById("volume-range-adjust"),
"range_set": document.getElementById("volume-range-set"),
"select_mode": document.getElementById("volume-mode"),
"select_icon": document.getElementById("icon-mode"),
};
this.refreshElements = function(){
const deviceChosen = els.dev_input.checked || els.dev_output.checked;
if (!deviceChosen){
containers.range_adjust.style.display = "none";
containers.range_set.style.display = "none";
containers.select_mode.style.display = "none";
containers.select_icon.style.display = "none";
return;
}
containers.select_mode.style.removeProperty("display");
if( els.select_mode.value == "adjust"){
containers.range_adjust.style.removeProperty("display");
if( settings.isInMultiAction){
containers.select_icon.style.display = "none";
} else {
containers.select_icon.style.removeProperty("display");
}
containers.range_set.style.display = "none";
}
else if (els.select_mode.value == "set"){
containers.range_set.style.removeProperty("display");
containers.select_icon.style.display = "none";
containers.range_adjust.style.display = "none";
if(els.dev_input.checked){
els.range_set.max = 100;
} else if (els.dev_output.checked){
els.range_set.max = 200;
}
}
};
els.dev_output.addEventListener("change", () => {
settings['device'] = "output";
this.refreshElements();
piSaveSettings();
});
els.dev_input.addEventListener("change", () => {
settings['device'] = "input";
this.refreshElements();
piSaveSettings();
});
els.select_mode.addEventListener("change", () => {
settings['mode'] = els.select_mode.value;
this.refreshElements();
piSaveSettings();
});
els.select_icon.addEventListener("change", () => {
settings['icon'] = els.select_icon.value;
piSaveSettings();
});
els.range_adjust.addEventListener("change", volumeChanged = (inEvent) => {
settings['volAdjustValue'] = parseInt(inEvent.target.value);
console.log(settings);
piSaveSettings();
});
els.range_set.addEventListener("change", volumeChanged = (inEvent) => {
settings['volSetValue'] = parseInt(inEvent.target.value);
console.log(settings);
piSaveSettings();
});
this.addSliderTooltip(els.range_adjust, (value)=>{
return (value >= 0 ? "+" + (value + 1) : value) + "%";
});
this.addSliderTooltip(els.range_set, (value)=>{
return value + "%";
});
els.dev_input.checked = settings['device'] == "input";
els.dev_output.checked = settings['device'] == "output";
this.setAndValidateField(els.range_adjust, "volAdjustValue");
this.setAndValidateField(els.range_set, "volSetValue");
this.setAndValidateField(els.select_mode, "mode");
this.setAndValidateField(els.select_icon, "icon", settings['icon'] || "static");
this.refreshElements();
// Before overwriting parrent method, save a copy of it
var piLoad = this.load;
// Public function called to load the fields
this.load = function (data) {
// Call PI load method
piLoad.call(this, data);
// If action enabled
if (!data.disabled && !data.unauthorized) {
els.dev_input.checked = settings['device'] == "input";
els.dev_output.checked = settings['device'] == "output";
els.range_adjust.value = settings['volAdjustValue'];
els.range_set.value = settings['volSetValue'];
els.select_mode.value = settings['mode'];
els.select_icon.value = settings['icon'] || "static";
}
// Enable / Disable the fields
els.dev_input.disabled = data.disabled || data.unauthorized;
els.dev_output.disabled = data.disabled || data.unauthorized;
els.range_adjust.disabled = data.disabled || data.unauthorized;
els.range_set.disabled = data.disabled || data.unauthorized;
els.select_mode.disabled = data.disabled || data.unauthorized;
els.select_icon.disabled = data.disabled || data.unauthorized;
this.refreshElements();
// Show PI
document.getElementById('pi').style.display = "block";
}
}

View File

@@ -0,0 +1,92 @@
/*!
@file textChannelPI.js
@brief Contains PI for Text Channel action
@author Andrew story
@copyright (c) 2023, Corsair Memory, Inc. All Rights Reserved.
*/
function VolumePI(inContext, inLanguage) {
// Inherit from PI
PI.call(this, inContext, inLanguage);
// Save a copy of a method
var piSaveSettings = this.saveSettings;
// Add fields
var fields =`
<div type="radio" class="sdpi-item" id="device">
<div class="sdpi-item-label translated" x-text="IODevice"></div>
<div class="sdpi-item-value ">
<span class="sdpi-item-child">
<input id="dev_output" type="radio" name="rdio">
<label for="dev_output" class="sdpi-item-label translated" x-text="IODeviceOutput"><span></span></label>
</span>
<span class="sdpi-item-child">
<input id="dev_input" type="radio" name="rdio">
<label for="dev_input" class="sdpi-item-label translated" x-text="IODeviceInput"><span></span></label>
</span>
</div>
</div>
<div type="range" class="sdpi-item" id="volume-range">
<div class="sdpi-item-label translated" x-text="VolStepSize"></div>
<div class="sdpi-item-value">
<input class="floating-tooltip" data-suffix=" %" type="range" min="1" max="5" id="vol-range">
</div>
</div>
<div class="sdpi-info-label hidden" style="top: -1000;" value="">TooltipText</div>`
document.getElementById('placeholder').innerHTML = fields;
document.getElementById('dev_output').addEventListener("change", () => {
settings['device'] = "output";
console.log(settings);
piSaveSettings();
});
document.getElementById('dev_input').addEventListener("change", () => {
settings['device'] = "input"
console.log(settings);
piSaveSettings();
});
document.getElementById("vol-range").addEventListener("change", volumeChanged = (inEvent) => {
settings['volValue'] = parseInt(inEvent.target.value);
console.log(settings);
piSaveSettings();
});
this.addSliderTooltip(document.getElementById("vol-range"), (value)=>{
return "+/- " + value + "%";
});
document.getElementById('dev_input').checked = settings['device'] == "input";
document.getElementById('dev_output').checked = settings['device'] == "output";
this.setAndValidateField(document.getElementById("vol-range"), 'volValue');
// Before overwriting parrent method, save a copy of it
var piLoad = this.load;
// Public function called to load the fields
this.load = function (data) {
// Call PI load method
console.log("loading", settings);
piLoad.call(this, data);
console.log("loading...", settings);
// If action enabled
if (!data.disabled && !data.unauthorized) {
// Load all servers
console.log("device", settings);
document.getElementById('dev_input').checked = settings['device'] == "input";
document.getElementById('dev_output').checked = settings['device'] == "output";
document.getElementById("vol-range").value = settings['volValue'];
}
console.log("loading.......", settings);
// Enable / Disable the fields
document.getElementById('dev_input').disabled = data.disabled || data.unauthorized;
document.getElementById('dev_output').disabled = data.disabled || data.unauthorized;
document.getElementById('vol-range').disabled = data.disabled || data.unauthorized;
// Show PI
document.getElementById('pi').style.display = "block";
}
}