Speiseplan der Mensen der Georg-August-Universität Göttingen https://mensa.schneider-hosting.de
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.

172 lines
3.9 KiB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. <template>
  2. <div id="app">
  3. <h1>Essen in Göttingen</h1>
  4. Wo? <select v-model="where">
  5. <option v-for="mensa in mensen" :value="mensa.url">{{mensa.name}}</option>
  6. </select>
  7. Wann? <select v-model="when" id="selWhen">
  8. <option v-for="day in days" :value="day" :key="day">{{dayOfWeek[day]}}</option>
  9. </select>
  10. <v-touch
  11. v-on:swipeleft="swipePrevious"
  12. v-on:swiperight="swipeNext"
  13. v-bind:swipe-options="{ direction: 'horizontal' }">
  14. <router-view></router-view>
  15. </v-touch>
  16. <footer>
  17. <hr>
  18. <div>
  19. <span>
  20. Developed by <a href="https://webschneider.org">webschneider.org</a>
  21. &copy; {{ new Date().getFullYear() }}
  22. </span>
  23. <span><a href="https://webschneider.org/impress">Impressum</a></span><br>
  24. <span>Icons made by <a href="https://www.flaticon.com/authors/smashicons">Smashicons</a> from <a href="https://www.flaticon.com">www.flaticon.com</a></span>
  25. </div>
  26. </footer>
  27. </div>
  28. </template>
  29. <script>
  30. import Mensen from '@/lib/Mensen.js'
  31. export default {
  32. name: 'app',
  33. data() {
  34. return {
  35. selWhen: {},
  36. mensen: Mensen,
  37. days: [1, 2, 3, 4, 5, 6],
  38. dayOfWeek: {
  39. 1: 'Montag',
  40. 2: 'Dienstag',
  41. 3: 'Mittwoch',
  42. 4: 'Donnerstag',
  43. 5: 'Freitag',
  44. 6: 'Samstag'
  45. }
  46. }
  47. },
  48. methods: {
  49. swipeNext() {
  50. window._paq.push(['trackEvent', 'Navigation', 'NextDay', 'swipe'])
  51. this.nextDay()
  52. },
  53. swipePrevious() {
  54. window._paq.push(['trackEvent', 'Navigation', 'PreviousDay', 'swipe'])
  55. this.previousDay()
  56. },
  57. previousDay() {
  58. this.when === 1 ? (this.when = 6) : this.when--
  59. },
  60. nextDay() {
  61. this.when === 6 ? (this.when = 1) : this.when++
  62. }
  63. },
  64. filters: {
  65. noBreak(value) {
  66. return value.replace(/\s/g, '\u00a0')
  67. }
  68. },
  69. computed: {
  70. where: {
  71. get() {
  72. return this.$store.state.where
  73. },
  74. set(value) {
  75. this.$store.dispatch('loadMeals', {
  76. when: this.when,
  77. where: value
  78. })
  79. }
  80. },
  81. when: {
  82. get() {
  83. return this.$store.state.when
  84. },
  85. set(value) {
  86. this.$store.dispatch('loadMeals', {
  87. when: value,
  88. where: this.where
  89. })
  90. }
  91. }
  92. },
  93. created() {
  94. let where = window.localStorage.getItem('mensa_where')
  95. if (where !== null) {
  96. this.where = where
  97. }
  98. this.$store.dispatch('loadMeals', {
  99. when: this.when,
  100. where: this.where
  101. })
  102. let vm = this
  103. document.onkeydown = evt => {
  104. evt = evt || window.event
  105. switch (evt.keyCode) {
  106. case 37:
  107. if (vm.selWhen !== document.activeElement) {
  108. // increment only if selection is not focused, avoid double execution
  109. window._paq.push([
  110. 'trackEvent',
  111. 'Navigation',
  112. 'PreviousDay',
  113. 'arrow'
  114. ])
  115. vm.previousDay()
  116. }
  117. break
  118. case 39:
  119. if (vm.selWhen !== document.activeElement) {
  120. // increment only if selection is not focused, avoid double execution
  121. window._paq.push(['trackEvent', 'Navigation', 'NextDay', 'arrow'])
  122. vm.nextDay()
  123. break
  124. }
  125. }
  126. }
  127. },
  128. mounted() {
  129. this.selWhen = document.getElementById('selWhen')
  130. }
  131. }
  132. </script>
  133. <style src="./assets/base.css">
  134. </style>
  135. <style src="./assets/links.css">
  136. </style>
  137. <style>
  138. #app {
  139. font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
  140. Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
  141. -webkit-font-smoothing: antialiased;
  142. -moz-osx-font-smoothing: grayscale;
  143. text-align: center;
  144. color: #2c3e50;
  145. font-size: 16px;
  146. max-width: 30em;
  147. margin: 0 auto;
  148. }
  149. footer {
  150. margin: 1em 0;
  151. }
  152. footer > div {
  153. margin: 0.5em;
  154. }
  155. nav > a {
  156. margin: 0.3em;
  157. wrap: no-wrap;
  158. }
  159. .router-link-active:before {
  160. content: '>';
  161. }
  162. .router-link-active:after {
  163. content: '<';
  164. }
  165. </style>