From c0ac56022ca12d730c07feeae691748819797a07 Mon Sep 17 00:00:00 2001 From: l0o0 Date: Wed, 2 Sep 2020 15:33:26 +0800 Subject: [PATCH] Add function to remove dot in Chinese lastname and firstname. Fix error in 0.0.5 --- chrome/content/overlay.xul | 1 + chrome/content/preferences.xul | 2 ++ chrome/content/scripts/jasminum.js | 23 ++++++++++++++++++++++- chrome/locale/en-US/overlay.dtd | 4 +++- chrome/locale/zh-CN/overlay.dtd | 4 +++- 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/chrome/content/overlay.xul b/chrome/content/overlay.xul index 1665346..5b048f5 100644 --- a/chrome/content/overlay.xul +++ b/chrome/content/overlay.xul @@ -20,6 +20,7 @@ + + @@ -30,6 +31,7 @@ + &jasminum.namepatent.desc; diff --git a/chrome/content/scripts/jasminum.js b/chrome/content/scripts/jasminum.js index 389f639..1436b76 100644 --- a/chrome/content/scripts/jasminum.js +++ b/chrome/content/scripts/jasminum.js @@ -867,7 +867,7 @@ Zotero.Jasminum = { } var bookmark = await Zotero.Jasminum.getBookmark(item); if (!bookmark) { - alert("No Bookmark found!\n书签信息未找到"); + alert("No Bookmark found!\n书签信息未找到"); } await Zotero.Jasminum.addBookmark(item, bookmark); // Use zotfile to add TOC @@ -965,6 +965,27 @@ Zotero.Jasminum = { } } }, + + removeDotM: function () { + var items = ZoteroPane.getSelectedItems(); + Zotero.Jasminum.removeDot(items); + }, + + removeDot: async function (items) { + for (let item of items) { + var attachmentIDs = item.getAttachments(); + for (let id of attachmentIDs) { + var atta = Zotero.Items.get(id); + var newName = atta.attachmentFilename.replace( + /([\u4e00-\u9fa5]), ([\u4e00-\u9fa5])/g, + "$1$2" + ); + await atta.renameAttachmentFile(newName); + atta.setField("title", newName); + atta.saveTx(); + } + } + }, }; window.addEventListener( diff --git a/chrome/locale/en-US/overlay.dtd b/chrome/locale/en-US/overlay.dtd index c2969bb..b74d19b 100644 --- a/chrome/locale/en-US/overlay.dtd +++ b/chrome/locale/en-US/overlay.dtd @@ -18,4 +18,6 @@ - \ No newline at end of file + + + \ No newline at end of file diff --git a/chrome/locale/zh-CN/overlay.dtd b/chrome/locale/zh-CN/overlay.dtd index beec89e..82e7019 100644 --- a/chrome/locale/zh-CN/overlay.dtd +++ b/chrome/locale/zh-CN/overlay.dtd @@ -18,4 +18,6 @@ - \ No newline at end of file + + + \ No newline at end of file