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.

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