Translator issue: detection triggered too early

Hello,

I have written a translator for a website (www.pv-tech.org). It works fine with Zotero 1 (I've developed it with Scaffold) but the detection fails in many cases with Zotero 2.
The issue is that the detection is triggered too soon, before the page is entirely loaded. As the translator relies on the presence of some div of a particular class, it gives misleading results if the page is not completely loaded.

A workaround is to create a recursive call until a div which is on all complete pages is seen (cf. code below). It works, but I'd rather avoid this kind of tricks.

Any better idea?


var urlComponents = url.split("/");

if (doc.evaluate('//div[@class="article"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()){
if (urlComponents[3]=="events" || urlComponents[3]=="tariff_watch"){
return("webpage");
} else{
return("multiple");
}
} else{
// most single pages are simple "web pages" except blogs, technical papers, and solar leader video clip
if (doc.evaluate('//div[@id="paper"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()){
// the page is fully loaded
if (urlComponents[3] == "editors_blog" || urlComponents[3] == "chip_shots"){
return("blogPost");
} else if (urlComponents[3] == "technical_papers"){
return("journalArticle");
} else if (urlComponents[3] == "solar_leaders_video_clips"){
return("videoRecording");
} else{
return("webpage");
}
} else{
// carry on trying
return(detectWeb(doc, url));
}
}
  • Better to post this to zotero-dev, and ideally include a link to the draft translator (in 2.0 form). Nobody has ever reported anything like this, so I suspect there's either a problem with your translator or the site is doing something funky.
  • Hi Dan,

    The detection part of the translator is fairly standard. The site may do something funny, but the translator reproducibly worked with Zotero 1, and reproducibly failed with Zotero 2 (same site, same browser). So it seems reasonable to think some changes in the way Zotero operates caused the problem, doesn't it?

    By the way, I did post the message and the translator on zotero-dev two weeks ago. No reply so far.
  • See my response on the list.
This discussion has been closed.