Skip to content

Commit

Permalink
add: support up to 9 rule groups
Browse files Browse the repository at this point in the history
Add help tab in preference setting.
Add more help infomation
  • Loading branch information
windingwind committed Feb 21, 2021
1 parent 74bbe83 commit 24d9224
Show file tree
Hide file tree
Showing 10 changed files with 156 additions and 131 deletions.
Binary file removed builds/zotero-tag-0.0.5.xpi
Binary file not shown.
Binary file added builds/zotero-tag-0.0.6.xpi
Binary file not shown.
159 changes: 91 additions & 68 deletions chrome/content/preferences.xul
Original file line number Diff line number Diff line change
Expand Up @@ -13,76 +13,99 @@
onpaneload="initPreferences();"
>
<preferences id="zotero-preferences-zoterotag">
<preference id="pref-zoterotag-automatic-add-tag" name="extensions.zotero.zoterotag.automatic_add_tag" type="bool"/>
<preference id="pref-zoterotag-tag-name" name="extensions.zotero.zoterotag.tag_name" type="string"/>
<preference id="pref-zoterotag-rules" name="extensions.zotero.zoterotag.rules" type="string"/>
</preferences>
<vbox flex="1">
<groupbox>
<caption label="&zotero.zoterotag.rules.title;"/>
<label value="&zotero.zoterotag.rules.info.1;"/>
<label value="&zotero.zoterotag.rules.info.2;"/>
<label value="&zotero.zoterotag.rules.info.3;"/>
<label value="&zotero.zoterotag.rules.info.4;"/>
<listbox id="zoterotag-rules-listbox" flex="1">
<listhead>
<listheader label="&zotero.zoterotag.rules.listheader.id;"/>
<listheader label="&zotero.zoterotag.rules.listheader.tags;"/>
<listheader label="&zotero.zoterotag.rules.listheader.group;"/>
<listheader label="&zotero.zoterotag.rules.listheader.autoadd;"/>
<listheader label="&zotero.zoterotag.rules.listheader.operation;"/>
<!-- <listheader label="&zotero.zoterotag.rules.listheader.delete;"/> -->
</listhead>
<listcols>
<listcol/>
<listcol width="250"/>
<listcol/>
<listcol/>
<listcol/>
<!-- <listcol width="80"/> -->
</listcols>
<!-- <listitem id="zoterotag-rules-#" allowevents="true">
<listcell>
<label id="zoterotag-rules-#-id" value="#"/>
</listcell>
<listcell>
<textbox id="zoterotag-rules-#-tags"/>
</listcell>
<listcell>
<menulist id="zoterotag-rules-#-group">
<menupopup>
<menuitem value="1" label="1(&zotero.zoterotag.rules.group.default;)"/>
<menuitem value="2" label="2"/>
<menuitem value="3" label="3"/>
<menuitem value="0" label="&zotero.zoterotag.rules.group.other;"/>
</menupopup>
</menulist>
</listcell>
<listcell>
<checkbox id="zoterotag-rules-#-autoadd"/>
</listcell>
<listcell>
<button label="&zotero.zoterotag.rules.add;" tooltiptext="&zotero.zoterotag.rules.addtext;" oncommand="addRule()"/>
</listcell>
<listcell>
<button label="&zotero.zoterotag.rules.remove;" tooltiptext="&zotero.zoterotag.rules.removetext;" oncommand="" disabled="true"/>
</listcell>
</listitem> -->
</listbox>
<hbox style="display: block">
<button label="&zotero.zoterotag.rules.reset;" tooltiptext="&zotero.zoterotag.rules.resettext;" oncommand="resetPreferences()"/>
<label value="&zotero.zoterotag.rules.warningtext;" style="color: red"/>
</hbox>
</groupbox>
<groupbox>
<caption label="&zotero.zoterotag.help.title.label;"/>
<hbox style="display: block">
<label value="&zotero.zoterotag.help.shortcuts.add.label;"/>
<label value="&zotero.zoterotag.help.shortcuts.remove.label;"/>
<label value="&zotero.zoterotag.help.setcolor.label;" class="zotero-text-link" href="https://github.com/windingwind/zotero-tag/blob/master/docs/tag-color.md"/>
</hbox>
</groupbox>
</vbox>
<tabbox>
<tabs>
<tab label="&zotero.zoterotag.rules.title;"/>
<tab label="&zotero.zoterotag.help.title.label;"/>
</tabs>

