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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755
  1. glob_mx.filmstrip_handlers[undefined] = function function_name(argument) {
  2. clog("default FN HANDLER")
  3. }
  4. glob_mx.dims = glob_mx.dims || {}
  5. dflt_css = {
  6. 'padding-top': '',
  7. "min-height": ``,
  8. "min-width": ``,
  9. width: ``,
  10. height: ``,
  11. }
  12. function fix_avatar(vid){
  13. var k,v,bcr
  14. for (v of $(vid).filter(".remote_vid,.local_vid")){
  15. bcr = v.getBoundingClientRect()
  16. $(v).find(".avatar-container").css({
  17. width:Math.ceil(bcr.height * .75),
  18. height:Math.ceil(bcr.height * .75),
  19. })
  20. }
  21. }
  22. function resize_thumbs_vertical(cont){
  23. const computed_css = Object.assign({},dflt_css)
  24. var aspect = 16/9
  25. var width = 335
  26. var thumbs = $(cont).children(".small_vid")
  27. width = $(cont).width() - 1
  28. width = glob_mx.dims.w5
  29. // computed_css["--v_index"]=`"VERT"`
  30. var height = Math.round(width/aspect)
  31. computed_css.height = height
  32. computed_css["min-height"] = height
  33. computed_css.width = width
  34. computed_css["min-width"] = width
  35. var k,v
  36. for ([k,v] of Object.entries(computed_css)){
  37. Number(v) ? computed_css[k] = v + "px" : 0
  38. }
  39. // clog("RTHUMBS")
  40. thumbs.css(computed_css)
  41. fix_avatar(thumbs)
  42. }
  43. function resize_thumbs_horizontal(cont){
  44. const computed_css = Object.assign({},dflt_css)
  45. var aspect = 16/9
  46. var width = 335
  47. // computed_css["--v_index"]=`"horizontal"`
  48. var thumbs = $(cont).children(".small_vid")
  49. width = ($(cont).height() * aspect)
  50. width = ($(cont).height() * aspect) - 1
  51. width = glob_mx.dims.w5
  52. var height = Math.round(width/aspect)
  53. computed_css.height = height
  54. computed_css.width = width
  55. clog("RTH",cont)
  56. computed_css["min-width"] = width
  57. var k,v
  58. for ([k,v] of Object.entries(computed_css)){
  59. Number(v) ? computed_css[k] = v + "px" : 0
  60. }
  61. // clog("RTHUMBS")
  62. fix_avatar(thumbs)
  63. thumbs.css(computed_css)
  64. }
  65. function resize_thumbs_center(cont){
  66. const computed_css = Object.assign({},dflt_css)
  67. var aspect = 16/9
  68. var width = 335
  69. // computed_css["--v_index"]=`"horizontal"`
  70. var thumbs = $(cont).children(".small_vid")
  71. width = ($(cont).width() ) - 10
  72. var height = Math.round(width/aspect)
  73. computed_css.height = height
  74. computed_css.width = width
  75. var k,v
  76. for ([k,v] of Object.entries(computed_css)){
  77. Number(v) ? computed_css[k] = v + "px" : 0
  78. }
  79. // clog("RTHUMBS")
  80. thumbs.css(computed_css)
  81. fix_avatar(thumbs)
  82. }
  83. dflt_css_proto = {
  84. 'padding-top': '',
  85. "max-height": ``,
  86. "min-height": ``,
  87. "max-width": ``,
  88. "min-width": ``,
  89. width: ``,
  90. height: ``,
  91. top: ``,
  92. left: ``,
  93. bottom: ``,
  94. right: ``,
  95. position:``,
  96. tramsform:``,
  97. // right: ``,
  98. // right: ``,
  99. }
  100. function resize_thumbs_proto(thumbs,css_arg){
  101. var k,v
  102. let css
  103. if (Array.isArray(css_arg)){
  104. css = Object.assign({},dflt_css_proto,...css_arg)
  105. } else {
  106. css = Object.assign({},dflt_css_proto,css_arg)
  107. }
  108. if (typeof(css.data) == "object"){
  109. try{
  110. Object.assign($(thumbs)[0].dataset,css.data)
  111. } catch(err) {
  112. clog("dataset err",err)
  113. }
  114. }
  115. css["--vdim"] = `"${css.width} x ${css.height}"`
  116. $(thumbs).css(css)
  117. }
  118. // this handles the layout of all custom filmstrips an the large video element
  119. // todo refactor half of this into the api
  120. function calc_fs_dims(){
  121. const hd_w = 16
  122. const hd_h = 9
  123. const aspect_ratio_hd = hd_w / hd_h
  124. const aspect_ratio_65 = (hd_w * 6) / (hd_h * 5)
  125. const aspect_ratio_64 = (hd_w * 6) / (hd_h * 4)
  126. const state = APP.store.getState();
  127. var { clientHeight, clientWidth } = state['features/base/responsive-ui'];
  128. var avail_width =clientWidth
  129. // var avail_height =clientHeight - 100
  130. var avail_height =clientHeight - 45
  131. var dim_hd = glob_dev_fns.calculateThumbnailSizeForTileView_dev({
  132. columns:1,
  133. visibleRows:1,
  134. clientWidth:avail_width,
  135. clientHeight:avail_height,
  136. TILE_ASPECT_RATIO:TILE_ASPECT_RATIO ,
  137. verticalMargin:0,
  138. // sideMargins=0,
  139. // topBottomPadding:100,
  140. })
  141. let w5,h5,w53,h53,w54,h54
  142. h5 = dim_hd.height/5
  143. w5 = dim_hd.width/5
  144. let m = 10
  145. let wm = 10
  146. let hm = 8
  147. // w5 = w5 - m
  148. // h5 = h5 - m
  149. w53 = w5 * 3
  150. h53 = h5 * 3
  151. w54 = w5 * 4
  152. h54 = h5 * 4
  153. w5 = w5 - m
  154. h5 = h5 - hm
  155. glob_mx.dims.w5 = w5
  156. glob_mx.dims.h5 = h5
  157. glob_mx.dims.m = m
  158. h54 = h54 + (hm * 2)
  159. let vtop
  160. let vleft
  161. let s_width,h_height
  162. s_width = w53
  163. h_height = h53 + 1 * hm
  164. vleft = w5 + ( m )
  165. // = h5 + ((m * 2 ) / aspect_ratio_hd) + 1
  166. vtop = h5 + ( m * 2 ) - 2
  167. vtop = h5 + (hm * 1.5)
  168. clog("....",clientHeight - dim_hd.height > 100,clientHeight - dim_hd.height,clientHeight , dim_hd.height)
  169. var top_margin_flag
  170. if (clientHeight - dim_hd.height > 150 ) {
  171. top_margin_flag = 1
  172. // $(".fs_container").css({width:dim_hd.width,"min-height":dim_hd.height,"max-height":dim_hd.height + 100})
  173. resize_thumbs_proto($(".fs_container"),{width:dim_hd.width,"height":dim_hd.height})
  174. // top_margin_flag =
  175. // $(".fs_container").css({width:dim_hd.width,"min-height":dim_hd.height,"max-height":dim_hd.height + 100})
  176. } else {
  177. top_margin_flag = 0
  178. // resize_thumbs_proto($(".fs_container"),{width:dim_hd.width,"height":dim_hd.height})
  179. resize_thumbs_proto($(".fs_container"),{width:dim_hd.width,"min-height":dim_hd.height,"max-height":dim_hd.height + 100})
  180. }
  181. // $(".fs_container").css({width:dim_hd.width,"height":dim_hd.height})
  182. // fs_type: "vertical"
  183. resize_thumbs_proto($(".ic1"),[
  184. {
  185. width:dim_hd.width,
  186. height:h5,
  187. "--vtext":`"top_fs"`,
  188. // data:{fs_type: "vertical"},
  189. data:{fs_type: "horizontal",},
  190. },])
  191. resize_thumbs_proto($(".ic2"),[
  192. {
  193. width:w5,
  194. height:h53,
  195. top:vtop ,
  196. "--vtext":`"left_fs"`,
  197. data:{fs_type: "vertical"},
  198. },])
  199. resize_thumbs_proto($(".ic3"),[
  200. {
  201. width:w5,
  202. height:h53,
  203. top:vtop,
  204. left:w54,
  205. // left:0,
  206. // right:0,
  207. "--vtext":`"right_fs"`,
  208. data:{fs_type: "vertical"},
  209. },])
  210. let overflow_vids = $(".ic6").children(".small_vid")
  211. let overflow_obj = {}
  212. if (overflow_vids.length > 5){
  213. }
  214. overflow_obj.width = w5 * (overflow_vids.length + 1)
  215. resize_thumbs_proto($(".c6"),[{
  216. width:dim_hd.width,
  217. height:h5,
  218. height:h5 + 20,
  219. top:h54 - (hm) * .5,
  220. left:0,}])
  221. resize_thumbs_proto($(".ic6"),[
  222. {
  223. width:dim_hd.width,
  224. height:h5 + 10,
  225. // top:h54 - (hm) * .5,
  226. // left:0,
  227. // left:w54,
  228. // right:0,
  229. "--vtext":`"bottom_fs"`,
  230. data:{fs_type: "horizontal"},
  231. },overflow_obj])
  232. resize_thumbs_proto($(".ic4"),[
  233. {
  234. // height:h53,
  235. width:s_width,
  236. // height:h53,
  237. height:h_height,
  238. top:vtop - 1,
  239. left:vleft,
  240. // left:w54,
  241. // right:0,
  242. "--vtext":`"center"`,
  243. data:{fs_type: "single"},
  244. },])
  245. var center_vid = $(".ic4")[0]
  246. var bcr = center_vid.getBoundingClientRect()
  247. var bcr_fs = $(".fs_container")[0].getBoundingClientRect()
  248. if (top_margin_flag){
  249. resize_thumbs_proto($("#largeVideoContainer"),[
  250. {
  251. // height:h53,
  252. width:s_width - m,
  253. // height:h53,
  254. height:h_height - hm,
  255. // top:vtop - 2 + (hm * .5),
  256. transform: "translate(0%, -50%)",
  257. top:`calc(50% + ${Math.floor(hm * 1)}px)`,
  258. top:`calc(50% + ${Math.floor(hm * .7)}px)`,
  259. left:vleft + (.5 * m),
  260. position:"relative",
  261. // outline:"1px solid blue",
  262. outline:"",
  263. // "z-index":"10",
  264. // left:w54,
  265. // right:0,
  266. "--vtext":`"center"`,
  267. data:{fs_type: "single"},
  268. },])
  269. } else {
  270. resize_thumbs_proto($("#largeVideoContainer"),[
  271. {
  272. // height:h53,
  273. width:s_width - m,
  274. // height:h53,
  275. height:h_height - hm,
  276. top:vtop - 2 + (hm * .5) + bcr_fs.y,
  277. // top:h5 + (3 * hm),
  278. transform: "translate(-50%, 0)",
  279. // top:`calc(50% + ${Math.floor(hm * 1)}px)`,
  280. // top:`calc(50% + ${Math.floor(hm * .7)}px)`,
  281. // left:vleft + (.5 * m),
  282. left:"50%",
  283. position:"relative",
  284. // "z-index":"10",
  285. // left:w54,
  286. // right:0,
  287. // outline:"1px solid red",
  288. outline:"",
  289. "--vtext":`"center"`,
  290. data:{fs_type: "single"},
  291. },])
  292. }
  293. // #sharedVideo
  294. // resize_thumbs_proto($(".ic4"),[
  295. resize_thumbs_proto($("#sharedVideoIFrame.z"),[
  296. {
  297. // height:h53,
  298. width:s_width,
  299. // height:h53,
  300. height:h_height,
  301. top:vtop - 1,
  302. left:vleft,
  303. position:"relative",
  304. // "z-index":"10",
  305. // left:w54,
  306. // right:0,
  307. "--vtext":`"center"`,
  308. data:{fs_type: "single"},
  309. },])
  310. resize_thumbs_proto($("#sharedVideoIFrame"),{
  311. position:"",
  312. })
  313. clog("top",top_margin_flag)
  314. resize_thumbs_proto($("#largeVideoContainer.z,#sharedVideoIFrame"),{position:"",})
  315. }
  316. function filmstrip_rs(){
  317. calc_fs_dims()
  318. clog("filmstrip_rs")
  319. }
  320. glob_mx.filmstrip_handlers.vertical = filmstrip_rs
  321. glob_mx.filmstrip_handlers.horizontal = filmstrip_rs
  322. glob_mx.filmstrip_handlers.center = filmstrip_rs
  323. glob_mx.filmstrip_tile_handlers.vertical = resize_thumbs_vertical
  324. glob_mx.filmstrip_tile_handlers.horizontal = resize_thumbs_horizontal
  325. glob_mx.filmstrip_tile_handlers.center = resize_thumbs_center
  326. // this handles sorting the videos
  327. function sort_id3(a, b) {
  328. if (a.id > b.id){
  329. return 1
  330. } else if (a.id < b.id){
  331. return -1
  332. }
  333. return 0
  334. }
  335. indexed_tiles = []
  336. indexed_map = window.indexed_map || new Map()
  337. reverse_indexed_map = window.reverse_indexed_map || new Map()
  338. // indexed_map = new Map()
  339. // reverse_indexed_map = new Map()
  340. function array_move(arr, old_index, new_index) {
  341. if (new_index >= arr.length) {
  342. var k = new_index - arr.length + 1;
  343. while (k--) {
  344. arr.push(undefined);
  345. }
  346. }
  347. arr.splice(new_index, 0, arr.splice(old_index, 1)[0]);
  348. return arr; // for testing
  349. };
  350. function mod_sort(){
  351. var arr = []
  352. var parr = []
  353. var ivid = {}
  354. var k,v
  355. var j = $(".small_vid:not(.pseudo_vid)")
  356. window.indexed_map = new Map()
  357. window.reverse_indexed_map = new Map()
  358. var part = get_participants()
  359. var parts =jc(part).sort(sort_id3)
  360. // clog(parts,part)
  361. var mod_id = get_mod(part)
  362. if (mod_id){
  363. remap_set( $(`#participant_${mod_id.id}`)[0],2)
  364. }
  365. var n
  366. var cnt = 0
  367. for (k of parts){
  368. // clog("z",k,k.local)
  369. if (k.isFakeParticipant){
  370. n = `<span class="plugin_top pseudo_vid small_vid youtube_vid"><div class="m2 xbox2">ABC</div></span>`
  371. if ($(".youtube_vid").length){
  372. } else {
  373. // html_hooks.create_video_tile(n)
  374. }
  375. // remap_set($(".youtube_vid")[0],0)
  376. j = $("#sharedVideoContainer")
  377. remap_set(j[0],2)
  378. // remap_set( $(`#participant_${mod_id.id}`)[0],1)
  379. } else {
  380. j = k.local ? $("#localVideoContainer") : $(`#participant_${k.id}`)
  381. // get_mod().id
  382. }
  383. j.css({"--v_index":`"I: ${cnt}"`})
  384. j.css({"--v_id":`"${k.id}"`})
  385. j[0].dataset.v_index = cnt
  386. arr.push(j[0])
  387. cnt += 1
  388. }
  389. v = $(".pseudo_vid")
  390. for (k of v){
  391. // clog(k)
  392. $(k).css({"--v_index":`"I: ${cnt}"`})
  393. $(k).css({"--v_id":`"pseudo_${cnt}"`})
  394. parr.push(k)
  395. $(k)[0].dataset.v_index = cnt
  396. cnt += 1
  397. }
  398. arr.push(...parr)
  399. window.arig_tiles = jc(arr)
  400. // remap_set($(".local_vid")[0],1)
  401. remap_set($(".local_vid")[0],3)
  402. // remap_set( $(`#participant_${mod_id.id}`)[0],2)
  403. arr = remap_sort(arr)
  404. arr = remap_sort(arr)
  405. arr = remap_sort(arr)
  406. window.sorted_tiles = arr
  407. // for
  408. }
  409. sorted_tiles = window.sorted_tiles || []
  410. function remap_sort(arr){
  411. // return
  412. var k,v
  413. for ([k,v] of indexed_map){
  414. // clog(k,v)
  415. var old_index = arr.indexOf(k)
  416. // clog("K,v",k,v,old_index)
  417. array_move(arr,old_index,v)
  418. // clog(cnt,sorted_tiles.includes(k),v,k)
  419. // cnt += 1
  420. }
  421. return arr
  422. }
  423. function remap_set(vid,loc){
  424. if (typeof(vid)=="number"){
  425. vid = sorted_tiles[vid]
  426. }
  427. var old = reverse_indexed_map.get(loc)
  428. // reverse_indexed_map
  429. indexed_map.delete(old,loc)
  430. indexed_map.set(vid,loc)
  431. reverse_indexed_map.set(loc,vid)
  432. var k,v
  433. var cnt = 0
  434. for ([k,v] of indexed_map){
  435. // clog(k,v)
  436. // clog(cnt,sorted_tiles.includes(k),v,k)
  437. cnt += 1
  438. }
  439. }
  440. // move videos onto the filmstrips
  441. function new_move(){
  442. var j
  443. try {
  444. j = jc(window.sorted_tiles)
  445. } catch (err) {
  446. clog("NEW MOVE err:",err)
  447. }
  448. $(".ic1").append(j.splice(0,5))
  449. $(".ic2").append(j.splice(0,3))
  450. $(".ic3").append(j.splice(0,3))
  451. const all_extra = j.splice(0)
  452. if (all_extra.length > 5){
  453. $(".ic6").addClass("overflow")
  454. } else {
  455. $(".ic6").removeClass("overflow")
  456. }
  457. $(".ic6").append(all_extra)
  458. }
  459. // the rest of this slides the bottom row if there is overflow.
  460. timeout_scroll_glob = window.timeout_scroll_glob || {
  461. stop:1,
  462. timeout:3000,
  463. rid:0,
  464. mx_raf:200,
  465. to_left:1,
  466. }
  467. timeout_scroll_glob.stop=1
  468. function timeout_scroll(rid){
  469. // clog("Tscroll",rid,timeout_scroll_glob)
  470. if (timeout_scroll_glob.stop || rid != timeout_scroll_glob.rid){
  471. // clog("tscroll stop")
  472. return
  473. }
  474. // clog("tscroll continue")
  475. scroll_send()
  476. var t = setTimeout(timeout_scroll,timeout_scroll_glob.timeout,rid)
  477. }
  478. function timeout_scroll_start(){
  479. timeout_scroll_glob.rid += 1
  480. setTimeout(timeout_scroll,timeout_scroll_glob.timeout,timeout_scroll_glob.rid)
  481. }
  482. function get_bcrs(arr,fs_bcr){
  483. var ret = {
  484. arr:[],
  485. first_left:0,
  486. first_left_bcr:0,
  487. first_right:0,
  488. first_right_bcr:0,
  489. }
  490. var s = $(".ic6").children(".small_vid")
  491. s.removeClass("ir il ilr ir0 il0")
  492. var k,v,bcr,isleft,isright
  493. for (v of arr){
  494. bcr = v.getBoundingClientRect()
  495. ret.arr.push(bcr)
  496. isleft = bcr.right < (fs_bcr.right + 10)
  497. isright = bcr.left > (fs_bcr.left )
  498. if (isleft && isright){
  499. $(v).addClass("ilr")
  500. } else if (isleft){
  501. $(v).addClass("il")
  502. } else if (isright){
  503. $(v).addClass("ir")
  504. }
  505. if (isleft && ! isright){
  506. ret.first_left = v
  507. ret.first_left_bcr = bcr
  508. }
  509. if ( (! ret.first_right ) && !isleft && isright ){
  510. ret.first_right = v
  511. ret.first_right_bcr = bcr
  512. }
  513. }
  514. clog("````",ret)
  515. $(ret.first_right).addClass("ir0")
  516. $(ret.first_left).addClass("il0")
  517. return ret
  518. }
  519. function scroll_to(n){
  520. var fs,fs_bcr,vid_bcr,ifs
  521. fs = $(".c6")[0]
  522. ifs = $(".ic6")[0]
  523. var vid
  524. var s = $(".ic6").children(".small_vid")
  525. fs_bcr = fs.getBoundingClientRect()
  526. var ov = get_bcrs([...s],fs_bcr)
  527. var tobj = {
  528. }
  529. var scroll_to_vid = 0
  530. if (timeout_scroll_glob.to_left){
  531. if (ov.first_left){
  532. scroll_to_vid = ov.first_left
  533. vid_bcr = ov.first_left_bcr
  534. tobj.inc_mx = vid_bcr.left - fs_bcr.left
  535. tobj.inc = -8
  536. } else {
  537. timeout_scroll_glob.to_left = 0
  538. }
  539. } else {
  540. if (ov.first_right){
  541. scroll_to_vid = ov.first_right
  542. vid_bcr = ov.first_right_bcr
  543. tobj.inc_mx = vid_bcr.right - fs_bcr.right
  544. tobj.inc = 8
  545. } else {
  546. timeout_scroll_glob.to_left = 1
  547. }
  548. }
  549. scroll_to_vid ? requestAnimationFrame(raf.bind(timeout_scroll_glob,fs,scroll_to_vid,tobj.inc,tobj.inc_mx,0,0),"z-index") : 0
  550. }
  551. function raf_clog(fs,vid,cnt,ts){
  552. clog("raf.",cnt,ts)
  553. }
  554. function raf(fs,vid,inc,inc_mx,cnt,ts0,ts){
  555. fs.scrollBy(inc,0)
  556. if (Math.abs(inc) < Math.abs(inc_mx) && cnt < timeout_scroll_glob.mx_raf && ts - (ts0 || ts) < 3000){
  557. requestAnimationFrame(raf.bind(timeout_scroll_glob,fs,vid,inc,inc_mx - inc ,cnt+1,ts0 || ts))
  558. } else {
  559. // clog("FIN",[fs,vid],cnt,ts0,inc_mx,ts,ts-ts0)
  560. vid.scrollIntoView({ behavior: 'smooth', block: 'nearest' ,inline:"nearest"})
  561. }
  562. }
  563. if (window.refresh_fs_proc){
  564. refresh_fs_proc()
  565. }