REST Service for POPCORN - ILIAS
alex
2025-10-23 9297f199f384b8f257a80c6254d335724705d995
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<script setup>
 
import * as itemOffset from '../lib/itemOffset.js'
import {onKeyStroke} from "@vueuse/core"
import IconKeyboard from "@/components/icons/IconKeyboard.vue"
import KeyboardToggle from "@/components/KeyboardToggle.vue"
import {ref} from "vue"
 
const props = defineProps({
   total: Number,
   offset: Number,
   limit: Number,
   current: 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", "ArrowUp", "ArrowDown"], (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 "ArrowUp":
         goStart()
         break
      case "ArrowDown":
         goEnd()
         break
   }
})
 
/////// keyboard ////////////////////////////////////////////////////////////////
 
const keyboardVisible = ref(false)
function toggleKeyboard (value) {
   console.log("toggleKeyboard", value)
   keyboardVisible.value = value
}
 
</script>
 
<template>
 
   <div class="pagination">
      <div class="pagination-buttons">
<!--         <pre>&#45;&#45;{{current}}&#45;&#45;</pre>-->
         <input type="button" @click="goStart()" class="start" value="«">
         <input type="button" @click="goPrev()" class="prev" value="‹">
         <span class="current">{{ offset }} - {{ offset + current }} / {{ total }}</span>
         <input type="button" @click="goNext()" class="next" value="›">
         <input type="button" @click="goEnd()" class="end" value="»">
         <KeyboardToggle :initial="false" @toggle="toggleKeyboard" style="color: #666" />
      </div>
      <small class="pagination-info" v-show="keyboardVisible">
         <em>Keyboard control:</em>
         <span class="spacer" />
         <kbd class="bigger">&ltri;</kbd> previous page
         <span class="spacer" />
         <kbd class="bigger">&rtri;</kbd> next page
         <span class="spacer" />
         <kbd>SHIFT</kbd> + <kbd class="bigger">&ltri;</kbd> {{limit * 10}} backward
         <span class="spacer" />
         <kbd>SHIFT</kbd> + <kbd class="bigger">&rtri;</kbd> {{limit * 10}} forward
         <span class="spacer" />
         <kbd class="bigger">&utri;</kbd> start
         <span class="spacer" />
         <kbd class="bigger">&dtri;</kbd> end
      </small>
   </div>
 
</template>
 
<style scoped lang="stylus">
 
.pagination-info
   margin-top .5em;
   display flex;
   gap .5em
   padding .33em .66em;
   align-items center;
   background-color #f1f1f1
   .spacer
      width 2em;
      height 1px
      display inline-block;
      //background-color black
 
kbd
   border 1px solid #777
   border-radius 4px
   font-size 120%;
   line-height 50%
   min-width 1rem;
   height 1rem
   padding 3px;
   display inline-flex;
   align-items center;
   justify-content center;
 
kbd.bigger
   font-size 220%
   line-height 0
 
 
.pagination
   display flex;
   flex-direction column
   align-items center;
.pagination-buttons
   font-size 1.33rem
   display flex;
   gap 1em
   align-items center;
   justify-content center;
 
   & > 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
input[type=button]
   color rgb(0,0,238)
   cursor pointer;
   &:hover
      background-color #ddd;
 
 
button
   display inline-flex;
   align-items center;
   justify-content center;
   border none
   background-color transparent;
   cursor pointer
   &:hover
      background-color #eee;
 
 
</style>