You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

_m_utils.js 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. if (!window.glob_mx){
  2. // window.glob_mx={}
  3. }
  4. /*
  5. msto_qx = {
  6. local:{},
  7. conference:{},
  8. participant:{},
  9. }
  10. msto_qx = {
  11. private_local:{},
  12. participant_local:{},
  13. conference:{},
  14. participant:{
  15. '<id_0>':{},
  16. '<id_1>':{},
  17. '<id_...>':{},
  18. '<id_n>':{
  19. rkey:{},
  20. },
  21. },
  22. }
  23. */
  24. mhndlr_opt_null = {
  25. from: undefined,
  26. handler: "onAll",
  27. id: null,
  28. name: null,
  29. // "http://jitsi.org/jitmeet"
  30. ns: null,
  31. options: {matchBareFromJid: false, ignoreNamespaceFragment: false},
  32. type: null,
  33. user: true,
  34. cstr:"test"
  35. };
  36. // cstr:"onMsgx"
  37. mhndlr_opt_x = {
  38. cstr:"?",
  39. ns:"corner_mx",
  40. handler:mhndlr,
  41. }
  42. function rtrue(){
  43. // clog("rtrue...",this,arguments)
  44. // console.trace("rtrue")
  45. return true
  46. }
  47. function rtrue2(){
  48. clog("rtrue2...",this,arguments)
  49. // console.trace("rtrue2")
  50. return true
  51. }
  52. function rtrue3(){
  53. clog("rtrue3...",this,arguments)
  54. // console.trace("rtrue2")
  55. allevnt(...arguments)
  56. return true
  57. }
  58. mhndlr_opt_x_all = {
  59. cstr:"?",
  60. ns:"jabber:client",
  61. // name:"message",
  62. type:"groupchat",
  63. handler:allevnt,
  64. // isMatch:rtrue2,
  65. // run:rtrue3,
  66. // namespaceMatch:rtrue,
  67. }
  68. function add_handler_m(argument) {
  69. // minit()
  70. // if (!th.phx){
  71. // th.
  72. // }
  73. // var phx = APP.conference._room.room.connection.handlers[0].__proto__;
  74. var phx = APP.connection.xmpp.connection._stropheConn.handlers[0].__proto__;
  75. var hxa=Object.create(phx)
  76. Object.assign(hxa,mhndlr_opt_null,mhndlr_opt_x)
  77. // APP.conference._room.room.connection.handlers.push(hxa)
  78. APP.connection.xmpp.connection._stropheConn.addHandlers.push(hxa)
  79. // th.hxa=hxa
  80. // th.hx
  81. // body...
  82. }
  83. function add_handler_m2(argument) {
  84. clog("ADD HANDLER M2")
  85. // minit()
  86. // if (!th.phx){
  87. // th.
  88. // }
  89. // var phx = APP.conference._room.room.connection.handlers[0].__proto__;
  90. var phx = APP.connection.xmpp.connection._stropheConn.handlers[0].__proto__;
  91. var hxa=Object.create(phx)
  92. Object.assign(hxa,mhndlr_opt_null,mhndlr_opt_x_all)
  93. // APP.conference._room.room.connection.handlers.push(hxa)
  94. APP.connection.xmpp.connection._stropheConn.addHandlers.push(hxa)
  95. return hxa
  96. // th.hxa=hxa
  97. // th.hx
  98. // body...
  99. }
  100. function tmsgx(data,tag="div",attrs={}){
  101. // return
  102. var ns = {xmlns:"corner_mx"}
  103. var msg = $build("message",{ to: window.APP.conference._room.room.roomjid,
  104. type: 'groupchat',
  105. });
  106. var payload=JSON.stringify(data)
  107. Object.assign({},ns,attrs)
  108. msg.c(tag, payload,Object.assign({},ns,attrs)).up();
  109. console.log("zzzz")
  110. APP.conference._room.room.connection.send(msg)
  111. }
  112. function tmsgx2(data,opt_arg={},attrs={}){
  113. // return
  114. dflt_opt = {
  115. tag:"code",
  116. type:"chat",
  117. to:window.APP.conference._room.room.roomjid,
  118. }
  119. var opt = Object.assign({},dflt_opt,opt_arg)
  120. var ns = {xmlns:"corner_mx"}
  121. var msg = $build("message",{ to: opt.to,
  122. type: opt.type,
  123. });
  124. var payload=JSON.stringify(data)
  125. Object.assign({},ns,attrs)
  126. msg.c(opt.tag, payload,Object.assign({},ns,attrs)).up();
  127. console.log("zzzz")
  128. APP.conference._room.room.connection.send(msg)
  129. }
  130. function tmsgx3(data,opt_arg={},attrs={}){
  131. // return
  132. dflt_opt = {
  133. tag:"code",
  134. // type:"chat",
  135. to:window.APP.conference._room.room.roomjid,
  136. }
  137. var opt = Object.assign({},dflt_opt,opt_arg)
  138. clog("T:",data,opt,opt.type)
  139. if (!opt.type){
  140. clog("NO TYPE")
  141. opt.to == dflt_opt.to ? opt.type = "groupchat" : opt.type = "chat"
  142. }
  143. clog("T:",data,opt,opt.type)
  144. var ns = {xmlns:"corner_mx"}
  145. var msg = $build("message",{ to: opt.to,
  146. type: opt.type,
  147. // from: "nnnx@conference.jfidev.com/3db7bf15",
  148. // xtra: "nnnx@conference.jfidev.com/3db7bf15",
  149. });
  150. var payload=JSON.stringify(data)
  151. Object.assign({},ns,attrs)
  152. msg.c(opt.tag, payload,Object.assign({},ns,attrs)).up();
  153. console.log("zzzz")
  154. APP.conference._room.room.connection.send(msg)
  155. }
  156. function mhndlr_rld_dflt(a0,a1,a2,a3,a4){
  157. // clog("mhndlr....",a0,a1,a2)
  158. clog("mhndlr... dflt")
  159. // setTimeout(window.onAll_rld_v2,1,this,a0,a1,a2,a3,a4)
  160. return true
  161. }
  162. if (!window.mhndlr_rld){
  163. window.mhndlr_rld = mhndlr_rld_dflt
  164. }
  165. function mhndlr(a0,a1,a2,a3,a4){
  166. // clog("MH!")
  167. setTimeout(window.mhndlr_rld,1,this,a0,a1,a2,a3,a4)
  168. return true
  169. }
  170. function allevnt(a0,a1,a2,a3,a4){
  171. clog("MH! allevnt")
  172. setTimeout(window.allevnt_rld,1,this,a0,a1,a2,a3,a4)
  173. return true
  174. }
  175. function rld_room(room){
  176. clog("rld_room...",room)
  177. window.location.assign(room)
  178. }
  179. function allevnt_rld(a0,a1,a2,a3,a4){
  180. // clog("MH!")
  181. // clog("allevnt_rld",a0,a1,a2,a3,a4)
  182. var msg = a1.querySelector(`body`)
  183. if (!msg){
  184. return
  185. }
  186. // clog("allevnt_rld...",a1)
  187. // clog("allevnt_rldw",_from.split("/").pop())
  188. // clog(msg)
  189. // return
  190. // @Joseph-Innace
  191. // clog(msg.innerHTML)
  192. var msg_txt = msg.innerHTML
  193. if (msg_txt.startsWith("moveto=")){
  194. var room = msg_txt.split("=").pop()
  195. if (room){
  196. var _from = a1.getAttribute("from").split("/").pop()
  197. if (get_local().id == _from){
  198. rld_room(room)
  199. } else {
  200. setTimeout(rld_room,2000,room)
  201. }
  202. // get_local().id
  203. }
  204. // clog("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",msg_txt.split("~"),msg_txt.split("~").pop())
  205. }
  206. // clog($(a1))
  207. // clog("z",$(a1)[0].innerHTML)
  208. // setTimeout(window.mhndlr_rld,1,this,a0,a1,a2,a3,a4)
  209. return true
  210. }
  211. /*
  212. delete Root_io
  213. {
  214. class Root_io {
  215. constructor(){}
  216. _pub_msg(m){
  217. clog("ixi PUB MSG",m)
  218. }
  219. _rec_msg(m){
  220. clog("ixi REC MSG",m)
  221. }
  222. }
  223. window.Root_io = Root_io
  224. }
  225. */
  226. // function allevnt(){
  227. // }
  228. clog("ZZZZZZZZZ")
  229. function init_mx(){
  230. clog("INITMX3")
  231. add_handler_m(mhndlr)
  232. add_handler_m2(allevnt)
  233. }
  234. ifn_obj.init_conf_join.push(init_mx)
  235. // sto_event
  236. // sto_update
  237. // pub_msg
  238. // rec_msg
  239. // set_local