mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 23:34:06 +00:00
fix: js undefined error (#1298)
* fix: js undefined error * [autofix.ci] apply automated fixes --------- Co-authored-by: YiFang Xiao <yifang.xiao@noreply.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
8ea4ef84d9
commit
fb85f68b21
|
@ -674,8 +674,8 @@ void ArticleRequest::bodyFinished()
|
||||||
fmt::format_to( std::back_inserter( head ),
|
fmt::format_to( std::back_inserter( head ),
|
||||||
FMT_COMPILE(
|
FMT_COMPILE(
|
||||||
R"( <div class="gdarticle {0} {1}" id="{2}"
|
R"( <div class="gdarticle {0} {1}" id="{2}"
|
||||||
onClick="gdMakeArticleActive( '{3}', false );"
|
onClick="if(typeof gdMakeArticleActive !='undefined') gdMakeArticleActive( '{3}', false );"
|
||||||
onContextMenu="gdMakeArticleActive( '{3}', false );">)" ),
|
onContextMenu="if(typeof gdMakeArticleActive !='undefined') gdMakeArticleActive( '{3}', false );">)" ),
|
||||||
closePrevSpan ? "" : " gdactivearticle",
|
closePrevSpan ? "" : " gdactivearticle",
|
||||||
collapse ? " gdcollapsedarticle" : "",
|
collapse ? " gdcollapsedarticle" : "",
|
||||||
gdFrom,
|
gdFrom,
|
||||||
|
|
|
@ -555,9 +555,10 @@ bool ArticleView::setCurrentArticle( QString const & id, bool moveToIt )
|
||||||
QString dictId = id.mid( 7 );
|
QString dictId = id.mid( 7 );
|
||||||
if ( dictId.isEmpty() )
|
if ( dictId.isEmpty() )
|
||||||
return false;
|
return false;
|
||||||
QString script = QString(
|
QString script =
|
||||||
|
QString(
|
||||||
"var elem=document.getElementById('%1'); "
|
"var elem=document.getElementById('%1'); "
|
||||||
"if(elem!=undefined){elem.scrollIntoView(true);} gdMakeArticleActive('%2',true);" )
|
"if(elem!=undefined){elem.scrollIntoView(true);} if(typeof gdMakeArticleActive !='undefined') gdMakeArticleActive('%2',true);" )
|
||||||
.arg( id, dictId );
|
.arg( id, dictId );
|
||||||
onJsActiveArticleChanged( id );
|
onJsActiveArticleChanged( id );
|
||||||
webview->page()->runJavaScript( script );
|
webview->page()->runJavaScript( script );
|
||||||
|
|
Loading…
Reference in a new issue