aboutsummaryrefslogtreecommitdiff
path: root/src/fields/WebField.ts
diff options
context:
space:
mode:
authormadelinegr <laura_wilson@brown.edu>2019-03-02 16:33:42 -0500
committermadelinegr <laura_wilson@brown.edu>2019-03-02 16:33:42 -0500
commit043f40fec06da86732aeb6534d50edc56d4b8fad (patch)
treefe8ba1113ad87cfd41d4641120ce78b9553c8239 /src/fields/WebField.ts
parent33809739a0a24a256d6a1b30bf237fc8bd749db3 (diff)
parentbde8aabad7e5745b4797e73b564e4efb19faeca9 (diff)
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web into treeview
Diffstat (limited to 'src/fields/WebField.ts')
-rw-r--r--src/fields/WebField.ts30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/fields/WebField.ts b/src/fields/WebField.ts
new file mode 100644
index 000000000..8f945d686
--- /dev/null
+++ b/src/fields/WebField.ts
@@ -0,0 +1,30 @@
+import { BasicField } from "./BasicField";
+import { Field, FieldId } from "./Field";
+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);
+ }
+
+ toString(): string {
+ return this.Data.href;
+ }
+
+ ToScriptString(): string {
+ return `new WebField("${this.Data}")`;
+ }
+
+ Copy(): Field {
+ return new WebField(this.Data);
+ }
+
+ ToJson(): { type: Types, data: URL, _id: string } {
+ return {
+ type: Types.Web,
+ data: this.Data,
+ _id: this.Id
+ }
+ }
+
+} \ No newline at end of file