diff options
author | matthewsotoudeh <matthewsot@outlook.com> | 2015-08-21 19:35:49 -0700 |
---|---|---|
committer | matthewsotoudeh <matthewsot@outlook.com> | 2015-08-21 19:35:49 -0700 |
commit | 96a473e779d20def7760e0063ebea37e20a386b9 (patch) | |
tree | 3d1409e2b03a88b5af4791dc98c559e5289cca10 | |
parent | d4229b0923b98bf079c47eeb2e84a5e3f2223235 (diff) |
starting on a basic presentation layer
-rw-r--r-- | dist/presentation.js | 2 | ||||
-rw-r--r-- | dist/text.js (renamed from dist/ecrit.js) | 82 | ||||
-rw-r--r-- | gulpfile.js | 22 | ||||
-rw-r--r-- | package.json | 3 | ||||
-rw-r--r-- | src/ecrit.js | 2 | ||||
-rw-r--r-- | src/presentation/demo.html | 13 | ||||
-rw-r--r-- | src/presentation/test.jsx | 2 | ||||
-rw-r--r-- | src/text/NodeHistory.js (renamed from src/NodeHistory.js) | 0 | ||||
-rw-r--r-- | temp/presentation/test.js | 1 |
9 files changed, 81 insertions, 46 deletions
diff --git a/dist/presentation.js b/dist/presentation.js new file mode 100644 index 0000000..8a35685 --- /dev/null +++ b/dist/presentation.js @@ -0,0 +1,2 @@ +var ecrit = ecrit || {}; +alert("hi");
\ No newline at end of file diff --git a/dist/ecrit.js b/dist/text.js index 89e66f7..83d52f6 100644 --- a/dist/ecrit.js +++ b/dist/text.js @@ -1,44 +1,4 @@ -var ecrit = {}; -ecrit.NodeHistory = function () { - this._push = this.push; - this.push = function (element) { - this._push(element); - this.sort(function (a, b) { - return a.timestamp - b.timestamp; - }); - }; -}; - -ecrit.NodeHistory.prototype = Object.create(Array.prototype); - -ecrit.NodeHistory.prototype.withTimestamp = function (stamp) { - for (var i = 0; i < this.length; i++) { - if (this[i].timestamp === stamp) { - return this[i]; - } - } - return null; -}; - -ecrit.NodeHistory.prototype.afterTimestamp = function (stamp) { - var ret = []; - for (var i = 0; i < this.length; i++) { - if (this[i].timestamp > stamp) { - ret.push(this[i]); - } - } - return ret; -}; - -ecrit.NodeHistory.prototype.betweenTimestamps = function (afterStamp, beforeStamp) { - var ret = []; - for (var i = 0; i < this.length; i++) { - if (this[i].timestamp > afterStamp && this[i].timestamp < beforeStamp) { - ret.push(this[i]); - } - } - return ret; -}; +var ecrit = ecrit || {}; ecrit.Node = function (parent, id, nodes) { this.parent = parent; this.id = id; @@ -157,6 +117,46 @@ ecrit.Node.prototype.removeNode = function (node) { this._emit("childRemoved", foundNode); }; +ecrit.NodeHistory = function () { + this._push = this.push; + this.push = function (element) { + this._push(element); + this.sort(function (a, b) { + return a.timestamp - b.timestamp; + }); + }; +}; + +ecrit.NodeHistory.prototype = Object.create(Array.prototype); + +ecrit.NodeHistory.prototype.withTimestamp = function (stamp) { + for (var i = 0; i < this.length; i++) { + if (this[i].timestamp === stamp) { + return this[i]; + } + } + return null; +}; + +ecrit.NodeHistory.prototype.afterTimestamp = function (stamp) { + var ret = []; + for (var i = 0; i < this.length; i++) { + if (this[i].timestamp > stamp) { + ret.push(this[i]); + } + } + return ret; +}; + +ecrit.NodeHistory.prototype.betweenTimestamps = function (afterStamp, beforeStamp) { + var ret = []; + for (var i = 0; i < this.length; i++) { + if (this[i].timestamp > afterStamp && this[i].timestamp < beforeStamp) { + ret.push(this[i]); + } + } + return ret; +}; /** * Represents an ecrit Document. * @constructor diff --git a/gulpfile.js b/gulpfile.js index c538271..a8916c9 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,15 +1,31 @@ var gulp = require("gulp"); +var react = require('gulp-react'); var concat = require("gulp-concat"); var vm = require("vm"); var fs = require("fs"); -gulp.task('default', function () { - return gulp.src(["./src/**/*.js" ]) - .pipe(concat('ecrit.js')) +gulp.task('text', function () { + return gulp.src(["./src/ecrit.js", "./src/text/**/*.js" ]) + .pipe(concat('text.js')) .pipe(gulp.dest('./dist/')); }); +gulp.task('presentation-jsx', function () { + return gulp.src("./src/presentation/**/*.jsx").pipe(react()).pipe(gulp.dest('./temp/presentation/')); +}); + +gulp.task('presentation', function () { + gulp.start("presentation-jsx"); + + return gulp.src(["./src/ecrit.js", "./src/presentation/**/*.js", "./temp/presentation/**/*.js"]) + .pipe(concat('presentation.js')) + .pipe(gulp.dest('./dist/')); +}); + +gulp.task('default', ["text", "presentation"]); +gulp.task('build', ["text", "presentation"]); + function assert(val, err) { if (!val) { console.log("FAILED: " + err); diff --git a/package.json b/package.json index 43a047f..065d78d 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "0.0.1", "devDependencies": { "gulp": "^3.9.0", - "gulp-concat": "^2.6.0" + "gulp-concat": "^2.6.0", + "gulp-react": "^3.0.1" } } diff --git a/src/ecrit.js b/src/ecrit.js index 59aefd5..b66c465 100644 --- a/src/ecrit.js +++ b/src/ecrit.js @@ -1 +1 @@ -var ecrit = {};
\ No newline at end of file +var ecrit = ecrit || {};
\ No newline at end of file diff --git a/src/presentation/demo.html b/src/presentation/demo.html new file mode 100644 index 0000000..4efbc05 --- /dev/null +++ b/src/presentation/demo.html @@ -0,0 +1,13 @@ +<!DOCTYPE html> +<html> + <head> + <title>Ecrit Demo</title> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/react.min.js"></script> + <script type="text/javascript" src="../../dist/text.js"></script> + </head> + <body> + <script> + + </script> + </body> +</html>
\ No newline at end of file diff --git a/src/presentation/test.jsx b/src/presentation/test.jsx new file mode 100644 index 0000000..100cd48 --- /dev/null +++ b/src/presentation/test.jsx @@ -0,0 +1,2 @@ +alert("hi"); + diff --git a/src/NodeHistory.js b/src/text/NodeHistory.js index 0366c9f..0366c9f 100644 --- a/src/NodeHistory.js +++ b/src/text/NodeHistory.js diff --git a/temp/presentation/test.js b/temp/presentation/test.js new file mode 100644 index 0000000..9528bf0 --- /dev/null +++ b/temp/presentation/test.js @@ -0,0 +1 @@ +alert("hi");
\ No newline at end of file |