38 lines
842 B
JavaScript
38 lines
842 B
JavaScript
|
|
/** @typedef { import('types/CreditsObject.js').CreditsObject} CreditsObject */
|
||
|
|
|
||
|
|
export function Credits(){
|
||
|
|
return {
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Credits. Preloaded at startup.
|
||
|
|
* @type {CreditsObject[]}
|
||
|
|
*/
|
||
|
|
credits: [],
|
||
|
|
|
||
|
|
/**
|
||
|
|
*
|
||
|
|
* @param {string|null} jsonCredits
|
||
|
|
*/
|
||
|
|
init( jsonCredits= null ){
|
||
|
|
if( jsonCredits !== null ){
|
||
|
|
this.credits = JSON.parse(jsonCredits);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Add an empty credit.
|
||
|
|
*/
|
||
|
|
addEmptyCredits() {
|
||
|
|
this.credits.push({name: '', description: ''});
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Remove a specific credits.
|
||
|
|
* @param {number} index index of credit.
|
||
|
|
*/
|
||
|
|
removeCredits( index ){
|
||
|
|
this.credits.splice(index, 1);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|