Skip to content

Commit 0ecaf2f

Browse files
committed
fix: lint indentation + trailing commas + formatting
1 parent 6072af7 commit 0ecaf2f

4 files changed

Lines changed: 47 additions & 47 deletions

File tree

public/src/client/topic.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -479,23 +479,23 @@ define('forum/topic', [
479479
alerts.remove('bookmark');
480480
}
481481
}
482-
function configurePostToggles() {
483-
$('.topic').on('click', '.view-translated-btn', function (e) {
484-
e.preventDefault();
482+
function configurePostToggles() {
483+
$('.topic').on('click', '.view-translated-btn', function (e) {
484+
e.preventDefault();
485485

486-
const translatedContent = $(this).closest('.sensitive-content-message').next('.translated-content');
486+
const translatedContent = $(this).closest('.sensitive-content-message').next('.translated-content');
487487

488-
translatedContent.toggle();
488+
translatedContent.toggle();
489489

490-
if (translatedContent.is(':visible')) {
491-
$(this).text('Hide the translated message.');
492-
} else {
493-
$(this).text('Click here to view the translated message.');
494-
}
495-
});
496-
}
497-
$(document).ready(function() {
498-
configurePostToggles();
499-
});
490+
if (translatedContent.is(':visible')) {
491+
$(this).text('Hide the translated message.');
492+
} else {
493+
$(this).text('Click here to view the translated message.');
494+
}
495+
});
496+
}
497+
$(document).ready(function() {
498+
configurePostToggles();
499+
});
500500
return Topic;
501501
});

src/posts/create.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module.exports = function (Posts) {
2929
}
3030

3131
const pid = data.pid || await db.incrObjectField('global', 'nextPid');
32-
const [isEnglish, translatedContent] = await translate.translate(data);
32+
const [isEnglish, translatedContent] = await translate.translate(data);
3333
let postData = { pid, uid, tid, content, sourceContent, timestamp, isEnglish, translatedContent };
3434

3535
if (data.toPid) {

src/posts/data.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ function modifyPost(post, fields) {
103103
if (!fields.length || fields.includes('attachments')) {
104104
post.attachments = (post.attachments || '').split(',').filter(Boolean);
105105
}
106-
post.isEnglish = post.isEnglish == 'true' || post.isEnglish === undefined;
106+
post.isEnglish = post.isEnglish == 'true' || post.isEnglish === undefined;
107107
// If translatedContent is undefined, default to empty string (no translation needed for English posts)
108108
if (post.translatedContent === undefined) {
109-
post.translatedContent = '';
109+
post.translatedContent = '';
110110
}
111111
}
112112
}

src/translate/index.js

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,33 @@
33
const translatorApi = module.exports;
44

55
translatorApi.translate = async function (postData) {
6-
// Dynamically import node-fetch (ES module)
7-
const fetch = (await import('node-fetch')).default;
8-
9-
const FLASK_URL = 'http://localhost:8080/translate';
10-
11-
try {
12-
const response = await fetch(FLASK_URL, {
13-
method: 'POST',
14-
headers: {
15-
'Content-Type': 'application/json',
16-
},
17-
body: JSON.stringify({
18-
text: postData.content || ''
19-
})
20-
});
21-
22-
if (!response.ok) {
23-
throw new Error(`HTTP error! status: ${response.status}`);
24-
}
25-
26-
const data = await response.json();
27-
28-
// Return [isEnglish, translatedContent]
29-
return [data.is_english, data.translated || data.translated_content || ''];
30-
} catch (error) {
31-
console.error('Translation API error:', error);
32-
// Return defaults on error - assume English, no translation
33-
return [true, ''];
34-
}
6+
// Dynamically import node-fetch (ES module)
7+
const fetch = (await import('node-fetch')).default;
8+
9+
const FLASK_URL = 'http://localhost:8080/translate';
10+
11+
try {
12+
const response = await fetch(FLASK_URL, {
13+
method: 'POST',
14+
headers: {
15+
'Content-Type': 'application/json',
16+
},
17+
body: JSON.stringify({
18+
text: postData.content || '',
19+
}),
20+
});
21+
22+
if (!response.ok) {
23+
throw new Error(`HTTP error! status: ${response.status}`);
24+
}
25+
26+
const data = await response.json();
27+
28+
// Return [isEnglish, translatedContent]
29+
return [data.is_english, data.translated || data.translated_content || ''];
30+
} catch (error) {
31+
console.error('Translation API error:', error);
32+
// Return defaults on error - assume English, no translation
33+
return [true, ''];
34+
}
3535
};

0 commit comments

Comments
 (0)