Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. // this will be refactored into the api and an a filmstrip module
  2. mod_templates = window.mod_templates || $("")
  3. // reload templates
  4. function html_js_handler(rsp) {
  5. clog("html_js_handler",[...arguments])
  6. mod_templates = $(`<span>${rsp}</span>`)
  7. init_api6()
  8. }
  9. html_hooks = {
  10. create_video_tile(n){
  11. add_node(n,`#localVideoTileViewContainer`,"before")
  12. },
  13. create_vid_toptoolbar_hook(n){
  14. add_node(n,`.vid_toptoolbar_hook`,"append")
  15. },
  16. create_new_toolbox_hook(n){
  17. add_node(n,`.new_toolbox_hook`,"append")
  18. },
  19. create_vid_toptoolbar_hook_after(n){
  20. add_node(n,`.vid_toptoolbar_hook`,"append")
  21. },
  22. // Top of window
  23. create_top_toolbox_hook(n){
  24. add_node(n,`.top_toolbox`,"append")
  25. },
  26. create_bottom_toolbox_hook(n){
  27. add_node(n,`.button-group-right`,"prepend")
  28. },
  29. create_new_filmstrip(n){
  30. add_node(n,`#filmstripRemoteVideos`,"prepend")
  31. },
  32. }
  33. function saftly_remove(n,remove_nodes=true){
  34. const j =$(n)
  35. $(`#localVideoTileViewContainer`).append(j.find(".local_vid"))
  36. $(`#filmstripRemoteVideosContainer`).append(j.find("#localVideoTileViewContainer"))
  37. $(`#localVideoTileViewContainer`).before(j.find(".remote_vid"))
  38. remove_nodes ? j.remove() : clog("DO NOT REMOVE")
  39. }
  40. // follow focus EventListener
  41. function ffcb(){
  42. clog("ffcb",this.value,this.checked,[this,...arguments])
  43. disp(glob_react.base_conference.setFollowMe(this.checked))
  44. var follow_focus_force=$("#follow_focus_force")[0]
  45. if (follow_focus_force.checked && !this.checked){
  46. msto.conference.force_follow = this.checked
  47. follow_focus_force.checked = this.checked
  48. }
  49. }
  50. // force follow focus EventListener
  51. function fffcb(){
  52. var follow_focus=$("#follow_focus")[0]
  53. if (!follow_focus.checked && this.checked){
  54. follow_focus.checked = this.checked
  55. ffcb.bind(follow_focus)()
  56. }
  57. msto.conference.force_follow = this.checked
  58. }
  59. // number of pseudo videos EventListener
  60. function num_pseudo(){
  61. msto.conference.repeat = this.value
  62. setTimeout(refresh_fs_send,100)
  63. }
  64. // overflow scroll EventListener
  65. function scroll_timeout_runner(){
  66. $("#follow_focus_force")[0]
  67. // scroll_send)
  68. var ov_timeout=$("#ov_timeout")[0]
  69. var ov_timeout_disable=$("#ov_timeout_disable")[0]
  70. // ov_timeout_disable
  71. if (ov_timeout_disable.checked){
  72. timeout_scroll_glob.stop = 1
  73. } else {
  74. timeout_scroll_glob.stop = 0
  75. }
  76. if (!isNaN(ov_timeout.value) && ov_timeout.value > .2){
  77. timeout_scroll_glob.timeout = Math.ceil(ov_timeout.value * 1000)
  78. msto.conference.scroll_timeout = ov_timeout.value
  79. timeout_scroll_start()
  80. }
  81. }
  82. // to
  83. function refresh_toolbars(){
  84. saftly_remove(".plugin_top.tbar")
  85. // this stuff should go in a template
  86. n = `
  87. <span class="plugin_top tbar"><span class="outline_indicator ind_1"></span><span class="outline_indicator ind_2"></span><span class="outline_indicator ind_3"></span>
  88. <div class="m xbox">ABC</div>
  89. </span>`
  90. html_hooks.create_vid_toptoolbar_hook_after(n)
  91. n = `
  92. <div class="plugin_top tbar">
  93. <div class="tbox_slide_indicator cutCorner"><div class="tsi"></div></div>
  94. </div>`
  95. html_hooks.create_new_toolbox_hook(n)
  96. n = `
  97. <div class="plugin_top tbar">
  98. <span class="lvov_container">
  99. <span class="toggle_ff lvov">enter fullframe</span>
  100. <span class="lv_info lvov">
  101. <span class="autoplay_msg lvov">
  102. autoplay is probably disabled
  103. <br>
  104. click on page to enable playback
  105. </span>
  106. <br>
  107. <span class="autoplay_dbg_msg lvov">
  108. </span>
  109. <span class="force_enable lvov">force allow autoplay
  110. </span>
  111. </span>
  112. </span>
  113. <div class="tbox_slide_indicator2"></div>
  114. </div>`
  115. n = $(n)
  116. // <span class="lv_info lvov"></span>
  117. add_node(n,`.lvc_overlay`,"append")
  118. var v = $("#largeVideoContainer")[0]
  119. // v.onmousemove= ff_mm
  120. v.onmouseenter= ff_me
  121. v.onmouseleave =ff_ml
  122. try {
  123. n.find(".toggle_ff")[0].onclick = toggle_ff
  124. n.find(".force_enable")[0].onclick = allow_autoplay
  125. // n.find(".allow_autoplay")[0].onclick = allow_autoplay
  126. } catch (e){}
  127. // html_hooks.create_new_toolbox_hook(n)
  128. $(".tsi").corner("bevel top 20px");
  129. n = `<span class="plugin_top tbar"><span class="m follow_focus">
  130. <input type="checkbox" id="follow_focus" name="follow_focus">
  131. <label for="follow_focus">
  132. follow focus (moderator only)
  133. </label>
  134. <br>
  135. <input type="checkbox" id="follow_focus_force" name="follow_focus_force">
  136. <label for="follow_focus_force">
  137. force
  138. </label>
  139. </span>
  140. <span class="m follow_focus2">
  141. <label for="num_pseudo"># of pseudo videos</label>
  142. <input type="number" id="num_pseudo" name="num_pseudo" value=${window.msto ? msto.conference.repeat || 0 : 0} min=0>
  143. <br>
  144. <label for="ov_timeout">overflow scroll interval </label>
  145. <input type="number" id="ov_timeout" name="timeout" min=.4 step=.1 value=${window.msto ? msto.conference.scroll_timeout || 15 : 15}>
  146. <br>
  147. <input type="checkbox" id="ov_timeout_disable" name="ov_timeout_disable">
  148. <label for="ov_timeout_disable" class="inline_input">
  149. disable
  150. </label>
  151. <span class="inline_input"><button id="scroll_now" class="inline_input">scroll now</button></span>
  152. </span>
  153. </span>`
  154. // add moderator elements
  155. if (amimod()){
  156. n = $(n)
  157. n.find("input#follow_focus")[0].onchange = ffcb
  158. n.find("input#follow_focus_force")[0].onchange = fffcb
  159. n.find("input#ov_timeout")[0].onchange = scroll_timeout_runner
  160. n.find("input#ov_timeout_disable")[0].onchange = scroll_timeout_runner
  161. n.find("#scroll_now")[0].onclick = scroll_send
  162. n.find("#num_pseudo")[0].onchange = num_pseudo
  163. add_node(n,`.subject`,"prepend")
  164. }
  165. }
  166. //
  167. function init_api6(){
  168. clog("init_api6...")
  169. saftly_remove(".plugin_top")
  170. // return
  171. var arr = []
  172. var n
  173. n = `<span class="plugin_top pseudo_vid small_vid "><div class="m2 xbox2">ABC</div></span>`
  174. const repeat = window.msto ? msto.conference.repeat || 0 : 0
  175. if ((!isNaN(repeat) && repeat > 0 )){
  176. html_hooks.create_video_tile(n.repeat(repeat))
  177. }
  178. refresh_toolbars()
  179. // ff_set_ev()
  180. n = `<span class="plugin_top"><div class="m xbox">ABC</div></span>`
  181. html_hooks.create_bottom_toolbox_hook(n)
  182. // n = `<span class="plugin_top abs"><div class="dev_filmstrip">ABC</div></span>`
  183. // n = `<span class="plugin_top abs"><div class="dev_filmstrip">ABC</div></span>`
  184. // n= mod_templates.find(".filmstrip_template")[0].outerHTML
  185. // html_hooks.create_new_filmstrip(n)
  186. // n = `<span class="plugin_top pseudo_vid small_vid "><div class="m4 xbox3">ABC</div></span>`
  187. let nj = mod_templates.find("#vspace_filmstrip_template")
  188. if (nj.length){
  189. n= mod_templates.find("#vspace_filmstrip_template")[0].outerHTML
  190. add_node(n,`.vspace`,"append")
  191. }
  192. if (window.mod_sort){
  193. mod_sort()
  194. }
  195. dispatch_resize()
  196. }
  197. function ff_me(){
  198. clog("ff_me")
  199. // $(".lvov").removeClass("_hide")
  200. $(".lvov_container").removeClass("_hide")
  201. // $(".lvov").removeClass("hide")
  202. // glob_dbg.ff.ts = Date.now()
  203. // glob_dbg.ff.stop = 0
  204. // glob_dbg.ff.n = $(".toggle_ff")[0]
  205. // glob_dbg.ff.mma.shift()s
  206. // dev_raf()
  207. }
  208. function ff_ml(){
  209. clog("ff_ml")
  210. $(".lvov_container").addClass("_hide")
  211. // glob_dbg.ff.stop = 1
  212. }
  213. function ff_mm(){
  214. clog("ff_mm")
  215. glob_dbg.ff.mmc += 1
  216. }
  217. function toggle_ff(){
  218. clog("TOGGLEFF")
  219. // glob_dbg.ytp.playVideo()
  220. // return
  221. glob_mx.dims.fullframe = !glob_mx.dims.fullframe
  222. if (glob_mx.dims.fullframe){
  223. $(".vspace").addClass("_hide")
  224. $(".toggle_ff")[0].innerHTML = "shrink"
  225. $(".toggle_ff")[0].innerHTML = "exit fullframe"
  226. // ._hide
  227. } else {
  228. $(".toggle_ff")[0].innerHTML = "enter fullframe"
  229. $(".vspace").removeClass("_hide")
  230. }
  231. dispatch_resize()
  232. }
  233. function allow_autoplay(){
  234. glob_dbg.ytp.playVideo()
  235. // clog("ALA")
  236. setTimeout(allow_autoplay_end,1)
  237. }
  238. function allow_autoplay_end(){
  239. // glob_dbg.ytp.playVideo()
  240. clog("allow_autoplay_end")
  241. if (glob_dbg.slf && glob_dbg.slf.attr_cache && glob_dbg.slf.attr_cache.state == "playing"){
  242. clog("allow_autoplay_end CONTINUE!")
  243. } else {
  244. glob_dbg.ytp.pauseVideo()
  245. }
  246. // glob_dbg.ytp.pauseVideo()
  247. var j = $(".lv_info")
  248. j.removeClass("_show")
  249. // $(".allow_autoplay")[0].innerHTML = "should work now"
  250. }
  251. function ff_set_ev(){
  252. var v = $("#largeVideoContainer")[0]
  253. // v.onmousemove= ff_mm
  254. v.onmouseenter= ff_me
  255. v.onmouseleave =ff_ml
  256. $(".toggle_ff")[0].onclick = toggle_ff
  257. $(".allow_autoplay")[0].onclick = allow_autoplay
  258. }
  259. /*
  260. // example event
  261. function event_test(){
  262. tmsgx({
  263. "type":"event",
  264. "payload":{path:"z",key:"z",val:"z",etype:"xyz"},
  265. },"code")
  266. }
  267. function all_plugin_events(e){
  268. clog("all_plugin_events",[this],[...arguments])
  269. }
  270. glob_mx.event_handlers.e1 = {
  271. fn:all_plugin_events,
  272. m:{},
  273. }
  274. */
  275. function refresh_fs_send(){
  276. tmsgx({
  277. "type":"event",
  278. "payload":'{path,key,val}',
  279. etype:"refresh_fs"
  280. },"code")
  281. }
  282. function refresh_fs_proc(){
  283. init_api6()
  284. mod_sort()
  285. new_move()
  286. dispatch_resize()
  287. clog("refresh_fs_proc")
  288. }
  289. function scroll_send(){
  290. tmsgx({
  291. "type":"event",
  292. "payload":'{path,key,val}',
  293. etype:"overflow_scroll"
  294. },"code")
  295. }
  296. function scroll_proc(e){
  297. scroll_to()
  298. // clog("scroll_proc",[this,...arguments])
  299. }
  300. glob_mx.event_handlers.e2 = {
  301. fn:scroll_proc,
  302. // fn:nop,
  303. // m:{etype:"timer_start"},
  304. m:{etype:"overflow_scroll"},
  305. }
  306. glob_mx.event_handlers.e3 = {
  307. fn:refresh_fs_proc,
  308. // fn:nop,
  309. // m:{etype:"timer_start"},
  310. m:{etype:"refresh_fs"},
  311. }
  312. if (window.refresh_fs_proc){
  313. refresh_fs_proc()
  314. }