mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
update qt ts to prettier 2.0
This commit is contained in:
parent
0cab26d40c
commit
2a3ef80c90
6 changed files with 31 additions and 31 deletions
|
@ -8,7 +8,7 @@ function init() {
|
||||||
scroll: false,
|
scroll: false,
|
||||||
|
|
||||||
// can't use "helper: 'clone'" because of a bug in jQuery 1.5
|
// can't use "helper: 'clone'" because of a bug in jQuery 1.5
|
||||||
helper: function(event) {
|
helper: function (event) {
|
||||||
return $(this).clone(false);
|
return $(this).clone(false);
|
||||||
},
|
},
|
||||||
delay: 200,
|
delay: 200,
|
||||||
|
|
|
@ -13,9 +13,9 @@ declare interface String {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* kept for compatibility with add-ons */
|
/* kept for compatibility with add-ons */
|
||||||
String.prototype.format = function() {
|
String.prototype.format = function () {
|
||||||
const args = arguments;
|
const args = arguments;
|
||||||
return this.replace(/\{\d+\}/g, function(m) {
|
return this.replace(/\{\d+\}/g, function (m) {
|
||||||
return args[m.match(/\d+/)];
|
return args[m.match(/\d+/)];
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -41,7 +41,7 @@ function saveNow(keepFocus) {
|
||||||
|
|
||||||
function triggerKeyTimer() {
|
function triggerKeyTimer() {
|
||||||
clearChangeTimer();
|
clearChangeTimer();
|
||||||
changeTimer = setTimeout(function() {
|
changeTimer = setTimeout(function () {
|
||||||
updateButtonState();
|
updateButtonState();
|
||||||
saveField("key");
|
saveField("key");
|
||||||
}, 600);
|
}, 600);
|
||||||
|
@ -391,7 +391,7 @@ function hideDupes() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If the field has only an empty br, remove it first.
|
/// If the field has only an empty br, remove it first.
|
||||||
let insertHtmlRemovingInitialBR = function(html: string) {
|
let insertHtmlRemovingInitialBR = function (html: string) {
|
||||||
if (html !== "") {
|
if (html !== "") {
|
||||||
// remove <br> in empty field
|
// remove <br> in empty field
|
||||||
if (currentField && currentField.innerHTML === "<br>") {
|
if (currentField && currentField.innerHTML === "<br>") {
|
||||||
|
@ -401,12 +401,12 @@ let insertHtmlRemovingInitialBR = function(html: string) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let pasteHTML = function(html, internal, extendedMode) {
|
let pasteHTML = function (html, internal, extendedMode) {
|
||||||
html = filterHTML(html, internal, extendedMode);
|
html = filterHTML(html, internal, extendedMode);
|
||||||
insertHtmlRemovingInitialBR(html);
|
insertHtmlRemovingInitialBR(html);
|
||||||
};
|
};
|
||||||
|
|
||||||
let filterHTML = function(html, internal, extendedMode) {
|
let filterHTML = function (html, internal, extendedMode) {
|
||||||
// wrap it in <top> as we aren't allowed to change top level elements
|
// wrap it in <top> as we aren't allowed to change top level elements
|
||||||
const top = $.parseHTML("<ankitop>" + html + "</ankitop>")[0] as Element;
|
const top = $.parseHTML("<ankitop>" + html + "</ankitop>")[0] as Element;
|
||||||
if (internal) {
|
if (internal) {
|
||||||
|
@ -476,11 +476,11 @@ const allowedStyling = {
|
||||||
"text-decoration-line": true,
|
"text-decoration-line": true,
|
||||||
};
|
};
|
||||||
|
|
||||||
let isNightMode = function(): boolean {
|
let isNightMode = function (): boolean {
|
||||||
return document.body.classList.contains("nightMode");
|
return document.body.classList.contains("nightMode");
|
||||||
};
|
};
|
||||||
|
|
||||||
let filterExternalSpan = function(node) {
|
let filterExternalSpan = function (node) {
|
||||||
// filter out attributes
|
// filter out attributes
|
||||||
let toRemove = [];
|
let toRemove = [];
|
||||||
for (const attr of node.attributes) {
|
for (const attr of node.attributes) {
|
||||||
|
@ -520,7 +520,7 @@ allowedTagsExtended["SPAN"] = filterExternalSpan;
|
||||||
Object.assign(allowedTagsExtended, allowedTagsBasic);
|
Object.assign(allowedTagsExtended, allowedTagsBasic);
|
||||||
|
|
||||||
// filtering from another field
|
// filtering from another field
|
||||||
let filterInternalNode = function(node) {
|
let filterInternalNode = function (node) {
|
||||||
if (node.style) {
|
if (node.style) {
|
||||||
node.style.removeProperty("background-color");
|
node.style.removeProperty("background-color");
|
||||||
node.style.removeProperty("font-size");
|
node.style.removeProperty("font-size");
|
||||||
|
@ -533,7 +533,7 @@ let filterInternalNode = function(node) {
|
||||||
};
|
};
|
||||||
|
|
||||||
// filtering from external sources
|
// filtering from external sources
|
||||||
let filterNode = function(node, extendedMode) {
|
let filterNode = function (node, extendedMode) {
|
||||||
// text node?
|
// text node?
|
||||||
if (node.nodeType === 3) {
|
if (node.nodeType === 3) {
|
||||||
return;
|
return;
|
||||||
|
@ -586,7 +586,7 @@ let filterNode = function(node, extendedMode) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let adjustFieldsTopMargin = function() {
|
let adjustFieldsTopMargin = function () {
|
||||||
const topHeight = $("#topbuts").height();
|
const topHeight = $("#topbuts").height();
|
||||||
const margin = topHeight + 8;
|
const margin = topHeight + 8;
|
||||||
document.getElementById("fields").style.marginTop = margin + "px";
|
document.getElementById("fields").style.marginTop = margin + "px";
|
||||||
|
@ -594,16 +594,16 @@ let adjustFieldsTopMargin = function() {
|
||||||
|
|
||||||
let mouseDown = 0;
|
let mouseDown = 0;
|
||||||
|
|
||||||
$(function() {
|
$(function () {
|
||||||
document.body.onmousedown = function() {
|
document.body.onmousedown = function () {
|
||||||
mouseDown++;
|
mouseDown++;
|
||||||
};
|
};
|
||||||
|
|
||||||
document.body.onmouseup = function() {
|
document.body.onmouseup = function () {
|
||||||
mouseDown--;
|
mouseDown--;
|
||||||
};
|
};
|
||||||
|
|
||||||
document.onclick = function(evt: MouseEvent) {
|
document.onclick = function (evt: MouseEvent) {
|
||||||
const src = evt.target as Element;
|
const src = evt.target as Element;
|
||||||
if (src.tagName === "IMG") {
|
if (src.tagName === "IMG") {
|
||||||
// image clicked; find contenteditable parent
|
// image clicked; find contenteditable parent
|
||||||
|
@ -618,11 +618,11 @@ $(function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
// prevent editor buttons from taking focus
|
// prevent editor buttons from taking focus
|
||||||
$("button.linkb").on("mousedown", function(e) {
|
$("button.linkb").on("mousedown", function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
window.onresize = function() {
|
window.onresize = function () {
|
||||||
adjustFieldsTopMargin();
|
adjustFieldsTopMargin();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* Copyright: Ankitects Pty Ltd and contributors
|
/* Copyright: Ankitects Pty Ltd and contributors
|
||||||
* License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html */
|
* License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html */
|
||||||
|
|
||||||
$(function() {
|
$(function () {
|
||||||
$("#study").focus();
|
$("#study").focus();
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,16 +4,16 @@
|
||||||
var time: number; // set in python code
|
var time: number; // set in python code
|
||||||
|
|
||||||
let maxTime = 0;
|
let maxTime = 0;
|
||||||
$(function() {
|
$(function () {
|
||||||
$("#ansbut").focus();
|
$("#ansbut").focus();
|
||||||
updateTime();
|
updateTime();
|
||||||
setInterval(function() {
|
setInterval(function () {
|
||||||
time += 1;
|
time += 1;
|
||||||
updateTime();
|
updateTime();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
});
|
});
|
||||||
|
|
||||||
let updateTime = function() {
|
let updateTime = function () {
|
||||||
let timeNode = $("#time");
|
let timeNode = $("#time");
|
||||||
if (!maxTime) {
|
if (!maxTime) {
|
||||||
timeNode.text("");
|
timeNode.text("");
|
||||||
|
|
|
@ -21,7 +21,7 @@ function _updateQA(html, fadeTime, onupdate, onshown) {
|
||||||
// if a request to update q/a comes in before the previous content
|
// if a request to update q/a comes in before the previous content
|
||||||
// has been loaded, wait a while and try again
|
// has been loaded, wait a while and try again
|
||||||
if (_updatingQA) {
|
if (_updatingQA) {
|
||||||
setTimeout(function() {
|
setTimeout(function () {
|
||||||
_updateQA(html, fadeTime, onupdate, onshown);
|
_updateQA(html, fadeTime, onupdate, onshown);
|
||||||
}, 50);
|
}, 50);
|
||||||
return;
|
return;
|
||||||
|
@ -34,7 +34,7 @@ function _updateQA(html, fadeTime, onupdate, onshown) {
|
||||||
|
|
||||||
// fade out current text
|
// fade out current text
|
||||||
var qa = $("#qa");
|
var qa = $("#qa");
|
||||||
qa.fadeTo(fadeTime, 0, function() {
|
qa.fadeTo(fadeTime, 0, function () {
|
||||||
// update text
|
// update text
|
||||||
try {
|
try {
|
||||||
qa.html(html);
|
qa.html(html);
|
||||||
|
@ -55,8 +55,8 @@ function _updateQA(html, fadeTime, onupdate, onshown) {
|
||||||
MathJax.Hub.Queue(["Typeset", MathJax.Hub]);
|
MathJax.Hub.Queue(["Typeset", MathJax.Hub]);
|
||||||
|
|
||||||
// and reveal when processing is done
|
// and reveal when processing is done
|
||||||
MathJax.Hub.Queue(function() {
|
MathJax.Hub.Queue(function () {
|
||||||
qa.fadeTo(fadeTime, 1, function() {
|
qa.fadeTo(fadeTime, 1, function () {
|
||||||
_runHook(onShownHook);
|
_runHook(onShownHook);
|
||||||
_updatingQA = false;
|
_updatingQA = false;
|
||||||
});
|
});
|
||||||
|
@ -68,13 +68,13 @@ function _showQuestion(q, bodyclass) {
|
||||||
_updateQA(
|
_updateQA(
|
||||||
q,
|
q,
|
||||||
qFade,
|
qFade,
|
||||||
function() {
|
function () {
|
||||||
// return to top of window
|
// return to top of window
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0);
|
||||||
|
|
||||||
document.body.className = bodyclass;
|
document.body.className = bodyclass;
|
||||||
},
|
},
|
||||||
function() {
|
function () {
|
||||||
// focus typing area if visible
|
// focus typing area if visible
|
||||||
typeans = document.getElementById("typeans");
|
typeans = document.getElementById("typeans");
|
||||||
if (typeans) {
|
if (typeans) {
|
||||||
|
@ -88,7 +88,7 @@ function _showAnswer(a, bodyclass) {
|
||||||
_updateQA(
|
_updateQA(
|
||||||
a,
|
a,
|
||||||
aFade,
|
aFade,
|
||||||
function() {
|
function () {
|
||||||
if (bodyclass) {
|
if (bodyclass) {
|
||||||
// when previewing
|
// when previewing
|
||||||
document.body.className = bodyclass;
|
document.body.className = bodyclass;
|
||||||
|
@ -100,7 +100,7 @@ function _showAnswer(a, bodyclass) {
|
||||||
e[0].scrollIntoView();
|
e[0].scrollIntoView();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
function() {}
|
function () {}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html */
|
* License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html */
|
||||||
|
|
||||||
// prevent backspace key from going back a page
|
// prevent backspace key from going back a page
|
||||||
document.addEventListener("keydown", function(evt: KeyboardEvent) {
|
document.addEventListener("keydown", function (evt: KeyboardEvent) {
|
||||||
if (evt.keyCode !== 8) {
|
if (evt.keyCode !== 8) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue