Skip to content

Commit

Permalink
升级为0.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
redleafnew committed Apr 25, 2021
1 parent e6c20aa commit 5961291
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 7 deletions.
96 changes: 94 additions & 2 deletions chrome/content/scripts/delitem.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,5 +139,97 @@ Zotero.DelItem = {
} //2 if

} ;
}
}
},

// 检查附件是否存在函数
checkItemAtt: function (item) {
if (item && !item.isNote()) {
if (item.isRegularItem()) { // not an attachment already
let attachmentIDs = item.getAttachments();
for (let id of attachmentIDs) {
let attachment = Zotero.Items.get(id);
var attType = attachment.attachmentContentType;
}
}
if (item.isAttachment()) {
var attType = item.attachmentContentType;
}
}


if (attType != undefined ) {
return true;} else {
return false;}
},

// 检查快照是否存在函数
checkItemSnap: function (item) {
if (item && !item.isNote()) {
if (item.isRegularItem()) { // not an attachment already
let attachmentIDs = item.getAttachments();
for (let id of attachmentIDs) {
let attachment = Zotero.Items.get(id);
var attType = attachment.attachmentContentType;
}
}
if (item.isAttachment()) {
var attType = item.attachmentContentType;
}
}


if (attType == 'text/html' ) {
return true;} else {
return false;}
},

// 是否显示菜单函数
displayMenuitem: function () { // 如果无附件则不显示菜单
var pane = Services.wm.getMostRecentWindow("navigator:browser")
.ZoteroPane;
var items = pane.getSelectedItems();
//Zotero.debug("**Jasminum selected item length: " + items.length);
var showMenuAtt = items.some((item) => Zotero.DelItem.checkItemAtt(item)); // 检查附件
var showMenuSnap = items.some((item) => Zotero.DelItem.checkItemSnap(item)); // 检查快照

//pane.document.getElementById("id-delitem-separator").hidden = !( // 分隔条是否出现
// showMenuAtt ||
// showMenuSnap);

pane.document.getElementById( //总菜单
"zotero-itemmenu-delitem-namehandler"
).disabled = !( // 总菜单是否可用
showMenuAtt ||
showMenuSnap);
pane.document.getElementById( //删除条目和附件
"zotero-itemmenu-delitem"
).disabled = !( // 删除条目和附件是否可用
showMenuAtt ||
showMenuSnap);
pane.document.getElementById( // 仅删除附件菜单
"zotero-itemmenu-delatt"
).disabled = !showMenuAtt; // 仅删除附件菜单是否可用

pane.document.getElementById( // 仅删除快照菜单
"zotero-itemmenu-delsnap"
).disabled = !showMenuSnap;// 仅删除快照是否可用

},
};

window.addEventListener(
"load",
function (e) {
if (window.ZoteroPane) {
var doc = window.ZoteroPane.document;
// add event listener for menu items
doc.getElementById("zotero-itemmenu").addEventListener(
"popupshowing",
Zotero.DelItem.displayMenuitem,
false
);
}
},
false
);

2 changes: 1 addition & 1 deletion chrome/locale/zh-CN/overlay.dtd
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
<!ENTITY zotero.delitem.delitem.label "删除附件和条目">
<!ENTITY zotero.delitem.delitems.label "删除分类条目包括附件">
<!ENTITY zotero.delitem.delsnap.label "仅删除快照">
<!ENTITY zotero.delitem.namehandler.label "仅删除附件">
<!ENTITY zotero.delitem.namehandler.label "删除附件">
2 changes: 1 addition & 1 deletion install.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
RDF:about="urn:mozilla:install-manifest"
em:id="[email protected]"
em:name="Del Item With Att"
em:version="0.0.5"
em:version="0.0.6"
em:type="2"
em:creator="Minyi Han"
em:description="Delete Item(s) With Attachment(s)"
Expand Down
6 changes: 3 additions & 3 deletions update.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
<rdf:Seq>
<rdf:li>
<rdf:Description>
<em:version>0.0.5</em:version>
<em:version>0.0.6</em:version>
<em:targetApplication>
<rdf:Description>
<em:id>[email protected]</em:id>
<em:minVersion>5.0.0</em:minVersion>
<em:maxVersion>5.*</em:maxVersion>
<em:updateLink>https://github.com/redleafnew/delitemwithatt/releases/download/0.0.5/delitemwithatt.xpi</em:updateLink>
<em:updateLink>https://github.com/redleafnew/delitemwithatt/releases/download/0.0.6/delitemwithatt.xpi</em:updateLink>
</rdf:Description>
</em:targetApplication>

Expand All @@ -21,7 +21,7 @@
<em:id>[email protected]</em:id>
<em:minVersion>4.999</em:minVersion>
<em:maxVersion>5.*</em:maxVersion>
<em:updateLink>https://github.com/redleafnew/delitemwithatt/releases/download/0.0.5/delitemwithatt.xpi</em:updateLink>
<em:updateLink>https://github.com/redleafnew/delitemwithatt/releases/download/0.0.6/delitemwithatt.xpi</em:updateLink>
</rdf:Description>
</em:targetApplication>

Expand Down

0 comments on commit 5961291

Please sign in to comment.