Added alt-detection. Just need to set up pre-delete for userModel function to remove refrences to itself on alt accounts
This commit is contained in:
parent
6e785dc211
commit
980c84afff
14 changed files with 346 additions and 12 deletions
|
|
@ -98,6 +98,80 @@ class canopyUXUtils{
|
|||
return entryRow;
|
||||
}
|
||||
|
||||
static tooltip = class{
|
||||
constructor(content, ajaxTooltip = false, cb){
|
||||
//Define non-tooltip node values
|
||||
this.content = content;
|
||||
this.ajaxPopup = ajaxTooltip;
|
||||
this.cb = cb;
|
||||
this.id = Math.random();
|
||||
|
||||
//create and append tooltip
|
||||
this.tooltip = document.createElement('div');
|
||||
this.tooltip.classList.add('tooltip');
|
||||
|
||||
//Display tooltip even if it's not loaded to prevent removal of unloaded tooltips
|
||||
this.displayTooltip();
|
||||
|
||||
//Fill the tooltip
|
||||
this.fillTooltipContent();
|
||||
}
|
||||
|
||||
async fillTooltipContent(){
|
||||
if(this.ajaxPopup){
|
||||
this.tooltip.textContent = "Loading tooltip..."
|
||||
this.tooltip.innerHTML = await utils.ajax.getTooltip(this.content);
|
||||
}else{
|
||||
this.tooltip.innerHTML = this.content;
|
||||
}
|
||||
|
||||
if(this.cb){
|
||||
//Callbacks are kinda out of vogue, but there really isn't a good way to handle asynchronously constructed objects/classes
|
||||
this.cb();
|
||||
}
|
||||
}
|
||||
|
||||
displayTooltip(){
|
||||
document.body.appendChild(this.tooltip);
|
||||
}
|
||||
|
||||
moveToPos(x,y){
|
||||
//If the distance between the left edge of the window - the window width is more than the width of our tooltip
|
||||
if((window.innerWidth - (window.innerWidth - x)) > this.tooltip.getBoundingClientRect().width){
|
||||
//Push it to the right edge of the cursor, where the hard edge typically is
|
||||
this.tooltip.style.right = `${window.innerWidth - x}px`;
|
||||
this.tooltip.style.left = '';
|
||||
//otherwise, if we're close to the edge
|
||||
}else{
|
||||
//push it away from the edge of the screen
|
||||
this.tooltip.style.right = ''
|
||||
this.tooltip.style.left = `${x}px`
|
||||
}
|
||||
|
||||
|
||||
//If the distance between the top edge of the window - the window height is more than the heigt of our tooltip
|
||||
if((window.innerHeight - (window.innerHeight - y)) > this.tooltip.getBoundingClientRect().height){
|
||||
//Push it above the mouse
|
||||
this.tooltip.style.bottom = `${window.innerHeight - y}px`;
|
||||
this.tooltip.style.top = '';
|
||||
//otherwise if we're close to the edge
|
||||
}else{
|
||||
//Push it below the mouse to avoid the top edge of the screen
|
||||
//-50px to account for a normal sized cursor
|
||||
this.tooltip.style.bottom = '';
|
||||
this.tooltip.style.top = `${y+15}px`;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
moveToMouse(event){
|
||||
this.moveToPos(event.clientX, event.clientY)
|
||||
}
|
||||
|
||||
remove(){
|
||||
this.tooltip.remove();
|
||||
}
|
||||
}
|
||||
|
||||
static popup = class{
|
||||
constructor(content, ajaxPopup = false, cb){
|
||||
|
|
@ -468,6 +542,18 @@ class canopyAjaxUtils{
|
|||
}
|
||||
}
|
||||
|
||||
async getTooltip(tooltip){
|
||||
var response = await fetch(`/tooltip/${tooltip}`,{
|
||||
method: "GET"
|
||||
});
|
||||
|
||||
if(response.status == 200){
|
||||
return (await response.text())
|
||||
}else{
|
||||
utils.ux.displayResponseError(await response.json());
|
||||
}
|
||||
}
|
||||
|
||||
async getChanBans(chanName){
|
||||
var response = await fetch(`/api/channel/ban?chanName=${chanName}`,{
|
||||
method: "GET",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue