remove some "window." instances

master
Aevann 2023-09-29 09:11:18 +03:00
parent a14656de22
commit ed435cf86b
10 changed files with 23 additions and 23 deletions

View File

@ -267,9 +267,9 @@ function snow(flakesMax) {
};
this.resizeHandler = function () {
if (window.innerWidth || window.innerHeight) {
screenX = window.innerWidth - 16 - storm.flakeRightOffset;
screenY = storm.flakeBottom || window.innerHeight;
if (innerWidth || innerHeight) {
screenX = innerWidth - 16 - storm.flakeRightOffset;
screenY = storm.flakeBottom || innerHeight;
} else {
screenX =
(document.documentElement.clientWidth ||

View File

@ -52,7 +52,7 @@ function Circle(x, y, v, range) {
bones_container.appendChild(this.element);
this.update = function() {
if (_this.y > window.innerHeight) {
if (_this.y > innerHeight) {
_this.y = 80 + Math.random() * 4;
_this.x = _this.range[0] + Math.random() * _this.range[1];
}

View File

@ -1,6 +1,6 @@
let st = init("canvas"), // stranger things var
w = (canvas.width = innerWidth),
h = (canvas.height = window.innerHeight);
h = (canvas.height = innerHeight);
class firefly {
constructor() {
@ -45,7 +45,7 @@ function init(elemid) {
let canvas = document.getElementById(elemid),
st = canvas.getContext("2d"),
w = (canvas.width = innerWidth),
h = (canvas.height = window.innerHeight);
h = (canvas.height = innerHeight);
st.fillStyle = "rgba(30,30,30,1)";
st.fillRect(0, 0, w, h);
return st;
@ -70,9 +70,9 @@ function loop() {
draw();
}
window.addEventListener("resize", function () {
addEventListener("resize", function () {
(w = canvas.width = innerWidth),
(h = canvas.height = window.innerHeight);
(h = canvas.height = innerHeight);
loop();
});

View File

@ -50,7 +50,7 @@ socket.on('speak', function(json) {
const users = document.getElementsByClassName('user_id');
const last_user = users[users.length-1].value;
const scrolled_down = (box.scrollHeight - box.scrollTop <= window.innerHeight)
const scrolled_down = (box.scrollHeight - box.scrollTop <= innerHeight)
if (last_user != json.user_id) {
document.getElementsByClassName('avatar-pic')[0].src = '/pp/' + json.user_id

View File

@ -400,7 +400,7 @@ if (location.pathname != '/chat' && (gbrowser == 'iphone' || gbrowser == 'mac'))
}
}
const screen_width = (window.innerWidth > 0) ? window.innerWidth : screen.width;
const screen_width = (innerWidth > 0) ? innerWidth : screen.width;
function focusSearchBar(element)
{
if (screen_width >= 768) {

View File

@ -104,10 +104,10 @@ function idle() {
if (cursormarseyPosY < 32) {
avalibleIdleAnimations.push("scratchWallN");
}
if (cursormarseyPosX > window.innerWidth - 32) {
if (cursormarseyPosX > innerWidth - 32) {
avalibleIdleAnimations.push("scratchWallE");
}
if (cursormarseyPosY > window.innerHeight - 32) {
if (cursormarseyPosY > innerHeight - 32) {
avalibleIdleAnimations.push("scratchWallS");
}
idleAnimation =
@ -175,8 +175,8 @@ function frame() {
cursormarseyPosX -= (diffX / distance) * cursormarseySpeed;
cursormarseyPosY -= (diffY / distance) * cursormarseySpeed;
cursormarseyPosX = Math.min(Math.max(16, cursormarseyPosX), window.innerWidth - 16);
cursormarseyPosY = Math.min(Math.max(16, cursormarseyPosY), window.innerHeight - 16);
cursormarseyPosX = Math.min(Math.max(16, cursormarseyPosX), innerWidth - 16);
cursormarseyPosY = Math.min(Math.max(16, cursormarseyPosY), innerHeight - 16);
cursormarseyEl.style.left = `${cursormarseyPosX}px`;
cursormarseyEl.style.top = `${cursormarseyPosY}px`;

View File

@ -13,13 +13,13 @@ window.onscroll = function () {
const bottomSafeAreaInset = parseInt(getComputedStyle(bottomBar).getPropertyValue("--safe-area-inset-bottom")) || 0;
if (bottomBar != null) {
if (prevScrollpos > currentScrollPos && (window.innerHeight + currentScrollPos) < (document.body.offsetHeight - 65)) {
if (prevScrollpos > currentScrollPos && (innerHeight + currentScrollPos) < (document.body.offsetHeight - 65)) {
bottomBar.style.bottom = "0px";
}
else if (currentScrollPos <= 125 && (window.innerHeight + currentScrollPos) < (document.body.offsetHeight - 65)) {
else if (currentScrollPos <= 125 && (innerHeight + currentScrollPos) < (document.body.offsetHeight - 65)) {
bottomBar.style.bottom = "0px";
}
else if (prevScrollpos > currentScrollPos && (window.innerHeight + currentScrollPos) >= (document.body.offsetHeight - 65)) {
else if (prevScrollpos > currentScrollPos && (innerHeight + currentScrollPos) >= (document.body.offsetHeight - 65)) {
bottomBar.style.bottom = `-${50 + bottomSafeAreaInset}px`;
}
else {

View File

@ -1,5 +1,5 @@
if (!is_pwa) {
if (window.innerWidth <= 737) {
if (innerWidth <= 737) {
const tt = bootstrap.Tooltip.getOrCreateInstance(document.getElementById('mobile-prompt'))
tt.show()
document.getElementsByClassName('tooltip')[0].addEventListener('click', function(e) {

File diff suppressed because one or more lines are too long

View File

@ -36,15 +36,15 @@ var dx=Math.cos(angle)*this.options.flySpeed,dy=Math.sin(angle)*this.options.fly
if((currentTop<landingPosition.top&&dy<0)||(currentTop>landingPosition.top&&dy>0)){dy=-1*dy;if(Math.abs(diffy)<Math.abs(dy)){dy=dy/4;}}
this.moveBug((currentLeft+dx),(currentTop+dy));},flyRand:function(){this.stop();var landingPosition={};landingPosition.top=this.random(this.options.edge_resistance,document.documentElement.clientHeight-this.options.edge_resistance);landingPosition.left=this.random(this.options.edge_resistance,document.documentElement.clientWidth-this.options.edge_resistance);this.startFlying(landingPosition);},startFlying:function(landingPosition){var currentTop=this.bug.top,currentLeft=this.bug.left,diffx=(landingPosition.left-currentLeft),diffy=(landingPosition.top-currentTop);this.bug.left=landingPosition.left;this.bug.top=landingPosition.top;this.angle_rad=Math.atan(diffy/diffx);this.angle_deg=this.rad2deg(this.angle_rad);if(diffx>0){this.angle_deg=90+this.angle_deg;}else{this.angle_deg=270+this.angle_deg;}
this.moveBug(currentLeft,currentTop,this.angle_deg);var that=this;this.flyperiodical=setInterval(function(){that.fly(landingPosition);},10);},flyIn:function(){if(!this.bug){this.makeBug();}
if(!this.bug)return;this.stop();var side=Math.round(Math.random()*4-0.5),d=document,e=d.documentElement,g=d.getElementsByTagName('body')[0],windowX=window.innerWidth||e.clientWidth||g.clientWidth,windowY=window.innerHeight||e.clientHeight||g.clientHeight;if(side>3)side=3;if(side<0)side=0;var style={},s;if(side===0){style.top=(-2*this.options.bugHeight);style.left=Math.random()*windowX;}else if(side===1){style.top=Math.random()*windowY;style.left=windowX+(2*this.options.bugWidth);}else if(side===2){style.top=windowY+(2*this.options.bugHeight);style.left=Math.random()*windowX;}else{style.top=Math.random()*windowY;style.left=(-3*this.options.bugWidth);}
if(!this.bug)return;this.stop();var side=Math.round(Math.random()*4-0.5),d=document,e=d.documentElement,g=d.getElementsByTagName('body')[0],windowX=innerWidth||e.clientWidth||g.clientWidth,windowY=innerHeight||e.clientHeight||g.clientHeight;if(side>3)side=3;if(side<0)side=0;var style={},s;if(side===0){style.top=(-2*this.options.bugHeight);style.left=Math.random()*windowX;}else if(side===1){style.top=Math.random()*windowY;style.left=windowX+(2*this.options.bugWidth);}else if(side===2){style.top=windowY+(2*this.options.bugHeight);style.left=Math.random()*windowX;}else{style.top=Math.random()*windowY;style.left=(-3*this.options.bugWidth);}
var row=(this.wingsOpen)?'0':'-'+this.options.bugHeight+'px';this.bug.style.backgroundPosition=(-3*this.options.bugWidth)+'px '+row;this.bug.top=style.top
this.bug.left=style.left
this.drawBug();var landingPosition={};landingPosition.top=this.random(this.options.edge_resistance,document.documentElement.clientHeight-this.options.edge_resistance);landingPosition.left=this.random(this.options.edge_resistance,document.documentElement.clientWidth-this.options.edge_resistance);this.startFlying(landingPosition);},walkIn:function(){if(!this.bug){this.makeBug();}
if(!this.bug)return;this.stop();var side=Math.round(Math.random()*4-0.5),d=document,e=d.documentElement,g=d.getElementsByTagName('body')[0],windowX=window.innerWidth||e.clientWidth||g.clientWidth,windowY=window.innerHeight||e.clientHeight||g.clientHeight;if(side>3)side=3;if(side<0)side=0;var style={},s;if(side===0){style.top=(-1.3*this.options.bugHeight);style.left=Math.random()*windowX;}else if(side===1){style.top=Math.random()*windowY;style.left=windowX+(0.3*this.options.bugWidth);}else if(side===2){style.top=windowY+(0.3*this.options.bugHeight);style.left=Math.random()*windowX;}else{style.top=Math.random()*windowY;style.left=(-1.3*this.options.bugWidth);}
if(!this.bug)return;this.stop();var side=Math.round(Math.random()*4-0.5),d=document,e=d.documentElement,g=d.getElementsByTagName('body')[0],windowX=innerWidth||e.clientWidth||g.clientWidth,windowY=innerHeight||e.clientHeight||g.clientHeight;if(side>3)side=3;if(side<0)side=0;var style={},s;if(side===0){style.top=(-1.3*this.options.bugHeight);style.left=Math.random()*windowX;}else if(side===1){style.top=Math.random()*windowY;style.left=windowX+(0.3*this.options.bugWidth);}else if(side===2){style.top=windowY+(0.3*this.options.bugHeight);style.left=Math.random()*windowX;}else{style.top=Math.random()*windowY;style.left=(-1.3*this.options.bugWidth);}
var row=(this.wingsOpen)?'0':'-'+this.options.bugHeight+'px';this.bug.style.backgroundPosition=(-3*this.options.bugWidth)+'px '+row;this.bug.top=style.top
this.bug.left=style.left
this.drawBug();this.go();},flyOff:function(){this.stop();var side=this.random(0,3),style={},d=document,e=d.documentElement,g=d.getElementsByTagName('body')[0],windowX=window.innerWidth||e.clientWidth||g.clientWidth,windowY=window.innerHeight||e.clientHeight||g.clientHeight;if(side===0){style.top=-200;style.left=Math.random()*windowX;}else if(side===1){style.top=Math.random()*windowY;style.left=windowX+200;}else if(side===2){style.top=windowY+200;style.left=Math.random()*windowX;}else{style.top=Math.random()*windowY;style.left=-200;}
this.startFlying(style);},die:function(){this.stop();var deathType=this.random(0,this.options.numDeathTypes-1);this.alive=false;this.drop(deathType);},drop:function(deathType){var startPos=this.bug.top,d=document,e=d.documentElement,g=d.getElementsByTagName('body')[0],finalPos=window.innerHeight||e.clientHeight||g.clientHeight,finalPos=finalPos-this.options.bugHeight,rotationRate=this.random(0,20,true),startTime=Date.now(),that=this;this.bug.classList.add('bug-dead');this.dropTimer=requestAnimFrame(function(t){that._lastTimestamp=t;that.dropping(t,startPos,finalPos,rotationRate,deathType);});},dropping:function(t,startPos,finalPos,rotationRate,deathType){var elapsedTime=t-this._lastTimestamp,deltaPos=(0.002*(elapsedTime*elapsedTime)),newPos=startPos+deltaPos;var that=this;if(newPos>=finalPos){newPos=finalPos;clearTimeout(this.dropTimer);this.angle_deg=0;this.angle_rad=this.deg2rad(this.angle_deg);this.transform("rotate("+(90-this.angle_deg)+"deg) scale("+this.zoom+")");this.bug.style.top=null;var rotationOffset=((this.options.bugWidth*this.zoom)-(this.options.bugHeight*this.zoom))/2;var zoomOffset=((this.options.bugHeight)/2)*(1-this.zoom);this.bug.style.bottom=Math.ceil((rotationOffset-zoomOffset))+'px';this.bug.style.left=this.bug.left+'px';this.bug.style.backgroundPosition='-'+((deathType*2)*this.options.bugWidth)+'px 100%';this.twitch(deathType);return;}
this.drawBug();this.go();},flyOff:function(){this.stop();var side=this.random(0,3),style={},d=document,e=d.documentElement,g=d.getElementsByTagName('body')[0],windowX=innerWidth||e.clientWidth||g.clientWidth,windowY=innerHeight||e.clientHeight||g.clientHeight;if(side===0){style.top=-200;style.left=Math.random()*windowX;}else if(side===1){style.top=Math.random()*windowY;style.left=windowX+200;}else if(side===2){style.top=windowY+200;style.left=Math.random()*windowX;}else{style.top=Math.random()*windowY;style.left=-200;}
this.startFlying(style);},die:function(){this.stop();var deathType=this.random(0,this.options.numDeathTypes-1);this.alive=false;this.drop(deathType);},drop:function(deathType){var startPos=this.bug.top,d=document,e=d.documentElement,g=d.getElementsByTagName('body')[0],finalPos=innerHeight||e.clientHeight||g.clientHeight,finalPos=finalPos-this.options.bugHeight,rotationRate=this.random(0,20,true),startTime=Date.now(),that=this;this.bug.classList.add('bug-dead');this.dropTimer=requestAnimFrame(function(t){that._lastTimestamp=t;that.dropping(t,startPos,finalPos,rotationRate,deathType);});},dropping:function(t,startPos,finalPos,rotationRate,deathType){var elapsedTime=t-this._lastTimestamp,deltaPos=(0.002*(elapsedTime*elapsedTime)),newPos=startPos+deltaPos;var that=this;if(newPos>=finalPos){newPos=finalPos;clearTimeout(this.dropTimer);this.angle_deg=0;this.angle_rad=this.deg2rad(this.angle_deg);this.transform("rotate("+(90-this.angle_deg)+"deg) scale("+this.zoom+")");this.bug.style.top=null;var rotationOffset=((this.options.bugWidth*this.zoom)-(this.options.bugHeight*this.zoom))/2;var zoomOffset=((this.options.bugHeight)/2)*(1-this.zoom);this.bug.style.bottom=Math.ceil((rotationOffset-zoomOffset))+'px';this.bug.style.left=this.bug.left+'px';this.bug.style.backgroundPosition='-'+((deathType*2)*this.options.bugWidth)+'px 100%';this.twitch(deathType);return;}
this.dropTimer=requestAnimFrame(function(t){that.dropping(t,startPos,finalPos,rotationRate,deathType);});if(elapsedTime<20)return;this.angle_deg=((this.angle_deg+rotationRate)%360);this.angle_rad=this.deg2rad(this.angle_deg);this.moveBug(this.bug.left,newPos,this.angle_deg);},twitch:function(deathType,legPos){if(!legPos)legPos=0;var that=this;if(deathType===0||deathType===1){that.twitchTimer=setTimeout(function(){that.bug.style.backgroundPosition='-'+((deathType*2+(legPos%2))*that.options.bugWidth)+'px 100%';that.twitchTimer=setTimeout(function(){legPos++;that.bug.style.backgroundPosition='-'+((deathType*2+(legPos%2))*that.options.bugWidth)+'px 100%';that.twitch(deathType,++legPos);},that.random(300,800));},this.random(1000,10000));}},rad2deg:function(rad){return rad*this.rad2deg_k;},deg2rad:function(deg){return deg*this.deg2rad_k;},random:function(min,max,plusminus){if(min==max)return min;var result=Math.round(min-0.5+(Math.random()*(max-min+1)));if(plusminus)return Math.random()>0.5?result:-result;return result;},next_small_turn:function(){this.small_turn_counter=Math.round(Math.random()*10);},next_large_turn:function(){this.large_turn_counter=Math.round(Math.random()*40);},next_stationary:function(){this.toggle_stationary_counter=this.random(50,300);},bug_near_window_edge:function(){this.near_edge=0;if(this.bug.top<this.options.edge_resistance)
this.near_edge|=this.NEAR_TOP_EDGE;else if(this.bug.top>document.documentElement.clientHeight-this.options.edge_resistance)
this.near_edge|=this.NEAR_BOTTOM_EDGE;if(this.bug.left<this.options.edge_resistance)