mirror of
https://github.com/schlagmichdoch/PairDrop.git
synced 2026-04-23 07:30:54 +08:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8f4ce63a0c | |||
| b42c8a0b1a | |||
| 4c7bdd3a0f | |||
| 3f72fa1160 | |||
| 5c3f5ece7d |
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "pairdrop",
|
"name": "pairdrop",
|
||||||
"version": "1.6.1",
|
"version": "1.6.2",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "pairdrop",
|
"name": "pairdrop",
|
||||||
"version": "1.6.1",
|
"version": "1.6.2",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "pairdrop",
|
"name": "pairdrop",
|
||||||
"version": "1.6.1",
|
"version": "1.6.2",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
+6
-6
@@ -6,7 +6,7 @@
|
|||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
<!-- Web App Config -->
|
<!-- Web App Config -->
|
||||||
<title>PairDrop</title>
|
<title>PairDrop</title>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<meta name="theme-color" content="#3367d6">
|
<meta name="theme-color" content="#3367d6">
|
||||||
<meta name="color-scheme" content="dark light">
|
<meta name="color-scheme" content="dark light">
|
||||||
<meta name="apple-mobile-web-app-capable" content="no">
|
<meta name="apple-mobile-web-app-capable" content="no">
|
||||||
@@ -39,24 +39,24 @@
|
|||||||
|
|
||||||
<body translate="no">
|
<body translate="no">
|
||||||
<header class="row-reverse">
|
<header class="row-reverse">
|
||||||
<a href="#about" class="icon-button" title="About PairDrop">
|
<a href="#about" class="icon-button" title="About PairDrop" aria-label="Open About PairDrop">
|
||||||
<svg class="icon">
|
<svg class="icon">
|
||||||
<use xlink:href="#info-outline" />
|
<use xlink:href="#info-outline" />
|
||||||
</svg>
|
</svg>
|
||||||
</a>
|
</a>
|
||||||
<div id="theme-wrapper">
|
<div id="theme-wrapper">
|
||||||
<div id="theme-auto" class="icon-button selected" title="Adapt to System" >
|
<div id="theme-auto" class="icon-button selected" title="Adapt Theme to System" >
|
||||||
<svg class="icon">
|
<svg class="icon">
|
||||||
<use xlink:href="#icon-theme-auto" />
|
<use xlink:href="#icon-theme-auto" />
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div id="theme-light" class="icon-button" title="Always Light" >
|
<div id="theme-light" class="icon-button" title="Always Use Light-Theme" >
|
||||||
<svg class="icon">
|
<svg class="icon">
|
||||||
<use xlink:href="#icon-theme-light" />
|
<use xlink:href="#icon-theme-light" />
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
<div id="theme-dark" class="icon-button" title="Always Dark" >
|
<div id="theme-dark" class="icon-button" title="Always Use Dark-Theme" >
|
||||||
<svg class="icon">
|
<svg class="icon">
|
||||||
<use xlink:href="#icon-theme-dark" />
|
<use xlink:href="#icon-theme-dark" />
|
||||||
</svg>
|
</svg>
|
||||||
@@ -264,7 +264,7 @@
|
|||||||
<!-- About Page -->
|
<!-- About Page -->
|
||||||
<x-about id="about" class="full center column">
|
<x-about id="about" class="full center column">
|
||||||
<header class="row-reverse fade-in">
|
<header class="row-reverse fade-in">
|
||||||
<a href="#" class="close icon-button">
|
<a href="#" class="close icon-button" aria-label="Close About PairDrop">
|
||||||
<svg class="icon">
|
<svg class="icon">
|
||||||
<use xlink:href="#close-icon" />
|
<use xlink:href="#close-icon" />
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
+18
-58
@@ -57,6 +57,12 @@ class PeersUI {
|
|||||||
console.log("Retrieved edited display name:", displayName)
|
console.log("Retrieved edited display name:", displayName)
|
||||||
if (displayName) Events.fire('self-display-name-changed', displayName);
|
if (displayName) Events.fire('self-display-name-changed', displayName);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
/* prevent animation on load */
|
||||||
|
setTimeout(_ => {
|
||||||
|
this.$xNoPeers.style.animationIterationCount = "1";
|
||||||
|
}, 300);
|
||||||
}
|
}
|
||||||
|
|
||||||
_insertDisplayName(displayName) {
|
_insertDisplayName(displayName) {
|
||||||
@@ -175,7 +181,6 @@ class PeersUI {
|
|||||||
if (!$peer) return;
|
if (!$peer) return;
|
||||||
$peer.remove();
|
$peer.remove();
|
||||||
this.evaluateOverflowing();
|
this.evaluateOverflowing();
|
||||||
if ($$('x-peers:empty')) setTimeout(_ => window.animateBackground(true), 1750); // Start animation again
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_onSecretRoomDeleted(roomSecret) {
|
_onSecretRoomDeleted(roomSecret) {
|
||||||
@@ -315,7 +320,6 @@ class PeerUI {
|
|||||||
$$('x-peers').appendChild(this.$el)
|
$$('x-peers').appendChild(this.$el)
|
||||||
Events.fire('peer-added');
|
Events.fire('peer-added');
|
||||||
this.$xInstructions = $$('x-instructions');
|
this.$xInstructions = $$('x-instructions');
|
||||||
setTimeout(_ => window.animateBackground(false), 1750); // Stop animation
|
|
||||||
}
|
}
|
||||||
|
|
||||||
html() {
|
html() {
|
||||||
@@ -1571,27 +1575,15 @@ class NetworkStatusUI {
|
|||||||
constructor() {
|
constructor() {
|
||||||
Events.on('offline', _ => this._showOfflineMessage());
|
Events.on('offline', _ => this._showOfflineMessage());
|
||||||
Events.on('online', _ => this._showOnlineMessage());
|
Events.on('online', _ => this._showOnlineMessage());
|
||||||
Events.on('ws-connected', _ => this._onWsConnected());
|
|
||||||
Events.on('ws-disconnected', _ => this._onWsDisconnected());
|
|
||||||
if (!navigator.onLine) this._showOfflineMessage();
|
if (!navigator.onLine) this._showOfflineMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
_showOfflineMessage() {
|
_showOfflineMessage() {
|
||||||
Events.fire('notify-user', 'You are offline');
|
Events.fire('notify-user', 'You are offline');
|
||||||
window.animateBackground(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_showOnlineMessage() {
|
_showOnlineMessage() {
|
||||||
Events.fire('notify-user', 'You are back online');
|
Events.fire('notify-user', 'You are back online');
|
||||||
window.animateBackground(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
_onWsConnected() {
|
|
||||||
window.animateBackground(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
_onWsDisconnected() {
|
|
||||||
window.animateBackground(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1942,28 +1934,26 @@ window.addEventListener('beforeinstallprompt', e => {
|
|||||||
return e.preventDefault();
|
return e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Background Animation
|
// Background Circles
|
||||||
Events.on('load', () => {
|
Events.on('load', () => {
|
||||||
let c = document.createElement('canvas');
|
let c = document.createElement('canvas');
|
||||||
document.body.appendChild(c);
|
|
||||||
let style = c.style;
|
let style = c.style;
|
||||||
style.width = '100%';
|
style.width = '100%';
|
||||||
style.position = 'absolute';
|
style.position = 'absolute';
|
||||||
style.zIndex = -1;
|
style.zIndex = -1;
|
||||||
style.top = 0;
|
style.top = 0;
|
||||||
style.left = 0;
|
style.left = 0;
|
||||||
|
style.animation = "fade-in 800ms";
|
||||||
let cCtx = c.getContext('2d');
|
let cCtx = c.getContext('2d');
|
||||||
let x0, y0, w, h, dw, offset;
|
let x0, y0, w, h, dw, offset;
|
||||||
|
|
||||||
let offscreenCanvases = [];
|
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
let oldW = w;
|
let oldW = w;
|
||||||
let oldH = h;
|
let oldH = h;
|
||||||
let oldOffset = offset
|
let oldOffset = offset
|
||||||
w = document.documentElement.clientWidth;
|
w = document.documentElement.clientWidth;
|
||||||
h = document.documentElement.clientHeight;
|
h = document.documentElement.clientHeight;
|
||||||
offset = $$('footer').offsetHeight - 32;
|
offset = $$('footer').offsetHeight - 33;
|
||||||
if (h > 800) offset += 16;
|
if (h > 800) offset += 16;
|
||||||
|
|
||||||
if (oldW === w && oldH === h && oldOffset === offset) return; // nothing has changed
|
if (oldW === w && oldH === h && oldOffset === offset) return; // nothing has changed
|
||||||
@@ -1973,63 +1963,33 @@ Events.on('load', () => {
|
|||||||
x0 = w / 2;
|
x0 = w / 2;
|
||||||
y0 = h - offset;
|
y0 = h - offset;
|
||||||
dw = Math.round(Math.max(w, h, 1000) / 13);
|
dw = Math.round(Math.max(w, h, 1000) / 13);
|
||||||
drawCircles(cCtx, 0);
|
|
||||||
|
|
||||||
// enforce redrawing of frames
|
if (document.body.contains(c)) {
|
||||||
offscreenCanvases = [];
|
document.body.removeChild(c);
|
||||||
}
|
}
|
||||||
|
drawCircles(cCtx, dw);
|
||||||
|
document.body.appendChild(c);
|
||||||
|
}
|
||||||
|
|
||||||
Events.on('bg-resize', _ => init());
|
Events.on('bg-resize', _ => init());
|
||||||
window.onresize = _ => Events.fire('bg-resize');
|
window.onresize = _ => Events.fire('bg-resize');
|
||||||
|
|
||||||
function drawCircle(ctx, radius) {
|
function drawCircle(ctx, radius) {
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.lineWidth = 2;
|
ctx.lineWidth = 2;
|
||||||
let opacity = 0.2 * (1 - 1.2 * radius / Math.max(w, h));
|
let opacity = 0.3 * (1 - 1.2 * radius / Math.max(w, h));
|
||||||
ctx.strokeStyle = `rgb(128, 128, 128, ${opacity})`;
|
ctx.strokeStyle = `rgba(128, 128, 128, ${opacity})`;
|
||||||
ctx.arc(x0, y0, radius, 0, 2 * Math.PI);
|
ctx.arc(x0, y0, radius, 0, 2 * Math.PI);
|
||||||
ctx.stroke();
|
ctx.stroke();
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawCircles(ctx, frame) {
|
function drawCircles(ctx, frame) {
|
||||||
for (let i = 0; i < 13; i++) {
|
for (let i = 0; i < 13; i++) {
|
||||||
drawCircle(ctx, dw * i + frame);
|
drawCircle(ctx, dw * i + frame + 33);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createOffscreenCanvas(frame) {
|
|
||||||
let canvas = document.createElement("canvas");
|
|
||||||
canvas.width = c.width;
|
|
||||||
canvas.height = c.height;
|
|
||||||
offscreenCanvases[frame] = canvas;
|
|
||||||
let ctx = canvas.getContext('2d');
|
|
||||||
drawCircles(ctx, frame);
|
|
||||||
}
|
|
||||||
|
|
||||||
function drawFrame(frame) {
|
|
||||||
cCtx.clearRect(0, 0, w, h);
|
|
||||||
if (!offscreenCanvases[frame]) {
|
|
||||||
createOffscreenCanvas(frame);
|
|
||||||
}
|
|
||||||
cCtx.drawImage(offscreenCanvases[frame], 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
let animate = true;
|
|
||||||
let currentFrame = 0;
|
|
||||||
|
|
||||||
function animateBg() {
|
|
||||||
if (currentFrame + 1 < dw || animate) {
|
|
||||||
currentFrame = (currentFrame + 1) % dw;
|
|
||||||
drawFrame(currentFrame);
|
|
||||||
}
|
|
||||||
setTimeout(_ => animateBg(), 3000 / dw);
|
|
||||||
}
|
|
||||||
|
|
||||||
window.animateBackground = function(l) {
|
|
||||||
animate = l;
|
|
||||||
};
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
animateBg();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
document.changeFavicon = function (src) {
|
document.changeFavicon = function (src) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const cacheVersion = 'v1.6.1';
|
const cacheVersion = 'v1.6.2';
|
||||||
const cacheTitle = `pairdrop-cache-${cacheVersion}`;
|
const cacheTitle = `pairdrop-cache-${cacheVersion}`;
|
||||||
const urlsToCache = [
|
const urlsToCache = [
|
||||||
'index.html',
|
'index.html',
|
||||||
|
|||||||
+2
-2
@@ -405,10 +405,10 @@ x-no-peers {
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
/* prevent flickering on load */
|
|
||||||
animation: fade-in 300ms;
|
animation: fade-in 300ms;
|
||||||
animation-delay: 500ms;
|
|
||||||
animation-fill-mode: backwards;
|
animation-fill-mode: backwards;
|
||||||
|
/* prevent flickering on load */
|
||||||
|
animation-iteration-count: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
x-no-peers h2,
|
x-no-peers h2,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
<!-- Web App Config -->
|
<!-- Web App Config -->
|
||||||
<title>PairDrop</title>
|
<title>PairDrop</title>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<meta name="theme-color" content="#3367d6">
|
<meta name="theme-color" content="#3367d6">
|
||||||
<meta name="color-scheme" content="dark light">
|
<meta name="color-scheme" content="dark light">
|
||||||
<meta name="apple-mobile-web-app-capable" content="no">
|
<meta name="apple-mobile-web-app-capable" content="no">
|
||||||
@@ -39,24 +39,24 @@
|
|||||||
|
|
||||||
<body translate="no">
|
<body translate="no">
|
||||||
<header class="row-reverse">
|
<header class="row-reverse">
|
||||||
<a href="#about" class="icon-button" title="About PairDrop">
|
<a href="#about" class="icon-button" title="About PairDrop" aria-label="Open About PairDrop">
|
||||||
<svg class="icon">
|
<svg class="icon">
|
||||||
<use xlink:href="#info-outline" />
|
<use xlink:href="#info-outline" />
|
||||||
</svg>
|
</svg>
|
||||||
</a>
|
</a>
|
||||||
<div id="theme-wrapper">
|
<div id="theme-wrapper">
|
||||||
<div id="theme-auto" class="icon-button selected" title="Adapt to System" >
|
<div id="theme-auto" class="icon-button selected" title="Adapt Theme to System" >
|
||||||
<svg class="icon">
|
<svg class="icon">
|
||||||
<use xlink:href="#icon-theme-auto" />
|
<use xlink:href="#icon-theme-auto" />
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div id="theme-light" class="icon-button" title="Always Light" >
|
<div id="theme-light" class="icon-button" title="Always Use Light-Theme" >
|
||||||
<svg class="icon">
|
<svg class="icon">
|
||||||
<use xlink:href="#icon-theme-light" />
|
<use xlink:href="#icon-theme-light" />
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
<div id="theme-dark" class="icon-button" title="Always Dark" >
|
<div id="theme-dark" class="icon-button" title="Always Use Dark-Theme" >
|
||||||
<svg class="icon">
|
<svg class="icon">
|
||||||
<use xlink:href="#icon-theme-dark" />
|
<use xlink:href="#icon-theme-dark" />
|
||||||
</svg>
|
</svg>
|
||||||
@@ -267,7 +267,7 @@
|
|||||||
<!-- About Page -->
|
<!-- About Page -->
|
||||||
<x-about id="about" class="full center column">
|
<x-about id="about" class="full center column">
|
||||||
<header class="row-reverse fade-in">
|
<header class="row-reverse fade-in">
|
||||||
<a href="#" class="close icon-button">
|
<a href="#" class="close icon-button" aria-label="Close About PairDrop">
|
||||||
<svg class="icon">
|
<svg class="icon">
|
||||||
<use xlink:href="#close-icon" />
|
<use xlink:href="#close-icon" />
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
@@ -57,6 +57,12 @@ class PeersUI {
|
|||||||
console.log("Retrieved edited display name:", displayName)
|
console.log("Retrieved edited display name:", displayName)
|
||||||
if (displayName) Events.fire('self-display-name-changed', displayName);
|
if (displayName) Events.fire('self-display-name-changed', displayName);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
/* prevent animation on load */
|
||||||
|
setTimeout(_ => {
|
||||||
|
this.$xNoPeers.style.animationIterationCount = "1";
|
||||||
|
}, 300);
|
||||||
}
|
}
|
||||||
|
|
||||||
_insertDisplayName(displayName) {
|
_insertDisplayName(displayName) {
|
||||||
@@ -175,7 +181,6 @@ class PeersUI {
|
|||||||
if (!$peer) return;
|
if (!$peer) return;
|
||||||
$peer.remove();
|
$peer.remove();
|
||||||
this.evaluateOverflowing();
|
this.evaluateOverflowing();
|
||||||
if ($$('x-peers:empty')) setTimeout(_ => window.animateBackground(true), 1750); // Start animation again
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_onSecretRoomDeleted(roomSecret) {
|
_onSecretRoomDeleted(roomSecret) {
|
||||||
@@ -315,7 +320,6 @@ class PeerUI {
|
|||||||
$$('x-peers').appendChild(this.$el)
|
$$('x-peers').appendChild(this.$el)
|
||||||
Events.fire('peer-added');
|
Events.fire('peer-added');
|
||||||
this.$xInstructions = $$('x-instructions');
|
this.$xInstructions = $$('x-instructions');
|
||||||
setTimeout(_ => window.animateBackground(false), 1750); // Stop animation
|
|
||||||
}
|
}
|
||||||
|
|
||||||
html() {
|
html() {
|
||||||
@@ -362,7 +366,6 @@ class PeerUI {
|
|||||||
this.$el.ui = this;
|
this.$el.ui = this;
|
||||||
this._peer.roomTypes.forEach(roomType => this.$el.classList.add(`type-${roomType}`));
|
this._peer.roomTypes.forEach(roomType => this.$el.classList.add(`type-${roomType}`));
|
||||||
this.$el.classList.add('center');
|
this.$el.classList.add('center');
|
||||||
if (!this._peer.rtcSupported || !window.isRtcSupported) this.$el.classList.add('ws-peer')
|
|
||||||
this.html();
|
this.html();
|
||||||
|
|
||||||
this._callbackInput = e => this._onFilesSelected(e)
|
this._callbackInput = e => this._onFilesSelected(e)
|
||||||
@@ -1572,27 +1575,15 @@ class NetworkStatusUI {
|
|||||||
constructor() {
|
constructor() {
|
||||||
Events.on('offline', _ => this._showOfflineMessage());
|
Events.on('offline', _ => this._showOfflineMessage());
|
||||||
Events.on('online', _ => this._showOnlineMessage());
|
Events.on('online', _ => this._showOnlineMessage());
|
||||||
Events.on('ws-connected', _ => this._onWsConnected());
|
|
||||||
Events.on('ws-disconnected', _ => this._onWsDisconnected());
|
|
||||||
if (!navigator.onLine) this._showOfflineMessage();
|
if (!navigator.onLine) this._showOfflineMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
_showOfflineMessage() {
|
_showOfflineMessage() {
|
||||||
Events.fire('notify-user', 'You are offline');
|
Events.fire('notify-user', 'You are offline');
|
||||||
window.animateBackground(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_showOnlineMessage() {
|
_showOnlineMessage() {
|
||||||
Events.fire('notify-user', 'You are back online');
|
Events.fire('notify-user', 'You are back online');
|
||||||
window.animateBackground(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
_onWsConnected() {
|
|
||||||
window.animateBackground(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
_onWsDisconnected() {
|
|
||||||
window.animateBackground(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1943,28 +1934,26 @@ window.addEventListener('beforeinstallprompt', e => {
|
|||||||
return e.preventDefault();
|
return e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Background Animation
|
// Background Circles
|
||||||
Events.on('load', () => {
|
Events.on('load', () => {
|
||||||
let c = document.createElement('canvas');
|
let c = document.createElement('canvas');
|
||||||
document.body.appendChild(c);
|
|
||||||
let style = c.style;
|
let style = c.style;
|
||||||
style.width = '100%';
|
style.width = '100%';
|
||||||
style.position = 'absolute';
|
style.position = 'absolute';
|
||||||
style.zIndex = -1;
|
style.zIndex = -1;
|
||||||
style.top = 0;
|
style.top = 0;
|
||||||
style.left = 0;
|
style.left = 0;
|
||||||
|
style.animation = "fade-in 800ms";
|
||||||
let cCtx = c.getContext('2d');
|
let cCtx = c.getContext('2d');
|
||||||
let x0, y0, w, h, dw, offset;
|
let x0, y0, w, h, dw, offset;
|
||||||
|
|
||||||
let offscreenCanvases = [];
|
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
let oldW = w;
|
let oldW = w;
|
||||||
let oldH = h;
|
let oldH = h;
|
||||||
let oldOffset = offset
|
let oldOffset = offset
|
||||||
w = document.documentElement.clientWidth;
|
w = document.documentElement.clientWidth;
|
||||||
h = document.documentElement.clientHeight;
|
h = document.documentElement.clientHeight;
|
||||||
offset = $$('footer').offsetHeight - 32;
|
offset = $$('footer').offsetHeight - 33;
|
||||||
if (h > 800) offset += 16;
|
if (h > 800) offset += 16;
|
||||||
|
|
||||||
if (oldW === w && oldH === h && oldOffset === offset) return; // nothing has changed
|
if (oldW === w && oldH === h && oldOffset === offset) return; // nothing has changed
|
||||||
@@ -1974,63 +1963,33 @@ Events.on('load', () => {
|
|||||||
x0 = w / 2;
|
x0 = w / 2;
|
||||||
y0 = h - offset;
|
y0 = h - offset;
|
||||||
dw = Math.round(Math.max(w, h, 1000) / 13);
|
dw = Math.round(Math.max(w, h, 1000) / 13);
|
||||||
drawCircles(cCtx, 0);
|
|
||||||
|
|
||||||
// enforce redrawing of frames
|
if (document.body.contains(c)) {
|
||||||
offscreenCanvases = [];
|
document.body.removeChild(c);
|
||||||
}
|
}
|
||||||
|
drawCircles(cCtx, dw);
|
||||||
|
document.body.appendChild(c);
|
||||||
|
}
|
||||||
|
|
||||||
Events.on('bg-resize', _ => init());
|
Events.on('bg-resize', _ => init());
|
||||||
window.onresize = _ => Events.fire('bg-resize');
|
window.onresize = _ => Events.fire('bg-resize');
|
||||||
|
|
||||||
function drawCircle(ctx, radius) {
|
function drawCircle(ctx, radius) {
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.lineWidth = 2;
|
ctx.lineWidth = 2;
|
||||||
let opacity = 0.2 * (1 - 1.2 * radius / Math.max(w, h));
|
let opacity = 0.3 * (1 - 1.2 * radius / Math.max(w, h));
|
||||||
ctx.strokeStyle = `rgb(128, 128, 128, ${opacity})`;
|
ctx.strokeStyle = `rgba(128, 128, 128, ${opacity})`;
|
||||||
ctx.arc(x0, y0, radius, 0, 2 * Math.PI);
|
ctx.arc(x0, y0, radius, 0, 2 * Math.PI);
|
||||||
ctx.stroke();
|
ctx.stroke();
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawCircles(ctx, frame) {
|
function drawCircles(ctx, frame) {
|
||||||
for (let i = 0; i < 13; i++) {
|
for (let i = 0; i < 13; i++) {
|
||||||
drawCircle(ctx, dw * i + frame);
|
drawCircle(ctx, dw * i + frame + 33);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createOffscreenCanvas(frame) {
|
|
||||||
let canvas = document.createElement("canvas");
|
|
||||||
canvas.width = c.width;
|
|
||||||
canvas.height = c.height;
|
|
||||||
offscreenCanvases[frame] = canvas;
|
|
||||||
let ctx = canvas.getContext('2d');
|
|
||||||
drawCircles(ctx, frame);
|
|
||||||
}
|
|
||||||
|
|
||||||
function drawFrame(frame) {
|
|
||||||
cCtx.clearRect(0, 0, w, h);
|
|
||||||
if (!offscreenCanvases[frame]) {
|
|
||||||
createOffscreenCanvas(frame);
|
|
||||||
}
|
|
||||||
cCtx.drawImage(offscreenCanvases[frame], 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
let animate = true;
|
|
||||||
let currentFrame = 0;
|
|
||||||
|
|
||||||
function animateBg() {
|
|
||||||
if (currentFrame + 1 < dw || animate) {
|
|
||||||
currentFrame = (currentFrame + 1) % dw;
|
|
||||||
drawFrame(currentFrame);
|
|
||||||
}
|
|
||||||
setTimeout(_ => animateBg(), 3000 / dw);
|
|
||||||
}
|
|
||||||
|
|
||||||
window.animateBackground = function(l) {
|
|
||||||
animate = l;
|
|
||||||
};
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
animateBg();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
document.changeFavicon = function (src) {
|
document.changeFavicon = function (src) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const cacheVersion = 'v1.6.1';
|
const cacheVersion = 'v1.6.2';
|
||||||
const cacheTitle = `pairdrop-included-ws-fallback-cache-${cacheVersion}`;
|
const cacheTitle = `pairdrop-included-ws-fallback-cache-${cacheVersion}`;
|
||||||
const urlsToCache = [
|
const urlsToCache = [
|
||||||
'index.html',
|
'index.html',
|
||||||
|
|||||||
@@ -415,10 +415,10 @@ x-no-peers {
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
/* prevent flickering on load */
|
|
||||||
animation: fade-in 300ms;
|
animation: fade-in 300ms;
|
||||||
animation-delay: 500ms;
|
|
||||||
animation-fill-mode: backwards;
|
animation-fill-mode: backwards;
|
||||||
|
/* prevent flickering on load */
|
||||||
|
animation-iteration-count: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
x-no-peers h2,
|
x-no-peers h2,
|
||||||
|
|||||||
Reference in New Issue
Block a user