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.

class_dec.js 9.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. GLOB_ORIG = "glob_orig_v2"
  2. function FS_dec_proto_v2(fn,fn_name) {
  3. return function() {
  4. clog("fdp0",fn_name,glob_react.Filmstrip._getThumbs())
  5. dec_fns[fn_name] && dec_fns[fn_name].pre ? dec_fns[fn_name].pre({that:this, arguments}) : 1
  6. if (fn_name == "updateDOMLocation") {
  7. this.updateDOMLocation2()
  8. }
  9. const ret = fn.apply(this, arguments);
  10. // console.log('FSD',fn_name,ret, [this,...arguments]);
  11. // console.log('FSD',fn_name);
  12. // console.trace('FSD_trc '+fn_name);
  13. // log_tb()
  14. // window.log_tb(new Error(),fn_name)
  15. // clog("rtscv1",glob_react.Filmstrip._getThumbs())
  16. // resizeThumbnailsForCustomView(this,fn_name,arguments)
  17. clog("fdp2",fn_name,glob_react.Filmstrip._getThumbs())
  18. const ret2 = dec_fns[fn_name] && dec_fns[fn_name].post ? dec_fns[fn_name].post({that:this, arguments}) : 0
  19. if (ret2){
  20. return ret2.ret
  21. }
  22. // const result = fn.apply(this, arguments);
  23. // console.log('Finished');
  24. // clog("rtscv2",glob_react.Filmstrip._getThumbs())
  25. return ret;
  26. }
  27. }
  28. function undec_class_v2(cls,cls_orig,cname){
  29. var k,v
  30. var proto = cls_orig
  31. // var proto = glob_react.vidClass.LocalVideo.prototype
  32. // for ([k,v] of iter_desc(proto)){
  33. for ([k,v] of Object.entries(proto)){
  34. // glob_react.Filmstrip[k] = v
  35. // clog(k,v)
  36. cls.prototype[k] = v.value
  37. // clog(k,v)
  38. }
  39. }
  40. function _method_dec_v2(fn,fn_name){
  41. return function() {
  42. // clog("fdp0",fn_name,glob_react.Filmstrip._getThumbs())
  43. const ret1 = dec_fns[fn_name] && dec_fns[fn_name].pre ? dec_fns[fn_name].pre({that:this, args:arguments}) : 0
  44. // if (fn_name == "updateDOMLocation") {
  45. // this.updateDOMLocation2()
  46. // }
  47. if (ret1){
  48. return ret1.ret
  49. }
  50. const ret = fn.apply(this, arguments);
  51. // clog("MDV2",fn_name,{that:this, args:arguments,ret:ret})
  52. // clog("MDV2 xyz",fn_name,{that:this, args:arguments,ret:ret})
  53. // console.log('FSD',fn_name,ret, [this,...arguments]);
  54. // console.log('FSD',fn_name);
  55. // console.trace('FSD_trc '+fn_name);
  56. // log_tb()
  57. // window.log_tb(new Error(),fn_name)
  58. // clog("rtscv1",glob_react.Filmstrip._getThumbs())
  59. // resizeThumbnailsForCustomView(this,fn_name,arguments)
  60. // clog("fdp2",fn_name,glob_react.Filmstrip._getThumbs())
  61. const ret2 = dec_fns[fn_name] && dec_fns[fn_name].post ? dec_fns[fn_name].post({that:this, arguments}) : 0
  62. // clog("MDEX",{ret1,ret2})
  63. if (ret2){
  64. return ret2.ret
  65. }
  66. // const result = fn.apply(this, arguments);
  67. // console.log('Finished');
  68. // clog("rtscv2",glob_react.Filmstrip._getThumbs())
  69. return ret;
  70. }
  71. }
  72. function _method_dec_v2_1(fn,fn_name,cname){
  73. return function() {
  74. window.sv_trc ? sv_trc({fn_name,cname,that:this,args:[...arguments]}) : 0
  75. // const ret1 = dec_fns[fn_name] && dec_fns[fn_name].pre ? dec_fns[fn_name].pre({that:this, args:arguments}) : 0
  76. // const ret1 = dec_fns[fn_name] && dec_fns[fn_name].pre ? dec_fns[fn_name].pre.call(this,[{that:this, args:arguments}]) : 0
  77. const ret1 = dec_fns[fn_name] && dec_fns[fn_name].pre ? dec_fns[fn_name].pre.apply(this,[{that:this, args:arguments}]) : 0
  78. if (ret1){
  79. return ret1.ret
  80. }
  81. const ret = fn.apply(this, arguments);
  82. const ret2 = dec_fns[fn_name] && dec_fns[fn_name].post ? dec_fns[fn_name].post({that:this, arguments}) : 0
  83. // clog("MDEX",{ret1,ret2})
  84. if (ret2){
  85. return ret2.ret
  86. }
  87. return ret;
  88. }
  89. }
  90. function _method_dec_v2_2(fn,fn_name){
  91. return function() {
  92. const ret1 = dec_fns[fn_name] && dec_fns[fn_name].pre ? dec_fns[fn_name].pre({that:this, args:arguments}) : 0
  93. if (ret1){
  94. return ret1.ret
  95. }
  96. const ret = fn.apply(this, arguments);
  97. const ret2 = dec_fns[fn_name] && dec_fns[fn_name].post ? dec_fns[fn_name].post({that:this, arguments}) : 0
  98. // clog("MDEX",{ret1,ret2})
  99. if (ret2){
  100. return ret2.ret
  101. }
  102. return ret;
  103. }
  104. }
  105. function dec_class_v2(cls,cls_orig,cname){
  106. clog("trc dec_class_v2",cname,{cls,cls_orig,cname})
  107. var k,v
  108. var proto = cls_orig
  109. // var proto = glob_react.vidClass.LocalVideo.prototype
  110. // for ([k,v] of iter_desc(proto)){
  111. for ([k,v] of Object.entries(proto)){
  112. // glob_react.Filmstrip[k] = v
  113. // clog(k,v)
  114. cls.prototype[k] = _method_dec_v2(v.value,k)
  115. // clog(k,v)
  116. }
  117. }
  118. function dec_class_v2_1(cls,cls_orig,cname){
  119. clog("trc dec_class_v2",cname,{cls,cls_orig,cname})
  120. var k,v
  121. var proto = cls_orig
  122. // var proto = glob_react.vidClass.LocalVideo.prototype
  123. // for ([k,v] of iter_desc(proto)){
  124. for ([k,v] of Object.entries(proto)){
  125. // glob_react.Filmstrip[k] = v
  126. // clog(k,v)
  127. cls.prototype[k] = _method_dec_v2_1(v.value,k,cname)
  128. // clog(k,v)
  129. }
  130. }
  131. function save_orig_class(cls){
  132. var i,k,v
  133. var i2,k2,v2
  134. var o
  135. var ret = {}
  136. // o = glob_react.vidClass.LocalVideo.prototype
  137. // o = tobj
  138. // o = glob_react.vidClass.LocalVideo
  139. // for ([k,v] of Object.entries(glob_react.vidClass)){
  140. // for ([k,v] of Object.entries(o)){
  141. // for ([k2,v2] of Object.entries(glob_react.vidClass)){
  142. // for ([k2,v2] of Object.entries(classes)){
  143. // clog("...",k2)
  144. // ret[k2] = {}
  145. o = cls.prototype
  146. for ([k,v] of iter_desc(o)){
  147. // clog(k,v)
  148. ret[k]=v
  149. // clog(k2,k,v)
  150. }
  151. // }
  152. // clog("><",Object.getOwnPropertyDescriptors(o))
  153. return ret
  154. }
  155. // dec_fns
  156. function init_cdec(){
  157. let runonce = !window[GLOB_ORIG]
  158. // runonce = 1
  159. // if (!window[GLOB_ORIG]){
  160. // }
  161. window[GLOB_ORIG] = window[GLOB_ORIG] || {
  162. classes:{}
  163. }
  164. cdec.glob_orig = window[GLOB_ORIG]
  165. if (runonce){
  166. window[GLOB_ORIG].classes["SharedVideoManager"] = cdec.get_class_methods(glob_react.SharedVideoManager)
  167. window[GLOB_ORIG].classes["SharedVideoContainer"] = cdec.get_class_methods(glob_react.SharedVideoContainer)
  168. //
  169. }
  170. }
  171. function undec_svm(){
  172. cdec.undec_class(glob_react.SharedVideoManager,cdec.glob_orig.classes.SharedVideoManager)
  173. }
  174. function dec_svm(){
  175. cdec.dec_class(glob_react.SharedVideoManager,cdec.glob_orig.classes.SharedVideoManager,"SharedVideoManager")
  176. cdec.dec_class(glob_react.SharedVideoContainer,cdec.glob_orig.classes.SharedVideoContainer,"SharedVideoContainer")
  177. }
  178. // function dec_svm(){}
  179. function onSharedVideoUpdate_mod(id, url, attributes) {
  180. // if we are sending the event ignore
  181. if (APP.conference.isLocalId(this.from)) {
  182. return;
  183. }
  184. if (!this.isSharedVideoShown) {
  185. this.onSharedVideoStart(id, url, attributes);
  186. return;
  187. }
  188. // eslint-disable-next-line no-negated-condition
  189. if (!this.player) {
  190. this.initialAttributes = attributes;
  191. } else {
  192. this.processVideoUpdate(this.player, attributes);
  193. }
  194. }
  195. dec_fns_v2 = {
  196. fireSharedVideoEvent:{
  197. pre(o) {
  198. // return
  199. const sendPauseEvent = o.args[0]
  200. const UIEvents = glob_react.UIEvents
  201. clog("fireSharedVideoEventx",this,o,o.args[0],[...arguments])
  202. // return {}
  203. // return
  204. // ignore update checks if we are not the owner of the video
  205. // or there is still no player defined or we are stopped
  206. // (in a process of stopping)
  207. if (!APP.conference.isLocalId(this.from) || !this.player
  208. || !this.isSharedVideoShown) {
  209. // return;
  210. return {};
  211. }
  212. const state = this.player.getPlayerState();
  213. // if its paused and haven't been pause - send paused
  214. if (state === YT.PlayerState.PAUSED && sendPauseEvent) {
  215. this.emitter.emit(UIEvents.UPDATE_SHARED_VIDEO,
  216. this.url, 'pause', this.player.getCurrentTime());
  217. } else if (state === YT.PlayerState.PLAYING) {
  218. // if its playing and it was paused - send update with time
  219. // if its playing and was playing just send update with time
  220. this.emitter.emit(UIEvents.UPDATE_SHARED_VIDEO,
  221. this.url, 'playing',
  222. this.player.getCurrentTime(),
  223. this.player.isMuted(),
  224. this.player.getVolume(),);
  225. // this.player.getVolume(),"xtra_var");
  226. }
  227. return {};
  228. }
  229. },
  230. onSharedVideoUpdate:{
  231. pre(o){
  232. try {
  233. if (!o.that.player){
  234. window.autoplay_probably_disabled ? autoplay_probably_disabled(o) : clog("NO fix implemented")
  235. // window.autoplay_probably_disabled ? autoplay_probably_disabled(o) : clog("NO fix implemented2")
  236. clog("...autoplay_probably_disabled...")
  237. } else {
  238. // clog("yt_dbg AUTO")
  239. }
  240. /*
  241. clog("onSharedVideoUpdate pre arg",[...o.args])
  242. // clog("onSharedVideoUpdate pre",o.args[2],o.that.isSharedVideoShown,!this.player)
  243. clog("onSharedVideoUpdate pre",o.args[2],!o.that.isSharedVideoShown,!o.that.player)
  244. // onSharedVideoUpdate_mod.apply(o.that, o.args);
  245. try {
  246. clog("osvu player",o.that.player)
  247. o.that.player.g.g.playerVars
  248. } catch (err){
  249. clog("osvu err")
  250. }
  251. clog("onSharedVideoUpdate...",o.that.player)
  252. */
  253. // return {}
  254. } catch (err){clog("dec fn err svm",err)}
  255. // return onSharedVideoUpdate_mod.apply(o.that, o.args);
  256. // return onSharedVideoUpdate_mod.apply(o.that, o.args);
  257. },
  258. post_x(o){
  259. try {
  260. // clog("onSharedVideoUpdate post",o)
  261. } catch (err){clog("dec fn err svm")}
  262. },
  263. }
  264. }
  265. // clog("TRC_ <!--#echo var='request_filename' -->",'<!--#echo var="uri" -->')
  266. clog("TRC_2 ",'<!--#echo var="request_filename" -->'.split("/").pop())
  267. cdec = {
  268. get_class_methods:save_orig_class,
  269. undec_class:undec_class_v2,
  270. // dec_class:dec_class_v2,
  271. dec_class:dec_class_v2_1,
  272. glob_orig:window[GLOB_ORIG],
  273. }
  274. dec_fns = window.dec_fns || {}
  275. Object.assign(dec_fns,dec_fns_v2)
  276. init_cdec()
  277. dec_svm()