Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JS, HTML and CSS fmt + NPM lockfile version bump #514

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
501 changes: 310 additions & 191 deletions client/index.html

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions client/scripts/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ class Peer {
}

_onChunkReceived(chunk) {
if(!chunk.byteLength) return;
if (!chunk.byteLength) return;

this._digester.unchunk(chunk);
const progress = this._digester.progress;
this._onDownloadProgress(progress);
Expand Down Expand Up @@ -254,7 +254,7 @@ class RTCPeer extends Peer {
}

_openChannel() {
const channel = this._conn.createDataChannel('data-channel', {
const channel = this._conn.createDataChannel('data-channel', {
ordered: true,
reliable: true // Obsolete. See https://developer.mozilla.org/en-US/docs/Web/API/RTCDataChannel/reliable
});
Expand All @@ -279,7 +279,7 @@ class RTCPeer extends Peer {

if (message.sdp) {
this._conn.setRemoteDescription(new RTCSessionDescription(message.sdp))
.then( _ => {
.then(_ => {
if (message.sdp.type === 'offer') {
return this._conn.createAnswer()
.then(d => this._onDescription(d));
Expand Down
12 changes: 6 additions & 6 deletions client/scripts/theme.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
(function(){
(function () {

// Select the button
const btnTheme = document.getElementById('theme');
// Check for dark mode preference at the OS level
const prefersDarkScheme = window.matchMedia('(prefers-color-scheme: dark)');

// Get the user's theme preference from local storage, if it's available
const currentTheme = localStorage.getItem('theme');
// If the user's preference in localStorage is dark...
if (currentTheme == 'dark') {
// ...let's toggle the .dark-theme class on the body
document.body.classList.toggle('dark-theme');
// Otherwise, if the user's preference in localStorage is light...
// Otherwise, if the user's preference in localStorage is light...
} else if (currentTheme == 'light') {
// ...let's toggle the .light-theme class on the body
document.body.classList.toggle('light-theme');
}

// Listen for a click on the button
btnTheme.addEventListener('click', function() {
btnTheme.addEventListener('click', function () {
// If the user's OS setting is dark and matches our .dark-theme class...
if (prefersDarkScheme.matches) {
// ...then toggle the light mode class
Expand Down
20 changes: 10 additions & 10 deletions client/scripts/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,11 @@ class ReceiveDialog extends Dialog {
$a.href = url;
$a.download = file.name;

if(this._autoDownload()){
if (this._autoDownload()) {
$a.click()
return
}
if(file.mime.split('/')[0] === 'image'){
if (file.mime.split('/')[0] === 'image') {
console.log('the file is image');
this.$el.querySelector('.preview').style.visibility = 'inherit';
this.$el.querySelector("#img-preview").src = url;
Expand Down Expand Up @@ -304,7 +304,7 @@ class ReceiveDialog extends Dialog {
}


_autoDownload(){
_autoDownload() {
return !this.$el.querySelector('#autoDownload').checked
}
}
Expand Down Expand Up @@ -435,12 +435,12 @@ class Notifications {
}

// Notification is persistent on Android. We have to close it manually
const visibilitychangeHandler = () => {
if (document.visibilityState === 'visible') {
const visibilitychangeHandler = () => {
if (document.visibilityState === 'visible') {
notification.close();
Events.off('visibilitychange', visibilitychangeHandler);
}
};
}
};
Events.on('visibilitychange', visibilitychangeHandler);

return notification;
Expand Down Expand Up @@ -516,7 +516,7 @@ class WebShareTargetUI {
let shareTargetText = title ? title : '';
shareTargetText += text ? shareTargetText ? ' ' + text : text : '';

if(url) shareTargetText = url; // We share only the Link - no text. Because link-only text becomes clickable.
if (url) shareTargetText = url; // We share only the Link - no text. Because link-only text becomes clickable.

if (!shareTargetText) return;
window.shareTargetText = shareTargetText;
Expand Down Expand Up @@ -617,13 +617,13 @@ Events.on('load', () => {

function animate() {
if (loading || step % dw < dw - 5) {
requestAnimationFrame(function() {
requestAnimationFrame(function () {
drawCircles();
animate();
});
}
}
window.animateBackground = function(l) {
window.animateBackground = function (l) {
loading = l;
animate();
};
Expand Down
18 changes: 9 additions & 9 deletions client/service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,44 +11,44 @@ var urlsToCache = [
'images/favicon-96x96.png'
];

self.addEventListener('install', function(event) {
self.addEventListener('install', function (event) {
// Perform install steps
event.waitUntil(
caches.open(CACHE_NAME)
.then(function(cache) {
.then(function (cache) {
console.log('Opened cache');
return cache.addAll(urlsToCache);
})
);
});


self.addEventListener('fetch', function(event) {
self.addEventListener('fetch', function (event) {
event.respondWith(
caches.match(event.request)
.then(function(response) {
.then(function (response) {
// Cache hit - return response
if (response) {
return response;
}
return fetch(event.request);
}
)
)
);
});


self.addEventListener('activate', function(event) {
self.addEventListener('activate', function (event) {
console.log('Updating Service Worker...')
event.waitUntil(
caches.keys().then(function(cacheNames) {
caches.keys().then(function (cacheNames) {
return Promise.all(
cacheNames.filter(function(cacheName) {
cacheNames.filter(function (cacheName) {
// Return true if you want to remove this cache,
// but remember that caches are shared across
// the whole origin
return true
}).map(function(cacheName) {
}).map(function (cacheName) {
return caches.delete(cacheName);
})
);
Expand Down
8 changes: 4 additions & 4 deletions client/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ screen and (min-width: 1100px) {
*/
@supports (-webkit-overflow-scrolling: touch) {


html {
position: fixed;
}
Expand Down Expand Up @@ -717,8 +717,9 @@ x-dialog x-paper {
color: var(--text-color);
background-color: var(--bg-color-secondary);
}

/* Image Preview */
#img-preview{
#img-preview {
max-height: 50vh;
margin: auto;
display: block;
Expand Down Expand Up @@ -753,5 +754,4 @@ x-dialog x-paper {
body {
overflow: hidden;
}
}

}
30 changes: 15 additions & 15 deletions server/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
var process = require('process')
// Handle SIGINT
process.on('SIGINT', () => {
console.info("SIGINT Received, exiting...")
process.exit(0)
console.info("SIGINT Received, exiting...")
process.exit(0)
})

// Handle SIGTERM
process.on('SIGTERM', () => {
console.info("SIGTERM Received, exiting...")
process.exit(0)
console.info("SIGTERM Received, exiting...")
process.exit(0)
})

const parser = require('ua-parser-js');
Expand Down Expand Up @@ -210,18 +210,18 @@ class Peer {


let deviceName = '';

if (ua.os && ua.os.name) {
deviceName = ua.os.name.replace('Mac OS', 'Mac') + ' ';
}

if (ua.device.model) {
deviceName += ua.device.model;
} else {
deviceName += ua.browser.name;
}

if(!deviceName)
if (!deviceName)
deviceName = 'Unknown Device';

const displayName = uniqueNamesGenerator({
Expand Down Expand Up @@ -278,15 +278,15 @@ class Peer {
}

Object.defineProperty(String.prototype, 'hashCode', {
value: function() {
var hash = 0, i, chr;
for (i = 0; i < this.length; i++) {
chr = this.charCodeAt(i);
hash = ((hash << 5) - hash) + chr;
hash |= 0; // Convert to 32bit integer
value: function () {
var hash = 0, i, chr;
for (i = 0; i < this.length; i++) {
chr = this.charCodeAt(i);
hash = ((hash << 5) - hash) + chr;
hash |= 0; // Convert to 32bit integer
}
return hash;
}
return hash;
}
});

const server = new SnapdropServer(process.env.PORT || 3000);
53 changes: 51 additions & 2 deletions server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.