Merge branch 'master' into pirate-patch-3

This commit is contained in:
timvisee 2021-05-19 11:30:50 +02:00
commit 1d6872e279
No known key found for this signature in database
GPG key ID: B8DB720BC383E172
3 changed files with 41 additions and 30 deletions

View file

@ -31,12 +31,11 @@ module.exports = function(state, emit) {
counts,
num => state.translate('downloadCount', { num }),
value => {
const max = state.user.maxDownloads;
state.archive.dlimit = Math.min(value, max);
if (value > max) {
emit('signup-cta', 'count');
} else {
emit('render');
const selected = parseInt(value);
state.archive.dlimit = selected;
emit('render');
if (selected > parseInt(state.user.maxDownloads || '0')) {
console.log('Chosen max download count is larger than the allowed limit', selected)
}
},
'expire-after-dl-count-select'
@ -58,12 +57,11 @@ module.exports = function(state, emit) {
return state.translate(l10n.id, l10n);
},
value => {
const max = state.user.maxExpireSeconds;
state.archive.timeLimit = Math.min(value, max);
if (value > max) {
emit('signup-cta', 'time');
} else {
emit('render');
const selected = parseInt(value);
state.archive.timeLimit = selected;
emit('render');
if (selected > parseInt(state.user.maxExpireSeconds || '0')) {
console.log('Chosen download expiration is larger than the allowed limit', selected)
}
},
'expire-after-time-select'

View file

@ -1,32 +1,28 @@
const html = require('choo/html');
module.exports = function(selected, options, translate, changed, htmlId) {
let x = selected;
function choose(event) {
if (event.target.value != selected) {
console.log('Selected new value from dropdown', htmlId, ':', selected, '->', event.target.value)
changed(event.target.value);
}
}
return html`
<select
id="${htmlId}"
class="appearance-none cursor-pointer border rounded bg-grey-10 hover:border-blue-50 focus:border-blue-50 pl-1 pr-8 py-1 my-1 h-8 dark:bg-grey-80"
data-selected="${selected}"
onchange="${choose}"
>
${options.map(
i =>
value =>
html`
<option value="${i}" ${i === selected ? 'selected' : ''}
>${translate(i)}</option
>
<option value="${value}" ${value == selected ? 'selected' : ''}>
${translate(value)}
</option>
`
)}
</select>
`;
function choose(event) {
const target = event.target;
const value = +target.value;
if (x !== value) {
x = value;
changed(value);
}
}
};