commit:444d96e78330e26617ee486ce001c1ed7b15d369
author:Chip Black
committer:Chip Black
date:Sat Nov 10 16:03:04 2018 -0600
parents:6b7a702a1e940f950080f0a34d14a61c9f02edd5
Ignore built parser.ts
diff --git a/.gitignore b/.gitignore
line changes: +1/-0
index de4d1f0..d4f5a88
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
 dist
 node_modules
+src/script/parser.ts

diff --git a/src/celleditor.ts b/src/celleditor.ts
line changes: +127/-0
index 0000000..a53152a
--- /dev/null
+++ b/src/celleditor.ts
@@ -0,0 +1,127 @@
+import { Cell } from './cell';
+import { GameEvent, GameEventType } from './event';
+import FragmentManager from './fragmentmanager';
+
+export type EditorCallback = (cell: Cell) => void;
+
+export default class Editor {
+    container: HTMLDivElement
+    titleRef: HTMLInputElement
+    descriptionRef: HTMLTextAreaElement
+    events: FragmentManager[]
+    cell: Cell
+
+    onClose: (cell: Cell) => void
+
+    constructor() {
+        this.container = <HTMLDivElement>document.getElementById('editor-container');
+        this.container.addEventListener('keydown', function(e: KeyboardEvent) {
+            e.cancelBubble = true;
+        });
+
+        this.titleRef = this.container.querySelector('[name=title]');
+        this.descriptionRef = this.container.querySelector('[name=description]');
+
+        const addEventButton = document.getElementById('add-event');
+        addEventButton.addEventListener('click', this.addEventHandler.bind(this));
+        this.events = []
+
+        const closeButton = document.getElementById('editor-close');
+        closeButton.addEventListener('click', this.closeHandler.bind(this));
+    }
+
+    open(cell: Cell) {
+        this.cell = cell;
+        this.titleRef.value = cell.title;
+        this.descriptionRef.value = cell.description;
+
+        for (let [k, e] of cell.events) {
+            this.addEvent(e);
+        }
+        this.container.classList.add('visible');
+        this.titleRef.focus();
+    }
+
+    addEventHandler() {
+        this.addEvent();
+    }
+
+    addEvent(event?: GameEvent) {
+        const eventForm = new FragmentManager(`
+            <h3>ID</h3>
+            <input name="id">
+            <h3>Type</h3>
+            <select name="type">
+                <option value="0">Enter</option>
+                <option value="1">Leave</option>
+                <option value="2">Random</option>
+                <option value="3">Action</option>
+            </select>
+            <h3>Title</h3>
+            <input name="title">
+            <h3>Script</h3>
+            <textarea name="script"></textarea>
+            <div>
+                <button name="delete">Delete Event</button>
+            </div>
+        `, 'div', { className: 'vflex' });
+        eventForm.mount('event-list');
+        this.events.push(eventForm);
+
+        const deleteButton = eventForm.q('[name=delete]');
+        deleteButton.addEventListener('click', () => {
+            eventForm.unmount();
+            const i = this.events.indexOf(eventForm);
+            this.events.splice(i, 1);
+        });
+
+        if (!event) {
+            event = new GameEvent();
+        }
+        (<HTMLInputElement>eventForm.q('[name=id]'))
+            .value = event.id;
+        (<HTMLSelectElement>eventForm.q('[name=type]'))
+            .value = event.type.toString();
+        (<HTMLInputElement>eventForm.q('[name=title]'))
+            .value = event.title;
+        (<HTMLTextAreaElement>eventForm.q('[name=script]'))
+            .value = event.script;
+    }
+
+    close() {
+        this.closeHandler();
+    }
+
+    closeHandler() {
+        this.cell.title = this.titleRef.value;
+        this.cell.description = this.descriptionRef.value;
+
+        // We recreate all of the cell's events to make sure we remove any deleted ones
+        this.cell.events.clear();
+        for (let eventForm of this.events) {
+            const id = (<HTMLInputElement>eventForm.q('[name=id]')).value;
+            const type = <GameEventType>parseInt((<HTMLInputElement>eventForm.q('[name=type]')).value);
+            const title = (<HTMLInputElement>eventForm.q('[name=title]')).value;
+            const script = (<HTMLInputElement>eventForm.q('[name=script]')).value;
+
+            const e = new GameEvent();
+
+            e.id = id;
+            e.type = type;
+            e.title = title;
+            e.script = script;
+
+            this.cell.events.set(id, e);
+        }
+
+        for (let ev of this.events)
+            ev.unmount();
+        this.events = [];
+
+        if (this.onClose) {
+            this.onClose(this.cell);
+            this.onClose = null;
+        }
+        this.container.classList.remove('visible');
+    }
+}

