Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
dev:translator_coding [2011/02/05 20:40] – rmzelle | dev:translator_coding [2017/11/12 19:53] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | Below we will describe how the '' | + | < |
+ | in the process | ||
+ | <a href="https://www.zotero.org/blog/zotero-5-0"> | ||
+ | may be outdated in the meantime. Thanks for your understanding.</ | ||
- | ====== Web Translators ====== | ||
- | ===== detectWeb ===== | + | See [[dev/translators/Coding]]. |
- | + | ||
- | '' | + | |
- | + | ||
- | '' | + | |
- | + | ||
- | <code javascript> | + | |
- | + | ||
- | if (url.indexOf(" | + | |
- | return " | + | |
- | } else if (url.indexOf(" | + | |
- | return " | + | |
- | } | + | |
- | }</ | + | |
- | + | ||
- | ===== doWeb ===== | + | |
- | + | ||
- | '' | + | |
- | + | ||
- | ==== Saving Single Items ==== | + | |
- | + | ||
- | === Metadata === | + | |
- | + | ||
- | The first step towards saving an item is to create an item object of the desired [[http:// | + | |
- | + | ||
- | <code javascript> | + | |
- | + | ||
- | Metadata can then be stored in the properties of the object. Of the different fields available for the chosen item type (see the [[http:// | + | |
- | + | ||
- | <code javascript> | + | |
- | newItem.title = title; | + | |
- | + | ||
- | var PMID = citation.PMID.text().toString(); | + | |
- | newItem.url = " | + | |
- | + | ||
- | After all metadata has been stored in the item object, the item can be saved: | + | |
- | + | ||
- | <code javascript> | + | |
- | + | ||
- | This process can be repeated (e.g. using a loop) to save multiple items. | + | |
- | + | ||
- | === Attachments === | + | |
- | + | ||
- | Attachments may be saved alongside item metadata via the item object' | + | |
- | + | ||
- | <code javascript> | + | |
- | newItem.attachments = [{ | + | |
- | url: linkurl, | + | |
- | title: " | + | |
- | mimeType: " | + | |
- | snapshot: false}]; | + | |
- | + | ||
- | var pdfurl = " | + | |
- | newItem.attachments.push({ | + | |
- | title:" | + | |
- | mimeType:" | + | |
- | url: | + | |
- | + | ||
- | An attachment can only be saved if the source is indicated. The source is often a URL (set on the '' | + | |
- | + | ||
- | === Notes === | + | |
- | + | ||
- | Notes are saved similarly to attachments. The content of the note, which should consist of a string, should be stored in the '' | + | |
- | + | ||
- | <code javascript> | + | |
- | newItem.notes.push({note: | + | |
- | + | ||
- | ==== Saving Multiple Items ==== | + | |
- | + | ||
- | Some webpages, such as those showing search results or the index of a journal issue, list multiple items. For these pages, web translators can be written to a) allow the user to select one or more items and b) batch save the selected items to the user's Zotero library. | + | |
- | + | ||
- | === Item Selection === | + | |
- | + | ||
- | To present the user with a selection window that shows all the items that have been found on the webpage, a JavaScript object should be created. Then, for each item, an item ID and label should be stored in the object as a property/ | + | |
- | + | ||
- | <code javascript> | + | |
- | var items = new Object(); | + | |
- | ... | + | |
- | while (next_title = titles.iterateNext()) { | + | |
- | items[next_title.href] = Zotero.Utilities.trim(next_title.textContent); | + | |
- | } | + | |
- | items = Zotero.selectItems(items); | + | |
- | ... | + | |
- | }</ | + | |
- | + | ||
- | For compatibility with Zotero Standalone, '' | + | |
- | + | ||
- | === Batch Saving === | + |