aboutsummaryrefslogtreecommitdiff
path: root/static
diff options
context:
space:
mode:
authortdro <tdro@noreply.example.com>2023-04-08 22:26:43 -0400
committertdro <tdro@noreply.example.com>2023-04-08 22:26:43 -0400
commit787b97a30f788957eb471f2ed3f08b66a405b092 (patch)
tree95f10e86ca44f5bea78c119753a8d09ad675fc0d /static
parentf0cbdec755e91fc3f02e96b03e1fc200b135815e (diff)
downloadcanory-787b97a30f788957eb471f2ed3f08b66a405b092.tar.gz
canory-787b97a30f788957eb471f2ed3f08b66a405b092.tar.bz2
canory-787b97a30f788957eb471f2ed3f08b66a405b092.zip
static/js: Babel fish
Diffstat (limited to 'static')
-rw-r--r--static/js/contextmenu.ts4
-rw-r--r--static/js/fixedsearch.ts27
-rw-r--r--static/js/pager.ts6
-rw-r--r--static/js/timeago.ts74
4 files changed, 53 insertions, 58 deletions
diff --git a/static/js/contextmenu.ts b/static/js/contextmenu.ts
index dea9bec..b19cf9e 100644
--- a/static/js/contextmenu.ts
+++ b/static/js/contextmenu.ts
@@ -1,11 +1,11 @@
(function () {
- const hide = (triggers) => {
+ const hide = function (triggers) {
for (let i = 0; i < triggers.length; i++) {
triggers[i].checked = false;
}
};
- const hideIfClickedOutside = (menus, triggers, event) => {
+ const hideIfClickedOutside = function (menus, triggers, event) {
for (let i = 0; i < menus.length; i++) {
const active = triggers[i].checked === true;
const outside = !menus[i].contains(event.target);
diff --git a/static/js/fixedsearch.ts b/static/js/fixedsearch.ts
index 938e1f5..b42a620 100644
--- a/static/js/fixedsearch.ts
+++ b/static/js/fixedsearch.ts
@@ -170,7 +170,7 @@
function initialize() {
if (firstRun) {
loadScript(window.location.origin + "/js/fuzzysort.js")
- .then(() => {
+ .then(function () {
firstRun = false;
fetchJson("/index.json", {});
@@ -185,7 +185,7 @@
});
search(query.value, data.items, options);
- }).catch((error) => {
+ }).catch(function (error) {
console.log("Error failed to load fuzzy sort: " + error);
});
}
@@ -204,18 +204,15 @@
if (results.length === 0 && term.length >= 0) {
let separator = "—";
if (term.length === 0) separator = "";
- items = `
- <li>
- <a href="javascript: void(0)" tabindex="0">${
- escape(term)
- } ${separator} No Results Found</a>
- </li>
- `;
+ items = '<li><a href="javascript: void(0)" tabindex="0">'.concat(
+ escape(term),
+ " ",
+ ).concat(separator, " No Results Found</a></li>");
dropdown.removeAttribute("hidden");
container.setAttribute("data-focus", "");
} else {
dropdown.removeAttribute("hidden");
- for (const string in results.slice(0, 10)) {
+ for (var string in results.slice(0, 10)) {
const title = results[string].obj.title;
let highlight = fuzzysort.highlight(
fuzzysort.single(escape(term), escape(title)),
@@ -228,14 +225,12 @@
}
items = items +
- `
- <li>
- <a href="${results[string].obj.url}" tabindex="0">${highlight}</a>
- </li>
- `;
+ '\n<li>\n<a href="'.concat(
+ results[string].obj.url,
+ '" tabindex="0">',
+ ).concat(highlight, "</a>\n</li>\n");
}
}
-
dropdown.innerHTML = items;
}
});
diff --git a/static/js/pager.ts b/static/js/pager.ts
index 01d40d7..8b89897 100644
--- a/static/js/pager.ts
+++ b/static/js/pager.ts
@@ -11,7 +11,7 @@
const url = self.location.href.split("#")[0].split("?")[0];
- const scrollRestore = (url) => {
+ const scrollRestore = function (url) {
if (history.scrollRestoration) history.scrollRestoration = "manual";
if (localStorage["settings"]) {
settings = JSON.parse(localStorage["settings"]);
@@ -35,13 +35,13 @@
localStorage["settings"] = JSON.stringify(settings);
};
- const scrollTrack = (url) => {
+ const scrollTrack = function (url) {
const currentPosition = self.pageYOffset;
settings["pager"][url] = currentPosition;
localStorage["settings"] = JSON.stringify(settings);
};
- const backTrack = (back, up, event) => {
+ const backTrack = function (back, up, event) {
if (document.body.contains(up) && up.contains(event.target)) {
event.preventDefault();
window.scrollTo(0, 0);
diff --git a/static/js/timeago.ts b/static/js/timeago.ts
index af974fc..f7567ed 100644
--- a/static/js/timeago.ts
+++ b/static/js/timeago.ts
@@ -8,47 +8,47 @@
style: "long",
});
- const date = () => {
- [...document.querySelectorAll("time")]
- .forEach(
- (element) => {
- try {
- const time: millisecond = new Date(element.dateTime) || new Date();
- const interval: second = ((new Date().getTime() - time.getTime()) / 1000);
-
- const seconds: number = Math.floor(interval);
- const minutes: number = Math.floor(seconds / 60);
- const hours: number = Math.floor(minutes / 60);
- const days: number = Math.floor(hours / 24);
-
- if (Math.sign(seconds) === 1) {
- if (seconds <= 60) { return element.textContent = relative.format(-1 * seconds, "second",); }
- if (minutes <= 120) { return element.textContent = relative.format(-1 * minutes, "minute",); }
- if (hours <= 48) { return element.textContent = relative.format(-1 * hours, "hour",); }
- if (days <= 60) { return element.textContent = relative.format(-1 * days, "day",); }
- }
-
- if (Math.sign(seconds) === -1) {
- if (-1 * days >= 60) { return element.textContent = relative.format(-1 * days, "day",); }
- if (-1 * hours >= 48) { return element.textContent = relative.format(-1 * hours, "hour",); }
- if (-1 * minutes >= 120) { return element.textContent = relative.format(-1 * minutes, "minute",); }
- if (-1 * seconds >= 0) { return element.textContent = relative.format(-1 * seconds, "second",); }
- }
-
- } catch (error) {
- console.error(
- "Error: Unable to resolve relative time format!",
- error,
- );
+ const date = function () {
+ const elements = document.querySelectorAll("time");
+ for (let i = 0; i < elements.length; ++i) {
+ (function (element) {
+ try {
+ const time: millisecond = new Date(element.dateTime) || new Date();
+ const interval: second = ((new Date().getTime() - time.getTime()) / 1000);
+
+ const seconds: number = Math.floor(interval);
+ const minutes: number = Math.floor(seconds / 60);
+ const hours: number = Math.floor(minutes / 60);
+ const days: number = Math.floor(hours / 24);
+
+ if (Math.sign(seconds) === 1) {
+ if (seconds <= 60) { return element.textContent = relative.format(-1 * seconds, "second",); }
+ if (minutes <= 120) { return element.textContent = relative.format(-1 * minutes, "minute",); }
+ if (hours <= 48) { return element.textContent = relative.format(-1 * hours, "hour",); }
+ if (days <= 60) { return element.textContent = relative.format(-1 * days, "day",); }
}
- },
- );
- }
+
+ if (Math.sign(seconds) === -1) {
+ if (-1 * days >= 60) { return element.textContent = relative.format(-1 * days, "day",); }
+ if (-1 * hours >= 48) { return element.textContent = relative.format(-1 * hours, "hour",); }
+ if (-1 * minutes >= 120) { return element.textContent = relative.format(-1 * minutes, "minute",); }
+ if (-1 * seconds >= 0) { return element.textContent = relative.format(-1 * seconds, "second",); }
+ }
+
+ } catch (error) {
+ console.error(
+ "Error: Unable to resolve relative time format!",
+ error,
+ );
+ }
+ })(elements[i]);
+ }
+ };
const substitution = setInterval(date, 4);
- self.addEventListener("load", () => {
- setTimeout(() => {
+ self.addEventListener("load", function () {
+ setTimeout(function () {
clearInterval(substitution);
setInterval(date, 1000);
}, 1000);