Global.buildAlias (alias, collection)
function gets a String passed as argument and constructs an object-alias which is unique in a collection

  • Parameter String:
    proposed alias for object
  • Parameter Obj:
    Destination collection
  • Returns
    String determined name
Sourcecode in Global/objectFunctions.js:
1:   function buildAlias(alias, collection) {
2:      // clean name from any invalid characters
3:      var newAlias = alias.toLowerCase().toFileName();
4:      if (newAlias.startsWith("."))
5:         newAlias = newAlias.substring(1);
6:      if (collection && collection.get(newAlias)) {
7:         // alias is already existing in collection, so we append a number
8:         var nr = 1;
9:         while (collection.get(newAlias + nr.toString()))
10:           nr++;
11:        return newAlias + nr.toString();
12:     } else
13:        return newAlias;
14:  }