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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899
  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 = Math.floor(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. thumbs.css(computed_css)
  63. fix_avatar(thumbs)
  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.fw = dim_hd.width
  158. glob_mx.dims.fh = dim_hd.height
  159. glob_mx.dims.m = m
  160. h54 = h54 + (hm * 2)
  161. let vtop
  162. let vleft
  163. let s_width,h_height
  164. s_width = w53
  165. h_height = h53 + 1 * hm
  166. vleft = w5 + ( m )
  167. // = h5 + ((m * 2 ) / aspect_ratio_hd) + 1
  168. vtop = h5 + ( m * 2 ) - 2
  169. vtop = h5 + (hm * 1.5)
  170. clog("....",clientHeight - dim_hd.height > 100,clientHeight - dim_hd.height,clientHeight , dim_hd.height)
  171. var top_margin_flag
  172. if (clientHeight - dim_hd.height > 150 ) {
  173. top_margin_flag = 1
  174. // $(".fs_container").css({width:dim_hd.width,"min-height":dim_hd.height,"max-height":dim_hd.height + 100})
  175. resize_thumbs_proto($(".fs_container"),{width:dim_hd.width,"height":dim_hd.height})
  176. // top_margin_flag =
  177. // $(".fs_container").css({width:dim_hd.width,"min-height":dim_hd.height,"max-height":dim_hd.height + 100})
  178. } else {
  179. top_margin_flag = 0
  180. // resize_thumbs_proto($(".fs_container"),{width:dim_hd.width,"height":dim_hd.height})
  181. resize_thumbs_proto($(".fs_container"),{width:dim_hd.width,"min-height":dim_hd.height,"max-height":dim_hd.height + 100})
  182. }
  183. // $(".fs_container").css({width:dim_hd.width,"height":dim_hd.height})
  184. // fs_type: "vertical"
  185. resize_thumbs_proto($(".ic1"),[
  186. {
  187. width:dim_hd.width,
  188. height:h5,
  189. "--vtext":`"top_fs"`,
  190. // data:{fs_type: "vertical"},
  191. data:{fs_type: "horizontal",},
  192. },])
  193. resize_thumbs_proto($(".ic2"),[
  194. {
  195. width:w5,
  196. height:h53,
  197. top:vtop ,
  198. "--vtext":`"left_fs"`,
  199. data:{fs_type: "vertical"},
  200. },])
  201. resize_thumbs_proto($(".ic3"),[
  202. {
  203. width:w5,
  204. height:h53,
  205. top:vtop,
  206. left:w54,
  207. // left:0,
  208. // right:0,
  209. "--vtext":`"right_fs"`,
  210. data:{fs_type: "vertical"},
  211. },])
  212. let overflow_vids = $(".ic6").children(".small_vid")
  213. let overflow_obj = {}
  214. if (overflow_vids.length > 5){
  215. }
  216. overflow_obj.width = w5 * (overflow_vids.length + 1)
  217. resize_thumbs_proto($(".c6"),[{
  218. width:dim_hd.width,
  219. height:h5,
  220. height:h5 + 20,
  221. top:h54 - (hm) * .5,
  222. left:0,}])
  223. resize_thumbs_proto($(".ic6"),[
  224. {
  225. width:dim_hd.width,
  226. "--xxwidth":dim_hd.width + 200,
  227. height:h5 + 10,
  228. // top:h54 - (hm) * .5,
  229. // left:0,
  230. // left:w54,
  231. // right:0,
  232. "--vtext":`"bottom_fs"`,
  233. data:{fs_type: "horizontal"},
  234. },overflow_obj])
  235. resize_thumbs_proto($(".ic4"),[
  236. {
  237. // height:h53,
  238. width:s_width,
  239. // height:h53,
  240. height:h_height,
  241. top:vtop - 1,
  242. left:vleft,
  243. // left:w54,
  244. // right:0,
  245. "--vtext":`"center"`,
  246. data:{fs_type: "single"},
  247. },])
  248. var center_vid = $(".ic4")[0]
  249. var bcr = center_vid.getBoundingClientRect()
  250. var bcr_fs = $(".fs_container")[0].getBoundingClientRect()
  251. glob_mx.dims.top_margin_flag=top_margin_flag
  252. glob_mx.dims.top_offset=bcr_fs.y
  253. glob_mx.dims.left_offset=bcr_fs.x
  254. if (glob_mx.dims.fullframe){
  255. fullframe()
  256. }else if (top_margin_flag){
  257. resize_thumbs_proto($("#largeVideoContainer"),[
  258. {
  259. // height:h53,
  260. width:s_width - m,
  261. // height:h53,
  262. height:h_height - hm,
  263. // top:vtop - 2 + (hm * .5),
  264. transform: "translate(0%, -50%)",
  265. top:`calc(50% + ${Math.floor(hm * 1)}px)`,
  266. top:`calc(50% + ${Math.floor(hm * .7)}px)`,
  267. left:vleft + (.5 * m),
  268. position:"relative",
  269. // outline:"1px solid blue",
  270. outline:"",
  271. // "z-index":"10",
  272. // left:w54,
  273. // right:0,
  274. "--vtext":`"center"`,
  275. data:{fs_type: "single"},
  276. },])
  277. } else {
  278. resize_thumbs_proto($("#largeVideoContainer"),[
  279. {
  280. // height:h53,
  281. width:s_width - m,
  282. // height:h53,
  283. height:h_height - hm,
  284. top:vtop - 2 + (hm * .5) + bcr_fs.y,
  285. // top:h5 + (3 * hm),
  286. transform: "translate(-50%, 0)",
  287. // top:`calc(50% + ${Math.floor(hm * 1)}px)`,
  288. // top:`calc(50% + ${Math.floor(hm * .7)}px)`,
  289. // left:vleft + (.5 * m),
  290. left:"50%",
  291. position:"relative",
  292. // "z-index":"10",
  293. // left:w54,
  294. // right:0,
  295. // outline:"1px solid red",
  296. outline:"",
  297. "--vtext":`"center"`,
  298. data:{fs_type: "single"},
  299. },])
  300. }
  301. // #sharedVideo
  302. // resize_thumbs_proto($(".ic4"),[
  303. resize_thumbs_proto($("#sharedVideoIFrame.z"),[
  304. {
  305. // height:h53,
  306. width:s_width,
  307. // height:h53,
  308. height:h_height,
  309. top:vtop - 1,
  310. left:vleft,
  311. position:"relative",
  312. // "z-index":"10",
  313. // left:w54,
  314. // right:0,
  315. "--vtext":`"center"`,
  316. data:{fs_type: "single"},
  317. },])
  318. resize_thumbs_proto($("#sharedVideoIFrame"),{
  319. position:"",
  320. })
  321. clog("top",top_margin_flag)
  322. resize_thumbs_proto($("#largeVideoContainer.z,#sharedVideoIFrame"),{position:"",})
  323. }
  324. function fullframe(){
  325. var w,h
  326. w = glob_mx.dims.fw
  327. h = glob_mx.dims.fh
  328. let top = "50%"
  329. let transform ="translate(-50%, -50%)"
  330. if (glob_mx.dims.top_margin_flag){
  331. top = glob_mx.dims.top_offset+ "px"
  332. transform = "translate(-50%, 0px)"
  333. transform = "translate(0%, 0px)"
  334. glob_mx.dims.top_offset
  335. // left_offset
  336. }
  337. resize_thumbs_proto($("#largeVideoContainer"),[
  338. {
  339. // height:h53,
  340. width:w,
  341. // height:h53,
  342. height: h,
  343. // top:vtop - 2 + (hm * .5) + bcr_fs.y,
  344. // top:h5 + (3 * hm),
  345. // transform: "translate(-50%, 0)",
  346. // transform: "translate(-50%, -50%)",
  347. // top:`calc(50% + ${Math.floor(hm * 1)}px)`,
  348. // top:`calc(50% + ${Math.floor(hm * .7)}px)`,
  349. // left:vleft + (.5 * m),
  350. // left:"50%",
  351. transform:"",
  352. // top:`50% ${glob_mx.dims.top_offset}`,
  353. top:`calc(50% + ${top}px)`,
  354. top:glob_mx.dims.top_offset,
  355. left:glob_mx.dims.left_offset,
  356. position:"relative",
  357. // "z-index":"10",
  358. // left:w54,
  359. // right:0,
  360. // outline:"1px solid red",
  361. outline:"",
  362. "--vtext":`"center"`,
  363. data:{fs_type: "single"},
  364. },])
  365. }
  366. // fullframe()
  367. // setTimeout(fullframe,100)
  368. function filmstrip_rs(){
  369. calc_fs_dims()
  370. clog("filmstrip_rs")
  371. }
  372. glob_mx.filmstrip_handlers.vertical = filmstrip_rs
  373. glob_mx.filmstrip_handlers.horizontal = filmstrip_rs
  374. glob_mx.filmstrip_handlers.center = filmstrip_rs
  375. glob_mx.filmstrip_tile_handlers.vertical = resize_thumbs_vertical
  376. glob_mx.filmstrip_tile_handlers.horizontal = resize_thumbs_horizontal
  377. glob_mx.filmstrip_tile_handlers.center = resize_thumbs_center
  378. // this handles sorting the videos
  379. function sort_id3(a, b) {
  380. if (a.id > b.id){
  381. return 1
  382. } else if (a.id < b.id){
  383. return -1
  384. }
  385. return 0
  386. }
  387. indexed_tiles = []
  388. indexed_map = window.indexed_map || new Map()
  389. reverse_indexed_map = window.reverse_indexed_map || new Map()
  390. // indexed_map = new Map()
  391. // reverse_indexed_map = new Map()
  392. function array_move(arr, old_index, new_index) {
  393. if (new_index >= arr.length) {
  394. var k = new_index - arr.length + 1;
  395. while (k--) {
  396. arr.push(undefined);
  397. }
  398. }
  399. arr.splice(new_index, 0, arr.splice(old_index, 1)[0]);
  400. return arr; // for testing
  401. };
  402. color_palette=[
  403. "#fff",
  404. "#ff0",
  405. "#f0f",
  406. "#0ff",
  407. "#f00",
  408. "#0f0",
  409. "#00f",
  410. "#800",
  411. "#080",
  412. "#008",
  413. "#880",
  414. "#088",
  415. "#808",
  416. "#888",
  417. "#f44",
  418. "#4f4",
  419. "#44f",
  420. // "#44f",
  421. "#ff4",
  422. "#4ff",
  423. "#f4f",
  424. "#f84",
  425. "#8f4",
  426. "#84f",
  427. "#f48",
  428. "#4f8",
  429. "#48f",
  430. "#400",
  431. "#040",
  432. "#004",
  433. "#440",
  434. "#044",
  435. "#404",
  436. // "#444",
  437. // "#444",
  438. // "#000",
  439. ]
  440. window.glob_mx.arrs = window.glob_mx.arrs || {}
  441. function mod_sort(){
  442. clog("mod_sort")
  443. var arr = []
  444. var parr = []
  445. var ivid = {}
  446. var k,v
  447. var j = $(".small_vid:not(.pseudo_vid)")
  448. window.indexed_map = new Map()
  449. window.reverse_indexed_map = new Map()
  450. var part = get_participants()
  451. var parts =jc(part).sort(sort_id3)
  452. // clog(parts,part)
  453. var mod_id = get_mod(part)
  454. if (mod_id){
  455. remap_set( $(`#participant_${mod_id.id}`)[0],2)
  456. }
  457. var n
  458. var cnt = 0
  459. for (k of parts){
  460. // clog("z",k,k.local)
  461. if (k.isFakeParticipant){
  462. n = `<span class="plugin_top pseudo_vid small_vid youtube_vid"><div class="m2 xbox2">ABC</div></span>`
  463. if ($(".youtube_vid").length){
  464. } else {
  465. // html_hooks.create_video_tile(n)
  466. }
  467. // remap_set($(".youtube_vid")[0],0)
  468. j = $("#sharedVideoContainer")
  469. remap_set(j[0],2)
  470. // remap_set( $(`#participant_${mod_id.id}`)[0],1)
  471. } else {
  472. j = k.local ? $("#localVideoContainer") : $(`#participant_${k.id}`)
  473. // get_mod().id
  474. }
  475. j.css({"--v_index":`"I: ${cnt}"`})
  476. j.css({"--v_id":`"${k.id}"`})
  477. j[0].dataset.v_index = cnt
  478. arr.push(j[0])
  479. cnt += 1
  480. }
  481. v = $(".pseudo_vid")
  482. for (k of v){
  483. // clog(k)
  484. $(k).css({"--v_index":`"I: ${cnt}"`})
  485. $(k).css({"--v_id":`"pseudo_${cnt}"`})
  486. // $(k).css({"--v_id2":`"pseudoxxx_${cnt}"`})
  487. $(k).css({"--v_cpal":color_palette[cnt]})
  488. $(k).addClass(`pseudo_num_${cnt}`)
  489. parr.push(k)
  490. $(k)[0].dataset.v_index = cnt
  491. cnt += 1
  492. }
  493. glob_mx.arrs.remotes = [...arr]
  494. cnt = 0
  495. for (k of arr){
  496. $(k).css({"--v_index2":`"I2: ${cnt}"`})
  497. cnt +=1
  498. }
  499. arr.push(...parr)
  500. glob_mx.arrs.all = [...arr]
  501. window.arig_tiles = jc(arr)
  502. // remap_set($(".local_vid")[0],1)
  503. remap_set($(".local_vid")[0],3)
  504. // remap_set( $(`#participant_${mod_id.id}`)[0],2)
  505. clog("indexed_map0",arr,indexed_map)
  506. if (window.rotate_tiles){
  507. try {
  508. clog("mod_sort2")
  509. window.rotate_tiles(arr)
  510. } catch {}
  511. }
  512. clog("indexed_map",arr,indexed_map)
  513. arr = remap_sort(arr)
  514. arr = remap_sort(arr)
  515. arr = remap_sort(arr)
  516. clog("indexed_map2",arr,indexed_map)
  517. window.sorted_tiles = arr
  518. // for
  519. }
  520. sorted_tiles = window.sorted_tiles || []
  521. function remap_sort(arr){
  522. // return
  523. var k,v
  524. for ([k,v] of indexed_map){
  525. // clog(k,v)
  526. var old_index = arr.indexOf(k)
  527. // clog("K,v",k,v,old_index)
  528. array_move(arr,old_index,v)
  529. // clog(cnt,sorted_tiles.includes(k),v,k)
  530. // cnt += 1
  531. }
  532. return arr
  533. }
  534. function remap_set(vid,loc){
  535. if (typeof(vid)=="number"){
  536. vid = sorted_tiles[vid]
  537. }
  538. var old = reverse_indexed_map.get(loc)
  539. // reverse_indexed_map
  540. indexed_map.delete(old,loc)
  541. indexed_map.set(vid,loc)
  542. reverse_indexed_map.set(loc,vid)
  543. var k,v
  544. var cnt = 0
  545. for ([k,v] of indexed_map){
  546. // clog(k,v)
  547. // clog(cnt,sorted_tiles.includes(k),v,k)
  548. cnt += 1
  549. }
  550. }
  551. // move videos onto the filmstrips
  552. function new_move(){
  553. var j
  554. try {
  555. j = jc(window.sorted_tiles)
  556. } catch (err) {
  557. clog("NEW MOVE err:",err)
  558. }
  559. $(".ic1").append(j.splice(0,5))
  560. // $(".ic2").append(j.splice(0,3))
  561. // $(".ic3").append(j.splice(0,3))
  562. $(".ic2").append(j.splice(0,1))
  563. $(".ic3").append(j.splice(0,1))
  564. $(".ic2").append(j.splice(0,1))
  565. $(".ic3").append(j.splice(0,1))
  566. $(".ic2").append(j.splice(0,1))
  567. $(".ic3").append(j.splice(0,1))
  568. const all_extra = j.splice(0)
  569. if (all_extra.length > 5){
  570. $(".ic6").addClass("overflow")
  571. } else {
  572. $(".ic6").removeClass("overflow")
  573. }
  574. $(".ic6").append(all_extra)
  575. }
  576. // the rest of this slides the bottom row if there is overflow.
  577. timeout_scroll_glob = window.timeout_scroll_glob || {
  578. stop:1,
  579. timeout:3000,
  580. rid:0,
  581. mx_raf:200,
  582. to_left:1,
  583. }
  584. timeout_scroll_glob.stop=1
  585. function timeout_scroll(rid){
  586. // scroll_disabled
  587. return
  588. // clog("Tscroll",rid,timeout_scroll_glob)
  589. if (timeout_scroll_glob.stop || rid != timeout_scroll_glob.rid){
  590. // clog("tscroll stop")
  591. return
  592. }
  593. // clog("tscroll continue")
  594. msto.conference.rotate_index = msto.conference.rotate_index || 0
  595. msto.conference.rotate_index += 1
  596. // scroll_send()
  597. setTimeout(scroll_send,20)
  598. var t = setTimeout(timeout_scroll,timeout_scroll_glob.timeout,rid)
  599. }
  600. function timeout_scroll_start(){
  601. timeout_scroll_glob.rid += 1
  602. setTimeout(timeout_scroll,timeout_scroll_glob.timeout,timeout_scroll_glob.rid)
  603. }
  604. function get_bcrs(arr,fs_bcr){
  605. var ret = {
  606. arr:[],
  607. first_left:0,
  608. first_left_bcr:0,
  609. first_right:0,
  610. first_right_bcr:0,
  611. }
  612. var s = $(".ic6").children(".small_vid")
  613. s.removeClass("ir il ilr ir0 il0")
  614. var k,v,bcr,isleft,isright
  615. for (v of arr){
  616. bcr = v.getBoundingClientRect()
  617. ret.arr.push(bcr)
  618. isleft = bcr.right < (fs_bcr.right + 10)
  619. isright = bcr.left > (fs_bcr.left )
  620. if (isleft && isright){
  621. $(v).addClass("ilr")
  622. } else if (isleft){
  623. $(v).addClass("il")
  624. } else if (isright){
  625. $(v).addClass("ir")
  626. }
  627. if (isleft && ! isright){
  628. ret.first_left = v
  629. ret.first_left_bcr = bcr
  630. }
  631. if ( (! ret.first_right ) && !isleft && isright ){
  632. ret.first_right = v
  633. ret.first_right_bcr = bcr
  634. }
  635. }
  636. clog("````",ret)
  637. $(ret.first_right).addClass("ir0")
  638. $(ret.first_left).addClass("il0")
  639. return ret
  640. }
  641. function scroll_to(n){
  642. var fs,fs_bcr,vid_bcr,ifs
  643. fs = $(".c6")[0]
  644. ifs = $(".ic6")[0]
  645. var vid
  646. var s = $(".ic6").children(".small_vid")
  647. fs_bcr = fs.getBoundingClientRect()
  648. var ov = get_bcrs([...s],fs_bcr)
  649. var tobj = {
  650. }
  651. var scroll_to_vid = 0
  652. if (timeout_scroll_glob.to_left){
  653. if (ov.first_left){
  654. scroll_to_vid = ov.first_left
  655. vid_bcr = ov.first_left_bcr
  656. tobj.inc_mx = vid_bcr.left - fs_bcr.left
  657. tobj.inc = -8
  658. } else {
  659. timeout_scroll_glob.to_left = 0
  660. }
  661. } else {
  662. if (ov.first_right){
  663. scroll_to_vid = ov.first_right
  664. vid_bcr = ov.first_right_bcr
  665. tobj.inc_mx = vid_bcr.right - fs_bcr.right
  666. tobj.inc = 8
  667. } else {
  668. timeout_scroll_glob.to_left = 1
  669. }
  670. }
  671. scroll_to_vid ? requestAnimationFrame(raf.bind(timeout_scroll_glob,fs,scroll_to_vid,tobj.inc,tobj.inc_mx,0,0),"z-index") : 0
  672. }
  673. function raf_clog(fs,vid,cnt,ts){
  674. clog("raf.",cnt,ts)
  675. }
  676. function raf(fs,vid,inc,inc_mx,cnt,ts0,ts){
  677. fs.scrollBy(inc,0)
  678. if (Math.abs(inc) < Math.abs(inc_mx) && cnt < timeout_scroll_glob.mx_raf && ts - (ts0 || ts) < 3000){
  679. requestAnimationFrame(raf.bind(timeout_scroll_glob,fs,vid,inc,inc_mx - inc ,cnt+1,ts0 || ts))
  680. } else {
  681. // clog("FIN",[fs,vid],cnt,ts0,inc_mx,ts,ts-ts0)
  682. vid.scrollIntoView({ behavior: 'smooth', block: 'nearest' ,inline:"nearest"})
  683. }
  684. }
  685. if (window.refresh_fs_proc){
  686. refresh_fs_proc()
  687. }
  688. // $(".video-stream.html5-main-video").play()
  689. // $(".video-stream.html5-main-video").play()
  690. // if ()