play sound in the dictionary html

This commit is contained in:
yifang 2021-09-23 13:05:05 +08:00
parent bec982c51e
commit bf2640bb25
3 changed files with 10 additions and 6 deletions

View file

@ -668,11 +668,16 @@ void ArticleRequest::bodyFinished()
}
}
//todo ,gdArticleContents应该可以用类变量保存。
//todo ,gdArticleContents need refractor in the future?
string jsVal = Html::escapeForJavaScript( dictId );
head += "<script type=\"text/javascript\">var gdArticleContents; "
"if ( !gdArticleContents ) gdArticleContents = \"" + jsVal +" \"; "
"else gdArticleContents += \"" + jsVal + " \";</script>";
"else gdArticleContents += \"" + jsVal + " \";"
"function playSound(sound){"
" var a=new Audio(sound);"
" a.play();"
"}"
"</script>";
head += string( "<div class=\"gdarticle" ) +
( closePrevSpan ? "" : " gdactivearticle" ) +

View file

@ -1700,8 +1700,6 @@ void ArticleView::playSound()
" } "
" "
" var music = new Audio(link); "
" music.muted=true; "
" music.play(); "
);

5
dsl.cc
View file

@ -906,8 +906,9 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node )
result += addAudioLink( ref, getId() );
result += "<span class=\"dsl_s_wav\"><a href=" + ref
+ "><img src=\"qrcx://localhost/icons/playsound.png\" border=\"0\" align=\"absmiddle\" alt=\"Play\"/></a></span>";
string surl=url.toEncoded().data();
result += "<span class=\"dsl_s_wav\"><a onclick=\"playSound('"+surl+"')\" href= \"javascript:void(0)\" ><img src=\"qrcx://localhost/icons/playsound.png\" border=\"0\" align=\"absmiddle\" alt=\"Play\"/></a></span>";
}
else
if ( Filetype::isNameOfPicture( filename ) )