mirror of
https://github.com/Jonnyan404/memos-bber.git
synced 2026-04-24 19:48:37 +09:00
59700dce59
Introduce an upload attachments panel with styles, localization and client-side management. Added new i18n keys (EN/ZH) and refactored js/i18n.js to helper setters for text/placeholder/title. popup.html and css/main.css add the upload-list UI and styles. oper.js implements rendering, drag-and-drop reorder, deletion (calls DELETE api with token), storage persistence (resourceIdList), escapeHtml sanitization, and sync change handling; it also fixes a config check (repo -> apiTokens), stores filename from upload responses, handles attachments/resources compatibility, and clears the list after sending a memo. Overall this enables reorderable, deletable uploaded attachments with proper localization and tooltips.
48 lines
1.3 KiB
JavaScript
48 lines
1.3 KiB
JavaScript
function getMessage(key) {
|
|
return chrome.i18n.getMessage(key) || ''
|
|
}
|
|
|
|
function setText(id, messageKey) {
|
|
const el = document.getElementById(id)
|
|
if (el) el.textContent = getMessage(messageKey)
|
|
}
|
|
|
|
function setPlaceholder(id, messageKey) {
|
|
const el = document.getElementById(id)
|
|
if (el) el.placeholder = getMessage(messageKey)
|
|
}
|
|
|
|
function setTitle(id, messageKey) {
|
|
const el = document.getElementById(id)
|
|
if (el) el.title = getMessage(messageKey)
|
|
}
|
|
|
|
setText("saveKey", "saveBtn")
|
|
setText("saveTag", "saveBtn")
|
|
|
|
setPlaceholder("apiUrl", "placeApiUrl")
|
|
setPlaceholder("apiTokens", "placeApiTokens")
|
|
setPlaceholder("content", "placeContent")
|
|
|
|
setText("lockPrivate", "lockPrivate")
|
|
setText("lockProtected", "lockProtected")
|
|
setText("lockPublic", "lockPublic")
|
|
|
|
setText("content_submit_text", "submitBtn")
|
|
|
|
setPlaceholder("hideInput", "placeHideInput")
|
|
setPlaceholder("showInput", "placeShowInput")
|
|
|
|
setText("uploadlist-title", "uploadedListTitle")
|
|
|
|
// Native hover tooltips (title)
|
|
setTitle("opensite", "tipOpenSite")
|
|
setTitle("blog_info_edit", "tipSettings")
|
|
setTitle("tags", "tipTags")
|
|
setTitle("newtodo", "tipTodo")
|
|
setTitle("upres", "tipUpload")
|
|
setTitle("getlink", "tipLink")
|
|
setTitle("random", "tipRandom")
|
|
setTitle("search", "tipSearch")
|
|
setTitle("lock", "tipVisibility")
|
|
setTitle("content_submit_text", "tipSend") |