File tree Expand file tree Collapse file tree 4 files changed +39
-6
lines changed
Expand file tree Collapse file tree 4 files changed +39
-6
lines changed Original file line number Diff line number Diff line change 1414 "public.noResultsTitle" : " No results" ,
1515 "public.searchTitle" : " \" {query}\" meaning" ,
1616 "public.similarTitle" : " Similar words" ,
17+ "public.playAudio" : " Play audio" ,
1718 "public.subTitle" : " English-Malayalam dictionary" ,
1819 "public.submitEntry" : " Suggest new entry" ,
1920 "public.submitEntryTitle" : " Suggest new entry" ,
Original file line number Diff line number Diff line change 88 < li class ="entry " data-guid ="{{ $r.GUID }} " data-head ="{{ $r.Content | join ", " }}">
99 < header class ="head ">
1010 < div >
11- < h3 class ="title "> {{ $r.Content | join ", " }}
11+ < div class ="title-wrap ">
12+ < h3 class ="title "> {{ $r.Content | join ", " }}</ h3 >
13+
14+ {{- if $r.Meta.audio -}}
15+ < a href ="{{ $r.Meta.audio }} " class ="audio " data-audio > < img src ="/static/audio.svg?v={{ $.AssetVer }} " alt ="{{ $.L.T "public.playAudio " }}"> </ a >
16+ {{- end -}}
17+
1218 {{- if $.Consts.EnableSubmissions -}}
1319 < a href ="# " data-from ="{{ $r.GUID }} " class ="edit " title ="{{ $.L.Ts "public.suggestEdit " "word" (index $r.Content 0) }}"> ✏️</ a >
1420 {{- end -}}
15- </ h3 >
16-
21+ </ div >
1722
1823 {{- if $r.Phones -}}
1924 < span class ="pronun "> ♪ {{ $r.Phones | join "," }}</ span >
Original file line number Diff line number Diff line change @@ -153,6 +153,19 @@ async function screenshotElement(element) {
153153 } ) ;
154154} ) ( ) ;
155155
156+ // Play audio.
157+ ( ( ) => {
158+ document . querySelectorAll ( "a[data-audio]" ) . forEach ( ( el ) => {
159+ el . onclick = ( e ) => {
160+ e . preventDefault ( ) ;
161+ const audio = new Audio ( el . getAttribute ( "href" ) ) ;
162+ audio . play ( ) . catch ( ( err ) => {
163+ console . error ( "error playing audio:" , err ) ;
164+ alert ( "error playing audio" ) ;
165+ } ) ;
166+ } ;
167+ } ) ;
168+ } ) ( ) ;
156169
157170// Submission form.
158171( ( ) => {
Original file line number Diff line number Diff line change @@ -274,6 +274,22 @@ button:hover,
274274 margin : 0 ;
275275}
276276
277+ .entries .title-wrap {
278+ display : flex;
279+ align-items : center;
280+ gap : 10px ;
281+ }
282+
283+ .entries .audio {
284+ display : inline-block;
285+ vertical-align : middle;
286+ cursor : pointer;
287+ transition : ease-in-out 0.035s ;
288+ }
289+ .entries .audio : hover {
290+ transform : scale (1.1 );
291+ }
292+
277293.entries .pronun {
278294 color : var (--light );
279295}
@@ -356,10 +372,8 @@ button:hover,
356372}
357373
358374.entry .edit {
359- color : var (--white );
360- padding : 3px 10px ;
375+ padding : 3px ;
361376 display : none;
362- position : absolute;
363377 text-decoration : none;
364378 z-index : 1000 ;
365379 line-height : 1 ;
You can’t perform that action at this time.
0 commit comments