This commit is contained in:
Wolfgang Sourdeau
2012-10-19 04:34:13 -04:00
parent b744710ee3
commit b005b872de
2 changed files with 30 additions and 30 deletions

View File

@@ -1,17 +1,17 @@
/* -*- Mode: js2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
SOGoMailDataSource = Class.create({
initialize: function(dataTable, url) {
// Instance variables
this.dataTable = dataTable;
this.id = url;
this.url = url;
this.uids = new Array();
this.threaded = false;
this.cache = new Hash();
this.loaded = false;
this.delayedGetData = false;
this.ajaxGetData = false;
@@ -19,7 +19,7 @@ SOGoMailDataSource = Class.create({
// Constants
this.overflow = 50; // must be higher or equal to the overflow of the data table class
},
destroy: function() {
this.uids.clear();
var keys = this.cache.keys();
@@ -71,7 +71,7 @@ SOGoMailDataSource = Class.create({
this.loaded = true;
// log ("MailDataSource.init() " + this.uids.length + " UIDs, " + this.cache.keys().length + " headers");
},
load: function(urlParams) {
var params;
this.loaded = false;
@@ -89,7 +89,7 @@ SOGoMailDataSource = Class.create({
params,
{ "Content-type": "application/x-www-form-urlencoded" });
},
_loadCallback: function(http) {
if (http.status == 200) {
if (http.responseText.length > 0) {
@@ -108,7 +108,7 @@ SOGoMailDataSource = Class.create({
log("SOGoMailDataSource._loadCallback Error " + http.status + ": " + http.responseText);
}
},
getData: function(id, index, count, callbackFunction, delay) {
if (this.loaded == false) {
// UIDs are not yet loaded -- delay the call until loading the data is completed.
@@ -124,12 +124,12 @@ SOGoMailDataSource = Class.create({
callbackFunction
).delay(delay);
},
_getData: function(id, index, count, callbackFunction) {
var start, end;
var i, j;
var missingUids = new Array();
if (count > 1) {
// Compute last index depending on number of UIDs
start = index - (this.overflow/2);
@@ -170,7 +170,7 @@ SOGoMailDataSource = Class.create({
else if (callbackFunction)
this._returnData(callbackFunction, id, start, end);
},
_getRemoteData: function(callbackData, urlParams) {
if (this.ajaxGetData) {
this.ajaxGetData.aborted = true;
@@ -184,7 +184,7 @@ SOGoMailDataSource = Class.create({
urlParams,
{ "Content-type": "application/x-www-form-urlencoded" });
},
_getRemoteDataCallback: function(http) {
if (http.status == 200) {
if (http.responseText.length > 0) {
@@ -207,7 +207,7 @@ SOGoMailDataSource = Class.create({
log("SOGoMailDataSource._getRemoteDataCallback Error " + http.status + ": " + http.responseText);
}
},
_returnData: function(callbackFunction, id, start, end) {
var i, j;
var data = new Array();