diff --git a/src/editor.ts b/src/editor.ts
line changes: +0/-127
index a53152a..0000000
--- a/src/editor.ts
+++ /dev/null
@@ -1,127 +0,0 @@
-import { Cell } from './cell';
-import { GameEvent, GameEventType } from './event';
-import FragmentManager from './fragmentmanager';
-
-export type EditorCallback = (cell: Cell) => void;
-
-export default class Editor {
-    container: HTMLDivElement
-    titleRef: HTMLInputElement
-    descriptionRef: HTMLTextAreaElement
-    events: FragmentManager[]
-    cell: Cell
-
-    onClose: (cell: Cell) => void
-
-    constructor() {
-        this.container = <HTMLDivElement>document.getElementById('editor-container');
-        this.container.addEventListener('keydown', function(e: KeyboardEvent) {
-            e.cancelBubble = true;
-        });
-
-        this.titleRef = this.container.querySelector('[name=title]');
-        this.descriptionRef = this.container.querySelector('[name=description]');
-
-        const addEventButton = document.getElementById('add-event');
-        addEventButton.addEventListener('click', this.addEventHandler.bind(this));
-        this.events = []
-
-        const closeButton = document.getElementById('editor-close');
-        closeButton.addEventListener('click', this.closeHandler.bind(this));
-    }
-
-    open(cell: Cell) {
-        this.cell = cell;
-        this.titleRef.value = cell.title;
-        this.descriptionRef.value = cell.description;
-
-        for (let [k, e] of cell.events) {
-            this.addEvent(e);
-        }
-        this.container.classList.add('visible');
-        this.titleRef.focus();
-    }
-
-    addEventHandler() {
-        this.addEvent();
-    }
-
-    addEvent(event?: GameEvent) {
-        const eventForm = new FragmentManager(`
-            <h3>ID</h3>
-            <input name="id">
-            <h3>Type</h3>
-            <select name="type">
-                <option value="0">Enter</option>
-                <option value="1">Leave</option>
-                <option value="2">Random</option>
-                <option value="3">Action</option>
-            </select>
-            <h3>Title</h3>
-            <input name="title">
-            <h3>Script</h3>
-            <textarea name="script"></textarea>
-            <div>
-                <button name="delete">Delete Event</button>
-            </div>
-        `, 'div', { className: 'vflex' });
-        eventForm.mount('event-list');
-        this.events.push(eventForm);
-
-        const deleteButton = eventForm.q('[name=delete]');
-        deleteButton.addEventListener('click', () => {
-            eventForm.unmount();
-            const i = this.events.indexOf(eventForm);
-            this.events.splice(i, 1);
-        });
-
-        if (!event) {
-            event = new GameEvent();
-        }
-        (<HTMLInputElement>eventForm.q('[name=id]'))
-            .value = event.id;
-        (<HTMLSelectElement>eventForm.q('[name=type]'))
-            .value = event.type.toString();
-        (<HTMLInputElement>eventForm.q('[name=title]'))
-            .value = event.title;
-        (<HTMLTextAreaElement>eventForm.q('[name=script]'))
-            .value = event.script;
-    }
-
-    close() {
-        this.closeHandler();
-    }
-
-    closeHandler() {
-        this.cell.title = this.titleRef.value;
-        this.cell.description = this.descriptionRef.value;
-
-        // We recreate all of the cell's events to make sure we remove any deleted ones
-        this.cell.events.clear();
-        for (let eventForm of this.events) {
-            const id = (<HTMLInputElement>eventForm.q('[name=id]')).value;
-            const type = <GameEventType>parseInt((<HTMLInputElement>eventForm.q('[name=type]')).value);
-            const title = (<HTMLInputElement>eventForm.q('[name=title]')).value;
-            const script = (<HTMLInputElement>eventForm.q('[name=script]')).value;
-
-            const e = new GameEvent();
-
-            e.id = id;
-            e.type = type;
-            e.title = title;
-            e.script = script;
-
-            this.cell.events.set(id, e);
-        }
-
-        for (let ev of this.events)
-            ev.unmount();
-        this.events = [];
-
-        if (this.onClose) {
-            this.onClose(this.cell);
-            this.onClose = null;
-        }
-        this.container.classList.remove('visible');
-    }
-}