summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLV-426 <lv-426@taproot.org.il>2014-11-19 03:20:36 +0200
committerLV-426 <lv-426@taproot.org.il>2014-11-19 03:20:36 +0200
commit917e4416ccfa65d4a6b92f98821d5a5c8b341054 (patch)
treeb2e36112edb7dc6f4deb81dd4edf778eb6ca34d2 /src
parent85b5b2d1a36ea61a38e3b47267eeb60537976e4d (diff)
add rz_config, provide id generation scheme control: hash/seq, defaulting to seq
Diffstat (limited to 'src')
-rw-r--r--src/main.js8
-rw-r--r--src/model/core.js28
-rw-r--r--src/rz_config.js6
3 files changed, 36 insertions, 6 deletions
diff --git a/src/main.js b/src/main.js
index 67213056..a401c1b2 100644
--- a/src/main.js
+++ b/src/main.js
@@ -1,5 +1,5 @@
-define(['textanalysis.ui', 'buttons', 'history', 'drag_n_drop', 'robot'],
-function(textanalysis_ui, buttons, history, drag_n_drop, robot) {
+define(['textanalysis.ui', 'buttons', 'history', 'drag_n_drop', 'robot', 'model/core', 'rz_config'],
+function(textanalysis_ui, buttons, history, drag_n_drop, robot, model_core, rz_config) {
function expand(obj){
if (!obj.savesize) {
@@ -16,8 +16,10 @@ function(textanalysis_ui, buttons, history, drag_n_drop, robot) {
$('#textanalyser').onkeyup = function() { expand(this); };
textanalysis_ui.main();
+
+ model_core.init(rz_config);
}
-
+
return {
main: main };
}
diff --git a/src/model/core.js b/src/model/core.js
index ce75e41c..03d5db7b 100644
--- a/src/model/core.js
+++ b/src/model/core.js
@@ -8,12 +8,33 @@ define([], function() {
/**
* return a random id
*/
- var random_id = function() {
- return Math.random().toString(36).substring(2);
+ var random_id;
+
+ var random_id__hash = function() {
+ return Math.random().toString(36).substring(2, 10);
+ }
+
+ var random_id__seq = function () {
+ var id = 0;
+ function get_next() {
+ var next = id;
+ id += 1;
+ return next;
+ }
+ return get_next;
}
function random_node_name() {
- return Math.random().toString(36).substring(2, 10);
+ return random_id__hash();
+ }
+
+ function init(config){
+ if (config['rand_id_generator'] == 'hash') {
+ random_id = random_id__hash;
+ }
+ if (config['rand_id_generator'] == 'seq') {
+ random_id = random_id__seq();
+ }
}
function Node() {
@@ -141,6 +162,7 @@ define([], function() {
}
return {
+ init : init,
random_node_name : random_node_name,
crete_node_from_spec : crete_node_from_spec,
crete_link_from_spec : crete_link_from_spec,
diff --git a/src/rz_config.js b/src/rz_config.js
new file mode 100644
index 00000000..6093573a
--- /dev/null
+++ b/src/rz_config.js
@@ -0,0 +1,6 @@
+define(function() {
+
+ return {
+ 'rand_id_generator' : 'hash',
+ };
+});