br.getOpenLibraryRecord = function(callback) {
// Try looking up by ocaid first, then by source_record
- var jsonURL = this.olHost + '/query.json?type=/type/edition&*=&ocaid=' + br.bookId;
+ var self = this; // closure
+
+ var jsonURL = self.olHost + '/query.json?type=/type/edition&*=&ocaid=' + self.bookId;
$.ajax({
url: jsonURL,
success: function(data) {
if (data && data.length > 0) {
- callback(br, data[0]);
+ callback(self, data[0]);
} else {
// try sourceid
- jsonURL = this.olHost + '/query.json?type=/type/edition&*=&source_records=ia:' + br.bookId;
+ jsonURL = self.olHost + '/query.json?type=/type/edition&*=&source_records=ia:' + self.bookId;
$.ajax({
url: jsonURL,
success: function(data) {
if (data && data.length > 0) {
- callback(br, data[0]);
+ callback(self, data[0]);
}
},
dataType: 'jsonp'
} else if (brConfig['mode'] == 2) {
br.mode = 2;
}
+
+ if (typeof(brConfig["isAdmin"]) != 'undefined') {
+ br.isAdmin = brConfig["isAdmin"];
+ } else {
+ br.isAdmin = false;
+ }
} // brConfig
this.popup.innerHTML = ['<p><strong>', msg, '</strong></p><p>', resolution, '</p>'].join('\n');
}
+OLAuth.prototype.showError = function(msg, resolution) {
+ $(this.popup).css({
+ backgroundColor: "#fff",
+ color: "#000"
+ });
+
+ this.setPopupMsg(msg, resolution);
+}
+
OLAuth.prototype.initCallback = function(obj) {
if (false == obj.success) {
- $(this.popup).css({
- backgroundColor: "#fff",
- color: "#000"
- });
-
- this.setPopupMsg(obj.msg, obj.resolution);
- return;
+ if (br.isAdmin) {
+ ret = confirm("We couldn't authenticate your loan with Open Library, but since you are an administrator or uploader of this book, you can access this book for QA purposes. Would you like to QA this book?");
+ if (!ret) {
+ this.showError(obj.msg, obj.resolution)
+ } else {
+ br.init();
+ }
+ } else {
+ this.showError(obj.msg, obj.resolution)
+ }
+ } else {
+ //user is authenticated
+ this.setCookie(obj.token);
+ this.olConnect = true;
+ this.startPolling();
+ br.init();
}
-
- //user is authenticated
- this.setCookie(obj.token);
- this.olConnect = true;
- this.startPolling();
- br.init();
}
OLAuth.prototype.callback = function(obj) {