From b387e22c1690dd3ff9e3601083867bd055758690 Mon Sep 17 00:00:00 2001 From: Lewis Hemens Date: Wed, 8 Jan 2014 21:58:41 +0000 Subject: [PATCH] Added missing state class, and updated readme --- README | 18 ++++++++++++++++++ js-lib/state.js | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 README create mode 100644 js-lib/state.js diff --git a/README b/README new file mode 100644 index 0000000..5d5ec91 --- /dev/null +++ b/README @@ -0,0 +1,18 @@ +Follow the following to get asciiflow running locally. + +Clone closure-library at the same level as asciiflow2: + +$git clone https://code.google.com/p/closure-library/ + +Update compile.sh script if neccessary and run it: +$./compile.sh + +This may require chmod a+x on some files. + +Run a simple web server: +$python -m SimpleHttpServer + +Goto localhost:8000/root.html + + + diff --git a/js-lib/state.js b/js-lib/state.js new file mode 100644 index 0000000..f50d98d --- /dev/null +++ b/js-lib/state.js @@ -0,0 +1,41 @@ +/** + * Classes holding the state of the ascii-diagram. + */ +goog.provide('asciiflow.State'); + +/** + * @constructor + */ +asciiflow.Cell = function() { + /** @type {string|null} */ // Uses the string "#" for lines. + this.value = null; +}; + +asciiflow.Cell.prototype.setValue = function(value) { + this.value = value; +}; + +/** + * @constructor + */ +asciiflow.State = function() { + /** @type {Array.>} */ + this.cells = new Array(asciiflow.State.MAX_SIZE); + + for (var i = 0; i < this.cells.length; i++) { + this.cells[i] = new Array(asciiflow.State.MAX_SIZE); + for (var j = 0; j < this.cells[i].length; j++) { + this.cells[i][j] = new asciiflow.Cell(); + // Hack: Just fill image with random stuff for now. + if ((i % 10 == 0) && (j % 10 == 0)) { + var jstr = ("" + j); + this.cells[i][j].setValue(jstr.substring(jstr.length-1,jstr.length)); + } + } + } +}; + +/** @const */ asciiflow.State.MAX_SIZE = 1000; + +asciiflow.State.prototype.blah = function() { +};