mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-22 22:25:28 +01:00
Support preview/codegen for custom currencies in pay button (#2896)
This commit is contained in:
parent
d5c96eee32
commit
ac34109da3
1 changed files with 10 additions and 1 deletions
|
@ -224,8 +224,17 @@ function addInputPrice(name, price, widthInput, customFn, type, min, max, step)
|
|||
}
|
||||
|
||||
function addSelectCurrency(currency) {
|
||||
// Remove all non-alphabet characters from input string and uppercase it for display
|
||||
var safeCurrency = currency.replace(/[^a-z]/gi, '').toUpperCase();
|
||||
var defaultCurrencies = ['USD', 'GBP', 'EUR', 'BTC'];
|
||||
var options = defaultCurrencies.map(c => ' <option value="' + c + '"' + (c === safeCurrency ? ' selected' : '') + '>' + c + '</option>');
|
||||
// If user provided a currency not in our default currencies list, add it to the top of the options as a selected option
|
||||
if (defaultCurrencies.indexOf(safeCurrency) === -1) {
|
||||
options.unshift(' <option value="' + safeCurrency + '" selected>' + safeCurrency + '</option>')
|
||||
}
|
||||
|
||||
return ' <select name="currency">\n' +
|
||||
['USD', 'GBP', 'EUR', 'BTC'].map(c => ' <option value="' + c + '"' + (c === currency ? ' selected' : '') + '>' + c + '</option>').join('\n') + '\n' +
|
||||
options.join('\n') + '\n' +
|
||||
' </select>\n'
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue