mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 04:24:09 +00:00
jquery noconflict()
This commit is contained in:
parent
70c972ddc2
commit
ccc0f275ba
|
@ -57,6 +57,9 @@ std::string ArticleMaker::makeHtmlHeader( QString const & word,
|
||||||
result += "<script type=\"text/javascript\" "
|
result += "<script type=\"text/javascript\" "
|
||||||
"src=\"qrc:///resources/jquery-3.6.0.slim.min.js\"></script>";
|
"src=\"qrc:///resources/jquery-3.6.0.slim.min.js\"></script>";
|
||||||
|
|
||||||
|
result += "<script>"
|
||||||
|
"var $_$=$.noConflict(true);"
|
||||||
|
"</script>";
|
||||||
//custom javascript
|
//custom javascript
|
||||||
result += "<script type=\"text/javascript\" "
|
result += "<script type=\"text/javascript\" "
|
||||||
"src=\"qrc:///resources/gd_custom.js\"></script>";
|
"src=\"qrc:///resources/gd_custom.js\"></script>";
|
||||||
|
@ -70,13 +73,13 @@ std::string ArticleMaker::makeHtmlHeader( QString const & word,
|
||||||
|
|
||||||
// document ready ,init webchannel
|
// document ready ,init webchannel
|
||||||
{
|
{
|
||||||
// var _JS = { 'jQuery': jQuery.noConflict(true) };
|
|
||||||
result += "<script>"
|
result += "<script>"
|
||||||
" $(document).ready( function (){ "
|
" $_$(document).ready( function ($){ "
|
||||||
" console.log(\"document ready,init webchannel\"); "
|
" console.log(\"webchannel ready...\"); "
|
||||||
" new QWebChannel(qt.webChannelTransport, function "
|
" new QWebChannel(qt.webChannelTransport, function "
|
||||||
"(channel) { "
|
"(channel) { "
|
||||||
" window.articleview = channel.objects.articleview; "
|
" window.articleview = channel.objects.articleview; "
|
||||||
|
" articleview.onJsActiveArticleChanged(gdCurrentArticle);"
|
||||||
" }); "
|
" }); "
|
||||||
" }); "
|
" }); "
|
||||||
"</script>";
|
"</script>";
|
||||||
|
@ -664,8 +667,8 @@ void ArticleRequest::bodyFinished()
|
||||||
} else {
|
} else {
|
||||||
// This is the first article
|
// This is the first article
|
||||||
head += "<script type=\"text/javascript\">"
|
head += "<script type=\"text/javascript\">"
|
||||||
"var gdCurrentArticle=\"" + gdFrom + "\"; "
|
"var gdCurrentArticle=\"" + gdFrom + "\"; "
|
||||||
"articleview.onJsActiveArticleChanged(gdCurrentArticle)</script>";
|
"</script>";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool collapse = false;
|
bool collapse = false;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
//document ready ,
|
//document ready
|
||||||
|
(function($){
|
||||||
$(function() {
|
$(function() {
|
||||||
$("a").click(function(event) {
|
$("a").click(function(event) {
|
||||||
var link = $(this).attr("href");
|
var link = $(this).attr("href");
|
||||||
|
@ -8,10 +9,10 @@ $(function() {
|
||||||
|
|
||||||
var newLink;
|
var newLink;
|
||||||
var href = window.location.href;
|
var href = window.location.href;
|
||||||
|
var index=-1;
|
||||||
if (link.startsWith("#")) {
|
if (link.startsWith("#")) {
|
||||||
//the href may contain # fragment already.remove them before append the new #fragment
|
//the href may contain # fragment already.remove them before append the new #fragment
|
||||||
var index = href.indexOf("#");
|
index = href.indexOf("#");
|
||||||
if(index>-1)
|
if(index>-1)
|
||||||
{
|
{
|
||||||
newLink = href.substring(0, index) + link;
|
newLink = href.substring(0, index) + link;
|
||||||
|
@ -20,7 +21,7 @@ $(function() {
|
||||||
newLink= href+link;
|
newLink= href+link;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var index = href.indexOf("?");
|
index = href.indexOf("?");
|
||||||
if(index>-1)
|
if(index>-1)
|
||||||
{
|
{
|
||||||
newLink = href.substring(0, index) + "?word=" + link;
|
newLink = href.substring(0, index) + "?word=" + link;
|
||||||
|
@ -33,10 +34,10 @@ $(function() {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
});
|
||||||
|
})($_$);
|
||||||
|
|
||||||
);
|
|
||||||
function playSound(sound) {
|
function playSound(sound) {
|
||||||
var a = new Audio(sound);
|
var a = new Audio(sound);
|
||||||
a.play();
|
a.play();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue