240 lines
9 KiB
HTML
240 lines
9 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>JSDoc: Source: panels/settingsPanel.js</title>
|
|
|
|
<script src="scripts/prettify/prettify.js"> </script>
|
|
<script src="scripts/prettify/lang-css.js"> </script>
|
|
<!--[if lt IE 9]>
|
|
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
|
<![endif]-->
|
|
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
|
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div id="main">
|
|
|
|
<h1 class="page-title">Source: panels/settingsPanel.js</h1>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<section>
|
|
<article>
|
|
<pre class="prettyprint source linenums"><code>/*Canopy - The next generation of stoner streaming software
|
|
Copyright (C) 2024-2025 Rainbownapkin and the TTN Community
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Affero General Public License as
|
|
published by the Free Software Foundation, either version 3 of the
|
|
License, or (at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Affero General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
|
|
|
/**
|
|
* Class representing the settings panel
|
|
* @extends panelObj
|
|
*/
|
|
class settingsPanel extends panelObj{
|
|
/**
|
|
* Instantiates a new Panel Object
|
|
* @param {channel} client - Parent client Management Object
|
|
* @param {Document} panelDocument - Panel Document
|
|
*/
|
|
constructor(client, panelDocument){
|
|
super(client, "Client Settings", "/panel/settings", panelDocument);
|
|
}
|
|
|
|
closer(){
|
|
}
|
|
|
|
docSwitch(){
|
|
/**
|
|
* Youtube Source Selector
|
|
*/
|
|
this.youtubeSource = this.panelDocument.querySelector("#settings-panel-youtube-source select");
|
|
|
|
/**
|
|
* Internet Archive CDN Server Input
|
|
*/
|
|
this.iaCDN = this.panelDocument.querySelector("#settings-panel-ia-server input");
|
|
|
|
/**
|
|
* Syncronization Tolerance Input
|
|
*/
|
|
this.syncTolerance = this.panelDocument.querySelector("#settings-panel-sync-tolerance input");
|
|
|
|
/**
|
|
* Livestream Syncronization Tolerance Input
|
|
*/
|
|
this.liveSyncTolerance = this.panelDocument.querySelector("#settings-panel-live-sync-tolerance input");
|
|
|
|
/**
|
|
* Syncronization Tolerance Delta
|
|
*/
|
|
this.syncDelta = this.panelDocument.querySelector("#settings-panel-sync-delta input");
|
|
|
|
/**
|
|
* Chat Width Minimum while Size-Locked to Media Aspect Ratio
|
|
*/
|
|
this.chatWidthMinimum = this.panelDocument.querySelector("#settings-panel-min-chat-width input");
|
|
|
|
this.renderSettings();
|
|
this.setupInput();
|
|
}
|
|
|
|
/**
|
|
* Defines input-related event handlers
|
|
*/
|
|
setupInput(){
|
|
this.youtubeSource.addEventListener('change', this.updateYoutubeSource.bind(this));
|
|
this.iaCDN.addEventListener('keydown', this.updateIACDN.bind(this));
|
|
this.syncTolerance.addEventListener('change', this.updateSyncTolerance.bind(this));
|
|
this.liveSyncTolerance.addEventListener('change', this.updateLiveSyncTolerance.bind(this));
|
|
this.syncDelta.addEventListener('change', this.updateSyncDelta.bind(this));
|
|
this.chatWidthMinimum.addEventListener('change', this.updateChatWidthMinimum.bind(this));
|
|
}
|
|
|
|
/**
|
|
* Renders actual user settings state into panel display
|
|
*/
|
|
renderSettings(){
|
|
this.youtubeSource.value = localStorage.getItem("ytPlayerType");
|
|
this.iaCDN.value = localStorage.getItem("IACDN");
|
|
this.syncTolerance.value = localStorage.getItem("syncTolerance");
|
|
this.liveSyncTolerance.value = localStorage.getItem("liveSyncTolerance");
|
|
this.syncDelta.value = localStorage.getItem("syncDelta");
|
|
this.chatWidthMinimum.value = localStorage.getItem("chatWidthMin");
|
|
}
|
|
|
|
/**
|
|
* Event handler for Youtube Source selector
|
|
*/
|
|
updateYoutubeSource(){
|
|
localStorage.setItem("ytPlayerType", this.youtubeSource.value);
|
|
client.processConfig("ytPlayerType", this.youtubeSource.value);
|
|
}
|
|
|
|
/**
|
|
* Event handler for Internet Archive CDN Server input
|
|
* @param {Event} event - Event handed down by event listener
|
|
*/
|
|
updateIACDN(event){
|
|
//If we hit enter
|
|
if(event.key == "Enter"){
|
|
//If we have an invalid server string
|
|
if(!(this.iaCDN.value.match(/^ia[0-9]{6}\...$/g) || this.iaCDN.value == "")){
|
|
//reset back to what was set before
|
|
this.iaCDN.value = localStorage.getItem('IACDN');
|
|
|
|
//BAIL!
|
|
return;
|
|
}
|
|
|
|
localStorage.setItem("IACDN", this.iaCDN.value);
|
|
client.processConfig("IACDN", this.iaCDN.value);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Handles Sync Tolerance Changes
|
|
*/
|
|
updateSyncTolerance(){
|
|
//If sync tolerance was set to a negative number
|
|
if(this.syncTolerance.value < 0){
|
|
//Reset setting back to stored value
|
|
this.syncTolerance.value = localStorage.getItem('syncTolerance');
|
|
|
|
//BAIL!
|
|
return;
|
|
}
|
|
|
|
localStorage.setItem("syncTolerance", this.syncTolerance.value);
|
|
client.processConfig("syncTolerance", this.syncTolerance.value);
|
|
}
|
|
|
|
/**
|
|
* Handles Live Sync Tolerance Changes
|
|
*/
|
|
updateLiveSyncTolerance(){
|
|
//If sync tolerance was set to a negative number
|
|
if(this.liveSyncTolerance.value < 0){
|
|
//Reset setting back to stored value
|
|
this.liveSyncTolerance.value = localStorage.getItem('liveSyncTolerance');
|
|
|
|
//BAIL!
|
|
return;
|
|
}
|
|
|
|
localStorage.setItem("liveSyncTolerance", this.liveSyncTolerance.value);
|
|
client.processConfig("liveSyncTolerance", this.liveSyncTolerance.value);
|
|
}
|
|
|
|
/**
|
|
* Handles Sync Delta Changes
|
|
*/
|
|
updateSyncDelta(){
|
|
//If sync tolerance was set to a negative number
|
|
if(this.syncDelta.value < 0){
|
|
//Reset setting back to stored value
|
|
this.syncDelta.value = localStorage.getItem('syncDelta');
|
|
|
|
//BAIL!
|
|
return;
|
|
}
|
|
|
|
localStorage.setItem("syncDelta", this.syncDelta.value);
|
|
client.processConfig("syncDelta", this.syncDelta.value);
|
|
}
|
|
|
|
/**
|
|
* Handles Chat Width minimum Changes
|
|
*/
|
|
updateChatWidthMinimum(){
|
|
//If sync tolerance was set to a negative number
|
|
if(this.chatWidthMinimum.value < 0 || this.chatWidthMinimum > 100){
|
|
//Reset setting back to stored value
|
|
this.syncDelta.value = localStorage.getItem('chatWidthMin');
|
|
|
|
//BAIL!
|
|
return;
|
|
}
|
|
|
|
localStorage.setItem("chatWidthMin", this.chatWidthMinimum.value);
|
|
client.processConfig("chatWidthMin", this.chatWidthMinimum.value);
|
|
}
|
|
}</code></pre>
|
|
</article>
|
|
</section>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<nav>
|
|
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="addURLPopup.html">addURLPopup</a></li><li><a href="cPanel.html">cPanel</a></li><li><a href="channel.html">channel</a></li><li><a href="chatBox.html">chatBox</a></li><li><a href="chatPostprocessor.html">chatPostprocessor</a></li><li><a href="clearPopup.html">clearPopup</a></li><li><a href="commandPreprocessor.html">commandPreprocessor</a></li><li><a href="commandProcessor.html">commandProcessor</a></li><li><a href="defaultTitlesPopup.html">defaultTitlesPopup</a></li><li><a href="emotePanel.html">emotePanel</a></li><li><a href="hlsBase.html">hlsBase</a></li><li><a href="hlsLiveStreamHandler.html">hlsLiveStreamHandler</a></li><li><a href="mediaHandler.html">mediaHandler</a></li><li><a href="newPlaylistPopup.html">newPlaylistPopup</a></li><li><a href="nullHandler.html">nullHandler</a></li><li><a href="panelObj.html">panelObj</a></li><li><a href="player.html">player</a></li><li><a href="playlistManager.html">playlistManager</a></li><li><a href="poppedPanel.html">poppedPanel</a></li><li><a href="queuePanel.html">queuePanel</a></li><li><a href="rawFileBase.html">rawFileBase</a></li><li><a href="rawFileHandler.html">rawFileHandler</a></li><li><a href="renamePopup.html">renamePopup</a></li><li><a href="reschedulePopup.html">reschedulePopup</a></li><li><a href="schedulePopup.html">schedulePopup</a></li><li><a href="settingsPanel.html">settingsPanel</a></li><li><a href="userList.html">userList</a></li><li><a href="youtubeEmbedHandler.html">youtubeEmbedHandler</a></li></ul><h3>Global</h3><ul><li><a href="global.html#onYouTubeIframeAPIReady">onYouTubeIframeAPIReady</a></li></ul>
|
|
</nav>
|
|
|
|
<br class="clear">
|
|
|
|
<footer>
|
|
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.4</a> on Sat Sep 06 2025 19:07:57 GMT-0400 (Eastern Daylight Time)
|
|
</footer>
|
|
|
|
<script> prettyPrint(); </script>
|
|
<script src="scripts/linenumber.js"> </script>
|
|
</body>
|
|
</html>
|