Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

webclient.js 6.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /* JS helpers for the Flash RDP Web Control.
  2. *
  3. * Methods started with '_' are for internal use and must not be called.
  4. * Methods started with '_control' are called from the SWF.
  5. */
  6. var RDPWebClient = {
  7. RDPWebUUID: "747f07ac-c30b-4439-826d-7b5c67fd47e7",
  8. embedSWF: function (FlashFileName, FlashId)
  9. {
  10. /* Create the Flash object. */
  11. var flashvars = {};
  12. flashvars.flashId = FlashId;
  13. var params = {};
  14. params.wmode="opaque";
  15. params.menu="false";
  16. params.bgcolor="#ffffff";
  17. params.quality="low";
  18. params.allowScriptAccess="always";
  19. var attributes = {};
  20. /* Make sure that the SWF will be reloaded from the server, not from browser cache. */
  21. var stamp = new Date();
  22. var seed = "?s=" + stamp.getTime();
  23. swfobject.embedSWF(FlashFileName + seed, FlashId, "100%", "100%", "9.0.0",
  24. "", flashvars, params, attributes);
  25. },
  26. isRDPWebControlById: function(Id)
  27. {
  28. var flash = RDPWebClient.getFlashById(Id);
  29. return RDPWebClient.isRDPWebControlByElement(flash);
  30. },
  31. isRDPWebControlByElement: function(element)
  32. {
  33. if (element && element.getProperty)
  34. {
  35. var uuid = element.getProperty("UUID");
  36. if (uuid == RDPWebClient.RDPWebUUID)
  37. {
  38. return true;
  39. }
  40. }
  41. return false;
  42. },
  43. _controlInit: function (FlashId)
  44. {
  45. var flash = RDPWebClient.getFlashById(FlashId);
  46. if (flash)
  47. {
  48. if (window.addEventListener)
  49. {
  50. /* Mozilla */
  51. window.addEventListener("contextmenu", function(event) { return RDPWebClient._MozillaContextMenu(event); }, true);
  52. window.addEventListener("mousedown", function(event) { return RDPWebClient._MozillaMouse(event, true); }, true);
  53. window.addEventListener("mouseup", function(event) { return RDPWebClient._MozillaMouse(event, false); }, true);
  54. flash.addEventListener("mouseout", function(event) { return RDPWebClient._MozillaMouseOut(event); }, true);
  55. }
  56. else
  57. {
  58. document.oncontextmenu = function() { return RDPWebClient._IEContextMenu(); }
  59. flash.parentNode.onmousedown = function() { return RDPWebClient._IEMouse(true); }
  60. flash.parentNode.onmouseup = function() { return RDPWebClient._IEMouse(false); }
  61. flash.onmouseout=function() {return RDPWebClient._IEMouseOut(); }
  62. }
  63. }
  64. },
  65. _controlResize: function(flashId, width, height, reason)
  66. {
  67. var e = document.getElementById(flashId + 'Container');
  68. if (e)
  69. {
  70. e.style.width=width + "px";
  71. e.style.height=height + "px";
  72. }
  73. },
  74. _IEMouseOut: function()
  75. {
  76. if (window.event && RDPWebClient.isRDPWebControlById(window.event.srcElement.id))
  77. {
  78. RDPWebClient._callMouseOut(window.event.srcElement.id);
  79. }
  80. return true;
  81. },
  82. _IECancelEvent: function()
  83. {
  84. window.event.returnValue = false;
  85. window.event.cancelBubble = true;
  86. return false;
  87. },
  88. _IEContextMenu: function()
  89. {
  90. if (window.event && RDPWebClient.isRDPWebControlById(window.event.srcElement.id))
  91. {
  92. return RDPWebClient._IECancelEvent();
  93. }
  94. },
  95. _IEMouse: function(fMouseDown)
  96. {
  97. if (window.event && RDPWebClient.isRDPWebControlById(window.event.srcElement.id))
  98. {
  99. if (window.event.button == 2)
  100. {
  101. if (fMouseDown == true)
  102. {
  103. RDPWebClient.getFlashById(window.event.srcElement.id).parentNode.setCapture();
  104. RDPWebClient._callRightMouseDown(window.event.srcElement.id);
  105. }
  106. else
  107. {
  108. RDPWebClient._callRightMouseUp(window.event.srcElement.id);
  109. RDPWebClient.getFlashById(window.event.srcElement.id).parentNode.releaseCapture();
  110. }
  111. return RDPWebClient._IECancelEvent();
  112. }
  113. }
  114. },
  115. _MozillaMouseOut: function(event)
  116. {
  117. if (RDPWebClient.isRDPWebControlById(event.target.id))
  118. {
  119. RDPWebClient._callMouseOut(event.target.id);
  120. }
  121. return true;
  122. },
  123. _MozillaCancelEvent: function(event)
  124. {
  125. if (event)
  126. {
  127. if (event.preventBubble) event.preventBubble();
  128. if (event.preventCapture) event.preventCapture();
  129. if (event.preventDefault) event.preventDefault();
  130. if (event.stopPropagation) event.stopPropagation();
  131. }
  132. },
  133. _MozillaContextMenu: function(event)
  134. {
  135. if (RDPWebClient.isRDPWebControlById(event.target.id))
  136. {
  137. RDPWebClient._MozillaCancelEvent(event);
  138. }
  139. },
  140. _MozillaMouse: function(event, fMouseDown)
  141. {
  142. if (RDPWebClient.isRDPWebControlById(event.target.id))
  143. {
  144. if (event.button == 2)
  145. {
  146. if (fMouseDown)
  147. {
  148. RDPWebClient._callRightMouseDown(event.target.id);
  149. }
  150. else
  151. {
  152. RDPWebClient._callRightMouseUp(event.target.id);
  153. }
  154. RDPWebClient._MozillaCancelEvent(event);
  155. }
  156. }
  157. },
  158. _callRightMouseDown: function(FlashId)
  159. {
  160. var flash = RDPWebClient.getFlashById(FlashId);
  161. if (flash && flash.rightMouseDown)
  162. {
  163. try
  164. {
  165. flash.rightMouseDown();
  166. }
  167. catch (e) {}; /* Hack for IE, which calls the Flash method but then throws the exception. */
  168. }
  169. },
  170. _callRightMouseUp: function(FlashId)
  171. {
  172. var flash = RDPWebClient.getFlashById(FlashId);
  173. if (flash && flash.rightMouseUp)
  174. {
  175. try
  176. {
  177. flash.rightMouseUp();
  178. }
  179. catch (e) {}; /* Hack for IE, which calls the Flash method but then throws the exception. */
  180. }
  181. },
  182. _callMouseOut: function(FlashId)
  183. {
  184. var flash = RDPWebClient.getFlashById(FlashId);
  185. if (flash && flash.mouseOut)
  186. {
  187. try
  188. {
  189. flash.mouseOut();
  190. }
  191. catch (e) {}; /* Hack for IE, which calls the Flash method but then throws the exception. */
  192. }
  193. },
  194. getFlashById: function(flashId)
  195. {
  196. if (document.embeds && document.embeds[flashId])
  197. return document.embeds[flashId];
  198. return document.getElementById(flashId);
  199. }
  200. }