/**
* This library is intended to simplify client mechanics writing.
*
* It will encompass many little developement tricks such as text list management, ...
**/

/*
* adds a value to a comma separated list, ensuring value is unique. The list is the value content of the 
* provided text. The function returns the modified list. The list does not care about value ordering.
*/
function addToList(textlist, value)
{
   re = new RegExp("\b" + value + "\b");
   if (!textlist.match(re))
   {
      textlist += "," + value;
   }
   textlist = textlist.replace(/^,|,$/, "");
   self.status = textlist;
   return textlist;
}

function delFromList(textlist, value)
{
   re = new RegExp("\\b" + value + "\\b");
   textlist = textlist.replace(re, "");
   textlist = textlist.replace(/,,/g, ",");
   textlist = textlist.replace(/^,|,$/, "");
   self.status = textlist;
   return textlist;
}