Home.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <template>
  2. <div class="app">
  3. <main-header></main-header>
  4. <div class="modal fade" id="register" tabindex="-1" role="dialog" aria-labelledby="register-modal">
  5. <div class="modal-dialog" role="document">
  6. <div class="modal-content">
  7. <div class="modal-header">
  8. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  9. <h5 class="modal-title">Register</h5>
  10. </div>
  11. <div class="modal-body">
  12. <input class="form-control" type="text" placeholder="Email..." v-model="register.email"/>
  13. <input class="form-control" type="text" placeholder="Username..." v-model="register.username"/>
  14. <input class="form-control" type="password" placeholder="Password..." v-model="register.password"/>
  15. <div class="g-recaptcha" data-sitekey="6LdNCQcUAAAAANj_w5leQSrxnAmDp2ioh4alkUHg"></div>
  16. </div>
  17. <div class="modal-footer">
  18. <button type="button" class="btn btn-primary" data-dismiss="modal" @click="this.$dispatch('register');">Submit</button>
  19. </div>
  20. </div>
  21. </div>
  22. </div>
  23. <div class="modal fade" id="login" tabindex="-1" role="dialog" aria-labelledby="login-modal">
  24. <div class="modal-dialog" role="document">
  25. <div class="modal-content">
  26. <div class="modal-header">
  27. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  28. <h5 class="modal-title">Login</h5>
  29. </div>
  30. <div class="modal-body">
  31. <input class="form-control" type="text" placeholder="Email..." v-model="login.email"/>
  32. <input class="form-control" type="password" placeholder="Password..." v-model="login.password"/>
  33. <hr />
  34. <a class="btn btn-block btn-default btn-github" href="/users/github"><i class="fa fa-github"></i> Login with GitHub</a>
  35. <a class="btn btn-block btn-default btn-discord" href="/users/discord">Login with Discord</a>
  36. </div>
  37. <div class="modal-footer">
  38. <button type="button" class="btn btn-primary" data-dismiss="modal" @click="this.$dispatch('login');">Submit</button>
  39. </div>
  40. </div>
  41. </div>
  42. </div>
  43. <div class="group" v-for="group in groups">
  44. <div class="group-title">{{group.name}}</div>
  45. <div class="group-rooms">
  46. <div class="rooms-room" v-for="room in group.rooms" v-link="{ path: '/station' }">
  47. <img class="room-image" :src="room.thumbnail" />
  48. <div class="room-info">
  49. <div class="room-grid-left">
  50. <h3>{{ room.name }}</h3>
  51. <p>{{ room.description }}</p>
  52. </div>
  53. <div class="room-grid-right">
  54. <div>{{ room.users }}&nbsp;&nbsp;<i class="fa fa-user" aria-hidden="true"></i></div>
  55. </div>
  56. </div>
  57. </div>
  58. </div>
  59. </div>
  60. <main-footer></main-footer>
  61. </div>
  62. </template>
  63. <script>
  64. import MainHeader from '../components/MainHeader.vue'
  65. import MainFooter from '../components/MainFooter.vue'
  66. export default {
  67. data() {
  68. return {
  69. home: {
  70. visible: true
  71. },
  72. station: {
  73. visible: false
  74. },
  75. register: {
  76. email: "",
  77. username: "",
  78. password: ""
  79. },
  80. login: {
  81. email: "",
  82. password: ""
  83. },
  84. loggedIn: true,
  85. groups: [
  86. {
  87. id: "lu08gw56571r4497wrk9",
  88. name: "Official Rooms",
  89. rooms: [
  90. { id: "73qvw65746acvo8yqfr", thumbnail: "https://lh6.googleusercontent.com/-ghASz3s6yL4/AAAAAAAAAAI/AAAAAAAAALc/tFblPp2myu0/s0-c-k-no-ns/photo.jpg", name: "Country", description: "Johnny Cash - I Walk The Line", users: 10 },
  91. { id: "enxcysmhn1k7ld56ogvi", thumbnail: "http://66.media.tumblr.com/1734069af425e491fae7deae0a19869f/tumblr_o0i0xmIYrF1v421f2o1_1280.jpg", name: "Pop", description: "Sia - Cheap Thrills", users: 14 },
  92. { id: "kqa99gbva7lij05dn29", thumbnail: "http://www.youredm.com/wp-content/uploads/2014/09/taking-you-higher.jpg", name: "Chill", description: "MrSuicideSheep - Taking you higher", users: 13 },
  93. { id: "w19hu791iiub6wmjf9a4i", thumbnail: "http://edmsauce.wpengine.netdna-cdn.com/wp-content/uploads/2012/12/Deadmau5-album-title-goes-here.jpg", name: "EDM", description: "Deadmau5 - There Might Be Coffee", users: 13 }
  94. ]
  95. },
  96. {
  97. id: "g2b8v03xaedj8ht1emi",
  98. name: "Trending Rooms",
  99. rooms: [
  100. { id: "73qvw65746acvo8yqfr", thumbnail: "https://lh6.googleusercontent.com/-ghASz3s6yL4/AAAAAAAAAAI/AAAAAAAAALc/tFblPp2myu0/s0-c-k-no-ns/photo.jpg", name: "Country", description: "Johnny Cash - I Walk The Line", users: 10 },
  101. { id: "enxcysmhn1k7ld56ogvi", thumbnail: "http://66.media.tumblr.com/1734069af425e491fae7deae0a19869f/tumblr_o0i0xmIYrF1v421f2o1_1280.jpg", name: "Pop", description: "Sia - Cheap Thrills", users: 14 },
  102. { id: "kqa99gbva7lij05dn29", thumbnail: "http://www.youredm.com/wp-content/uploads/2014/09/taking-you-higher.jpg", name: "Chill", description: "MrSuicideSheep - Taking you higher", users: 13 },
  103. { id: "w19hu791iiub6wmjf9a4i", thumbnail: "http://edmsauce.wpengine.netdna-cdn.com/wp-content/uploads/2012/12/Deadmau5-album-title-goes-here.jpg", name: "EDM", description: "Deadmau5 - There Might Be Coffee", users: 13 }
  104. ]
  105. }
  106. ]
  107. }
  108. },
  109. methods: {
  110. logout() {
  111. $.ajax({
  112. method: "GET",
  113. url: "/users/logout",
  114. dataType: "json",
  115. complete: function (msg) {
  116. alert("Logged in!");
  117. location.reload();
  118. }
  119. });
  120. }
  121. },
  122. ready: function () {
  123. this.socket = io();
  124. this.socket.on("ready", function(status) {
  125. this.loggedIn = status;
  126. });
  127. },
  128. components: { MainHeader, MainFooter },
  129. events: {
  130. 'register': function() {
  131. console.log('registered');
  132. $.ajax({
  133. method: "POST",
  134. url: "/users/register",
  135. data: JSON.stringify({
  136. email: this.register.email,
  137. username: this.register.username,
  138. password: this.register.password,
  139. recaptcha: grecaptcha.getResponse()
  140. }),
  141. contentType: "application/json; charset=utf-8",
  142. dataType: "json",
  143. success: function (msg) {
  144. if (msg) console.log(msg);
  145. alert("Registered!");
  146. //do something
  147. },
  148. error: function (err) {
  149. if (err) console.log(err);
  150. alert("Not registered!");
  151. //do something else
  152. }
  153. });
  154. },
  155. 'login': function() {
  156. console.log('login');
  157. $.ajax({
  158. method: "POST",
  159. url: "/users/login",
  160. data: JSON.stringify({
  161. email: this.login.email,
  162. password: this.login.password
  163. }),
  164. contentType: "application/json; charset=utf-8",
  165. dataType: "json",
  166. success: function (msg) {
  167. if (msg) console.log(msg);
  168. alert("Logged in!");
  169. //do something
  170. },
  171. error: function (err) {
  172. if (err) console.log(err);
  173. alert("Not logged in!");
  174. //do something else
  175. }
  176. });
  177. }
  178. }
  179. }
  180. </script>
  181. <style lang="sass">
  182. * { box-sizing: border-box; font-family: Roboto, sans-serif; }
  183. html {
  184. width: 100%;
  185. height: 100%;
  186. color: rgba(0, 0, 0, 0.87);
  187. body {
  188. width: 100%;
  189. height: 100%;
  190. margin: 0;
  191. padding: 0;
  192. }
  193. }
  194. @media only screen and (min-width: 1200px) {
  195. html {
  196. font-size: 15px;
  197. }
  198. }
  199. @media only screen and (min-width: 992px) {
  200. html {
  201. font-size: 14.5px;
  202. }
  203. }
  204. @media only screen and (min-width: 0) {
  205. html {
  206. font-size: 14px;
  207. }
  208. }
  209. .g-recaptcha {
  210. display: flex;
  211. justify-content: center;
  212. margin-top: 10px;
  213. }
  214. .group {
  215. width: 100%;
  216. height: 448px;
  217. margin: 64px 0 64px 0;
  218. .group-title {
  219. float: left;
  220. clear: none;
  221. width: 100%;
  222. height: 64px;
  223. line-height: 48px;
  224. text-align: center;
  225. font-size: 48px;
  226. }
  227. .group-rooms {
  228. white-space: nowrap;
  229. text-align: center;
  230. overflow: hidden;
  231. float: left;
  232. clear: none;
  233. width: 100%;
  234. height: 384px;
  235. .rooms-room {
  236. position: relative;
  237. top: 16px;
  238. display: inline-block;
  239. clear: none;
  240. width: 256px;
  241. height: 345px;
  242. margin: 0 16px 0 16px;
  243. box-shadow: 0 1px 6px 2px rgba(0, 0, 0, 0.25);
  244. cursor: pointer;
  245. .room-info {
  246. display: flex;
  247. flex-direction: row;
  248. align-items: center;
  249. padding: 5px;
  250. }
  251. .room-image {
  252. width: 100%;
  253. height: 256px;
  254. }
  255. .room-grid-left {
  256. display: flex;
  257. flex-direction: column;
  258. width: 75%;
  259. text-align: left;
  260. padding-left: 10px;
  261. h3, p {
  262. margin: 0;
  263. white-space: normal;
  264. }
  265. }
  266. .room-grid-right {
  267. display: flex;
  268. flex-direction: column;
  269. width: 25%;
  270. }
  271. }
  272. }
  273. }
  274. .btn-github {
  275. background-color: #333;
  276. color: #fff;
  277. border: 0;
  278. &:hover, &:active, &:focus {
  279. background-color: darken(#333, 5%);
  280. color: #fff;
  281. }
  282. }
  283. .btn-discord {
  284. background-color: #7289DA;
  285. color: #fff;
  286. border: 0;
  287. &:hover, &:active, &:focus {
  288. background-color: darken(#7289DA, 5%);
  289. color: #fff;
  290. }
  291. }
  292. </style>