variableList.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. var variableList={};
  2. variableList.parseVariables=
  3. function(pars){
  4. let pA=pars.split(";");
  5. let q=new Object();
  6. for (let i=0;i<pA.length;i++){
  7. let vA=pA[i].split('=');
  8. q[vA[0]]=vA[vA.length-1];
  9. }
  10. return q;
  11. }
  12. variableList.printVariables=
  13. function(parentClass,q){
  14. let fName="[printVariables]";
  15. for (let x in q){
  16. parentClass.print(fName+" ["+x+"] "+q[x]);
  17. }
  18. }
  19. variableList.hasVariable=
  20. function(q,varName){
  21. if (q && varName in q)
  22. return true;
  23. return false;
  24. }
  25. variableList.isFilterList=
  26. function(v){
  27. if (typeof(v)!='string') return false;
  28. if (v.search(';')==-1) return false;
  29. return true;
  30. }
  31. variableList.convertToDictionary=
  32. function(rows){
  33. let x=new Array();
  34. for (let i=0;i<rows.length;i++){
  35. let n=rows[i]['name'];
  36. let v=rows[i]['value'];
  37. x[n]=v;
  38. }
  39. return x;
  40. }
  41. variableList.convertToAssociatedArray=
  42. function(rows,fieldName="name"){
  43. let x=new Object();
  44. for (let i=0;i<rows.length;i++){
  45. let n=rows[i][fieldName];
  46. x[n]=rows[i];
  47. }
  48. return x;
  49. }