|
5 | 5 | var ZOTERO_CONFIG = { |
6 | 6 | "zotId": "2211939", // ID of group or user library to search in Zotero, e.g., 2211939, 2055673 |
7 | 7 | "zotIdType": "group", // group or user |
8 | | - "collectionKey": "", // Key of collection within library to search, e.g., "KHTHLKB5", or "" if no collection |
| 8 | + "collectionKey": "KHTHLKB5", // Key of collection within library to search, e.g., "KHTHLKB5", or "" if no collection |
9 | 9 | "filterTags": "", // For filtering results by tag(s), e.g., "&tag=LTER-Funded". See examples at https://www.zotero.org/support/dev/web_api/v3/basics |
10 | 10 | "resultsElementId": "searchResults", // Element to contain results |
11 | 11 | "includeCols": ["Year", "Type", "ShowTags"], // Array of columns to include in the output table, other than Citation. The full set is ["Year", "Type", "ShowTags"] |
@@ -282,12 +282,17 @@ function showUrl(url) { |
282 | 282 | } |
283 | 283 |
|
284 | 284 |
|
| 285 | +function encodeStyle(style) { |
| 286 | + return style.replace(/\//g, '%3A').replace(/:/g, '%2F'); |
| 287 | +} |
| 288 | + |
| 289 | + |
285 | 290 | // Passes search URL and callbacks to CORS function |
286 | 291 | function searchZotero(query, itemType, sort, start) { |
287 | 292 | var zotId = (ZOTERO_CONFIG["zotIdType"] === "group") ? "groups/" + ZOTERO_CONFIG["zotId"] : "users/" + ZOTERO_CONFIG["zotId"]; |
288 | | - var collection = (ZOTERO_CONFIG["collectionKey"] === "") ? "/" : "/collections/" + ZOTERO_CONFIG["collectionKey"] + "/"; |
| 293 | + var collection = (ZOTERO_CONFIG["collectionKey"] === "") ? "" : "/collections/" + ZOTERO_CONFIG["collectionKey"]; |
289 | 294 | var base = "https://api.zotero.org/" + zotId + collection + "/items?v=3&include=bib,data"; |
290 | | - var style = (ZOTERO_CONFIG["style"] === "") ? "" : "&style=" + ZOTERO_CONFIG["style"]; |
| 295 | + var style = (ZOTERO_CONFIG["style"] === "") ? "" : "&style=" + encodeStyle(ZOTERO_CONFIG["style"]); |
291 | 296 | var params = "&q=" + encodeURI(query) + "&itemType=" + itemType + |
292 | 297 | "&sort=" + sort + "&start=" + start + ZOTERO_CONFIG["filterTags"]; |
293 | 298 | var limit = "&limit=" + ZOTERO_CONFIG["limit"]; |
|
0 commit comments