Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. // clog = console.log
  2. // function nop(){}
  3. glob_dev_hooks = window.glob_dev_hooks || {}
  4. glob_dev_fns = window.glob_dev_fns || {}
  5. window.glob_react = window.glob_react || {i:"r0"}
  6. function FS_dec(fn) {
  7. return function() {
  8. dec_fns[fn.name] && dec_fns[fn.name].pre ? dec_fns[fn.name].pre({that:this, arguments}) : 1
  9. const ret = fn.apply(this, arguments);
  10. // console.log('FSD',fn.name,ret, [this,...arguments]);
  11. const ret2 = dec_fns[fn.name] && dec_fns[fn.name].post ? dec_fns[fn.name].post({that:this, arguments}) : 0
  12. if (ret2){
  13. return ret2.ret
  14. }
  15. // const result = fn.apply(this, arguments);
  16. // console.log('Finished');
  17. return ret;
  18. }
  19. }
  20. function save_orig(){
  21. glob_orig = window.glob_orig || {
  22. Filmstrip:{},
  23. fs:{},
  24. rf_filmstrip:{},
  25. }
  26. glob_orig.Filmstrip = Object.assign({},glob_react.Filmstrip)
  27. glob_orig.fs = Object.assign({},glob_react.fs)
  28. glob_orig.rf_filmstrip = Object.assign({},glob_react.rf_filmstrip)
  29. save_orig = nop
  30. }
  31. if (window.glob_orig){
  32. save_orig = nop
  33. // save_orig()
  34. }
  35. if (!window.glob_orig && window.glob_react){
  36. // save_orig = nop
  37. save_orig()
  38. }
  39. if (window.glob_orig && window.glob_react){
  40. dec_fs()
  41. // save_orig = nop
  42. // save_orig()
  43. }
  44. // if ((!window.glob_orig) && ){
  45. // }
  46. // glob_react.rf_filmstrip.calculateThumbnailSizeForTileView
  47. // calculateThumbnailSizeForTileView
  48. dec_fns = {
  49. resizeThumbnailsForTileView:{
  50. pre:function(){
  51. // console.trace("resizeThumbnailsForTileView")
  52. },
  53. post:function(){
  54. },
  55. }
  56. }
  57. function rt(w,h = 0,force = true){
  58. h ? 0 : h = w / (16/9)
  59. glob_react.Filmstrip.resizeThumbnailsForTileView(w,h,force)
  60. }
  61. function dec_fs2(){
  62. var k,v
  63. glob_react.rf_filmstrip.calculateThumbnailSizeForTileView = FS_dec(glob_react.rf_filmstrip.calculateThumbnailSizeForTileView)
  64. // for ([k,v] of Object.entries(glob_orig.Filmstrip)){
  65. // for ([k,v] of Object.entries(glob_react.Filmstrip)){
  66. // clog("~",k,v.name)
  67. // glob_react.Filmstrip[k] = FS_dec(v)
  68. // }
  69. }
  70. function dec_fs(){
  71. var k,v
  72. for ([k,v] of Object.entries(glob_orig.Filmstrip)){
  73. // for ([k,v] of Object.entries(glob_react.Filmstrip)){
  74. clog("~",k,v.name)
  75. glob_react.Filmstrip[k] = FS_dec(v)
  76. }
  77. }
  78. modkeys = ["calculateThumbnailSizeForTileView",
  79. "TILE_VIEW_SIDE_MARGINS",
  80. "SET_TILE_VIEW_DIMENSIONS",]
  81. // glob_react.rf_filmstrip
  82. function check_mod_keys(){
  83. var k
  84. for (k of modkeys){
  85. clog(k,glob_react.rf_filmstrip[k])
  86. }
  87. }
  88. // function setTileViewDimensions_x(dimensions: Object, windowSize: Object) {
  89. function setTileViewDimensions_x() {
  90. // dev hook
  91. if (window.glob_dev_fns && window.glob_dev_fns.setTileViewDimensions){
  92. // var ret = window.glob_dev_fns.setTileViewDimensions.apply(this,...arguments)
  93. var ret = window.glob_dev_fns.setTileViewDimensions({that:this,args:arguments})
  94. if (ret){
  95. return ret.ret
  96. }
  97. }
  98. const thumbnailSize = calculateThumbnailSizeForTileView({
  99. ...dimensions,
  100. ...windowSize
  101. });
  102. const filmstripWidth = dimensions.columns * (TILE_VIEW_SIDE_MARGINS + thumbnailSize.width);
  103. return {
  104. type: SET_TILE_VIEW_DIMENSIONS,
  105. dimensions: {
  106. gridDimensions: dimensions,
  107. xtra:"xtra_val",
  108. thumbnailSize,
  109. filmstripWidth
  110. }
  111. };
  112. }
  113. glob_dev_fns.getTileViewGridDimensions = function(numberOfParticipants,state,maxColumns){
  114. clog("getTileViewGridDimensions....")
  115. }
  116. glob_dev_fns.setTileViewDimensions_x = function(o,dimensions,windowSize,that){
  117. // console.trace("STV")
  118. // SET_TILE_VIEW_DIMENSIONS
  119. windowSize = o.args[1]
  120. dimensions = o.args[0]
  121. clog("glob_dev_fns.setTileViewDimensions",arguments)
  122. var aspect = 16/9
  123. Thumbs = glob_react.Filmstrip._getThumbs()
  124. const topBottomPadding = 200;
  125. const sideMargins = 30 * 2;
  126. var thumbs_count = Thumbs.remoteThumbs.length + Thumbs.localThumb.length
  127. var avail_width = windowSize.clientWidth - sideMargins
  128. var avail_height = windowSize.clientHeight - topBottomPadding
  129. clog("",avail_width,avail_height)
  130. const r1 = avail_width/avail_height
  131. const r0 = aspect
  132. var clo = calc_layout2((avail_width/avail_height)/aspect,thumbs_count)
  133. // calc_layout2
  134. clog(windowSize,dimensions)
  135. var bw = avail_width
  136. var w2,width
  137. // clog(xgrp,xgrp.length,clo)
  138. if ((r1/r0) * (clo.c / clo.r) > 1) {
  139. w2 = bw / ((r1/r0) * clo.c)
  140. } else {
  141. w2 = bw / ( clo.r)
  142. }
  143. // width = 310
  144. // w2 =w2 - 12
  145. w2 =w2 - (10 * aspect)
  146. // w2 =w2 - 15
  147. // w2 =w2 - 16
  148. // width = Math.round(w2)
  149. width = Math.floor(w2)
  150. var height = Math.floor(width / (aspect))
  151. clog(clo)
  152. var avail_width2 = avail_width
  153. // if (clo.ni < clo.n){
  154. // r and c are misnamed!
  155. var col,max_width
  156. if (clo.c == 2){
  157. col = Math.ceil(clo.ni / 2)
  158. max_width = (col + .5) * width
  159. clog("MX...",col ,avail_width2,max_width)
  160. if (max_width < avail_width2){
  161. clog("MX",avail_width2,max_width)
  162. avail_width2 = max_width
  163. }
  164. }
  165. if (clo.ni <= clo.n + clo.c){
  166. // avail_width2 = Math.round(width * clo.)
  167. // avail_width2 = Math.round(avail_width2 - width/2)
  168. }
  169. // return
  170. const SET_TILE_VIEW_DIMENSIONS = "SET_TILE_VIEW_DIMENSIONS"
  171. return {ret:{
  172. type: SET_TILE_VIEW_DIMENSIONS,
  173. dimensions: {
  174. gridDimensions: {columns:clo.c,visibleRows:clo.r,},
  175. xtra:"xtra_val2",
  176. thumbnailSize:{height,width},
  177. filmstripWidth:avail_width2
  178. }
  179. }};
  180. /*
  181. return {
  182. dimensions:{
  183. columns:cl.c,
  184. visibleRows:cl.r,
  185. }
  186. }
  187. */
  188. return {ret:{
  189. type: SET_TILE_VIEW_DIMENSIONS,
  190. dimensions: {
  191. gridDimensions: dimensions,
  192. xtra:"xtra_val",
  193. thumbnailSize,
  194. filmstripWidth
  195. }
  196. }};
  197. }
  198. // ["Filmstrip", "fs", "rf_filmstrip"]
  199. function calc_layout2(a,ni){
  200. var r = 1
  201. var c = 1
  202. var n = 1
  203. clog("mx CL",ni,a)
  204. while (1){
  205. if (r * c < n){
  206. if ( (c + 1) * a < r + 1 ) {
  207. c++
  208. } else {
  209. r++
  210. }
  211. }
  212. n=r*c
  213. if (n >= ni){
  214. break
  215. }
  216. n=n+1
  217. }
  218. clog("CL",ni,r,c,n)
  219. return {
  220. r:r,
  221. c:c,
  222. n:n,
  223. ni:ni,
  224. }
  225. }