closes #264, UMich lib catalog doesn't work on Windows; other issues related to Mirlyn

positions "saving item" window in a slightly better place on Windows

the UMich bug was actually bigger than I though. as it turns out, the HiddenDOMWindow in Windows is not a chrome window, so i had to modify createHiddenBrowser() to attach the hidden browser object to an existing browser window. i don't believe this should have any adverse effects for snapshots, etc., but Dan, correct me if i'm wrong. it would be nice to be able to create a real chrome instance instead of a XUL element, but all of my attempts at doing so have failed.
This commit is contained in:
Simon Kornblith 2006-09-04 20:19:38 +00:00
parent 2b0bebe7a4
commit aa6e2cfab1
4 changed files with 41 additions and 34 deletions

View File

@ -457,8 +457,8 @@ Scholar_Ingester_Interface.Progress = new function() {
function _move() { function _move() {
_progressWindow.sizeToContent(); _progressWindow.sizeToContent();
_progressWindow.moveTo( _progressWindow.moveTo(
window.screenX + window.outerWidth - _progressWindow.outerWidth - 30, window.screenX + window.innerWidth - _progressWindow.outerWidth - 30,
window.screenY + window.outerHeight - _progressWindow.outerHeight - 10 window.screenY + window.innerHeight - _progressWindow.outerHeight - 10
); );
} }

View File

@ -770,15 +770,15 @@ Scholar.Browser = new function() {
function createHiddenBrowser(myWindow) { function createHiddenBrowser(myWindow) {
if(!myWindow) { if(!myWindow) {
var myWindow = Components.classes["@mozilla.org/appshell/appShellService;1"] var myWindow = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIAppShellService) .getService(Components.interfaces.nsIWindowMediator)
.hiddenDOMWindow; .getMostRecentWindow("navigator:browser");
} }
// Create a hidden browser // Create a hidden browser
var newHiddenBrowser = myWindow.document.createElement("browser"); var newHiddenBrowser = myWindow.document.createElement("browser");
var windows = myWindow.document.getElementsByTagName("window"); Scholar.debug(myWindow.document.documentElement.nodeName);
windows[0].appendChild(newHiddenBrowser); myWindow.document.documentElement.appendChild(newHiddenBrowser);
Scholar.debug("created hidden browser"); Scholar.debug("created hidden browser");
return newHiddenBrowser; return newHiddenBrowser;
} }

View File

@ -499,6 +499,7 @@ Scholar.Utilities.HTTP = new function() {
// want to do this, because it makes it easier to leak memory // want to do this, because it makes it easier to leak memory
Scholar.Utilities.HTTP.processDocuments = function(firstDoc, urls, processor, done, exception, saveBrowser) { Scholar.Utilities.HTTP.processDocuments = function(firstDoc, urls, processor, done, exception, saveBrowser) {
var hiddenBrowser = Scholar.Browser.createHiddenBrowser(); var hiddenBrowser = Scholar.Browser.createHiddenBrowser();
hiddenBrowser.docShell.allowImages = false;
var prevUrl, url; var prevUrl, url;
if (urls.length == 0) { if (urls.length == 0) {

View File

@ -5,7 +5,7 @@ REPLACE INTO "version" VALUES ('repository', STRFTIME('%s', '2006-08-31 22:44:00
REPLACE INTO "translators" VALUES ('96b9f483-c44d-5784-cdad-ce21b984fe01', '2006-08-11 11:18:00', 4, 'Amazon.com', 'Simon Kornblith', '^http://www\.amazon\.com/', REPLACE INTO "translators" VALUES ('96b9f483-c44d-5784-cdad-ce21b984fe01', '2006-08-11 11:18:00', 4, 'Amazon.com', 'Simon Kornblith', '^http://www\.amazon\.com/',
'function detectWeb(doc, url) { 'function detectWeb(doc, url) {
var searchRe = new RegExp(''^http://www\.amazon\.com/(gp/search/|exec/obidos/search-handle-url/|s/)''); var searchRe = new RegExp(''^http://(?:www\.)?amazon\.com/(gp/search/|exec/obidos/search-handle-url/|s/)'');
if(searchRe.test(doc.location.href)) { if(searchRe.test(doc.location.href)) {
return "multiple"; return "multiple";
} else { } else {
@ -1704,9 +1704,9 @@ function doWeb(doc, url) {
} }
}'); }');
REPLACE INTO "translators" VALUES ('cf87eca8-041d-b954-795a-2d86348999d5', '2006-06-26 16:01:00', 4, 'Aleph', 'Simon Kornblith', '^http://[^/]+/F(?:/[A-Z0-9\-]+(?:\?.*)?$|\?func=find)', REPLACE INTO "translators" VALUES ('cf87eca8-041d-b954-795a-2d86348999d5', '2006-06-26 16:01:00', 4, 'Aleph', 'Simon Kornblith', '^http://[^/]+/F(?:/[A-Z0-9\-]+(?:\?.*)?$|\?func=find|\?func=scan)',
'function detectWeb(doc, url) { 'function detectWeb(doc, url) {
var singleRe = new RegExp("^http://[^/]+/F/[A-Z0-9\-]+\?.*func=full-set-set.*\&format=[0-9]{3}"); var singleRe = new RegExp("^http://[^/]+/F/[A-Z0-9\-]+\?.*(?:func=full-set-set.*\&format=[0-9]{3}|func=direct)");
if(singleRe.test(doc.location.href)) { if(singleRe.test(doc.location.href)) {
return "book"; return "book";
@ -1720,14 +1720,15 @@ REPLACE INTO "translators" VALUES ('cf87eca8-041d-b954-795a-2d86348999d5', '2006
} }
}', }',
'function doWeb(doc, url) { 'function doWeb(doc, url) {
var detailRe = new RegExp("^http://[^/]+/F/[A-Z0-9\-]+\?.*func=full-set-set.*\&format=[0-9]{3}"); var detailRe = new RegExp("^http://[^/]+/F/[A-Z0-9\-]+\?.*(?:func=full-set-set.*\&format=[0-9]{3}|func=direct)");
var uri = doc.location.href; var uri = doc.location.href;
var newUris = new Array(); var newUris = new Array();
if(detailRe.test(uri)) { if(detailRe.test(uri)) {
newUris.push(uri.replace(/\&format=[0-9]{3}/, "&format=001")) newUris.push(uri.replace(/\&format=[0-9]{3}/, "&format=001"))
} else { } else {
var items = Scholar.Utilities.getItemArray(doc, doc, ''^http://[^/]+/F/[A-Z0-9\-]+\?.*func=full-set-set.*\&format=999'', ''^[0-9]+$''); var itemRegexp = ''^http://[^/]+/F/[A-Z0-9\-]+\?.*(?:func=full-set-set.*\&format=999|func=direct)''
var items = Scholar.Utilities.getItemArray(doc, doc, itemRegexp, ''^[0-9]+$'');
// ugly hack to see if we have any items // ugly hack to see if we have any items
var haveItems = false; var haveItems = false;
@ -1738,7 +1739,7 @@ REPLACE INTO "translators" VALUES ('cf87eca8-041d-b954-795a-2d86348999d5', '2006
// If we don''t have any items otherwise, let us use the numbers // If we don''t have any items otherwise, let us use the numbers
if(!haveItems) { if(!haveItems) {
var items = Scholar.Utilities.getItemArray(doc, doc, ''^http://[^/]+/F/[A-Z0-9\-]+\?.*func=full-set-set.*\&format=999''); var items = Scholar.Utilities.getItemArray(doc, doc, itemRegexp);
} }
items = Scholar.selectItems(items); items = Scholar.selectItems(items);
@ -1748,7 +1749,11 @@ REPLACE INTO "translators" VALUES ('cf87eca8-041d-b954-795a-2d86348999d5', '2006
} }
for(var i in items) { for(var i in items) {
newUris.push(i.replace("&format=999", "&format=001")); var newUri = i.replace("&format=999", "&format=001");
if(newUri == i) {
newUri += "&format=001";
}
newUris.push(newUri);
} }
} }
@ -5728,6 +5733,7 @@ record.prototype.importBinary = function(record) {
// add a field to this record // add a field to this record
record.prototype.addField = function(field, indicator, value) { record.prototype.addField = function(field, indicator, value) {
Scholar.Utilities.debug("adding field "+field+": "+value);
field = parseInt(field, 10); field = parseInt(field, 10);
// make sure indicator is the right length // make sure indicator is the right length
if(indicator.length > this.indicatorLength) { if(indicator.length > this.indicatorLength) {