diff --git a/src/controllers/panel/settingsController.js b/src/controllers/panel/settingsController.js new file mode 100644 index 0000000..2048f1d --- /dev/null +++ b/src/controllers/panel/settingsController.js @@ -0,0 +1,20 @@ +/*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 .*/ + +//root index functions +module.exports.get = async function(req, res){ + res.render('partial/panels/settings', {}); +} \ No newline at end of file diff --git a/src/routers/panelRouter.js b/src/routers/panelRouter.js index 0efba65..7cafe14 100644 --- a/src/routers/panelRouter.js +++ b/src/routers/panelRouter.js @@ -24,6 +24,7 @@ const emoteController = require("../controllers/panel/emoteController"); const popoutContainerController = require("../controllers/panel/popoutContainerController"); const profileController = require("../controllers/panel/profileController"); const queueController = require("../controllers/panel/queueController"); +const settingsController = require("../controllers/panel/settingsController"); //Validators const accountValidator = require("../validators/accountValidator"); @@ -36,5 +37,6 @@ router.get('/emote', emoteController.get); router.get('/popoutContainer', popoutContainerController.get); router.get('/profile', accountValidator.user(), profileController.get); router.get('/queue', queueController.get); +router.get('/settings', settingsController.get); module.exports = router; diff --git a/src/views/channel.ejs b/src/views/channel.ejs index 5deb6bb..2bd8cc9 100644 --- a/src/views/channel.ejs +++ b/src/views/channel.ejs @@ -51,6 +51,7 @@ along with this program. If not, see . %> + <%# main client %> diff --git a/src/views/partial/panels/settings.ejs b/src/views/partial/panels/settings.ejs new file mode 100644 index 0000000..5b0eab5 --- /dev/null +++ b/src/views/partial/panels/settings.ejs @@ -0,0 +1,27 @@ +<%# 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 . %> + +
+

Client Settings

+ +

Youtube Player Type:

+ +
+
+ \ No newline at end of file diff --git a/www/css/panel/settings.css b/www/css/panel/settings.css new file mode 100644 index 0000000..95bfa62 --- /dev/null +++ b/www/css/panel/settings.css @@ -0,0 +1,33 @@ +/*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 .*/ +#settings-panel{ + display: flex; + flex-direction: column; + gap: 1em; +} + +#settings-panel h2{ + text-align: center; + margin: 1em 0 0; +} + +.settings-panel-setting{ + display: flex; + flex-direction: row; + text-wrap: nowrap; + height: 1em; + align-items: center; +} \ No newline at end of file diff --git a/www/js/channel/channel.js b/www/js/channel/channel.js index e4e5eda..97b1b19 100644 --- a/www/js/channel/channel.js +++ b/www/js/channel/channel.js @@ -32,6 +32,12 @@ class channel{ this.userList = new userList(this); //Create the Canopy Panel Object this.cPanel = new cPanel(this); + + //Set defaults for any unset settings and run any required process steps for the current config + this.setDefaults(false, true); + + //Freak out any weirdos who take a peek in the dev console for gaffs + console.log("👁️👄👁️ ℬℴ𝓊𝓃𝒿ℴ𝓊𝓇."); } connect(){ @@ -91,6 +97,52 @@ class channel{ //Store queue lock status this.queueLock = data.queueLock; } + + setDefaults(force = false, processConfig = false){ + //Iterate through default config + for(let [key, value] of channel.defaultConfig){ + //If the setting is unset or function was called forcefully + if(force || localStorage.getItem(key) == null){ + //Set item from default map + localStorage.setItem(key, value); + } + + //If we're running process steps for the config + if(processConfig){ + //Process the current config value + this.processConfig(key, localStorage.getItem(key)); + } + } + } + + processConfig(key, value){ + //Switch/case by config key + switch(key){ + case 'ytPlayerType': + console.log("FUCK"); + //If the user is running the embedded player + if(value == 'embed'){ + //Find our footer + const footer = document.querySelector('footer'); + + //Create new script tag + const ytEmbedAPI = document.createElement('script'); + //Link the iframe api from youtube + ytEmbedAPI.src = "https://www.youtube.com/iframe_api"; + //set the iframe api script id + ytEmbedAPI.classList.add('yt-embed-api'); + + //Append the script tag to the top of the footer to give everything else access + footer.prepend(ytEmbedAPI); + } + //Stop while we're ahead + return; + } + } + + static defaultConfig = new Map([ + ["ytPlayerType","raw"] + ]); } const client = new channel(); \ No newline at end of file diff --git a/www/js/channel/chat.js b/www/js/channel/chat.js index 30d8840..5ba1b3b 100644 --- a/www/js/channel/chat.js +++ b/www/js/channel/chat.js @@ -64,7 +64,7 @@ class chatBox{ this.chatPrompt.addEventListener("input", this.displayAutocomplete.bind(this)); this.autocompleteDisplay.addEventListener("click", this.tabComplete.bind(this)); this.sendButton.addEventListener("click", this.send.bind(this)); - this.settingsIcon.addEventListener("click", ()=>{this.client.cPanel.setActivePanel(new panelObj(client))}); + this.settingsIcon.addEventListener("click", ()=>{this.client.cPanel.setActivePanel(new settingsPanel(client))}); this.adminIcon.addEventListener("click", ()=>{this.client.cPanel.setActivePanel(new queuePanel(client))}); this.emoteIcon.addEventListener("click", ()=>{this.client.cPanel.setActivePanel(new emotePanel(client))}); diff --git a/www/js/channel/panels/settingsPanel.js b/www/js/channel/panels/settingsPanel.js new file mode 100644 index 0000000..c17ef7c --- /dev/null +++ b/www/js/channel/panels/settingsPanel.js @@ -0,0 +1,37 @@ +/*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 .*/ +class settingsPanel extends panelObj{ + constructor(client, panelDocument){ + super(client, "Client Settings", "/panel/settings", panelDocument); + } + + closer(){ + } + + docSwitch(){ + this.youtubeSource = this.panelDocument.querySelector("#settings-panel-youtube-source select"); + + this.setupInput(); + } + + setupInput(){ + this.youtubeSource.addEventListener('change', this.updateYoutubeSource.bind(this)); + } + + updateYoutubeSource(){ + localStorage.setItem("ytPlayerType", this.youtubeSource.value); + } +} \ No newline at end of file