aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2023-06-07 21:15:50 +0300
committerGravatar Vitaly Takmazov2023-06-07 21:57:06 +0300
commit7bbbcf0df392be397ce70e78d218e0d2fcd0815a (patch)
treeca1c3d74a5b59ad49d5ec8f14719d9ff90ee217e /src
parente83558253ef0945bdd3a71e5aa24d73361eee0e2 (diff)
scripts: cleanup remaining lint warnings
Diffstat (limited to 'src')
-rw-r--r--src/main/assets/icon.js1
-rw-r--r--src/main/assets/scripts.js42
2 files changed, 22 insertions, 21 deletions
diff --git a/src/main/assets/icon.js b/src/main/assets/icon.js
index c94a1663..5cd787a5 100644
--- a/src/main/assets/icon.js
+++ b/src/main/assets/icon.js
@@ -26,7 +26,6 @@ function wrapSpinner(html, klass) {
*
*/
export default function renderIcons() {
- var render = true
var icons = document.querySelectorAll('[data-icon]')
for (var i = 0; i < icons.length; i++) {
diff --git a/src/main/assets/scripts.js b/src/main/assets/scripts.js
index 4cb06966..94f79424 100644
--- a/src/main/assets/scripts.js
+++ b/src/main/assets/scripts.js
@@ -500,7 +500,7 @@ function toggleWL(e, name) {
.catch(console.err)
return false
}
-
+/*
function getTags() {
fetch('/api/tags?hash=' + document.getElementById('body').getAttribute('data-hash'), {
credentials: 'omit'
@@ -513,28 +513,30 @@ function getTags() {
}).catch(console.error)
return false
}
-
+*/
function addTag(tag) {
document.forms['postmsg'].body.value = '*' + tag + ' ' + document.forms['postmsg'].body.value
return false
}
-function fetchUserUri(dataUri, callback) {
+function fetchUserUri(dataUri) {
let data = new FormData()
data.append('uri', dataUri)
- fetch('/api/u/', {
- method: 'POST',
- body: data
- }).then(handleErrors)
- .then(response => {
- return response.json()
- })
- .then(json => {
- callback(json)
- })
- .catch(e => {
- callback({ uname: dataUri, uri: dataUri })
- })
+ return new Promise((resolve) => {
+ fetch('/api/u/', {
+ method: 'POST',
+ body: data
+ }).then(handleErrors)
+ .then(response => {
+ return response.json()
+ })
+ .then(json => {
+ resolve(json)
+ })
+ .catch(() => {
+ resolve({ uname: dataUri, uri: dataUri })
+ })
+ })
}
const registerServiceWorker = () => {
@@ -640,7 +642,7 @@ ready(() => {
if (opMessage) {
let replyTextarea = /** @type {HTMLTextAreaElement} */ (opMessage.querySelector('textarea.reply'))
if (replyTextarea) {
- replyTextarea.addEventListener('focus', e => showCommentForm(pageMID, 0))
+ replyTextarea.addEventListener('focus', () => showCommentForm(pageMID, 0))
replyTextarea.addEventListener('keypress', e => postformListener(/** @type {HTMLElement} */(e.target), e))
if (!window.location.hash) {
replyTextarea.focus()
@@ -777,7 +779,7 @@ ready(() => {
Array.from(document.querySelectorAll('[data-uri]')).forEach(el => {
let dataUri = el.getAttribute('data-uri') || ''
if (dataUri) {
- setTimeout(() => fetchUserUri(dataUri, user => {
+ setTimeout(() => fetchUserUri(dataUri).then(user => {
let header = el.closest('.msg-header')
Array.from(header.querySelectorAll('.a-username')).forEach(a => {
a.setAttribute('href', user.url || user.uri)
@@ -798,7 +800,7 @@ ready(() => {
Array.from(document.querySelectorAll('[data-user-uri]')).forEach(el => {
let dataUri = el.getAttribute('href') || ''
if (dataUri) {
- setTimeout(() => fetchUserUri(dataUri, user => {
+ setTimeout(() => fetchUserUri(dataUri).then(user => {
let textNode = el.childNodes[0]
if (textNode.nodeType === Node.TEXT_NODE && textNode.nodeValue.trim().length > 0) {
let uname = document.createTextNode(`@${user.uname}`)
@@ -825,7 +827,7 @@ ready(() => {
const button = document.getElementById('notifications_toggle')
if (button) {
button.addEventListener('click', () => {
- Notification.requestPermission(function(result) { notificationsCheckPermissions(button) })
+ Notification.requestPermission(() => { notificationsCheckPermissions(button) })
})
notificationsCheckPermissions(button)
}