[ticket/17100] Remove inline javascript from lang select

PHPBB3-17100
This commit is contained in:
Marc Alexander 2022-02-25 21:37:56 +01:00
parent 4846723bb6
commit fb1899de62
No known key found for this signature in database
GPG key ID: 50E0D2423696F995

View file

@ -3,22 +3,10 @@
<!-- IF S_SHOW_COPPA or S_REGISTRATION --> <!-- IF S_SHOW_COPPA or S_REGISTRATION -->
{% if lang_options|length > 0 %} {% if lang_options|length > 0 %}
<script>
/**
* Change language
*/
function change_language(lang_iso)
{
document.cookie = '{COOKIE_NAME}_lang=' + lang_iso + '; path={COOKIE_PATH}';
document.forms['register'].change_lang.value = lang_iso;
document.forms['register'].submit();
}
</script>
<form method="post" action="{S_UCP_ACTION}" id="register"> <form method="post" action="{S_UCP_ACTION}" id="register">
<p class="rightside"> <p class="rightside">
<label for="lang">{L_LANGUAGE}{L_COLON}</label> <label for="lang">{{ lang('LANGUAGE') ~ lang('COLON') }}</label>
<select name="lang" id="lang" onchange="change_language(this.value); return false;" title="{L_LANGUAGE}"> <select name="lang" id="lang" title="{{ lang('LANGUAGE') }}">
{% for option in lang_options %} {% for option in lang_options %}
<option value="{{ option.LANG_ISO }}"{% if option.SELECTED %} selected="selected"{% endif %}>{{ option.LANG_LOCAL_NAME }}</option> <option value="{{ option.LANG_ISO }}"{% if option.SELECTED %} selected="selected"{% endif %}>{{ option.LANG_LOCAL_NAME }}</option>
{% endfor %} {% endfor %}
@ -29,6 +17,17 @@
<div class="clear"></div> <div class="clear"></div>
<script>
/**
* Change language on change
*/
document.querySelector('#lang').addEventListener('change', (event) => {
const langIso = event.target.value;
document.cookie = '{{ COOKIE_NAME }}_lang=' + langIso + '; path={{ COOKIE_PATH }}';
document.forms['register'].change_lang.value = langIso;
document.forms['register'].submit();
});
</script>
{% endif %} {% endif %}
<form method="post" action="{S_UCP_ACTION}" id="agreement"> <form method="post" action="{S_UCP_ACTION}" id="agreement">