<tabpanels id="zotero-prefpane-zoterotag" orient="vertical" minheight="400">
<tabpanel id="zotero-prefpane-zoterotag-rules" orient="vertical">
<listbox id="zoterotag-rules-listbox" flex="1">
<listhead>
<listheader label="&zotero.zoterotag.rules.listheader.id;"/>
<listheader label="&zotero.zoterotag.rules.listheader.tags;"/>
<listheader label="&zotero.zoterotag.rules.listheader.group;"/>
<listheader label="&zotero.zoterotag.rules.listheader.autoadd;"/>
<listheader label="&zotero.zoterotag.rules.listheader.operation;"/>
</listhead>
<listcols>
<listcol/>
<listcol width="250"/>
<listcol/>
<listcol/>
<listcol/>
<!-- <listcol width="80"/> -->
</listcols>
<!-- <listitem id="zoterotag-rules-#" allowevents="true">
<listcell>
<label id="zoterotag-rules-#-id" value="#"/>
</listcell>
<listcell>
<textbox id="zoterotag-rules-#-tags"/>
</listcell>
<listcell>
<menulist id="zoterotag-rules-#-group">
<menupopup>
<menuitem value="1" label="1(&zotero.zoterotag.rules.group.default;)"/>
<menuitem value="2" label="2"/>
<menuitem value="3" label="3"/>
<menuitem value="0" label="&zotero.zoterotag.rules.group.other;"/>
</menupopup>
</menulist>
</listcell>
<listcell>
<checkbox id="zoterotag-rules-#-autoadd"/>
</listcell>
<listcell>
<button label="&zotero.zoterotag.rules.add;" tooltiptext="&zotero.zoterotag.rules.addtext;" oncommand="addRule()"/>
</listcell>
<listcell>
<button label="&zotero.zoterotag.rules.remove;" tooltiptext="&zotero.zoterotag.rules.removetext;" oncommand="" disabled="true"/>
</listcell>
</listitem> -->
</listbox>
<hbox style="display: block">
<button label="&zotero.zoterotag.rules.reset;" tooltiptext="&zotero.zoterotag.rules.resettext;" oncommand="resetPreferences()"/>
<label value="&zotero.zoterotag.rules.warningtext;" style="color: red"/>
</hbox>
</tabpanel>
<tabpanel id="zotero-prefpane-zoterotag-help" orient="vertical">
<groupbox>
<caption label="&zotero.zoterotag.help.rules.caption.label;"/>
<label value="&zotero.zoterotag.rules.info.1.label;"/>
<label value="&zotero.zoterotag.rules.info.2.label;"/>
<label value="&zotero.zoterotag.rules.info.3.label;"/>
<label value="&zotero.zoterotag.rules.info.4.label;"/>
<label value="&zotero.zoterotag.rules.info.5.label;"/>
</groupbox>
<groupbox>
<caption label="&zotero.zoterotag.help.shortcuts.caption.label;"/>
<hbox style="display: block">
<label value="&zotero.zoterotag.help.shortcuts.add.label;"/>
<label value="&zotero.zoterotag.help.shortcuts.remove.label;"/>
<label value="&zotero.zoterotag.help.shortcuts.auto.label;"/>
</hbox>
</groupbox>
<groupbox>
<caption label="&zotero.zoterotag.help.setcolor.caption.label;"/>
<hbox style="display: block">
<label value="&zotero.zoterotag.help.setcolor.label;" class="zotero-text-link" href="https://github.com/windingwind/zotero-tag/blob/master/docs/tag-color.md"/>
</hbox>
</groupbox>
<groupbox>
<caption label="&zotero.zoterotag.help.feedback.caption.label;"/>
<hbox style="display: block">
<label value="&zotero.zoterotag.help.feedback.label;" class="zotero-text-link" href="https://github.com/windingwind/zotero-tag/issues"/>
</hbox>
</groupbox>
<label value="&zotero.zoterotag.help.version.label;"/>
<label value="&zotero.zoterotag.help.releasetime.label;"/>
</tabpanel>
</tabpanels>
</tabbox>
</prefpane>
</prefwindow>

