wdDialogInit.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. var addEvent = (function () {
  2. if (document.addEventListener) {
  3. return function (el, type, fn) {
  4. if (el.length) {
  5. for (var i = 0; i < el.length; i++) {
  6. addEvent(el[i], type, fn);
  7. }
  8. } else {
  9. el.addEventListener(type, fn, false);
  10. }
  11. };
  12. } else {
  13. return function (el, type, fn) {
  14. if (el.length) {
  15. for (var i = 0; i < el.length; i++) {
  16. addEvent(el[i], type, fn);
  17. }
  18. } else {
  19. el.attachEvent('on' + type, function () {
  20. return fn.call(el, window.event);
  21. });
  22. }
  23. };
  24. }
  25. })();
  26. var dhxWins;
  27. addEvent(window, 'load', function () {
  28. if (!dhxWins && !window.dhtmlXWindows) return
  29. if (!dhxWins)
  30. dhxWins = new dhtmlXWindows();
  31. /* 改。Lin
  32. dhxWins.setImagePath('/wd/theme/window/dhx_blue/image/active/');
  33. */ dhxWins.setImagePath('/ss/window/theme/dhx_blue/image/active/');
  34. dhxWins.enableAutoViewport(true);
  35. dhxWins.attachEvent("onContentLoaded", function (winEle) {
  36. if (winEle.checkEvent("onContentLoaded")) {
  37. winEle.callEvent("onContentLoaded", winEle.getFrame());
  38. }
  39. })
  40. });
  41. try {
  42. if (!wd.topWindow.clearToken) {
  43. wd.topWindow.clearToken = function (removeUrl, param) {
  44. var formObject = new FormData();
  45. Object.keys(param).forEach(function (key) {
  46. var value = param[key];
  47. if (typeof value != 'string') {
  48. value = JSON.stringify(value);
  49. }
  50. formObject.append(key, value);
  51. });
  52. wd.topWindow.navigator.sendBeacon(removeUrl, formObject);
  53. }
  54. }
  55. } catch (e) {
  56. console.log(e);
  57. }
  58. function params(data) {
  59. var arr = [];
  60. Object.keys(data).forEach(function (key) {
  61. var value = data[key];
  62. arr.push(key + "=" + encodeURIComponent(value));
  63. })
  64. return arr.join("&");
  65. }
  66. function getXmlHttpRequest() {
  67. var xmlHttpRequest = null;
  68. if ((typeof XMLHttpRequest) != 'undefined') {
  69. xmlHttpRequest = new XMLHttpRequest();
  70. } else {
  71. xmlHttpRequest = new ActiveXObject('Microsoft.XMLHttp');
  72. }
  73. return xmlHttpRequest;
  74. }
  75. //缓存其他需要清除的token
  76. var removeTokenString = window.removeTokenString || "";
  77. function addRemoveToken(param) {
  78. if (typeof (param) == "string") {
  79. removeTokenString += "," + param;
  80. } else if (typeof (param) == "object") {
  81. removeTokenString += "," + removeTokenList.join(",");
  82. }
  83. }
  84. function tokenCleanser(removeUrl, param) {
  85. if (window.location.href.indexOf("view.jsp") > 0) return;
  86. addRemoveToken(param.tokenList)
  87. var exitMethod = window.onunload;
  88. window.onunload = (function () {
  89. return function () {
  90. if (exitMethod) exitMethod();
  91. if (removeTokenString) {
  92. wd.topWindow.clearToken(removeUrl, {
  93. tokenList: removeTokenString
  94. });
  95. removeTokenString = "";
  96. }
  97. }
  98. })()
  99. }