summaryrefslogtreecommitdiff
path: root/scripts/model/core.js
diff options
context:
space:
mode:
authorLV-426 <lv-426@taproot.org.il>2014-11-13 17:06:47 +0200
committerLV-426 <lv-426@taproot.org.il>2014-11-13 17:11:56 +0200
commit22c032f9bf222de58c3923f769d67c4274034871 (patch)
tree757f0cda5cf3bddc481de8ca531f1209488826d1 /scripts/model/core.js
parent542be75b7f71378146c522c1e681160a4b4f3564 (diff)
rename model/model -> model/core
Diffstat (limited to 'scripts/model/core.js')
-rw-r--r--scripts/model/core.js71
1 files changed, 71 insertions, 0 deletions
diff --git a/scripts/model/core.js b/scripts/model/core.js
new file mode 100644
index 00000000..39b5f0be
--- /dev/null
+++ b/scripts/model/core.js
@@ -0,0 +1,71 @@
+"use strict"
+
+/**
+ * core model module - currently unused
+ */
+define([], function() {
+
+ /**
+ * return a random id
+ */
+ var random_id = function() {
+ return Math.random().toString(36).substring(2);
+ }
+
+ function Node() {
+ }
+
+ this.create_node_with_random_id = function(node_spec) {
+ var ret = new Node();
+ ret.id = random_id();
+
+ ret.name = spec.name;
+ ret.type = spec.type;
+ ret.state = spec.state;
+ ret.status = spec.status;
+ ret.url = spec.url;
+
+ ret.start = spec.start;
+ ret.end = spec.end;
+
+ return ret;
+ }
+
+ this.create_link_with_random_id = function(link_spec) {
+ var ret = new Link();
+ ret.id = random_id();
+ }
+
+ /**
+ * determine if nodes are equal by ID
+ *
+ * @param other_node
+ * @returns {Boolean}
+ */
+ Node.prototype.equlas_by_id = function(other) {
+ ret = this.id.toLowerCase() == other.id.toLowerCase();
+ if (false == ret) {
+ console.debug(this.id + ' != ' + other.id);
+ }
+ return ret;
+ }
+
+ function Link() {
+
+ }
+
+ /**
+ * determine if links are equal by ID
+ *
+ * @param other_node
+ * @returns {Boolean}
+ */
+ Link.prototype.equlas_by_id = function(other) {
+ return this.id.toLowerCase() == other.id.toLowerCase();
+ }
+
+ return {
+ create_node_with_random_id : create_node_with_random_id,
+ create_link_with_random_id : create_link_with_random_id,
+ };
+});