Skip to content

Commit

Permalink
Get dbCatalog parameter from search page. Show pdf bookmark popup in …
Browse files Browse the repository at this point in the history
…theis item. Do not update the item when creates are the same
  • Loading branch information
l0o0 committed Jul 14, 2020
1 parent eac3432 commit 1a40ea1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 25 deletions.
39 changes: 19 additions & 20 deletions chrome/content/scripts/jasminum.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,17 @@ Zotero.Jasminum = {
};
},

createPost: function (fileData) {
createPost: async function (fileData) {
var searchUrl =
"https://kns.cnki.net/kns/brief/result.aspx?dbprefix=SCDB&crossDbcodes=CJFQ,CDFD,CMFD,CPFD,IPFD,CCND,CCJD";
var respText = await Zotero.Jasminum.promiseGet(searchUrl);
var dbCatalog = "";
if (respText.includes("中国学术期刊网络出版总库")) {
dbCatalog = "中国学术期刊网络出版总库";
} else {
dbCatalog = "中国学术文献网络出版总库";
}
Zotero.debug("** Jasminum search dbCatalog: " + dbCatalog);
// Create a search string.
static_post_data = {
action: "",
Expand Down Expand Up @@ -191,17 +201,6 @@ Zotero.Jasminum = {
return { dbname: dbname[1], filename: filename[1], dbcode: dbcode[1] };
},

parseRef: function (targetID) {
var postData =
"formfilenames=" +
encodeURIComponent(
targetID.dbname + "!" + targetID.filename + "!1!0,"
) +
"&hid_kLogin_headerUrl=/KLogin/Request/GetKHeader.ashx%3Fcallback%3D%3F" +
"&hid_KLogin_FooterUrl=/KLogin/Request/GetKHeader.ashx%3Fcallback%3D%3F" +
"&CookieName=FileNameS";
},

promiseGet: function (url) {
Zotero.debug("** Jasminum create http get.");
return new Promise(function (resolve, reject) {
Expand All @@ -228,7 +227,7 @@ Zotero.Jasminum = {
},

searchPrepare: async function (fileData) {
var searchData = Zotero.Jasminum.createPost(fileData);
var searchData = await Zotero.Jasminum.createPost(fileData);
var SEARCH_HANDLE_URL =
"https://kns.cnki.net/kns/request/SearchHandler.ashx";
var url = SEARCH_HANDLE_URL + "?" + searchData;
Expand Down Expand Up @@ -442,8 +441,9 @@ Zotero.Jasminum = {
item.attachmentContentType &&
item.attachmentContentType === "application/pdf" &&
item.parentItem.getField("libraryCatalog") &&
item.parentItem.getField("libraryCatalog").includes("CNKI")
); // Contain Chinese
item.parentItem.getField("libraryCatalog").includes("CNKI") &&
item.parentItem.itemTypeID === 7
);
},

getChapterUrl: async function (itemUrl) {
Expand Down Expand Up @@ -478,19 +478,16 @@ Zotero.Jasminum = {
getBookmark: async function (item) {
// demo url https://kreader.cnki.net/Kreader/buildTree.aspx?dbCode=cdmd&FileName=1020622678.nh&TableName=CMFDTEMP&sourceCode=GHSFU&date=&year=2020&period=&fileNameList=&compose=&subscribe=&titleName=&columnCode=&previousType=_&uid=
var parentItem = item.parentItem;
var parentItemType = parentItem.itemTypeID; // theis = 7
var itemUrl = "";
var itemChapterUrl = "";

if (
parentItemType === 7 &&
parentItem.getField("extra") &&
parentItem.getField("extra").includes("cnki")
) {
Zotero.debug("1");
itemChapterUrl = parentItem.getField("extra");
} else if (
parentItemType === 7 &&
parentItem.getField("url") &&
parentItem.getField("url").includes("cnki")
) {
Expand Down Expand Up @@ -658,8 +655,10 @@ Zotero.Jasminum = {
}
creators[i] = creator;
}
item.setCreators(creators);
item.saveTx();
if (creators != item.getCreators()) {
item.setCreators(creators);
item.saveTx();
}
}
},
};
Expand Down
5 changes: 0 additions & 5 deletions install.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@
<em:iconURL>chrome://jasminum/skin/icon.png</em:iconURL>
<em:multiprocessCompatible>true</em:multiprocessCompatible>
<em:creator>Xingzhong Lin</em:creator>
<!--
<em:homepageURL>http://www.google.com</em:homepageURL>
<em:optionsURL>chrome://znote/content/options.xul</em:optionsURL>
<em:updateURL>https://raw.githubusercontent.com/jlegewie/zotfile/master/zotfile-update.rdf</em:updateURL>
-->

<em:targetApplication>
<Description>
Expand Down

0 comments on commit 1a40ea1

Please sign in to comment.