Added CPanel Pinning

This commit is contained in:
rainbownapkin 2024-11-16 07:12:33 -05:00
parent d4a97faf68
commit 9a17dc5c86
4 changed files with 102 additions and 23 deletions

View file

@ -19,28 +19,92 @@ class cPanel{
//Client Object
this.client = client;
//Panel Objects
this.activePanel = null;
this.pinnedPanel = null;
this.poppedPanels = [];
//Element Nodes
this.activePanel = document.querySelector("#cpanel-active-div");
//Active Panel
this.activePanelDiv = document.querySelector("#cpanel-active-div");
this.activePanelTitle = document.querySelector("#cpanel-active-title");
this.activePanelDoc = document.querySelector("#cpanel-active-doc");
this.activePanelPinIcon = document.querySelector("#cpanel-active-pin-icon");
this.activePanelCloseIcon = document.querySelector("#cpanel-active-close-icon");
//Pinned Panel
this.pinnedPanelDiv = document.querySelector("#cpanel-pinned-div");
this.pinnedPanelTitle = document.querySelector("#cpanel-pinned-title");
this.pinnedPanelDoc = document.querySelector("#cpanel-pinned-doc");
this.pinnedPanelCloseIcon = document.querySelector("#cpanel-pinned-close-icon");
this.setupInput();
}
setupInput(){
this.activePanelCloseIcon.addEventListener("click", this.hidePanel.bind(this));
this.activePanelCloseIcon.addEventListener("click", this.hideActivePanel.bind(this));
this.activePanelPinIcon.addEventListener("click", this.pinActivePanel.bind(this));
this.pinnedPanelCloseIcon.addEventListener("click", this.hidePinnedPanel.bind(this));
}
async setPanel(panel){
this.activePanel.style.display = "flex";
this.activePanelTitle.textContent = panel.name;
this.activePanelDoc.innerHTML = await panel.getPage();
async setActivePanel(panel){
//Set active panel
this.activePanel = panel;
//Grab panel hypertext content and load it into div
this.activePanelDoc.innerHTML = await this.activePanel.getPage();
//Display panel
this.activePanelDiv.style.display = "flex";
this.activePanelTitle.textContent = this.activePanel.name;
//Call panel initialization function
this.activePanel.panelInit();
}
hidePanel(){
this.activePanel.style.display = "none";
hideActivePanel(){
this.activePanelDiv.style.display = "none";
this.activePanel = null;
}
pinActivePanel(){
//Yoink panel object
this.pinnedPanel = this.activePanel
//Yoink Content and Title
this.pinnedPanelTitle.textContent = this.pinnedPanel.name;
this.pinnedPanelDoc.innerHTML = this.activePanelDoc.innerHTML;
//Do a switchem
this.pinnedPanelDiv.style.display = "flex";
this.hideActivePanel();
//Re-Run panel init function
this.pinnedPanel.panelInit();
}
async setPinnedPanel(panel){
//Set pinned panel
this.pinnedPanel = panel;
//Set Title
this.pinnedPanelTitle.textContent = this.pinnedPanel.name;
//Grab panel hypertext content and load it into div
this.pinnedPanelDoc.innerHTML = await this.pinnedPanel.getPage();
//Display panel
this.pinnedPanelDiv.style.display = "flex";
//Call panel initialization function
this.pinnedPanel.panelInit();
}
hidePinnedPanel(){
this.pinnedPanelDiv.style.display = "none";
this.pinnedPanel = null;
}
}
class panelObj{
@ -56,4 +120,7 @@ class panelObj{
return await response.text();
}
panelInit(){
}
}