CMgr.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * DON'T REMOVE THE FOLLOWING LICENSE
  3. * INFORMATION!
  4. * ----------------------------------
  5. * Copyright by
  6. * Dennis Ritz
  7. * Author: Dennis Ritz
  8. * dennis.ritz@gmx.net
  9. * 2007-2008
  10. * ----------------------------------
  11. */
  12. function CMgr() {
  13. this.auth = null;
  14. this.model = null;
  15. this.__construct = function __construct() {
  16. CMgr.components = new Array();
  17. }
  18. this.start = function start(p_comp,p_callStack) {
  19. var cbObj = new Object();
  20. cbObj.callback = CMgr.startCb;
  21. cbObj.calldata = new Object();
  22. cbObj.calldata.comp = p_comp;
  23. if(typeof p_callStack == "object") {
  24. cbObj.calldata.callStack = p_callStack;
  25. } else {
  26. cbObj.calldata.callStack = "";
  27. }
  28. Ajax.request(p_comp,"__init",cbObj);
  29. }
  30. this.startCb = function startCb(p_cb,p_calldata) {
  31. if(p_cb instanceof Object) {
  32. var newStyle = Browser.createElement("style",p_calldata.comp+"Style");
  33. newStyle.type = "text/css";
  34. newStyle.media = "all";
  35. if(newStyle.styleSheet) {
  36. newStyle.styleSheet.cssText = p_cb[1];
  37. }else{
  38. var newStyleText = Browser.createTextNode(p_cb[1]);
  39. newStyle.appendChild(newStyleText);
  40. }
  41. Browser.getElementsByTagName("head")[0].appendChild(newStyle);
  42. Browser.setScript('text/javascript',p_calldata.comp, p_cb[0]);
  43. eval(p_cb[2]);
  44. }
  45. if(typeof p_calldata.callStack == "object") {
  46. var argsStr = p_calldata.callStack.args.join('","');
  47. if(argsStr != "") argsStr = ',"'+argsStr+'"';
  48. eval('Ajax.request(p_calldata.callStack.comp,p_calldata.callStack.method'+argsStr+',p_calldata.callStack.cbObject)');
  49. }
  50. }
  51. this.callComp = function callComp(p_comp,p_execute) {
  52. if(!CMgr.isCompStarted(p_comp)) {
  53. CMgr.start(p_comp,p_execute);
  54. } else {
  55. eval(p_comp+'.'+p_execute);
  56. }
  57. }
  58. this.isCompStarted = function isCompStarted(p_comp) {
  59. if(Browser.getElementById(p_comp+"ODS")) {
  60. return true;
  61. }else{
  62. return false;
  63. }
  64. }
  65. this.evalCb = function evalCb(p_cb) {
  66. for(var i in p_cb) {
  67. eval(p_cb[i]);
  68. }
  69. }
  70. this.setMODEL = function setMODEL(p_comp) {
  71. this.model = p_comp;
  72. this.model.__construct();
  73. }
  74. this.getMODEL = function getMODEL() {
  75. return this.model;
  76. }
  77. this.setAUTH = function setAUTH(p_comp) {
  78. this.auth = p_comp;
  79. this.auth.__construct();
  80. }
  81. this.getAUTH = function getAUTH() {
  82. return this.auth;
  83. }
  84. }
  85. var CMgr = new CMgr();
  86. CMgr.__construct();