clean: use vanilla JS instead of jQuery
Some checks are pending
SonarCloud / Build and analyze (push) Waiting to run

This commit is contained in:
shenleban tongying 2024-10-21 00:52:49 -04:00 committed by GitHub
parent ad6a0472cc
commit e6edd34c3a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 43 additions and 31 deletions

View file

@ -29,8 +29,7 @@ jobs:
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
brew install clang-format
(/home/linuxbrew/.linuxbrew/opt/clang-format/bin/git-clang-format --binary=/home/linuxbrew/.linuxbrew/opt/clang-format/bin/clang-format --style=file HEAD^) || true
- uses: autofix-ci/action@89762f9c25dd85f6b78cd40e521232e403357ec0
- uses: autofix-ci/action@ff86a557419858bb967097bfc916833f5647fa8c
css-js-html-format:
@ -39,16 +38,6 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- uses: actions/setup-node@v4
with:
node-version: 16
- run: npm ci
- run: npx prettier --write src/stylesheets src/scripts/gd-*.js
# Optimize all PNGs with https://pngquant.org/
# - run: sudo apt-get update && sudo apt-get install -y pngquant
# - name: Run pngquant
# run: |
# shopt -s globstar
# pngquant -f --ext .png --skip-if-larger -- **/*.png
- uses: autofix-ci/action@89762f9c25dd85f6b78cd40e521232e403357ec0
- run: npx prettier . --write
- uses: autofix-ci/action@ff86a557419858bb967097bfc916833f5647fa8c

View file

@ -1,2 +1,12 @@
**/.clang-format
# ignore all
/**/*.*
# unignore js and cssfiles
!**/*.js
!**/*.css
# reignore other js files
**/*.min.js
**/iframe-defer.js
**/mark.js
**/darkreader.js

View file

@ -1 +1 @@
{}

12
package-lock.json generated
View file

@ -5,19 +5,23 @@
"packages": {
"": {
"devDependencies": {
"prettier": "3.0.0"
"prettier": "3"
}
},
"node_modules/prettier": {
"version": "3.0.0",
"resolved": "https://registry.npmmirror.com/prettier/-/prettier-3.0.0.tgz",
"integrity": "sha512-zBf5eHpwHOGPC47h0zrPyNn+eAEIdEzfywMoYn2XPi0P44Zp0tSq64rq0xAREh4auw2cJZHo9QUob+NqCQky4g==",
"version": "3.3.3",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz",
"integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==",
"dev": true,
"license": "MIT",
"bin": {
"prettier": "bin/prettier.cjs"
},
"engines": {
"node": ">=14"
},
"funding": {
"url": "https://github.com/prettier/prettier?sponsor=1"
}
}
}

View file

@ -1,5 +1,5 @@
{
"devDependencies": {
"prettier": "3.0.0"
"prettier": "3"
}
}

View file

@ -50,7 +50,8 @@ std::string ArticleMaker::makeHtmlHeader( QString const & word, QString const &
// add jquery
{
result += R"(<script src="qrc:///scripts/jquery-3.6.0.slim.min.js"></script>)";
result += R"(<script> var $_$=jQuery.noConflict(); </script>)";
result += R"(<script> jQuery.noConflict(); </script>)";
result += R"(<script src="qrc:///scripts/gd-custom.js"></script>)";
result += R"(<script src="qrc:///scripts/iframeResizer.min.js"></script>)";
}
@ -64,13 +65,19 @@ std::string ArticleMaker::makeHtmlHeader( QString const & word, QString const &
{
result += R"(
<script>
$_$(document).ready( function ($){
function gd_init_QtWebChannel(){
console.log("webchannel ready...");
new QWebChannel(qt.webChannelTransport, function(channel) {
window.articleview = channel.objects.articleview;
});
});
</script>
};
if (document.readyState !== "loading") {
gd_init_QtWebChannel();
} else {
document.addEventListener("DOMContentLoaded", gd_init_QtWebChannel);
};
</script>
)";
}

View file

@ -8,12 +8,14 @@ var gdAudioLinks = {
var gdAudioMap = new Map();
function gdMakeArticleActive(newId, noEvent) {
var gdCurrentArticle = $_$(".gdactivearticle").attr("id");
const gdCurrentArticle =
document.querySelector(".gdactivearticle").attributes.id;
if (gdCurrentArticle !== "gdfrom-" + newId) {
$_$(".gdactivearticle").removeClass("gdactivearticle");
var newFormId = "gdfrom-" + newId;
$_$("#" + newFormId).addClass("gdactivearticle");
gdCurrentArticle = "gdfrom-" + newId;
document
.querySelector(".gdactivearticle")
.classList.remove("gdactivearticle");
const newFormId = "gdfrom-" + newId;
document.querySelector(`#${newFormId}`).classList.add("gdactivearticle");
gdAudioLinks.current = newId;
if (!noEvent) articleview.onJsActiveArticleChanged("gdfrom-" + newId);
}

View file

@ -65,4 +65,4 @@
autoResize: false,
});
});
})($_$);
})(jQuery);