Compare commits

..

No commits in common. "73aab6f20e4d598b3e257d17c456e333c01283de" and "584dcf1ac7e42e88680b2a6de68711f0877d8ac8" have entirely different histories.

6 changed files with 22 additions and 84 deletions

View file

@ -9,7 +9,7 @@ Canopy
<a href="https://git.ourfore.st/rainbownapkin/canopy/issues" target="_blank"><img src="https://git.ourfore.st/rainbownapkin/canopy/badges/issues/closed.svg"></a> <a href="https://git.ourfore.st/rainbownapkin/canopy/issues" target="_blank"><img src="https://git.ourfore.st/rainbownapkin/canopy/badges/issues/closed.svg"></a>
<a href="https://www.gnu.org/licenses/agpl-3.0.en.html" target="_blank"><img src="https://img.shields.io/badge/License-AGPL_v3-663366.svg"></a> <a href="https://www.gnu.org/licenses/agpl-3.0.en.html" target="_blank"><img src="https://img.shields.io/badge/License-AGPL_v3-663366.svg"></a>
0.1-Alpha (Panama Red) - Hotfix 3 0.1-Alpha (Panama Red) - Hotfix 2
========= =========
Canopy - /ˈkæ.nə.pi/: Canopy - /ˈkæ.nə.pi/:

View file

