aboutsummaryrefslogtreecommitdiff
path: root/src/fields
diff options
context:
space:
mode:
Diffstat (limited to 'src/fields')
-rw-r--r--src/fields/Document.ts37
-rw-r--r--src/fields/Field.ts4
-rw-r--r--src/fields/WebField.ts2
3 files changed, 15 insertions, 28 deletions
diff --git a/src/fields/Document.ts b/src/fields/Document.ts
index 92d03d765..8eca5e30c 100644
--- a/src/fields/Document.ts
+++ b/src/fields/Document.ts
@@ -34,33 +34,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-";
}
@@ -106,7 +93,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)) {
@@ -137,7 +124,7 @@ export class Document extends Field {
break;
}
}
- if (doc == FieldWaiting) field = FieldWaiting;
+ if (doc === FieldWaiting) field = FieldWaiting;
}
return field;
@@ -191,7 +178,7 @@ export class Document extends Field {
if (callback) {
fn(callback);
} else {
- return new Promise(res => fn(res));
+ return new Promise(fn);
}
}
@@ -237,7 +224,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;
@@ -249,7 +236,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();
@@ -366,7 +353,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();
}
@@ -415,7 +402,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/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 {