@@ -129,9 +129,12 @@ function showTooltip(e, tooltip) {
129129 if ( e . pageY + 20 < window . innerHeight - tooltipElement . getBoundingClientRect ( ) . height ) {
130130 tooltipElement . style . top = e . pageY + 10 + "px" ;
131131 tooltipElement . style . bottom = '' ;
132- } else {
132+ } else if ( e . pageY - 20 > tooltipElement . getBoundingClientRect ( ) . height ) {
133133 tooltipElement . style . top = '' ;
134134 tooltipElement . style . bottom = window . innerHeight - e . pageY + 10 + "px" ;
135+ } else {
136+ tooltipElement . style . top = 10 + "px" ;
137+ tooltipElement . style . bottom = '' ;
135138 }
136139 tooltipElement . style . opacity = 0.95 ;
137140}
@@ -165,6 +168,7 @@ function registerTooptip(element, tooltip) {
165168function populateYearSelect ( ) {
166169 const now = new Date ( ) ;
167170 const currentYear = now . getFullYear ( ) ;
171+ yearSelect . childNodes . forEach ( n => n . remove ( ) ) ;
168172 for ( let y = currentYear - 1 ; y <= currentYear + 2 ; y ++ ) {
169173 const optCal = document . createElement ( "option" ) ;
170174 optCal . value = `${ y } -01~${ y } -12` ;
@@ -192,27 +196,28 @@ function populateYearSelect() {
192196 * @return {void }
193197 */
194198function renderCountrySelection ( ) {
199+ controls . querySelectorAll ( ".placeholder" ) . forEach ( c => c . remove ( ) )
195200 countries . forEach ( ( code ) => {
196201 const flag = code . toUpperCase ( ) . replace ( / ./ g,
197202 char => String . fromCodePoint ( 127397 + char . charCodeAt ( ) ) ) ;
198- const div = document . createElement ( "div " ) ;
199- div . className = "country-item" ;
203+ const button = document . createElement ( "button " ) ;
204+ button . className = "country-item" ;
200205 if ( selectedCountries . includes ( code ) ) {
201- div . className += " active" ;
206+ button . className += " active" ;
202207 }
203- div . dataset . code = code ;
204- div . innerHTML = `<span>${ flag } </span> <span>${ formatCountryName ( code ) } </span>` ;
205- div . addEventListener ( "click" , async ( ) => {
208+ button . dataset . code = code ;
209+ button . innerHTML = `<span>${ flag } </span> <span>${ formatCountryName ( code ) } </span>` ;
210+ button . addEventListener ( "click" , async ( ) => {
206211 if ( selectedCountries . includes ( code ) ) {
207212 selectedCountries = selectedCountries . filter ( ( x ) => x !== code ) ;
208- div . classList . remove ( "active" ) ;
213+ button . classList . remove ( "active" ) ;
209214 } else {
210215 selectedCountries . push ( code ) ;
211- div . classList . add ( "active" ) ;
216+ button . classList . add ( "active" ) ;
212217 }
213218 await updateCalendar ( ) ;
214219 } ) ;
215- controls . appendChild ( div ) ;
220+ controls . appendChild ( button ) ;
216221 } ) ;
217222}
218223
0 commit comments