@ -1,7 +1,7 @@
{ {
"name": "canopy-of-alpha", "name": "canopy-of-alpha",
"version": "0.1.3", "version": "0.1.2",
"canopyDisplayVersion": "0.1-Alpha (Panama Red) - Hotfix 3", "canopyDisplayVersion": "0.1-Alpha (Panama Red) - Hotfix 2",
"license": "AGPL-3.0-only", "license": "AGPL-3.0-only",
"dependencies": { "dependencies": {
"@braintree/sanitize-url": "^7.1.1", "@braintree/sanitize-url": "^7.1.1",

View file

@ -57,7 +57,7 @@ class chatPreprocessor{
//If we don't pass sanatization/validation turn this car around //If we don't pass sanatization/validation turn this car around
if(!this.sanatizeCommand(commandObj)){ if(!this.sanatizeCommand(commandObj)){
return false; return;
} }
//split the command //split the command

View file

@ -38,11 +38,6 @@ class chatBox{
*/ */
this.autoScroll = true; this.autoScroll = true;
/**
* Whether or not the screen is currently in portrait mode
*/
this.portrait = false;
/** /**
* Chat-Width Minimum while sized to media Aspect-Ratio * Chat-Width Minimum while sized to media Aspect-Ratio
*/ */
@ -79,11 +74,6 @@ class chatBox{
this.chatPostprocessor = new chatPostprocessor(client); this.chatPostprocessor = new chatPostprocessor(client);
//Element Nodes //Element Nodes
/**
* Channel Div
*/
this.channelDiv = document.querySelector("#channel-flexbox");
/** /**
* Chat Panel Container Div * Chat Panel Container Div
*/ */
@ -483,14 +473,8 @@ class chatBox{
resizeAspect(event){ resizeAspect(event){
const playerHidden = this.client.player.playerDiv.style.display == "none"; const playerHidden = this.client.player.playerDiv.style.display == "none";
//If window is taller than wide and not in portrait mode, or vice-versa //If the aspect is locked and the player is hidden
if(this.portrait != (window.innerWidth <= window.innerHeight)){ if(this.aspectLock && !playerHidden){
//Toggle portrait mode
this.togglePortrait();
}
//If the aspect is locked/the window is portrait and the player isn't hidden
if((this.aspectLock || this.portrait) && !playerHidden){
this.sizeToAspect(); this.sizeToAspect();
//Otherwise //Otherwise
}else{ }else{
@ -506,13 +490,8 @@ class chatBox{
* Re-sizes chat box relative to media aspect ratio * Re-sizes chat box relative to media aspect ratio
*/ */
sizeToAspect(){ sizeToAspect(){
//If the chat panel is visible
if(this.chatPanel.style.display != "none"){ if(this.chatPanel.style.display != "none"){
//If our window width is more than or equal to window height (not portrait mode)
if(!this.portrait){
//Get target video width by multiplying media ratio by window height
var targetVidWidth = this.client.player.getRatio() * this.chatPanel.getBoundingClientRect().height; var targetVidWidth = this.client.player.getRatio() * this.chatPanel.getBoundingClientRect().height;
//Get target chat width my subtracting target media width from total window width
const targetChatWidth = window.innerWidth - targetVidWidth; const targetChatWidth = window.innerWidth - targetVidWidth;
//This should be changeable in settings later on, for now it defaults to 20% //This should be changeable in settings later on, for now it defaults to 20%
const limit = window.innerWidth * this.chatWidthMinimum; const limit = window.innerWidth * this.chatWidthMinimum;
@ -523,17 +502,6 @@ class chatBox{
//Fix busted layout //Fix busted layout
var pageBreak = document.body.scrollWidth - document.body.getBoundingClientRect().width; var pageBreak = document.body.scrollWidth - document.body.getBoundingClientRect().width;
this.chatPanel.style.flexBasis = `${this.chatPanel.getBoundingClientRect().width + pageBreak}px`; this.chatPanel.style.flexBasis = `${this.chatPanel.getBoundingClientRect().width + pageBreak}px`;
}else{
//Calculate target video height from media aspect ratio and window width
var targetVidHeight = window.innerWidth / this.client.player.getRatio();
//Calculate target chat height from the difference between the channel div height and the target video height
var targetChatHeight = this.channelDiv.getBoundingClientRect().height - targetVidHeight;
//Set div heights accordingly
this.client.player.playerDiv.style.height = `${targetVidHeight}px`;
this.chatPanel.style.height = `${targetChatHeight}px`;
}
//This sometimes gets called before userList ahs been initiated :p //This sometimes gets called before userList ahs been initiated :p
if(this.client.userList != null){ if(this.client.userList != null){
this.client.userList.clickDragger.fixCutoff(); this.client.userList.clickDragger.fixCutoff();
@ -541,36 +509,6 @@ class chatBox{
} }
} }
togglePortrait(){
//If our window width is more than or equal to window height (not portrait mode)
if(window.innerWidth >= window.innerHeight){
//Disable portrait CSS modifiers
this.channelDiv.style.flexDirection = "row";
this.clickDragger.enabled = true;
this.chatPanel.style.width = "";
this.client.player.playerDiv.style.height = "";
this.chatPanel.style.height = "";
//Disable portrait behavior modifiers
this.portrait = false;
//resize player in-case of empty flex basis
this.resizeAspect();
}else{
//Modify CSS for portrait displays
this.channelDiv.style.flexDirection = "column";
this.clickDragger.enabled = false;
this.chatPanel.style.width = "100%";
this.chatPanel.style.flexBasis = "";
//Enable portrait behavior modifiers
this.portrait = true;
//resize player to correct height
this.resizeAspect();
}
}
/** /**
* Toggles Chat Box UX * Toggles Chat Box UX
* @param {Boolean} show - Whether or not to show Chat Box UX * @param {Boolean} show - Whether or not to show Chat Box UX

View file

@ -144,7 +144,7 @@ class chatPostprocessor{
//with negative lookaheads to exclude file seperators so we don't split link placeholders, dashes so we dont split usernames and other things, and accented characters to keep those from splitting boundries too //with negative lookaheads to exclude file seperators so we don't split link placeholders, dashes so we dont split usernames and other things, and accented characters to keep those from splitting boundries too
//Also split by any invisble whitespace as a crutch to handle mushed links/emotes //Also split by any invisble whitespace as a crutch to handle mushed links/emotes
//If we can one day figure out how to split non-repeating special chars instead of special chars with whitespace, that would be perf, unfortunately my brain hasn't rotted enough to understand regex like that just yet. //If we can one day figure out how to split non-repeating special chars instead of special chars with whitespace, that would be perf, unfortunately my brain hasn't rotted enough to understand regex like that just yet.
const splitString = utils.unescapeEntities(this.rawData.msg).split(/(?<!-)(?<!␜)(?=\w)\b|(?!-|[\u00C0-\u017F])(?<=\w)\b|(?=\s)\B|(?<=\s)\B|/g); const splitString = utils.unescapeEntities(this.rawData.msg).split(/(?<!-)(?<!␜)(?=\w)\b|(?!-|[\u00C0-\u017F])(?<=\w)\b|(?=\s)\B|(?<=\s)\B|/g);
//for each word in the splitstring //for each word in the splitstring
splitString.forEach((string) => { splitString.forEach((string) => {
@ -474,7 +474,7 @@ class chatPostprocessor{
//After eight characters //After eight characters
if(charIndex > 8){ if(charIndex > 8){
//Push an invisible line-break character between every character //Push an invisible line-break character between every character
wordArray.push(""); wordArray.push("");
} }
}); });

View file

@ -116,14 +116,14 @@ class commandPreprocessor{
*/ */
processEmotes(){ processEmotes(){
//inject invisible whitespace in-between emotes to prevent from mushing links together //inject invisible whitespace in-between emotes to prevent from mushing links together
this.message = this.message.replaceAll('][',']['); this.message = this.message.replaceAll('][','][');
//For each list of emotes //For each list of emotes
Object.keys(this.emotes).forEach((key) => { Object.keys(this.emotes).forEach((key) => {
//For each emote in the current list //For each emote in the current list
this.emotes[key].forEach((emote) => { this.emotes[key].forEach((emote) => {
//Inject emote links into the message, pad with invisible whitespace to keep link from getting mushed //Inject emote links into the message, pad with invisible whitespace to keep link from getting mushed
this.message = this.message.replaceAll(`[${emote.name}]`, `${emote.link}`); this.message = this.message.replaceAll(`[${emote.name}]`, `${emote.link}`);
}); });
}); });
} }
@ -135,13 +135,13 @@ class commandPreprocessor{
//Strip out file seperators in-case the user is being a smart-ass //Strip out file seperators in-case the user is being a smart-ass
this.message = this.message.replaceAll('␜',''); this.message = this.message.replaceAll('␜','');
//Split message by links //Split message by links
var splitMessage = this.message.split(/(https?:\/\/[^\s]+)/g); var splitMessage = this.message.split(/(https?:\/\/[^\s]+)/g);
//Create an empty array to hold links //Create an empty array to hold links
this.links = []; this.links = [];
splitMessage.forEach((chunk, chunkIndex) => { splitMessage.forEach((chunk, chunkIndex) => {
//For each chunk that is a link //For each chunk that is a link
if(chunk.match(/(https?:\/\/[^\s]+)/g)){ if(chunk.match(/(https?:\/\/[^\s]+)/g)){
//I looked online for obscure characters that no one would use to prevent people from chatting embed placeholders //I looked online for obscure characters that no one would use to prevent people from chatting embed placeholders
//Then I found this fucker, turns out it's literally made for the job lmao (even if it was originally intended for paper/magnetic tape) //Then I found this fucker, turns out it's literally made for the job lmao (even if it was originally intended for paper/magnetic tape)
//Replace link with indexed placeholder //Replace link with indexed placeholder