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_req.js 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. window.ifn_obj = window.ifn_obj || { init_conf_join:[],iammod:[] }
  2. function get_mod(participants){
  3. if (!participants){
  4. participants = get_participants()
  5. }
  6. var k,v
  7. for (v of participants){
  8. if (v.role == "moderator"){
  9. clog("cui_mod_cd",[v],v.corner_data)
  10. return v
  11. }
  12. }
  13. }
  14. function get_participants(){
  15. return APP.store.getState()["features/base/participants"]
  16. }
  17. function get_local(participants){
  18. if (!participants){
  19. participants = get_participants()
  20. }
  21. var k,v
  22. for (v of participants){
  23. if (v.local){
  24. return v
  25. }
  26. }
  27. return APP.store.getState()["features/base/participants"]
  28. }
  29. function amimod() {
  30. try {
  31. return get_local().role == "moderator"
  32. } catch (e) {
  33. console.error("AM I MOD ERR: is evrything inited?",e)
  34. // clog("AM I MOD ERR: is evrything inited?",e)
  35. }
  36. }
  37. function Someone_Left_Handler(o){
  38. delete msto.participants[o.action.participant.id]
  39. }
  40. // reflow all your filmstrips
  41. function Someone_Left_or_Joined_Handler(o){
  42. try {
  43. APP.store.dispatch(window.glob_react.video_layout.setTileView(false))
  44. APP.store.dispatch(window.glob_react.rf_filmstrip.setFilmstripVisible(false))
  45. if (! $("#vspace_filmstrip_template").length){
  46. init_api6()
  47. }
  48. refresh_toolbars()
  49. mod_sort()
  50. new_move()
  51. dispatch_resize()
  52. } catch(err) {
  53. console.error("Someone_Left_or_Joined_Handler err:", err)
  54. }
  55. }
  56. // dispay moderator toolbar if you become moderator
  57. window.iammod = window.iammod || false
  58. function amimodnow(){
  59. var iammod = amimod()
  60. window.iammod = iammod
  61. if (iammod){
  62. run_ifn_cbs("iammod")
  63. refresh_toolbars()
  64. }
  65. }
  66. // run init callbacks after CONFERENCE_JOINED
  67. function cji(){
  68. if (window.init_m){
  69. // setTimeout(window.init_m())
  70. }
  71. if (ifn_obj && ifn_obj.init_conf_join){
  72. var k,v
  73. for ([k,v] of Object.entries(ifn_obj.init_conf_join)){
  74. v()
  75. }
  76. }
  77. }
  78. function run_ifn_cbs(cb_name,args){
  79. if (ifn_obj && ifn_obj[cb_name]){
  80. var k,v
  81. for ([k,v] of Object.entries(ifn_obj[cb_name])){
  82. v()
  83. }
  84. } else {}
  85. }
  86. // safe to remove
  87. function stv(o,ta){
  88. clog(o,ta)
  89. }
  90. function SET_TOOLBOX_info(o,that){
  91. // clog("SET_TOOLBOX_info",o,that)
  92. clog("ti",o.action.type,o.action)
  93. }
  94. function share_vid_info(o,that,m = true){
  95. clog("svi",m,o.action.type,o)
  96. }
  97. qxi_match = {
  98. share_vid:{
  99. startsWith:"",
  100. includes:"SHARE",
  101. endsWith:"",
  102. // arr:["SET_TOOLBAR_HOVERED"],
  103. // arr:[],
  104. // arr_or:["PARTICIPANT_UPDATED","SET_LOADABLE_AVATAR_URL"],
  105. arr_or:["PARTICIPANT_JOINED","PARTICIPANT_LEFT"],
  106. },
  107. }
  108. // 2m_req.js?c=023?v=39:163 QXI PARTICIPANT_UPDATED
  109. // 2m_req.js?c=023?v=39:163 QXI SET_LOADABLE_AVATAR_URL
  110. function qxi_jnk_match(o,that,m,fn){
  111. var flag = "~"
  112. var flag0 = 0
  113. var rf = []
  114. rf.push(flag0)
  115. m.startsWith ? flag0 =!o.action.type.startsWith(m.startsWith) || flag0 : 0
  116. rf.push(flag0)
  117. m.includes ? flag0 = !o.action.type.includes(m.includes) || flag0 : 0
  118. rf.push(flag0)
  119. m.endsWith ? flag0 = !o.action.type.endsWith(m.endsWith) || flag0 : 0
  120. rf.push(flag0)
  121. m.arr ? flag0 = !m.arr.includes(o.action.type) || flag0 : 0
  122. m.arr_or ? flag0 = !m.arr_or.includes(o.action.type) && flag0 : 0
  123. rf.push(flag0)
  124. if (!flag0){
  125. fn(o,that)
  126. } else {
  127. // fn(o,that,!!0)
  128. }
  129. // clog("qxi_jnk_match",o.action.type,flag0,rf,m)
  130. }
  131. // this is called with setTimeout so we can throw errors without wrecking everything
  132. function dev_middleware_listner(o) {
  133. if (!o.action.type){
  134. return
  135. }
  136. // /*
  137. if (o.action.type != "ENDPOINT_MESSAGE_RECEIVED"){
  138. // CONFERENCE_JOINED
  139. // if (o.action.type.startsWith("SET_TOOLBOX_" || o.action.type == "TOGGLE_TOOLBOX_VISIBLE")){
  140. // SET_TOOLBOX_info(o,this)
  141. // }
  142. // if ()
  143. // qxi_jnk_match(o,this,qxi_match.share_vid,share_vid_info)
  144. // clog("QXI",o.action.type)
  145. }
  146. // */
  147. switch(o.action.type){
  148. case "PARTICIPANT_UPDATED":
  149. window.iammod ? 0 : amimodnow()
  150. break;
  151. case "PARTICIPANT_LEFT":
  152. setTimeout(Someone_Left_Handler,1,o)
  153. // setTimeout(Someone_Left_Handler,1000,o)
  154. case "PARTICIPANT_JOINED":
  155. setTimeout(Someone_Left_or_Joined_Handler,1,o)
  156. // setTimeout(Someone_Left_or_Joined_Handler,300,o)
  157. break;
  158. // case "SET_TILE_VIEW":
  159. // stv(o,[this,arguments])
  160. break;
  161. case "CONFERENCE_JOINED":
  162. setTimeout(cji,1)
  163. break;
  164. }
  165. }
  166. // SET_TOOLBOX_ENABLED
  167. // SET_TOOLBOX_