DatabaseTableView.js [plain text]
WebInspector.DatabaseTableView = function(database, tableName)
{
WebInspector.View.call(this);
this.database = database;
this.tableName = tableName;
this.element.addStyleClass("database-view");
this.element.addStyleClass("table");
}
WebInspector.DatabaseTableView.prototype = {
show: function(parentElement)
{
WebInspector.View.prototype.show.call(this, parentElement);
this.update();
},
update: function()
{
function queryTransaction(tx)
{
tx.executeSql("SELECT * FROM " + this.tableName, null, InspectorController.wrapCallback(this._queryFinished.bind(this)), InspectorController.wrapCallback(this._queryError.bind(this)));
}
this.database.database.transaction(InspectorController.wrapCallback(queryTransaction.bind(this)), InspectorController.wrapCallback(this._queryError.bind(this)));
},
_queryFinished: function(tx, result)
{
this.element.removeChildren();
var dataGrid = WebInspector.panels.databases.dataGridForResult(result);
if (!dataGrid) {
var emptyMsgElement = document.createElement("div");
emptyMsgElement.className = "database-table-empty";
emptyMsgElement.textContent = WebInspector.UIString("The ā%sā\ntable is empty.", this.tableName);
this.element.appendChild(emptyMsgElement);
return;
}
this.element.appendChild(dataGrid.element);
},
_queryError: function(tx, error)
{
this.element.removeChildren();
var errorMsgElement = document.createElement("div");
errorMsgElement.className = "database-table-error";
errorMsgElement.textContent = WebInspector.UIString("An error occurred trying to\nread the ā%sā table.", this.tableName);
this.element.appendChild(errorMsgElement);
},
}
WebInspector.DatabaseTableView.prototype.__proto__ = WebInspector.View.prototype;