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.

152 lines
3.4 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="nextDay"
  12. v-on:swiperight="previousDay"
  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. previousDay() {
  50. this.when === 1 ? (this.when = 6) : this.when--
  51. },
  52. nextDay() {
  53. this.when === 6 ? (this.when = 1) : this.when++
  54. }
  55. },
  56. filters: {
  57. noBreak(value) {
  58. return value.replace(/\s/g, '\u00a0')
  59. }
  60. },
  61. computed: {
  62. where: {
  63. get() {
  64. return this.$store.state.where
  65. },
  66. set(value) {
  67. this.$store.dispatch('loadMeals', {
  68. when: this.when,
  69. where: value
  70. })
  71. }
  72. },
  73. when: {
  74. get() {
  75. return this.$store.state.when
  76. },
  77. set(value) {
  78. this.$store.dispatch('loadMeals', {
  79. when: value,
  80. where: this.where
  81. })
  82. }
  83. }
  84. },
  85. created() {
  86. this.$store.dispatch('loadMeals', {
  87. when: this.when,
  88. where: this.where
  89. })
  90. let vm = this
  91. document.onkeydown = evt => {
  92. evt = evt || window.event
  93. switch (evt.keyCode) {
  94. case 37:
  95. if (vm.selWhen !== document.activeElement) {
  96. // increment only if selection is not focused, avoid double execution
  97. vm.previousDay()
  98. }
  99. break
  100. case 39:
  101. if (vm.selWhen !== document.activeElement) {
  102. // increment only if selection is not focused, avoid double execution
  103. vm.nextDay()
  104. break
  105. }
  106. }
  107. }
  108. },
  109. mounted() {
  110. this.selWhen = document.getElementById('selWhen')
  111. }
  112. }
  113. </script>
  114. <style src="./assets/base.css">
  115. </style>
  116. <style src="./assets/links.css">
  117. </style>
  118. <style>
  119. #app {
  120. font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
  121. Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
  122. -webkit-font-smoothing: antialiased;
  123. -moz-osx-font-smoothing: grayscale;
  124. text-align: center;
  125. color: #2c3e50;
  126. font-size: 16px;
  127. max-width: 30em;
  128. margin: 0 auto;
  129. }
  130. footer {
  131. margin: 1em 0;
  132. }
  133. footer > div {
  134. margin: 0.5em;
  135. }
  136. nav > a {
  137. margin: 0.3em;
  138. wrap: no-wrap;
  139. }
  140. .router-link-active:before {
  141. content: '>';
  142. }
  143. .router-link-active:after {
  144. content: '<';
  145. }
  146. </style>