const html = require('choo/html');
const Component = require('choo/component');
class Footer extends Component {
constructor(name, state) {
super(name);
this.state = state;
}
update() {
return false;
}
createElement() {
const translate = this.state.translate;
// Add additional links from configuration if available
var links = [];
if (this.state != undefined && this.state.WEB_UI != undefined) {
const WEB_UI = this.state.WEB_UI;
if (WEB_UI.FOOTER_DONATE_URL != '') {
links.push(html`
${translate('footerLinkDonate')}
`);
}
if (WEB_UI.FOOTER_CLI_URL != '') {
links.push(html`
${translate('footerLinkCli')}
`);
}
if (WEB_UI.FOOTER_DMCA_URL != '') {
links.push(html`
${translate('footerLinkDmca')}
`);
}
if (WEB_UI.FOOTER_SOURCE_URL != '') {
links.push(html`
${translate('footerLinkSource')}
`);
}
} else {
links.push(html`
${translate('footerLinkSource')}
`);
}
// Defining a custom footer
var footer = [];
if (this.state != undefined && this.state.WEB_UI != undefined) {
const WEB_UI = this.state.WEB_UI;
if (WEB_UI.CUSTOM_FOOTER_URL != '' && WEB_UI.CUSTOM_FOOTER_TEXT != '') {
footer.push(html`
${WEB_UI.CUSTOM_FOOTER_TEXT}
`);
}
else if (WEB_UI.CUSTOM_FOOTER_URL != '') {
footer.push(html`
${WEB_UI.CUSTOM_FOOTER_URL}
`);
}
else if (WEB_UI.CUSTOM_FOOTER_TEXT != '') {
footer.push(html`
${WEB_UI.CUSTOM_FOOTER_TEXT}
`)
}
else {
footer.push(html`
${translate('footerText')}
`);
}
}
return html`
`;
}
}
module.exports = Footer;