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.

m.js 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. mod_templates_4 = window.mod_templates_4 || $("")
  2. // reload templates
  3. function html_js_handler_lobby(rsp) {
  4. clog("html_js_handler_lobby",[...arguments])
  5. mod_templates_4 = $(`<span>${rsp}</span>`)
  6. clog("html_js_handler_lobby2")
  7. init_lobby()
  8. clog("html_js_handler_lobby3")
  9. // init_api6()
  10. }
  11. function init_lobby(){
  12. saftly_remove(".plugin_top.lobby_root")
  13. var lroot = mod_templates_4.find(".lobby_root")
  14. lr = $(lroot[0].outerHTML)
  15. clog("...",lr)
  16. // welcome_page
  17. // add_node
  18. // add_node(n,`.vid_toptoolbar_hook`,"append")
  19. // rooms_dir
  20. // lr.find(".rooms_dir")[0].style.height = "600px"
  21. add_node(lr,"#welcome_page","append")
  22. add_tiles()
  23. $(".arrow").click(arrow_click_cb)
  24. $(".tile_button").click(tile_button_cb)
  25. clog("init_lobby........")
  26. // $("#welcome_page").
  27. }
  28. function scroll_rt(n){
  29. var rooms_scroll = $(".rooms_dir_full")
  30. var room_tiles = rooms_scroll.children(".room_span")
  31. room_tiles[n].scrollIntoView({ behavior: 'smooth', block: 'nearest' ,inline:"nearest"})
  32. // room_span
  33. // vid.scrollIntoView({ behavior: 'smooth', block: 'nearest' ,inline:"nearest"})
  34. }
  35. function scroll_rt2(o){
  36. var rooms_scroll = $(".rooms_dir_full")
  37. var room_tiles = rooms_scroll.children(".room_span")
  38. var bcr
  39. var bcr_rooms
  40. var rooms_dir = $(".rooms_dir")
  41. // rooms_scroll
  42. bcr_rooms = rooms_dir[0].getBoundingClientRect()
  43. // clog("~~~",bcr_rooms)
  44. var v_last
  45. var r,l
  46. var r_,l_,r_2,l_2
  47. var c,c2,cr,cl,cr2,cl2
  48. var r2,l2
  49. var cr_n,cr_p,cl_n,cl_p
  50. var cr_nn,cr_pn,cl_nn,cl_pn
  51. cr_n = -Infinity
  52. cl_n = -Infinity
  53. cr_p = Infinity
  54. cl_p = Infinity
  55. cr_nn = ""
  56. cl_nn = ""
  57. cr_pn = ""
  58. cl_pn = ""
  59. $(".nxt").removeClass("nxt")
  60. $(".nxt_x").removeClass("nxt_x")
  61. $(".nxt0").removeClass("nxt0")
  62. $(".nxt1").removeClass("nxt1")
  63. $(".nxt2").removeClass("nxt2")
  64. $(".nxt3").removeClass("nxt3")
  65. for (v of room_tiles){
  66. bcr = v.getBoundingClientRect()
  67. // clog("...",bcr.left - bcr_rooms.left,bcr)
  68. // clog("...",bcr_rooms.left - bcr.left ,bcr)
  69. // clog("...",bcr_rooms.right - bcr.right,bcr_rooms.left - bcr.left ,bcr)
  70. // r = bcr_rooms.right - bcr.right
  71. // l = bcr_rooms.left - bcr.left
  72. // r_ = bcr_rooms.right - bcr.left
  73. // l_ = bcr_rooms.left - bcr.right
  74. c = (bcr.right + bcr.left) / 2
  75. cr = bcr_rooms.right - c
  76. cl = bcr_rooms.left - c
  77. cl = c - bcr_rooms.left
  78. if (cr < 0){
  79. cr_n = Math.max(cr_n,cr)
  80. cr_n == cr ? cr_nn = v : 0
  81. } else {
  82. cr_p = Math.min(cr_p,cr)
  83. cr_p == cr ? cr_pn = v : 0
  84. }
  85. if (cl < 0){
  86. cl_n = Math.max(cl_n,cl)
  87. cl_n == cl ? cl_nn = v : 0
  88. } else {
  89. cl_p = Math.min(cl_p,cl)
  90. cl_p == cl ? cl_pn = v : 0
  91. }
  92. // r2 = r
  93. // l2 = l
  94. // r_2 = r_
  95. // l_2 = l_
  96. c2 = c
  97. cr2 = cr
  98. cl2 = cl
  99. // clog("...",bcr_rooms.right - bcr.right,bcr_rooms.left - bcr.left ,v)
  100. v_last = v
  101. }
  102. // $(cr_nn).addClass("nxt0")
  103. // $(cl_nn).addClass("nxt1")
  104. var scroll_n = ""
  105. if ($(o.that).hasClass("right")){
  106. if (cr_nn){
  107. scroll_n = cr_nn
  108. } else {
  109. scroll_n = cr_np
  110. }
  111. } else if ($(o.that).hasClass("left")){
  112. if (cl_nn){
  113. scroll_n = cl_nn
  114. } else {
  115. scroll_n = cl_np
  116. }
  117. }
  118. if (scroll_n){
  119. scroll_n.scrollIntoView({ behavior: 'smooth', block: 'nearest' ,inline:"nearest"})
  120. // $(scroll_n).addClass("nxt_x")
  121. }
  122. // $(cr_pn).addClass("nxt2")
  123. // $(cl_pn).addClass("nxt3")
  124. // var bcr
  125. }
  126. function arrow_click_cb(e){
  127. scroll_rt2({that:this,e})
  128. // clog("arrow_click_cb",{that:this,e})
  129. }
  130. function tile_button_cb(e){
  131. var rspan = $(this).parents(".room_span")
  132. var room_name = rspan[0].dataset["room"]
  133. // clog("tile_button",rspan[0].dataset["room"],{that:this,e})
  134. // clog("nav",location.pathname + rspan[0].dataset["room"])
  135. if (!room_name){
  136. clog("<>")
  137. return
  138. }
  139. location.assign(location.pathname + rspan[0].dataset["room"])
  140. }
  141. dj_tiles = [
  142. {room:"fisher","img":"fisher.png","title":"Fisher"},
  143. {room:"louis_the_child","img":"louis_the_child.png","title":"Louis The Child"},
  144. {room:"petit_biscuit","img":"petit_biscuit.png","title":"Petit Biscuit"},
  145. {room:"porter_robinson","img":"porter_robinson.png","title":"Porter Robinson"},
  146. ]
  147. // $(".rxt")[0].style.cssText
  148. function add_tiles(){
  149. var rtile = mod_templates_4.find(".room_span.rxt")
  150. var rtile2 = rtile[0].outerHTML
  151. var i,k,v,n
  152. i=0
  153. var djt
  154. while (i < 10){
  155. n = $(rtile2)
  156. djt = dj_tiles[i]
  157. // url("/ign/rf/img/cropped_bak.jpg");
  158. if (djt){
  159. n.css({
  160. // "--vurl":`/ign/rf/artists/${djt["img"]}`,
  161. // "--vurl":`"/ign/rf/artists/${djt["img"]}"`,
  162. "--vurl":`url("/ign/rf/artists/${djt["img"]}")`,
  163. "--vtitle":`"${djt["title"]}"`,
  164. })
  165. clog("zz")
  166. // n[0].cssText += `--vurl:${djt["img"]};`
  167. // n[0].cssText += `--vtitle:"${djt["title"]}"`
  168. n.addClass(`rxz${i}`)
  169. n[0].dataset["room"] = djt["room"]
  170. }
  171. n.addClass(`rx${i}`)
  172. // add_node(n,".rooms_dir","append")
  173. add_node(n,".rooms_dir_full","append")
  174. i+=1
  175. clog("//",i)
  176. }
  177. resize_tiles()
  178. // set_width()
  179. }
  180. function set_width(){
  181. var rdf = $('.rooms_dir_full')
  182. // var totalWidth = 20;
  183. var totalWidth = 0;
  184. rdf.children().each(function(){
  185. totalWidth += $(this).outerWidth();
  186. totalWidth +=px_int($(this).css("margin-left") )
  187. totalWidth +=px_int($(this).css("margin-right"))
  188. // totalWidth += ? :
  189. // totalWidth += ? :
  190. });
  191. rdf.css('width', totalWidth);
  192. }
  193. function px_int(s){
  194. // totalWidth
  195. var a = s.split("px")
  196. var ret = Number(a[0])
  197. ret = ret ? ret : 0
  198. return ret
  199. }
  200. // CLIENT_RESIZED
  201. function resize_tiles(){
  202. try {
  203. var Height= window.innerHeight
  204. var Width= window.innerWidth
  205. var vheight0 = window.innerHeight - 230
  206. var vheight = window.innerHeight - 230
  207. vheight = Math.max(vheight,350)
  208. vheight = Math.min(Height,vheight)
  209. // if
  210. $(".rooms_dir").css({
  211. "--innerHeight":`${window.innerHeight}px`,
  212. "--vheight":`${vheight}px`,
  213. "--innerWidth":`${window.innerWidth}px`,
  214. })
  215. set_width()
  216. }catch(err){}
  217. }
  218. /*
  219. $(document).ready(function(){
  220. var totalWidth = 0;
  221. $('#container').children().each(function(){
  222. totalWidth += $(this).outerWidth();
  223. });
  224. $('#container').css('width', totalWidth);
  225. });
  226. */
  227. glob_mx.qxi_cb["CLIENT_RESIZED"] = window.glob_mx.qxi_cb["CLIENT_RESIZED"] || {}
  228. glob_mx.qxi_cb["CLIENT_RESIZED"].fn = resize_tiles
  229. clog(".....2")
  230. try {
  231. setTimeout(init_lobby,1000)
  232. init_lobby()
  233. } catch (err) {
  234. clog("err:",err)
  235. }