===== Chapter 14: DetectWeb Tab =====
[[http://niche-canada.org/member-projects/zotero-guide/chapter14.html|HWZT chapter 14 (DetectWeb Tab)]]: the tutorial example works in Scaffold 2.0 and Firefox 3.5, with 2 minor exceptions
- HWZT says "Save your entry and click Execute": instead click icon="Run detectWeb" (the eye)
- HWZT says "If you would like to see the Icon in the address bar [of the first sample page], you will likely have to relaunch Firefox": in fact, if you have in fact saved your entry, you need only reload the page or tab.
As HWZT has gotten increasingly casual, here are some step-by-step instructions for this chapter's tutorial section:
- Close any running Scaffold 2.0 instances.
- Ensure the [[http://niche-canada.org/member-projects/zotero-guide/sample1.html|first sample page]] is open in your browser and has focus.
- Open Scaffold 2.0 from the Firefox main menu with Tools>Scaffold. This should popup dialog="Zotero Scaffold".
- Hit icon=Load (the non-OS UI item closest to the upper left of the dialog). This should popup dialog="Load Translator" displaying a single table mapping "Label" to "Creator".
- Scroll through the "Load Translator" table until you see Label=How to Write a Zotero Translator, then hit button=OK.
- You will return to the main dialog="Zotero Scaffold". Check to see that tab=Metadata is properly populated.
- Switch to tab=Code and enter the following:function detectWeb(doc, url) {
if (doc.title.match("Single Item")) {
return "book";
} else if (doc.title.match("Search Results")) {
return "multiple";
}
}
- Click icon="Run detectWeb" (the eye): in the Test Frame you should get results like 12:00:00 detectWeb returned type "book"
- Click icon=Save (second from left): your translator should save silently.
- Return focus to the page or tab containing the [[http://niche-canada.org/member-projects/zotero-guide/sample1.html|first sample page]] and refresh it: you should see the Zotero book icon in the location field of your Firefox.
**Next**: [[dev/How to Write a Zotero Translator, 2nd Edition/Chapter 15|Chapter 15: Scraping the Search Results Page: doWeb Function]]