aboutsummaryrefslogtreecommitdiff
path: root/src/fields
diff options
context:
space:
mode:
Diffstat (limited to 'src/fields')
-rw-r--r--src/fields/AudioField.ts2
-rw-r--r--src/fields/BasicField.ts2
-rw-r--r--src/fields/Document.ts37
-rw-r--r--src/fields/Field.ts4
-rw-r--r--src/fields/ImageField.ts2
-rw-r--r--src/fields/KeyStore.ts9
-rw-r--r--src/fields/ListField.ts10
-rw-r--r--src/fields/PDFField.ts2
-rw-r--r--src/fields/VideoField.ts2
-rw-r--r--src/fields/WebField.ts2
10 files changed, 29 insertions, 43 deletions
diff --git a/src/fields/AudioField.ts b/src/fields/AudioField.ts
index 8864471ae..252a5b74e 100644
--- a/src/fields/AudioField.ts
+++ b/src/fields/AudioField.ts
@@ -4,7 +4,7 @@ import { Types } from "../server/Message";
export class AudioField extends BasicField<URL> {
constructor(data: URL | undefined = undefined, id?: FieldId, save: boolean = true) {
- super(data == undefined ? new URL("http://techslides.com/demos/samples/sample.mp3") : data, save, id);
+ super(data === undefined ? new URL("http://techslides.com/demos/samples/sample.mp3") : data, save, id);
}
toString(): string {
diff --git a/src/fields/BasicField.ts b/src/fields/BasicField.ts
index a92c4a236..3083a1937 100644
--- a/src/fields/BasicField.ts
+++ b/src/fields/BasicField.ts
@@ -46,7 +46,7 @@ export abstract class BasicField<T> extends Field {
@action
TrySetValue(value: any): boolean {
- if (typeof value == typeof this.data) {
+ if (typeof value === typeof this.data) {
this.Data = value;
return true;
}
diff --git a/src/fields/Document.ts b/src/fields/Document.ts
index 02004678d..4fa478f32 100644
--- a/src/fields/Document.ts
+++ b/src/fields/Document.ts
@@ -37,33 +37,20 @@ export class Document extends Field {
}
}
- public Width = () => {
- return this.GetNumber(KeyStore.Width, 0);
- };
- public Height = () => {
- return this.GetNumber(
- KeyStore.Height,
- this.GetNumber(KeyStore.NativeWidth, 0)
- ? (this.GetNumber(KeyStore.NativeHeight, 0) /
- this.GetNumber(KeyStore.NativeWidth, 0)) *
- this.GetNumber(KeyStore.Width, 0)
- : 0
- );
- };
- public Scale = () => {
- return this.GetNumber(KeyStore.Scale, 1);
- };
+ public Width = () => this.GetNumber(KeyStore.Width, 0)
+ public Height = () => this.GetNumber(KeyStore.Height, this.GetNumber(KeyStore.NativeWidth, 0) ? (this.GetNumber(KeyStore.NativeHeight, 0) / this.GetNumber(KeyStore.NativeWidth, 0)) * this.GetNumber(KeyStore.Width, 0) : 0);
+ public Scale = () => this.GetNumber(KeyStore.Scale, 1)
@computed
public get Title(): string {
let title = this.Get(KeyStore.Title, true);
if (title)
- if (title != FieldWaiting && title instanceof TextField)
+ if (title !== FieldWaiting && title instanceof TextField)
return title.Data;
else return "-waiting-";
let parTitle = this.GetT(KeyStore.Title, TextField);
if (parTitle)
- if (parTitle != FieldWaiting) return parTitle.Data + ".alias";
+ if (parTitle !== FieldWaiting) return parTitle.Data + ".alias";
else return "-waiting-.alias";
return "-untitled-";
}
@@ -109,7 +96,7 @@ export class Document extends Field {
}
} else {
let doc: FieldValue<Document> = this;
- while (doc && doc != FieldWaiting && field != FieldWaiting) {
+ while (doc && field !== FieldWaiting) {
let curField = doc.fields.get(key.Id);
let curProxy = doc._proxies.get(key.Id);
if (!curField || (curProxy && curField.field.Id !== curProxy)) {
@@ -140,7 +127,7 @@ export class Document extends Field {
break;
}
}
- if (doc == FieldWaiting) field = FieldWaiting;
+ if (doc === FieldWaiting) field = FieldWaiting;
}
return field;
@@ -194,7 +181,7 @@ export class Document extends Field {
if (callback) {
fn(callback);
} else {
- return new Promise(res => fn(res));
+ return new Promise(fn);
}
}
@@ -240,7 +227,7 @@ export class Document extends Field {
ignoreProto: boolean = false
): FieldValue<T> {
var getfield = this.Get(key, ignoreProto);
- if (getfield != FieldWaiting) {
+ if (getfield !== FieldWaiting) {
return Cast(getfield, ctor);
}
return FieldWaiting;
@@ -252,7 +239,7 @@ export class Document extends Field {
ignoreProto: boolean = false
): T {
const field = this.GetT(key, ctor, ignoreProto);
- if (field && field != FieldWaiting) {
+ if (field && field !== FieldWaiting) {
return field;
}
const newField = new ctor();
@@ -362,7 +349,7 @@ export class Document extends Field {
GetAllPrototypes(): Document[] {
let protos: Document[] = [];
let doc: FieldValue<Document> = this;
- while (doc && doc != FieldWaiting) {
+ while (doc && doc !== FieldWaiting) {
protos.push(doc);
doc = doc.GetPrototype();
}
@@ -425,7 +412,7 @@ export class Document extends Field {
let fields: [string, string][] = [];
this._proxies.forEach((field, key) => {
if (field) {
- fields.push([key, field as string]);
+ fields.push([key, field]);
}
});
diff --git a/src/fields/Field.ts b/src/fields/Field.ts
index d48509a47..0d0e56f77 100644
--- a/src/fields/Field.ts
+++ b/src/fields/Field.ts
@@ -12,8 +12,8 @@ export function Cast<T extends Field>(field: FieldValue<Field>, ctor: { new(): T
return undefined;
}
-export const FieldWaiting: FIELD_WAITING = "<Waiting>";
-export type FIELD_WAITING = "<Waiting>";
+export const FieldWaiting: FIELD_WAITING = null;
+export type FIELD_WAITING = null;
export type FieldId = string;
export type Opt<T> = T | undefined;
export type FieldValue<T> = Opt<T> | FIELD_WAITING;
diff --git a/src/fields/ImageField.ts b/src/fields/ImageField.ts
index a9ece7d7b..ef616b2ad 100644
--- a/src/fields/ImageField.ts
+++ b/src/fields/ImageField.ts
@@ -4,7 +4,7 @@ import { Types } from "../server/Message";
export class ImageField extends BasicField<URL> {
constructor(data: URL | undefined = undefined, id?: FieldId, save: boolean = true) {
- super(data == undefined ? new URL("http://cs.brown.edu/~bcz/bob_fettucine.jpg") : data, save, id);
+ super(data === undefined ? new URL("http://cs.brown.edu/~bcz/bob_fettucine.jpg") : data, save, id);
}
toString(): string {
diff --git a/src/fields/KeyStore.ts b/src/fields/KeyStore.ts
index 42dc34c51..e24e9c8ec 100644
--- a/src/fields/KeyStore.ts
+++ b/src/fields/KeyStore.ts
@@ -55,11 +55,10 @@ export namespace KeyStore {
Archives, Workspaces, Minimized, CopyDraggedItems
];
export function KeyLookup(keyid: string) {
- for (let i = 0; i < KeyList.length; i++) {
- let keylistid = KeyList[i].Id;
- if (keylistid === keyid)
- return KeyList[i];
+ for (const key of KeyList) {
+ if (key.Id === keyid)
+ return key;
}
- return null;
+ return undefined;
}
}
diff --git a/src/fields/ListField.ts b/src/fields/ListField.ts
index c4008bd12..815a3df73 100644
--- a/src/fields/ListField.ts
+++ b/src/fields/ListField.ts
@@ -26,7 +26,7 @@ export class ListField<T extends Field> extends BasicField<T[]> {
}
this.observeDisposer = observe(this.Data as IObservableArray<T>, (change: IArrayChange<T> | IArraySplice<T>) => {
this.updateProxies()
- if (change.type == "splice") {
+ if (change.type === "splice") {
UndoManager.AddEvent({
undo: () => this.Data.splice(change.index, change.addedCount, ...change.removed),
redo: () => this.Data.splice(change.index, change.removedCount, ...change.added)
@@ -57,8 +57,8 @@ export class ListField<T extends Field> extends BasicField<T[]> {
}
private arraysEqual(a: any[], b: any[]) {
if (a === b) return true;
- if (a == null || b == null) return false;
- if (a.length != b.length) return false;
+ if (a === null || b === null) return false;
+ if (a.length !== b.length) return false;
// If you don't care about the order of the elements inside
// the array, you should sort both arrays here.
@@ -79,9 +79,9 @@ export class ListField<T extends Field> extends BasicField<T[]> {
var added = this.data.length < this._proxies.length;
var deleted = this.data.length > this._proxies.length;
for (let i = 0; i < dataids.length && added; i++)
- added = proxies.indexOf(dataids[i]) != -1;
+ added = proxies.indexOf(dataids[i]) !== -1;
for (let i = 0; i < this._proxies.length && deleted; i++)
- deleted = dataids.indexOf(proxies[i]) != -1;
+ deleted = dataids.indexOf(proxies[i]) !== -1;
this._processingServerUpdate = true;
for (let i = 0; i < proxies.length && added; i++) {
diff --git a/src/fields/PDFField.ts b/src/fields/PDFField.ts
index b6625387e..436c1cf2b 100644
--- a/src/fields/PDFField.ts
+++ b/src/fields/PDFField.ts
@@ -7,7 +7,7 @@ import { Types } from "../server/Message";
export class PDFField extends BasicField<URL> {
constructor(data: URL | undefined = undefined, id?: FieldId, save: boolean = true) {
- super(data == undefined ? new URL("http://cs.brown.edu/~bcz/bob_fettucine.jpg") : data, save, id);
+ super(data === undefined ? new URL("http://cs.brown.edu/~bcz/bob_fettucine.jpg") : data, save, id);
}
toString(): string {
diff --git a/src/fields/VideoField.ts b/src/fields/VideoField.ts
index 626e4ec83..992cc1641 100644
--- a/src/fields/VideoField.ts
+++ b/src/fields/VideoField.ts
@@ -4,7 +4,7 @@ import { Types } from "../server/Message";
export class VideoField extends BasicField<URL> {
constructor(data: URL | undefined = undefined, id?: FieldId, save: boolean = true) {
- super(data == undefined ? new URL("http://techslides.com/demos/sample-videos/small.mp4") : data, save, id);
+ super(data === undefined ? new URL("http://techslides.com/demos/sample-videos/small.mp4") : data, save, id);
}
toString(): string {
diff --git a/src/fields/WebField.ts b/src/fields/WebField.ts
index 6c4de5000..0cbcc6d33 100644
--- a/src/fields/WebField.ts
+++ b/src/fields/WebField.ts
@@ -4,7 +4,7 @@ import { Types } from "../server/Message";
export class WebField extends BasicField<URL> {
constructor(data: URL | undefined = undefined, id?: FieldId, save: boolean = true) {
- super(data == undefined ? new URL("https://crossorigin.me/" + "https://cs.brown.edu/") : data, save, id);
+ super(data === undefined ? new URL("https://crossorigin.me/" + "https://cs.brown.edu/") : data, save, id);
}
toString(): string {