]>
git.immae.eu Git - github/shaarli/Shaarli.git/blob - tpl/vintage/js/shaarli.js
1 window
.onload = function () {
2 var continent
= document
.getElementById('continent');
3 var city
= document
.getElementById('city');
4 if (continent
!= null && city
!= null) {
5 continent
.addEventListener('change', function(event
) {
6 hideTimezoneCities(city
, continent
.options
[continent
.selectedIndex
].value
, true);
8 hideTimezoneCities(city
, continent
.options
[continent
.selectedIndex
].value
, false);
13 * Add the class 'hidden' to city options not attached to the current selected continent.
15 * @param cities List of <option> elements
16 * @param currentContinent Current selected continent
17 * @param reset Set to true to reset the selected value
19 function hideTimezoneCities(cities
, currentContinent
, reset
= false) {
21 [].forEach
.call(cities
, function(option
) {
22 if (option
.getAttribute('data-continent') != currentContinent
) {
23 option
.className
= 'hidden';
25 option
.className
= '';
26 if (reset
=== true && first
=== true) {
27 option
.setAttribute('selected', 'selected');