-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
clean: use native JS methods instead of JQuery #1845
clean: use native JS methods instead of JQuery #1845
Conversation
src/article_maker.cc
Outdated
// TODO: document why Jquery cannot be removed or can we? | ||
result += R"(<script src="qrc:///scripts/jquery-3.6.0.slim.min.js"></script>)"; | ||
result += R"(<script> var $_$=jQuery.noConflict(); </script>)"; | ||
// TODO: document why noCliflict need to be called. | ||
result += R"(<script> jQuery.noConflict(); </script>)"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have vague memory that says including jQuery actually fixes some dictionaries that forget to include jQuery.
However, I cannot find the source of this claim and the jQuery.noConflict()
seems to nullify this claim.
edit: the claim -> https://forum.freemdict.com/t/topic/11094/14
If we cannot remove jQuery, then we should document this fact here @xiaoyifang .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remembered that some dictionaries will include their own version of JQuery which will conflict with the built-in JQuery.
As far as I know, dictionary makers should not dependent on the gd-ng's built-in jquery , This will limit the dictionary's usage and increase difficulty to be used in other Dictionary Software .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this include is at the header and noConflict
effectively disabled its $
and dictionaries have to include their own one.
I will leave it be for now, there is another place that needs the jQuery
and I will do it later.
src/article_maker.cc
Outdated
<script> | ||
function gd_init_QtWebChannel(){ | ||
new QWebChannel(qt.webChannelTransport, function(channel) { | ||
window.articleview = channel.objects.articleview;}); | ||
console.log("Qt webchannel ready..."); | ||
}; | ||
|
||
if (document.readyState !== "loading") { | ||
gd_init_QtWebChannel(); | ||
} else { | ||
document.addEventListener("DOMContentLoaded", gd_init_QtWebChannel); | ||
}; | ||
</script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should move these from .cc
to .js
. I will probably do it in another PR.
bb80452
to
e9f7b78
Compare
I agree ,it is just a trick to make sure that no others will use the same variable name. |
a596eed
to
98f5bd6
Compare
3226298
to
e4e0967
Compare
There is another |
Quality Gate passedIssues Measures |
I know a tiny bit of jQuery years ago, and I am not motivated to learn it more. Because learning standardized JS can be useful elsewhere but learning jQuery is more or less useless to me.
The
$_$
🤑 is weird. Just usejQuery
, the real symbol.The prettier doesn't work for me locally, I adjusted it a little.