Started work on JSDoc for www/js/channel

This commit is contained in:
rainbow napkin 2025-09-04 05:45:33 -04:00
parent 5ad20f6823
commit ac06f839ea
97 changed files with 18556 additions and 91 deletions

View file

@ -14,26 +14,47 @@ 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 for object containing base code for the Canopy channel client.
*/
class channel{
/**
* Instantiates a new channel object
*/
constructor(){
//Establish connetion to the server via socket.io
this.connect();
//Define socket listeners
this.defineListeners();
//Flag youtube iframe-embed api as unloaded
/**
* Returns true once the ytEmbed API has loaded in from google (eww)
*/
this.ytEmbedAPILoaded = false;
//Scrape channel name off URL
/**
* Current connected channels name
*/
this.channelName = window.location.pathname.split('/c/')[1].split('/')[0];
//Create the Video Player Object
/**
* Child Video Player object
*/
this.player = new player(this);
//Create the Chat Box Object
/**
* Child Chat Box Object
*/
this.chatBox = new chatBox(this);
//Create the User List Object
/**
* Child User List Object
*/
this.userList = new userList(this);
//Create the Canopy Panel Object
/**
* Child Canopy Panel Object
*/
this.cPanel = new cPanel(this);
//Set defaults for any unset settings and run any required process steps for the current config
@ -43,6 +64,9 @@ class channel{
console.log("👁️👄👁️ 𝓊𝓃𝒿𝓊𝓇.");
}
/**
* Handles initial client connection
*/
connect(){
this.socket = io({
extraHeaders: {
@ -52,6 +76,9 @@ class channel{
});
}
/**
* Defines network-related listeners
*/
defineListeners(){
this.socket.on("connect", () => {
document.title = `${this.channelName} - Connected`
@ -82,6 +109,10 @@ class channel{
});
}
/**
* Handles initial client-metadata ingestion from server upon connection
* @param {Object} data - Data glob from server
*/
handleClientInfo(data){
//Ingest user data
this.user = data.user;
@ -107,6 +138,11 @@ class channel{
}
}
/**
* Processes and applies default config on any unset settings
* @param {Boolean} force - Whether or not to forcefully reset already set settings
* @param {Boolean} processConfig - Whether or not to run the Process Config function once complete
*/
setDefaults(force = false, processConfig = false){
//Iterate through default config
for(let [key, value] of channel.defaultConfig){
@ -124,6 +160,11 @@ class channel{
}
}
/**
* Run once every config change to ensure settings are properly set
* @param {String} key - Setting to change
* @param {*} value - Value to set setting to
*/
processConfig(key, value){
//Switch/case by config key
switch(key){
@ -179,12 +220,17 @@ class channel{
}
}
/**
* Default channel config
*/
static defaultConfig = new Map([
["ytPlayerType","raw"]
]);
}
//Youtube iframe-embed API load handler
/**
* Youtube iframe-embed API entry point
*/
function onYouTubeIframeAPIReady(){
//Set embed api to true
client.ytEmbedAPILoaded = true;