a
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
const bilder = [
|
||||
{
|
||||
dateiname: "robot.png",
|
||||
beschreibung: "Frida Kahlo painting of a robot waving goodbye",
|
||||
},
|
||||
{
|
||||
dateiname: "meadow.png",
|
||||
beschreibung:
|
||||
"A photo of a wide green meadow and a clear blue sky",
|
||||
},
|
||||
{
|
||||
dateiname: "elephant.png",
|
||||
beschreibung: "A pink elephant in a small room",
|
||||
},
|
||||
{
|
||||
dateiname: "fhdortmund.png",
|
||||
beschreibung: "An expressive oil painting of FH Dortmund in summer",
|
||||
},
|
||||
];
|
||||
|
||||
// Hier den Code ergaenzen!
|
||||
module.exports = {
|
||||
holeStartBild: function () {
|
||||
return {
|
||||
bild: bilder[0],
|
||||
index: 0,
|
||||
};
|
||||
},
|
||||
|
||||
vor: function (aktuellerIndex) {
|
||||
const neuerIndex = (aktuellerIndex + 1) % bilder.length;
|
||||
return {
|
||||
bild: bilder[neuerIndex],
|
||||
index: neuerIndex,
|
||||
};
|
||||
},
|
||||
|
||||
zurueck: function (aktuellerIndex) {
|
||||
let neuerIndex = aktuellerIndex - 1;
|
||||
if (neuerIndex < 0) {
|
||||
neuerIndex = bilder.length - 1;
|
||||
}
|
||||
return {
|
||||
bild: bilder[neuerIndex],
|
||||
index: neuerIndex,
|
||||
};
|
||||
},
|
||||
|
||||
holeBildMitIndex: function (index) {
|
||||
const validIndex = Math.max(0, Math.min(index, bilder.length - 1));
|
||||
return {
|
||||
bild: bilder[validIndex],
|
||||
index: validIndex,
|
||||
};
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user