Add support for reduce. Update unit tests for subdir books.
[bookreader.git] / BookReaderIA / test / unit / Common.js
1 // Defines common variables for testing
2
3 // $$$ TODO make test host auto-magic
4 common = {
5     testHost: 'http://www-testflip.archive.org'
6     //testHost: 'http://www-mang.archive.org'    
7 }
8
9 // Set up dummy BookReader class for JSLocate
10 function BookReader() {
11 };
12
13 BookReader.prototype.init = function() {
14     return true;
15 };
16
17
18 // Returns locator URL for the given id
19 function jsLocateURL(identifier, book) {
20     var bookURL = common.testHost + '/bookreader/BookReaderJSLocate.php?id=' + identifier;
21     if (book) {
22         bookURL += '&book=' + book;
23     }
24     return bookURL;
25 }
26
27 // Page should be in ['cover','title','preview']
28 function previewURL(identifier, subPrefix, page) {
29     var bookPrefix = subPrefix || identifier;
30     var previewPage = bookPrefix + '_' + page;
31     return imagePermalink(identifier, subPrefix, previewPage);
32 }
33
34 // Page should be e.g. page5.jpg, n4.jpg, cover_t.jpg, n4_r3.jpg
35 function imagePermalink(identifier, subPrefix, page) {
36     var imageURL = common.testHost + '/download/' + identifier;
37     if (subPrefix) {
38         imageURL += '/' + subPrefix;
39     }
40     imageURL += '/page/' + page;
41     return imageURL;
42 }