mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
move webview js into separate file
This commit is contained in:
parent
cd76281695
commit
66500f5262
2 changed files with 18 additions and 19 deletions
|
@ -173,7 +173,8 @@ border-radius:5px; font-family: Helvetica }"""
|
|||
family = self.font().family()
|
||||
fontspec = 'font-size:14px;font-family:%s;'%\
|
||||
family
|
||||
jstxt = "\n".join(self.bundledScript(fname) for fname in js)
|
||||
jstxt = "\n".join([self.bundledScript("webview.js")]+
|
||||
[self.bundledScript(fname) for fname in js])
|
||||
|
||||
html="""
|
||||
<!doctype html>
|
||||
|
@ -182,24 +183,6 @@ body { zoom: %f; %s }
|
|||
%s
|
||||
%s</style>
|
||||
%s
|
||||
<script>
|
||||
// prevent backspace key from going back a page
|
||||
document.addEventListener("keydown", function(evt) {
|
||||
if (evt.keyCode != 8) {
|
||||
return;
|
||||
}
|
||||
var isText = 0;
|
||||
var nn = evt.target.nodeName;
|
||||
if (nn == "INPUT" || nn == "TEXTAREA") {
|
||||
isText = 1;
|
||||
} else if (nn == "DIV" && evt.target.contentEditable) {
|
||||
isText = 1;
|
||||
}
|
||||
if (!isText) {
|
||||
evt.preventDefault();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
%s
|
||||
|
||||
</head>
|
||||
|
|
16
web/webview.js
Normal file
16
web/webview.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
// prevent backspace key from going back a page
|
||||
document.addEventListener("keydown", function (evt) {
|
||||
if (evt.keyCode !== 8) {
|
||||
return;
|
||||
}
|
||||
var isText = 0;
|
||||
var nn = evt.target.nodeName;
|
||||
if (nn === "INPUT" || nn === "TEXTAREA") {
|
||||
isText = 1;
|
||||
} else if (nn === "DIV" && evt.target.contentEditable) {
|
||||
isText = 1;
|
||||
}
|
||||
if (!isText) {
|
||||
evt.preventDefault();
|
||||
}
|
||||
});
|
Loading…
Reference in a new issue