1 // Defines common variables for testing
3 // What host to use for testing
5 // Autodetect if running from a home directory, or use live site
7 var patterns = [ new RegExp('.*?/~(.*?)/'), new RegExp('www-(.*?)\\.') ]
8 for (index in patterns) {
9 var match = patterns[index].exec(document.location.href);
17 return 'http://www-' + user + '.archive.org';
20 return 'http://www.archive.org'; // live site
27 // Set up dummy BookReader class for JSLocate
28 function BookReader() {
31 BookReader.prototype.init = function() {
36 // Returns locator URL for the given id
37 function jsLocateURL(identifier, book) {
38 var bookURL = common.testHost + '/bookreader/BookReaderJSLocate.php?id=' + identifier;
40 bookURL += '&book=' + book;
45 // Page should be in ['cover','title','preview']
46 function previewURL(identifier, subPrefix, page) {
47 var bookPrefix = subPrefix || identifier;
48 var previewPage = bookPrefix + '_' + page;
49 return imagePermalink(identifier, subPrefix, previewPage);
52 // Page should be e.g. page5.jpg, n4.jpg, cover_t.jpg, n4_r3.jpg
53 function imagePermalink(identifier, subPrefix, page) {
54 var imageURL = common.testHost + '/download/' + identifier;
56 imageURL += '/' + subPrefix;
58 imageURL += '/page/' + page;