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.

147 lines
3.2 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
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. <router-view></router-view>
  11. <footer>
  12. <hr>
  13. <div>
  14. <span>
  15. Developed by <a href="https://webschneider.org">webschneider.org</a>
  16. &copy; {{ new Date().getFullYear() }}
  17. </span>
  18. <span><a href="https://webschneider.org/impress">Impressum</a></span><br>
  19. <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>
  20. </div>
  21. </footer>
  22. </div>
  23. </template>
  24. <script>
  25. import Mensen from '@/lib/Mensen.js'
  26. export default {
  27. name: 'app',
  28. data() {
  29. return {
  30. selWhen: {},
  31. mensen: Mensen,
  32. days: [1, 2, 3, 4, 5, 6],
  33. dayOfWeek: {
  34. 1: 'Montag',
  35. 2: 'Dienstag',
  36. 3: 'Mittwoch',
  37. 4: 'Donnerstag',
  38. 5: 'Freitag',
  39. 6: 'Samstag'
  40. }
  41. }
  42. },
  43. methods: {
  44. previousDay() {
  45. this.when === 1 ? (this.when = 6) : this.when--
  46. },
  47. nextDay() {
  48. this.when === 6 ? (this.when = 1) : this.when++
  49. }
  50. },
  51. filters: {
  52. noBreak(value) {
  53. return value.replace(/\s/g, '\u00a0')
  54. }
  55. },
  56. computed: {
  57. where: {
  58. get() {
  59. return this.$store.state.where
  60. },
  61. set(value) {
  62. this.$store.dispatch('loadMeals', {
  63. when: this.when,
  64. where: value
  65. })
  66. }
  67. },
  68. when: {
  69. get() {
  70. return this.$store.state.when
  71. },
  72. set(value) {
  73. this.$store.dispatch('loadMeals', {
  74. when: value,
  75. where: this.where
  76. })
  77. }
  78. }
  79. },
  80. created() {
  81. this.$store.dispatch('loadMeals', {
  82. when: this.when,
  83. where: this.where
  84. })
  85. let vm = this
  86. document.onkeydown = evt => {
  87. evt = evt || window.event
  88. switch (evt.keyCode) {
  89. case 37:
  90. if (vm.selWhen !== document.activeElement) {
  91. // increment only if selection is not focused, avoid double execution
  92. vm.previousDay()
  93. }
  94. break
  95. case 39:
  96. if (vm.selWhen !== document.activeElement) {
  97. // increment only if selection is not focused, avoid double execution
  98. vm.nextDay()
  99. break
  100. }
  101. }
  102. }
  103. },
  104. mounted() {
  105. this.selWhen = document.getElementById('selWhen')
  106. }
  107. }
  108. </script>
  109. <style src="./assets/base.css">
  110. </style>
  111. <style src="./assets/links.css">
  112. </style>
  113. <style>
  114. #app {
  115. font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
  116. Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
  117. -webkit-font-smoothing: antialiased;
  118. -moz-osx-font-smoothing: grayscale;
  119. text-align: center;
  120. color: #2c3e50;
  121. font-size: 16px;
  122. max-width: 30em;
  123. margin: 0 auto;
  124. }
  125. footer {
  126. margin: 1em 0;
  127. }
  128. footer > div {
  129. margin: 0.5em;
  130. }
  131. nav > a {
  132. margin: 0.3em;
  133. wrap: no-wrap;
  134. }
  135. .router-link-active:before {
  136. content: '>';
  137. }
  138. .router-link-active:after {
  139. content: '<';
  140. }
  141. </style>