Home.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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. <h4 class="modal-title">Register</h4>
  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. <h4 class="modal-title">Login</h4>
  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. </div>
  34. <div class="modal-footer">
  35. <button type="button" class="btn btn-primary" data-dismiss="modal" @click="this.$dispatch('login');">Submit</button>
  36. </div>
  37. </div>
  38. </div>
  39. </div>
  40. <div class="group" v-for="group in groups">
  41. <div class="group-title">{{group.name}}</div>
  42. <div class="group-rooms">
  43. <div class="rooms-room" v-for="room in group.rooms" v-link="{ path: '/station' }">
  44. <img class="room-image" :src="room.thumbnail" />
  45. <div class="room-info">
  46. <div class="room-grid-left">
  47. <h3>{{ room.name }}</h3>
  48. <p>{{ room.description }}</p>
  49. </div>
  50. <div class="room-grid-right">
  51. <div>{{ room.users }}&nbsp;&nbsp;<i class="fa fa-user" aria-hidden="true"></i></div>
  52. </div>
  53. </div>
  54. </div>
  55. </div>
  56. </div>
  57. <main-footer></main-footer>
  58. </div>
  59. </template>
  60. <script>
  61. import MainHeader from '../components/MainHeader.vue'
  62. import MainFooter from '../components/MainFooter.vue'
  63. export default {
  64. data() {
  65. return {
  66. home: {
  67. visible: true
  68. },
  69. station: {
  70. visible: false
  71. },
  72. register: {
  73. email: "",
  74. username: "",
  75. password: ""
  76. },
  77. login: {
  78. email: "",
  79. password: ""
  80. },
  81. loggedIn: true,
  82. groups: [
  83. {
  84. id: "lu08gw56571r4497wrk9",
  85. name: "Official Rooms",
  86. rooms: [
  87. { 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 },
  88. { id: "enxcysmhn1k7ld56ogvi", thumbnail: "http://66.media.tumblr.com/1734069af425e491fae7deae0a19869f/tumblr_o0i0xmIYrF1v421f2o1_1280.jpg", name: "Pop", description: "Sia - Cheap Thrills", users: 14 },
  89. { 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 },
  90. { 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 }
  91. ]
  92. },
  93. {
  94. id: "g2b8v03xaedj8ht1emi",
  95. name: "Trending Rooms",
  96. rooms: [
  97. { 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 },
  98. { id: "enxcysmhn1k7ld56ogvi", thumbnail: "http://66.media.tumblr.com/1734069af425e491fae7deae0a19869f/tumblr_o0i0xmIYrF1v421f2o1_1280.jpg", name: "Pop", description: "Sia - Cheap Thrills", users: 14 },
  99. { 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 },
  100. { 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 }
  101. ]
  102. }
  103. ]
  104. }
  105. },
  106. methods: {
  107. logout() {
  108. $.ajax({
  109. method: "GET",
  110. url: "/users/logout",
  111. dataType: "json",
  112. complete: function (msg) {
  113. console.log(1, msg);
  114. alert("Logged out!");
  115. //do something
  116. location.reload();
  117. }
  118. });
  119. }
  120. },
  121. ready: function () {
  122. this.socket = io();
  123. this.socket.on("ready", function(loggedIn) {
  124. this.loggedIn = loggedIn;
  125. });
  126. },
  127. components: { MainHeader, MainFooter },
  128. events: {
  129. 'register': function() {
  130. console.log('registered');
  131. $.ajax({
  132. method: "POST",
  133. url: "/users/register",
  134. data: JSON.stringify({
  135. email: this.register.email,
  136. username: this.register.username,
  137. password: this.register.password,
  138. recaptcha: grecaptcha.getResponse()
  139. }),
  140. contentType: "application/json; charset=utf-8",
  141. dataType: "json",
  142. success: function (msg) {
  143. console.log(1, msg);
  144. alert("Registered!");
  145. //do something
  146. },
  147. error: function (errormessage) {
  148. console.log(2, errormessage);
  149. alert("Not registered!");
  150. //do something else
  151. }
  152. });
  153. },
  154. 'login': function() {
  155. console.log('login');
  156. $.ajax({
  157. method: "POST",
  158. url: "/users/login",
  159. data: JSON.stringify({
  160. email: this.login.email,
  161. password: this.login.password
  162. }),
  163. contentType: "application/json; charset=utf-8",
  164. dataType: "json",
  165. success: function (msg) {
  166. console.log(1, msg);
  167. alert("Logged in!");
  168. //do something
  169. location.reload();
  170. },
  171. error: function (errormessage) {
  172. console.log(2, errormessage);
  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. </style>