update qt ts to prettier 2.0

This commit is contained in:
Damien Elmes 2020-06-24 21:54:38 +10:00
parent 0cab26d40c
commit 2a3ef80c90
6 changed files with 31 additions and 31 deletions

View file

@ -8,7 +8,7 @@ function init() {
scroll: false,
// can't use "helper: 'clone'" because of a bug in jQuery 1.5
helper: function(event) {
helper: function (event) {
return $(this).clone(false);
},
delay: 200,

View file

@ -13,9 +13,9 @@ declare interface String {
}
/* kept for compatibility with add-ons */
String.prototype.format = function() {
String.prototype.format = function () {
const args = arguments;
return this.replace(/\{\d+\}/g, function(m) {
return this.replace(/\{\d+\}/g, function (m) {
return args[m.match(/\d+/)];
});
};
@ -41,7 +41,7 @@ function saveNow(keepFocus) {
function triggerKeyTimer() {
clearChangeTimer();
changeTimer = setTimeout(function() {
changeTimer = setTimeout(function () {
updateButtonState();
saveField("key");
}, 600);
@ -391,7 +391,7 @@ function hideDupes() {
}
/// If the field has only an empty br, remove it first.
let insertHtmlRemovingInitialBR = function(html: string) {
let insertHtmlRemovingInitialBR = function (html: string) {
if (html !== "") {
// remove <br> in empty field
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);
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
const top = $.parseHTML("<ankitop>" + html + "</ankitop>")[0] as Element;
if (internal) {
@ -476,11 +476,11 @@ const allowedStyling = {
"text-decoration-line": true,
};
let isNightMode = function(): boolean {
let isNightMode = function (): boolean {
return document.body.classList.contains("nightMode");
};
let filterExternalSpan = function(node) {
let filterExternalSpan = function (node) {
// filter out attributes
let toRemove = [];
for (const attr of node.attributes) {
@ -520,7 +520,7 @@ allowedTagsExtended["SPAN"] = filterExternalSpan;
Object.assign(allowedTagsExtended, allowedTagsBasic);
// filtering from another field
let filterInternalNode = function(node) {
let filterInternalNode = function (node) {
if (node.style) {
node.style.removeProperty("background-color");
node.style.removeProperty("font-size");
@ -533,7 +533,7 @@ let filterInternalNode = function(node) {
};
// filtering from external sources
let filterNode = function(node, extendedMode) {
let filterNode = function (node, extendedMode) {
// text node?
if (node.nodeType === 3) {
return;
@ -586,7 +586,7 @@ let filterNode = function(node, extendedMode) {
}
};
let adjustFieldsTopMargin = function() {
let adjustFieldsTopMargin = function () {
const topHeight = $("#topbuts").height();
const margin = topHeight + 8;
document.getElementById("fields").style.marginTop = margin + "px";
@ -594,16 +594,16 @@ let adjustFieldsTopMargin = function() {
let mouseDown = 0;
$(function() {
document.body.onmousedown = function() {
$(function () {
document.body.onmousedown = function () {
mouseDown++;
};
document.body.onmouseup = function() {
document.body.onmouseup = function () {
mouseDown--;
};
document.onclick = function(evt: MouseEvent) {
document.onclick = function (evt: MouseEvent) {
const src = evt.target as Element;
if (src.tagName === "IMG") {
// image clicked; find contenteditable parent
@ -618,11 +618,11 @@ $(function() {
};
// prevent editor buttons from taking focus
$("button.linkb").on("mousedown", function(e) {
$("button.linkb").on("mousedown", function (e) {
e.preventDefault();
});
window.onresize = function() {
window.onresize = function () {
adjustFieldsTopMargin();
};

View file

@ -1,6 +1,6 @@
/* Copyright: Ankitects Pty Ltd and contributors
* License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html */
$(function() {
$(function () {
$("#study").focus();
});

View file

@ -4,16 +4,16 @@
var time: number; // set in python code
let maxTime = 0;
$(function() {
$(function () {
$("#ansbut").focus();
updateTime();
setInterval(function() {
setInterval(function () {
time += 1;
updateTime();
}, 1000);
});
let updateTime = function() {
let updateTime = function () {
let timeNode = $("#time");
if (!maxTime) {
timeNode.text("");

View file

@ -21,7 +21,7 @@ function _updateQA(html, fadeTime, onupdate, onshown) {
// if a request to update q/a comes in before the previous content
// has been loaded, wait a while and try again
if (_updatingQA) {
setTimeout(function() {
setTimeout(function () {
_updateQA(html, fadeTime, onupdate, onshown);
}, 50);
return;
@ -34,7 +34,7 @@ function _updateQA(html, fadeTime, onupdate, onshown) {
// fade out current text
var qa = $("#qa");
qa.fadeTo(fadeTime, 0, function() {
qa.fadeTo(fadeTime, 0, function () {
// update text
try {
qa.html(html);
@ -55,8 +55,8 @@ function _updateQA(html, fadeTime, onupdate, onshown) {
MathJax.Hub.Queue(["Typeset", MathJax.Hub]);
// and reveal when processing is done
MathJax.Hub.Queue(function() {
qa.fadeTo(fadeTime, 1, function() {
MathJax.Hub.Queue(function () {
qa.fadeTo(fadeTime, 1, function () {
_runHook(onShownHook);
_updatingQA = false;
});
@ -68,13 +68,13 @@ function _showQuestion(q, bodyclass) {
_updateQA(
q,
qFade,
function() {
function () {
// return to top of window
window.scrollTo(0, 0);
document.body.className = bodyclass;
},
function() {
function () {
// focus typing area if visible
typeans = document.getElementById("typeans");
if (typeans) {
@ -88,7 +88,7 @@ function _showAnswer(a, bodyclass) {
_updateQA(
a,
aFade,
function() {
function () {
if (bodyclass) {
// when previewing
document.body.className = bodyclass;
@ -100,7 +100,7 @@ function _showAnswer(a, bodyclass) {
e[0].scrollIntoView();
}
},
function() {}
function () {}
);
}

View file

@ -2,7 +2,7 @@
* License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html */
// prevent backspace key from going back a page
document.addEventListener("keydown", function(evt: KeyboardEvent) {
document.addEventListener("keydown", function (evt: KeyboardEvent) {
if (evt.keyCode !== 8) {
return;
}