added and clarified event msgs

This commit is contained in:
Andy Gup 2014-05-23 16:43:20 -06:00
parent b60dc5bae7
commit f59e5e3cf3

View File

@ -23,14 +23,17 @@ define([
MAX_DB_SIZE: 75, // Recommended maximum size in MBs
TILE_PATH:"", // The absolute path to the root of bundle/bundleX files e.g. V101/YOSEMITE_MAP/
RECENTER_DELAY: 350, // Millisecond delay before attempting to recent map after an orientation change
VALIDATION_ERROR: "validationError", // Library validation error.
DATABASE_ERROR: "databaseError", // An error thrown by the database.
PARSING_ERROR: 'parsingError', // An error was encountered while parsing a TPK file.
DB_INIT_ERROR: "dbInitError", // An error occurred while initializing the database.
DB_FULL_ERROR: "dbFullError", // No space left in the database.
NO_SUPPORT_ERROR: "libNotSupportedError", // Error indicating this library is not supported in a particular browser.
VALIDATION_EVENT: "validationEvent", // Library validation checks.
PROGRESS_EVENT: "progress", // Event dispatched while parsing a bundle file.
PROGRESS_START: "start",
PROGRESS_END: "end",
WINDOW_VALIDATED: "windowValidated", // All window functionality checks have passed
DB_VALIDATED: "dbValidated", // All database functionality checks have passed
//
// Private properties
@ -171,7 +174,10 @@ define([
//Verify if basic functionality is supported by the browser
if(!window.File && !window.FileReader && !window.Blob && !window.btoa && !window.DataView){
console.error(new Error( "This library is not supported on your browser!").stack);
this.emit(this.VALIDATION_ERROR,{msg:this.NO_SUPPORT_ERROR, err : null});
this.emit(this.VALIDATION_EVENT,{msg:this.NO_SUPPORT_ERROR, err : null});
}
else{
this.emit(this.VALIDATION_EVENT,{msg:this.WINDOW_VALIDATED, err : null});
}
//Verify if IndexedDB is supported and initializes properly
@ -187,8 +193,9 @@ define([
var mb = this._bytes2MBs(size.sizeBytes);
if(mb > this.MAX_DB_SIZE){
console.error(new Error( "Database is full!").stack);
this.emit(this.DATABASE_ERROR,{msg:"Database full! ",err : err});
this.emit(this.DATABASE_ERROR,{msg:this.DB_FULL_ERROR,err : err});
}
this.emit(this.VALIDATION_EVENT,{msg:this.DB_VALIDATED,err : null})
console.log("DB size: " + mb + " MBs, Tile count: " + size.tileCount + ", Error: " + err)
}.bind(this))
}
@ -197,7 +204,7 @@ define([
else
{
console.error(new Error( "IndexedDB is not supported on your browser.").stack);
this.emit(this.VALIDATION_ERROR,{msg:"IndexedDB is not supported.", err : null});
this.emit(this.VALIDATION_EVENT,{msg:this.NO_SUPPORT_ERROR, err : null});
}
},