Expand Down
9 changes: 6 additions & 3 deletions chrome/content/scripts/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,15 @@ creatRuleListElement = function(rule) {
menulist = document.createElement("menulist");
menulist.setAttribute("id", `${listIDHead}-${rule.id}-group`);
menupopup = document.createElement("menupopup");
let menuValueList = ["1", "2", "3", "0"];
let menuLabelList = ["1(default)", "2", "3", "other"];
for(let i=0; i<4; i++){
let menuValueList = ["1", "2", "3", "4", "5", "6", "7", "8", "9"];
let menuLabelList = ["1(default)*", "2*", "3*", "4", "5", "6", "7", "8", "9"];
for(let i=0; i<menuValueList.length; i++){
menuitem = document.createElement("menuitem");
menuitem.setAttribute("value", menuValueList[i]);
menuitem.setAttribute("label", menuLabelList[i]);
if(menuLabelList[i][menuLabelList[i].length-1]==='*'){
menuitem.setAttribute("style", "color: green");
}
menupopup.appendChild(menuitem);
}
menulist.setAttribute("value", `${rule.group}`);
Expand Down
58 changes: 16 additions & 42 deletions chrome/content/scripts/zoterotag.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,50 +138,24 @@ Zotero.ZoteroTag = {
// keyset: {},

initKeys: function() {
let shortcuts = [
{
id: '1',
let shortcuts = [];
// init shortcuts
for(let i=0; i<=9; i++){
shortcuts.push({
id: String(i),
operation: 'add',
group: 1,
group: i,
modifiers: 'control',
key: '1',
},
{
id: '2',
operation: 'add',
group: 2,
modifiers: 'control',
key: '2',
},
{
id: '3',
operation: 'add',
group: 3,
modifiers: 'control',
key: '3',
},
{
id: '4',
operation: 'remove',
group: 1,
modifiers: 'alt',
key: '1',
},
{
id: '5',
operation: 'remove',
group: 2,
modifiers: 'alt',
key: '2',
},
{
id: '6',
key: String(i),
});
shortcuts.push({
id: String(i+10),
operation: 'remove',
group: 3,
group: i,
modifiers: 'alt',
key: '3',
},
];
key: String(i),
});
}
let keyset = document.createElement('keyset');
keyset.setAttribute('id', 'zoterotag-keyset');

Expand Down Expand Up @@ -288,7 +262,7 @@ Zotero.ZoteroTag = {
Zotero.debug(val);
Zotero.ZoteroTag.updateItem(val, operation, tags);
})
Zotero.ZoteroTag.showProgressWindow('SUCCESS', `${operation} ${tags.length} tags in ${items.length} items.`)
Zotero.ZoteroTag.showProgressWindow('SUCCESS', `${operation} ${tags.length>3?String(tags.length)+' tags':tags} ${operation==='add'?'to':'from'} ${items.length} items.`)
},
updateItem: function(item, operation, tags) {
Zotero.debug('ZoteroTag: Updating item: ' + JSON.stringify(item));
Expand All @@ -313,7 +287,7 @@ Zotero.ZoteroTag = {
progressWindow.changeHeadline(header);
progressWindow.progress = new progressWindow.ItemProgress(Zotero.ZoteroTag.progressWindowIcon[type], context);
progressWindow.show();
progressWindow.startCloseTimer(8000);
progressWindow.startCloseTimer(5000);
}
};

Expand Down
26 changes: 18 additions & 8 deletions chrome/locale/en-US/overlay.dtd
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@
<!ENTITY zotero.zoterotag.updateCollection.label "Update Collection Tags">

<!ENTITY zotero.zoterotag.rules.title "Rules Management">
<!ENTITY zotero.zoterotag.rules.info.1 "Rules in group 1, 2, and 3 can be added/removed in batches through the right-click menu;">
<!ENTITY zotero.zoterotag.rules.info.2 "You can set automatic addition for different rules;">
<!ENTITY zotero.zoterotag.rules.info.3 "Split different tags by ','(comma) and manage them in one rule;">
<!ENTITY zotero.zoterotag.rules.info.4 "Example: rule 2 contains 'tag1, tag2, tag3', and all three tags can be managed in rule 2.">
<!ENTITY zotero.zoterotag.rules.listheader.id "ID">
<!ENTITY zotero.zoterotag.rules.listheader.tags "Tags">
<!ENTITY zotero.zoterotag.rules.listheader.autoadd "Automatic Add">
<!ENTITY zotero.zoterotag.rules.listheader.autoadd "Auto-Add">
<!ENTITY zotero.zoterotag.rules.listheader.group "Group">
<!ENTITY zotero.zoterotag.rules.listheader.operation "Operation">
<!ENTITY zotero.zoterotag.rules.listheader.delete "Delete">
Expand All @@ -27,6 +23,20 @@
<!ENTITY zotero.zoterotag.rules.warningtext "The OK button will NOT save any rule modification. Please click ✅ to save modified rule.">

<!ENTITY zotero.zoterotag.help.title.label "Help">
<!ENTITY zotero.zoterotag.help.shortcuts.add.label "Add tag Group shortcuts: ctrl+1(Group 1), ctrl+2(Group 2), ctrl+3(Group 3).">
<!ENTITY zotero.zoterotag.help.shortcuts.remove.label "Remove tag Group shortcuts: alt+1(Group 1), alt+2(Group 2), alt+3(Group 3).">
<!ENTITY zotero.zoterotag.help.setcolor.label "How to colorize my tags?">
<!ENTITY zotero.zoterotag.help.rules.caption.label "Rules">
<!ENTITY zotero.zoterotag.rules.info.1.label "All rules can be added/removed using shortcut keys;">
<!ENTITY zotero.zoterotag.rules.info.2.label "Rules in group 1, 2, and 3 can also be controlled through the right-click menu;">
<!ENTITY zotero.zoterotag.rules.info.3.label "You can set automatic addition for different rules;">
<!ENTITY zotero.zoterotag.rules.info.4.label "Split different tags by ','(comma) and manage them in one rule;">
<!ENTITY zotero.zoterotag.rules.info.5.label "Example: rule 2 contains 'tag1, tag2, tag3', and all three tags can be managed in rule 2.">
<!ENTITY zotero.zoterotag.help.shortcuts.caption.label "Shortcut Keys">
<!ENTITY zotero.zoterotag.help.shortcuts.add.label "The shortcut keys for adding a tag group to selected items: ctrl+1 (group 1), ctrl+2 (group 2), and so on.">
<!ENTITY zotero.zoterotag.help.shortcuts.remove.label "The shortcut keys for removing a tag group from selected items: alt+1 (group 1), alt+2 (group 2), and so on.">
<!ENTITY zotero.zoterotag.help.shortcuts.auto.label "ctrl+0 (add group auto), alt+0 (remove group auto).">
<!ENTITY zotero.zoterotag.help.setcolor.caption.label "Colorize">
<!ENTITY zotero.zoterotag.help.setcolor.label "How to colorize my tags?">
<!ENTITY zotero.zoterotag.help.feedback.caption.label "Feedback">
<!ENTITY zotero.zoterotag.help.feedback.label "github">

<!ENTITY zotero.zoterotag.help.version.label "ZoteroTag VERSION 0.0.6">
<!ENTITY zotero.zoterotag.help.releasetime.label "2021-02-21 11:40:10">
24 changes: 17 additions & 7 deletions chrome/locale/zh-CN/overlay.dtd
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
<!ENTITY zotero.zoterotag.updateCollection.label "更新分类下所有标签">

<!ENTITY zotero.zoterotag.rules.title "规则管理">
<!ENTITY zotero.zoterotag.rules.info.1 "分组1,2,3中的规则可以通过右键菜单控制批量添加/移除;">
<!ENTITY zotero.zoterotag.rules.info.2 "可以为不同规则分别设置自动添加;">
<!ENTITY zotero.zoterotag.rules.info.3 "用半角逗号(,)分隔不同标签,并在一条规则中同时管理它们;">
<!ENTITY zotero.zoterotag.rules.info.4 "例如:规则2包含'tag1, tag2, tag3',则三个标签都将由规则2管理。">
<!ENTITY zotero.zoterotag.rules.listheader.id "序号">
<!ENTITY zotero.zoterotag.rules.listheader.tags "标签">
<!ENTITY zotero.zoterotag.rules.listheader.autoadd "自动添加">
Expand All @@ -27,6 +23,20 @@
<!ENTITY zotero.zoterotag.rules.warningtext "OK按钮【不会】保存更改,请单击✅以保存对规则的修改。">

<!ENTITY zotero.zoterotag.help.title.label "帮助">
<!ENTITY zotero.zoterotag.help.shortcuts.add.label "为选中项添加标签组快捷键: ctrl+1(组 1), ctrl+2(组 2), ctrl+3(组 3)。">
<!ENTITY zotero.zoterotag.help.shortcuts.remove.label "从选中项删除标签组快捷键: alt+1(组 1), alt+2(组 2), alt+3(组 3)。">
<!ENTITY zotero.zoterotag.help.setcolor.label "如何为标签添加颜色?">
<!ENTITY zotero.zoterotag.help.rules.caption.label "规则">
<!ENTITY zotero.zoterotag.rules.info.1.label "所有规则都可以使用快捷键添加/移除;">
<!ENTITY zotero.zoterotag.rules.info.2.label "分组1,2,3中的规则还可以通过右键菜单控制;">
<!ENTITY zotero.zoterotag.rules.info.3.label "可以为不同规则分别设置自动添加;">
<!ENTITY zotero.zoterotag.rules.info.4.label "用半角逗号(,)分隔不同标签,并在一条规则中同时管理它们;">
<!ENTITY zotero.zoterotag.rules.info.5.label "例如:规则2包含'tag1, tag2, tag3',则三个标签都将由规则2管理。">
<!ENTITY zotero.zoterotag.help.shortcuts.caption.label "快捷键">
<!ENTITY zotero.zoterotag.help.shortcuts.add.label "为选中项添加标签组快捷键: ctrl+1(组 1), ctrl+2(组 2), 以此类推。">
<!ENTITY zotero.zoterotag.help.shortcuts.remove.label "从选中项删除标签组快捷键: alt+1(组 1), alt+2(组 2),以此类推。">
<!ENTITY zotero.zoterotag.help.shortcuts.auto.label "ctrl+0 (添加“自动添加”标签组), alt+0 (移除“自动添加”标签组)。">
<!ENTITY zotero.zoterotag.help.setcolor.caption.label "为标签添加颜色">
<!ENTITY zotero.zoterotag.help.setcolor.label "如何为标签添加颜色?">
<!ENTITY zotero.zoterotag.help.feedback.caption.label "意见反馈">
<!ENTITY zotero.zoterotag.help.feedback.label "github">

<!ENTITY zotero.zoterotag.help.version.label "ZoteroTag 版本 0.0.6">
<!ENTITY zotero.zoterotag.help.releasetime.label "2021-02-21 11:40:10">
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="xy_wong@zju.edu.cn"
em:name="Zotero Tag"
em:version="0.0.5"
em:version="0.0.6"
em:type="2"
em:creator="windingwind"
em:description="Zotero plugin for automatically add tag for an added item."
Expand Down
Loading

0 comments on commit 24d9224

Please sign in to comment.