aboutsummaryrefslogtreecommitdiffstats
path: root/web_src/js/features/comp
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2021-10-21 15:37:43 +0800
committerGitHub <noreply@github.com>2021-10-21 15:37:43 +0800
commit2add8fe9beede4aa82c913fcb70c0cf5bb1c6185 (patch)
treebe2555d0a8f0ae926d56eefd3a3b3e533985074a /web_src/js/features/comp
parent5879ab83b5fab57a71aed4c8b3c4d9293b4a4398 (diff)
downloadgitea-2add8fe9beede4aa82c913fcb70c0cf5bb1c6185.tar.gz
gitea-2add8fe9beede4aa82c913fcb70c0cf5bb1c6185.zip
Frontend refactor, PascalCase to camelCase, remove unused code (#17365)
* Frontend refactor, PascalCase to camelCase, remove unused code * fix
Diffstat (limited to 'web_src/js/features/comp')
-rw-r--r--web_src/js/features/comp/ImagePaste.js8
-rw-r--r--web_src/js/features/comp/MarkupContentPreview.js4
-rw-r--r--web_src/js/features/comp/ReactionSelector.js4
-rw-r--r--web_src/js/features/comp/SearchUserBox.js4
-rw-r--r--web_src/js/features/comp/WebHookEditor.js4
5 files changed, 12 insertions, 12 deletions
diff --git a/web_src/js/features/comp/ImagePaste.js b/web_src/js/features/comp/ImagePaste.js
index b6881dd282..30c5820f62 100644
--- a/web_src/js/features/comp/ImagePaste.js
+++ b/web_src/js/features/comp/ImagePaste.js
@@ -1,4 +1,4 @@
-const {AppSubUrl, csrf} = window.config;
+const {appSubUrl, csrfToken} = window.config;
async function uploadFile(file, uploadUrl) {
const formData = new FormData();
@@ -6,7 +6,7 @@ async function uploadFile(file, uploadUrl) {
const res = await fetch(uploadUrl, {
method: 'POST',
- headers: {'X-Csrf-Token': csrf},
+ headers: {'X-Csrf-Token': csrfToken},
body: formData,
});
return await res.json();
@@ -67,7 +67,7 @@ export function initCompImagePaste($target) {
const name = img.name.substr(0, img.name.lastIndexOf('.'));
insertAtCursor(textarea, `![${name}]()`);
const data = await uploadFile(img, uploadUrl);
- replaceAndKeepCursor(textarea, `![${name}]()`, `![${name}](${AppSubUrl}/attachments/${data.uuid})`);
+ replaceAndKeepCursor(textarea, `![${name}]()`, `![${name}](${appSubUrl}/attachments/${data.uuid})`);
const input = $(`<input id="${data.uuid}" name="files" type="hidden">`).val(data.uuid);
dropzoneFiles.appendChild(input[0]);
}
@@ -83,7 +83,7 @@ export function initSimpleMDEImagePaste(simplemde, dropzone, files) {
const name = img.name.substr(0, img.name.lastIndexOf('.'));
const data = await uploadFile(img, uploadUrl);
const pos = simplemde.codemirror.getCursor();
- simplemde.codemirror.replaceRange(`![${name}](${AppSubUrl}/attachments/${data.uuid})`, pos);
+ simplemde.codemirror.replaceRange(`![${name}](${appSubUrl}/attachments/${data.uuid})`, pos);
const input = $(`<input id="${data.uuid}" name="files" type="hidden">`).val(data.uuid);
files.append(input);
}
diff --git a/web_src/js/features/comp/MarkupContentPreview.js b/web_src/js/features/comp/MarkupContentPreview.js
index 0b05c4efae..ed0995296b 100644
--- a/web_src/js/features/comp/MarkupContentPreview.js
+++ b/web_src/js/features/comp/MarkupContentPreview.js
@@ -1,6 +1,6 @@
import {initMarkupContent} from '../../markup/content.js';
-const {csrf} = window.config;
+const {csrfToken} = window.config;
export function initCompMarkupContentPreviewTab($form) {
const $tabMenu = $form.find('.tabular.menu');
@@ -8,7 +8,7 @@ export function initCompMarkupContentPreviewTab($form) {
$tabMenu.find(`.item[data-tab="${$tabMenu.data('preview')}"]`).on('click', function () {
const $this = $(this);
$.post($this.data('url'), {
- _csrf: csrf,
+ _csrf: csrfToken,
mode: 'comment',
context: $this.data('context'),
text: $form.find(`.tab[data-tab="${$tabMenu.data('write')}"] textarea`).val()
diff --git a/web_src/js/features/comp/ReactionSelector.js b/web_src/js/features/comp/ReactionSelector.js
index d11c9667b9..d77b8d3d4e 100644
--- a/web_src/js/features/comp/ReactionSelector.js
+++ b/web_src/js/features/comp/ReactionSelector.js
@@ -1,4 +1,4 @@
-const {csrf} = window.config;
+const {csrfToken} = window.config;
export function initCompReactionSelector(parent) {
let reactions = '';
@@ -20,7 +20,7 @@ export function initCompReactionSelector(parent) {
type: 'POST',
url,
data: {
- _csrf: csrf,
+ _csrf: csrfToken,
content: $(this).data('content')
}
}).done((resp) => {
diff --git a/web_src/js/features/comp/SearchUserBox.js b/web_src/js/features/comp/SearchUserBox.js
index 9019f17de3..0e7d122391 100644
--- a/web_src/js/features/comp/SearchUserBox.js
+++ b/web_src/js/features/comp/SearchUserBox.js
@@ -1,13 +1,13 @@
import {htmlEscape} from 'escape-goat';
-const {AppSubUrl} = window.config;
+const {appSubUrl} = window.config;
export function initSearchUserBox() {
const $searchUserBox = $('#search-user-box');
$searchUserBox.search({
minCharacters: 2,
apiSettings: {
- url: `${AppSubUrl}/api/v1/users/search?q={query}`,
+ url: `${appSubUrl}/api/v1/users/search?q={query}`,
onResponse(response) {
const items = [];
const searchQueryUppercase = $searchUserBox.find('input').val().toUpperCase();
diff --git a/web_src/js/features/comp/WebHookEditor.js b/web_src/js/features/comp/WebHookEditor.js
index 6911c6cb16..ddff73ee37 100644
--- a/web_src/js/features/comp/WebHookEditor.js
+++ b/web_src/js/features/comp/WebHookEditor.js
@@ -1,4 +1,4 @@
-const {csrf} = window.config;
+const {csrfToken} = window.config;
export function initWebHookEditor() {
if ($('.new.webhook').length === 0) {
@@ -30,7 +30,7 @@ export function initWebHookEditor() {
const $this = $(this);
$this.addClass('loading disabled');
$.post($this.data('link'), {
- _csrf: csrf
+ _csrf: csrfToken
}).done(
setTimeout(() => {
window.location.href = $this.data('redirect');