REST Service for POPCORN - ILIAS
alex
2025-06-06 beb0698a28d4700876a5f63cf4e484595813e20f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<script setup>
 
import * as itemOffset from '../lib/itemOffset.js'
import {onKeyStroke} from "@vueuse/core"
 
const props = defineProps({
   total: Number,
   offset: Number,
   limit: Number,
})
 
const emit = defineEmits(["go"])
 
function goStart () {
   const offset2 = itemOffset.goStart(props.offset, props.limit, props.total)
   emit("go", offset2)
}
 
function goEnd () {
   const offset2 = itemOffset.goEnd(props.offset, props.limit, props.total)
   emit("go", offset2)
}
 
function goPrev (multiplier = 1) {
   const offset2 = itemOffset.goPrev(props.offset, props.limit * multiplier, props.total)
   emit("go", offset2)
}
 
function goNext (multiplier = 1) {
   const offset2 = itemOffset.goNext(props.offset, props.limit * multiplier, props.total)
   emit("go", offset2)
}
 
/////// KEYBOARD ////////////////////////////////////////////////////////////////
 
onKeyStroke(["ArrowLeft", "ArrowRight", "Home", "End"], (e) => {
   let multiplier = 1
   switch (e.key) {
      case "ArrowLeft":
         multiplier = e.shiftKey ? 10 : 1
         goPrev(multiplier)
         break
      case "ArrowRight":
         multiplier = e.shiftKey ? 10 : 1
         goNext(multiplier)
         break
      case "Home":
         goStart()
         break
      case "End":
         goEnd()
         break
   }
})
 
 
</script>
 
<template>
 
   <div class="pagination">
      <input type="button" @click="goStart()" class="start" value="«">
      <input type="button" @click="goPrev()" class="prev" value="‹">
      <span class="current">
         {{ offset }} - {{ offset + limit }}
          / {{ total }}
      </span>
      <input type="button" @click="goNext()" class="next" value="›">
      <input type="button" @click="goEnd()" class="end" value="»">
   </div>
 
</template>
 
<style scoped lang="stylus">
 
.pagination
   font-size 1.33rem
   display flex;
   gap 1em
   align-items center;
   justify-content center;
   margin -1em 0 1em 0;
 
   & > div
      cursor: pointer
      color #6464b5
      font-weight bold;
 
      &:hover
         color orange
 
.start, .end, .prev, .next
   font-size 130%
 
//width 1em
.current
   width 12em;
   text-align center;
 
input
   //all: unset
   border none
   width 1em
 
</style>