1
0
mirror of https://github.com/falk-werner/webfuse-provider synced 2024-10-27 20:44:10 +00:00

fixed some code style issues

This commit is contained in:
Falk Werner 2019-02-13 21:09:43 +01:00
parent 78b83379b8
commit 14af1fd8d1
4 changed files with 22 additions and 22 deletions

View File

@ -11,10 +11,10 @@ class Connection {
connectTo(url) { connectTo(url) {
if (this.ws) { this.close(); } if (this.ws) { this.close(); }
this.ws = new WebSocket(url, 'fs'); this.ws = new WebSocket(url, "fs");
this.ws.onopen = () => { this.ws.onopen = () => {
this.isConnected = true; this.isConnected = true;
this.onopen() this.onopen();
}; };
this.ws.onclose = () => { this.ws.onclose = () => {
this.isConnected = false; this.isConnected = false;

View File

@ -4,21 +4,21 @@ class ConnectionView {
this.connection.onclose = () => { this.onConnectionClosed(); }; this.connection.onclose = () => { this.onConnectionClosed(); };
this.connection.onopen = () => { this.onConnectionOpened(); }; this.connection.onopen = () => { this.onConnectionOpened(); };
this.element = document.createElement('div'); this.element = document.createElement("div");
let urlLabel = document.createElement('span'); let urlLabel = document.createElement("span");
urlLabel.textContent = 'URL:'; urlLabel.textContent = "URL:";
this.element.appendChild(urlLabel); this.element.appendChild(urlLabel);
this.urlTextbox = document.createElement('input'); this.urlTextbox = document.createElement("input");
this.urlTextbox.type = 'text'; this.urlTextbox.type = "text";
this.urlTextbox.value = window.location.href.replace(/^http/, "ws"); this.urlTextbox.value = window.location.href.replace(/^http/, "ws");
this.element.appendChild(this.urlTextbox); this.element.appendChild(this.urlTextbox);
this.connectButton = document.createElement('input'); this.connectButton = document.createElement("input");
this.connectButton.type = 'button'; this.connectButton.type = "button";
this.connectButton.value = 'connect'; this.connectButton.value = "connect";
this.connectButton.addEventListener('click', () => { this.onConnectButtonClicked(); }); this.connectButton.addEventListener("click", () => { this.onConnectButtonClicked(); });
this.element.appendChild(this.connectButton); this.element.appendChild(this.connectButton);
} }
@ -32,11 +32,11 @@ class ConnectionView {
} }
} }
onConnectionOpened() { onConnectionOpened() {
this.connectButton.value = 'disconnect'; this.connectButton.value = "disconnect";
} }
onConnectionClosed() { onConnectionClosed() {
this.connectButton.value = 'connect'; this.connectButton.value = "connect";
} }
} }

View File

@ -44,7 +44,7 @@ class FileSystem {
return { return {
inode: entry.inode, inode: entry.inode,
mode: entry.mode || parseInt("755", 8), mode: entry.mode || parseInt("755", 8),
type: entry.type || 'file', type: entry.type || "file",
size: entry.size || (entry.contents && entry.contents.length) || 0, size: entry.size || (entry.contents && entry.contents.length) || 0,
atime: entry.atime || 0, atime: entry.atime || 0,
mtime: entry.mtime || 0, mtime: entry.mtime || 0,
@ -62,7 +62,7 @@ class FileSystem {
if (entry) { if (entry) {
return { return {
mode: entry.mode || parseInt("755", 8), mode: entry.mode || parseInt("755", 8),
type: entry.type || 'file', type: entry.type || "file",
size: entry.size || (entry.contents && entry.contents.length) || 0, size: entry.size || (entry.contents && entry.contents.length) || 0,
atime: entry.atime || 0, atime: entry.atime || 0,
mtime: entry.mtime || 0, mtime: entry.mtime || 0,
@ -80,13 +80,13 @@ class FileSystem {
if ((entry) && ("dir" === entry.type)) { if ((entry) && ("dir" === entry.type)) {
result = [ result = [
{name: '.', inode: entry.inode}, {name: ".", inode: entry.inode},
{name: '..', inode: entry.inode} {name: "..", inode: entry.inode}
]; ];
for(let subdir of Object.entries(entry.entries)) { for(let subdir of Object.entries(entry.entries)) {
const name = subdir[0]; const name = subdir[0];
const inode = subdir[1].inode; const inode = subdir[1].inode;
result.push({name: name, inode: inode}); result.push({name, inode});
} }
} }
@ -97,8 +97,8 @@ class FileSystem {
let result = FileSystem.BAD_NOENTRY; let result = FileSystem.BAD_NOENTRY;
let entry = this._inodes[inode]; let entry = this._inodes[inode];
if (entry.type == "file") { if (entry.type === "file") {
result = ((mode & FileSystem.O_ACCMODE) == FileSystem.O_RDONLY) ? {handle: 1337} : FileSystem.BAD_NOACCESS; result = ((mode & FileSystem.O_ACCMODE) === FileSystem.O_RDONLY) ? {handle: 1337} : FileSystem.BAD_NOACCESS;
} }
return result; return result;
@ -113,7 +113,7 @@ class FileSystem {
let result = FileSystem.BAD_NOENTRY; let result = FileSystem.BAD_NOENTRY;
let entry = this._inodes[inode]; let entry = this._inodes[inode];
if (entry.type == "file") { if (entry.type === "file") {
let end = Math.min(offset + length, entry.contents.length); let end = Math.min(offset + length, entry.contents.length);
let data = (offset < entry.contents.length) ? entry.contents.substring(offset, end) : ""; let data = (offset < entry.contents.length) ? entry.contents.substring(offset, end) : "";
result = { result = {

View File

@ -83,5 +83,5 @@ class FileSystemHandler {
} }
} }
catch (ex) { console.log(ex, message); } catch (ex) { console.log(ex, message); }
}; }
} }