Skip to content

Commit

Permalink
期刊标签
Browse files Browse the repository at this point in the history
  • Loading branch information
MuiseDestiny committed Feb 10, 2023
1 parent 78e8000 commit 7a135e7
Show file tree
Hide file tree
Showing 7 changed files with 357 additions and 22 deletions.
28 changes: 15 additions & 13 deletions addon/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,21 @@ function setDefaultPrefs(rootURI) {
var branch = Services.prefs.getDefaultBranch("");
var obj = {
pref(pref, value) {
switch (typeof value) {
case "boolean":
branch.setBoolPref(pref, value);
break;
case "string":
branch.setStringPref(pref, value);
break;
case "number":
branch.setIntPref(pref, value);
break;
default:
Zotero.logError(`Invalid type '${typeof value}' for pref '${pref}'`);
}
try {
switch (typeof value) {
case "boolean":
branch.setBoolPref(pref, value);
break;
case "string":
branch.setStringPref(pref, value);
break;
case "number":
branch.setIntPref(pref, value);
break;
default:
Zotero.logError(`Invalid type '${typeof value}' for pref '${pref}'`);
}
} catch {}
},
};
Zotero.getMainWindow().console.log(rootURI + "prefs.js");
Expand Down
1 change: 1 addition & 0 deletions addon/chrome/locale/en-US/addon.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ tabpanel.reader.tab.label=Reader Tab


column.IF=IF
column.PublicationTags=Publication Tags
column.Rating=Rating
column.Progress=Progress
column.Tags=Tags
Expand Down
1 change: 1 addition & 0 deletions addon/chrome/locale/zh-CN/addon.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ tabpanel.lib.tab.label=库标签
tabpanel.reader.tab.label=阅读器标签

column.IF=影响因子
column.PublicationTags=期刊标签
column.Rating=评级
column.Progress=进度
column.Tags=标签
Expand Down
10 changes: 8 additions & 2 deletions addon/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ pref("extensions.zotero.__addonRef__.textTagsColumn.textColor", "black");
pref("extensions.zotero.__addonRef__.textTagsColumn.prefix", "#");




pref("extensions.zotero.__addonRef__.titleColumn.color", "#FFC6D3");
pref("extensions.zotero.__addonRef__.titleColumn.tags", false);
pref("extensions.zotero.__addonRef__.titleColumn.opacity", "0.7");
Expand All @@ -23,6 +21,14 @@ pref("extensions.zotero.__addonRef__.IFColumn.opacity", "0.7");
pref("extensions.zotero.__addonRef__.IFColumn.max", "15");
pref("extensions.zotero.__addonRef__.IFColumn.info", false);

pref("extensions.zotero.__addonRef__.PublicationTagsColumn.fields", "sci, sciif5, eii");
pref("extensions.zotero.__addonRef__.PublicationTagsColumn.opacity", "0.5");
pref("extensions.zotero.__addonRef__.PublicationTagsColumn.fieldColor", '{"sci":{"Q1":"#ff9999","Q2":"#86dad1","Q3":"#ffe78f","Q4":"#ffd4a9","Q5":"#cce5ff"}}');
pref("extensions.zotero.__addonRef__.PublicationTagsColumn.defaultColor", "#86dad1");
pref("extensions.zotero.__addonRef__.PublicationTagsColumn.textColor", 'black');
pref("extensions.zotero.__addonRef__.PublicationTagsColumn.sortBy", 'sci');




pref("extensions.zotero.__addonRef__.progressColumn.style", "bar");
Expand Down
1 change: 1 addition & 0 deletions src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ async function onStartup() {
await views.createTextTagsColumn()
await views.createProgressColumn()
await views.createIFColumn()
await views.createPublicationTagsColumn()
// await views.createRatingColumn()
let createForceGraph = views.createForceGraph()
views.registerSwitchColumnsViewUI()
Expand Down
10 changes: 5 additions & 5 deletions src/modules/progress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default class Progress {
if (limit > 0) {
maxValue = maxValue > limit ? maxValue : limit
}
let [r, g, b] = this.getRGB(color)
let [r, g, b] = Progress.getRGB(color)
for (let value of values) {
span.appendChild(
ztoolkit.UI.createElement(
Expand Down Expand Up @@ -100,7 +100,7 @@ export default class Progress {

const paper = Raphael(container, "100%", "100%");
paper.setViewBox(0, 0, w, h, true)
const [red, green, blue] = this.getRGB(color)
const [red, green, blue] = Progress.getRGB(color)
paper.path(polygon).attr({
stroke: "transparent",
fill: `90-rgba(${red}, ${green}, ${blue}, ${opacity})-rgba(${red}, ${green}, ${blue}, 0.8)`,
Expand Down Expand Up @@ -149,7 +149,7 @@ export default class Progress {
opacity
}
})
const [red, green, blue] = this.getRGB(color)
const [red, green, blue] = Progress.getRGB(color)
for (let value of values) {
const styles = {
position: "absolute",
Expand Down Expand Up @@ -186,7 +186,7 @@ export default class Progress {
* 显示百分比
*/
public linePercent(value: number, maxValue: number, color: string = "#62B6B7", opacity: string = "1"): HTMLSpanElement {
const [red, green, blue] = this.getRGB(color)
const [red, green, blue] = Progress.getRGB(color)
const percent = value / maxValue * 100
const heightPct = 0.28
const span = ztoolkit.UI.createElement(
Expand Down Expand Up @@ -245,7 +245,7 @@ export default class Progress {

}

public getRGB(color: string) {
static getRGB(color: string) {
var sColor = color.toLowerCase();
//十六进制颜色值的正则表达式
var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
Expand Down
Loading

0 comments on commit 7a135e7

Please sign in to comment.