summaryrefslogtreecommitdiff
path: root/src/model/core.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/model/core.js')
-rw-r--r--src/model/core.js28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/model/core.js b/src/model/core.js
index 6111954b..aff222f6 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() {
@@ -144,6 +165,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,