Cleaned up code formatting in .js, .html, .vt, .css, .less files.

git-svn-id: http://google-refine.googlecode.com/svn/trunk@2185 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
David Huynh 2011-08-04 20:37:14 +00:00
parent c9db107d7e
commit bad7266534
90 changed files with 10939 additions and 10920 deletions

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,89 +29,89 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
function init() {
Packages.com.google.refine.freebase.oauth.FreebaseProvider.register();
var RS = Packages.com.google.refine.RefineServlet;
RS.registerClassMapping(
"com.google.refine.model.changes.DataExtensionChange",
"com.google.refine.freebase.model.changes.DataExtensionChange");
RS.registerClassMapping(
"com.google.refine.operations.SaveProtographOperation$ProtographChange",
"com.google.refine.freebase.operations.SaveProtographOperation$ProtographChange");
// TODO(dfhuynh): Temporary hack until we know how the core module can resolve our module's classes
RS.cacheClass(Packages.com.google.refine.freebase.model.changes.DataExtensionChange);
RS.cacheClass(Packages.com.google.refine.freebase.operations.SaveProtographOperation$ProtographChange);
RS.registerCommand(module, "extend-data", new Packages.com.google.refine.freebase.commands.ExtendDataCommand());
RS.registerCommand(module, "preview-extend-data", new Packages.com.google.refine.freebase.commands.PreviewExtendDataCommand());
Packages.com.google.refine.freebase.oauth.FreebaseProvider.register();
RS.registerCommand(module, "preview-protograph", new Packages.com.google.refine.freebase.commands.PreviewProtographCommand());
RS.registerCommand(module, "save-protograph", new Packages.com.google.refine.freebase.commands.SaveProtographCommand());
var RS = Packages.com.google.refine.RefineServlet;
RS.registerClassMapping(
"com.google.refine.model.changes.DataExtensionChange",
"com.google.refine.freebase.model.changes.DataExtensionChange");
RS.registerClassMapping(
"com.google.refine.operations.SaveProtographOperation$ProtographChange",
"com.google.refine.freebase.operations.SaveProtographOperation$ProtographChange");
RS.registerCommand(module, "check-authorization", new Packages.com.google.refine.freebase.commands.auth.CheckAuthorizationCommand());
RS.registerCommand(module, "authorize", new Packages.com.google.refine.freebase.commands.auth.AuthorizeCommand());
RS.registerCommand(module, "deauthorize", new Packages.com.google.refine.freebase.commands.auth.DeAuthorizeCommand());
RS.registerCommand(module, "user-badges", new Packages.com.google.refine.freebase.commands.auth.GetUserBadgesCommand());
// TODO(dfhuynh): Temporary hack until we know how the core module can resolve our module's classes
RS.cacheClass(Packages.com.google.refine.freebase.model.changes.DataExtensionChange);
RS.cacheClass(Packages.com.google.refine.freebase.operations.SaveProtographOperation$ProtographChange);
RS.registerCommand(module, "upload-data", new Packages.com.google.refine.freebase.commands.UploadDataCommand());
RS.registerCommand(module, "import-qa-data", new Packages.com.google.refine.freebase.commands.ImportQADataCommand());
RS.registerCommand(module, "mqlread", new Packages.com.google.refine.freebase.commands.MQLReadCommand());
RS.registerCommand(module, "mqlwrite", new Packages.com.google.refine.freebase.commands.MQLWriteCommand());
RS.registerCommand(module, "extend-data", new Packages.com.google.refine.freebase.commands.ExtendDataCommand());
RS.registerCommand(module, "preview-extend-data", new Packages.com.google.refine.freebase.commands.PreviewExtendDataCommand());
var OR = Packages.com.google.refine.operations.OperationRegistry;
OR.registerOperation(module, "extend-data", Packages.com.google.refine.freebase.operations.ExtendDataOperation);
OR.registerOperation(module, "import-qa-data", Packages.com.google.refine.freebase.operations.ImportQADataOperation);
OR.registerOperation(module, "save-protograph", Packages.com.google.refine.freebase.operations.SaveProtographOperation); // for backward compatibility
OR.registerOperation(module, "save-schema-alignment-skeleton", Packages.com.google.refine.freebase.operations.SaveProtographOperation);
var RC = Packages.com.google.refine.model.recon.ReconConfig;
RC.registerReconConfig(module, "strict", Packages.com.google.refine.freebase.model.recon.StrictReconConfig);
RC.registerReconConfig(module, "extend", Packages.com.google.refine.freebase.model.recon.DataExtensionReconConfig);
var ER = Packages.com.google.refine.exporters.ExporterRegistry;
ER.registerExporter("tripleloader", new Packages.com.google.refine.freebase.ProtographTransposeExporter.TripleLoaderExporter());
ER.registerExporter("mqlwrite", new Packages.com.google.refine.freebase.ProtographTransposeExporter.MqlwriteLikeExporter());
var FCR = Packages.com.google.refine.grel.ControlFunctionRegistry;
FCR.registerFunction("mqlKeyQuote", new Packages.com.google.refine.freebase.expr.MqlKeyQuote());
FCR.registerFunction("mqlKeyUnquote", new Packages.com.google.refine.freebase.expr.MqlKeyUnquote());
Packages.com.google.refine.model.Project.
registerOverlayModel("freebaseProtograph", Packages.com.google.refine.freebase.protograph.Protograph);
ClientSideResourceManager.addPaths(
"project/scripts",
module,
[
"scripts/extension.js",
"scripts/util/sign.js",
"scripts/util/freebase.js",
"scripts/dialogs/freebase-loading-dialog.js",
"scripts/dialogs/extend-data-preview-dialog.js",
"scripts/dialogs/schema-alignment/dialog.js",
"scripts/dialogs/schema-alignment/ui-node.js",
"scripts/dialogs/schema-alignment/ui-link.js"
]
);
ClientSideResourceManager.addPaths(
"project/styles",
module,
[
"styles/dialogs/freebase-loading-dialog.less",
"styles/dialogs/extend-data-preview-dialog.less",
"styles/dialogs/schema-alignment-dialog.less"
]
);
RS.registerCommand(module, "preview-protograph", new Packages.com.google.refine.freebase.commands.PreviewProtographCommand());
RS.registerCommand(module, "save-protograph", new Packages.com.google.refine.freebase.commands.SaveProtographCommand());
RS.registerCommand(module, "check-authorization", new Packages.com.google.refine.freebase.commands.auth.CheckAuthorizationCommand());
RS.registerCommand(module, "authorize", new Packages.com.google.refine.freebase.commands.auth.AuthorizeCommand());
RS.registerCommand(module, "deauthorize", new Packages.com.google.refine.freebase.commands.auth.DeAuthorizeCommand());
RS.registerCommand(module, "user-badges", new Packages.com.google.refine.freebase.commands.auth.GetUserBadgesCommand());
RS.registerCommand(module, "upload-data", new Packages.com.google.refine.freebase.commands.UploadDataCommand());
RS.registerCommand(module, "import-qa-data", new Packages.com.google.refine.freebase.commands.ImportQADataCommand());
RS.registerCommand(module, "mqlread", new Packages.com.google.refine.freebase.commands.MQLReadCommand());
RS.registerCommand(module, "mqlwrite", new Packages.com.google.refine.freebase.commands.MQLWriteCommand());
var OR = Packages.com.google.refine.operations.OperationRegistry;
OR.registerOperation(module, "extend-data", Packages.com.google.refine.freebase.operations.ExtendDataOperation);
OR.registerOperation(module, "import-qa-data", Packages.com.google.refine.freebase.operations.ImportQADataOperation);
OR.registerOperation(module, "save-protograph", Packages.com.google.refine.freebase.operations.SaveProtographOperation); // for backward compatibility
OR.registerOperation(module, "save-schema-alignment-skeleton", Packages.com.google.refine.freebase.operations.SaveProtographOperation);
var RC = Packages.com.google.refine.model.recon.ReconConfig;
RC.registerReconConfig(module, "strict", Packages.com.google.refine.freebase.model.recon.StrictReconConfig);
RC.registerReconConfig(module, "extend", Packages.com.google.refine.freebase.model.recon.DataExtensionReconConfig);
var ER = Packages.com.google.refine.exporters.ExporterRegistry;
ER.registerExporter("tripleloader", new Packages.com.google.refine.freebase.ProtographTransposeExporter.TripleLoaderExporter());
ER.registerExporter("mqlwrite", new Packages.com.google.refine.freebase.ProtographTransposeExporter.MqlwriteLikeExporter());
var FCR = Packages.com.google.refine.grel.ControlFunctionRegistry;
FCR.registerFunction("mqlKeyQuote", new Packages.com.google.refine.freebase.expr.MqlKeyQuote());
FCR.registerFunction("mqlKeyUnquote", new Packages.com.google.refine.freebase.expr.MqlKeyUnquote());
Packages.com.google.refine.model.Project.
registerOverlayModel("freebaseProtograph", Packages.com.google.refine.freebase.protograph.Protograph);
ClientSideResourceManager.addPaths(
"project/scripts",
module,
[
"scripts/extension.js",
"scripts/util/sign.js",
"scripts/util/freebase.js",
"scripts/dialogs/freebase-loading-dialog.js",
"scripts/dialogs/extend-data-preview-dialog.js",
"scripts/dialogs/schema-alignment/dialog.js",
"scripts/dialogs/schema-alignment/ui-node.js",
"scripts/dialogs/schema-alignment/ui-link.js"
]
);
ClientSideResourceManager.addPaths(
"project/styles",
module,
[
"styles/dialogs/freebase-loading-dialog.less",
"styles/dialogs/extend-data-preview-dialog.less",
"styles/dialogs/schema-alignment-dialog.less"
]
);
}

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,368 +29,368 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
function ExtendDataPreviewDialog(column, columnIndex, rowIndices, onDone) {
this._column = column;
this._columnIndex = columnIndex;
this._rowIndices = rowIndices;
this._onDone = onDone;
this._extension = { properties: [] };
this._column = column;
this._columnIndex = columnIndex;
this._rowIndices = rowIndices;
this._onDone = onDone;
this._extension = { properties: [] };
var self = this;
this._dialog = $(DOM.loadHTML("freebase", "scripts/dialogs/extend-data-preview-dialog.html"));
this._elmts = DOM.bind(this._dialog);
this._elmts.dialogHeader.text("Add Columns from Freebase Based on Column " + column.name);
this._elmts.resetButton.click(function() {
self._extension.properties = [];
self._update();
});
this._elmts.okButton.click(function() {
if (self._extension.properties.length === 0) {
alert("Please add some properties first.");
} else {
DialogSystem.dismissUntil(self._level - 1);
self._onDone(self._extension);
}
});
this._elmts.cancelButton.click(function() {
DialogSystem.dismissUntil(self._level - 1);
});
var dismissBusy = DialogSystem.showBusy();
var type = (column.reconConfig) && (column.reconConfig.type) ? column.reconConfig.type.id : "/common/topic";
ExtendDataPreviewDialog.getAllProperties(type, function(properties) {
dismissBusy();
self._show(properties);
});
var self = this;
this._dialog = $(DOM.loadHTML("freebase", "scripts/dialogs/extend-data-preview-dialog.html"));
this._elmts = DOM.bind(this._dialog);
this._elmts.dialogHeader.text("Add Columns from Freebase Based on Column " + column.name);
this._elmts.resetButton.click(function() {
self._extension.properties = [];
self._update();
});
this._elmts.okButton.click(function() {
if (self._extension.properties.length === 0) {
alert("Please add some properties first.");
} else {
DialogSystem.dismissUntil(self._level - 1);
self._onDone(self._extension);
}
});
this._elmts.cancelButton.click(function() {
DialogSystem.dismissUntil(self._level - 1);
});
var dismissBusy = DialogSystem.showBusy();
var type = (column.reconConfig) && (column.reconConfig.type) ? column.reconConfig.type.id : "/common/topic";
ExtendDataPreviewDialog.getAllProperties(type, function(properties) {
dismissBusy();
self._show(properties);
});
}
ExtendDataPreviewDialog.getAllProperties = function(typeID, onDone) {
var done = false;
$.getJSON(
Refine.refineHelperService + "/get_properties_of_type?type=" + typeID + "&callback=?",
null,
function(data) {
if (done) return;
done = true;
var allProperties = [];
for (var i = 0; i < data.properties.length; i++) {
var property = data.properties[i];
var property2 = {
id: property.id,
name: property.name
};
if ("id2" in property) {
property2.expected = property.schema2;
property2.properties = [{
id: property.id2,
name: property.name2,
expected: property.expects
}];
} else {
property2.expected = property.expects;
}
allProperties.push(property2);
}
allProperties.sort(function(a, b) { return a.name.localeCompare(b.name); });
onDone(allProperties);
var done = false;
$.getJSON(
Refine.refineHelperService + "/get_properties_of_type?type=" + typeID + "&callback=?",
null,
function(data) {
if (done) return;
done = true;
var allProperties = [];
for (var i = 0; i < data.properties.length; i++) {
var property = data.properties[i];
var property2 = {
id: property.id,
name: property.name
};
if ("id2" in property) {
property2.expected = property.schema2;
property2.properties = [{
id: property.id2,
name: property.name2,
expected: property.expects
}];
} else {
property2.expected = property.expects;
}
);
window.setTimeout(function() {
if (done) return;
done = true;
onDone([]);
}, 7000); // time to give up?
allProperties.push(property2);
}
allProperties.sort(function(a, b) { return a.name.localeCompare(b.name); });
onDone(allProperties);
}
);
window.setTimeout(function() {
if (done) return;
done = true;
onDone([]);
}, 7000); // time to give up?
};
ExtendDataPreviewDialog.prototype._show = function(properties) {
this._level = DialogSystem.showDialog(this._dialog);
var n = this._elmts.suggestedPropertyContainer.offset().top +
this._elmts.suggestedPropertyContainer.outerHeight(true) -
this._elmts.addPropertyInput.offset().top;
this._elmts.previewContainer.height(Math.floor(n));
var self = this;
var container = this._elmts.suggestedPropertyContainer;
var renderSuggestedProperty = function(property) {
var label = ("properties" in property) ? (property.name + " &raquo; " + property.properties[0].name) : property.name;
var div = $('<div>').addClass("suggested-property").appendTo(container);
$('<a>')
.attr("href", "javascript:{}")
.html(label)
.appendTo(div)
.click(function() {
self._addProperty(property);
});
};
for (var i = 0; i < properties.length; i++) {
renderSuggestedProperty(properties[i]);
}
var suggestConfig = {
type: '/type/property'
};
if ((this._column.reconConfig) && (this._column.reconConfig.type)) {
suggestConfig.ac_param = { schema: this._column.reconConfig.type.id };
}
this._elmts.addPropertyInput.suggestP(suggestConfig).bind("fb-select", function(evt, data) {
var expected = data.expected_type;
self._addProperty({
id : data.id,
name: data.name,
expected: {
id: expected.id,
name: expected.name
}
});
this._level = DialogSystem.showDialog(this._dialog);
var n = this._elmts.suggestedPropertyContainer.offset().top +
this._elmts.suggestedPropertyContainer.outerHeight(true) -
this._elmts.addPropertyInput.offset().top;
this._elmts.previewContainer.height(Math.floor(n));
var self = this;
var container = this._elmts.suggestedPropertyContainer;
var renderSuggestedProperty = function(property) {
var label = ("properties" in property) ? (property.name + " &raquo; " + property.properties[0].name) : property.name;
var div = $('<div>').addClass("suggested-property").appendTo(container);
$('<a>')
.attr("href", "javascript:{}")
.html(label)
.appendTo(div)
.click(function() {
self._addProperty(property);
});
};
for (var i = 0; i < properties.length; i++) {
renderSuggestedProperty(properties[i]);
}
var suggestConfig = {
type: '/type/property'
};
if ((this._column.reconConfig) && (this._column.reconConfig.type)) {
suggestConfig.ac_param = { schema: this._column.reconConfig.type.id };
}
this._elmts.addPropertyInput.suggestP(suggestConfig).bind("fb-select", function(evt, data) {
var expected = data.expected_type;
self._addProperty({
id : data.id,
name: data.name,
expected: {
id: expected.id,
name: expected.name
}
});
});
};
ExtendDataPreviewDialog.prototype._update = function() {
this._elmts.previewContainer.empty().text("Querying Freebase ...");
var self = this;
var params = {
project: theProject.id,
columnName: this._column.name
};
$.post(
"/command/freebase/preview-extend-data?" + $.param(params),
{
rowIndices: JSON.stringify(this._rowIndices),
extension: JSON.stringify(this._extension)
},
function(data) {
self._renderPreview(data);
},
"json"
);
this._elmts.previewContainer.empty().text("Querying Freebase ...");
var self = this;
var params = {
project: theProject.id,
columnName: this._column.name
};
$.post(
"/command/freebase/preview-extend-data?" + $.param(params),
{
rowIndices: JSON.stringify(this._rowIndices),
extension: JSON.stringify(this._extension)
},
function(data) {
self._renderPreview(data);
},
"json"
);
};
ExtendDataPreviewDialog.prototype._addProperty = function(p) {
var addSeveralToList = function(properties, oldProperties) {
for (var i = 0; i < properties.length; i++) {
addToList(properties[i], oldProperties);
var addSeveralToList = function(properties, oldProperties) {
for (var i = 0; i < properties.length; i++) {
addToList(properties[i], oldProperties);
}
};
var addToList = function(property, oldProperties) {
for (var i = 0; i < oldProperties.length; i++) {
var oldProperty = oldProperties[i];
if (oldProperty.id == property.id) {
if ("included" in property) {
oldProperty.included = "included" in oldProperty ?
(oldProperty.included || property.included) :
property.included;
}
};
var addToList = function(property, oldProperties) {
for (var i = 0; i < oldProperties.length; i++) {
var oldProperty = oldProperties[i];
if (oldProperty.id == property.id) {
if ("included" in property) {
oldProperty.included = "included" in oldProperty ?
(oldProperty.included || property.included) :
property.included;
}
if ("properties" in property) {
if ("properties" in oldProperty) {
addSeveralToList(property.properties, oldProperty.properties);
} else {
oldProperty.properties = property.properties;
}
}
return;
}
if ("properties" in property) {
if ("properties" in oldProperty) {
addSeveralToList(property.properties, oldProperty.properties);
} else {
oldProperty.properties = property.properties;
}
}
oldProperties.push(property);
};
addToList(p, this._extension.properties);
this._update();
return;
}
}
oldProperties.push(property);
};
addToList(p, this._extension.properties);
this._update();
};
ExtendDataPreviewDialog.prototype._renderPreview = function(data) {
var self = this;
var container = this._elmts.previewContainer.empty();
if (data.code == "error") {
container.text("Error.");
return;
}
var table = $('<table>')[0];
var trHead = table.insertRow(table.rows.length);
$('<th>').appendTo(trHead).text(this._column.name);
var renderColumnHeader = function(column) {
var th = $('<th>').appendTo(trHead);
$('<span>').html(column.names.join(" &raquo; ")).appendTo(th);
$('<br>').appendTo(th);
$('<a href="javascript:{}"></a>')
.text("remove")
.addClass("action")
.attr("title", "Remove this column")
.click(function() {
self._removeProperty(column.path);
}).appendTo(th);
$('<a href="javascript:{}"></a>')
.text("constrain")
.addClass("action")
.attr("title", "Add constraints to this column")
.click(function() {
self._constrainProperty(column.path);
}).appendTo(th);
};
for (var c = 0; c < data.columns.length; c++) {
renderColumnHeader(data.columns[c]);
}
for (var r = 0; r < data.rows.length; r++) {
var tr = table.insertRow(table.rows.length);
var row = data.rows[r];
for (var c = 0; c < row.length; c++) {
var td = tr.insertCell(tr.cells.length);
var cell = row[c];
if (cell !== null) {
if ($.isPlainObject(cell)) {
$('<a>').attr("href", "http://www.freebase.com/view" + cell.id).text(cell.name).appendTo(td);
} else {
$('<span>').text(cell).appendTo(td);
}
}
var self = this;
var container = this._elmts.previewContainer.empty();
if (data.code == "error") {
container.text("Error.");
return;
}
var table = $('<table>')[0];
var trHead = table.insertRow(table.rows.length);
$('<th>').appendTo(trHead).text(this._column.name);
var renderColumnHeader = function(column) {
var th = $('<th>').appendTo(trHead);
$('<span>').html(column.names.join(" &raquo; ")).appendTo(th);
$('<br>').appendTo(th);
$('<a href="javascript:{}"></a>')
.text("remove")
.addClass("action")
.attr("title", "Remove this column")
.click(function() {
self._removeProperty(column.path);
}).appendTo(th);
$('<a href="javascript:{}"></a>')
.text("constrain")
.addClass("action")
.attr("title", "Add constraints to this column")
.click(function() {
self._constrainProperty(column.path);
}).appendTo(th);
};
for (var c = 0; c < data.columns.length; c++) {
renderColumnHeader(data.columns[c]);
}
for (var r = 0; r < data.rows.length; r++) {
var tr = table.insertRow(table.rows.length);
var row = data.rows[r];
for (var c = 0; c < row.length; c++) {
var td = tr.insertCell(tr.cells.length);
var cell = row[c];
if (cell !== null) {
if ($.isPlainObject(cell)) {
$('<a>').attr("href", "http://www.freebase.com/view" + cell.id).text(cell.name).appendTo(td);
} else {
$('<span>').text(cell).appendTo(td);
}
}
}
container.append(table);
}
container.append(table);
};
ExtendDataPreviewDialog.prototype._removeProperty = function(path) {
var removeFromList = function(path, index, properties) {
var id = path[index];
for (var i = properties.length - 1; i >= 0; i--) {
var property = properties[i];
if (property.id == id) {
if (index === path.length - 1) {
if ("included" in property) {
delete property.included;
}
} else if ("properties" in property && property.properties.length > 0) {
removeFromList(path, index + 1, property.properties);
}
if (!("properties" in property) || property.properties.length === 0) {
properties.splice(i, 1);
}
return;
}
var removeFromList = function(path, index, properties) {
var id = path[index];
for (var i = properties.length - 1; i >= 0; i--) {
var property = properties[i];
if (property.id == id) {
if (index === path.length - 1) {
if ("included" in property) {
delete property.included;
}
} else if ("properties" in property && property.properties.length > 0) {
removeFromList(path, index + 1, property.properties);
}
};
removeFromList(path, 0, this._extension.properties);
this._update();
if (!("properties" in property) || property.properties.length === 0) {
properties.splice(i, 1);
}
return;
}
}
};
removeFromList(path, 0, this._extension.properties);
this._update();
};
ExtendDataPreviewDialog.prototype._findProperty = function(path) {
var find = function(path, index, properties) {
var id = path[index];
for (var i = properties.length - 1; i >= 0; i--) {
var property = properties[i];
if (property.id == id) {
if (index === path.length - 1) {
return property;
} else if ("properties" in property && property.properties.length > 0) {
return find(path, index + 1, property.properties);
}
break;
}
var find = function(path, index, properties) {
var id = path[index];
for (var i = properties.length - 1; i >= 0; i--) {
var property = properties[i];
if (property.id == id) {
if (index === path.length - 1) {
return property;
} else if ("properties" in property && property.properties.length > 0) {
return find(path, index + 1, property.properties);
}
return null;
};
return find(path, 0, this._extension.properties);
break;
}
}
return null;
};
return find(path, 0, this._extension.properties);
};
ExtendDataPreviewDialog.prototype._constrainProperty = function(path) {
var self = this;
var property = this._findProperty(path);
var frame = DialogSystem.createDialog();
frame.width("500px");
var header = $('<div></div>').addClass("dialog-header").text("Constrain " + path.join(" > ")).appendTo(frame);
var body = $('<div></div>').addClass("dialog-body").appendTo(frame);
var footer = $('<div></div>').addClass("dialog-footer").appendTo(frame);
body.html(
'<div class="grid-layout layout-normal layout-full"><table>' +
'<tr><td>' +
'Enter MQL query constraints as JSON' +
'</td></tr>' +
'<tr><td>' +
'<textarea style="width: 100%; height: 300px; font-family: monospace;" bind="textarea"></textarea>' +
'</td></tr>' +
'</table></div>'
);
var bodyElmts = DOM.bind(body);
if ("constraints" in property) {
bodyElmts.textarea[0].value = JSON.stringify(property.constraints, null, 2);
} else {
bodyElmts.textarea[0].value = JSON.stringify({ "limit" : 10 }, null, 2);
var self = this;
var property = this._findProperty(path);
var frame = DialogSystem.createDialog();
frame.width("500px");
var header = $('<div></div>').addClass("dialog-header").text("Constrain " + path.join(" > ")).appendTo(frame);
var body = $('<div></div>').addClass("dialog-body").appendTo(frame);
var footer = $('<div></div>').addClass("dialog-footer").appendTo(frame);
body.html(
'<div class="grid-layout layout-normal layout-full"><table>' +
'<tr><td>' +
'Enter MQL query constraints as JSON' +
'</td></tr>' +
'<tr><td>' +
'<textarea style="width: 100%; height: 300px; font-family: monospace;" bind="textarea"></textarea>' +
'</td></tr>' +
'</table></div>'
);
var bodyElmts = DOM.bind(body);
if ("constraints" in property) {
bodyElmts.textarea[0].value = JSON.stringify(property.constraints, null, 2);
} else {
bodyElmts.textarea[0].value = JSON.stringify({ "limit" : 10 }, null, 2);
}
footer.html(
'<button class="button" bind="okButton">&nbsp;&nbsp;OK&nbsp;&nbsp;</button>' +
'<button class="button" bind="cancelButton">Cancel</button>'
);
var footerElmts = DOM.bind(footer);
var level = DialogSystem.showDialog(frame);
var dismiss = function() {
DialogSystem.dismissUntil(level - 1);
};
footerElmts.cancelButton.click(dismiss);
footerElmts.okButton.click(function() {
try {
var o = JSON.parse(bodyElmts.textarea[0].value);
if (o === undefined) {
alert("Please ensure that the JSON you enter is valid.");
return;
}
if ($.isArray(o) && o.length == 1) {
o = o[0];
}
if (!$.isPlainObject(o)) {
alert("The JSON you enter must be an object, that is, it is of this form { ... }.");
return;
}
property.constraints = o;
dismiss();
self._update();
} catch (e) {
//console.log(e);
}
footer.html(
'<button class="button" bind="okButton">&nbsp;&nbsp;OK&nbsp;&nbsp;</button>' +
'<button class="button" bind="cancelButton">Cancel</button>'
);
var footerElmts = DOM.bind(footer);
var level = DialogSystem.showDialog(frame);
var dismiss = function() {
DialogSystem.dismissUntil(level - 1);
};
footerElmts.cancelButton.click(dismiss);
footerElmts.okButton.click(function() {
try {
var o = JSON.parse(bodyElmts.textarea[0].value);
if (o === undefined) {
alert("Please ensure that the JSON you enter is valid.");
return;
}
if ($.isArray(o) && o.length == 1) {
o = o[0];
}
if (!$.isPlainObject(o)) {
alert("The JSON you enter must be an object, that is, it is of this form { ... }.");
return;
}
property.constraints = o;
dismiss();
self._update();
} catch (e) {
//console.log(e);
}
});
bodyElmts.textarea.focus();
});
bodyElmts.textarea.focus();
};

View File

@ -19,7 +19,8 @@
<tr><td>Source ID (optional)</td>
<td colspan="2"><input type="text" size="60" id="freebase-loading-source-id" bind="source_id" /></td>
</tr>
<tr><td colspan="3">
<tr>
<td colspan="3">
<p class="body-text">Note: Your data will only be loaded into
<a href="http://www.sandbox-freebase.com/" target="_blank">Sandbox</a>.
Sandbox is where everyone can experiment with Freebase technologies without disruption

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,218 +29,219 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
function FreebaseLoadingDialog() {
this._createDialog();
this._signedin = false;
this._createDialog();
this._signedin = false;
}
FreebaseLoadingDialog.prototype._createDialog = function() {
var self = this;
var dialog = $(DOM.loadHTML("freebase", "scripts/dialogs/freebase-loading-dialog.html"));
this._elmts = DOM.bind(dialog);
this._elmts.cancelButton.click(function() { self._dismiss(); });
var provider = "www.freebase.com";
var authorization = this._elmts.authorization;
var loadButton = this._elmts.loadButton;
var check_authorization = function(cont) {
$.get("/command/freebase/check-authorization/" + provider, function(data) {
if ("status" in data && data.code == "/api/status/ok") {
authorization.html('Signed in as: <a target="_new" href="http://www.freebase.com/view/user/' + data.username + '">' + data.username + '</a> | <a href="javascript:{}" bind="signout">Sign Out</a>').show();
DOM.bind(authorization).signout.click(function() {
self._signedin = false;
loadButton.attr("disabled","disabled");
$("#freebase-loading-graph-selector-freebase").attr("disabled","disabled").button("refresh");
Sign.signout(check_authorization,provider);
});
loadButton.unbind().click(function() {
self._load();
});
self._signedin = true;
$("#freebase-loading-source-name").keyup();
if (typeof cont == "function") cont(data);
var self = this;
var dialog = $(DOM.loadHTML("freebase", "scripts/dialogs/freebase-loading-dialog.html"));
this._elmts = DOM.bind(dialog);
this._elmts.cancelButton.click(function() { self._dismiss(); });
var provider = "www.freebase.com";
var authorization = this._elmts.authorization;
var loadButton = this._elmts.loadButton;
var check_authorization = function(cont) {
$.get("/command/freebase/check-authorization/" + provider, function(data) {
if ("status" in data && data.code == "/api/status/ok") {
authorization.html('Signed in as: <a target="_new" href="http://www.freebase.com/view/user/' + data.username + '">' + data.username + '</a> | <a href="javascript:{}" bind="signout">Sign Out</a>').show();
DOM.bind(authorization).signout.click(function() {
self._signedin = false;
loadButton.attr("disabled","disabled");
$("#freebase-loading-graph-selector-freebase").attr("disabled","disabled").button("refresh");
Sign.signout(check_authorization,provider);
});
loadButton.unbind().click(function() {
self._load();
});
self._signedin = true;
$("#freebase-loading-source-name").keyup();
if (typeof cont == "function") cont(data);
} else {
authorization.html('<a href="javascript:{}" bind="signin">Sign into Freebase</a> to enable loading').show();
self._signedin = false;
$("#freebase-loading-source-name").keyup();
DOM.bind(authorization).signin.click(function() {
Sign.signin(function() {
check_authorization(cont);
},provider);
});
}
},"json");
};
var make_topic = function(new_topic_id, topic_type, cont) {
var mql_query = [{
"create": "unless_exists",
"name": new_topic_id,
"a:type": topic_type,
"b:type": "/common/topic",
"id": null,
"guid": null
}];
$.post("/command/freebase/mqlwrite/" + provider,
{ "query" : JSON.stringify(mql_query) },
function(data) {
if ("status" in data && data.code == "/api/status/ok") {
self._elmts.source_id.val(data.result[0].id);
if (typeof cont == "function") cont();
} else {
self._show_error("Error creating new topic", data);
}
},
"json"
);
};
var show_triples = function(cont) {
$.post(
"/command/freebase/preview-protograph?" + $.param({ project: theProject.id }),
{
protograph: JSON.stringify(theProject.overlayModels.freebaseProtograph || {}),
engine: JSON.stringify(ui.browsingEngine.getJSON())
},
function(data) {
if ("tripleloader" in data) {
self._elmts.functionalCase.show();
self._level = DialogSystem.showDialog(dialog);
self._elmts.functionalTabs.tabs();
self._elmts.previewContainer.text(data.tripleloader).show();
self._elmts.source_name.keyup(function() {
if (self._signedin && $(this).val() != "") {
loadButton.removeAttr("disabled").removeClass("button-disabled");
} else {
authorization.html('<a href="javascript:{}" bind="signin">Sign into Freebase</a> to enable loading').show();
self._signedin = false;
$("#freebase-loading-source-name").keyup();
DOM.bind(authorization).signin.click(function() {
Sign.signin(function() {
check_authorization(cont);
},provider);
});
loadButton.attr("disabled","disabled").addClass("button-disabled");
}
},"json");
};
var make_topic = function(new_topic_id, topic_type, cont) {
var mql_query = [{
"create": "unless_exists",
"name": new_topic_id,
"a:type": topic_type,
"b:type": "/common/topic",
"id": null,
"guid": null
}];
});
$.post("/command/freebase/mqlwrite/" + provider,
{ "query" : JSON.stringify(mql_query) },
self._elmts.source_id.suggest({
"type": "/dataworld/information_source",
"suggest_new": "Click here to add a new information source"
}).bind("fb-select", function(e, data) {
self._elmts.source_id.val(data.id);
}).bind("fb-select-new", function(e, val) {
make_topic(val, "/dataworld/information_source");
});
$.getJSON(
"/command/core/get-preference?" + $.param({ project: theProject.id, name: "freebase.load.jobName" }),
null,
function(data) {
if ("status" in data && data.code == "/api/status/ok") {
self._elmts.source_id.val(data.result[0].id);
if (typeof cont == "function") cont();
} else {
self._show_error("Error creating new topic", data);
}
},
"json"
);
};
var show_triples = function(cont) {
$.post(
"/command/freebase/preview-protograph?" + $.param({ project: theProject.id }),
{
protograph: JSON.stringify(theProject.overlayModels.freebaseProtograph || {}),
engine: JSON.stringify(ui.browsingEngine.getJSON())
},
function(data) {
if ("tripleloader" in data) {
self._elmts.functionalCase.show();
self._level = DialogSystem.showDialog(dialog);
self._elmts.functionalTabs.tabs();
self._elmts.previewContainer.text(data.tripleloader).show();
self._elmts.source_name.keyup(function() {
if (self._signedin && $(this).val() != "") {
loadButton.removeAttr("disabled").removeClass("button-disabled");
} else {
loadButton.attr("disabled","disabled").addClass("button-disabled");
}
});
self._elmts.source_id.suggest({
"type": "/dataworld/information_source",
"suggest_new": "Click here to add a new information source"
}).bind("fb-select", function(e, data) {
self._elmts.source_id.val(data.id);
}).bind("fb-select-new", function(e, val) {
make_topic(val, "/dataworld/information_source");
});
self._elmts.source_name[0].value = (data.value) ? data.value : theProject.metadata.name;
}
);
$.getJSON(
"/command/core/get-preference?" + $.param({ project: theProject.id, name: "freebase.load.jobName" }),
null,
function(data) {
self._elmts.source_name[0].value = (data.value) ? data.value : theProject.metadata.name;
}
);
if (typeof cont == "function") cont();
} else {
self._elmts.unalignedCase.show();
self._level = DialogSystem.showDialog(dialog);
if (typeof cont == "function") cont();
} else {
self._elmts.unalignedCase.show();
self._level = DialogSystem.showDialog(dialog);
self._elmts.alignButton.click(function() {
self._dismiss();
FreebaseExtension.handlers.editSchemaAlignment(false);
});
self._end();
}
},
"json"
);
};
self._elmts.alignButton.click(function() {
self._dismiss();
FreebaseExtension.handlers.editSchemaAlignment(false);
});
self._end();
}
},
"json"
);
};
show_triples(check_authorization);
show_triples(check_authorization);
};
FreebaseLoadingDialog.prototype._load = function() {
var self = this;
var qa = self._elmts.qaCheckbox.is(':checked');
var self = this;
var qa = self._elmts.qaCheckbox.is(':checked');
var get_refinery_url = function(url) {
return "http://refinery.freebaseapps.com/load/" + url.split("/").slice(-1)[0];
var get_refinery_url = function(url) {
return "http://refinery.freebaseapps.com/load/" + url.split("/").slice(-1)[0];
};
var doLoad = function() {
var dismissBusy = DialogSystem.showBusy();
$.post(
"/command/freebase/upload-data",
{
"project" : theProject.id,
"qa" : qa,
"engine" : JSON.stringify(ui.browsingEngine.getJSON()),
"source_name" : self._elmts.source_name.val(),
"source_id" : self._elmts.source_id.val()
},
function(data) {
dismissBusy();
var body = self._elmts.dialogBody;
if ("status" in data && typeof data.status == "object" && "code" in data.status && data.status.code == 200) {
self._elmts.tripleCountSpan.text(data.result.added);
self._elmts.refineryLink.attr("href", get_refinery_url(data.result.status_url));
self._elmts.functionalCase.hide();
self._elmts.loadedCase.show();
self._end();
} else {
self._show_error("Error loading data",data);
}
},
"json"
);
};
if (qa) {
var dialog = $(DOM.loadHTML("freebase", "scripts/dialogs/confirm-qa-dialog.html"));
var elmts = DOM.bind(dialog);
var level = DialogSystem.showDialog(dialog);
var dismiss = function() {
DialogSystem.dismissUntil(level - 1);
};
var doLoad = function() {
var dismissBusy = DialogSystem.showBusy();
$.post("/command/freebase/upload-data",
{
project: theProject.id,
"qa" : qa,
"engine" : JSON.stringify(ui.browsingEngine.getJSON()),
"source_name" : self._elmts.source_name.val(),
"source_id" : self._elmts.source_id.val()
},
function(data) {
dismissBusy();
var body = self._elmts.dialogBody;
if ("status" in data && typeof data.status == "object" && "code" in data.status && data.status.code == 200) {
self._elmts.tripleCountSpan.text(data.result.added);
self._elmts.refineryLink.attr("href", get_refinery_url(data.result.status_url));
self._elmts.functionalCase.hide();
self._elmts.loadedCase.show();
self._end();
} else {
self._show_error("Error loading data",data);
}
},
"json"
);
};
if (qa) {
var dialog = $(DOM.loadHTML("freebase", "scripts/dialogs/confirm-qa-dialog.html"));
var elmts = DOM.bind(dialog);
var level = DialogSystem.showDialog(dialog);
var dismiss = function() {
DialogSystem.dismissUntil(level - 1);
};
elmts.okButton.click(function() {
doLoad();
dismiss();
});
elmts.cancelButton.click(function() {
dismiss();
});
} else {
doLoad();
}
elmts.okButton.click(function() {
doLoad();
dismiss();
});
elmts.cancelButton.click(function() {
dismiss();
});
} else {
doLoad();
}
};
FreebaseLoadingDialog.prototype._dismiss = function() {
DialogSystem.dismissUntil(this._level - 1);
DialogSystem.dismissUntil(this._level - 1);
};
FreebaseLoadingDialog.prototype._show_error = function(msg, error) {
this._elmts.dialogBody.children().hide();
this._elmts.errorCase.show();
this._elmts.errorMessage.text(msg);
this._elmts.errorDetails.html(
(('message' in error) ? '<p>' + error.message + '</p>' : '<pre>' + JSON.stringify(error, null, 2) + '</pre>') +
(('stack' in error) ? '<pre>' + error.stack.replace(/\\n/g,'\n').replace(/\\t/g,'\t') + '</pre>' : "")
);
this._end();
console.log(error);
this._elmts.dialogBody.children().hide();
this._elmts.errorCase.show();
this._elmts.errorMessage.text(msg);
this._elmts.errorDetails.html(
(('message' in error) ? '<p>' + error.message + '</p>' : '<pre>' + JSON.stringify(error, null, 2) + '</pre>') +
(('stack' in error) ? '<pre>' + error.stack.replace(/\\n/g,'\n').replace(/\\t/g,'\t') + '</pre>' : "")
);
this._end();
console.log(error);
};
FreebaseLoadingDialog.prototype._end = function() {
var self = this;
this._elmts.loadButton.text("Close").removeAttr("disabled").removeClass("button-disabled").unbind().click(function() {
self._dismiss();
});
this._elmts.cancelButton.hide();
this._elmts.authorization.hide();
var self = this;
this._elmts.loadButton.text("Close").removeAttr("disabled").removeClass("button-disabled").unbind().click(function() {
self._dismiss();
});
this._elmts.cancelButton.hide();
this._elmts.authorization.hide();
};

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,283 +29,283 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
var SchemaAlignment = {};
SchemaAlignment.autoAlign = function() {
var protograph = {};
var columns = theProject.columnModel.columns;
var typedCandidates = [];
var candidates = [];
for (var c = 0; c < columns.length; c++) {
var column = columns[c];
var typed = (column.reconConfig) &&
ReconciliationManager.isFreebaseIdOrMid(column.reconConfig.identifierSpace) &&
ReconciliationManager.isFreebaseId(column.reconConfig.schemaSpace);
var candidate = {
status: "unbound",
typed: typed,
index: c,
column: column
};
candidates.push(candidate);
if (typed) {
typedCandidates.push(candidate);
}
var protograph = {};
var columns = theProject.columnModel.columns;
var typedCandidates = [];
var candidates = [];
for (var c = 0; c < columns.length; c++) {
var column = columns[c];
var typed = (column.reconConfig) &&
ReconciliationManager.isFreebaseIdOrMid(column.reconConfig.identifierSpace) &&
ReconciliationManager.isFreebaseId(column.reconConfig.schemaSpace);
var candidate = {
status: "unbound",
typed: typed,
index: c,
column: column
};
candidates.push(candidate);
if (typed) {
typedCandidates.push(candidate);
}
if (typedCandidates.length > 0) {
} else {
var queries = {};
for (var i = 0; i < candidates.length; i++) {
var candidate = candidates[i];
var name = SchemaAlignment._cleanName(candidate.column.name);
var key = "t" + i + ":search";
queries[key] = {
"query" : name,
"limit" : 10,
"type" : "/type/type,/type/property",
"type_strict" : "any"
};
}
SchemaAlignment._batchSearch(queries, function(result) {
console.log(result);
});
}
if (typedCandidates.length > 0) {
} else {
var queries = {};
for (var i = 0; i < candidates.length; i++) {
var candidate = candidates[i];
var name = SchemaAlignment._cleanName(candidate.column.name);
var key = "t" + i + ":search";
queries[key] = {
"query" : name,
"limit" : 10,
"type" : "/type/type,/type/property",
"type_strict" : "any"
};
}
SchemaAlignment._batchSearch(queries, function(result) {
console.log(result);
});
}
};
SchemaAlignment._batchSearch = function(queries, onDone) {
var keys = [];
for (var n in queries) {
if (queries.hasOwnProperty(n)) {
keys.push(n);
}
var keys = [];
for (var n in queries) {
if (queries.hasOwnProperty(n)) {
keys.push(n);
}
var result = {};
var args = [];
var makeBatch = function(keyBatch) {
var batch = {};
for (var k = 0; k < keyBatch.length; k++) {
var key = keyBatch[k];
batch[key] = queries[key];
}
args.push("http://api.freebase.com/api/service/search?" +
$.param({ "queries" : JSON.stringify(batch) }) + "&callback=?");
args.push(null); // no data
args.push(function(data) {
for (var k = 0; k < keyBatch.length; k++) {
var key = keyBatch[k];
result[key] = data[key];
}
});
};
for (var i = 0; i < keys.length; i += 10) {
makeBatch(keys.slice(i, i + 10));
}
var result = {};
var args = [];
var makeBatch = function(keyBatch) {
var batch = {};
for (var k = 0; k < keyBatch.length; k++) {
var key = keyBatch[k];
batch[key] = queries[key];
}
args.push(function() {
onDone(result);
args.push("http://api.freebase.com/api/service/search?" +
$.param({ "queries" : JSON.stringify(batch) }) + "&callback=?");
args.push(null); // no data
args.push(function(data) {
for (var k = 0; k < keyBatch.length; k++) {
var key = keyBatch[k];
result[key] = data[key];
}
});
Ajax.chainGetJSON.apply(null, args);
};
for (var i = 0; i < keys.length; i += 10) {
makeBatch(keys.slice(i, i + 10));
}
args.push(function() {
onDone(result);
});
Ajax.chainGetJSON.apply(null, args);
};
SchemaAlignment._cleanName = function(s) {
return s.replace(/\W/g, " ").replace(/\s+/g, " ").toLowerCase();
return s.replace(/\W/g, " ").replace(/\s+/g, " ").toLowerCase();
};
SchemaAlignment.createNewRootNode = function() {
var rootNode = null;
var links = [];
var columns = theProject.columnModel.columns;
for (var i = 0; i < columns.length; i++) {
var column = columns[i];
var target = {
nodeType: "cell-as-topic",
columnName: column.name,
createForNoReconMatch: true
};
if ((column.reconConfig) &&
ReconciliationManager.isFreebaseIdOrMid(column.reconConfig.identifierSpace) &&
ReconciliationManager.isFreebaseId(column.reconConfig.schemaSpace) &&
(column.reconConfig.type)) {
var rootNode = null;
var links = [];
var columns = theProject.columnModel.columns;
for (var i = 0; i < columns.length; i++) {
var column = columns[i];
var target = {
nodeType: "cell-as-topic",
columnName: column.name,
createForNoReconMatch: true
};
if ((column.reconConfig) &&
ReconciliationManager.isFreebaseIdOrMid(column.reconConfig.identifierSpace) &&
ReconciliationManager.isFreebaseId(column.reconConfig.schemaSpace) &&
(column.reconConfig.type)) {
target.type = {
id: column.reconConfig.type.id,
name: column.reconConfig.type.name
};
}
if (column.name == theProject.columnModel.keyColumnName) {
rootNode = target;
} else {
links.push({
property: null,
target: target
});
}
target.type = {
id: column.reconConfig.type.id,
name: column.reconConfig.type.name
};
}
rootNode = rootNode || { nodeType: "cell-as-topic" };
rootNode.links = links;
return rootNode;
if (column.name == theProject.columnModel.keyColumnName) {
rootNode = target;
} else {
links.push({
property: null,
target: target
});
}
}
rootNode = rootNode || { nodeType: "cell-as-topic" };
rootNode.links = links;
return rootNode;
};
function SchemaAlignmentDialog(protograph, onDone) {
this._onDone = onDone;
this._hasUnsavedChanges = false;
this._createDialog();
this._reset(protograph, true);
this._onDone = onDone;
this._hasUnsavedChanges = false;
this._createDialog();
this._reset(protograph, true);
}
SchemaAlignmentDialog.prototype._reset = function(protograph, initial) {
this._originalProtograph = protograph || { rootNodes: [] };
this._protograph = cloneDeep(this._originalProtograph); // this is what can be munched on
if (!this._protograph.rootNodes.length) {
this._protograph.rootNodes.push(SchemaAlignment.createNewRootNode());
}
$(this._nodeTable).empty();
this._nodeUIs = [];
for (var i = 0; i < this._protograph.rootNodes.length; i++) {
this._nodeUIs.push(new SchemaAlignmentDialog.UINode(
this,
this._protograph.rootNodes[i],
this._nodeTable,
{
expanded: true,
mustBeCellTopic: true
}
));
}
this.preview(initial);
this._originalProtograph = protograph || { rootNodes: [] };
this._protograph = cloneDeep(this._originalProtograph); // this is what can be munched on
if (!this._protograph.rootNodes.length) {
this._protograph.rootNodes.push(SchemaAlignment.createNewRootNode());
}
$(this._nodeTable).empty();
this._nodeUIs = [];
for (var i = 0; i < this._protograph.rootNodes.length; i++) {
this._nodeUIs.push(new SchemaAlignmentDialog.UINode(
this,
this._protograph.rootNodes[i],
this._nodeTable,
{
expanded: true,
mustBeCellTopic: true
}
));
}
this.preview(initial);
};
SchemaAlignmentDialog.prototype._save = function(onDone) {
var self = this;
var protograph = this.getJSON();
Refine.postProcess(
"freebase",
"save-protograph",
{},
{ protograph: JSON.stringify(protograph) },
{},
{
onDone: function() {
theProject.overlayModels.freebaseProtograph = protograph;
self._elmts.statusIndicator.hide();
self._hasUnsavedChanges = false;
if (onDone) onDone();
}
}
);
var self = this;
var protograph = this.getJSON();
Refine.postProcess(
"freebase",
"save-protograph",
{},
{ protograph: JSON.stringify(protograph) },
{},
{
onDone: function() {
theProject.overlayModels.freebaseProtograph = protograph;
self._elmts.statusIndicator.hide();
self._hasUnsavedChanges = false;
if (onDone) onDone();
}
}
);
};
SchemaAlignmentDialog.prototype._createDialog = function() {
var self = this;
var frame = $(DOM.loadHTML("freebase", "scripts/dialogs/schema-alignment/schema-alignment-dialog.html"));
var elmts = this._elmts = DOM.bind(frame);
this._level = DialogSystem.showDialog(frame);
var dismiss = function() {
DialogSystem.dismissUntil(self._level - 1);
};
elmts.saveButton.click(function() {
self._save();
});
elmts.saveAndLoadButton.click(function() {
self._save(function() {
dismiss();
FreebaseExtension.handlers.loadIntoFreebase();
});
});
elmts.resetButton.click(function() {
self._reset(null);
});
elmts.closeButton.click(function() {
if (!self._hasUnsavedChanges || window.confirm("There are unsaved changes. Close anyway?")) {
dismiss();
}
});
$("#schema-alignment-tabs").tabs();
$("#schema-alignment-tabs-preview-mqllike").css("display", "");
$("#schema-alignment-tabs-preview-tripleloader").css("display", "");
var self = this;
var frame = $(DOM.loadHTML("freebase", "scripts/dialogs/schema-alignment/schema-alignment-dialog.html"));
var elmts = this._elmts = DOM.bind(frame);
this._previewPanes = $(".schema-alignment-dialog-preview");
this._canvas = $(".schema-alignment-dialog-canvas");
this._nodeTable = $('<table></table>').addClass("schema-alignment-table-layout").appendTo(this._canvas)[0];
this._level = DialogSystem.showDialog(frame);
var dismiss = function() {
DialogSystem.dismissUntil(self._level - 1);
};
elmts.saveButton.click(function() {
self._save();
});
elmts.saveAndLoadButton.click(function() {
self._save(function() {
dismiss();
FreebaseExtension.handlers.loadIntoFreebase();
});
});
elmts.resetButton.click(function() {
self._reset(null);
});
elmts.closeButton.click(function() {
if (!self._hasUnsavedChanges || window.confirm("There are unsaved changes. Close anyway?")) {
dismiss();
}
});
$("#schema-alignment-tabs").tabs();
$("#schema-alignment-tabs-preview-mqllike").css("display", "");
$("#schema-alignment-tabs-preview-tripleloader").css("display", "");
this._previewPanes = $(".schema-alignment-dialog-preview");
this._canvas = $(".schema-alignment-dialog-canvas");
this._nodeTable = $('<table></table>').addClass("schema-alignment-table-layout").appendTo(this._canvas)[0];
};
SchemaAlignmentDialog.prototype.getJSON = function() {
var rootNodes = [];
for (var i = 0; i < this._nodeUIs.length; i++) {
var node = this._nodeUIs[i].getJSON();
if (node !== null) {
rootNodes.push(node);
}
var rootNodes = [];
for (var i = 0; i < this._nodeUIs.length; i++) {
var node = this._nodeUIs[i].getJSON();
if (node !== null) {
rootNodes.push(node);
}
return {
rootNodes: rootNodes
};
}
return {
rootNodes: rootNodes
};
};
SchemaAlignmentDialog.prototype.preview = function(initial) {
var self = this;
this._previewPanes.empty();
if (!(initial)) {
this._elmts.statusIndicator.show().text("There are unsaved changes.");
this._hasUnsavedChanges = true;
}
var protograph = this.getJSON();
$.post(
"/command/freebase/preview-protograph?" + $.param({ project: theProject.id }),
{ protograph: JSON.stringify(protograph), engine: JSON.stringify(ui.browsingEngine.getJSON()) },
function(data) {
if ("mqllike" in data) {
$(self._previewPanes[0]).text(JSON.stringify(data.mqllike, null, 2));
}
if ("tripleloader" in data) {
$(self._previewPanes[1]).text(data.tripleloader);
}
},
"json"
);
var self = this;
this._previewPanes.empty();
if (!(initial)) {
this._elmts.statusIndicator.show().text("There are unsaved changes.");
this._hasUnsavedChanges = true;
}
var protograph = this.getJSON();
$.post(
"/command/freebase/preview-protograph?" + $.param({ project: theProject.id }),
{ protograph: JSON.stringify(protograph), engine: JSON.stringify(ui.browsingEngine.getJSON()) },
function(data) {
if ("mqllike" in data) {
$(self._previewPanes[0]).text(JSON.stringify(data.mqllike, null, 2));
}
if ("tripleloader" in data) {
$(self._previewPanes[1]).text(data.tripleloader);
}
},
"json"
);
};
SchemaAlignmentDialog._findColumn = function(cellIndex) {
var columns = theProject.columnModel.columns;
for (var i = 0; i < columns.length; i++) {
var column = columns[i];
if (column.cellIndex == cellIndex) {
return column;
}
var columns = theProject.columnModel.columns;
for (var i = 0; i < columns.length; i++) {
var column = columns[i];
if (column.cellIndex == cellIndex) {
return column;
}
return null;
}
return null;
};

View File

@ -7,20 +7,20 @@
<a href="http://code.google.com/p/google-refine/wiki/SchemaAlignment" target="_blank">Find out more ...</a>
</p>
<div id="schema-alignment-tabs" class="refine-tabs">
<ul>
<li><a href="#schema-alignment-tabs-protograph">Skeleton</a></li>
<li><a href="#schema-alignment-tabs-preview-mqllike">MQL-like Preview</a></li>
<li><a href="#schema-alignment-tabs-preview-tripleloader">TripleLoader Preview</a></li>
</ul>
<div id="schema-alignment-tabs-protograph">
<div class="schema-alignment-dialog-canvas"></div>
</div>
<div id="schema-alignment-tabs-preview-mqllike" style="display: none;">
<div class="schema-alignment-dialog-preview"></div>
</div>
<div id="schema-alignment-tabs-preview-tripleloader" style="display: none;">
<div class="schema-alignment-dialog-preview"></div>
</div>
<ul>
<li><a href="#schema-alignment-tabs-protograph">Skeleton</a></li>
<li><a href="#schema-alignment-tabs-preview-mqllike">MQL-like Preview</a></li>
<li><a href="#schema-alignment-tabs-preview-tripleloader">TripleLoader Preview</a></li>
</ul>
<div id="schema-alignment-tabs-protograph">
<div class="schema-alignment-dialog-canvas"></div>
</div>
<div id="schema-alignment-tabs-preview-mqllike" style="display: none;">
<div class="schema-alignment-dialog-preview"></div>
</div>
<div id="schema-alignment-tabs-preview-tripleloader" style="display: none;">
<div class="schema-alignment-dialog-preview"></div>
</div>
</div>
</div>
<div class="dialog-footer" bind="dialogFooter"><div class="grid-layout layout-normal layout-full"><table><tr>

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,354 +29,354 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
SchemaAlignmentDialog.UILink = function(dialog, link, table, options, parentUINode) {
this._dialog = dialog;
this._link = link;
this._options = options;
this._parentUINode = parentUINode;
// Make sure target node is there
this._link.target = this._link.target || { nodeType: "cell-as-value" }
this._tr = table.insertRow(table.rows.length);
this._tdMain = this._tr.insertCell(0);
this._tdToggle = this._tr.insertCell(1);
this._tdDetails = this._tr.insertCell(2);
$(this._tdMain).addClass("schema-alignment-link-main").attr("width", "250").addClass("padded");
$(this._tdToggle).addClass("schema-alignment-link-toggle").attr("width", "1%").addClass("padded");
$(this._tdDetails).addClass("schema-alignment-link-details").attr("width", "90%");
this._collapsedDetailDiv = $('<div></div>').appendTo(this._tdDetails).addClass("padded").html("...");
this._expandedDetailDiv = $('<div></div>').appendTo(this._tdDetails).addClass("schema-alignment-detail-container");
var self = this;
var show = function() {
if (self._options.expanded) {
self._collapsedDetailDiv.hide();
self._expandedDetailDiv.show();
} else {
self._collapsedDetailDiv.show();
self._expandedDetailDiv.hide();
}
};
this._dialog = dialog;
this._link = link;
this._options = options;
this._parentUINode = parentUINode;
// Make sure target node is there
this._link.target = this._link.target || { nodeType: "cell-as-value" }
this._tr = table.insertRow(table.rows.length);
this._tdMain = this._tr.insertCell(0);
this._tdToggle = this._tr.insertCell(1);
this._tdDetails = this._tr.insertCell(2);
$(this._tdMain).addClass("schema-alignment-link-main").attr("width", "250").addClass("padded");
$(this._tdToggle).addClass("schema-alignment-link-toggle").attr("width", "1%").addClass("padded");
$(this._tdDetails).addClass("schema-alignment-link-details").attr("width", "90%");
this._collapsedDetailDiv = $('<div></div>').appendTo(this._tdDetails).addClass("padded").html("...");
this._expandedDetailDiv = $('<div></div>').appendTo(this._tdDetails).addClass("schema-alignment-detail-container");
var self = this;
var show = function() {
if (self._options.expanded) {
self._collapsedDetailDiv.hide();
self._expandedDetailDiv.show();
} else {
self._collapsedDetailDiv.show();
self._expandedDetailDiv.hide();
}
};
show();
$(this._tdToggle).html("&nbsp;");
$('<img />')
.attr("src", this._options.expanded ? "images/expanded.png" : "images/collapsed.png")
.appendTo(this._tdToggle)
.click(function() {
self._options.expanded = !self._options.expanded;
$(this).attr("src", self._options.expanded ? "images/expanded.png" : "images/collapsed.png");
show();
$(this._tdToggle).html("&nbsp;");
$('<img />')
.attr("src", this._options.expanded ? "images/expanded.png" : "images/collapsed.png")
.appendTo(this._tdToggle)
.click(function() {
self._options.expanded = !self._options.expanded;
$(this).attr("src", self._options.expanded ? "images/expanded.png" : "images/collapsed.png");
show();
});
this._renderMain();
this._renderDetails();
});
this._renderMain();
this._renderDetails();
};
SchemaAlignmentDialog.UILink.prototype._renderMain = function() {
$(this._tdMain).empty();
var label = this._link.property !== null ?
(this._link.property.id + ((this._link.condition) ? " [?]" : "")) :
"property?";
var self = this;
$('<img />')
.attr("title", "remove property")
.attr("src", "images/close.png")
.css("cursor", "pointer")
.prependTo(this._tdMain)
.click(function() {
window.setTimeout(function() {
self._parentUINode.removeLink(self);
self._tr.parentNode.removeChild(self._tr);
self._dialog.preview();
}, 100);
});
var a = $('<a href="javascript:{}"></a>')
.addClass("schema-alignment-link-tag")
.html(label)
.appendTo(this._tdMain)
.click(function(evt) {
self._startEditProperty(this);
});
$('<img />').attr("src", "images/arrow-start.png").prependTo(a);
$('<img />').attr("src", "images/arrow-end.png").appendTo(a);
$(this._tdMain).empty();
var label = this._link.property !== null ?
(this._link.property.id + ((this._link.condition) ? " [?]" : "")) :
"property?";
var self = this;
$('<img />')
.attr("title", "remove property")
.attr("src", "images/close.png")
.css("cursor", "pointer")
.prependTo(this._tdMain)
.click(function() {
window.setTimeout(function() {
self._parentUINode.removeLink(self);
self._tr.parentNode.removeChild(self._tr);
self._dialog.preview();
}, 100);
});
var a = $('<a href="javascript:{}"></a>')
.addClass("schema-alignment-link-tag")
.html(label)
.appendTo(this._tdMain)
.click(function(evt) {
self._startEditProperty(this);
});
$('<img />').attr("src", "images/arrow-start.png").prependTo(a);
$('<img />').attr("src", "images/arrow-end.png").appendTo(a);
};
SchemaAlignmentDialog.UILink.prototype._renderDetails = function() {
if (this._targetUI) {
this._targetUI.dispose();
}
if (this._tableDetails) {
this._tableDetails.remove();
}
this._tableDetails = $('<table></table>').addClass("schema-alignment-table-layout").appendTo(this._expandedDetailDiv);
this._targetUI = new SchemaAlignmentDialog.UINode(
this._dialog,
this._link.target,
this._tableDetails[0],
{ expanded: "links" in this._link.target && this._link.target.links.length > 0 });
if (this._targetUI) {
this._targetUI.dispose();
}
if (this._tableDetails) {
this._tableDetails.remove();
}
this._tableDetails = $('<table></table>').addClass("schema-alignment-table-layout").appendTo(this._expandedDetailDiv);
this._targetUI = new SchemaAlignmentDialog.UINode(
this._dialog,
this._link.target,
this._tableDetails[0],
{ expanded: "links" in this._link.target && this._link.target.links.length > 0 });
};
SchemaAlignmentDialog.UILink.prototype._startEditProperty = function(elmt) {
var sourceTypeID = this._parentUINode.getExpectedType();
var targetNode = this._targetUI._node;
var targetTypeID = "type" in targetNode && targetNode.type !== null ? targetNode.type.id : null;
var targetTypeName = "columnNames" in targetNode ? targetNode.columnNames[0] : null;
if (sourceTypeID !== null) {
var self = this;
var dismissBusy = DialogSystem.showBusy();
var instanceCount = 0;
var outgoing = [];
var incoming = [];
var onDone = function(properties) {
dismissBusy();
self._showPropertySuggestPopup(
elmt,
properties
);
};
SchemaAlignmentDialog.UILink._getPropertiesOfType(
sourceTypeID,
targetTypeID,
targetTypeName,
onDone
);
} else {
this._showPropertySuggestPopup(elmt, []);
}
var sourceTypeID = this._parentUINode.getExpectedType();
var targetNode = this._targetUI._node;
var targetTypeID = "type" in targetNode && targetNode.type !== null ? targetNode.type.id : null;
var targetTypeName = "columnNames" in targetNode ? targetNode.columnNames[0] : null;
if (sourceTypeID !== null) {
var self = this;
var dismissBusy = DialogSystem.showBusy();
var instanceCount = 0;
var outgoing = [];
var incoming = [];
var onDone = function(properties) {
dismissBusy();
self._showPropertySuggestPopup(
elmt,
properties
);
};
SchemaAlignmentDialog.UILink._getPropertiesOfType(
sourceTypeID,
targetTypeID,
targetTypeName,
onDone
);
} else {
this._showPropertySuggestPopup(elmt, []);
}
};
SchemaAlignmentDialog.UILink._getPropertiesOfType = function(typeID, targetTypeID, targetTypeName, onDone) {
var done = false;
var params = {
"type" : typeID
};
if (targetTypeID !== null) {
params.expects = targetTypeID;
} else if (targetTypeName !== null) {
params.expects = targetTypeName;
var done = false;
var params = {
"type" : typeID
};
if (targetTypeID !== null) {
params.expects = targetTypeID;
} else if (targetTypeName !== null) {
params.expects = targetTypeName;
}
$.getJSON(
Refine.refineHelperService + "/get_properties_of_type?" + $.param(params) + "&callback=?",
null,
function(data) {
if (done) return;
done = true;
onDone(data.properties || []);
}
$.getJSON(
Refine.refineHelperService + "/get_properties_of_type?" + $.param(params) + "&callback=?",
null,
function(data) {
if (done) return;
done = true;
onDone(data.properties || []);
}
);
window.setTimeout(function() {
if (done) return;
done = true;
onDone([]);
}, 7000); // time to give up?
);
window.setTimeout(function() {
if (done) return;
done = true;
onDone([]);
}, 7000); // time to give up?
};
SchemaAlignmentDialog.UILink.prototype._showPropertySuggestPopup = function(elmt, suggestions) {
self = this;
var menu = MenuSystem.createMenu().width("350px");
var commitProperty = function(p) {
window.setTimeout(function() { MenuSystem.dismissAll(); }, 100);
if ("id2" in p) {
// self._targetUI.dispose();
self._link.property = {
id: p.id,
name: p.name
};
self._link.target = {
nodeType: "anonymous",
links: [{
property: {
id: p.id2,
name: p.name2
},
target: self._link.target
}]
};
self._renderDetails();
} else {
self._link.property = {
id: p.id,
name: p.name
};
}
var conditionColumnName = conditionalSelect[0].value;
if (conditionColumnName != "") {
self._link.condition = { columnName: conditionColumnName };
} else {
delete self._link.condition;
}
self._configureTarget();
};
var divConditional = $('<div>')
.addClass("schema-alignment-link-menu-section")
.html("Assert link when 'true' is found in column<br/>").appendTo(menu);
var conditionalSelect = $('<select>').appendTo(divConditional);
$('<option>')
.text("(always assert)")
.attr("value", "")
.attr("name", "schema-alignment-link-menu-condition")
.appendTo(conditionalSelect);
for (var c = 0; c < theProject.columnModel.columns.length; c++) {
var column = theProject.columnModel.columns[c];
var option = $('<option>')
.text(column.name)
.attr("value", column.name)
.attr("name", "schema-alignment-link-menu-condition")
.appendTo(conditionalSelect);
if ((self._link.condition) && column.name == self._link.condition.columnName) {
option.attr("selected", "true");
}
}
var divSearch;
if (suggestions.length > 0) {
divSearch = $('<div>')
.addClass("schema-alignment-link-menu-section")
.css("margin-bottom", "2em")
.html('<div>Search for a property or pick one below</div>').appendTo(menu);
var createSuggestion = function(suggestion) {
var menuItem = MenuSystem.createMenuItem().appendTo(menu);
$('<span>')
.text(suggestion.name)
.attr("title", suggestion.id)
.appendTo(menuItem);
if ("name2" in suggestion) {
$('<span>').html(" &raquo; ").appendTo(menuItem);
$('<span>')
.text(suggestion.name2)
.attr("title", suggestion.id2)
.appendTo(menuItem);
}
menuItem.click(function() {
commitProperty(suggestion);
});
};
for (var i = 0; i < suggestions.length && i < 10; i++) {
createSuggestion(suggestions[i]);
}
self = this;
var menu = MenuSystem.createMenu().width("350px");
var commitProperty = function(p) {
window.setTimeout(function() { MenuSystem.dismissAll(); }, 100);
if ("id2" in p) {
// self._targetUI.dispose();
self._link.property = {
id: p.id,
name: p.name
};
self._link.target = {
nodeType: "anonymous",
links: [{
property: {
id: p.id2,
name: p.name2
},
target: self._link.target
}]
};
self._renderDetails();
} else {
divSearch = $('<div>')
.addClass("schema-alignment-link-menu-section-last")
.html('<div>Search for a property</div>').appendTo(menu);
self._link.property = {
id: p.id,
name: p.name
};
}
var input = $('<input />').appendTo($('<div>').appendTo(divSearch));
MenuSystem.showMenu(menu, function(){});
MenuSystem.positionMenuAboveBelow(menu, $(elmt));
var suggestOptions = {
type : '/type/property'
var conditionColumnName = conditionalSelect[0].value;
if (conditionColumnName != "") {
self._link.condition = { columnName: conditionColumnName };
} else {
delete self._link.condition;
}
self._configureTarget();
};
var divConditional = $('<div>')
.addClass("schema-alignment-link-menu-section")
.html("Assert link when 'true' is found in column<br/>").appendTo(menu);
var conditionalSelect = $('<select>').appendTo(divConditional);
$('<option>')
.text("(always assert)")
.attr("value", "")
.attr("name", "schema-alignment-link-menu-condition")
.appendTo(conditionalSelect);
for (var c = 0; c < theProject.columnModel.columns.length; c++) {
var column = theProject.columnModel.columns[c];
var option = $('<option>')
.text(column.name)
.attr("value", column.name)
.attr("name", "schema-alignment-link-menu-condition")
.appendTo(conditionalSelect);
if ((self._link.condition) && column.name == self._link.condition.columnName) {
option.attr("selected", "true");
}
}
var divSearch;
if (suggestions.length > 0) {
divSearch = $('<div>')
.addClass("schema-alignment-link-menu-section")
.css("margin-bottom", "2em")
.html('<div>Search for a property or pick one below</div>').appendTo(menu);
var createSuggestion = function(suggestion) {
var menuItem = MenuSystem.createMenuItem().appendTo(menu);
$('<span>')
.text(suggestion.name)
.attr("title", suggestion.id)
.appendTo(menuItem);
if ("name2" in suggestion) {
$('<span>').html(" &raquo; ").appendTo(menuItem);
$('<span>')
.text(suggestion.name2)
.attr("title", suggestion.id2)
.appendTo(menuItem);
}
menuItem.click(function() {
commitProperty(suggestion);
});
};
var sourceTypeID = this._parentUINode.getExpectedType();
if (sourceTypeID !== null) {
suggestOptions.ac_param = { schema: sourceTypeID };
for (var i = 0; i < suggestions.length && i < 10; i++) {
createSuggestion(suggestions[i]);
}
input.suggestP(suggestOptions).bind("fb-select", function(e, data) { commitProperty(data); });
input[0].focus();
} else {
divSearch = $('<div>')
.addClass("schema-alignment-link-menu-section-last")
.html('<div>Search for a property</div>').appendTo(menu);
}
var input = $('<input />').appendTo($('<div>').appendTo(divSearch));
MenuSystem.showMenu(menu, function(){});
MenuSystem.positionMenuAboveBelow(menu, $(elmt));
var suggestOptions = {
type : '/type/property'
};
var sourceTypeID = this._parentUINode.getExpectedType();
if (sourceTypeID !== null) {
suggestOptions.ac_param = { schema: sourceTypeID };
}
input.suggestP(suggestOptions).bind("fb-select", function(e, data) { commitProperty(data); });
input[0].focus();
};
SchemaAlignmentDialog.UILink.prototype.getJSON = function() {
if ("property" in this._link && this._link.property !== null &&
"target" in this._link && this._link.target !== null) {
var targetJSON = this._targetUI.getJSON();
if (targetJSON !== null) {
var json = {
property: cloneDeep(this._link.property),
target: targetJSON
};
if (this._link.condition) {
json.condition = cloneDeep(this._link.condition);
}
return json;
}
if ("property" in this._link && this._link.property !== null &&
"target" in this._link && this._link.target !== null) {
var targetJSON = this._targetUI.getJSON();
if (targetJSON !== null) {
var json = {
property: cloneDeep(this._link.property),
target: targetJSON
};
if (this._link.condition) {
json.condition = cloneDeep(this._link.condition);
}
return json;
}
return null;
}
return null;
};
SchemaAlignmentDialog.UILink.prototype._configureTarget = function() {
var self = this;
var dismissBusy = DialogSystem.showBusy();
$.getJSON(
"http://api.freebase.com/api/service/mqlread?query=" + JSON.stringify({
query: {
"id" : this._link.property.id,
"type" : "/type/property",
"expected_type" : {
"id" : null,
"name" : null,
"/freebase/type_hints/mediator" : null
}
}
}) + "&callback=?",
null,
function(o) {
dismissBusy();
if ("result" in o) {
var expected_type = o.result.expected_type;
self._link.target.type = {
id: expected_type.id,
name: expected_type.name
};
if (expected_type["/freebase/type_hints/mediator"] === true) {
self._link.target.nodeType = "anonymous";
} else if (expected_type.id == "/type/key") {
self._link.target.nodeType = "cell-as-key";
} else if (expected_type.id.match(/^\/type\//)) {
self._link.target.nodeType = "cell-as-value";
} else if (!("topic" in self._link.target)) {
self._link.target.nodeType = "cell-as-topic";
self._link.target.createForNoReconMatch = true;
}
self._targetUI.render();
}
self._renderMain();
self._dialog.preview();
},
"jsonp"
);
var self = this;
var dismissBusy = DialogSystem.showBusy();
$.getJSON(
"http://api.freebase.com/api/service/mqlread?query=" + JSON.stringify({
query: {
"id" : this._link.property.id,
"type" : "/type/property",
"expected_type" : {
"id" : null,
"name" : null,
"/freebase/type_hints/mediator" : null
}
}
}) + "&callback=?",
null,
function(o) {
dismissBusy();
if ("result" in o) {
var expected_type = o.result.expected_type;
self._link.target.type = {
id: expected_type.id,
name: expected_type.name
};
if (expected_type["/freebase/type_hints/mediator"] === true) {
self._link.target.nodeType = "anonymous";
} else if (expected_type.id == "/type/key") {
self._link.target.nodeType = "cell-as-key";
} else if (expected_type.id.match(/^\/type\//)) {
self._link.target.nodeType = "cell-as-value";
} else if (!("topic" in self._link.target)) {
self._link.target.nodeType = "cell-as-topic";
self._link.target.createForNoReconMatch = true;
}
self._targetUI.render();
}
self._renderMain();
self._dialog.preview();
},
"jsonp"
);
};

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,117 +29,117 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
var FreebaseExtension = { handlers: {} };
FreebaseExtension.handlers.editSchemaAlignment = function() {
new SchemaAlignmentDialog(theProject.overlayModels.freebaseProtograph, function(newProtograph) {});
new SchemaAlignmentDialog(theProject.overlayModels.freebaseProtograph, function(newProtograph) {});
};
FreebaseExtension.handlers.loadIntoFreebase = function() {
new FreebaseLoadingDialog();
new FreebaseLoadingDialog();
};
FreebaseExtension.handlers.browseToDataLoad = function() {
// The form has to be created as part of the click handler. If you create it
// inside the getJSON success handler, it won't work.
var form = document.createElement("form");
$(form)
.css("display", "none")
.attr("method", "GET")
.attr("target", "dataload");
// The form has to be created as part of the click handler. If you create it
// inside the getJSON success handler, it won't work.
document.body.appendChild(form);
var w = window.open("about:blank", "dataload");
$.getJSON(
"/command/core/get-preference?" + $.param({ project: theProject.id, name: "freebase.load.jobID" }),
null,
function(data) {
if (data.value == null) {
alert("You have not tried to load the data in this project into Freebase yet.");
} else {
$(form).attr("action", "http://refinery.freebaseapps.com/load/" + data.value);
form.submit();
w.focus();
}
document.body.removeChild(form);
}
);
var form = document.createElement("form");
$(form)
.css("display", "none")
.attr("method", "GET")
.attr("target", "dataload");
document.body.appendChild(form);
var w = window.open("about:blank", "dataload");
$.getJSON(
"/command/core/get-preference?" + $.param({ project: theProject.id, name: "freebase.load.jobID" }),
null,
function(data) {
if (data.value == null) {
alert("You have not tried to load the data in this project into Freebase yet.");
} else {
$(form).attr("action", "http://refinery.freebaseapps.com/load/" + data.value);
form.submit();
w.focus();
}
document.body.removeChild(form);
}
);
};
FreebaseExtension.handlers.importQAData = function() {
Refine.postProcess(
"freebase-extension",
"import-qa-data",
{},
{},
{ cellsChanged: true }
);
Refine.postProcess(
"freebase-extension",
"import-qa-data",
{},
{},
{ cellsChanged: true }
);
};
ExtensionBar.addExtensionMenu({
"id" : "freebase",
"label" : "Freebase",
"submenu" : [
{
"id" : "freebase/schema-alignment",
label: "Align to Freebase's schemas...",
click: function() { FreebaseExtension.handlers.editSchemaAlignment(false); }
},
{
"id" : "freebase/load-info-freebase",
label: "Load into Freebase...",
click: function() { FreebaseExtension.handlers.loadIntoFreebase(); }
},
{},
{
"id" : "freebase/browse-load",
label: "Browse data load details...",
click: function() { FreebaseExtension.handlers.browseToDataLoad(); }
},
{
"id" : "freebase/import-qa-data",
label: "Import QA data",
click: function() { FreebaseExtension.handlers.importQAData(); }
}
]
"id" : "freebase",
"label" : "Freebase",
"submenu" : [
{
"id" : "freebase/schema-alignment",
label: "Align to Freebase's schemas...",
click: function() { FreebaseExtension.handlers.editSchemaAlignment(false); }
},
{
"id" : "freebase/load-info-freebase",
label: "Load into Freebase...",
click: function() { FreebaseExtension.handlers.loadIntoFreebase(); }
},
{},
{
"id" : "freebase/browse-load",
label: "Browse data load details...",
click: function() { FreebaseExtension.handlers.browseToDataLoad(); }
},
{
"id" : "freebase/import-qa-data",
label: "Import QA data",
click: function() { FreebaseExtension.handlers.importQAData(); }
}
]
});
DataTableColumnHeaderUI.extendMenu(function(column, columnHeaderUI, menu) {
var columnIndex = Refine.columnNameToColumnIndex(column.name);
var doAddColumnFromFreebase = function() {
var o = DataTableView.sampleVisibleRows(column);
new ExtendDataPreviewDialog(
column,
columnIndex,
o.rowIndices,
function(extension) {
Refine.postProcess(
"freebase",
"extend-data",
{
baseColumnName: column.name,
columnInsertIndex: columnIndex + 1
},
{
extension: JSON.stringify(extension)
},
{ rowsChanged: true, modelsChanged: true }
);
}
var columnIndex = Refine.columnNameToColumnIndex(column.name);
var doAddColumnFromFreebase = function() {
var o = DataTableView.sampleVisibleRows(column);
new ExtendDataPreviewDialog(
column,
columnIndex,
o.rowIndices,
function(extension) {
Refine.postProcess(
"freebase",
"extend-data",
{
baseColumnName: column.name,
columnInsertIndex: columnIndex + 1
},
{
extension: JSON.stringify(extension)
},
{ rowsChanged: true, modelsChanged: true }
);
};
MenuSystem.insertAfter(
menu,
[ "core/edit-column", "core/add-column-by-fetching-urls" ],
{
id: "freebase/add-columns-from-freebase",
label: "Add columns from Freebase ...",
click: doAddColumnFromFreebase
}
}
);
};
MenuSystem.insertAfter(
menu,
[ "core/edit-column", "core/add-column-by-fetching-urls" ],
{
id: "freebase/add-columns-from-freebase",
label: "Add columns from Freebase ...",
click: doAddColumnFromFreebase
}
);
});

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,35 +29,35 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
var Freebase = {};
Freebase.mqlread = function(query, options, onDone) {
var params = {};
var queryEnv = {
"query": query
};
if (options) {
for (var n in options) {
if (options.hasOwnProperty(n)) {
var v = options[n];
if (typeof v != "string") {
v = JSON.stringify(v);
}
queryEnv[n] = v;
}
var params = {};
var queryEnv = {
"query": query
};
if (options) {
for (var n in options) {
if (options.hasOwnProperty(n)) {
var v = options[n];
if (typeof v != "string") {
v = JSON.stringify(v);
}
queryEnv[n] = v;
}
}
params.query = JSON.stringify(queryEnv);
$.getJSON(
"http://api.freebase.com/api/service/mqlread?" + $.param(params) + "&callback=?",
null,
onDone,
"jsonp"
);
}
params.query = JSON.stringify(queryEnv);
$.getJSON(
"http://api.freebase.com/api/service/mqlread?" + $.param(params) + "&callback=?",
null,
onDone,
"jsonp"
);
};

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,125 +29,124 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
if (typeof window.Sign == 'undefined') {
window.Sign = {
window_position: function() {
var position = {};
if (typeof(window.innerWidth) == 'number') {
// Non-IE
position.width = window.outerWidth;
position.height = window.outerHeight;
position.top = window.screenY;
position.left = window.screenX;
} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
// IE 6+ in 'standards compliant mode'
position.width = document.body.clientWidth;
position.height = document.body.clientHeight;
position.top = window.screenTop;
position.left = window.screenLeft;
if (typeof window.Sign == 'undefined') {
window.Sign = {
window_position: function() {
var position = {};
if (typeof(window.innerWidth) == 'number') {
// Non-IE
position.width = window.outerWidth;
position.height = window.outerHeight;
position.top = window.screenY;
position.left = window.screenX;
} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
// IE 6+ in 'standards compliant mode'
position.width = document.body.clientWidth;
position.height = document.body.clientHeight;
position.top = window.screenTop;
position.left = window.screenLeft;
}
return position;
},
popup : function(url, width, height, windowname) {
width = width || 700;
height = height || 500;
var pos = window.Sign.window_position();
var left = Math.floor((pos.width - width) / 2) + pos.left;
var top = Math.floor((pos.height - height) / 2) + pos.top;
// Chrome might fix this bug, but until then add some padding
// to the height of the popup for the urlbar
var is_chrome = /chrome/.test(navigator.userAgent.toLowerCase());
if (is_chrome) {
height += 50;
}
var params = {
width: width,
height: height,
top: top,
left: left,
directories: 'no',
location: 'no',
menubar: 'no',
resizable: 'no',
scrollbars: 'yes',
status: 'no',
toolbar: 'no'
};
var params_list = [];
for (var key in params) {
if (params.hasOwnProperty(key)) {
params_list.push(key + "=" + params[key]);
}
return position;
},
popup : function(url, width, height, windowname) {
width = width || 700;
height = height || 500;
var pos = window.Sign.window_position();
var left = Math.floor((pos.width - width) / 2) + pos.left;
var top = Math.floor((pos.height - height) / 2) + pos.top;
// Chrome might fix this bug, but until then add some padding
// to the height of the popup for the urlbar
var is_chrome = /chrome/.test(navigator.userAgent.toLowerCase());
if (is_chrome) {
height += 50;
}
return window.open(url, windowname || "", params_list.join(","));
},
signintize : function(cont) {
$('.signedin').show();
$('.signedout').hide();
if (window.user) {
$('.user').html('<a href="http://freebase.com/view' + window.user.id + '">' + window.user.username + '</a>');
}
if (typeof cont == 'function') cont();
},
signin : function(success, provider, width, height) {
var newwin = window.Sign.popup("/command/freebase/authorize/" + provider, width, height);
if (newwin !== null) {
newwin.opener = window;
}
window.onauthorization = function() {
if (typeof success == 'undefined') {
window.location.reload();
} else {
$.ajax({
url: "/command/freebase/check-authorization/" + provider,
dataType: "json",
success: function(data) {
window.user = data;
window.Sign.signintize(success);
}
});
}
var params = {
width: width,
height: height,
top: top,
left: left,
directories: 'no',
location: 'no',
menubar: 'no',
resizable: 'no',
scrollbars: 'yes',
status: 'no',
toolbar: 'no'
};
var params_list = [];
for (var key in params) {
if (params.hasOwnProperty(key)) {
params_list.push(key + "=" + params[key]);
}
}
return window.open(url, windowname || "", params_list.join(","));
},
signintize : function(cont) {
$('.signedin').show();
$('.signedout').hide();
if (window.user) {
$('.user').html('<a href="http://freebase.com/view' + window.user.id + '">' + window.user.username + '</a>');
}
if (typeof cont == 'function') cont();
},
signin : function(success, provider, width, height) {
var newwin = window.Sign.popup("/command/freebase/authorize/" + provider, width, height);
if (newwin !== null) {
newwin.opener = window;
}
window.onauthorization = function() {
};
if (window.focus && newwin !== null) {
newwin.focus();
}
return false;
},
signoutize : function(cont) {
$('.signedin').hide();
$('.signedout').show();
if (typeof cont == 'function') cont();
},
signout : function(success,provider) {
$.ajax({
url: "/command/freebase/deauthorize/" + provider,
success: function() {
if (typeof success == 'undefined') {
window.location.reload();
} else {
$.ajax({
url: "/command/freebase/check-authorization/" + provider,
dataType: "json",
success: function(data) {
window.user = data;
window.Sign.signintize(success);
}
});
window.Sign.signoutize(success);
}
};
if (window.focus && newwin !== null) {
newwin.focus();
}
return false;
},
signoutize : function(cont) {
$('.signedin').hide();
$('.signedout').show();
if (typeof cont == 'function') cont();
},
signout : function(success,provider) {
$.ajax({
url: "/command/freebase/deauthorize/" + provider,
success: function() {
if (typeof success == 'undefined') {
window.location.reload();
} else {
window.Sign.signoutize(success);
}
}
});
}
};
}
});
}
};
}

View File

@ -34,38 +34,38 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@import-less url("../theme.less");
.extend-data-preview-dialog .suggested-property-container {
border: 1px solid #aaa;
padding: 5px;
overflow: auto;
height: 375px;
}
border: 1px solid #aaa;
padding: 5px;
overflow: auto;
height: 375px;
}
.extend-data-preview-dialog .suggested-property {
padding: 5px;
}
padding: 5px;
}
.extend-data-preview-dialog input.property-suggest {
display: block;
padding: 2%;
width: 96%;
}
display: block;
padding: 2%;
width: 96%;
}
.extend-data-preview-dialog .preview-container {
border: 1px solid #aaa;
overflow: auto;
}
border: 1px solid #aaa;
overflow: auto;
}
.extend-data-preview-dialog .preview-container table {
border-collapse: collapse;
}
border-collapse: collapse;
}
.extend-data-preview-dialog .preview-container td, .extend-data-preview-dialog .preview-container th {
padding: 3px 5px;
border-bottom: 1px solid #ddd;
border-right: 1px solid #ddd;
}
padding: 3px 5px;
border-bottom: 1px solid #ddd;
border-right: 1px solid #ddd;
}
.extend-data-preview-dialog .preview-container th img {
vertical-align: top;
margin-left: 5px;
}
vertical-align: top;
margin-left: 5px;
}

View File

@ -35,43 +35,43 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.freebase-loading-dialog-functional-tab-panel {
height: 400px !important;
}
}
.freebase-loading-tripleloader-data {
width: 99%;
overflow: scroll;
border: 1px solid #aaa;
white-space: pre;
padding: 0.3em 0.5em 0.5em 0.5em;
font-family: monospace;
}
width: 99%;
overflow: scroll;
border: 1px solid #aaa;
white-space: pre;
padding: 0.3em 0.5em 0.5em 0.5em;
font-family: monospace;
}
.freebase-loading-tripleloader-message {
height: 400px;
overflow: auto;
border: 1px solid #aaa;
padding: 1em;
}
height: 400px;
overflow: auto;
border: 1px solid #aaa;
padding: 1em;
}
.freebase-loading-tripleloader-message h2 {
font-size: 150%;
font-weight: normal;
}
}
.freebase-loading-tripleloader-message h2 span {
font-size; 130%;
font-weight: bold;
}
}
.freebase-loading-tripleloader-message h4 {
font-size: 120%;
margin-top: 2em;
font-weight: normal;
}
}
.freebase-loading-tripleloader-message a {
font-size: 120%;
font-weight: bold;
}
}
.freebase-loading-authorization {
margin: 0em 2em;
@ -80,13 +80,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
background-color: #fff;
-moz-border-radius: 0.8em;
-webkit-border-radius: 0.8em;
}
}
.freebase-loading-tripleloader-info {
margin-bottom: 0.5em;
}
}
.freebase-loading-tripleloader-info textarea {
width: 99%;
height: 5em;
}
}

View File

@ -34,86 +34,86 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@import-less url("../theme.less");
.schema-alignment-dialog-canvas {
height: 375px;
overflow: auto;
padding: 10px;
margin-top: 3px;
background: white;
}
height: 375px;
overflow: auto;
padding: 10px;
margin-top: 3px;
background: white;
}
table.schema-alignment-table-layout {
border-collapse: collapse;
margin: 0px;
padding: 0px;
margin-bottom: 1em;
}
border-collapse: collapse;
margin: 0px;
padding: 0px;
margin-bottom: 1em;
}
table.schema-alignment-table-layout .padded {
padding: 3px 6px;
}
padding: 3px 6px;
}
div.schema-alignment-detail-container {
border-left: 3px solid #eee;
}
border-left: 3px solid #eee;
}
td.schema-alignment-node-main, td.schema-alignment-link-main {
white-space: pre;
width: 300px;
}
white-space: pre;
width: 300px;
}
td.schema-alignment-node-toggle, td.schema-alignment-link-toggle {
white-space: pre;
width: 1%;
}
white-space: pre;
width: 1%;
}
td.schema-alignment-node-toggle img, td.schema-alignment-link-toggle img {
cursor: pointer;
vertical-align: middle;
padding: 2px;
}
cursor: pointer;
vertical-align: middle;
padding: 2px;
}
td.schema-alignment-node-details, td.schema-alignment-link-details {
width: 90%;
}
width: 90%;
}
a.schema-alignment-node-tag {
padding: 3px 6px;
background: #ddd;
text-decoration: none;
color: black;
-moz-border-radius: 10px;
}
padding: 3px 6px;
background: #ddd;
text-decoration: none;
color: black;
-moz-border-radius: 10px;
}
a.schema-alignment-node-tag:hover {
background: #888;
color: white;
}
background: #888;
color: white;
}
.schema-alignment-node-column {
font-weight: bold;
}
font-weight: bold;
}
a.schema-alignment-link-tag {
padding: 3px 6px;
text-decoration: none;
color: black;
}
padding: 3px 6px;
text-decoration: none;
color: black;
}
a.schema-alignment-link-tag:hover {
color: #88f;
}
color: #88f;
}
div.schema-alignment-dialog-preview {
height: 400px;
overflow: auto;
background: white;
padding: 10px;
margin-top: 3px;
white-space: pre;
font-family: monospace;
font-size: 9pt;
}
height: 400px;
overflow: auto;
background: white;
padding: 10px;
margin-top: 3px;
white-space: pre;
font-family: monospace;
font-size: 9pt;
}
.schema-alignment-status-indicator {
color: #red;
}
color: #red;
}
/*--------------------------------------------------
* Node dialog
@ -121,18 +121,18 @@ div.schema-alignment-dialog-preview {
*/
.schema-align-node-dialog-node-type {
padding: 0.25em;
background: #ddf;
}
padding: 0.25em;
background: #ddf;
}
.schema-align-node-dialog-node-type input {
vertical-align: text-bottom;
}
vertical-align: text-bottom;
}
.schema-alignment-node-dialog-column-list {
height: 300px;
width: 200px;
overflow: auto;
border: 1px solid #ddd;
}
height: 300px;
width: 200px;
overflow: auto;
border: 1px solid #ddd;
}
/*--------------------------------------------------
* Link dialog
@ -140,10 +140,10 @@ div.schema-alignment-dialog-preview {
*/
.schema-alignment-link-menu-section {
padding: 8px;
border-bottom: 1px solid #ddd;
}
padding: 8px;
border-bottom: 1px solid #ddd;
}
.schema-alignment-link-menu-section-last {
padding: 8px;
}
padding: 8px;
}

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,7 +29,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
var html = "text/html";
var encoding = "UTF-8";
@ -39,60 +39,60 @@ var version = "0.2";
* Function invoked to initialize the extension.
*/
function init() {
// Packages.java.lang.System.err.println("Initializing gData extension");
// Packages.java.lang.System.err.println(module.getMountPoint());
//Packages.java.lang.System.err.println("Initializing gData extension");
//Packages.java.lang.System.err.println(module.getMountPoint());
var RS = Packages.com.google.refine.RefineServlet;
RS.registerCommand(module, "authorize", Packages.com.google.refine.extension.gdata.AuthorizeCommand());
RS.registerCommand(module, "authorize2", Packages.com.google.refine.extension.gdata.AuthorizeCommand2());
RS.registerCommand(module, "deauthorize", Packages.com.google.refine.extension.gdata.DeAuthorizeCommand());
// Register importer and exporter
var IM = Packages.com.google.refine.importing.ImportingManager;
IM.registerFormat("service/gdata", "GData services"); // generic format, no parser to handle it
IM.registerFormat("service/gdata/spreadsheet", "Google spreadsheets", false, "GoogleSpreadsheetParserUI",
new Packages.com.google.refine.extension.gdata.GDataImporter());
IM.registerUrlRewriter(new Packages.com.google.refine.extension.gdata.GDataUrlRewriter())
IM.registerUrlRewriter(new Packages.com.google.refine.extension.gdata.FusionTablesUrlRewriter())
var RS = Packages.com.google.refine.RefineServlet;
RS.registerCommand(module, "authorize", Packages.com.google.refine.extension.gdata.AuthorizeCommand());
RS.registerCommand(module, "authorize2", Packages.com.google.refine.extension.gdata.AuthorizeCommand2());
RS.registerCommand(module, "deauthorize", Packages.com.google.refine.extension.gdata.DeAuthorizeCommand());
// Packages.com.google.refine.exporters.ExporterRegistry.registerExporter(
// "gdata-exporter", new Packages.com.google.refine.extension.gdata.GDataExporter());
// Register importer and exporter
var IM = Packages.com.google.refine.importing.ImportingManager;
IM.registerFormat("service/gdata", "GData services"); // generic format, no parser to handle it
IM.registerFormat("service/gdata/spreadsheet", "Google spreadsheets", false, "GoogleSpreadsheetParserUI",
new Packages.com.google.refine.extension.gdata.GDataImporter());
IM.registerUrlRewriter(new Packages.com.google.refine.extension.gdata.GDataUrlRewriter())
IM.registerUrlRewriter(new Packages.com.google.refine.extension.gdata.FusionTablesUrlRewriter())
//Packages.com.google.refine.exporters.ExporterRegistry.registerExporter(
//"gdata-exporter", new Packages.com.google.refine.extension.gdata.GDataExporter());
// Script files to inject into /project page
var ClientSideResourceManager = Packages.com.google.refine.ClientSideResourceManager;
ClientSideResourceManager.addPaths(
"project/scripts",
module,
[
"scripts/project-injection.js"
]
);
// Style files to inject into /project page
ClientSideResourceManager.addPaths(
"project/styles",
module,
[
"styles/project-injection.less"
]
);
// Script files to inject into /project page
var ClientSideResourceManager = Packages.com.google.refine.ClientSideResourceManager;
ClientSideResourceManager.addPaths(
"project/scripts",
module,
[
"scripts/project-injection.js"
]
);
// Style files to inject into /project page
ClientSideResourceManager.addPaths(
"project/styles",
module,
[
"styles/project-injection.less"
]
);
}
/*
* Function invoked to handle each request in a custom way.
*/
function process(path, request, response) {
// Analyze path and handle this request yourself.
if (path == "/" || path == "") {
var context = {};
// here's how to pass things into the .vt templates
context.version = version;
send(request, response, "index.vt", context);
}
// Analyze path and handle this request yourself.
if (path == "/" || path == "") {
var context = {};
// here's how to pass things into the .vt templates
context.version = version;
send(request, response, "index.vt", context);
}
}
function send(request, response, template, context) {
butterfly.sendTextFromTemplate(request, response, context, template, encoding, html);
butterfly.sendTextFromTemplate(request, response, context, template, encoding, html);
}

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,24 +29,24 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
function init() {
var libPath = new Packages.java.io.File(module.getPath(), "MOD-INF/lib/jython/").getCanonicalPath();
var libPath = new Packages.java.io.File(module.getPath(), "MOD-INF/lib/jython/").getCanonicalPath();
var S = Packages.java.lang.System;
var currentLibPath = S.getProperty("python.path");
if (currentLibPath == null) {
currentLibPath = libPath;
} else if (currentLibPath.indexOf(libPath) < 0) {
currentLibPath = currentLibPath + Packages.java.io.File.pathSeparator + libPath;
}
S.setProperty("python.path", currentLibPath);
Packages.com.google.refine.expr.MetaParser.registerLanguageParser(
"jython",
"Jython",
Packages.com.google.refine.jython.JythonEvaluable.createParser(),
"return value"
);
var S = Packages.java.lang.System;
var currentLibPath = S.getProperty("python.path");
if (currentLibPath == null) {
currentLibPath = libPath;
} else if (currentLibPath.indexOf(libPath) < 0) {
currentLibPath = currentLibPath + Packages.java.io.File.pathSeparator + libPath;
}
S.setProperty("python.path", currentLibPath);
Packages.com.google.refine.expr.MetaParser.registerLanguageParser(
"jython",
"Jython",
Packages.com.google.refine.jython.JythonEvaluable.createParser(),
"return value"
);
}

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,7 +29,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
var html = "text/html";
var encoding = "UTF-8";
@ -39,45 +39,45 @@ var ClientSideResourceManager = Packages.com.google.refine.ClientSideResourceMan
* Function invoked to initialize the extension.
*/
function init() {
// Packages.java.lang.System.err.println("Initializing sample extension");
// Packages.java.lang.System.err.println(module.getMountPoint());
// Script files to inject into /project page
ClientSideResourceManager.addPaths(
"project/scripts",
module,
[
"scripts/project-injection.js"
]
);
// Style files to inject into /project page
ClientSideResourceManager.addPaths(
"project/styles",
module,
[
"styles/project-injection.less"
]
);
// Packages.java.lang.System.err.println("Initializing sample extension");
// Packages.java.lang.System.err.println(module.getMountPoint());
// Script files to inject into /project page
ClientSideResourceManager.addPaths(
"project/scripts",
module,
[
"scripts/project-injection.js"
]
);
// Style files to inject into /project page
ClientSideResourceManager.addPaths(
"project/styles",
module,
[
"styles/project-injection.less"
]
);
}
/*
* Function invoked to handle each request in a custom way.
*/
function process(path, request, response) {
// Analyze path and handle this request yourself.
if (path == "/" || path == "") {
var context = {};
// here's how to pass things into the .vt templates
context.someList = ["Superior","Michigan","Huron","Erie","Ontario"];
context.someString = "foo";
context.someInt = Packages.com.google.refine.sampleExtension.SampleUtil.stringArrayLength(context.someList);
send(request, response, "index.vt", context);
}
// Analyze path and handle this request yourself.
if (path == "/" || path == "") {
var context = {};
// here's how to pass things into the .vt templates
context.someList = ["Superior","Michigan","Huron","Erie","Ontario"];
context.someString = "foo";
context.someInt = Packages.com.google.refine.sampleExtension.SampleUtil.stringArrayLength(context.someList);
send(request, response, "index.vt", context);
}
}
function send(request, response, template, context) {
butterfly.sendTextFromTemplate(request, response, context, template, encoding, html);
butterfly.sendTextFromTemplate(request, response, context, template, encoding, html);
}

File diff suppressed because it is too large Load Diff

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -34,141 +34,141 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
var GoogleRefineVersion;
var Refine = {
actionAreas: []
actionAreas: []
};
Refine.selectActionArea = function(id) {
$('.action-area-tab').removeClass('selected');
$('.action-area-tab-body').css('visibility', 'hidden').css('z-index', '100');
$('.action-area-tab').removeClass('selected');
$('.action-area-tab-body').css('visibility', 'hidden').css('z-index', '100');
for (var i = 0; i < Refine.actionAreas.length; i++) {
var actionArea = Refine.actionAreas[i];
if (id == actionArea.id) {
actionArea.tabElmt.addClass('selected');
actionArea.bodyElmt.css('visibility', 'visible').css('z-index', '110');;
}
for (var i = 0; i < Refine.actionAreas.length; i++) {
var actionArea = Refine.actionAreas[i];
if (id == actionArea.id) {
actionArea.tabElmt.addClass('selected');
actionArea.bodyElmt.css('visibility', 'visible').css('z-index', '110');;
}
}
};
$(function() {
var isThereNewRelease = function() {
var thisRevision = GoogleRefineVersion.revision;
var revision_pattern = /r([0-9]+)/;
if (!revision_pattern.test(thisRevision)) { // probably "trunk"
return false;
}
var latestRevision = GoogleRefineReleases.releases[0].revision;
var thisRev = parseInt(revision_pattern.exec(thisRevision)[1],10);
var latestRev = parseInt(revision_pattern.exec(GoogleRefineReleases.releases[0].revision)[1],10);
return latestRev > thisRev;
};
var isThereNewRelease = function() {
var thisRevision = GoogleRefineVersion.revision;
var showVersion = function() {
$.getJSON(
var revision_pattern = /r([0-9]+)/;
if (!revision_pattern.test(thisRevision)) { // probably "trunk"
return false;
}
var latestRevision = GoogleRefineReleases.releases[0].revision;
var thisRev = parseInt(revision_pattern.exec(thisRevision)[1],10);
var latestRev = parseInt(revision_pattern.exec(GoogleRefineReleases.releases[0].revision)[1],10);
return latestRev > thisRev;
};
var showVersion = function() {
$.getJSON(
"/command/core/get-version",
null,
function(data) {
GoogleRefineVersion = data;
GoogleRefineVersion = data;
$("#google-refine-version").text("Version " + GoogleRefineVersion.full_version);
$("#google-refine-version").text("Version " + GoogleRefineVersion.full_version);
var script = $('<script></script>')
.attr("src", "http://google-refine.googlecode.com/svn/support/releases.js")
.attr("type", "text/javascript")
.appendTo(document.body);
var script = $('<script></script>')
.attr("src", "http://google-refine.googlecode.com/svn/support/releases.js")
.attr("type", "text/javascript")
.appendTo(document.body);
var poll = function() {
if ("releases" in window) {
if (isThereNewRelease()) {
var container = $('<div id="notification-container">')
.appendTo(document.body)
var notification = $('<div id="notification">')
.text('New version! ')
.appendTo(container)
$('<a>')
.addClass('notification-action')
.attr("href", releases.homepage)
.text('Download ' + releases.releases[0].description + ' now.')
.appendTo(notification);
}
} else {
window.setTimeout(poll, 1000);
}
};
window.setTimeout(poll, 1000);
var poll = function() {
if ("releases" in window) {
if (isThereNewRelease()) {
var container = $('<div id="notification-container">')
.appendTo(document.body)
var notification = $('<div id="notification">')
.text('New version! ')
.appendTo(container)
$('<a>')
.addClass('notification-action')
.attr("href", releases.homepage)
.text('Download ' + releases.releases[0].description + ' now.')
.appendTo(notification);
}
} else {
window.setTimeout(poll, 1000);
}
};
window.setTimeout(poll, 1000);
}
);
};
);
};
var resize = function() {
var leftPanelWidth = 150;
// px
var width = $(window).width();
var height = $(window).height();
var headerHeight = $('#header').outerHeight();
var panelHeight = height - headerHeight;
var resize = function() {
var leftPanelWidth = 150;
// px
var width = $(window).width();
var height = $(window).height();
var headerHeight = $('#header').outerHeight();
var panelHeight = height - headerHeight;
$('.main-layout-panel')
.css("top", headerHeight + "px")
.css("bottom", "0px")
.css("height", panelHeight + "px")
.css("visibility", "visible");
$('.main-layout-panel')
.css("top", headerHeight + "px")
.css("bottom", "0px")
.css("height", panelHeight + "px")
.css("visibility", "visible");
$('#left-panel')
.css("left", "0px")
.css("width", leftPanelWidth + "px");
var leftPanelBodyHPaddings = 10;
// px
var leftPanelBodyVPaddings = 0;
// px
$('#left-panel-body')
.css("margin-left", leftPanelBodyHPaddings + "px")
.css("margin-top", leftPanelBodyVPaddings + "px")
.css("width", ($('#left-panel').width() - leftPanelBodyHPaddings) + "px")
.css("height", ($('#left-panel').height() - leftPanelBodyVPaddings) + "px");
$('#left-panel')
.css("left", "0px")
.css("width", leftPanelWidth + "px");
var leftPanelBodyHPaddings = 10;
// px
var leftPanelBodyVPaddings = 0;
// px
$('#left-panel-body')
.css("margin-left", leftPanelBodyHPaddings + "px")
.css("margin-top", leftPanelBodyVPaddings + "px")
.css("width", ($('#left-panel').width() - leftPanelBodyHPaddings) + "px")
.css("height", ($('#left-panel').height() - leftPanelBodyVPaddings) + "px");
$('#right-panel')
.css("left", leftPanelWidth + "px")
.css("width", (width - leftPanelWidth) + "px");
$('#right-panel')
.css("left", leftPanelWidth + "px")
.css("width", (width - leftPanelWidth) + "px");
var rightPanelBodyHPaddings = 5;
// px
var rightPanelBodyVPaddings = 5;
// px
$('#right-panel-body')
.css("margin-left", rightPanelBodyHPaddings + "px")
.css("margin-top", rightPanelBodyVPaddings + "px")
.css("width", ($('#right-panel').width() - rightPanelBodyHPaddings) + "px")
.css("height", ($('#right-panel').height() - rightPanelBodyVPaddings) + "px");
};
$(window).bind("resize", resize);
window.setTimeout(resize, 50); // for Chrome, give the window some time to layout first
var renderActionArea = function(actionArea) {
actionArea.bodyElmt = $('<div>')
.addClass('action-area-tab-body')
.appendTo('#right-panel-body');
var rightPanelBodyHPaddings = 5;
// px
var rightPanelBodyVPaddings = 5;
// px
$('#right-panel-body')
.css("margin-left", rightPanelBodyHPaddings + "px")
.css("margin-top", rightPanelBodyVPaddings + "px")
.css("width", ($('#right-panel').width() - rightPanelBodyHPaddings) + "px")
.css("height", ($('#right-panel').height() - rightPanelBodyVPaddings) + "px");
};
$(window).bind("resize", resize);
window.setTimeout(resize, 50); // for Chrome, give the window some time to layout first
actionArea.tabElmt = $('<li>')
.addClass('action-area-tab')
.text(actionArea.label)
.appendTo($('#action-area-tabs'))
.click(function() {
Refine.selectActionArea(actionArea.id);
});
var renderActionArea = function(actionArea) {
actionArea.bodyElmt = $('<div>')
.addClass('action-area-tab-body')
.appendTo('#right-panel-body');
actionArea.ui = new actionArea.uiClass(actionArea.bodyElmt);
};
actionArea.tabElmt = $('<li>')
.addClass('action-area-tab')
.text(actionArea.label)
.appendTo($('#action-area-tabs'))
.click(function() {
Refine.selectActionArea(actionArea.id);
});
for (var i = 0; i < Refine.actionAreas.length; i++) {
renderActionArea(Refine.actionAreas[i]);
}
Refine.selectActionArea('create-project');
actionArea.ui = new actionArea.uiClass(actionArea.bodyElmt);
};
showVersion();
for (var i = 0; i < Refine.actionAreas.length; i++) {
renderActionArea(Refine.actionAreas[i]);
}
Refine.selectActionArea('create-project');
showVersion();
});

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,113 +29,113 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
Refine.CreateProjectUI = function(elmt) {
var self = this;
this._elmt = elmt;
this._sourceSelectionUIs = [];
this._customPanels = [];
this._controllers = [];
$.post(
"/command/core/get-importing-configuration",
null,
function(data) {
Refine.importingConfig = data.config;
self._initializeUI();
},
"json"
);
var self = this;
this._elmt = elmt;
this._sourceSelectionUIs = [];
this._customPanels = [];
this._controllers = [];
$.post(
"/command/core/get-importing-configuration",
null,
function(data) {
Refine.importingConfig = data.config;
self._initializeUI();
},
"json"
);
};
Refine.CreateProjectUI.controllers = [];
Refine.CreateProjectUI.prototype._initializeUI = function() {
this._sourceSelectionElmt =
$(DOM.loadHTML("core", "scripts/index/create-project-ui-source-selection.html")).appendTo(this._elmt);
this._sourceSelectionElmt =
$(DOM.loadHTML("core", "scripts/index/create-project-ui-source-selection.html")).appendTo(this._elmt);
this._sourceSelectionElmts = DOM.bind(this._sourceSelectionElmt);
for (var i = 0; i < Refine.CreateProjectUI.controllers.length; i++) {
this._controllers.push(new Refine.CreateProjectUI.controllers[i](this));
}
this._sourceSelectionElmts = DOM.bind(this._sourceSelectionElmt);
for (var i = 0; i < Refine.CreateProjectUI.controllers.length; i++) {
this._controllers.push(new Refine.CreateProjectUI.controllers[i](this));
}
};
Refine.CreateProjectUI.prototype.addSourceSelectionUI = function(sourceSelectionUI) {
var self = this;
var headerContainer = $('#create-project-ui-source-selection-tabs');
var bodyContainer = $('#create-project-ui-source-selection-tab-bodies');
var self = this;
sourceSelectionUI._divBody = $('<div>')
.addClass('create-project-ui-source-selection-tab-body')
.appendTo(bodyContainer)
.hide();
var headerContainer = $('#create-project-ui-source-selection-tabs');
var bodyContainer = $('#create-project-ui-source-selection-tab-bodies');
sourceSelectionUI._divHeader = $('<div>')
.addClass('create-project-ui-source-selection-tab')
.text(sourceSelectionUI.label)
.appendTo(headerContainer)
.click(function() { self.selectImportSource(sourceSelectionUI.id); });
sourceSelectionUI._divBody = $('<div>')
.addClass('create-project-ui-source-selection-tab-body')
.appendTo(bodyContainer)
.hide();
sourceSelectionUI.ui.attachUI(sourceSelectionUI._divBody);
sourceSelectionUI._divHeader = $('<div>')
.addClass('create-project-ui-source-selection-tab')
.text(sourceSelectionUI.label)
.appendTo(headerContainer)
.click(function() { self.selectImportSource(sourceSelectionUI.id); });
this._sourceSelectionUIs.push(sourceSelectionUI);
if (this._sourceSelectionUIs.length == 1) {
self.selectImportSource(sourceSelectionUI.id);
}
sourceSelectionUI.ui.attachUI(sourceSelectionUI._divBody);
this._sourceSelectionUIs.push(sourceSelectionUI);
if (this._sourceSelectionUIs.length == 1) {
self.selectImportSource(sourceSelectionUI.id);
}
};
Refine.CreateProjectUI.prototype.selectImportSource = function(id) {
for (var i = 0; i < this._sourceSelectionUIs.length; i++) {
var sourceSelectionUI = this._sourceSelectionUIs[i];
if (sourceSelectionUI.id == id) {
$('.create-project-ui-source-selection-tab-body').hide();
$('.create-project-ui-source-selection-tab').removeClass('selected');
for (var i = 0; i < this._sourceSelectionUIs.length; i++) {
var sourceSelectionUI = this._sourceSelectionUIs[i];
if (sourceSelectionUI.id == id) {
$('.create-project-ui-source-selection-tab-body').hide();
$('.create-project-ui-source-selection-tab').removeClass('selected');
sourceSelectionUI._divBody.show();
sourceSelectionUI._divHeader.addClass('selected');
sourceSelectionUI.ui.focus();
break;
}
sourceSelectionUI._divBody.show();
sourceSelectionUI._divHeader.addClass('selected');
sourceSelectionUI.ui.focus();
break;
}
}
};
Refine.CreateProjectUI.prototype.addCustomPanel = function() {
var div = $('<div>')
.addClass('create-project-ui-panel')
.appendTo(this._elmt);
var innerDiv = $('<div>')
.addClass('relative-frame')
.appendTo(div);
this._customPanels.push(div);
return innerDiv;
var div = $('<div>')
.addClass('create-project-ui-panel')
.appendTo(this._elmt);
var innerDiv = $('<div>')
.addClass('relative-frame')
.appendTo(div);
this._customPanels.push(div);
return innerDiv;
};
Refine.CreateProjectUI.prototype.showCustomPanel = function(div) {
var parent = div.parent();
for (var i = 0; i < this._customPanels.length; i++) {
var panel = this._customPanels[i];
if (panel[0] === parent[0]) {
$('.create-project-ui-panel').css('visibility', 'hidden');
this._sourceSelectionElmt.css('visibility', 'hidden');
panel.css('visibility', 'visible');
break;
}
var parent = div.parent();
for (var i = 0; i < this._customPanels.length; i++) {
var panel = this._customPanels[i];
if (panel[0] === parent[0]) {
$('.create-project-ui-panel').css('visibility', 'hidden');
this._sourceSelectionElmt.css('visibility', 'hidden');
panel.css('visibility', 'visible');
break;
}
}
};
Refine.CreateProjectUI.prototype.showSourceSelectionPanel = function() {
$('.create-project-ui-panel').css('visibility', 'hidden');
this._sourceSelectionElmt.css('visibility', 'visible');
$('.create-project-ui-panel').css('visibility', 'hidden');
this._sourceSelectionElmt.css('visibility', 'visible');
};
Refine.actionAreas.push({

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,26 +29,26 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
Refine.DefaultImportingController = function(createProjectUI) {
this._createProjectUI = createProjectUI;
this._progressPanel = createProjectUI.addCustomPanel();
this._progressPanel.html(DOM.loadHTML("core", "scripts/index/default-importing-controller/progress-panel.html"));
this._errorPanel = createProjectUI.addCustomPanel();
this._errorPanel.html(DOM.loadHTML("core", "scripts/index/default-importing-controller/error-panel.html"));
this._fileSelectionPanel = createProjectUI.addCustomPanel();
this._parsingPanel = createProjectUI.addCustomPanel();
for (var i = 0; i < Refine.DefaultImportingController.sources.length; i++) {
var sourceSelectionUI = Refine.DefaultImportingController.sources[i];
sourceSelectionUI.ui = new sourceSelectionUI.uiClass(this);
createProjectUI.addSourceSelectionUI(sourceSelectionUI);
}
this._createProjectUI = createProjectUI;
this._progressPanel = createProjectUI.addCustomPanel();
this._progressPanel.html(DOM.loadHTML("core", "scripts/index/default-importing-controller/progress-panel.html"));
this._errorPanel = createProjectUI.addCustomPanel();
this._errorPanel.html(DOM.loadHTML("core", "scripts/index/default-importing-controller/error-panel.html"));
this._fileSelectionPanel = createProjectUI.addCustomPanel();
this._parsingPanel = createProjectUI.addCustomPanel();
for (var i = 0; i < Refine.DefaultImportingController.sources.length; i++) {
var sourceSelectionUI = Refine.DefaultImportingController.sources[i];
sourceSelectionUI.ui = new sourceSelectionUI.uiClass(this);
createProjectUI.addSourceSelectionUI(sourceSelectionUI);
}
};
Refine.CreateProjectUI.controllers.push(Refine.DefaultImportingController);
@ -56,287 +56,287 @@ Refine.DefaultImportingController.sources = [];
Refine.DefaultImportingController.parserUIs = {};
Refine.DefaultImportingController.prototype._startOver = function() {
this._disposeFileSelectionPanel();
this._disposeFileSelectionPanel();
delete this._fileSelectionPanelElmts;
delete this._parsingPanelElmts;
delete this._jobID;
delete this._job;
delete this._extensions;
delete this._format;
delete this._parserOptions;
delete this._projectName;
this._createProjectUI.showSourceSelectionPanel();
this._disposeFileSelectionPanel();
this._disposeFileSelectionPanel();
delete this._fileSelectionPanelElmts;
delete this._parsingPanelElmts;
delete this._jobID;
delete this._job;
delete this._extensions;
delete this._format;
delete this._parserOptions;
delete this._projectName;
this._createProjectUI.showSourceSelectionPanel();
};
Refine.DefaultImportingController.prototype.startImportJob = function(form, progressMessage, callback) {
var self = this;
$.post(
"/command/core/create-importing-job",
null,
function(data) {
var jobID = self._jobID = data.jobID;
var self = this;
$.post(
"/command/core/create-importing-job",
null,
function(data) {
var jobID = self._jobID = data.jobID;
form.attr("method", "post")
.attr("enctype", "multipart/form-data")
.attr("accept-charset", "UTF-8")
.attr("target", "default-importing-iframe")
.attr("action", "/command/core/importing-controller?" + $.param({
"controller": "core/default-importing-controller",
"jobID": jobID,
"subCommand": "load-raw-data"
}));
form[0].submit();
form.attr("method", "post")
.attr("enctype", "multipart/form-data")
.attr("accept-charset", "UTF-8")
.attr("target", "default-importing-iframe")
.attr("action", "/command/core/importing-controller?" + $.param({
"controller": "core/default-importing-controller",
"jobID": jobID,
"subCommand": "load-raw-data"
}));
form[0].submit();
var start = new Date();
var timerID = window.setInterval(
function() {
self._pollImportJob(
start, jobID, timerID,
function(job) {
return job.config.hasData;
},
function(jobID, job) {
self._job = job;
self._onImportJobReady();
if (callback) {
callback(jobID, job);
}
}
);
},
1000
);
self._initializeImportProgressPanel(progressMessage, function() {
// stop the iframe
$('#default-importing-iframe')[0].contentWindow.stop();
var start = new Date();
var timerID = window.setInterval(
function() {
self._pollImportJob(
start, jobID, timerID,
function(job) {
return job.config.hasData;
},
function(jobID, job) {
self._job = job;
self._onImportJobReady();
if (callback) {
callback(jobID, job);
}
}
);
},
1000
);
self._initializeImportProgressPanel(progressMessage, function() {
// stop the iframe
$('#default-importing-iframe')[0].contentWindow.stop();
// stop the timed polling
window.clearInterval(timerID);
// stop the timed polling
window.clearInterval(timerID);
// explicitly cancel the import job
$.post("/command/core/cancel-importing-job?" + $.param({ "jobID": jobID }));
self._createProjectUI.showSourceSelectionPanel();
});
},
"json"
);
// explicitly cancel the import job
$.post("/command/core/cancel-importing-job?" + $.param({ "jobID": jobID }));
self._createProjectUI.showSourceSelectionPanel();
});
},
"json"
);
};
Refine.DefaultImportingController.prototype._initializeImportProgressPanel = function(progressMessage, onCancel) {
var self = this;
this._createProjectUI.showCustomPanel(this._progressPanel);
$('#default-importing-progress-message').text(progressMessage);
$('#default-importing-progress-bar-body').css("width", "0%");
$('#default-importing-progress-message-left').text('Starting');
$('#default-importing-progress-message-center').empty();
$('#default-importing-progress-message-right').empty();
$('#default-importing-progress-timing').empty();
var self = this;
$('#default-importing-progress-cancel-button').unbind().click(onCancel);
this._createProjectUI.showCustomPanel(this._progressPanel);
$('#default-importing-progress-message').text(progressMessage);
$('#default-importing-progress-bar-body').css("width", "0%");
$('#default-importing-progress-message-left').text('Starting');
$('#default-importing-progress-message-center').empty();
$('#default-importing-progress-message-right').empty();
$('#default-importing-progress-timing').empty();
$('#default-importing-progress-cancel-button').unbind().click(onCancel);
};
Refine.DefaultImportingController.prototype._pollImportJob = function(start, jobID, timerID, checkDone, callback) {
var self = this;
$.post(
"/command/core/get-importing-job-status?" + $.param({ "jobID": jobID }),
null,
function(data) {
if (!(data)) {
self._showImportJobError("Unknown error");
window.clearInterval(timerID);
return;
} else if (data.code == "error" || !("job" in data)) {
self._showImportJobError(data.message || "Unknown error");
window.clearInterval(timerID);
return;
}
var job = data.job;
if (checkDone(job)) {
$('#default-importing-progress-message').text('Done.');
window.clearInterval(timerID);
if (callback) {
callback(jobID, job);
}
var self = this;
$.post(
"/command/core/get-importing-job-status?" + $.param({ "jobID": jobID }),
null,
function(data) {
if (!(data)) {
self._showImportJobError("Unknown error");
window.clearInterval(timerID);
return;
} else if (data.code == "error" || !("job" in data)) {
self._showImportJobError(data.message || "Unknown error");
window.clearInterval(timerID);
return;
}
var job = data.job;
if (checkDone(job)) {
$('#default-importing-progress-message').text('Done.');
window.clearInterval(timerID);
if (callback) {
callback(jobID, job);
}
} else {
var progress = job.config.progress;
if (progress.percent > 0) {
var secondsSpent = (new Date().getTime() - start.getTime()) / 1000;
var secondsRemaining = (100 / progress.percent) * secondsSpent - secondsSpent;
$('#default-importing-progress-bar-body')
.removeClass('indefinite')
.css("width", progress.percent + "%");
if (secondsRemaining > 1) {
if (secondsRemaining > 60) {
$('#default-importing-progress-timing').text(
Math.ceil(secondsRemaining / 60) + " minutes remaining");
} else {
var progress = job.config.progress;
if (progress.percent > 0) {
var secondsSpent = (new Date().getTime() - start.getTime()) / 1000;
var secondsRemaining = (100 / progress.percent) * secondsSpent - secondsSpent;
$('#default-importing-progress-bar-body')
.removeClass('indefinite')
.css("width", progress.percent + "%");
if (secondsRemaining > 1) {
if (secondsRemaining > 60) {
$('#default-importing-progress-timing').text(
Math.ceil(secondsRemaining / 60) + " minutes remaining");
} else {
$('#default-importing-progress-timing').text(
Math.ceil(secondsRemaining) + " seconds remaining");
}
} else {
$('#default-importing-progress-timing').text('almost done ...');
}
} else {
$('#default-importing-progress-bar-body').addClass('indefinite');
$('#default-importing-progress-timing').empty();
}
$('#default-importing-progress-message').text(progress.message);
$('#default-importing-progress-timing').text(
Math.ceil(secondsRemaining) + " seconds remaining");
}
},
"json"
);
} else {
$('#default-importing-progress-timing').text('almost done ...');
}
} else {
$('#default-importing-progress-bar-body').addClass('indefinite');
$('#default-importing-progress-timing').empty();
}
$('#default-importing-progress-message').text(progress.message);
}
},
"json"
);
};
Refine.DefaultImportingController.prototype._showImportJobError = function(message, stack) {
var self = this;
$('#default-importing-error-message').text(message);
$('#default-importing-error-stack').text(stack || 'No technical details.');
var self = this;
this._createProjectUI.showCustomPanel(this._errorPanel);
$('#default-importing-error-ok-button').unbind().click(function() {
self._createProjectUI.showSourceSelectionPanel();
});
$('#default-importing-error-message').text(message);
$('#default-importing-error-stack').text(stack || 'No technical details.');
this._createProjectUI.showCustomPanel(this._errorPanel);
$('#default-importing-error-ok-button').unbind().click(function() {
self._createProjectUI.showSourceSelectionPanel();
});
};
Refine.DefaultImportingController.prototype._onImportJobReady = function() {
this._prepareData();
if (this._job.config.retrievalRecord.files.length > 1) {
this._showFileSelectionPanel();
} else {
this._showParsingPanel(false);
}
this._prepareData();
if (this._job.config.retrievalRecord.files.length > 1) {
this._showFileSelectionPanel();
} else {
this._showParsingPanel(false);
}
};
Refine.DefaultImportingController.prototype._prepareData = function() {
var extensionMap = {};
var extensionList = [];
var files = this._job.config.retrievalRecord.files;
var fileSelection = this._job.config.fileSelection;
for (var i = 0; i < files.length; i++) {
var file = files[i];
file.selected = false;
var slash = file.fileName.lastIndexOf('/');
var dot = file.fileName.lastIndexOf('.');
if (dot > slash + 1) {
var extension = file.fileName.substring(dot);
if (extension in extensionMap) {
extensionMap[extension].count++;
} else {
extensionMap[extension] = { extension: extension, count: 1 };
extensionList.push(extensionMap[extension]);
}
}
var extensionMap = {};
var extensionList = [];
var files = this._job.config.retrievalRecord.files;
var fileSelection = this._job.config.fileSelection;
for (var i = 0; i < files.length; i++) {
var file = files[i];
file.selected = false;
var slash = file.fileName.lastIndexOf('/');
var dot = file.fileName.lastIndexOf('.');
if (dot > slash + 1) {
var extension = file.fileName.substring(dot);
if (extension in extensionMap) {
extensionMap[extension].count++;
} else {
extensionMap[extension] = { extension: extension, count: 1 };
extensionList.push(extensionMap[extension]);
}
}
for (var i = 0; i < fileSelection.length; i++) {
files[fileSelection[i]].selected = true;
}
extensionList.sort(function(a, b) {
return b.count - a.count;
});
this._extensions = extensionList;
}
for (var i = 0; i < fileSelection.length; i++) {
files[fileSelection[i]].selected = true;
}
extensionList.sort(function(a, b) {
return b.count - a.count;
});
this._extensions = extensionList;
};
Refine.DefaultImportingController.prototype._ensureFormatParserUIHasInitializationData = function(format, onDone) {
if (!(format in this._parserOptions)) {
var self = this;
var dismissBusy = DialogSystem.showBusy("Inspecting selected files ...");
$.post(
"/command/core/importing-controller?" + $.param({
"controller": "core/default-importing-controller",
"jobID": this._jobID,
"subCommand": "initialize-parser-ui",
"format": format
}),
null,
function(data) {
dismissBusy();
if (data.options) {
self._parserOptions[format] = data.options;
onDone();
}
},
"json"
);
} else {
onDone();
}
if (!(format in this._parserOptions)) {
var self = this;
var dismissBusy = DialogSystem.showBusy("Inspecting selected files ...");
$.post(
"/command/core/importing-controller?" + $.param({
"controller": "core/default-importing-controller",
"jobID": this._jobID,
"subCommand": "initialize-parser-ui",
"format": format
}),
null,
function(data) {
dismissBusy();
if (data.options) {
self._parserOptions[format] = data.options;
onDone();
}
},
"json"
);
} else {
onDone();
}
};
Refine.DefaultImportingController.prototype.updateFormatAndOptions = function(options, callback) {
var self = this;
$.post(
"/command/core/importing-controller?" + $.param({
"controller": "core/default-importing-controller",
"jobID": this._jobID,
"subCommand": "update-format-and-options"
}),
{
"format" : this._format,
"options" : JSON.stringify(options)
},
callback,
"json"
);
var self = this;
$.post(
"/command/core/importing-controller?" + $.param({
"controller": "core/default-importing-controller",
"jobID": this._jobID,
"subCommand": "update-format-and-options"
}),
{
"format" : this._format,
"options" : JSON.stringify(options)
},
callback,
"json"
);
};
Refine.DefaultImportingController.prototype.getPreviewData = function(callback, numRows) {
var self = this;
var result = {};
$.post(
"/command/core/get-models?" + $.param({ "importingJobID" : this._jobID }),
var self = this;
var result = {};
$.post(
"/command/core/get-models?" + $.param({ "importingJobID" : this._jobID }),
null,
function(data) {
for (var n in data) {
if (data.hasOwnProperty(n)) {
result[n] = data[n];
}
}
$.post(
"/command/core/get-rows?" + $.param({
"importingJobID" : self._jobID,
"start" : 0,
"limit" : numRows || 100 // More than we parse for preview anyway
}),
null,
function(data) {
for (var n in data) {
if (data.hasOwnProperty(n)) {
result[n] = data[n];
}
// Un-pool objects
for (var r = 0; r < data.rows.length; r++) {
var row = data.rows[r];
for (var c = 0; c < row.cells.length; c++) {
var cell = row.cells[c];
if ((cell) && ("r" in cell)) {
cell.r = data.pool.recons[cell.r];
}
}
$.post(
"/command/core/get-rows?" + $.param({
"importingJobID" : self._jobID,
"start" : 0,
"limit" : numRows || 100 // More than we parse for preview anyway
}),
null,
function(data) {
// Un-pool objects
for (var r = 0; r < data.rows.length; r++) {
var row = data.rows[r];
for (var c = 0; c < row.cells.length; c++) {
var cell = row.cells[c];
if ((cell) && ("r" in cell)) {
cell.r = data.pool.recons[cell.r];
}
}
}
result.rowModel = data;
callback(result);
},
"jsonp"
);
}
result.rowModel = data;
callback(result);
},
"json"
);
"jsonp"
);
},
"json"
);
};
Refine.DefaultImportingController.prototype._createProject = function() {
@ -347,49 +347,49 @@ Refine.DefaultImportingController.prototype._createProject = function() {
this._parsingPanelElmts.focus();
return;
}
var self = this;
var options = this._formatParserUI.getOptions();
options.projectName = projectName;
$.post(
"/command/core/importing-controller?" + $.param({
"controller": "core/default-importing-controller",
"jobID": this._jobID,
"subCommand": "create-project"
}),
{
"format" : this._format,
"options" : JSON.stringify(options)
},
function() {
var start = new Date();
var timerID = window.setInterval(
function() {
self._pollImportJob(
start,
self._jobID,
timerID,
function(job) {
return "projectID" in job.config;
},
function(jobID, job) {
document.location = "project?project=" + job.config.projectID;
}
);
},
1000
);
self._initializeImportProgressPanel("Creating project ...", function() {
// stop the timed polling
window.clearInterval(timerID);
"/command/core/importing-controller?" + $.param({
"controller": "core/default-importing-controller",
"jobID": this._jobID,
"subCommand": "create-project"
}),
{
"format" : this._format,
"options" : JSON.stringify(options)
},
function() {
var start = new Date();
var timerID = window.setInterval(
function() {
self._pollImportJob(
start,
self._jobID,
timerID,
function(job) {
return "projectID" in job.config;
},
function(jobID, job) {
document.location = "project?project=" + job.config.projectID;
}
);
},
1000
);
self._initializeImportProgressPanel("Creating project ...", function() {
// stop the timed polling
window.clearInterval(timerID);
// explicitly cancel the import job
$.post("/command/core/cancel-importing-job?" + $.param({ "jobID": jobID }));
self._createProjectUI.showSourceSelectionPanel();
});
},
"json"
// explicitly cancel the import job
$.post("/command/core/cancel-importing-job?" + $.param({ "jobID": jobID }));
self._createProjectUI.showSourceSelectionPanel();
});
},
"json"
);
}
};

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,286 +29,286 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
Refine.DefaultImportingController.prototype._showFileSelectionPanel = function() {
var self = this;
this._prepareFileSelectionPanel();
this._fileSelectionPanelElmts.nextButton.click(function() {
self._commitFileSelection();
});
this._renderFileSelectionPanel();
this._createProjectUI.showCustomPanel(this._fileSelectionPanel);
var self = this;
this._prepareFileSelectionPanel();
this._fileSelectionPanelElmts.nextButton.click(function() {
self._commitFileSelection();
});
this._renderFileSelectionPanel();
this._createProjectUI.showCustomPanel(this._fileSelectionPanel);
};
Refine.DefaultImportingController.prototype._disposeFileSelectionPanel = function() {
if (this._fileSelectionPanelResizer) {
$(window).unbind("resize", this._fileSelectionPanelResizer);
}
this._fileSelectionPanel.unbind().empty();
if (this._fileSelectionPanelResizer) {
$(window).unbind("resize", this._fileSelectionPanelResizer);
}
this._fileSelectionPanel.unbind().empty();
};
Refine.DefaultImportingController.prototype._prepareFileSelectionPanel = function() {
var self = this;
this._fileSelectionPanel.unbind().empty().html(
DOM.loadHTML("core", "scripts/index/default-importing-controller/file-selection-panel.html"));
this._fileSelectionPanelElmts = DOM.bind(this._fileSelectionPanel);
this._fileSelectionPanelElmts.startOverButton.click(function() {
self._startOver();
});
this._fileSelectionPanelResizer = function() {
var elmts = self._fileSelectionPanelElmts;
var width = self._fileSelectionPanel.width();
var height = self._fileSelectionPanel.height();
var headerHeight = elmts.wizardHeader.outerHeight(true);
var controlPanelWidth = 350;
elmts.controlPanel
.css("left", "0px")
.css("top", headerHeight + "px")
.css("width", (controlPanelWidth - DOM.getHPaddings(elmts.controlPanel)) + "px")
.css("height", (height - headerHeight - DOM.getVPaddings(elmts.controlPanel)) + "px");
elmts.filePanel
.css("left", controlPanelWidth + "px")
.css("top", headerHeight + "px")
.css("width", (width - controlPanelWidth - DOM.getHPaddings(elmts.filePanel)) + "px")
.css("height", (height - headerHeight - DOM.getVPaddings(elmts.filePanel)) + "px");
};
$(window).resize(this._fileSelectionPanelResizer);
this._fileSelectionPanelResizer();
var self = this;
this._fileSelectionPanel.unbind().empty().html(
DOM.loadHTML("core", "scripts/index/default-importing-controller/file-selection-panel.html"));
this._fileSelectionPanelElmts = DOM.bind(this._fileSelectionPanel);
this._fileSelectionPanelElmts.startOverButton.click(function() {
self._startOver();
});
this._fileSelectionPanelResizer = function() {
var elmts = self._fileSelectionPanelElmts;
var width = self._fileSelectionPanel.width();
var height = self._fileSelectionPanel.height();
var headerHeight = elmts.wizardHeader.outerHeight(true);
var controlPanelWidth = 350;
elmts.controlPanel
.css("left", "0px")
.css("top", headerHeight + "px")
.css("width", (controlPanelWidth - DOM.getHPaddings(elmts.controlPanel)) + "px")
.css("height", (height - headerHeight - DOM.getVPaddings(elmts.controlPanel)) + "px");
elmts.filePanel
.css("left", controlPanelWidth + "px")
.css("top", headerHeight + "px")
.css("width", (width - controlPanelWidth - DOM.getHPaddings(elmts.filePanel)) + "px")
.css("height", (height - headerHeight - DOM.getVPaddings(elmts.filePanel)) + "px");
};
$(window).resize(this._fileSelectionPanelResizer);
this._fileSelectionPanelResizer();
};
Refine.DefaultImportingController.prototype._renderFileSelectionPanel = function() {
this._renderFileSelectionPanelFileTable();
this._renderFileSelectionPanelControlPanel();
this._renderFileSelectionPanelFileTable();
this._renderFileSelectionPanelControlPanel();
};
Refine.DefaultImportingController.prototype._renderFileSelectionPanelFileTable = function() {
var self = this;
this._fileSelectionPanelElmts.filePanel.empty();
var fileTable = $('<table><tr><th></th><th>Name</th><th>Mime-type</th><th>Format</th><th>Size</th></tr></table>')
.appendTo(this._fileSelectionPanelElmts.filePanel)[0];
var self = this;
var files = this._job.config.retrievalRecord.files;
var renderFile = function(fileRecord, index) {
var tr = fileTable.insertRow(fileTable.rows.length);
$(tr).addClass(index % 2 == 0 ? 'even' : 'odd');
var tdSelect = $('<td>').appendTo(tr);
var checkbox = $('<input>')
.attr("type", "checkbox")
.attr("index", index)
.appendTo(tdSelect)
.click(function() {
files[index].selected = this.checked;
self._updateFileSelectionSummary();
});
if (fileRecord.selected) {
checkbox.attr("checked", "checked");
}
$('<td>').text(fileRecord.fileName).addClass("default-importing-file-selection-filename").appendTo(tr);
$('<td>').text(fileRecord.declaredMimeType || fileRecord.mimeType || "unknown").appendTo(tr);
$('<td>').text(fileRecord.format || "unknown").appendTo(tr);
$('<td>').text(fileRecord.size + " bytes").appendTo(tr);
};
for (var i = 0; i < files.length; i++) {
renderFile(files[i], i);
this._fileSelectionPanelElmts.filePanel.empty();
var fileTable = $('<table><tr><th></th><th>Name</th><th>Mime-type</th><th>Format</th><th>Size</th></tr></table>')
.appendTo(this._fileSelectionPanelElmts.filePanel)[0];
var files = this._job.config.retrievalRecord.files;
var renderFile = function(fileRecord, index) {
var tr = fileTable.insertRow(fileTable.rows.length);
$(tr).addClass(index % 2 == 0 ? 'even' : 'odd');
var tdSelect = $('<td>').appendTo(tr);
var checkbox = $('<input>')
.attr("type", "checkbox")
.attr("index", index)
.appendTo(tdSelect)
.click(function() {
files[index].selected = this.checked;
self._updateFileSelectionSummary();
});
if (fileRecord.selected) {
checkbox.attr("checked", "checked");
}
$('<td>').text(fileRecord.fileName).addClass("default-importing-file-selection-filename").appendTo(tr);
$('<td>').text(fileRecord.declaredMimeType || fileRecord.mimeType || "unknown").appendTo(tr);
$('<td>').text(fileRecord.format || "unknown").appendTo(tr);
$('<td>').text(fileRecord.size + " bytes").appendTo(tr);
};
for (var i = 0; i < files.length; i++) {
renderFile(files[i], i);
}
};
Refine.DefaultImportingController.prototype._renderFileSelectionPanelControlPanel = function() {
var self = this;
var files = this._job.config.retrievalRecord.files;
this._fileSelectionPanelElmts.extensionContainer.empty();
this._fileSelectionPanelElmts.selectAllButton.unbind().click(function(evt) {
for (var i = 0; i < files.length; i++) {
files[i].selected = true;
}
self._fileSelectionPanelElmts.filePanel.find("input").attr("checked", "checked");
self._updateFileSelectionSummary();
});
this._fileSelectionPanelElmts.unselectAllButton.unbind().click(function(evt) {
for (var i = 0; i < files.length; i++) {
files[i].selected = false;
}
self._fileSelectionPanelElmts.filePanel.find("input").removeAttr("checked");
self._updateFileSelectionSummary();
});
var table = $('<table></table>')
.appendTo(this._fileSelectionPanelElmts.extensionContainer)[0];
var renderExtension = function(extension) {
var tr = table.insertRow(table.rows.length);
$('<td>').text(extension.extension).appendTo(tr);
$('<td>').text(extension.count + (extension.count > 1 ? " files" : " file")).appendTo(tr);
$('<button>')
.text("Select")
.addClass("button")
.appendTo($('<td>').appendTo(tr))
.click(function() {
for (var i = 0; i < files.length; i++) {
var file = files[i];
if (!file.selected) {
if (file.fileName.endsWith(extension.extension)) {
file.selected = true;
self._fileSelectionPanelElmts.filePanel
.find("input[index='" + i + "']")
.attr("checked", "checked");
}
}
}
self._updateFileSelectionSummary();
});
$('<button>')
.text("Unselect")
.addClass("button")
.appendTo($('<td>').appendTo(tr))
.click(function() {
for (var i = 0; i < files.length; i++) {
var file = files[i];
if (file.selected) {
if (file.fileName.endsWith(extension.extension)) {
file.selected = false;
self._fileSelectionPanelElmts.filePanel
.find("input[index='" + i + "']")
.removeAttr("checked");
}
}
}
self._updateFileSelectionSummary();
});
};
for (var i = 0; i < this._extensions.length; i++) {
renderExtension(this._extensions[i]);
var self = this;
var files = this._job.config.retrievalRecord.files;
this._fileSelectionPanelElmts.extensionContainer.empty();
this._fileSelectionPanelElmts.selectAllButton.unbind().click(function(evt) {
for (var i = 0; i < files.length; i++) {
files[i].selected = true;
}
this._updateFileSelectionSummary();
this._fileSelectionPanelElmts.regexInput.unbind().keyup(function() {
var count = 0;
var elmts = self._fileSelectionPanelElmts.filePanel
.find(".default-importing-file-selection-filename")
.removeClass("highlighted");
try {
var regex = new RegExp(this.value);
elmts.each(function() {
if (regex.test($(this).text())) {
$(this).addClass("highlighted");
count++;
}
});
} catch (e) {
// Ignore
self._fileSelectionPanelElmts.filePanel.find("input").attr("checked", "checked");
self._updateFileSelectionSummary();
});
this._fileSelectionPanelElmts.unselectAllButton.unbind().click(function(evt) {
for (var i = 0; i < files.length; i++) {
files[i].selected = false;
}
self._fileSelectionPanelElmts.filePanel.find("input").removeAttr("checked");
self._updateFileSelectionSummary();
});
var table = $('<table></table>')
.appendTo(this._fileSelectionPanelElmts.extensionContainer)[0];
var renderExtension = function(extension) {
var tr = table.insertRow(table.rows.length);
$('<td>').text(extension.extension).appendTo(tr);
$('<td>').text(extension.count + (extension.count > 1 ? " files" : " file")).appendTo(tr);
$('<button>')
.text("Select")
.addClass("button")
.appendTo($('<td>').appendTo(tr))
.click(function() {
for (var i = 0; i < files.length; i++) {
var file = files[i];
if (!file.selected) {
if (file.fileName.endsWith(extension.extension)) {
file.selected = true;
self._fileSelectionPanelElmts.filePanel
.find("input[index='" + i + "']")
.attr("checked", "checked");
}
}
self._fileSelectionPanelElmts.regexSummary.text(count + (count == 1 ? " match" : " matches"));
}
self._updateFileSelectionSummary();
});
this._fileSelectionPanelElmts.selectRegexButton.unbind().click(function() {
self._fileSelectionPanelElmts.filePanel
.find(".default-importing-file-selection-filename")
.removeClass("highlighted");
try {
var regex = new RegExp(self._fileSelectionPanelElmts.regexInput[0].value);
for (var i = 0; i < files.length; i++) {
var file = files[i];
if (!file.selected) {
if (regex.test(file.fileName)) {
file.selected = true;
self._fileSelectionPanelElmts.filePanel
.find("input[index='" + i + "']")
.attr("checked", "checked");
}
}
}
self._updateFileSelectionSummary();
} catch (e) {
// Ignore
$('<button>')
.text("Unselect")
.addClass("button")
.appendTo($('<td>').appendTo(tr))
.click(function() {
for (var i = 0; i < files.length; i++) {
var file = files[i];
if (file.selected) {
if (file.fileName.endsWith(extension.extension)) {
file.selected = false;
self._fileSelectionPanelElmts.filePanel
.find("input[index='" + i + "']")
.removeAttr("checked");
}
}
}
self._updateFileSelectionSummary();
});
this._fileSelectionPanelElmts.unselectRegexButton.unbind().click(function() {
self._fileSelectionPanelElmts.filePanel
.find(".default-importing-file-selection-filename")
.removeClass("highlighted");
try {
var regex = new RegExp(self._fileSelectionPanelElmts.regexInput[0].value);
for (var i = 0; i < files.length; i++) {
var file = files[i];
if (file.selected) {
if (regex.test(file.fileName)) {
file.selected = false;
self._fileSelectionPanelElmts.filePanel
.find("input[index='" + i + "']")
.removeAttr("checked");
}
}
}
self._updateFileSelectionSummary();
} catch (e) {
// Ignore
};
for (var i = 0; i < this._extensions.length; i++) {
renderExtension(this._extensions[i]);
}
this._updateFileSelectionSummary();
this._fileSelectionPanelElmts.regexInput.unbind().keyup(function() {
var count = 0;
var elmts = self._fileSelectionPanelElmts.filePanel
.find(".default-importing-file-selection-filename")
.removeClass("highlighted");
try {
var regex = new RegExp(this.value);
elmts.each(function() {
if (regex.test($(this).text())) {
$(this).addClass("highlighted");
count++;
}
});
});
} catch (e) {
// Ignore
}
self._fileSelectionPanelElmts.regexSummary.text(count + (count == 1 ? " match" : " matches"));
});
this._fileSelectionPanelElmts.selectRegexButton.unbind().click(function() {
self._fileSelectionPanelElmts.filePanel
.find(".default-importing-file-selection-filename")
.removeClass("highlighted");
try {
var regex = new RegExp(self._fileSelectionPanelElmts.regexInput[0].value);
for (var i = 0; i < files.length; i++) {
var file = files[i];
if (!file.selected) {
if (regex.test(file.fileName)) {
file.selected = true;
self._fileSelectionPanelElmts.filePanel
.find("input[index='" + i + "']")
.attr("checked", "checked");
}
}
}
self._updateFileSelectionSummary();
} catch (e) {
// Ignore
}
});
this._fileSelectionPanelElmts.unselectRegexButton.unbind().click(function() {
self._fileSelectionPanelElmts.filePanel
.find(".default-importing-file-selection-filename")
.removeClass("highlighted");
try {
var regex = new RegExp(self._fileSelectionPanelElmts.regexInput[0].value);
for (var i = 0; i < files.length; i++) {
var file = files[i];
if (file.selected) {
if (regex.test(file.fileName)) {
file.selected = false;
self._fileSelectionPanelElmts.filePanel
.find("input[index='" + i + "']")
.removeAttr("checked");
}
}
}
self._updateFileSelectionSummary();
} catch (e) {
// Ignore
}
});
};
Refine.DefaultImportingController.prototype._updateFileSelectionSummary = function() {
var fileSelection = [];
var files = this._job.config.retrievalRecord.files;
for (var i = 0; i < files.length; i++) {
if (files[i].selected) {
fileSelection.push(i);
}
var fileSelection = [];
var files = this._job.config.retrievalRecord.files;
for (var i = 0; i < files.length; i++) {
if (files[i].selected) {
fileSelection.push(i);
}
this._job.config.fileSelection = fileSelection;
this._fileSelectionPanelElmts.summary.text(fileSelection.length + " of " + files.length + " files selected");
}
this._job.config.fileSelection = fileSelection;
this._fileSelectionPanelElmts.summary.text(fileSelection.length + " of " + files.length + " files selected");
};
Refine.DefaultImportingController.prototype._commitFileSelection = function() {
if (this._job.config.fileSelection.length == 0) {
alert("Please select at least one file.");
if (this._job.config.fileSelection.length == 0) {
alert("Please select at least one file.");
return;
}
var self = this;
var dismissBusy = DialogSystem.showBusy("Inspecting selected files ...");
$.post(
"/command/core/importing-controller?" + $.param({
"controller": "core/default-importing-controller",
"jobID": this._jobID,
"subCommand": "update-file-selection"
}),
{
"fileSelection" : JSON.stringify(this._job.config.fileSelection)
},
function(data) {
if (!(data)) {
self._showImportJobError("Unknown error");
window.clearInterval(timerID);
return;
}
var self = this;
var dismissBusy = DialogSystem.showBusy("Inspecting selected files ...");
$.post(
"/command/core/importing-controller?" + $.param({
"controller": "core/default-importing-controller",
"jobID": this._jobID,
"subCommand": "update-file-selection"
}),
{
"fileSelection" : JSON.stringify(this._job.config.fileSelection)
},
function(data) {
if (!(data)) {
self._showImportJobError("Unknown error");
window.clearInterval(timerID);
return;
} else if (data.code == "error" || !("job" in data)) {
self._showImportJobError(data.message || "Unknown error");
window.clearInterval(timerID);
return;
}
dismissBusy();
// Different files might be selected. We start over again.
delete this._parserOptions;
self._job = data.job;
self._showParsingPanel(true);
},
"json"
);
} else if (data.code == "error" || !("job" in data)) {
self._showImportJobError(data.message || "Unknown error");
window.clearInterval(timerID);
return;
}
dismissBusy();
// Different files might be selected. We start over again.
delete this._parserOptions;
self._job = data.job;
self._showParsingPanel(true);
},
"json"
);
};

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,158 +29,158 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
Refine.DefaultImportingController.prototype._showParsingPanel = function(hasFileSelection) {
var self = this;
if (!(this._format)) {
this._format = this._job.config.rankedFormats[0];
}
if (!(this._parserOptions)) {
this._parserOptions = {};
}
this._prepareParsingPanel();
this._parsingPanelElmts.nextButton.click(function() {
self._createProject();
var self = this;
if (!(this._format)) {
this._format = this._job.config.rankedFormats[0];
}
if (!(this._parserOptions)) {
this._parserOptions = {};
}
this._prepareParsingPanel();
this._parsingPanelElmts.nextButton.click(function() {
self._createProject();
});
if (hasFileSelection) {
this._parsingPanelElmts.previousButton.click(function() {
self._createProjectUI.showCustomPanel(self._fileSelectionPanel);
});
if (hasFileSelection) {
this._parsingPanelElmts.previousButton.click(function() {
self._createProjectUI.showCustomPanel(self._fileSelectionPanel);
});
} else {
this._parsingPanelElmts.previousButton.hide();
}
if (!(this._projectName) && this._job.config.fileSelection.length > 0) {
var index = this._job.config.fileSelection[0];
var record = this._job.config.retrievalRecord.files[index];
this._projectName = $.trim(record.fileName.replace(/\W/g, ' ').replace(/\s+/g, ' '));
}
if (this._projectName) {
this._parsingPanelElmts.projectNameInput[0].value = this._projectName;
}
this._createProjectUI.showCustomPanel(this._parsingPanel);
} else {
this._parsingPanelElmts.previousButton.hide();
}
if (!(this._projectName) && this._job.config.fileSelection.length > 0) {
var index = this._job.config.fileSelection[0];
var record = this._job.config.retrievalRecord.files[index];
this._projectName = $.trim(record.fileName.replace(/\W/g, ' ').replace(/\s+/g, ' '));
}
if (this._projectName) {
this._parsingPanelElmts.projectNameInput[0].value = this._projectName;
}
this._createProjectUI.showCustomPanel(this._parsingPanel);
};
Refine.DefaultImportingController.prototype._disposeFileSelectionPanel = function() {
this._disposeParserUI();
if (this._parsingPanelResizer) {
$(window).unbind("resize", this._parsingPanelResizer);
}
this._parsingPanel.unbind().empty();
delete this._parsingPanelElmts;
this._disposeParserUI();
if (this._parsingPanelResizer) {
$(window).unbind("resize", this._parsingPanelResizer);
}
this._parsingPanel.unbind().empty();
delete this._parsingPanelElmts;
};
Refine.DefaultImportingController.prototype._prepareParsingPanel = function() {
var self = this;
this._parsingPanel.unbind().empty().html(
DOM.loadHTML("core", "scripts/index/default-importing-controller/parsing-panel.html"));
this._parsingPanelElmts = DOM.bind(this._parsingPanel);
this._parsingPanelElmts.startOverButton.click(function() {
self._startOver();
var self = this;
this._parsingPanel.unbind().empty().html(
DOM.loadHTML("core", "scripts/index/default-importing-controller/parsing-panel.html"));
this._parsingPanelElmts = DOM.bind(this._parsingPanel);
this._parsingPanelElmts.startOverButton.click(function() {
self._startOver();
});
this._parsingPanelElmts.progressPanel.hide();
this._parsingPanelResizer = function() {console.log("here");
var elmts = self._parsingPanelElmts;
var width = self._parsingPanel.width();
var height = self._parsingPanel.height();
var headerHeight = elmts.wizardHeader.outerHeight(true);
var controlPanelHeight = 300;
elmts.dataPanel
.css("left", "0px")
.css("top", headerHeight + "px")
.css("width", (width - DOM.getHPaddings(elmts.dataPanel)) + "px")
.css("height", (height - headerHeight - controlPanelHeight - DOM.getVPaddings(elmts.dataPanel)) + "px");
elmts.progressPanel
.css("left", "0px")
.css("top", headerHeight + "px")
.css("width", (width - DOM.getHPaddings(elmts.progressPanel)) + "px")
.css("height", (height - headerHeight - controlPanelHeight - DOM.getVPaddings(elmts.progressPanel)) + "px");
elmts.controlPanel
.css("left", "0px")
.css("top", (height - controlPanelHeight) + "px")
.css("width", (width - DOM.getHPaddings(elmts.controlPanel)) + "px")
.css("height", (controlPanelHeight - DOM.getVPaddings(elmts.controlPanel)) + "px");
};
$(window).resize(this._parsingPanelResizer);
this._parsingPanelResizer();
var formats = this._job.config.rankedFormats;
var createFormatTab = function(format) {
var tab = $('<div>')
.text(Refine.importingConfig.formats[format].label)
.attr("format", format)
.addClass("default-importing-parsing-control-panel-format")
.appendTo(self._parsingPanelElmts.formatsContainer)
.click(function() {
self._selectFormat(format);
});
this._parsingPanelElmts.progressPanel.hide();
this._parsingPanelResizer = function() {console.log("here");
var elmts = self._parsingPanelElmts;
var width = self._parsingPanel.width();
var height = self._parsingPanel.height();
var headerHeight = elmts.wizardHeader.outerHeight(true);
var controlPanelHeight = 300;
elmts.dataPanel
.css("left", "0px")
.css("top", headerHeight + "px")
.css("width", (width - DOM.getHPaddings(elmts.dataPanel)) + "px")
.css("height", (height - headerHeight - controlPanelHeight - DOM.getVPaddings(elmts.dataPanel)) + "px");
elmts.progressPanel
.css("left", "0px")
.css("top", headerHeight + "px")
.css("width", (width - DOM.getHPaddings(elmts.progressPanel)) + "px")
.css("height", (height - headerHeight - controlPanelHeight - DOM.getVPaddings(elmts.progressPanel)) + "px");
elmts.controlPanel
.css("left", "0px")
.css("top", (height - controlPanelHeight) + "px")
.css("width", (width - DOM.getHPaddings(elmts.controlPanel)) + "px")
.css("height", (controlPanelHeight - DOM.getVPaddings(elmts.controlPanel)) + "px");
};
$(window).resize(this._parsingPanelResizer);
this._parsingPanelResizer();
var formats = this._job.config.rankedFormats;
var createFormatTab = function(format) {
var tab = $('<div>')
.text(Refine.importingConfig.formats[format].label)
.attr("format", format)
.addClass("default-importing-parsing-control-panel-format")
.appendTo(self._parsingPanelElmts.formatsContainer)
.click(function() {
self._selectFormat(format);
});
if (format == self._format) {
tab.addClass("selected");
}
};
for (var i = 0; i < formats.length; i++) {
createFormatTab(formats[i]);
if (format == self._format) {
tab.addClass("selected");
}
this._selectFormat(this._format);
};
for (var i = 0; i < formats.length; i++) {
createFormatTab(formats[i]);
}
this._selectFormat(this._format);
};
Refine.DefaultImportingController.prototype._disposeParserUI = function() {
if (this._formatParserUI) {
this._formatParserUI.dispose();
delete this._formatParserUI;
}
if (this._parsingPanelElmts) {
this._parsingPanelElmts.optionsContainer.unbind().empty();
this._parsingPanelElmts.progressPanel.unbind();
this._parsingPanelElmts.dataPanel.unbind().empty();
}
if (this._formatParserUI) {
this._formatParserUI.dispose();
delete this._formatParserUI;
}
if (this._parsingPanelElmts) {
this._parsingPanelElmts.optionsContainer.unbind().empty();
this._parsingPanelElmts.progressPanel.unbind();
this._parsingPanelElmts.dataPanel.unbind().empty();
}
};
Refine.DefaultImportingController.prototype._selectFormat = function(newFormat) {
if (newFormat == this._format && (this._formatParserUI)) {
// The new format is the same as the existing one.
return;
}
var uiClassName = Refine.importingConfig.formats[newFormat].uiClass;
var uiClass = Refine.DefaultImportingController.parserUIs[uiClassName];
if (uiClass) {
var self = this;
this._ensureFormatParserUIHasInitializationData(newFormat, function() {
self._disposeParserUI();
self._parsingPanelElmts.formatsContainer
.find(".default-importing-parsing-control-panel-format")
.removeClass("selected")
.each(function() {
if (this.getAttribute("format") == newFormat) {
$(this).addClass("selected");
}
});
self._format = newFormat;
self._formatParserUI = new uiClass(
self,
self._jobID,
self._job,
self._format,
self._parserOptions[newFormat],
self._parsingPanelElmts.dataPanel,
self._parsingPanelElmts.progressPanel,
self._parsingPanelElmts.optionsContainer
);
});
}
if (newFormat == this._format && (this._formatParserUI)) {
// The new format is the same as the existing one.
return;
}
var uiClassName = Refine.importingConfig.formats[newFormat].uiClass;
var uiClass = Refine.DefaultImportingController.parserUIs[uiClassName];
if (uiClass) {
var self = this;
this._ensureFormatParserUIHasInitializationData(newFormat, function() {
self._disposeParserUI();
self._parsingPanelElmts.formatsContainer
.find(".default-importing-parsing-control-panel-format")
.removeClass("selected")
.each(function() {
if (this.getAttribute("format") == newFormat) {
$(this).addClass("selected");
}
});
self._format = newFormat;
self._formatParserUI = new uiClass(
self,
self._jobID,
self._job,
self._format,
self._parserOptions[newFormat],
self._parsingPanelElmts.dataPanel,
self._parsingPanelElmts.progressPanel,
self._parsingPanelElmts.optionsContainer
);
});
}
};

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,90 +29,90 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
function ThisComputerImportingSourceUI(controller) {
this._controller = controller;
this._controller = controller;
}
Refine.DefaultImportingController.sources.push({
"label": "This Computer",
"id": "upload",
"uiClass": ThisComputerImportingSourceUI
"label": "This Computer",
"id": "upload",
"uiClass": ThisComputerImportingSourceUI
});
ThisComputerImportingSourceUI.prototype.attachUI = function(bodyDiv) {
var self = this;
bodyDiv.html(DOM.loadHTML("core", "scripts/index/default-importing-sources/import-from-computer-form.html"));
var self = this;
this._elmts = DOM.bind(bodyDiv);
this._elmts.nextButton.click(function(evt) {
if (self._elmts.fileInput[0].files.length === 0) {
window.alert("You must specify a data file to import.");
} else {
self._controller.startImportJob(self._elmts.form, "Uploading data ...");
}
});
bodyDiv.html(DOM.loadHTML("core", "scripts/index/default-importing-sources/import-from-computer-form.html"));
this._elmts = DOM.bind(bodyDiv);
this._elmts.nextButton.click(function(evt) {
if (self._elmts.fileInput[0].files.length === 0) {
window.alert("You must specify a data file to import.");
} else {
self._controller.startImportJob(self._elmts.form, "Uploading data ...");
}
});
};
ThisComputerImportingSourceUI.prototype.focus = function() {
};
function UrlImportingSourceUI(controller) {
this._controller = controller;
this._controller = controller;
}
Refine.DefaultImportingController.sources.push({
"label": "Web Addresses (URLs)",
"id": "download",
"uiClass": UrlImportingSourceUI
"label": "Web Addresses (URLs)",
"id": "download",
"uiClass": UrlImportingSourceUI
});
UrlImportingSourceUI.prototype.attachUI = function(bodyDiv) {
var self = this;
bodyDiv.html(DOM.loadHTML("core", "scripts/index/default-importing-sources/import-from-web-form.html"));
var self = this;
this._elmts = DOM.bind(bodyDiv);
this._elmts.nextButton.click(function(evt) {
if ($.trim(self._elmts.urlInput[0].value.length) === 0) {
window.alert("You must specify a web address (URL) to import.");
} else {
self._controller.startImportJob(self._elmts.form, "Downloading data ...");
}
});
this._elmts.addButton.click(function(evt) {
self._elmts.buttons.before(self._elmts.urlRow.clone());
});
bodyDiv.html(DOM.loadHTML("core", "scripts/index/default-importing-sources/import-from-web-form.html"));
this._elmts = DOM.bind(bodyDiv);
this._elmts.nextButton.click(function(evt) {
if ($.trim(self._elmts.urlInput[0].value.length) === 0) {
window.alert("You must specify a web address (URL) to import.");
} else {
self._controller.startImportJob(self._elmts.form, "Downloading data ...");
}
});
this._elmts.addButton.click(function(evt) {
self._elmts.buttons.before(self._elmts.urlRow.clone());
});
};
UrlImportingSourceUI.prototype.focus = function() {
this._elmts.urlInput.focus();
this._elmts.urlInput.focus();
};
function ClipboardImportingSourceUI(controller) {
this._controller = controller;
this._controller = controller;
}
Refine.DefaultImportingController.sources.push({
"label": "Clipboard",
"id": "clipboard",
"uiClass": ClipboardImportingSourceUI
"label": "Clipboard",
"id": "clipboard",
"uiClass": ClipboardImportingSourceUI
});
ClipboardImportingSourceUI.prototype.attachUI = function(bodyDiv) {
var self = this;
bodyDiv.html(DOM.loadHTML("core", "scripts/index/default-importing-sources/import-from-clipboard-form.html"));
var self = this;
this._elmts = DOM.bind(bodyDiv);
this._elmts.nextButton.click(function(evt) {
if ($.trim(self._elmts.textInput[0].value).length === 0) {
window.alert("You must paste some data to import.");
} else {
self._controller.startImportJob(self._elmts.form, "Uploading pasted data ...");
}
});
bodyDiv.html(DOM.loadHTML("core", "scripts/index/default-importing-sources/import-from-clipboard-form.html"));
this._elmts = DOM.bind(bodyDiv);
this._elmts.nextButton.click(function(evt) {
if ($.trim(self._elmts.textInput[0].value).length === 0) {
window.alert("You must paste some data to import.");
} else {
self._controller.startImportJob(self._elmts.form, "Uploading pasted data ...");
}
});
};
ClipboardImportingSourceUI.prototype.focus = function() {
this._elmts.textInput.focus();
this._elmts.textInput.focus();
};

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,242 +29,242 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
Refine.OpenProjectUI = function(elmt) {
var self = this;
var self = this;
elmt.html(DOM.loadHTML("core", "scripts/index/open-project-ui.html"));
elmt.html(DOM.loadHTML("core", "scripts/index/open-project-ui.html"));
this._elmt = elmt;
this._elmts = DOM.bind(elmt);
this._elmt = elmt;
this._elmts = DOM.bind(elmt);
var resize = function() {
var height = elmt.height();
var width = elmt.width();
var controlsHeight = self._elmts.workspaceControls.outerHeight();
self._elmts.projectsContainer
.css("height", (height - controlsHeight - DOM.getVPaddings(self._elmts.projectsContainer)) + "px");
self._elmts.workspaceControls
.css("bottom", "0px")
.css("width", (width - DOM.getHPaddings(self._elmts.workspaceControls)) + "px")
};
$(window).resize(resize);
window.setTimeout(resize, 100);
var resize = function() {
var height = elmt.height();
var width = elmt.width();
var controlsHeight = self._elmts.workspaceControls.outerHeight();
self._elmts.projectsContainer
.css("height", (height - controlsHeight - DOM.getVPaddings(self._elmts.projectsContainer)) + "px");
self._elmts.workspaceControls
.css("bottom", "0px")
.css("width", (width - DOM.getHPaddings(self._elmts.workspaceControls)) + "px")
};
$(window).resize(resize);
window.setTimeout(resize, 100);
$("#project-file-input").change(function() {
if ($("#project-name-input")[0].value.length == 0) {
var fileName = this.files[0].fileName;
if (fileName) {
$("#project-name-input")[0].value = fileName.replace(/\.\w+/, "").replace(/[_-]/g, " ");
}
$("#project-name-input").focus().select();
}
}).keypress(function(evt) {
if (evt.keyCode == 13) {
return self._onClickUploadFileButton(evt);
$("#project-file-input").change(function() {
if ($("#project-name-input")[0].value.length == 0) {
var fileName = this.files[0].fileName;
if (fileName) {
$("#project-name-input")[0].value = fileName.replace(/\.\w+/, "").replace(/[_-]/g, " ");
}
$("#project-name-input").focus().select();
}
}).keypress(function(evt) {
if (evt.keyCode == 13) {
return self._onClickUploadFileButton(evt);
}
});
$("#upload-file-button").click(function(evt) {
return self._onClickUploadFileButton(evt)
});
$('#projects-workspace-open').click(function() {
$.ajax({
type: "POST",
url: "/command/core/open-workspace-dir",
dataType: "json",
success: function (data) {
if (data.code != "ok" && "message" in data) {
alert(data.message);
}
}
});
});
$("#upload-file-button").click(function(evt) {
return self._onClickUploadFileButton(evt)
});
$('#projects-workspace-open').click(function() {
$.ajax({
type: "POST",
url: "/command/core/open-workspace-dir",
dataType: "json",
success: function (data) {
if (data.code != "ok" && "message" in data) {
alert(data.message);
}
}
});
});
this._fetchProjects();
this._fetchProjects();
};
Refine.OpenProjectUI.prototype._fetchProjects = function() {
var self = this;
$.getJSON(
"/command/core/get-all-project-metadata",
null,
function(data) {
self._renderProjects(data);
},
"json"
);
var self = this;
$.getJSON(
"/command/core/get-all-project-metadata",
null,
function(data) {
self._renderProjects(data);
},
"json"
);
};
Refine.OpenProjectUI.prototype._renderProjects = function(data) {
var self = this;
var projects = [];
for (var n in data.projects) {
if (data.projects.hasOwnProperty(n)) {
var project = data.projects[n];
project.id = n;
project.date = Date.parseExact(project.modified, "yyyy-MM-ddTHH:mm:ssZ");
projects.push(project);
}
var self = this;
var projects = [];
for (var n in data.projects) {
if (data.projects.hasOwnProperty(n)) {
var project = data.projects[n];
project.id = n;
project.date = Date.parseExact(project.modified, "yyyy-MM-ddTHH:mm:ssZ");
projects.push(project);
}
projects.sort(function(a, b) { return b.date.getTime() - a.date.getTime(); });
}
projects.sort(function(a, b) { return b.date.getTime() - a.date.getTime(); });
var container = $("#projects-container").empty();
if (!projects.length) {
$("#no-project-message").clone().show().appendTo(container);
} else {
Refine.selectActionArea('open-project');
var table = $(
'<table class="list-table"><tr>' +
'<th>Name</th>' +
'<th></th>' +
'<th></th>' +
'<th align="right">Last&nbsp;modified</th>' +
'</tr></table>'
).appendTo(container)[0];
var container = $("#projects-container").empty();
if (!projects.length) {
$("#no-project-message").clone().show().appendTo(container);
} else {
Refine.selectActionArea('open-project');
var formatDate = function(d) {
var d = new Date(d);
var last_year = Date.today().add({ years: -1 });
var last_month = Date.today().add({ months: -1 });
var last_week = Date.today().add({ days: -7 });
var today = Date.today();
var tomorrow = Date.today().add({ days: 1 });
var table = $(
'<table class="list-table"><tr>' +
'<th>Name</th>' +
'<th></th>' +
'<th></th>' +
'<th align="right">Last&nbsp;modified</th>' +
'</tr></table>'
).appendTo(container)[0];
if (d.between(today, tomorrow)) {
return "today " + d.toString("h:mm tt");
} else if (d.between(last_week, today)) {
var diff = Math.floor(today.getDayOfYear() - d.getDayOfYear());
return (diff <= 1) ? ("yesterday " + d.toString("h:mm tt")) : (diff + " days ago");
} else if (d.between(last_month, today)) {
var diff = Math.floor((today.getDayOfYear() - d.getDayOfYear()) / 7);
return (diff == 1) ? "a week ago" : diff.toFixed(0) + " weeks ago" ;
} else if (d.between(last_year, today)) {
var diff = Math.floor(today.getMonth() - d.getMonth());
return (diff == 1) ? "a month ago" : diff + " months ago";
var formatDate = function(d) {
var d = new Date(d);
var last_year = Date.today().add({ years: -1 });
var last_month = Date.today().add({ months: -1 });
var last_week = Date.today().add({ days: -7 });
var today = Date.today();
var tomorrow = Date.today().add({ days: 1 });
if (d.between(today, tomorrow)) {
return "today " + d.toString("h:mm tt");
} else if (d.between(last_week, today)) {
var diff = Math.floor(today.getDayOfYear() - d.getDayOfYear());
return (diff <= 1) ? ("yesterday " + d.toString("h:mm tt")) : (diff + " days ago");
} else if (d.between(last_month, today)) {
var diff = Math.floor((today.getDayOfYear() - d.getDayOfYear()) / 7);
return (diff == 1) ? "a week ago" : diff.toFixed(0) + " weeks ago" ;
} else if (d.between(last_year, today)) {
var diff = Math.floor(today.getMonth() - d.getMonth());
return (diff == 1) ? "a month ago" : diff + " months ago";
} else {
var diff = Math.floor(today.getYear() - d.getYear());
return (diff == 1) ? "a year ago" : diff + " years ago";
}
};
var renderProject = function(project) {
var tr = table.insertRow(table.rows.length);
tr.className = "project";
var nameLink = $('<a></a>')
.addClass("list-table-itemname")
.text(project.name)
.attr("href", "/project?project=" + project.id)
.appendTo(tr.insertCell(tr.cells.length));
var renameLink = $('<a></a>')
.text("rename")
.addClass("secondary")
.attr("href", "javascript:{}")
.css("visibility", "hidden")
.click(function() {
var name = window.prompt("New project name:", project.name);
if (name == null) {
return;
}
name = $.trim(name);
if (project.name == name || name.length == 0) {
return;
}
$.ajax({
type: "POST",
url: "/command/core/rename-project",
data: { "project" : project.id, "name" : name },
dataType: "json",
success: function (data) {
if (data && typeof data.code != 'undefined' && data.code == "ok") {
nameLink.text(name);
} else {
var diff = Math.floor(today.getYear() - d.getYear());
return (diff == 1) ? "a year ago" : diff + " years ago";
alert("Failed to rename project: " + data.message)
}
};
var renderProject = function(project) {
var tr = table.insertRow(table.rows.length);
tr.className = "project";
}
});
}).appendTo(tr.insertCell(tr.cells.length));
var nameLink = $('<a></a>')
.addClass("list-table-itemname")
.text(project.name)
.attr("href", "/project?project=" + project.id)
.appendTo(tr.insertCell(tr.cells.length));
var renameLink = $('<a></a>')
.text("rename")
.addClass("secondary")
.attr("href", "javascript:{}")
.css("visibility", "hidden")
.click(function() {
var name = window.prompt("New project name:", project.name);
if (name == null) {
return;
}
name = $.trim(name);
if (project.name == name || name.length == 0) {
return;
}
$.ajax({
type: "POST",
url: "/command/core/rename-project",
data: { "project" : project.id, "name" : name },
dataType: "json",
success: function (data) {
if (data && typeof data.code != 'undefined' && data.code == "ok") {
nameLink.text(name);
} else {
alert("Failed to rename project: " + data.message)
}
}
});
}).appendTo(tr.insertCell(tr.cells.length));
var deleteLink = $('<a></a>')
.addClass("delete-project")
.attr("title","Delete this project")
.attr("href","")
.css("visibility", "hidden")
.html("<img src='/images/close.png' />")
.click(function() {
if (window.confirm("Are you sure you want to delete project \"" + project.name + "\"?")) {
$.ajax({
type: "POST",
url: "/command/core/delete-project",
data: { "project" : project.id },
dataType: "json",
success: function (data) {
if (data && typeof data.code != 'undefined' && data.code == "ok") {
self._fetchProjects();
}
}
});
}
return false;
}).appendTo(tr.insertCell(tr.cells.length));
$('<div></div>')
.html(formatDate(project.date))
.addClass("last-modified")
.attr("title", project.date.toString())
.appendTo(tr.insertCell(tr.cells.length));
$(tr).mouseenter(function() {
renameLink.css("visibility", "visible");
deleteLink.css("visibility", "visible");
}).mouseleave(function() {
renameLink.css("visibility", "hidden");
deleteLink.css("visibility", "hidden");
});
};
for (var i = 0; i < projects.length; i++) {
renderProject(projects[i]);
var deleteLink = $('<a></a>')
.addClass("delete-project")
.attr("title","Delete this project")
.attr("href","")
.css("visibility", "hidden")
.html("<img src='/images/close.png' />")
.click(function() {
if (window.confirm("Are you sure you want to delete project \"" + project.name + "\"?")) {
$.ajax({
type: "POST",
url: "/command/core/delete-project",
data: { "project" : project.id },
dataType: "json",
success: function (data) {
if (data && typeof data.code != 'undefined' && data.code == "ok") {
self._fetchProjects();
}
}
});
}
return false;
}).appendTo(tr.insertCell(tr.cells.length));
$('<div></div>')
.html(formatDate(project.date))
.addClass("last-modified")
.attr("title", project.date.toString())
.appendTo(tr.insertCell(tr.cells.length));
$(tr).mouseenter(function() {
renameLink.css("visibility", "visible");
deleteLink.css("visibility", "visible");
}).mouseleave(function() {
renameLink.css("visibility", "hidden");
deleteLink.css("visibility", "hidden");
});
};
for (var i = 0; i < projects.length; i++) {
renderProject(projects[i]);
}
}
};
Refine.OpenProjectUI.prototype._onClickUploadFileButton = function(evt) {
var projectName = $("#project-name-input")[0].value;
var dataURL = $.trim($("#project-url-input")[0].value);
if (! $.trim(projectName).length) {
window.alert("You must specify a project name.");
var projectName = $("#project-name-input")[0].value;
var dataURL = $.trim($("#project-url-input")[0].value);
if (! $.trim(projectName).length) {
window.alert("You must specify a project name.");
} else if ($("#project-file-input")[0].files.length === 0 && ! dataURL.length) {
window.alert("You must specify a data file to upload or a URL to retrieve.");
} else if ($("#project-file-input")[0].files.length === 0 && ! dataURL.length) {
window.alert("You must specify a data file to upload or a URL to retrieve.");
} else {
$("#file-upload-form").attr("action",
"/command/core/create-project-from-upload?" + [
"url=" + escape(dataURL),
"split-into-columns=" + $("#split-into-columns-input")[0].checked,
"separator=" + $("#separator-input")[0].value,
"ignore=" + $("#ignore-input")[0].value,
"header-lines=" + $("#header-lines-input")[0].value,
"skip=" + $("#skip-input")[0].value,
"limit=" + $("#limit-input")[0].value,
"guess-value-type=" + $("#guess-value-type-input")[0].checked,
"ignore-quotes=" + $("#ignore-quotes-input")[0].checked
].join("&"));
} else {
$("#file-upload-form").attr("action",
"/command/core/create-project-from-upload?" + [
"url=" + escape(dataURL),
"split-into-columns=" + $("#split-into-columns-input")[0].checked,
"separator=" + $("#separator-input")[0].value,
"ignore=" + $("#ignore-input")[0].value,
"header-lines=" + $("#header-lines-input")[0].value,
"skip=" + $("#skip-input")[0].value,
"limit=" + $("#limit-input")[0].value,
"guess-value-type=" + $("#guess-value-type-input")[0].checked,
"ignore-quotes=" + $("#ignore-quotes-input")[0].checked
].join("&"));
return true;
}
return true;
}
evt.preventDefault();
return false;
evt.preventDefault();
return false;
};
Refine.actionAreas.push({

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,31 +29,31 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
Refine.ExcelParserUI = function(controller, jobID, job, format, config,
dataContainerElmt, progressContainerElmt, optionContainerElmt) {
this._controller = controller;
this._jobID = jobID;
this._job = job;
this._format = format;
this._config = config;
this._dataContainer = dataContainerElmt;
this._progressContainer = progressContainerElmt;
this._optionContainer = optionContainerElmt;
this._timerID = null;
this._initialize();
this._updatePreview();
this._controller = controller;
this._jobID = jobID;
this._job = job;
this._format = format;
this._config = config;
this._dataContainer = dataContainerElmt;
this._progressContainer = progressContainerElmt;
this._optionContainer = optionContainerElmt;
this._timerID = null;
this._initialize();
this._updatePreview();
};
Refine.DefaultImportingController.parserUIs["ExcelParserUI"] = Refine.ExcelParserUI;
Refine.ExcelParserUI.prototype.dispose = function() {
if (this._timerID != null) {
window.clearTimeout(this._timerID);
this._timerID = null;
}
if (this._timerID != null) {
window.clearTimeout(this._timerID);
this._timerID = null;
}
};
Refine.ExcelParserUI.prototype.confirmReadyToCreateProject = function() {
@ -61,138 +61,138 @@ Refine.ExcelParserUI.prototype.confirmReadyToCreateProject = function() {
};
Refine.ExcelParserUI.prototype.getOptions = function() {
var options = {
xmlBased: this._config.xmlBased,
sheets: []
};
var parseIntDefault = function(s, def) {
try {
var n = parseInt(s);
if (!isNaN(n)) {
return n;
}
} catch (e) {
// Ignore
}
return def;
};
this._optionContainerElmts.sheetRecordContainer.find('input').each(function() {
if (this.checked) {
options.sheets.push(parseInt(this.getAttribute('index')));
var options = {
xmlBased: this._config.xmlBased,
sheets: []
};
var parseIntDefault = function(s, def) {
try {
var n = parseInt(s);
if (!isNaN(n)) {
return n;
}
});
if (this._optionContainerElmts.ignoreCheckbox[0].checked) {
options.ignoreLines = parseIntDefault(this._optionContainerElmts.ignoreInput[0].value, -1);
} else {
options.ignoreLines = -1;
} catch (e) {
// Ignore
}
if (this._optionContainerElmts.headerLinesCheckbox[0].checked) {
options.headerLines = parseIntDefault(this._optionContainerElmts.headerLinesInput[0].value, 0);
} else {
options.headerLines = 0;
return def;
};
this._optionContainerElmts.sheetRecordContainer.find('input').each(function() {
if (this.checked) {
options.sheets.push(parseInt(this.getAttribute('index')));
}
if (this._optionContainerElmts.skipCheckbox[0].checked) {
options.skipDataLines = parseIntDefault(this._optionContainerElmts.skipInput[0].value, 0);
} else {
options.skipDataLines = 0;
}
if (this._optionContainerElmts.limitCheckbox[0].checked) {
options.limit = parseIntDefault(this._optionContainerElmts.limitInput[0].value, -1);
} else {
options.limit = -1;
}
options.storeBlankRows = this._optionContainerElmts.storeBlankRowsCheckbox[0].checked;
options.storeBlankCellsAsNulls = this._optionContainerElmts.storeBlankCellsAsNullsCheckbox[0].checked;
options.includeFileSources = this._optionContainerElmts.includeFileSourcesCheckbox[0].checked;
return options;
});
if (this._optionContainerElmts.ignoreCheckbox[0].checked) {
options.ignoreLines = parseIntDefault(this._optionContainerElmts.ignoreInput[0].value, -1);
} else {
options.ignoreLines = -1;
}
if (this._optionContainerElmts.headerLinesCheckbox[0].checked) {
options.headerLines = parseIntDefault(this._optionContainerElmts.headerLinesInput[0].value, 0);
} else {
options.headerLines = 0;
}
if (this._optionContainerElmts.skipCheckbox[0].checked) {
options.skipDataLines = parseIntDefault(this._optionContainerElmts.skipInput[0].value, 0);
} else {
options.skipDataLines = 0;
}
if (this._optionContainerElmts.limitCheckbox[0].checked) {
options.limit = parseIntDefault(this._optionContainerElmts.limitInput[0].value, -1);
} else {
options.limit = -1;
}
options.storeBlankRows = this._optionContainerElmts.storeBlankRowsCheckbox[0].checked;
options.storeBlankCellsAsNulls = this._optionContainerElmts.storeBlankCellsAsNullsCheckbox[0].checked;
options.includeFileSources = this._optionContainerElmts.includeFileSourcesCheckbox[0].checked;
return options;
};
Refine.ExcelParserUI.prototype._initialize = function() {
var self = this;
this._optionContainer.unbind().empty().html(
DOM.loadHTML("core", "scripts/index/parser-interfaces/excel-parser-ui.html"));
this._optionContainerElmts = DOM.bind(this._optionContainer);
this._optionContainerElmts.previewButton.click(function() { self._updatePreview(); });
var sheetTable = this._optionContainerElmts.sheetRecordContainer[0];
$.each(this._config.sheetRecords, function(i, v) {
var tr = sheetTable.insertRow(sheetTable.rows.length);
var td0 = $(tr.insertCell(0)).attr('width', '1%');
var checkbox = $('<input>')
.attr('type', 'checkbox')
.attr('index', i)
.appendTo(td0);
if (this.selected) {
checkbox.attr('checked', 'true');
}
$(tr.insertCell(1)).text(this.name);
$(tr.insertCell(2)).text(this.rows + ' rows');
});
if (this._config.ignoreLines > 0) {
this._optionContainerElmts.ignoreCheckbox.attr("checked", "checked");
this._optionContainerElmts.ignoreInput[0].value = this._config.ignoreLines.toString();
var self = this;
this._optionContainer.unbind().empty().html(
DOM.loadHTML("core", "scripts/index/parser-interfaces/excel-parser-ui.html"));
this._optionContainerElmts = DOM.bind(this._optionContainer);
this._optionContainerElmts.previewButton.click(function() { self._updatePreview(); });
var sheetTable = this._optionContainerElmts.sheetRecordContainer[0];
$.each(this._config.sheetRecords, function(i, v) {
var tr = sheetTable.insertRow(sheetTable.rows.length);
var td0 = $(tr.insertCell(0)).attr('width', '1%');
var checkbox = $('<input>')
.attr('type', 'checkbox')
.attr('index', i)
.appendTo(td0);
if (this.selected) {
checkbox.attr('checked', 'true');
}
if (this._config.headerLines > 0) {
this._optionContainerElmts.headerLinesCheckbox.attr("checked", "checked");
this._optionContainerElmts.headerLinesInput[0].value = this._config.headerLines.toString();
}
if (this._config.limit > 0) {
this._optionContainerElmts.limitCheckbox.attr("checked", "checked");
this._optionContainerElmts.limitInput[0].value = this._config.limit.toString();
}
if (this._config.skipDataLines > 0) {
this._optionContainerElmts.skipCheckbox.attr("checked", "checked");
this._optionContainerElmts.skipInput.value[0].value = this._config.skipDataLines.toString();
}
if (this._config.storeBlankRows) {
this._optionContainerElmts.storeBlankRowsCheckbox.attr("checked", "checked");
}
if (this._config.storeBlankCellsAsNulls) {
this._optionContainerElmts.storeBlankCellsAsNullsCheckbox.attr("checked", "checked");
}
if (this._config.includeFileSources) {
this._optionContainerElmts.includeFileSourcesCheckbox.attr("checked", "checked");
}
var onChange = function() {
self._scheduleUpdatePreview();
};
this._optionContainer.find("input").bind("change", onChange);
this._optionContainer.find("select").bind("change", onChange);
$(tr.insertCell(1)).text(this.name);
$(tr.insertCell(2)).text(this.rows + ' rows');
});
if (this._config.ignoreLines > 0) {
this._optionContainerElmts.ignoreCheckbox.attr("checked", "checked");
this._optionContainerElmts.ignoreInput[0].value = this._config.ignoreLines.toString();
}
if (this._config.headerLines > 0) {
this._optionContainerElmts.headerLinesCheckbox.attr("checked", "checked");
this._optionContainerElmts.headerLinesInput[0].value = this._config.headerLines.toString();
}
if (this._config.limit > 0) {
this._optionContainerElmts.limitCheckbox.attr("checked", "checked");
this._optionContainerElmts.limitInput[0].value = this._config.limit.toString();
}
if (this._config.skipDataLines > 0) {
this._optionContainerElmts.skipCheckbox.attr("checked", "checked");
this._optionContainerElmts.skipInput.value[0].value = this._config.skipDataLines.toString();
}
if (this._config.storeBlankRows) {
this._optionContainerElmts.storeBlankRowsCheckbox.attr("checked", "checked");
}
if (this._config.storeBlankCellsAsNulls) {
this._optionContainerElmts.storeBlankCellsAsNullsCheckbox.attr("checked", "checked");
}
if (this._config.includeFileSources) {
this._optionContainerElmts.includeFileSourcesCheckbox.attr("checked", "checked");
}
var onChange = function() {
self._scheduleUpdatePreview();
};
this._optionContainer.find("input").bind("change", onChange);
this._optionContainer.find("select").bind("change", onChange);
};
Refine.ExcelParserUI.prototype._scheduleUpdatePreview = function() {
if (this._timerID != null) {
window.clearTimeout(this._timerID);
this._timerID = null;
}
var self = this;
this._timerID = window.setTimeout(function() {
self._timerID = null;
self._updatePreview();
}, 500); // 0.5 second
if (this._timerID != null) {
window.clearTimeout(this._timerID);
this._timerID = null;
}
var self = this;
this._timerID = window.setTimeout(function() {
self._timerID = null;
self._updatePreview();
}, 500); // 0.5 second
};
Refine.ExcelParserUI.prototype._updatePreview = function() {
var self = this;
this._progressContainer.show();
this._controller.updateFormatAndOptions(this.getOptions(), function(result) {
if (result.status == "ok") {
self._controller.getPreviewData(function(projectData) {
self._progressContainer.hide();
new Refine.PreviewTable(projectData, self._dataContainer.unbind().empty());
});
}
});
var self = this;
this._progressContainer.show();
this._controller.updateFormatAndOptions(this.getOptions(), function(result) {
if (result.status == "ok") {
self._controller.getPreviewData(function(projectData) {
self._progressContainer.hide();
new Refine.PreviewTable(projectData, self._dataContainer.unbind().empty());
});
}
});
};

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,44 +29,44 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
Refine.FixedWidthParserUI = function(controller, jobID, job, format, config,
dataContainerElmt, progressContainerElmt, optionContainerElmt) {
this._controller = controller;
this._jobID = jobID;
this._job = job;
this._format = format;
this._config = config;
this._dataContainer = dataContainerElmt;
this._progressContainer = progressContainerElmt;
this._optionContainer = optionContainerElmt;
this._timerID = null;
this._initialize();
this.updatePreview();
this._controller = controller;
this._jobID = jobID;
this._job = job;
this._format = format;
this._config = config;
this._dataContainer = dataContainerElmt;
this._progressContainer = progressContainerElmt;
this._optionContainer = optionContainerElmt;
this._timerID = null;
this._initialize();
this.updatePreview();
};
Refine.DefaultImportingController.parserUIs["FixedWidthParserUI"] = Refine.FixedWidthParserUI;
Refine.FixedWidthParserUI.encodeSeparator = function(s) {
return s.replace("\\", "\\\\")
.replace("\n", "\\n")
.replace("\t", "\\t");
return s.replace("\\", "\\\\")
.replace("\n", "\\n")
.replace("\t", "\\t");
};
Refine.FixedWidthParserUI.decodeSeparator = function(s) {
return s.replace("\\n", "\n")
.replace("\\t", "\t")
.replace("\\\\", "\\");
return s.replace("\\n", "\n")
.replace("\\t", "\t")
.replace("\\\\", "\\");
};
Refine.FixedWidthParserUI.prototype.dispose = function() {
if (this._timerID != null) {
window.clearTimeout(this._timerID);
this._timerID = null;
}
if (this._timerID != null) {
window.clearTimeout(this._timerID);
this._timerID = null;
}
};
Refine.FixedWidthParserUI.prototype.confirmReadyToCreateProject = function() {
@ -74,398 +74,398 @@ Refine.FixedWidthParserUI.prototype.confirmReadyToCreateProject = function() {
};
Refine.FixedWidthParserUI.prototype.getOptions = function() {
var options = {
columnWidths: [].concat(this._config.columnWidths)
};
var columnNames = $.trim(this._optionContainerElmts.columnNamesInput[0].value).replace(/,\s+/g, ',').split(',');
if (columnNames.length > 0 && columnNames[0].length > 0) {
options.columnNames = columnNames;
var options = {
columnWidths: [].concat(this._config.columnWidths)
};
var columnNames = $.trim(this._optionContainerElmts.columnNamesInput[0].value).replace(/,\s+/g, ',').split(',');
if (columnNames.length > 0 && columnNames[0].length > 0) {
options.columnNames = columnNames;
}
switch (this._optionContainer.find("input[name='row-separator']:checked")[0].value) {
case 'new-line':
options.lineSeparator = "\n";
break;
default:
options.lineSeparator = Refine.FixedWidthParserUI.decodeSeparator(
this._optionContainerElmts.rowSeparatorInput[0].value);
}
var parseIntDefault = function(s, def) {
try {
var n = parseInt(s);
if (!isNaN(n)) {
return n;
}
} catch (e) {
// Ignore
}
switch (this._optionContainer.find("input[name='row-separator']:checked")[0].value) {
case 'new-line':
options.lineSeparator = "\n";
break;
default:
options.lineSeparator = Refine.FixedWidthParserUI.decodeSeparator(
this._optionContainerElmts.rowSeparatorInput[0].value);
}
var parseIntDefault = function(s, def) {
try {
var n = parseInt(s);
if (!isNaN(n)) {
return n;
}
} catch (e) {
// Ignore
}
return def;
};
if (this._optionContainerElmts.ignoreCheckbox[0].checked) {
options.ignoreLines = parseIntDefault(this._optionContainerElmts.ignoreInput[0].value, -1);
} else {
options.ignoreLines = -1;
}
if (this._optionContainerElmts.headerLinesCheckbox[0].checked) {
options.headerLines = parseIntDefault(this._optionContainerElmts.headerLinesInput[0].value, 0);
} else {
options.headerLines = 0;
}
if (this._optionContainerElmts.skipCheckbox[0].checked) {
options.skipDataLines = parseIntDefault(this._optionContainerElmts.skipInput[0].value, 0);
} else {
options.skipDataLines = 0;
}
if (this._optionContainerElmts.limitCheckbox[0].checked) {
options.limit = parseIntDefault(this._optionContainerElmts.limitInput[0].value, -1);
} else {
options.limit = -1;
}
options.guessCellValueTypes = this._optionContainerElmts.guessCellValueTypesCheckbox[0].checked;
options.storeBlankRows = this._optionContainerElmts.storeBlankRowsCheckbox[0].checked;
options.storeBlankCellsAsNulls = this._optionContainerElmts.storeBlankCellsAsNullsCheckbox[0].checked;
options.includeFileSources = this._optionContainerElmts.includeFileSourcesCheckbox[0].checked;
return options;
return def;
};
if (this._optionContainerElmts.ignoreCheckbox[0].checked) {
options.ignoreLines = parseIntDefault(this._optionContainerElmts.ignoreInput[0].value, -1);
} else {
options.ignoreLines = -1;
}
if (this._optionContainerElmts.headerLinesCheckbox[0].checked) {
options.headerLines = parseIntDefault(this._optionContainerElmts.headerLinesInput[0].value, 0);
} else {
options.headerLines = 0;
}
if (this._optionContainerElmts.skipCheckbox[0].checked) {
options.skipDataLines = parseIntDefault(this._optionContainerElmts.skipInput[0].value, 0);
} else {
options.skipDataLines = 0;
}
if (this._optionContainerElmts.limitCheckbox[0].checked) {
options.limit = parseIntDefault(this._optionContainerElmts.limitInput[0].value, -1);
} else {
options.limit = -1;
}
options.guessCellValueTypes = this._optionContainerElmts.guessCellValueTypesCheckbox[0].checked;
options.storeBlankRows = this._optionContainerElmts.storeBlankRowsCheckbox[0].checked;
options.storeBlankCellsAsNulls = this._optionContainerElmts.storeBlankCellsAsNullsCheckbox[0].checked;
options.includeFileSources = this._optionContainerElmts.includeFileSourcesCheckbox[0].checked;
return options;
};
Refine.FixedWidthParserUI.prototype._initialize = function() {
var self = this;
this._optionContainer.unbind().empty().html(
DOM.loadHTML("core", "scripts/index/parser-interfaces/fixed-width-parser-ui.html"));
this._optionContainerElmts = DOM.bind(this._optionContainer);
this._optionContainerElmts.previewButton.click(function() { self._updatePreview(); });
this._optionContainerElmts.columnWidthsInput[0].value = this._config.columnWidths.join(',');
if ('columnNames' in this._config) {
this._optionContainerElmts.columnNamesInput[0].value = this._config.columnNames.join(',');
var self = this;
this._optionContainer.unbind().empty().html(
DOM.loadHTML("core", "scripts/index/parser-interfaces/fixed-width-parser-ui.html"));
this._optionContainerElmts = DOM.bind(this._optionContainer);
this._optionContainerElmts.previewButton.click(function() { self._updatePreview(); });
this._optionContainerElmts.columnWidthsInput[0].value = this._config.columnWidths.join(',');
if ('columnNames' in this._config) {
this._optionContainerElmts.columnNamesInput[0].value = this._config.columnNames.join(',');
}
var rowSeparatorValue = (this._config.lineSeparator == "\n") ? 'new-line' : 'custom';
this._optionContainer.find(
"input[name='row-separator'][value='" + rowSeparatorValue + "']").attr("checked", "checked");
this._optionContainerElmts.rowSeparatorInput[0].value =
Refine.FixedWidthParserUI.encodeSeparator(this._config.lineSeparator);
if (this._config.ignoreLines > 0) {
this._optionContainerElmts.ignoreCheckbox.attr("checked", "checked");
this._optionContainerElmts.ignoreInput[0].value = this._config.ignoreLines.toString();
}
if (this._config.headerLines > 0) {
this._optionContainerElmts.headerLinesCheckbox.attr("checked", "checked");
this._optionContainerElmts.headerLinesInput[0].value = this._config.headerLines.toString();
}
if (this._config.limit > 0) {
this._optionContainerElmts.limitCheckbox.attr("checked", "checked");
this._optionContainerElmts.limitInput[0].value = this._config.limit.toString();
}
if (this._config.skipDataLines > 0) {
this._optionContainerElmts.skipCheckbox.attr("checked", "checked");
this._optionContainerElmts.skipInput.value[0].value = this._config.skipDataLines.toString();
}
if (this._config.storeBlankRows) {
this._optionContainerElmts.storeBlankRowsCheckbox.attr("checked", "checked");
}
if (this._config.guessCellValueTypes) {
this._optionContainerElmts.guessCellValueTypesCheckbox.attr("checked", "checked");
}
if (this._config.storeBlankCellsAsNulls) {
this._optionContainerElmts.storeBlankCellsAsNullsCheckbox.attr("checked", "checked");
}
if (this._config.includeFileSources) {
this._optionContainerElmts.includeFileSourcesCheckbox.attr("checked", "checked");
}
var onChange = function() {
self._scheduleUpdatePreview();
};
this._optionContainer.find("input").bind("change", onChange);
this._optionContainer.find("select").bind("change", onChange);
this._optionContainerElmts.columnWidthsInput.bind("change", function() {
var newColumnWidths = [];
var a = $.trim(this.value).replace(/,\s+/g, ',').split(',');
for (var i = 0; i < a.length; i++) {
var n = parseInt(a[i]);
if (isNaN(n)) {
return;
}
newColumnWidths.push(n);
}
var rowSeparatorValue = (this._config.lineSeparator == "\n") ? 'new-line' : 'custom';
this._optionContainer.find(
"input[name='row-separator'][value='" + rowSeparatorValue + "']").attr("checked", "checked");
this._optionContainerElmts.rowSeparatorInput[0].value =
Refine.FixedWidthParserUI.encodeSeparator(this._config.lineSeparator);
if (this._config.ignoreLines > 0) {
this._optionContainerElmts.ignoreCheckbox.attr("checked", "checked");
this._optionContainerElmts.ignoreInput[0].value = this._config.ignoreLines.toString();
}
if (this._config.headerLines > 0) {
this._optionContainerElmts.headerLinesCheckbox.attr("checked", "checked");
this._optionContainerElmts.headerLinesInput[0].value = this._config.headerLines.toString();
}
if (this._config.limit > 0) {
this._optionContainerElmts.limitCheckbox.attr("checked", "checked");
this._optionContainerElmts.limitInput[0].value = this._config.limit.toString();
}
if (this._config.skipDataLines > 0) {
this._optionContainerElmts.skipCheckbox.attr("checked", "checked");
this._optionContainerElmts.skipInput.value[0].value = this._config.skipDataLines.toString();
}
if (this._config.storeBlankRows) {
this._optionContainerElmts.storeBlankRowsCheckbox.attr("checked", "checked");
}
if (this._config.guessCellValueTypes) {
this._optionContainerElmts.guessCellValueTypesCheckbox.attr("checked", "checked");
}
if (this._config.storeBlankCellsAsNulls) {
this._optionContainerElmts.storeBlankCellsAsNullsCheckbox.attr("checked", "checked");
}
if (this._config.includeFileSources) {
this._optionContainerElmts.includeFileSourcesCheckbox.attr("checked", "checked");
}
var onChange = function() {
self._scheduleUpdatePreview();
};
this._optionContainer.find("input").bind("change", onChange);
this._optionContainer.find("select").bind("change", onChange);
this._optionContainerElmts.columnWidthsInput.bind("change", function() {
var newColumnWidths = [];
var a = $.trim(this.value).replace(/,\s+/g, ',').split(',');
for (var i = 0; i < a.length; i++) {
var n = parseInt(a[i]);
if (isNaN(n)) {
return;
}
newColumnWidths.push(n);
}
self._config.columnWidths = newColumnWidths;
onChange();
});
this._optionContainerElmts.columnNamesInput.bind("change", onChange);
self._config.columnWidths = newColumnWidths;
onChange();
});
this._optionContainerElmts.columnNamesInput.bind("change", onChange);
};
Refine.FixedWidthParserUI.prototype._scheduleUpdatePreview = function() {
if (this._timerID != null) {
window.clearTimeout(this._timerID);
this._timerID = null;
}
var self = this;
this._timerID = window.setTimeout(function() {
self._timerID = null;
self.updatePreview();
}, 500); // 0.5 second
if (this._timerID != null) {
window.clearTimeout(this._timerID);
this._timerID = null;
}
var self = this;
this._timerID = window.setTimeout(function() {
self._timerID = null;
self.updatePreview();
}, 500); // 0.5 second
};
Refine.FixedWidthParserUI.prototype.updatePreview = function() {
var self = this;
this._progressContainer.show();
var options = this.getOptions();
// for preview, we need exact text, so it's easier to show where the columns are split
options.guessCellValueTypes = false;
this._controller.updateFormatAndOptions(options, function(result) {
if (result.status == "ok") {
self._controller.getPreviewData(function(projectData) {
new Refine.FixedWidthPreviewTable(
self,
self._config,
projectData,
self._dataContainer
);
self._progressContainer.hide();
}, 20);
}
});
var self = this;
this._progressContainer.show();
var options = this.getOptions();
// for preview, we need exact text, so it's easier to show where the columns are split
options.guessCellValueTypes = false;
this._controller.updateFormatAndOptions(options, function(result) {
if (result.status == "ok") {
self._controller.getPreviewData(function(projectData) {
new Refine.FixedWidthPreviewTable(
self,
self._config,
projectData,
self._dataContainer
);
self._progressContainer.hide();
}, 20);
}
});
};
Refine.FixedWidthPreviewTable = function(parserUI, config, projectData, elmt) {
this._parserUI = parserUI;
this._config = config;
this._projectData = projectData;
this._elmt = elmt;
this._render();
this._parserUI = parserUI;
this._config = config;
this._projectData = projectData;
this._elmt = elmt;
this._render();
};
Refine.FixedWidthPreviewTable.prototype._render = function() {
var scrollTop = this._elmt[0].scrollTop;
var scrollLeft = this._elmt[0].scrollLeft;
this._elmt.unbind().empty();
var self = this;
var container = $('<div>')
.addClass('fixed-width-preview-container')
.appendTo(this._elmt);
var table = $('<table>')
.addClass("data-table")
.addClass("fixed-width-preview-data-table")
.appendTo(container)[0];
var columns = this._projectData.columnModel.columns;
var columnWidths = [].concat(this._config.columnWidths);
var addCell = function(tr) {
var index = tr.cells.length;
var td = tr.insertCell(index);
td.className = (index % 2 == 0) ? 'even' : 'odd';
return td;
};
/*------------------------------------------------------------
* Column Headers
*------------------------------------------------------------
*/
var scrollTop = this._elmt[0].scrollTop;
var scrollLeft = this._elmt[0].scrollLeft;
var trHead = table.insertRow(table.rows.length);
$(addCell(trHead)).addClass("column-header").html('&nbsp;'); // index
var createColumnHeader = function(column, index) {
var name = column.name;
if (index < columnWidths.length) {
name = name.slice(0, columnWidths[index]);
}
$(addCell(trHead))
.addClass("column-header")
.text(name)
.attr('title', column.name);
};
this._elmt.unbind().empty();
var self = this;
var container = $('<div>')
.addClass('fixed-width-preview-container')
.appendTo(this._elmt);
var table = $('<table>')
.addClass("data-table")
.addClass("fixed-width-preview-data-table")
.appendTo(container)[0];
var columns = this._projectData.columnModel.columns;
var columnWidths = [].concat(this._config.columnWidths);
var addCell = function(tr) {
var index = tr.cells.length;
var td = tr.insertCell(index);
td.className = (index % 2 == 0) ? 'even' : 'odd';
return td;
};
/*------------------------------------------------------------
* Column Headers
*------------------------------------------------------------
*/
var trHead = table.insertRow(table.rows.length);
$(addCell(trHead)).addClass("column-header").html('&nbsp;'); // index
var createColumnHeader = function(column, index) {
var name = column.name;
if (index < columnWidths.length) {
name = name.slice(0, columnWidths[index]);
}
$(addCell(trHead))
.addClass("column-header")
.text(name)
.attr('title', column.name);
};
for (var i = 0; i < columns.length; i++) {
createColumnHeader(columns[i], i);
}
/*------------------------------------------------------------
* Data Cells
*------------------------------------------------------------
*/
var rows = this._projectData.rowModel.rows;
var renderRow = function(tr, r, row) {
var tdIndex = addCell(tr);
$('<div></div>').html((row.i + 1) + ".").appendTo(tdIndex);
var cells = row.cells;
for (var i = 0; i < columns.length; i++) {
createColumnHeader(columns[i], i);
}
/*------------------------------------------------------------
* Data Cells
*------------------------------------------------------------
*/
var rows = this._projectData.rowModel.rows;
var renderRow = function(tr, r, row) {
var tdIndex = addCell(tr);
$('<div></div>').html((row.i + 1) + ".").appendTo(tdIndex);
var cells = row.cells;
for (var i = 0; i < columns.length; i++) {
var column = columns[i];
var td = addCell(tr);
var divContent = $('<div/>').addClass("data-table-cell-content").appendTo(td);
var cell = (column.cellIndex < cells.length) ? cells[column.cellIndex] : null;
if (!cell || ("v" in cell && cell.v === null)) {
$('<span>').html("&nbsp;").appendTo(divContent);
} else if ("e" in cell) {
$('<span>').addClass("data-table-error").text(cell.e).appendTo(divContent);
} else if (!("r" in cell) || !cell.r) {
if (typeof cell.v !== "string") {
if (typeof cell.v == "number") {
divContent.addClass("data-table-cell-content-numeric");
}
$('<span>')
.addClass("data-table-value-nonstring")
.text(cell.v)
.appendTo(divContent);
} else if (URL.looksLikeUrl(cell.v)) {
$('<a>')
.text(cell.v)
.attr("href", cell.v)
.attr("target", "_blank")
.appendTo(divContent);
} else {
$('<span>').text(cell.v).appendTo(divContent);
}
}
var column = columns[i];
var td = addCell(tr);
var divContent = $('<div/>').addClass("data-table-cell-content").appendTo(td);
var cell = (column.cellIndex < cells.length) ? cells[column.cellIndex] : null;
if (!cell || ("v" in cell && cell.v === null)) {
$('<span>').html("&nbsp;").appendTo(divContent);
} else if ("e" in cell) {
$('<span>').addClass("data-table-error").text(cell.e).appendTo(divContent);
} else if (!("r" in cell) || !cell.r) {
if (typeof cell.v !== "string") {
if (typeof cell.v == "number") {
divContent.addClass("data-table-cell-content-numeric");
}
$('<span>')
.addClass("data-table-value-nonstring")
.text(cell.v)
.appendTo(divContent);
} else if (URL.looksLikeUrl(cell.v)) {
$('<a>')
.text(cell.v)
.attr("href", cell.v)
.attr("target", "_blank")
.appendTo(divContent);
} else {
$('<span>').text(cell.v).appendTo(divContent);
}
};
for (var r = 0; r < rows.length; r++) {
var row = rows[r];
renderRow(table.insertRow(table.rows.length), r, row);
}
}
var pixelOffset = $(trHead.cells[1]).position().left;
var testString = '01234567890123456789012345678901234567890123456789';
var testDiv = $('<div>')
.css('position', 'absolute')
.css('top', '-100px')
.text(testString)
.appendTo(container);
var pixelsPerChar = testDiv.width() / testString.length;
testDiv.remove();
var columnSeparators = [];
var columnCharIndexes = [];
var positionColumnSeparator = function(outer, charIndex) {
outer.css('left',
Math.round(pixelOffset + charIndex * pixelsPerChar - DOM.getHPaddings(outer) / 2) + 'px');
};
var computeCharIndex = function(evt) {
var offset = evt.pageX - container.offset().left;
return Math.round((offset - pixelOffset) / pixelsPerChar);
};
var updatePreview = function() {
columnCharIndexes.sort(function(a, b) { return a - b; });
var newColumnWidths = [];
for (var i = 0; i < columnCharIndexes.length; i++) {
var charIndex = columnCharIndexes[i];
var columnWidth = (i == 0) ? charIndex : (charIndex - columnCharIndexes[i - 1]);
if (columnWidth > 0) {
newColumnWidths.push(columnWidth);
}
}
self._config.columnWidths = newColumnWidths;
self._parserUI._optionContainerElmts.columnWidthsInput[0].value = newColumnWidths.join(',');
self._parserUI.updatePreview();
};
var newSeparator = $('<div>')
.addClass('fixed-width-preview-column-separator-outer')
.append($('<div>').addClass('fixed-width-preview-column-separator-inner'))
.appendTo(container);
var createColumnSeparator = function(charIndex, index) {
columnCharIndexes[index] = charIndex;
var outer = $('<div>')
.addClass('fixed-width-preview-column-separator-outer')
.appendTo(container);
var inner = $('<div>')
.addClass('fixed-width-preview-column-separator-inner')
.appendTo(outer);
var close = $('<div>').appendTo(inner);
positionColumnSeparator(outer, charIndex);
outer.mouseover(function() {
newSeparator.hide();
})
.mouseout(function() {
newSeparator.show();
})
.mousedown(function() {
var mouseMove = function(evt) {
var newCharIndex = computeCharIndex(evt);
positionColumnSeparator(outer, newCharIndex);
evt.preventDefault();
evt.stopPropagation();
return false;
};
var mouseUp = function(evt) {
container.unbind('mousemove', mouseMove);
container.unbind('mouseup', mouseUp);
var newCharIndex = computeCharIndex(evt);
positionColumnSeparator(outer, newCharIndex);
columnCharIndexes[index] = newCharIndex;
updatePreview();
evt.preventDefault();
evt.stopPropagation();
return false;
};
container.bind('mousemove', mouseMove);
container.bind('mouseup', mouseUp);
});
close.click(function() {
columnCharIndexes[index] = index > 0 ? columnCharIndexes[index - 1] : 0;
updatePreview();
});
};
var charOffset = 0;
for (var i = 0; i < columnWidths.length; i++) {
var columnWidth = columnWidths[i];
createColumnSeparator(charOffset + columnWidth, i);
charOffset += columnWidth;
};
for (var r = 0; r < rows.length; r++) {
var row = rows[r];
renderRow(table.insertRow(table.rows.length), r, row);
}
var pixelOffset = $(trHead.cells[1]).position().left;
var testString = '01234567890123456789012345678901234567890123456789';
var testDiv = $('<div>')
.css('position', 'absolute')
.css('top', '-100px')
.text(testString)
.appendTo(container);
var pixelsPerChar = testDiv.width() / testString.length;
testDiv.remove();
var columnSeparators = [];
var columnCharIndexes = [];
var positionColumnSeparator = function(outer, charIndex) {
outer.css('left',
Math.round(pixelOffset + charIndex * pixelsPerChar - DOM.getHPaddings(outer) / 2) + 'px');
};
var computeCharIndex = function(evt) {
var offset = evt.pageX - container.offset().left;
return Math.round((offset - pixelOffset) / pixelsPerChar);
};
var updatePreview = function() {
columnCharIndexes.sort(function(a, b) { return a - b; });
var newColumnWidths = [];
for (var i = 0; i < columnCharIndexes.length; i++) {
var charIndex = columnCharIndexes[i];
var columnWidth = (i == 0) ? charIndex : (charIndex - columnCharIndexes[i - 1]);
if (columnWidth > 0) {
newColumnWidths.push(columnWidth);
}
}
container
.mouseout(function(evt) {
newSeparator.hide();
})
.mousemove(function(evt) {
var offset = evt.pageX - container.offset().left;
var newCharIndex = Math.round((offset - pixelOffset) / pixelsPerChar);
positionColumnSeparator(newSeparator.show(), newCharIndex);
});
newSeparator.mousedown(function(evt) {
self._config.columnWidths = newColumnWidths;
self._parserUI._optionContainerElmts.columnWidthsInput[0].value = newColumnWidths.join(',');
self._parserUI.updatePreview();
};
var newSeparator = $('<div>')
.addClass('fixed-width-preview-column-separator-outer')
.append($('<div>').addClass('fixed-width-preview-column-separator-inner'))
.appendTo(container);
var createColumnSeparator = function(charIndex, index) {
columnCharIndexes[index] = charIndex;
var outer = $('<div>')
.addClass('fixed-width-preview-column-separator-outer')
.appendTo(container);
var inner = $('<div>')
.addClass('fixed-width-preview-column-separator-inner')
.appendTo(outer);
var close = $('<div>').appendTo(inner);
positionColumnSeparator(outer, charIndex);
outer.mouseover(function() {
newSeparator.hide();
})
.mouseout(function() {
newSeparator.show();
})
.mousedown(function() {
var mouseMove = function(evt) {
var newCharIndex = computeCharIndex(evt);
columnCharIndexes.push(newCharIndex);
updatePreview();
positionColumnSeparator(outer, newCharIndex);
evt.preventDefault();
evt.stopPropagation();
return false;
};
var mouseUp = function(evt) {
container.unbind('mousemove', mouseMove);
container.unbind('mouseup', mouseUp);
var newCharIndex = computeCharIndex(evt);
positionColumnSeparator(outer, newCharIndex);
columnCharIndexes[index] = newCharIndex;
updatePreview();
evt.preventDefault();
evt.stopPropagation();
return false;
};
container.bind('mousemove', mouseMove);
container.bind('mouseup', mouseUp);
});
this._elmt[0].scrollTop = scrollTop;
this._elmt[0].scrollLeft = scrollLeft;
close.click(function() {
columnCharIndexes[index] = index > 0 ? columnCharIndexes[index - 1] : 0;
updatePreview();
});
};
var charOffset = 0;
for (var i = 0; i < columnWidths.length; i++) {
var columnWidth = columnWidths[i];
createColumnSeparator(charOffset + columnWidth, i);
charOffset += columnWidth;
}
container
.mouseout(function(evt) {
newSeparator.hide();
})
.mousemove(function(evt) {
var offset = evt.pageX - container.offset().left;
var newCharIndex = Math.round((offset - pixelOffset) / pixelsPerChar);
positionColumnSeparator(newSeparator.show(), newCharIndex);
});
newSeparator.mousedown(function(evt) {
var newCharIndex = computeCharIndex(evt);
columnCharIndexes.push(newCharIndex);
updatePreview();
evt.preventDefault();
evt.stopPropagation();
return false;
});
this._elmt[0].scrollTop = scrollTop;
this._elmt[0].scrollLeft = scrollLeft;
};

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,213 +29,213 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
Refine.JsonParserUI = function(controller, jobID, job, format, config,
dataContainerElmt, progressContainerElmt, optionContainerElmt) {
this._controller = controller;
this._jobID = jobID;
this._job = job;
this._format = format;
this._config = config;
this._dataContainer = dataContainerElmt;
this._progressContainer = progressContainerElmt;
this._optionContainer = optionContainerElmt;
this._timerID = null;
this._initialize();
this._showPickRecordNodesUI();
this._controller = controller;
this._jobID = jobID;
this._job = job;
this._format = format;
this._config = config;
this._dataContainer = dataContainerElmt;
this._progressContainer = progressContainerElmt;
this._optionContainer = optionContainerElmt;
this._timerID = null;
this._initialize();
this._showPickRecordNodesUI();
};
Refine.DefaultImportingController.parserUIs["JsonParserUI"] = Refine.JsonParserUI;
Refine.JsonParserUI.prototype.dispose = function() {
if (this._timerID != null) {
window.clearTimeout(this._timerID);
this._timerID = null;
}
if (this._timerID != null) {
window.clearTimeout(this._timerID);
this._timerID = null;
}
};
Refine.JsonParserUI.prototype.confirmReadyToCreateProject = function() {
if ((this._config.recordPath) && this._config.recordPath.length > 0) {
return true;
return true;
} else {
window.alert('Please specify a record path first.');
window.alert('Please specify a record path first.');
}
};
Refine.JsonParserUI.prototype.getOptions = function() {
var options = {
recordPath: this._config.recordPath
};
if (this._optionContainerElmts.limitCheckbox[0].checked) {
options.limit = parseIntDefault(this._optionContainerElmts.limitInput[0].value, -1);
} else {
options.limit = -1;
}
options.includeFileSources = this._optionContainerElmts.includeFileSourcesCheckbox[0].checked;
return options;
var options = {
recordPath: this._config.recordPath
};
if (this._optionContainerElmts.limitCheckbox[0].checked) {
options.limit = parseIntDefault(this._optionContainerElmts.limitInput[0].value, -1);
} else {
options.limit = -1;
}
options.includeFileSources = this._optionContainerElmts.includeFileSourcesCheckbox[0].checked;
return options;
};
Refine.JsonParserUI.prototype._initialize = function() {
var self = this;
this._optionContainer.unbind().empty().html(
DOM.loadHTML("core", "scripts/index/parser-interfaces/json-parser-ui.html"));
this._optionContainerElmts = DOM.bind(this._optionContainer);
this._optionContainerElmts.previewButton.click(function() { self._updatePreview(); });
if (this._config.limit > 0) {
this._optionContainerElmts.limitCheckbox.attr("checked", "checked");
this._optionContainerElmts.limitInput[0].value = this._config.limit.toString();
}
if (this._config.includeFileSources) {
this._optionContainerElmts.includeFileSourcesCheckbox.attr("checked", "checked");
}
this._optionContainerElmts.pickRecordElementsButton.click(function() {
self._showPickRecordNodesUI();
});
var onChange = function() {
self._scheduleUpdatePreview();
};
this._optionContainer.find("input").bind("change", onChange);
this._optionContainer.find("select").bind("change", onChange);
var self = this;
this._optionContainer.unbind().empty().html(
DOM.loadHTML("core", "scripts/index/parser-interfaces/json-parser-ui.html"));
this._optionContainerElmts = DOM.bind(this._optionContainer);
this._optionContainerElmts.previewButton.click(function() { self._updatePreview(); });
if (this._config.limit > 0) {
this._optionContainerElmts.limitCheckbox.attr("checked", "checked");
this._optionContainerElmts.limitInput[0].value = this._config.limit.toString();
}
if (this._config.includeFileSources) {
this._optionContainerElmts.includeFileSourcesCheckbox.attr("checked", "checked");
}
this._optionContainerElmts.pickRecordElementsButton.click(function() {
self._showPickRecordNodesUI();
});
var onChange = function() {
self._scheduleUpdatePreview();
};
this._optionContainer.find("input").bind("change", onChange);
this._optionContainer.find("select").bind("change", onChange);
};
Refine.JsonParserUI.prototype._showPickRecordNodesUI = function() {
var self = this;
this._dataContainer.unbind().empty().html(
DOM.loadHTML("core", "scripts/index/parser-interfaces/json-parser-select-ui.html"));
var elmts = DOM.bind(this._dataContainer);
var escapeElmt = $('<span>');
var escapeHtml = function(s) {
escapeElmt.empty().text(s);
return escapeElmt.html();
};
var textAsHtml = function(s) {
s = s.length <= 200 ? s : (s.substring(0, 200) + ' ...');
return '<span class="text">' + escapeHtml(s) + '</span>';
};
var hittest = function(evt, elmt) {
var a = $(evt.target).closest('.node');
return a.length > 0 && a[0] == elmt[0];
};
var registerEvents = function(elmt, path) {
elmt.bind('mouseover', function(evt) {
if (hittest(evt, elmt)) {
elmts.domContainer.find('.highlight').removeClass('highlight');
elmt.addClass('highlight');
}
})
.bind('mouseout', function(evt) {
elmt.removeClass('highlight');
})
.click(function(evt) {
if (hittest(evt, elmt)) {
self._setRecordPath(path);
}
});
};
var renderArray = function(a, container, parentPath) {
$('<span>').addClass('punctuation').text('[').appendTo(container);
var parentPath2 = [].concat(parentPath);
parentPath2.push('__anonymous__');
var elementNode = null;
for (var i = 0; i < a.length; i++) {
if (elementNode != null) {
$('<span>').addClass('punctuation').text(',').appendTo(elementNode);
}
elementNode = $('<div>').addClass('node').addClass('indented').appendTo(container);
renderNode(a[i], elementNode, parentPath2);
}
$('<span>').addClass('punctuation').text(']').appendTo(container);
};
var renderObject = function(o, container, parentPath) {
$('<span>').addClass('punctuation').text('{').appendTo(container);
var elementNode = null;
for (var key in o) {
if (o.hasOwnProperty(key)) {
if (elementNode != null) {
$('<span>').addClass('punctuation').text(',').appendTo(elementNode);
}
elementNode = $('<div>').addClass('node').addClass('indented').appendTo(container);
$('<span>').text(key).addClass('field-name').appendTo(elementNode);
$('<span>').text(': ').addClass('punctuation').appendTo(elementNode);
var parentPath2 = [].concat(parentPath);
parentPath2.push(key);
var self = this;
renderNode(o[key], elementNode, parentPath2);
}
this._dataContainer.unbind().empty().html(
DOM.loadHTML("core", "scripts/index/parser-interfaces/json-parser-select-ui.html"));
var elmts = DOM.bind(this._dataContainer);
var escapeElmt = $('<span>');
var escapeHtml = function(s) {
escapeElmt.empty().text(s);
return escapeElmt.html();
};
var textAsHtml = function(s) {
s = s.length <= 200 ? s : (s.substring(0, 200) + ' ...');
return '<span class="text">' + escapeHtml(s) + '</span>';
};
var hittest = function(evt, elmt) {
var a = $(evt.target).closest('.node');
return a.length > 0 && a[0] == elmt[0];
};
var registerEvents = function(elmt, path) {
elmt.bind('mouseover', function(evt) {
if (hittest(evt, elmt)) {
elmts.domContainer.find('.highlight').removeClass('highlight');
elmt.addClass('highlight');
}
})
.bind('mouseout', function(evt) {
elmt.removeClass('highlight');
})
.click(function(evt) {
if (hittest(evt, elmt)) {
self._setRecordPath(path);
}
});
};
var renderArray = function(a, container, parentPath) {
$('<span>').addClass('punctuation').text('[').appendTo(container);
var parentPath2 = [].concat(parentPath);
parentPath2.push('__anonymous__');
var elementNode = null;
for (var i = 0; i < a.length; i++) {
if (elementNode != null) {
$('<span>').addClass('punctuation').text(',').appendTo(elementNode);
}
elementNode = $('<div>').addClass('node').addClass('indented').appendTo(container);
renderNode(a[i], elementNode, parentPath2);
}
$('<span>').addClass('punctuation').text(']').appendTo(container);
};
var renderObject = function(o, container, parentPath) {
$('<span>').addClass('punctuation').text('{').appendTo(container);
var elementNode = null;
for (var key in o) {
if (o.hasOwnProperty(key)) {
if (elementNode != null) {
$('<span>').addClass('punctuation').text(',').appendTo(elementNode);
}
$('<span>').addClass('punctuation').text('}').appendTo(container);
elementNode = $('<div>').addClass('node').addClass('indented').appendTo(container);
$('<span>').text(key).addClass('field-name').appendTo(elementNode);
$('<span>').text(': ').addClass('punctuation').appendTo(elementNode);
var parentPath2 = [].concat(parentPath);
parentPath2.push(key);
renderNode(o[key], elementNode, parentPath2);
}
}
$('<span>').addClass('punctuation').text('}').appendTo(container);
registerEvents(container, parentPath);
};
var renderNode = function(node, container, parentPath) {
if (node == null) {
$('<span>').addClass('literal').text('null').appendTo(container);
} else {
if ($.isPlainObject(node)) {
renderObject(node, container, parentPath);
} else if ($.isArray(node)) {
renderArray(node, container, parentPath);
} else {
$('<span>').addClass('literal').text(node.toString()).appendTo(container);
registerEvents(container, parentPath);
};
var renderNode = function(node, container, parentPath) {
if (node == null) {
$('<span>').addClass('literal').text('null').appendTo(container);
} else {
if ($.isPlainObject(node)) {
renderObject(node, container, parentPath);
} else if ($.isArray(node)) {
renderArray(node, container, parentPath);
} else {
$('<span>').addClass('literal').text(node.toString()).appendTo(container);
registerEvents(container, parentPath);
}
}
};
renderNode(this._config.dom, elmts.domContainer, [ '__anonymous__' ]);
}
}
};
renderNode(this._config.dom, elmts.domContainer, [ '__anonymous__' ]);
};
Refine.JsonParserUI.prototype._scheduleUpdatePreview = function() {
if (this._timerID != null) {
window.clearTimeout(this._timerID);
this._timerID = null;
}
var self = this;
this._timerID = window.setTimeout(function() {
self._timerID = null;
self._updatePreview();
}, 500); // 0.5 second
if (this._timerID != null) {
window.clearTimeout(this._timerID);
this._timerID = null;
}
var self = this;
this._timerID = window.setTimeout(function() {
self._timerID = null;
self._updatePreview();
}, 500); // 0.5 second
};
Refine.JsonParserUI.prototype._setRecordPath = function(path) {
this._config.recordPath = path;
this._updatePreview();
this._config.recordPath = path;
this._updatePreview();
};
Refine.JsonParserUI.prototype._updatePreview = function() {
var self = this;
this._progressContainer.show();
var options = this.getOptions();
// for preview, we need exact text, so it's easier to show where the columns are split
options.guessCellValueTypes = false;
this._controller.updateFormatAndOptions(options, function(result) {
if (result.status == "ok") {
self._controller.getPreviewData(function(projectData) {
self._progressContainer.hide();
new Refine.PreviewTable(projectData, self._dataContainer.unbind().empty());
}, 100);
}
});
var self = this;
this._progressContainer.show();
var options = this.getOptions();
// for preview, we need exact text, so it's easier to show where the columns are split
options.guessCellValueTypes = false;
this._controller.updateFormatAndOptions(options, function(result) {
if (result.status == "ok") {
self._controller.getPreviewData(function(projectData) {
self._progressContainer.hide();
new Refine.PreviewTable(projectData, self._dataContainer.unbind().empty());
}, 100);
}
});
};

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,24 +29,24 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
Refine.LineBasedParserUI = function(controller, jobID, job, format, config,
dataContainerElmt, progressContainerElmt, optionContainerElmt) {
dataContainerElmt, progressContainerElmt, optionContainerElmt) {
this._controller = controller;
this._jobID = jobID;
this._job = job;
this._format = format;
this._config = config;
this._controller = controller;
this._jobID = jobID;
this._job = job;
this._format = format;
this._config = config;
this._dataContainer = dataContainerElmt;
this._progressContainer = progressContainerElmt;
this._optionContainer = optionContainerElmt;
this._dataContainer = dataContainerElmt;
this._progressContainer = progressContainerElmt;
this._optionContainer = optionContainerElmt;
this._timerID = null;
this._initialize();
this._updatePreview();
this._timerID = null;
this._initialize();
this._updatePreview();
};
Refine.DefaultImportingController.parserUIs["LineBasedParserUI"] = Refine.LineBasedParserUI;
@ -55,132 +55,132 @@ Refine.LineBasedParserUI.prototype.confirmReadyToCreateProject = function() {
};
Refine.LineBasedParserUI.prototype.dispose = function() {
if (this._timerID != null) {
window.clearTimeout(this._timerID);
this._timerID = null;
}
if (this._timerID != null) {
window.clearTimeout(this._timerID);
this._timerID = null;
}
};
Refine.LineBasedParserUI.prototype.getOptions = function() {
var options = {
recordPath: this._config.recordPath
};
var parseIntDefault = function(s, def) {
try {
var n = parseInt(s);
if (!isNaN(n)) {
return n;
}
} catch (e) {
// Ignore
}
return def;
};
options.linesPerRow = parseIntDefault(this._optionContainerElmts.linesPerRowInput[0].value, 1);
switch (this._optionContainer.find("input[name='row-separator']:checked")[0].value) {
case 'new-line':
options.lineSeparator = "\n";
break;
default:
options.lineSeparator = Refine.FixedWidthParserUI.decodeSeparator(
this._optionContainerElmts.rowSeparatorInput[0].value);
var options = {
recordPath: this._config.recordPath
};
var parseIntDefault = function(s, def) {
try {
var n = parseInt(s);
if (!isNaN(n)) {
return n;
}
} catch (e) {
// Ignore
}
if (this._optionContainerElmts.ignoreCheckbox[0].checked) {
options.ignoreLines = parseIntDefault(this._optionContainerElmts.ignoreInput[0].value, -1);
} else {
options.ignoreLines = -1;
}
if (this._optionContainerElmts.limitCheckbox[0].checked) {
options.limit = parseIntDefault(this._optionContainerElmts.limitInput[0].value, -1);
} else {
options.limit = -1;
}
if (this._optionContainerElmts.skipCheckbox[0].checked) {
options.skipDataLines = parseIntDefault(this._optionContainerElmts.skipInput[0].value, -1);
} else {
options.skipDataLines = -1;
}
options.storeBlankRows = this._optionContainerElmts.storeBlankRowsCheckbox[0].checked;
options.storeBlankCellsAsNulls = this._optionContainerElmts.storeBlankCellsAsNullsCheckbox[0].checked;
options.includeFileSources = this._optionContainerElmts.includeFileSourcesCheckbox[0].checked;
return options;
return def;
};
options.linesPerRow = parseIntDefault(this._optionContainerElmts.linesPerRowInput[0].value, 1);
switch (this._optionContainer.find("input[name='row-separator']:checked")[0].value) {
case 'new-line':
options.lineSeparator = "\n";
break;
default:
options.lineSeparator = Refine.FixedWidthParserUI.decodeSeparator(
this._optionContainerElmts.rowSeparatorInput[0].value);
}
if (this._optionContainerElmts.ignoreCheckbox[0].checked) {
options.ignoreLines = parseIntDefault(this._optionContainerElmts.ignoreInput[0].value, -1);
} else {
options.ignoreLines = -1;
}
if (this._optionContainerElmts.limitCheckbox[0].checked) {
options.limit = parseIntDefault(this._optionContainerElmts.limitInput[0].value, -1);
} else {
options.limit = -1;
}
if (this._optionContainerElmts.skipCheckbox[0].checked) {
options.skipDataLines = parseIntDefault(this._optionContainerElmts.skipInput[0].value, -1);
} else {
options.skipDataLines = -1;
}
options.storeBlankRows = this._optionContainerElmts.storeBlankRowsCheckbox[0].checked;
options.storeBlankCellsAsNulls = this._optionContainerElmts.storeBlankCellsAsNullsCheckbox[0].checked;
options.includeFileSources = this._optionContainerElmts.includeFileSourcesCheckbox[0].checked;
return options;
};
Refine.LineBasedParserUI.prototype._initialize = function() {
var self = this;
this._optionContainer.unbind().empty().html(
DOM.loadHTML("core", "scripts/index/parser-interfaces/line-based-parser-ui.html"));
this._optionContainerElmts = DOM.bind(this._optionContainer);
this._optionContainerElmts.previewButton.click(function() { self._updatePreview(); });
this._optionContainerElmts.linesPerRowInput[0].value =
this._config.linesPerRow.toString();
var rowSeparatorValue = (this._config.lineSeparator == "\n") ? 'new-line' : 'custom';
this._optionContainer.find(
"input[name='row-separator'][value='" + rowSeparatorValue + "']").attr("checked", "checked");
this._optionContainerElmts.rowSeparatorInput[0].value =
Refine.SeparatorBasedParserUI.encodeSeparator(this._config.lineSeparator);
var self = this;
if (this._config.ignoreLines > 0) {
this._optionContainerElmts.ignoreCheckbox.attr("checked", "checked");
this._optionContainerElmts.ignoreInput[0].value = this._config.ignoreLines.toString();
}
if (this._config.limit > 0) {
this._optionContainerElmts.limitCheckbox.attr("checked", "checked");
this._optionContainerElmts.limitInput[0].value = this._config.limit.toString();
}
if (this._config.skipDataLines > 0) {
this._optionContainerElmts.skipCheckbox.attr("checked", "checked");
this._optionContainerElmts.skipInput.value[0].value = this._config.skipDataLines.toString();
}
if (this._config.storeBlankRows) {
this._optionContainerElmts.storeBlankRowsCheckbox.attr("checked", "checked");
}
if (this._config.storeBlankCellsAsNulls) {
this._optionContainerElmts.storeBlankCellsAsNullsCheckbox.attr("checked", "checked");
}
if (this._config.includeFileSources) {
this._optionContainerElmts.includeFileSourcesCheckbox.attr("checked", "checked");
}
var onChange = function() {
self._scheduleUpdatePreview();
};
this._optionContainer.find("input").bind("change", onChange);
this._optionContainer.find("select").bind("change", onChange);
this._optionContainer.unbind().empty().html(
DOM.loadHTML("core", "scripts/index/parser-interfaces/line-based-parser-ui.html"));
this._optionContainerElmts = DOM.bind(this._optionContainer);
this._optionContainerElmts.previewButton.click(function() { self._updatePreview(); });
this._optionContainerElmts.linesPerRowInput[0].value =
this._config.linesPerRow.toString();
var rowSeparatorValue = (this._config.lineSeparator == "\n") ? 'new-line' : 'custom';
this._optionContainer.find(
"input[name='row-separator'][value='" + rowSeparatorValue + "']").attr("checked", "checked");
this._optionContainerElmts.rowSeparatorInput[0].value =
Refine.SeparatorBasedParserUI.encodeSeparator(this._config.lineSeparator);
if (this._config.ignoreLines > 0) {
this._optionContainerElmts.ignoreCheckbox.attr("checked", "checked");
this._optionContainerElmts.ignoreInput[0].value = this._config.ignoreLines.toString();
}
if (this._config.limit > 0) {
this._optionContainerElmts.limitCheckbox.attr("checked", "checked");
this._optionContainerElmts.limitInput[0].value = this._config.limit.toString();
}
if (this._config.skipDataLines > 0) {
this._optionContainerElmts.skipCheckbox.attr("checked", "checked");
this._optionContainerElmts.skipInput.value[0].value = this._config.skipDataLines.toString();
}
if (this._config.storeBlankRows) {
this._optionContainerElmts.storeBlankRowsCheckbox.attr("checked", "checked");
}
if (this._config.storeBlankCellsAsNulls) {
this._optionContainerElmts.storeBlankCellsAsNullsCheckbox.attr("checked", "checked");
}
if (this._config.includeFileSources) {
this._optionContainerElmts.includeFileSourcesCheckbox.attr("checked", "checked");
}
var onChange = function() {
self._scheduleUpdatePreview();
};
this._optionContainer.find("input").bind("change", onChange);
this._optionContainer.find("select").bind("change", onChange);
};
Refine.LineBasedParserUI.prototype._scheduleUpdatePreview = function() {
if (this._timerID != null) {
window.clearTimeout(this._timerID);
this._timerID = null;
}
var self = this;
this._timerID = window.setTimeout(function() {
self._timerID = null;
self._updatePreview();
}, 500); // 0.5 second
if (this._timerID != null) {
window.clearTimeout(this._timerID);
this._timerID = null;
}
var self = this;
this._timerID = window.setTimeout(function() {
self._timerID = null;
self._updatePreview();
}, 500); // 0.5 second
};
Refine.LineBasedParserUI.prototype._updatePreview = function() {
var self = this;
this._progressContainer.show();
this._controller.updateFormatAndOptions(this.getOptions(), function(result) {
if (result.status == "ok") {
self._controller.getPreviewData(function(projectData) {
self._progressContainer.hide();
new Refine.PreviewTable(projectData, self._dataContainer.unbind().empty());
});
}
});
var self = this;
this._progressContainer.show();
this._controller.updateFormatAndOptions(this.getOptions(), function(result) {
if (result.status == "ok") {
self._controller.getPreviewData(function(projectData) {
self._progressContainer.hide();
new Refine.PreviewTable(projectData, self._dataContainer.unbind().empty());
});
}
});
};

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,87 +29,87 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
Refine.PreviewTable = function(projectData, elmt) {
this._projectData = projectData;
this._elmt = elmt;
this._render();
this._projectData = projectData;
this._elmt = elmt;
this._render();
};
Refine.PreviewTable.prototype._render = function() {
var self = this;
var table = $('<table>').addClass("data-table").appendTo(this._elmt)[0];
var columns = this._projectData.columnModel.columns;
/*------------------------------------------------------------
* Column Headers
*------------------------------------------------------------
*/
var self = this;
var table = $('<table>').addClass("data-table").appendTo(this._elmt)[0];
var columns = this._projectData.columnModel.columns;
/*------------------------------------------------------------
* Column Headers
*------------------------------------------------------------
*/
var trHead = table.insertRow(table.rows.length);
$(trHead.insertCell(0)).addClass("column-header").html('&nbsp;'); // index
var createColumnHeader = function(column) {
$(trHead.insertCell(trHead.cells.length))
.addClass("column-header")
.text(column.name);
};
for (var i = 0; i < columns.length; i++) {
createColumnHeader(columns[i], i);
}
/*------------------------------------------------------------
* Data Cells
*------------------------------------------------------------
*/
var rows = this._projectData.rowModel.rows;
var renderRow = function(tr, r, row, even) {
$(tr).addClass(even ? "even" : "odd");
var cells = row.cells;
var tdIndex = tr.insertCell(tr.cells.length);
$('<div></div>').html((row.i + 1) + ".").appendTo(tdIndex);
var trHead = table.insertRow(table.rows.length);
$(trHead.insertCell(0)).addClass("column-header").html('&nbsp;'); // index
var createColumnHeader = function(column) {
$(trHead.insertCell(trHead.cells.length))
.addClass("column-header")
.text(column.name);
};
for (var i = 0; i < columns.length; i++) {
createColumnHeader(columns[i], i);
}
/*------------------------------------------------------------
* Data Cells
*------------------------------------------------------------
*/
var rows = this._projectData.rowModel.rows;
var renderRow = function(tr, r, row, even) {
$(tr).addClass(even ? "even" : "odd");
var cells = row.cells;
var tdIndex = tr.insertCell(tr.cells.length);
$('<div></div>').html((row.i + 1) + ".").appendTo(tdIndex);
for (var i = 0; i < columns.length; i++) {
var column = columns[i];
var td = tr.insertCell(tr.cells.length);
var divContent = $('<div/>').addClass("data-table-cell-content").appendTo(td);
var cell = (column.cellIndex < cells.length) ? cells[column.cellIndex] : null;
if (!cell || ("v" in cell && cell.v === null)) {
$('<span>').html("&nbsp;").appendTo(divContent);
} else if ("e" in cell) {
$('<span>').addClass("data-table-error").text(cell.e).appendTo(divContent);
} else if (!("r" in cell) || !cell.r) {
if (typeof cell.v !== "string") {
if (typeof cell.v == "number") {
divContent.addClass("data-table-cell-content-numeric");
}
$('<span>')
.addClass("data-table-value-nonstring")
.text(cell.v)
.appendTo(divContent);
} else if (URL.looksLikeUrl(cell.v)) {
$('<a>')
.text(cell.v)
.attr("href", cell.v)
.attr("target", "_blank")
.appendTo(divContent);
} else {
$('<span>').text(cell.v).appendTo(divContent);
}
}
var column = columns[i];
var td = tr.insertCell(tr.cells.length);
var divContent = $('<div/>').addClass("data-table-cell-content").appendTo(td);
var cell = (column.cellIndex < cells.length) ? cells[column.cellIndex] : null;
if (!cell || ("v" in cell && cell.v === null)) {
$('<span>').html("&nbsp;").appendTo(divContent);
} else if ("e" in cell) {
$('<span>').addClass("data-table-error").text(cell.e).appendTo(divContent);
} else if (!("r" in cell) || !cell.r) {
if (typeof cell.v !== "string") {
if (typeof cell.v == "number") {
divContent.addClass("data-table-cell-content-numeric");
}
$('<span>')
.addClass("data-table-value-nonstring")
.text(cell.v)
.appendTo(divContent);
} else if (URL.looksLikeUrl(cell.v)) {
$('<a>')
.text(cell.v)
.attr("href", cell.v)
.attr("target", "_blank")
.appendTo(divContent);
} else {
$('<span>').text(cell.v).appendTo(divContent);
}
};
var even = true;
for (var r = 0; r < rows.length; r++) {
var row = rows[r];
var tr = table.insertRow(table.rows.length);
even = !even;
renderRow(tr, r, row, even);
}
}
}
};
var even = true;
for (var r = 0; r < rows.length; r++) {
var row = rows[r];
var tr = table.insertRow(table.rows.length);
even = !even;
renderRow(tr, r, row, even);
}
};

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,43 +29,43 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
Refine.SeparatorBasedParserUI = function(controller, jobID, job, format, config,
dataContainerElmt, progressContainerElmt, optionContainerElmt) {
this._controller = controller;
this._jobID = jobID;
this._job = job;
this._format = format;
this._config = config;
this._dataContainer = dataContainerElmt;
this._progressContainer = progressContainerElmt;
this._optionContainer = optionContainerElmt;
this._timerID = null;
this._initialize();
this._updatePreview();
this._controller = controller;
this._jobID = jobID;
this._job = job;
this._format = format;
this._config = config;
this._dataContainer = dataContainerElmt;
this._progressContainer = progressContainerElmt;
this._optionContainer = optionContainerElmt;
this._timerID = null;
this._initialize();
this._updatePreview();
};
Refine.DefaultImportingController.parserUIs["SeparatorBasedParserUI"] = Refine.SeparatorBasedParserUI;
Refine.SeparatorBasedParserUI.encodeSeparator = function(s) {
return s.replace("\\", "\\\\")
.replace("\n", "\\n")
.replace("\t", "\\t");
return s.replace("\\", "\\\\")
.replace("\n", "\\n")
.replace("\t", "\\t");
};
Refine.SeparatorBasedParserUI.decodeSeparator = function(s) {
return s.replace("\\n", "\n")
.replace("\\t", "\t")
.replace("\\\\", "\\");
return s.replace("\\n", "\n")
.replace("\\t", "\t")
.replace("\\\\", "\\");
};
Refine.SeparatorBasedParserUI.prototype.dispose = function() {
if (this._timerID != null) {
window.clearTimeout(this._timerID);
this._timerID = null;
}
if (this._timerID != null) {
window.clearTimeout(this._timerID);
this._timerID = null;
}
};
Refine.SeparatorBasedParserUI.prototype.confirmReadyToCreateProject = function() {
@ -73,157 +73,157 @@ Refine.SeparatorBasedParserUI.prototype.confirmReadyToCreateProject = function()
};
Refine.SeparatorBasedParserUI.prototype.getOptions = function() {
var options = {};
switch (this._optionContainer.find("input[name='row-separator']:checked")[0].value) {
case 'new-line':
options.lineSeparator = "\n";
break;
default:
options.lineSeparator = Refine.SeparatorBasedParserUI.decodeSeparator(
this._optionContainerElmts.rowSeparatorInput[0].value);
var options = {};
switch (this._optionContainer.find("input[name='row-separator']:checked")[0].value) {
case 'new-line':
options.lineSeparator = "\n";
break;
default:
options.lineSeparator = Refine.SeparatorBasedParserUI.decodeSeparator(
this._optionContainerElmts.rowSeparatorInput[0].value);
}
switch (this._optionContainer.find("input[name='column-separator']:checked")[0].value) {
case 'comma':
options.separator = ",";
break;
case 'tab':
options.separator = "\t";
break;
default:
options.separator = Refine.SeparatorBasedParserUI.decodeSeparator(
this._optionContainerElmts.columnSeparatorInput[0].value);
}
var parseIntDefault = function(s, def) {
try {
var n = parseInt(s);
if (!isNaN(n)) {
return n;
}
} catch (e) {
// Ignore
}
switch (this._optionContainer.find("input[name='column-separator']:checked")[0].value) {
case 'comma':
options.separator = ",";
break;
case 'tab':
options.separator = "\t";
break;
default:
options.separator = Refine.SeparatorBasedParserUI.decodeSeparator(
this._optionContainerElmts.columnSeparatorInput[0].value);
}
var parseIntDefault = function(s, def) {
try {
var n = parseInt(s);
if (!isNaN(n)) {
return n;
}
} catch (e) {
// Ignore
}
return def;
};
if (this._optionContainerElmts.ignoreCheckbox[0].checked) {
options.ignoreLines = parseIntDefault(this._optionContainerElmts.ignoreInput[0].value, -1);
} else {
options.ignoreLines = -1;
}
if (this._optionContainerElmts.headerLinesCheckbox[0].checked) {
options.headerLines = parseIntDefault(this._optionContainerElmts.headerLinesInput[0].value, 0);
} else {
options.headerLines = 0;
}
if (this._optionContainerElmts.skipCheckbox[0].checked) {
options.skipDataLines = parseIntDefault(this._optionContainerElmts.skipInput[0].value, 0);
} else {
options.skipDataLines = 0;
}
if (this._optionContainerElmts.limitCheckbox[0].checked) {
options.limit = parseIntDefault(this._optionContainerElmts.limitInput[0].value, -1);
} else {
options.limit = -1;
}
options.storeBlankRows = this._optionContainerElmts.storeBlankRowsCheckbox[0].checked;
options.guessCellValueTypes = this._optionContainerElmts.guessCellValueTypesCheckbox[0].checked;
options.processQuotes = this._optionContainerElmts.processQuoteMarksCheckbox[0].checked;
options.storeBlankCellsAsNulls = this._optionContainerElmts.storeBlankCellsAsNullsCheckbox[0].checked;
options.includeFileSources = this._optionContainerElmts.includeFileSourcesCheckbox[0].checked;
return options;
return def;
};
if (this._optionContainerElmts.ignoreCheckbox[0].checked) {
options.ignoreLines = parseIntDefault(this._optionContainerElmts.ignoreInput[0].value, -1);
} else {
options.ignoreLines = -1;
}
if (this._optionContainerElmts.headerLinesCheckbox[0].checked) {
options.headerLines = parseIntDefault(this._optionContainerElmts.headerLinesInput[0].value, 0);
} else {
options.headerLines = 0;
}
if (this._optionContainerElmts.skipCheckbox[0].checked) {
options.skipDataLines = parseIntDefault(this._optionContainerElmts.skipInput[0].value, 0);
} else {
options.skipDataLines = 0;
}
if (this._optionContainerElmts.limitCheckbox[0].checked) {
options.limit = parseIntDefault(this._optionContainerElmts.limitInput[0].value, -1);
} else {
options.limit = -1;
}
options.storeBlankRows = this._optionContainerElmts.storeBlankRowsCheckbox[0].checked;
options.guessCellValueTypes = this._optionContainerElmts.guessCellValueTypesCheckbox[0].checked;
options.processQuotes = this._optionContainerElmts.processQuoteMarksCheckbox[0].checked;
options.storeBlankCellsAsNulls = this._optionContainerElmts.storeBlankCellsAsNullsCheckbox[0].checked;
options.includeFileSources = this._optionContainerElmts.includeFileSourcesCheckbox[0].checked;
return options;
};
Refine.SeparatorBasedParserUI.prototype._initialize = function() {
var self = this;
this._optionContainer.unbind().empty().html(
DOM.loadHTML("core", "scripts/index/parser-interfaces/separator-based-parser-ui.html"));
this._optionContainerElmts = DOM.bind(this._optionContainer);
this._optionContainerElmts.previewButton.click(function() { self._updatePreview(); });
var rowSeparatorValue = (this._config.lineSeparator == "\n") ? 'new-line' : 'custom';
this._optionContainer.find(
"input[name='row-separator'][value='" + rowSeparatorValue + "']").attr("checked", "checked");
this._optionContainerElmts.rowSeparatorInput[0].value =
Refine.SeparatorBasedParserUI.encodeSeparator(this._config.lineSeparator);
var columnSeparatorValue = (this._config.separator == ",") ? 'comma' :
((this._config.separator == "\t") ? 'tab' : 'custom');
this._optionContainer.find(
"input[name='column-separator'][value='" + columnSeparatorValue + "']").attr("checked", "checked");
this._optionContainerElmts.columnSeparatorInput[0].value =
Refine.SeparatorBasedParserUI.encodeSeparator(this._config.separator);
if (this._config.ignoreLines > 0) {
this._optionContainerElmts.ignoreCheckbox.attr("checked", "checked");
this._optionContainerElmts.ignoreInput[0].value = this._config.ignoreLines.toString();
}
if (this._config.headerLines > 0) {
this._optionContainerElmts.headerLinesCheckbox.attr("checked", "checked");
this._optionContainerElmts.headerLinesInput[0].value = this._config.headerLines.toString();
}
if (this._config.limit > 0) {
this._optionContainerElmts.limitCheckbox.attr("checked", "checked");
this._optionContainerElmts.limitInput[0].value = this._config.limit.toString();
}
if (this._config.skipDataLines > 0) {
this._optionContainerElmts.skipCheckbox.attr("checked", "checked");
this._optionContainerElmts.skipInput.value[0].value = this._config.skipDataLines.toString();
}
if (this._config.storeBlankRows) {
this._optionContainerElmts.storeBlankRowsCheckbox.attr("checked", "checked");
}
if (this._config.guessCellValueTypes) {
this._optionContainerElmts.guessCellValueTypesCheckbox.attr("checked", "checked");
}
if (this._config.processQuotes) {
this._optionContainerElmts.processQuoteMarksCheckbox.attr("checked", "checked");
}
if (this._config.storeBlankCellsAsNulls) {
this._optionContainerElmts.storeBlankCellsAsNullsCheckbox.attr("checked", "checked");
}
if (this._config.includeFileSources) {
this._optionContainerElmts.includeFileSourcesCheckbox.attr("checked", "checked");
}
var onChange = function() {
self._scheduleUpdatePreview();
};
this._optionContainer.find("input").bind("change", onChange);
this._optionContainer.find("select").bind("change", onChange);
var self = this;
this._optionContainer.unbind().empty().html(
DOM.loadHTML("core", "scripts/index/parser-interfaces/separator-based-parser-ui.html"));
this._optionContainerElmts = DOM.bind(this._optionContainer);
this._optionContainerElmts.previewButton.click(function() { self._updatePreview(); });
var rowSeparatorValue = (this._config.lineSeparator == "\n") ? 'new-line' : 'custom';
this._optionContainer.find(
"input[name='row-separator'][value='" + rowSeparatorValue + "']").attr("checked", "checked");
this._optionContainerElmts.rowSeparatorInput[0].value =
Refine.SeparatorBasedParserUI.encodeSeparator(this._config.lineSeparator);
var columnSeparatorValue = (this._config.separator == ",") ? 'comma' :
((this._config.separator == "\t") ? 'tab' : 'custom');
this._optionContainer.find(
"input[name='column-separator'][value='" + columnSeparatorValue + "']").attr("checked", "checked");
this._optionContainerElmts.columnSeparatorInput[0].value =
Refine.SeparatorBasedParserUI.encodeSeparator(this._config.separator);
if (this._config.ignoreLines > 0) {
this._optionContainerElmts.ignoreCheckbox.attr("checked", "checked");
this._optionContainerElmts.ignoreInput[0].value = this._config.ignoreLines.toString();
}
if (this._config.headerLines > 0) {
this._optionContainerElmts.headerLinesCheckbox.attr("checked", "checked");
this._optionContainerElmts.headerLinesInput[0].value = this._config.headerLines.toString();
}
if (this._config.limit > 0) {
this._optionContainerElmts.limitCheckbox.attr("checked", "checked");
this._optionContainerElmts.limitInput[0].value = this._config.limit.toString();
}
if (this._config.skipDataLines > 0) {
this._optionContainerElmts.skipCheckbox.attr("checked", "checked");
this._optionContainerElmts.skipInput.value[0].value = this._config.skipDataLines.toString();
}
if (this._config.storeBlankRows) {
this._optionContainerElmts.storeBlankRowsCheckbox.attr("checked", "checked");
}
if (this._config.guessCellValueTypes) {
this._optionContainerElmts.guessCellValueTypesCheckbox.attr("checked", "checked");
}
if (this._config.processQuotes) {
this._optionContainerElmts.processQuoteMarksCheckbox.attr("checked", "checked");
}
if (this._config.storeBlankCellsAsNulls) {
this._optionContainerElmts.storeBlankCellsAsNullsCheckbox.attr("checked", "checked");
}
if (this._config.includeFileSources) {
this._optionContainerElmts.includeFileSourcesCheckbox.attr("checked", "checked");
}
var onChange = function() {
self._scheduleUpdatePreview();
};
this._optionContainer.find("input").bind("change", onChange);
this._optionContainer.find("select").bind("change", onChange);
};
Refine.SeparatorBasedParserUI.prototype._scheduleUpdatePreview = function() {
if (this._timerID != null) {
window.clearTimeout(this._timerID);
this._timerID = null;
}
var self = this;
this._timerID = window.setTimeout(function() {
self._timerID = null;
self._updatePreview();
}, 500); // 0.5 second
if (this._timerID != null) {
window.clearTimeout(this._timerID);
this._timerID = null;
}
var self = this;
this._timerID = window.setTimeout(function() {
self._timerID = null;
self._updatePreview();
}, 500); // 0.5 second
};
Refine.SeparatorBasedParserUI.prototype._updatePreview = function() {
var self = this;
this._progressContainer.show();
this._controller.updateFormatAndOptions(this.getOptions(), function(result) {
if (result.status == "ok") {
self._controller.getPreviewData(function(projectData) {
self._progressContainer.hide();
new Refine.PreviewTable(projectData, self._dataContainer.unbind().empty());
});
}
});
var self = this;
this._progressContainer.show();
this._controller.updateFormatAndOptions(this.getOptions(), function(result) {
if (result.status == "ok") {
self._controller.getPreviewData(function(projectData) {
self._progressContainer.hide();
new Refine.PreviewTable(projectData, self._dataContainer.unbind().empty());
});
}
});
};

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,208 +29,208 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
Refine.XmlParserUI = function(controller, jobID, job, format, config,
dataContainerElmt, progressContainerElmt, optionContainerElmt) {
this._controller = controller;
this._jobID = jobID;
this._job = job;
this._format = format;
this._config = config;
this._dataContainer = dataContainerElmt;
this._progressContainer = progressContainerElmt;
this._optionContainer = optionContainerElmt;
this._timerID = null;
this._initialize();
this._showPickRecordElementsUI();
this._controller = controller;
this._jobID = jobID;
this._job = job;
this._format = format;
this._config = config;
this._dataContainer = dataContainerElmt;
this._progressContainer = progressContainerElmt;
this._optionContainer = optionContainerElmt;
this._timerID = null;
this._initialize();
this._showPickRecordElementsUI();
};
Refine.DefaultImportingController.parserUIs["XmlParserUI"] = Refine.XmlParserUI;
Refine.XmlParserUI.prototype.dispose = function() {
if (this._timerID != null) {
window.clearTimeout(this._timerID);
this._timerID = null;
}
if (this._timerID != null) {
window.clearTimeout(this._timerID);
this._timerID = null;
}
};
Refine.XmlParserUI.prototype.confirmReadyToCreateProject = function() {
if ((this._config.recordPath) && this._config.recordPath.length > 0) {
return true;
return true;
} else {
window.alert('Please specify a record path first.');
window.alert('Please specify a record path first.');
}
};
Refine.XmlParserUI.prototype.getOptions = function() {
var options = {
recordPath: this._config.recordPath
};
if (this._optionContainerElmts.limitCheckbox[0].checked) {
options.limit = parseIntDefault(this._optionContainerElmts.limitInput[0].value, -1);
} else {
options.limit = -1;
}
options.includeFileSources = this._optionContainerElmts.includeFileSourcesCheckbox[0].checked;
return options;
var options = {
recordPath: this._config.recordPath
};
if (this._optionContainerElmts.limitCheckbox[0].checked) {
options.limit = parseIntDefault(this._optionContainerElmts.limitInput[0].value, -1);
} else {
options.limit = -1;
}
options.includeFileSources = this._optionContainerElmts.includeFileSourcesCheckbox[0].checked;
return options;
};
Refine.XmlParserUI.prototype._initialize = function() {
var self = this;
this._optionContainer.unbind().empty().html(
DOM.loadHTML("core", "scripts/index/parser-interfaces/xml-parser-ui.html"));
this._optionContainerElmts = DOM.bind(this._optionContainer);
this._optionContainerElmts.previewButton.click(function() { self._updatePreview(); });
if (this._config.limit > 0) {
this._optionContainerElmts.limitCheckbox.attr("checked", "checked");
this._optionContainerElmts.limitInput[0].value = this._config.limit.toString();
}
if (this._config.includeFileSources) {
this._optionContainerElmts.includeFileSourcesCheckbox.attr("checked", "checked");
}
this._optionContainerElmts.pickRecordElementsButton.click(function() {
self._showPickRecordElementsUI();
});
var onChange = function() {
self._scheduleUpdatePreview();
};
this._optionContainer.find("input").bind("change", onChange);
this._optionContainer.find("select").bind("change", onChange);
var self = this;
this._optionContainer.unbind().empty().html(
DOM.loadHTML("core", "scripts/index/parser-interfaces/xml-parser-ui.html"));
this._optionContainerElmts = DOM.bind(this._optionContainer);
this._optionContainerElmts.previewButton.click(function() { self._updatePreview(); });
if (this._config.limit > 0) {
this._optionContainerElmts.limitCheckbox.attr("checked", "checked");
this._optionContainerElmts.limitInput[0].value = this._config.limit.toString();
}
if (this._config.includeFileSources) {
this._optionContainerElmts.includeFileSourcesCheckbox.attr("checked", "checked");
}
this._optionContainerElmts.pickRecordElementsButton.click(function() {
self._showPickRecordElementsUI();
});
var onChange = function() {
self._scheduleUpdatePreview();
};
this._optionContainer.find("input").bind("change", onChange);
this._optionContainer.find("select").bind("change", onChange);
};
Refine.XmlParserUI.prototype._showPickRecordElementsUI = function() {
var self = this;
this._dataContainer.unbind().empty().html(
DOM.loadHTML("core", "scripts/index/parser-interfaces/xml-parser-select-ui.html"));
var elmts = DOM.bind(this._dataContainer);
var escapeElmt = $('<span>');
var escapeHtml = function(s) {
escapeElmt.empty().text(s);
return escapeElmt.html();
};
var textAsHtml = function(s) {
s = s.length <= 200 ? s : (s.substring(0, 200) + ' ...');
return '<span class="text">' + escapeHtml(s) + '</span>';
};
var renderNode = function(node, container, parentPath) {
if (node.t) {
$('<div>').html(textAsHtml(node.t)).appendTo(container);
var self = this;
this._dataContainer.unbind().empty().html(
DOM.loadHTML("core", "scripts/index/parser-interfaces/xml-parser-select-ui.html"));
var elmts = DOM.bind(this._dataContainer);
var escapeElmt = $('<span>');
var escapeHtml = function(s) {
escapeElmt.empty().text(s);
return escapeElmt.html();
};
var textAsHtml = function(s) {
s = s.length <= 200 ? s : (s.substring(0, 200) + ' ...');
return '<span class="text">' + escapeHtml(s) + '</span>';
};
var renderNode = function(node, container, parentPath) {
if (node.t) {
$('<div>').html(textAsHtml(node.t)).appendTo(container);
} else {
var qname = node.n;
if (node.p) {
qname = node.p + ':' + qname;
}
var t = qname;
if (node.a) {
t += ' ' + $.map(node.a, function(attr) {
return attr.n + '="' + attr.v + '"';
}).join(' ');
}
if (node.ns) {
t += ' ' + $.map(node.ns, function(ns) {
return 'xmlns' + ((ns.p) ? (':' + ns.p) : '') + '="' + ns.uri + '"';
}).join(' ');
}
var path = [].concat(parentPath);
path.push(qname);
var div = $('<div>').addClass('elmt').appendTo(container);
var hasSelectableChildren = false;
var hotspot;
if (node.c) {
if (node.c.length == 1 && (node.c[0].t)) {
$('<span>').html('&lt;' + t + '&gt;' + textAsHtml(node.c[0].t) + '&lt;/' + qname + '&gt;').appendTo(div);
} else {
var qname = node.n;
if (node.p) {
qname = node.p + ':' + qname;
}
var t = qname;
if (node.a) {
t += ' ' + $.map(node.a, function(attr) {
return attr.n + '="' + attr.v + '"';
}).join(' ');
}
if (node.ns) {
t += ' ' + $.map(node.ns, function(ns) {
return 'xmlns' + ((ns.p) ? (':' + ns.p) : '') + '="' + ns.uri + '"';
}).join(' ');
}
var path = [].concat(parentPath);
path.push(qname);
var div = $('<div>').addClass('elmt').appendTo(container);
var hasSelectableChildren = false;
var hotspot;
if (node.c) {
if (node.c.length == 1 && (node.c[0].t)) {
$('<span>').html('&lt;' + t + '&gt;' + textAsHtml(node.c[0].t) + '&lt;/' + qname + '&gt;').appendTo(div);
} else {
$('<div>').text('<' + t + '>').appendTo(div);
$('<div>').text('<' + t + '>').appendTo(div);
var divChildren = $('<div>').addClass('children').appendTo(div);
$.each(node.c, function() {
renderNode(this, divChildren, path);
});
var divChildren = $('<div>').addClass('children').appendTo(div);
$.each(node.c, function() {
renderNode(this, divChildren, path);
});
$('<div>').text('</' + qname + '>').appendTo(div);
hasSelectableChildren = true;
}
} else {
$('<span>').text('<' + t + ' />').appendTo(div);
}
var hittest = function(evt) {
if (hasSelectableChildren) {
if (evt.target !== div[0] &&
(evt.target.className == 'elmt' || evt.target.parentNode !== div[0])) {
return false;
}
}
return true;
};
div.attr('title', '/' + path.join('/'))
.bind('mouseover', function(evt) {
if (hittest(evt)) {
elmts.domContainer.find('.highlight').removeClass('highlight');
div.addClass('highlight');
}
})
.bind('mouseout', function(evt) {
div.removeClass('highlight');
})
.click(function(evt) {
if (hittest(evt)) {
self._setRecordPath(path);
}
});
$('<div>').text('</' + qname + '>').appendTo(div);
hasSelectableChildren = true;
}
};
renderNode(this._config.dom, elmts.domContainer, []);
} else {
$('<span>').text('<' + t + ' />').appendTo(div);
}
var hittest = function(evt) {
if (hasSelectableChildren) {
if (evt.target !== div[0] &&
(evt.target.className == 'elmt' || evt.target.parentNode !== div[0])) {
return false;
}
}
return true;
};
div.attr('title', '/' + path.join('/'))
.bind('mouseover', function(evt) {
if (hittest(evt)) {
elmts.domContainer.find('.highlight').removeClass('highlight');
div.addClass('highlight');
}
})
.bind('mouseout', function(evt) {
div.removeClass('highlight');
})
.click(function(evt) {
if (hittest(evt)) {
self._setRecordPath(path);
}
});
}
};
renderNode(this._config.dom, elmts.domContainer, []);
};
Refine.XmlParserUI.prototype._scheduleUpdatePreview = function() {
if (this._timerID != null) {
window.clearTimeout(this._timerID);
this._timerID = null;
}
var self = this;
this._timerID = window.setTimeout(function() {
self._timerID = null;
self._updatePreview();
}, 500); // 0.5 second
if (this._timerID != null) {
window.clearTimeout(this._timerID);
this._timerID = null;
}
var self = this;
this._timerID = window.setTimeout(function() {
self._timerID = null;
self._updatePreview();
}, 500); // 0.5 second
};
Refine.XmlParserUI.prototype._setRecordPath = function(path) {
this._config.recordPath = path;
this._updatePreview();
this._config.recordPath = path;
this._updatePreview();
};
Refine.XmlParserUI.prototype._updatePreview = function() {
var self = this;
this._progressContainer.show();
var options = this.getOptions();
// for preview, we need exact text, so it's easier to show where the columns are split
options.guessCellValueTypes = false;
this._controller.updateFormatAndOptions(options, function(result) {
if (result.status == "ok") {
self._controller.getPreviewData(function(projectData) {
self._progressContainer.hide();
new Refine.PreviewTable(projectData, self._dataContainer.unbind().empty());
}, 20);
}
});
var self = this;
this._progressContainer.show();
var options = this.getOptions();
// for preview, we need exact text, so it's easier to show where the columns are split
options.guessCellValueTypes = false;
this._controller.updateFormatAndOptions(options, function(result) {
if (result.status == "ok") {
self._controller.getPreviewData(function(projectData) {
self._progressContainer.hide();
new Refine.PreviewTable(projectData, self._dataContainer.unbind().empty());
}, 20);
}
});
};

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,116 +29,121 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
var preferenceUIs = [];
function onLoad() {
$.post(
"/command/core/get-all-preferences",
null,
populatePreferences,
"json"
);
$.post(
"/command/core/get-all-preferences",
null,
populatePreferences,
"json"
);
}
$(onLoad);
function populatePreferences(prefs) {
var body = $("#body-info").empty();
$('<h1>').text("Preferences").appendTo(body);
var table = $('<table>').addClass("list-table").addClass("preferences").html('<tr><th>Key</th><th>Value</th><th></th></tr>').appendTo(body)[0];
for (var k in prefs) {
var tr = table.insertRow(table.rows.length);
preferenceUIs.push(new PreferenceUI(tr, k, prefs[k]));
}
var trLast = table.insertRow(table.rows.length);
var tdLast0 = trLast.insertCell(0);
trLast.insertCell(1);
trLast.insertCell(2);
$('<button class="button">').text("Add Preference").appendTo(tdLast0).click(function() {
var key = window.prompt("Preference key:");
if (key) {
var value = window.prompt("Preference key value:");
if (value != null) {
var tr = table.insertRow(table.rows.length - 1);
preferenceUIs.push(new PreferenceUI(tr, key, value));
$.post(
"/command/core/set-preference",
{
name : key,
value : JSON.stringify(value)
},
function(o) {
if (o.code == "error") {
alert(o.message);
}
},
"json"
);
var body = $("#body-info").empty();
$('<h1>').text("Preferences").appendTo(body);
var table = $('<table>')
.addClass("list-table")
.addClass("preferences")
.html('<tr><th>Key</th><th>Value</th><th></th></tr>')
.appendTo(body)[0];
for (var k in prefs) {
var tr = table.insertRow(table.rows.length);
preferenceUIs.push(new PreferenceUI(tr, k, prefs[k]));
}
var trLast = table.insertRow(table.rows.length);
var tdLast0 = trLast.insertCell(0);
trLast.insertCell(1);
trLast.insertCell(2);
$('<button class="button">').text("Add Preference").appendTo(tdLast0).click(function() {
var key = window.prompt("Preference key:");
if (key) {
var value = window.prompt("Preference key value:");
if (value != null) {
var tr = table.insertRow(table.rows.length - 1);
preferenceUIs.push(new PreferenceUI(tr, key, value));
$.post(
"/command/core/set-preference",
{
name : key,
value : JSON.stringify(value)
},
function(o) {
if (o.code == "error") {
alert(o.message);
}
}
});
},
"json"
);
}
}
});
}
function PreferenceUI(tr, key, value) {
var self = this;
var td0 = tr.insertCell(0);
$(td0).text(key);
var td1 = tr.insertCell(1);
$(td1).text(value != null ? value : "");
var td2 = tr.insertCell(2);
$('<button class="button">').text("Edit").appendTo(td2).click(function() {
var newValue = window.prompt("Change value of preference key " + key, value);
if (newValue != null) {
$(td1).text(newValue);
$.post(
"/command/core/set-preference",
{
name : key,
value : JSON.stringify(newValue)
},
function(o) {
if (o.code == "error") {
alert(o.message);
}
},
"json"
);
}
});
$('<button class="button">').text("Delete").appendTo(td2).click(function() {
if (window.confirm("Delete preference key " + key + "?")) {
$.post(
"/command/core/set-preference",
{
name : key
},
function(o) {
if (o.code == "ok") {
$(tr).remove();
for (var i = 0; i < preferenceUIs.length; i++) {
if (preferenceUIs[i] === self) {
preferenceUIs.splice(i, 1);
break;
}
}
} else if (o.code == "error") {
alert(o.message);
}
},
"json"
);
}
});
var self = this;
var td0 = tr.insertCell(0);
$(td0).text(key);
var td1 = tr.insertCell(1);
$(td1).text(value != null ? value : "");
var td2 = tr.insertCell(2);
$('<button class="button">').text("Edit").appendTo(td2).click(function() {
var newValue = window.prompt("Change value of preference key " + key, value);
if (newValue != null) {
$(td1).text(newValue);
$.post(
"/command/core/set-preference",
{
name : key,
value : JSON.stringify(newValue)
},
function(o) {
if (o.code == "error") {
alert(o.message);
}
},
"json"
);
}
});
$('<button class="button">').text("Delete").appendTo(td2).click(function() {
if (window.confirm("Delete preference key " + key + "?")) {
$.post(
"/command/core/set-preference",
{
name : key
},
function(o) {
if (o.code == "ok") {
$(tr).remove();
for (var i = 0; i < preferenceUIs.length; i++) {
if (preferenceUIs[i] === self) {
preferenceUIs.splice(i, 1);
break;
}
}
} else if (o.code == "error") {
alert(o.message);
}
},
"json"
);
}
});
}

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,402 +29,402 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
var theProject;
var ui = {};
var Refine = {
refineHelperService: "http://1.refine-helper.stefanomazzocchi.user.dev.freebaseapps.com"
refineHelperService: "http://1.refine-helper.stefanomazzocchi.user.dev.freebaseapps.com"
};
Refine.reportException = function(e) {
if (window.console) {
console.log(e);
}
if (window.console) {
console.log(e);
}
};
function resize() {
var header = $("#header");
var leftPanelWidth = 300;
var width = $(window).width();
var top = $("#header").outerHeight();
var height = $(window).height() - top;
var leftPanelPaddings = ui.leftPanelDiv.outerHeight(true) - ui.leftPanelDiv.height();
ui.leftPanelDiv
.css("top", top + "px")
.css("left", "0px")
.css("height", (height - leftPanelPaddings) + "px")
.css("width", leftPanelWidth + "px");
var leftPanelTabsPaddings = ui.leftPanelTabs.outerHeight(true) - ui.leftPanelTabs.height();
ui.leftPanelTabs.height(ui.leftPanelDiv.height() - leftPanelTabsPaddings);
var rightPanelVPaddings = ui.rightPanelDiv.outerHeight(true) - ui.rightPanelDiv.height();
var rightPanelHPaddings = ui.rightPanelDiv.outerWidth(true) - ui.rightPanelDiv.width();
ui.rightPanelDiv
.css("top", top + "px")
.css("left", leftPanelWidth + "px")
.css("height", (height - rightPanelVPaddings) + "px")
.css("width", (width - leftPanelWidth - rightPanelHPaddings) + "px");
ui.viewPanelDiv.height((height - ui.toolPanelDiv.outerHeight() - rightPanelVPaddings) + "px");
var processPanelWidth = 400;
ui.processPanelDiv
.css("width", processPanelWidth + "px")
.css("left", Math.floor((width - processPanelWidth) / 2) + "px");
var header = $("#header");
var leftPanelWidth = 300;
var width = $(window).width();
var top = $("#header").outerHeight();
var height = $(window).height() - top;
var leftPanelPaddings = ui.leftPanelDiv.outerHeight(true) - ui.leftPanelDiv.height();
ui.leftPanelDiv
.css("top", top + "px")
.css("left", "0px")
.css("height", (height - leftPanelPaddings) + "px")
.css("width", leftPanelWidth + "px");
var leftPanelTabsPaddings = ui.leftPanelTabs.outerHeight(true) - ui.leftPanelTabs.height();
ui.leftPanelTabs.height(ui.leftPanelDiv.height() - leftPanelTabsPaddings);
var rightPanelVPaddings = ui.rightPanelDiv.outerHeight(true) - ui.rightPanelDiv.height();
var rightPanelHPaddings = ui.rightPanelDiv.outerWidth(true) - ui.rightPanelDiv.width();
ui.rightPanelDiv
.css("top", top + "px")
.css("left", leftPanelWidth + "px")
.css("height", (height - rightPanelVPaddings) + "px")
.css("width", (width - leftPanelWidth - rightPanelHPaddings) + "px");
ui.viewPanelDiv.height((height - ui.toolPanelDiv.outerHeight() - rightPanelVPaddings) + "px");
var processPanelWidth = 400;
ui.processPanelDiv
.css("width", processPanelWidth + "px")
.css("left", Math.floor((width - processPanelWidth) / 2) + "px");
}
function resizeTabs() {
var totalHeight = ui.leftPanelDiv.height();
var headerHeight = ui.leftPanelTabs.find(".ui-tabs-nav").outerHeight(true);
var visibleTabPanels = ui.leftPanelTabs.find(".ui-tabs-panel:not(.ui-tabs-hide)");
var paddings = visibleTabPanels.outerHeight(true) - visibleTabPanels.height();
var allTabPanels = ui.leftPanelTabs.find(".ui-tabs-panel");
allTabPanels.height(totalHeight - headerHeight - paddings - 1);
var totalHeight = ui.leftPanelDiv.height();
var headerHeight = ui.leftPanelTabs.find(".ui-tabs-nav").outerHeight(true);
var visibleTabPanels = ui.leftPanelTabs.find(".ui-tabs-panel:not(.ui-tabs-hide)");
var paddings = visibleTabPanels.outerHeight(true) - visibleTabPanels.height();
var allTabPanels = ui.leftPanelTabs.find(".ui-tabs-panel");
allTabPanels.height(totalHeight - headerHeight - paddings - 1);
}
function resizeAll() {
resize();
resizeTabs();
ui.extensionBar.resize();
ui.browsingEngine.resize();
ui.processPanel.resize();
ui.historyPanel.resize();
ui.dataTableView.resize();
resize();
resizeTabs();
ui.extensionBar.resize();
ui.browsingEngine.resize();
ui.processPanel.resize();
ui.historyPanel.resize();
ui.dataTableView.resize();
}
function initializeUI(uiState) {
$("#loading-message").hide();
$("#notification-container").hide();
$("#project-title").show();
$("#project-controls").show();
$("#body").show();
$('#project-name-button').click(Refine._renameProject);
$('#project-permalink-button').mouseenter(function() {
this.href = Refine.getPermanentLink();
});
Refine.setTitle();
$("#loading-message").hide();
$("#notification-container").hide();
$("#project-title").show();
$("#project-controls").show();
$("#body").show();
ui = DOM.bind($("#body"));
ui.extensionBar = new ExtensionBar(ui.extensionBarDiv); // construct the menu first so we can resize everything else
ui.exporterManager = new ExporterManager($("#export-button"));
ui.leftPanelTabs.tabs({ selected: 0 });
resize();
resizeTabs();
ui.summaryBar = new SummaryBar(ui.summaryBarDiv);
ui.browsingEngine = new BrowsingEngine(ui.facetPanelDiv, uiState.facets || []);
ui.processPanel = new ProcessPanel(ui.processPanelDiv);
ui.historyPanel = new HistoryPanel(ui.historyPanelDiv, ui.historyTabHeader);
ui.dataTableView = new DataTableView(ui.viewPanelDiv);
ui.leftPanelTabs.bind('tabsshow', function(event, tabs) {
if (tabs.index === 0) {
ui.browsingEngine.resize();
} else if (tabs.index === 1) {
ui.historyPanel.resize();
}
});
$(window).bind("resize", resizeAll);
if (uiState.facets) {
Refine.update({ engineChanged: true });
$('#project-name-button').click(Refine._renameProject);
$('#project-permalink-button').mouseenter(function() {
this.href = Refine.getPermanentLink();
});
Refine.setTitle();
ui = DOM.bind($("#body"));
ui.extensionBar = new ExtensionBar(ui.extensionBarDiv); // construct the menu first so we can resize everything else
ui.exporterManager = new ExporterManager($("#export-button"));
ui.leftPanelTabs.tabs({ selected: 0 });
resize();
resizeTabs();
ui.summaryBar = new SummaryBar(ui.summaryBarDiv);
ui.browsingEngine = new BrowsingEngine(ui.facetPanelDiv, uiState.facets || []);
ui.processPanel = new ProcessPanel(ui.processPanelDiv);
ui.historyPanel = new HistoryPanel(ui.historyPanelDiv, ui.historyTabHeader);
ui.dataTableView = new DataTableView(ui.viewPanelDiv);
ui.leftPanelTabs.bind('tabsshow', function(event, tabs) {
if (tabs.index === 0) {
ui.browsingEngine.resize();
} else if (tabs.index === 1) {
ui.historyPanel.resize();
}
});
$(window).bind("resize", resizeAll);
if (uiState.facets) {
Refine.update({ engineChanged: true });
}
}
Refine.setTitle = function(status) {
var title = theProject.metadata.name + " - Google Refine";
if (status) {
title = status + " - " + title;
}
document.title = title;
$("#project-name-button").text(theProject.metadata.name);
var title = theProject.metadata.name + " - Google Refine";
if (status) {
title = status + " - " + title;
}
document.title = title;
$("#project-name-button").text(theProject.metadata.name);
};
Refine.reinitializeProjectData = function(f) {
Ajax.chainGetJSON(
"/command/core/get-project-metadata?" + $.param({ project: theProject.id }), null,
function(data) {
theProject.metadata = data;
},
"/command/core/get-models?" + $.param({ project: theProject.id }), null,
function(data) {
for (var n in data) {
if (data.hasOwnProperty(n)) {
theProject[n] = data[n];
}
}
},
f
);
Ajax.chainGetJSON(
"/command/core/get-project-metadata?" + $.param({ project: theProject.id }), null,
function(data) {
theProject.metadata = data;
},
"/command/core/get-models?" + $.param({ project: theProject.id }), null,
function(data) {
for (var n in data) {
if (data.hasOwnProperty(n)) {
theProject[n] = data[n];
}
}
},
f
);
};
Refine._renameProject = function() {
var name = window.prompt("New project name:", theProject.metadata.name);
if (name == null) {
return;
}
var name = window.prompt("New project name:", theProject.metadata.name);
if (name == null) {
return;
}
name = $.trim(name);
if (theProject.metadata.name == name || name.length == 0) {
return;
}
name = $.trim(name);
if (theProject.metadata.name == name || name.length == 0) {
return;
}
$.ajax({
type: "POST",
url: "/command/core/rename-project",
data: { "project" : theProject.id, "name" : name },
dataType: "json",
success: function (data) {
if (data && typeof data.code != 'undefined' && data.code == "ok") {
theProject.metadata.name = name;
Refine.setTitle();
} else {
alert("Failed to rename project: " + data.message);
}
}
});
$.ajax({
type: "POST",
url: "/command/core/rename-project",
data: { "project" : theProject.id, "name" : name },
dataType: "json",
success: function (data) {
if (data && typeof data.code != 'undefined' && data.code == "ok") {
theProject.metadata.name = name;
Refine.setTitle();
} else {
alert("Failed to rename project: " + data.message);
}
}
});
};
/*
* Utility state functions
*/
Refine.createUpdateFunction = function(options, onFinallyDone) {
var functions = [];
var pushFunction = function(f) {
var index = functions.length;
functions.push(function() {
f(functions[index + 1]);
});
};
pushFunction(function(onDone) {
ui.historyPanel.update(onDone);
var functions = [];
var pushFunction = function(f) {
var index = functions.length;
functions.push(function() {
f(functions[index + 1]);
});
if (options.everythingChanged || options.modelsChanged || options.columnStatsChanged) {
pushFunction(Refine.reinitializeProjectData);
}
if (options.everythingChanged || options.modelsChanged || options.rowsChanged || options.rowMetadataChanged || options.cellsChanged || options.engineChanged) {
pushFunction(function(onDone) {
ui.dataTableView.update(onDone);
});
pushFunction(function(onDone) {
ui.browsingEngine.update(onDone);
});
}
functions.push(onFinallyDone || function() {});
return functions[0];
};
pushFunction(function(onDone) {
ui.historyPanel.update(onDone);
});
if (options.everythingChanged || options.modelsChanged || options.columnStatsChanged) {
pushFunction(Refine.reinitializeProjectData);
}
if (options.everythingChanged || options.modelsChanged || options.rowsChanged || options.rowMetadataChanged || options.cellsChanged || options.engineChanged) {
pushFunction(function(onDone) {
ui.dataTableView.update(onDone);
});
pushFunction(function(onDone) {
ui.browsingEngine.update(onDone);
});
}
functions.push(onFinallyDone || function() {});
return functions[0];
};
Refine.update = function(options, onFinallyDone) {
var done = false;
var dismissBusy = null;
Refine.setAjaxInProgress();
Refine.createUpdateFunction(options, function() {
Refine.clearAjaxInProgress();
done = true;
if (dismissBusy) {
dismissBusy();
}
if (onFinallyDone) {
onFinallyDone();
}
})();
window.setTimeout(function() {
if (!done) {
dismissBusy = DialogSystem.showBusy();
}
}, 500);
var done = false;
var dismissBusy = null;
Refine.setAjaxInProgress();
Refine.createUpdateFunction(options, function() {
Refine.clearAjaxInProgress();
done = true;
if (dismissBusy) {
dismissBusy();
}
if (onFinallyDone) {
onFinallyDone();
}
})();
window.setTimeout(function() {
if (!done) {
dismissBusy = DialogSystem.showBusy();
}
}, 500);
};
Refine.postCoreProcess = function(command, params, body, updateOptions, callbacks) {
Refine.postProcess("core", command, params, body, updateOptions, callbacks);
Refine.postProcess("core", command, params, body, updateOptions, callbacks);
};
Refine.postProcess = function(moduleName, command, params, body, updateOptions, callbacks) {
updateOptions = updateOptions || {};
callbacks = callbacks || {};
params = params || {};
params.project = theProject.id;
body = body || {};
if (!("includeEngine" in updateOptions) || updateOptions.includeEngine) {
body.engine = JSON.stringify(
"engineConfig" in updateOptions ?
updateOptions.engineConfig :
ui.browsingEngine.getJSON()
);
}
var done = false;
var dismissBusy = null;
function onDone(o) {
done = true;
if (dismissBusy) {
dismissBusy();
}
Refine.clearAjaxInProgress();
if (o.code == "error") {
if ("onError" in callbacks) {
try {
callbacks.onError(o);
} catch (e) {
Refine.reportException(e);
}
} else {
alert(o.message);
}
} else {
if ("onDone" in callbacks) {
try {
callbacks.onDone(o);
} catch (e) {
Refine.reportException(e);
}
}
if (o.code == "ok") {
Refine.update(updateOptions, callbacks.onFinallyDone);
if ("historyEntry" in o) {
ui.processPanel.showUndo(o.historyEntry);
}
} else if (o.code == "pending") {
if ("onPending" in callbacks) {
try {
callbacks.onPending(o);
} catch (e) {
Refine.reportException(e);
}
}
ui.processPanel.update(updateOptions, callbacks.onFinallyDone);
}
}
}
Refine.setAjaxInProgress();
$.post(
"/command/" + moduleName + "/" + command + "?" + $.param(params),
body,
onDone,
"json"
updateOptions = updateOptions || {};
callbacks = callbacks || {};
params = params || {};
params.project = theProject.id;
body = body || {};
if (!("includeEngine" in updateOptions) || updateOptions.includeEngine) {
body.engine = JSON.stringify(
"engineConfig" in updateOptions ?
updateOptions.engineConfig :
ui.browsingEngine.getJSON()
);
window.setTimeout(function() {
if (!done) {
dismissBusy = DialogSystem.showBusy();
}
var done = false;
var dismissBusy = null;
function onDone(o) {
done = true;
if (dismissBusy) {
dismissBusy();
}
Refine.clearAjaxInProgress();
if (o.code == "error") {
if ("onError" in callbacks) {
try {
callbacks.onError(o);
} catch (e) {
Refine.reportException(e);
}
}, 500);
} else {
alert(o.message);
}
} else {
if ("onDone" in callbacks) {
try {
callbacks.onDone(o);
} catch (e) {
Refine.reportException(e);
}
}
if (o.code == "ok") {
Refine.update(updateOptions, callbacks.onFinallyDone);
if ("historyEntry" in o) {
ui.processPanel.showUndo(o.historyEntry);
}
} else if (o.code == "pending") {
if ("onPending" in callbacks) {
try {
callbacks.onPending(o);
} catch (e) {
Refine.reportException(e);
}
}
ui.processPanel.update(updateOptions, callbacks.onFinallyDone);
}
}
}
Refine.setAjaxInProgress();
$.post(
"/command/" + moduleName + "/" + command + "?" + $.param(params),
body,
onDone,
"json"
);
window.setTimeout(function() {
if (!done) {
dismissBusy = DialogSystem.showBusy();
}
}, 500);
};
Refine.setAjaxInProgress = function() {
$(document.body).attr("ajax_in_progress", "true");
$(document.body).attr("ajax_in_progress", "true");
};
Refine.clearAjaxInProgress = function() {
$(document.body).attr("ajax_in_progress", "false");
$(document.body).attr("ajax_in_progress", "false");
};
/*
* Utility model functions
*/
Refine.cellIndexToColumn = function(cellIndex) {
var columns = theProject.columnModel.columns;
for (var i = 0; i < columns.length; i++) {
var column = columns[i];
if (column.cellIndex == cellIndex) {
return column;
}
var columns = theProject.columnModel.columns;
for (var i = 0; i < columns.length; i++) {
var column = columns[i];
if (column.cellIndex == cellIndex) {
return column;
}
return null;
}
return null;
};
Refine.columnNameToColumn = function(columnName) {
var columns = theProject.columnModel.columns;
for (var i = 0; i < columns.length; i++) {
var column = columns[i];
if (column.name == columnName) {
return column;
}
var columns = theProject.columnModel.columns;
for (var i = 0; i < columns.length; i++) {
var column = columns[i];
if (column.name == columnName) {
return column;
}
return null;
}
return null;
};
Refine.columnNameToColumnIndex = function(columnName) {
var columns = theProject.columnModel.columns;
for (var i = 0; i < columns.length; i++) {
var column = columns[i];
if (column.name == columnName) {
return i;
}
var columns = theProject.columnModel.columns;
for (var i = 0; i < columns.length; i++) {
var column = columns[i];
if (column.name == columnName) {
return i;
}
return -1;
}
return -1;
};
Refine.fetchRows = function(start, limit, onDone, sorting) {
var body = {
engine: JSON.stringify(ui.browsingEngine.getJSON())
};
if (sorting) {
body.sorting = JSON.stringify(sorting)
}
$.post(
"/command/core/get-rows?" + $.param({ project: theProject.id, start: start, limit: limit }) + "&callback=?",
body,
function(data) {
theProject.rowModel = data;
// Un-pool objects
for (var r = 0; r < data.rows.length; r++) {
var row = data.rows[r];
for (var c = 0; c < row.cells.length; c++) {
var cell = row.cells[c];
if ((cell) && ("r" in cell)) {
cell.r = data.pool.recons[cell.r];
}
}
}
if (onDone) {
onDone();
}
},
"jsonp"
);
var body = {
engine: JSON.stringify(ui.browsingEngine.getJSON())
};
if (sorting) {
body.sorting = JSON.stringify(sorting)
}
$.post(
"/command/core/get-rows?" + $.param({ project: theProject.id, start: start, limit: limit }) + "&callback=?",
body,
function(data) {
theProject.rowModel = data;
// Un-pool objects
for (var r = 0; r < data.rows.length; r++) {
var row = data.rows[r];
for (var c = 0; c < row.cells.length; c++) {
var cell = row.cells[c];
if ((cell) && ("r" in cell)) {
cell.r = data.pool.recons[cell.r];
}
}
}
if (onDone) {
onDone();
}
},
"jsonp"
);
};
Refine.getPermanentLink = function() {
var params = [
"project=" + escape(theProject.id),
"ui=" + escape(JSON.stringify({
facets: ui.browsingEngine.getFacetUIStates()
}))
];
return "project?" + params.join("&");
var params = [
"project=" + escape(theProject.id),
"ui=" + escape(JSON.stringify({
facets: ui.browsingEngine.getFacetUIStates()
}))
];
return "project?" + params.join("&");
};
/*
@ -432,20 +432,20 @@ Refine.getPermanentLink = function() {
*/
function onLoad() {
var params = URL.getParameters();
if ("project" in params) {
var uiState = {};
if ("ui" in params) {
try {
uiState = JSON.parse(params.ui);
} catch (e) {
}
}
Refine.reinitializeProjectData(function() {
initializeUI(uiState);
});
var params = URL.getParameters();
if ("project" in params) {
var uiState = {};
if ("ui" in params) {
try {
uiState = JSON.parse(params.ui);
} catch (e) {
}
}
Refine.reinitializeProjectData(function() {
initializeUI(uiState);
});
}
}
$(onLoad);

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,270 +29,270 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
function BrowsingEngine(div, facetConfigs) {
this._div = div;
this._mode = theProject.recordModel.hasRecords ? 'record-based' : 'row-based';
this._facets = [];
this._initializeUI();
if (facetConfigs.length > 0) {
for (var i = 0; i < facetConfigs.length; i++) {
var facetConfig = facetConfigs[i];
var type = facetConfig.c.type;
var elmt = this._createFacetContainer();
var facet;
switch (type) {
case "range":
facet = RangeFacet.reconstruct(elmt, facetConfig);
break;
case "timerange":
facet = TimeRangeFacet.reconstruct(elmt, facetConfig);
break;
case "scatterplot":
facet = ScatterplotFacet.reconstruct(elmt, facetConfig);
break;
case "text":
facet = TextSearchFacet.reconstruct(elmt, facetConfig);
break;
default:
facet = ListFacet.reconstruct(elmt, facetConfig);
}
this._facets.push({ elmt: elmt, facet: facet });
}
this._div = div;
this._mode = theProject.recordModel.hasRecords ? 'record-based' : 'row-based';
this._facets = [];
this._initializeUI();
if (facetConfigs.length > 0) {
for (var i = 0; i < facetConfigs.length; i++) {
var facetConfig = facetConfigs[i];
var type = facetConfig.c.type;
var elmt = this._createFacetContainer();
var facet;
switch (type) {
case "range":
facet = RangeFacet.reconstruct(elmt, facetConfig);
break;
case "timerange":
facet = TimeRangeFacet.reconstruct(elmt, facetConfig);
break;
case "scatterplot":
facet = ScatterplotFacet.reconstruct(elmt, facetConfig);
break;
case "text":
facet = TextSearchFacet.reconstruct(elmt, facetConfig);
break;
default:
facet = ListFacet.reconstruct(elmt, facetConfig);
}
this._facets.push({ elmt: elmt, facet: facet });
}
}
}
BrowsingEngine.prototype.resize = function() {
if (this._facets.length > 0) {
var body = this._div.find(".facets-container");
var bodyPaddings = body.outerHeight(true) - body.height();
var height =
this._div.height() -
this._div.find(".browsing-panel-header").outerHeight(true) -
bodyPaddings;
body.css("height", height + "px");
this._elmts.facets.sortable("refresh");
}
if (this._facets.length > 0) {
var body = this._div.find(".facets-container");
var bodyPaddings = body.outerHeight(true) - body.height();
var height =
this._div.height() -
this._div.find(".browsing-panel-header").outerHeight(true) -
bodyPaddings;
body.css("height", height + "px");
this._elmts.facets.sortable("refresh");
}
};
BrowsingEngine.prototype.getFacetUIStates = function() {
var f = [];
for (var i = 0; i < this._facets.length; i++) {
var facet = this._facets[i];
f.push(facet.facet.getUIState());
}
return f;
var f = [];
for (var i = 0; i < this._facets.length; i++) {
var facet = this._facets[i];
f.push(facet.facet.getUIState());
}
return f;
};
BrowsingEngine.prototype._initializeUI = function() {
var self = this;
this._div.html(
'<div class="browsing-panel-help" bind="help">' +
'<h1>Using facets and filters</h1>' +
'<p>Use facets and filters to select subsets of your data to act on. Choose facet and filter methods from the menus at the top of each data column.</p>' +
'<p>Not sure how to get started?<br /><a href="http://code.google.com/p/google-refine/wiki/Screencasts" target="_blank"><b>Watch these screencasts</b></a></p>' +
'</div>' +
'<div class="browsing-panel-header" bind="header">' +
'<div class="browsing-panel-indicator" bind="indicator">' +
'<img src="images/small-spinner.gif" /> Refreshing facets...' +
'</div>' +
'<div class="browsing-panel-controls" bind="controls">' +
'<div class="browsing-panel-controls-refresh">' +
'<a href="javascript:{}" bind="refreshLink" class="button" title="Update all facets">Refresh</a>' +
'</div>' +
'<a href="javascript:{}" bind="resetLink" class="button button-pill-left" title="Clear selection in all facets">Reset All</a>' +
'<a href="javascript:{}" bind="removeLink" class="button button-pill-right" title="Remove all facets">Remove All</a>' +
'</div>' +
'</div>' +
'<ul bind="facets" class="facets-container"></ul>'
);
this._elmts = DOM.bind(this._div);
this._elmts.facets.sortable({
handle: '.facet-title',
update: function(event, ui) {
self._updateFacetOrder();
}
});
this._elmts.refreshLink.click(function() { self.update(); });
this._elmts.resetLink.click(function() { self.reset(); });
this._elmts.removeLink.click(function() { self.remove(); });
var self = this;
this._div.html(
'<div class="browsing-panel-help" bind="help">' +
'<h1>Using facets and filters</h1>' +
'<p>Use facets and filters to select subsets of your data to act on. Choose facet and filter methods from the menus at the top of each data column.</p>' +
'<p>Not sure how to get started?<br /><a href="http://code.google.com/p/google-refine/wiki/Screencasts" target="_blank"><b>Watch these screencasts</b></a></p>' +
'</div>' +
'<div class="browsing-panel-header" bind="header">' +
'<div class="browsing-panel-indicator" bind="indicator">' +
'<img src="images/small-spinner.gif" /> Refreshing facets...' +
'</div>' +
'<div class="browsing-panel-controls" bind="controls">' +
'<div class="browsing-panel-controls-refresh">' +
'<a href="javascript:{}" bind="refreshLink" class="button" title="Update all facets">Refresh</a>' +
'</div>' +
'<a href="javascript:{}" bind="resetLink" class="button button-pill-left" title="Clear selection in all facets">Reset All</a>' +
'<a href="javascript:{}" bind="removeLink" class="button button-pill-right" title="Remove all facets">Remove All</a>' +
'</div>' +
'</div>' +
'<ul bind="facets" class="facets-container"></ul>'
);
this._elmts = DOM.bind(this._div);
this._elmts.facets.sortable({
handle: '.facet-title',
update: function(event, ui) {
self._updateFacetOrder();
}
});
this._elmts.refreshLink.click(function() { self.update(); });
this._elmts.resetLink.click(function() { self.reset(); });
this._elmts.removeLink.click(function() { self.remove(); });
};
BrowsingEngine.prototype._updateFacetOrder = function() {
var elmts = this._elmts.facets.children();
var newFacets = [];
for (var e = 0; e < elmts.length; e++) {
var elmt = elmts[e];
for (var f = 0; f < this._facets.length; f++) {
if (elmt === this._facets[f].elmt[0]) {
newFacets.push(this._facets[f]);
break;
}
}
var elmts = this._elmts.facets.children();
var newFacets = [];
for (var e = 0; e < elmts.length; e++) {
var elmt = elmts[e];
for (var f = 0; f < this._facets.length; f++) {
if (elmt === this._facets[f].elmt[0]) {
newFacets.push(this._facets[f]);
break;
}
}
this._facets = newFacets;
}
this._facets = newFacets;
};
BrowsingEngine.prototype.getMode = function() {
return this._mode;
return this._mode;
};
BrowsingEngine.prototype.setMode = function(mode) {
if (this._mode != mode) {
this._mode = mode;
Refine.update({ engineChanged: true });
}
if (this._mode != mode) {
this._mode = mode;
Refine.update({ engineChanged: true });
}
};
BrowsingEngine.prototype.getJSON = function(keepUnrestrictedFacets, except) {
var a = {
facets: [],
mode: this._mode
};
for (var i = 0; i < this._facets.length; i++) {
var facet = this._facets[i];
if ((keepUnrestrictedFacets || facet.facet.hasSelection()) && (facet.facet !== except)) {
a.facets.push(facet.facet.getJSON());
}
var a = {
facets: [],
mode: this._mode
};
for (var i = 0; i < this._facets.length; i++) {
var facet = this._facets[i];
if ((keepUnrestrictedFacets || facet.facet.hasSelection()) && (facet.facet !== except)) {
a.facets.push(facet.facet.getJSON());
}
return a;
}
return a;
};
BrowsingEngine.prototype.addFacet = function(type, config, options) {
var elmt = this._createFacetContainer();
var facet;
switch (type) {
case "range":
facet = new RangeFacet(elmt, config, options);
break;
case "timerange":
facet = new TimeRangeFacet(elmt, config, options);
break;
case "scatterplot":
facet = new ScatterplotFacet(elmt, config, options);
break;
case "text":
facet = new TextSearchFacet(elmt, config, options);
break;
default:
facet = new ListFacet(elmt, config, options);
}
this._facets.push({ elmt: elmt, facet: facet });
ui.leftPanelTabs.tabs("select", 0);
Refine.update({ engineChanged: true });
var elmt = this._createFacetContainer();
var facet;
switch (type) {
case "range":
facet = new RangeFacet(elmt, config, options);
break;
case "timerange":
facet = new TimeRangeFacet(elmt, config, options);
break;
case "scatterplot":
facet = new ScatterplotFacet(elmt, config, options);
break;
case "text":
facet = new TextSearchFacet(elmt, config, options);
break;
default:
facet = new ListFacet(elmt, config, options);
}
this._facets.push({ elmt: elmt, facet: facet });
ui.leftPanelTabs.tabs("select", 0);
Refine.update({ engineChanged: true });
};
BrowsingEngine.prototype._createFacetContainer = function() {
return $('<li></li>').addClass("facet-container").attr("id","facet-" + this._facets.length).hide().appendTo(this._elmts.facets);
return $('<li></li>').addClass("facet-container").attr("id","facet-" + this._facets.length).hide().appendTo(this._elmts.facets);
};
BrowsingEngine.prototype.removeFacet = function(facet) {
var update = facet.hasSelection();
for (var i = this._facets.length - 1;i >= 0; i--) {
var facetRecord = this._facets[i];
if (facetRecord.facet === facet) {
this._facets.splice(i, 1);
facetRecord.facet.dispose();
// This makes really big facet disappear right away. If you just call remove()
// then it takes a while for all the event handlers to get unwired, and the UI
// appear frozen.
facetRecord.elmt.hide();
window.setTimeout(function() {
facetRecord.elmt.remove();
}, 300);
break;
}
}
var update = facet.hasSelection();
for (var i = this._facets.length - 1;i >= 0; i--) {
var facetRecord = this._facets[i];
if (facetRecord.facet === facet) {
this._facets.splice(i, 1);
for (var i = 0; i < this._facets.length; i++) {
if (typeof this._facets[i].facet.update == "function") {
this._facets[i].facet.update();
}
facetRecord.facet.dispose();
// This makes really big facet disappear right away. If you just call remove()
// then it takes a while for all the event handlers to get unwired, and the UI
// appear frozen.
facetRecord.elmt.hide();
window.setTimeout(function() {
facetRecord.elmt.remove();
}, 300);
break;
}
if (update) {
Refine.update({ engineChanged: true });
} else if (this._facets.length == 0) {
this._elmts.help.show();
this._elmts.header.hide();
}
for (var i = 0; i < this._facets.length; i++) {
if (typeof this._facets[i].facet.update == "function") {
this._facets[i].facet.update();
}
}
if (update) {
Refine.update({ engineChanged: true });
} else if (this._facets.length == 0) {
this._elmts.help.show();
this._elmts.header.hide();
}
};
BrowsingEngine.prototype.update = function(onDone) {
var self = this;
this._elmts.help.hide();
this._elmts.header.show();
this._elmts.controls.css("visibility", "hidden");
this._elmts.indicator.css("visibility", "visible");
$.post(
"/command/core/compute-facets?" + $.param({ project: theProject.id }),
{ engine: JSON.stringify(this.getJSON(true)) },
function(data) {
var facetData = data.facets;
for (var i = 0; i < facetData.length; i++) {
self._facets[i].facet.updateState(facetData[i]);
}
self._elmts.indicator.css("visibility", "hidden");
if (self._facets.length > 0) {
self._elmts.header.show();
self._elmts.controls.css("visibility", "visible");
self.resize();
} else {
self._elmts.help.show();
}
if (onDone) {
onDone();
}
},
"json"
);
var self = this;
this._elmts.help.hide();
this._elmts.header.show();
this._elmts.controls.css("visibility", "hidden");
this._elmts.indicator.css("visibility", "visible");
$.post(
"/command/core/compute-facets?" + $.param({ project: theProject.id }),
{ engine: JSON.stringify(this.getJSON(true)) },
function(data) {
var facetData = data.facets;
for (var i = 0; i < facetData.length; i++) {
self._facets[i].facet.updateState(facetData[i]);
}
self._elmts.indicator.css("visibility", "hidden");
if (self._facets.length > 0) {
self._elmts.header.show();
self._elmts.controls.css("visibility", "visible");
self.resize();
} else {
self._elmts.help.show();
}
if (onDone) {
onDone();
}
},
"json"
);
};
BrowsingEngine.prototype.reset = function() {
for (var i = 0; i < this._facets.length; i++) {
this._facets[i].facet.reset();
}
Refine.update({ engineChanged: true });
for (var i = 0; i < this._facets.length; i++) {
this._facets[i].facet.reset();
}
Refine.update({ engineChanged: true });
};
BrowsingEngine.prototype.remove = function() {
var oldFacets = this._facets;
this._facets = [];
var oldFacets = this._facets;
this._facets = [];
for (var i = 0; i < oldFacets.length; i++) {
var facet = oldFacets[i];
facet.facet.dispose();
facet.elmt.hide();
}
window.setTimeout(function() {
for (var i = 0; i < oldFacets.length; i++) {
var facet = oldFacets[i];
facet.facet.dispose();
facet.elmt.hide();
oldFacets[i].elmt.remove();
}
window.setTimeout(function() {
for (var i = 0; i < oldFacets.length; i++) {
oldFacets[i].elmt.remove();
}
}, 300);
Refine.update({ engineChanged: true });
}, 300);
Refine.update({ engineChanged: true });
};

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,133 +29,133 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
function ExporterManager(button) {
this._button = button;
this._initializeUI();
this._button = button;
this._initializeUI();
}
ExporterManager.handlers = {};
ExporterManager.MenuItems = [
{
"id" : "core/export-project",
"label": "Export project",
"click": function() { ExporterManager.handlers.exportProject(); }
},
{},
{
"id" : "core/export-tsv",
"label": "Tab-separated value",
"click": function() { ExporterManager.handlers.exportRows("tsv", "tsv"); }
},
{
"id" : "core/export-csv",
"label": "Comma-separated value",
"click": function() { ExporterManager.handlers.exportRows("csv", "csv"); }
},
{
"id" : "core/export-html-table",
"label": "HTML table",
"click": function() { ExporterManager.handlers.exportRows("html", "html"); }
},
{
"id" : "core/export-excel",
"label": "Excel",
"click": function() { ExporterManager.handlers.exportRows("xls", "xls"); }
},
{},
{
"id" : "core/export-tripleloader",
"label": "Triple loader",
"click": function() { ExporterManager.handlers.exportTripleloader("tripleloader"); }
},
{
"id" : "core/export-mqlwrite",
"label": "MQLWrite",
"click": function() { ExporterManager.handlers.exportTripleloader("mqlwrite"); }
},
{},
{
"id" : "core/export-templating",
"label": "Templating...",
"click": function() { new TemplatingExporterDialog(); }
}
{
"id" : "core/export-project",
"label": "Export project",
"click": function() { ExporterManager.handlers.exportProject(); }
},
{},
{
"id" : "core/export-tsv",
"label": "Tab-separated value",
"click": function() { ExporterManager.handlers.exportRows("tsv", "tsv"); }
},
{
"id" : "core/export-csv",
"label": "Comma-separated value",
"click": function() { ExporterManager.handlers.exportRows("csv", "csv"); }
},
{
"id" : "core/export-html-table",
"label": "HTML table",
"click": function() { ExporterManager.handlers.exportRows("html", "html"); }
},
{
"id" : "core/export-excel",
"label": "Excel",
"click": function() { ExporterManager.handlers.exportRows("xls", "xls"); }
},
{},
{
"id" : "core/export-tripleloader",
"label": "Triple loader",
"click": function() { ExporterManager.handlers.exportTripleloader("tripleloader"); }
},
{
"id" : "core/export-mqlwrite",
"label": "MQLWrite",
"click": function() { ExporterManager.handlers.exportTripleloader("mqlwrite"); }
},
{},
{
"id" : "core/export-templating",
"label": "Templating...",
"click": function() { new TemplatingExporterDialog(); }
}
];
ExporterManager.prototype._initializeUI = function() {
this._button.click(function(evt) {
MenuSystem.createAndShowStandardMenu(
ExporterManager.MenuItems,
this,
{ horizontal: false }
);
evt.preventDefault();
return false;
});
this._button.click(function(evt) {
MenuSystem.createAndShowStandardMenu(
ExporterManager.MenuItems,
this,
{ horizontal: false }
);
evt.preventDefault();
return false;
});
};
ExporterManager.handlers.exportTripleloader = function(format) {
if (!theProject.overlayModels.freebaseProtograph) {
alert(
"You haven't done any schema alignment yet,\nso there is no triple to export.\n\n" +
"Use the Freebase > Edit Schema Alignment Skeleton...\ncommand to align your data with Freebase schemas first."
);
} else {
ExporterManager.handlers.exportRows(format, "txt");
}
if (!theProject.overlayModels.freebaseProtograph) {
alert(
"You haven't done any schema alignment yet,\nso there is no triple to export.\n\n" +
"Use the Freebase > Edit Schema Alignment Skeleton...\ncommand to align your data with Freebase schemas first."
);
} else {
ExporterManager.handlers.exportRows(format, "txt");
}
};
ExporterManager.handlers.exportRows = function(format, ext) {
var name = $.trim(theProject.metadata.name.replace(/\W/g, ' ')).replace(/\s+/g, '-');
var form = document.createElement("form");
$(form)
.css("display", "none")
.attr("method", "post")
.attr("action", "/command/core/export-rows/" + name + "." + ext)
.attr("target", "refine-export");
var name = $.trim(theProject.metadata.name.replace(/\W/g, ' ')).replace(/\s+/g, '-');
var form = document.createElement("form");
$(form)
.css("display", "none")
.attr("method", "post")
.attr("action", "/command/core/export-rows/" + name + "." + ext)
.attr("target", "refine-export");
$('<input />')
.attr("name", "engine")
.attr("value", JSON.stringify(ui.browsingEngine.getJSON()))
.appendTo(form);
$('<input />')
.attr("name", "project")
.attr("value", theProject.id)
.appendTo(form);
$('<input />')
.attr("name", "format")
.attr("value", format)
.appendTo(form);
$('<input />')
.attr("name", "engine")
.attr("value", JSON.stringify(ui.browsingEngine.getJSON()))
.appendTo(form);
$('<input />')
.attr("name", "project")
.attr("value", theProject.id)
.appendTo(form);
$('<input />')
.attr("name", "format")
.attr("value", format)
.appendTo(form);
document.body.appendChild(form);
document.body.appendChild(form);
window.open("about:blank", "refine-export");
form.submit();
document.body.removeChild(form);
window.open("about:blank", "refine-export");
form.submit();
document.body.removeChild(form);
};
ExporterManager.handlers.exportProject = function() {
var name = $.trim(theProject.metadata.name.replace(/\W/g, ' ')).replace(/\s+/g, '-');
var form = document.createElement("form");
$(form)
.css("display", "none")
.attr("method", "post")
.attr("action", "/command/core/export-project/" + name + ".google-refine.tar.gz")
.attr("target", "refine-export");
$('<input />')
.attr("name", "project")
.attr("value", theProject.id)
.appendTo(form);
var name = $.trim(theProject.metadata.name.replace(/\W/g, ' ')).replace(/\s+/g, '-');
var form = document.createElement("form");
$(form)
.css("display", "none")
.attr("method", "post")
.attr("action", "/command/core/export-project/" + name + ".google-refine.tar.gz")
.attr("target", "refine-export");
$('<input />')
.attr("name", "project")
.attr("value", theProject.id)
.appendTo(form);
document.body.appendChild(form);
document.body.appendChild(form);
window.open("about:blank", "refine-export");
form.submit();
window.open("about:blank", "refine-export");
form.submit();
document.body.removeChild(form);
document.body.removeChild(form);
};

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,61 +29,61 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
function ExtensionBar(div) {
this._div = div;
this._initializeUI();
this._div = div;
this._initializeUI();
}
ExtensionBar.MenuItems = [
];
ExtensionBar.addExtensionMenu = function(what) {
MenuSystem.appendTo(ExtensionBar.MenuItems, [], what);
MenuSystem.appendTo(ExtensionBar.MenuItems, [], what);
}
ExtensionBar.appendTo = function(path, what) {
MenuSystem.appendTo(ExtensionBar.MenuItems, path, what);
MenuSystem.appendTo(ExtensionBar.MenuItems, path, what);
};
ExtensionBar.insertBefore = function(path, what) {
MenuSystem.insertBefore(ExtensionBar.MenuItems, path, what);
MenuSystem.insertBefore(ExtensionBar.MenuItems, path, what);
};
ExtensionBar.insertAfter = function(path, what) {
MenuSystem.insertAfter(ExtensionBar.MenuItems, path, what);
MenuSystem.insertAfter(ExtensionBar.MenuItems, path, what);
};
ExtensionBar.prototype.resize = function() {
};
ExtensionBar.prototype._initializeUI = function() {
var elmts = DOM.bind(this._div);
for (var i = 0; i < ExtensionBar.MenuItems.length; i++) {
var menuItem = ExtensionBar.MenuItems[i];
var menuButton = this._createMenuButton(menuItem.label, menuItem.submenu);
elmts.menuContainer.append(menuButton);
}
var elmts = DOM.bind(this._div);
for (var i = 0; i < ExtensionBar.MenuItems.length; i++) {
var menuItem = ExtensionBar.MenuItems[i];
var menuButton = this._createMenuButton(menuItem.label, menuItem.submenu);
elmts.menuContainer.append(menuButton);
}
};
ExtensionBar.prototype._createMenuButton = function(label, submenu) {
var self = this;
var self = this;
var menuItem = $("<a>").addClass("button").append('<span class="button-menu">' + label + '</span>');
menuItem.click(function(evt) {
MenuSystem.createAndShowStandardMenu(
submenu,
this,
{ horizontal: false }
);
var menuItem = $("<a>").addClass("button").append('<span class="button-menu">' + label + '</span>');
evt.preventDefault();
return false;
});
return menuItem;
menuItem.click(function(evt) {
MenuSystem.createAndShowStandardMenu(
submenu,
this,
{ horizontal: false }
);
evt.preventDefault();
return false;
});
return menuItem;
};
ExtensionBar.handlers = {};

View File

@ -1,7 +1,7 @@
<div class="history-panel-help" bind="helpDiv">
<h1>Infinite undo history</h1>
<p>Don't worry about making mistakes. Every change you make will be shown here, and you can undo your changes anytime.</p>
<p><a href="http://code.google.com/p/google-refine/wiki/History" target="_blank"><b>Learn more &raquo;</b></a></p>
<h1>Infinite undo history</h1>
<p>Don't worry about making mistakes. Every change you make will be shown here, and you can undo your changes anytime.</p>
<p><a href="http://code.google.com/p/google-refine/wiki/History" target="_blank"><b>Learn more &raquo;</b></a></p>
</div>
<div class="history-panel-controls" bind="controlsDiv">
<a class="button button-pill-left" href="javascript:{}" bind="extractLink">Extract&hellip;</a><a class="button button-pill-right" href="javascript:{}" bind="applyLink">Apply&hellip;</a>
@ -10,11 +10,11 @@
Filter: <input type="text" size="30" bind="filterInput" />
</div>
<div class="history-panel-body" bind="bodyDiv">
<div class="history-past" bind="pastDiv">
<div class="history-highlight" bind="pastHighlightDiv"></div>
</div>
<div class="history-now" bind="nowDiv"></div>
<div class="history-future" bind="futureDiv">
<div class="history-highlight" bind="futureHighlightDiv"></div>
</div>
<div class="history-past" bind="pastDiv">
<div class="history-highlight" bind="pastHighlightDiv"></div>
</div>
<div class="history-now" bind="nowDiv"></div>
<div class="history-future" bind="futureDiv">
<div class="history-highlight" bind="futureHighlightDiv"></div>
</div>
</div>'

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,275 +29,275 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
function HistoryPanel(div, tabHeader) {
this._div = div;
this._tabHeader = tabHeader;
this.update();
this._div = div;
this._tabHeader = tabHeader;
this.update();
}
HistoryPanel.prototype.resize = function() {
var body = this._div.find(".history-panel-body");
var controls = this._div.find(".history-panel-controls");
var bodyControls = this._div.find(".history-panel-filter");
var nowDiv = this._div.find(".history-now");
var bodyPaddings = body.outerHeight(true) - body.height();
body.height((this._div.height() - controls.outerHeight(true) - bodyControls.outerHeight(true) - bodyPaddings) + "px");
body[0].scrollTop =
nowDiv[0].offsetTop +
nowDiv[0].offsetHeight -
body[0].offsetHeight;
var body = this._div.find(".history-panel-body");
var controls = this._div.find(".history-panel-controls");
var bodyControls = this._div.find(".history-panel-filter");
var nowDiv = this._div.find(".history-now");
var bodyPaddings = body.outerHeight(true) - body.height();
body.height((this._div.height() - controls.outerHeight(true) - bodyControls.outerHeight(true) - bodyPaddings) + "px");
body[0].scrollTop =
nowDiv[0].offsetTop +
nowDiv[0].offsetHeight -
body[0].offsetHeight;
};
HistoryPanel.prototype.update = function(onDone) {
var self = this;
Ajax.chainGetJSON(
"/command/core/get-history?" + $.param({ project: theProject.id }), null,
function(data) {
self._data = data;
self._render();
if (onDone) {
onDone();
}
}
);
var self = this;
Ajax.chainGetJSON(
"/command/core/get-history?" + $.param({ project: theProject.id }), null,
function(data) {
self._data = data;
self._render();
if (onDone) {
onDone();
}
}
);
};
HistoryPanel.prototype._render = function() {
var self = this;
this._tabHeader.html('Undo / Redo <span class="count">' + this._data.past.length + '</span>');
this._div.empty().unbind().html(DOM.loadHTML("core", "scripts/project/history-panel.html"));
var elmts = DOM.bind(this._div);
var renderEntry = function(container, index, entry, lastDoneID, past) {
var a = $(DOM.loadHTML("core", "scripts/project/history-entry.html")).appendTo(container);
if (lastDoneID >= 0) {
a.attr("href", "javascript:{}")
.click(function(evt) {
return self._onClickHistoryEntry(evt, entry, lastDoneID);
})
.mouseover(function() {
if (past) {
elmts.pastHighlightDiv.show().height(elmts.pastDiv.height() - this.offsetTop - this.offsetHeight);
} else {
elmts.futureHighlightDiv.show().height(this.offsetTop + this.offsetHeight);
}
})
.mouseout(function() {
if (past) {
elmts.pastHighlightDiv.hide();
} else {
elmts.futureHighlightDiv.hide();
}
});
}
a[0].childNodes[0].appendChild(document.createTextNode(index + "."));
a[0].childNodes[1].appendChild(document.createTextNode(entry.description));
return a;
};
if (this._data.past.length > 0 || this._data.future.length > 0) {
if (!this._data.past.length) {
renderEntry(elmts.nowDiv, 0, {
description: "Create project"
}, 0, true);
} else {
renderEntry(elmts.pastDiv, 0, {
description: "Create project"
}, 0, true);
var self = this;
for (var i = 0; i < this._data.past.length - 1; i++) {
var entry = this._data.past[i];
renderEntry(elmts.pastDiv, i + 1, entry, entry.id, true);
}
renderEntry(elmts.nowDiv, this._data.past.length, this._data.past[this._data.past.length - 1], -1);
this._tabHeader.html('Undo / Redo <span class="count">' + this._data.past.length + '</span>');
this._div.empty().unbind().html(DOM.loadHTML("core", "scripts/project/history-panel.html"));
var elmts = DOM.bind(this._div);
var renderEntry = function(container, index, entry, lastDoneID, past) {
var a = $(DOM.loadHTML("core", "scripts/project/history-entry.html")).appendTo(container);
if (lastDoneID >= 0) {
a.attr("href", "javascript:{}")
.click(function(evt) {
return self._onClickHistoryEntry(evt, entry, lastDoneID);
})
.mouseover(function() {
if (past) {
elmts.pastHighlightDiv.show().height(elmts.pastDiv.height() - this.offsetTop - this.offsetHeight);
} else {
elmts.futureHighlightDiv.show().height(this.offsetTop + this.offsetHeight);
}
if (this._data.future.length) {
for (var i = 0; i < this._data.future.length; i++) {
var entry = this._data.future[i];
renderEntry(elmts.futureDiv, this._data.past.length + i + 1, entry, entry.id, false);
}
})
.mouseout(function() {
if (past) {
elmts.pastHighlightDiv.hide();
} else {
elmts.futureHighlightDiv.hide();
}
elmts.helpDiv.hide();
elmts.filterInput.keyup(function() {
var filter = $.trim(this.value.toLowerCase());
if (filter.length == 0) {
elmts.bodyDiv.find(".history-entry").removeClass("filtered-out");
} else {
elmts.bodyDiv.find(".history-entry").each(function() {
var text = this.childNodes[1].firstChild.nodeValue;
if (text.toLowerCase().indexOf(filter) >= 0) {
$(this).removeClass("filtered-out");
} else {
$(this).addClass("filtered-out");
}
});
}
});
} else {
elmts.bodyDiv.hide();
elmts.bodyControlsDiv.hide();
});
}
elmts.extractLink.click(function() { self._extractOperations(); });
elmts.applyLink.click(function() { self._showApplyOperationsDialog(); });
this.resize();
a[0].childNodes[0].appendChild(document.createTextNode(index + "."));
a[0].childNodes[1].appendChild(document.createTextNode(entry.description));
return a;
};
if (this._data.past.length > 0 || this._data.future.length > 0) {
if (!this._data.past.length) {
renderEntry(elmts.nowDiv, 0, {
description: "Create project"
}, 0, true);
} else {
renderEntry(elmts.pastDiv, 0, {
description: "Create project"
}, 0, true);
for (var i = 0; i < this._data.past.length - 1; i++) {
var entry = this._data.past[i];
renderEntry(elmts.pastDiv, i + 1, entry, entry.id, true);
}
renderEntry(elmts.nowDiv, this._data.past.length, this._data.past[this._data.past.length - 1], -1);
}
if (this._data.future.length) {
for (var i = 0; i < this._data.future.length; i++) {
var entry = this._data.future[i];
renderEntry(elmts.futureDiv, this._data.past.length + i + 1, entry, entry.id, false);
}
}
elmts.helpDiv.hide();
elmts.filterInput.keyup(function() {
var filter = $.trim(this.value.toLowerCase());
if (filter.length == 0) {
elmts.bodyDiv.find(".history-entry").removeClass("filtered-out");
} else {
elmts.bodyDiv.find(".history-entry").each(function() {
var text = this.childNodes[1].firstChild.nodeValue;
if (text.toLowerCase().indexOf(filter) >= 0) {
$(this).removeClass("filtered-out");
} else {
$(this).addClass("filtered-out");
}
});
}
});
} else {
elmts.bodyDiv.hide();
elmts.bodyControlsDiv.hide();
}
elmts.extractLink.click(function() { self._extractOperations(); });
elmts.applyLink.click(function() { self._showApplyOperationsDialog(); });
this.resize();
};
HistoryPanel.prototype._onClickHistoryEntry = function(evt, entry, lastDoneID) {
var self = this;
Refine.postCoreProcess(
"undo-redo",
{ lastDoneID: lastDoneID },
null,
{ everythingChanged: true }
);
var self = this;
Refine.postCoreProcess(
"undo-redo",
{ lastDoneID: lastDoneID },
null,
{ everythingChanged: true }
);
};
HistoryPanel.prototype._extractOperations = function() {
var self = this;
$.getJSON(
"/command/core/get-operations?" + $.param({ project: theProject.id }),
null,
function(data) {
if ("entries" in data) {
self._showExtractOperationsDialog(data);
}
},
"jsonp"
);
var self = this;
$.getJSON(
"/command/core/get-operations?" + $.param({ project: theProject.id }),
null,
function(data) {
if ("entries" in data) {
self._showExtractOperationsDialog(data);
}
},
"jsonp"
);
};
HistoryPanel.prototype._showExtractOperationsDialog = function(json) {
var self = this;
var frame = $(DOM.loadHTML("core", "scripts/project/history-extract-dialog.html"));
var elmts = DOM.bind(frame);
var entryTable = elmts.entryTable[0];
var createEntry = function(entry) {
var tr = entryTable.insertRow(entryTable.rows.length);
var td0 = tr.insertCell(0);
var td1 = tr.insertCell(1);
td0.width = "1%";
if ("operation" in entry) {
entry.selected = true;
$('<input type="checkbox" checked="true" />').appendTo(td0).click(function() {
entry.selected = !entry.selected;
updateJson();
});
$('<span>').text(entry.operation.description).appendTo(td1);
} else {
$('<span>').text(entry.description).css("color", "#888").appendTo(td1);
}
};
for (var i = 0; i < json.entries.length; i++) {
createEntry(json.entries[i]);
var self = this;
var frame = $(DOM.loadHTML("core", "scripts/project/history-extract-dialog.html"));
var elmts = DOM.bind(frame);
var entryTable = elmts.entryTable[0];
var createEntry = function(entry) {
var tr = entryTable.insertRow(entryTable.rows.length);
var td0 = tr.insertCell(0);
var td1 = tr.insertCell(1);
td0.width = "1%";
if ("operation" in entry) {
entry.selected = true;
$('<input type="checkbox" checked="true" />').appendTo(td0).click(function() {
entry.selected = !entry.selected;
updateJson();
});
$('<span>').text(entry.operation.description).appendTo(td1);
} else {
$('<span>').text(entry.description).css("color", "#888").appendTo(td1);
}
var updateJson = function() {
var a = [];
for (var i = 0; i < json.entries.length; i++) {
var entry = json.entries[i];
if ("operation" in entry && entry.selected) {
a.push(entry.operation);
}
}
elmts.textarea.text(JSON.stringify(a, null, 2));
};
};
for (var i = 0; i < json.entries.length; i++) {
createEntry(json.entries[i]);
}
var updateJson = function() {
var a = [];
for (var i = 0; i < json.entries.length; i++) {
var entry = json.entries[i];
if ("operation" in entry && entry.selected) {
a.push(entry.operation);
}
}
elmts.textarea.text(JSON.stringify(a, null, 2));
};
updateJson();
elmts.closeButton.click(function() { DialogSystem.dismissUntil(level - 1); });
elmts.selectAllButton.click(function() {
for (var i = 0; i < json.entries.length; i++) {
json.entries[i].selected = true;
}
frame.find('input[type="checkbox"]').attr("checked", "true");
updateJson();
elmts.closeButton.click(function() { DialogSystem.dismissUntil(level - 1); });
elmts.selectAllButton.click(function() {
for (var i = 0; i < json.entries.length; i++) {
json.entries[i].selected = true;
}
frame.find('input[type="checkbox"]').attr("checked", "true");
updateJson();
});
elmts.unselectAllButton.click(function() {
for (var i = 0; i < json.entries.length; i++) {
json.entries[i].selected = false;
}
frame.find('input[type="checkbox"]').removeAttr("checked");
updateJson();
});
var level = DialogSystem.showDialog(frame);
elmts.textarea[0].select();
});
elmts.unselectAllButton.click(function() {
for (var i = 0; i < json.entries.length; i++) {
json.entries[i].selected = false;
}
frame.find('input[type="checkbox"]').removeAttr("checked");
updateJson();
});
var level = DialogSystem.showDialog(frame);
elmts.textarea[0].select();
};
HistoryPanel.prototype._showApplyOperationsDialog = function() {
var self = this;
var frame = $(DOM.loadHTML("core", "scripts/project/history-apply-dialog.html"));
var elmts = DOM.bind(frame);
var fixJson = function(json) {
json = json.trim();
if (!json.startsWith("[")) {
json = "[" + json;
}
if (!json.endsWith("]")) {
json = json + "]";
}
return json.replace(/\}\s*\,\s*\]/g, "} ]").replace(/\}\s*\{/g, "}, {");
};
elmts.applyButton.click(function() {
var json;
try {
json = elmts.textarea[0].value;
json = fixJson(json);
json = JSON.parse(json);
} catch (e) {
alert("The JSON you pasted is invalid.");
return;
}
Refine.postCoreProcess(
"apply-operations",
{},
{ operations: JSON.stringify(json) },
{ everythingChanged: true },
{
onDone: function(o) {
if (o.code == "pending") {
// Something might have already been done and so it's good to update
Refine.update({ everythingChanged: true });
}
}
var self = this;
var frame = $(DOM.loadHTML("core", "scripts/project/history-apply-dialog.html"));
var elmts = DOM.bind(frame);
var fixJson = function(json) {
json = json.trim();
if (!json.startsWith("[")) {
json = "[" + json;
}
if (!json.endsWith("]")) {
json = json + "]";
}
return json.replace(/\}\s*\,\s*\]/g, "} ]").replace(/\}\s*\{/g, "}, {");
};
elmts.applyButton.click(function() {
var json;
try {
json = elmts.textarea[0].value;
json = fixJson(json);
json = JSON.parse(json);
} catch (e) {
alert("The JSON you pasted is invalid.");
return;
}
Refine.postCoreProcess(
"apply-operations",
{},
{ operations: JSON.stringify(json) },
{ everythingChanged: true },
{
onDone: function(o) {
if (o.code == "pending") {
// Something might have already been done and so it's good to update
Refine.update({ everythingChanged: true });
}
);
DialogSystem.dismissUntil(level - 1);
});
elmts.cancelButton.click(function() {
DialogSystem.dismissUntil(level - 1);
});
var level = DialogSystem.showDialog(frame);
elmts.textarea.focus();
}
}
);
DialogSystem.dismissUntil(level - 1);
});
elmts.cancelButton.click(function() {
DialogSystem.dismissUntil(level - 1);
});
var level = DialogSystem.showDialog(frame);
elmts.textarea.focus();
};

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,209 +29,209 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
function ProcessPanel(div) {
this._div = div;
this._timerID = null;
this._processCount = 0;
this._updateOptions = {};
this._onDones = [];
this._latestHistoryEntry = null;
var self = this;
$(window).keypress(function(evt) {
if (evt.charCode == 26 || (evt.charCode == 122 && (evt.ctrlKey || evt.metaKey))) { // ctrl-z or meta-z
var t = evt.target;
if (t) {
var tagName = t.tagName.toLowerCase();
if (tagName == "textarea" || tagName == "input") {
return;
}
}
self.undo();
this._div = div;
this._timerID = null;
this._processCount = 0;
this._updateOptions = {};
this._onDones = [];
this._latestHistoryEntry = null;
var self = this;
$(window).keypress(function(evt) {
if (evt.charCode == 26 || (evt.charCode == 122 && (evt.ctrlKey || evt.metaKey))) { // ctrl-z or meta-z
var t = evt.target;
if (t) {
var tagName = t.tagName.toLowerCase();
if (tagName == "textarea" || tagName == "input") {
return;
}
});
this.update({});
}
self.undo();
}
});
this.update({});
}
ProcessPanel.prototype.resize = function() {
};
ProcessPanel.prototype.update = function(updateOptions, onDone) {
this._latestHistoryEntry = null;
for (var n in updateOptions) {
if (updateOptions.hasOwnProperty(n)) {
this._updateOptions[n] = updateOptions[n];
}
this._latestHistoryEntry = null;
for (var n in updateOptions) {
if (updateOptions.hasOwnProperty(n)) {
this._updateOptions[n] = updateOptions[n];
}
if (onDone) {
this._onDones.push(onDone);
}
if (this._timerID !== null) {
return;
}
var self = this;
Ajax.chainGetJSON(
"/command/core/get-processes?" + $.param({ project: theProject.id }), null,
function(data) {
self._latestHistoryEntry = null;
self._render(data);
}
);
}
if (onDone) {
this._onDones.push(onDone);
}
if (this._timerID !== null) {
return;
}
var self = this;
Ajax.chainGetJSON(
"/command/core/get-processes?" + $.param({ project: theProject.id }), null,
function(data) {
self._latestHistoryEntry = null;
self._render(data);
}
);
};
ProcessPanel.prototype.showUndo = function(historyEntry) {
var self = this;
this._latestHistoryEntry = historyEntry;
var self = this;
this._div.stop(true,false)
.empty()
.html('<div id="notification"><span bind="description"></span> <span class="notification-action"><a href="javascript:{}" bind="undo">Undo</a></span></div>')
.fadeIn(200)
.delay(7500)
.fadeOut(200);
var elmts = DOM.bind(this._div);
elmts.description.text(historyEntry.description);
elmts.undo.click(function() { self.undo(); });
this._latestHistoryEntry = historyEntry;
this._div.stop(true,false)
.empty()
.html('<div id="notification"><span bind="description"></span> <span class="notification-action"><a href="javascript:{}" bind="undo">Undo</a></span></div>')
.fadeIn(200)
.delay(7500)
.fadeOut(200);
var elmts = DOM.bind(this._div);
elmts.description.text(historyEntry.description);
elmts.undo.click(function() { self.undo(); });
};
ProcessPanel.prototype.undo = function() {
if (this._latestHistoryEntry !== null) {
Refine.postCoreProcess(
"undo-redo",
{ undoID: this._latestHistoryEntry.id },
null,
{ everythingChanged: true }
);
}
if (this._latestHistoryEntry !== null) {
Refine.postCoreProcess(
"undo-redo",
{ undoID: this._latestHistoryEntry.id },
null,
{ everythingChanged: true }
);
}
};
ProcessPanel.prototype._cancelAll = function() {
var self = this;
$.post(
"/command/core/cancel-processes?" + $.param({ project: theProject.id }),
null,
function(o) {
self._data = null;
self._runOnDones();
},
"json"
);
var self = this;
$.post(
"/command/core/cancel-processes?" + $.param({ project: theProject.id }),
null,
function(o) {
self._data = null;
self._runOnDones();
},
"json"
);
};
ProcessPanel.prototype._render = function(newData) {
var self = this;
var newProcessMap = {};
this._div.stop(true, false).empty();
if (!newData.processes.length) {
Refine.setTitle();
this._div.fadeOut(200);
} else {
this._div.fadeIn(200);
var cancelmessage = "Cancel"
var noticeDiv = $('<div id="notification"></div>').appendTo(this._div);
var descriptionSpan = $('<span></span>').appendTo(noticeDiv);
var statusDiv = $('<div></div>').appendTo(noticeDiv);
$('<img src="images/small-spinner.gif" />')
.addClass("notification-loader")
.appendTo(statusDiv);
var progressSpan = $('<span></span>').appendTo(statusDiv);
var countSpan = $('<span></span>').appendTo(statusDiv);
var renderProcess = function(process) {
if (process.status != "pending") {
Refine.setTitle(process.progress + "% complete");
descriptionSpan.text(process.description);
progressSpan.text(process.progress + '% complete');
}
};
var renderProcessCount = function(count) {
var pendingcount = count - 1;
countSpan.text(', ' + pendingcount + ' pending processes');
};
var processes = newData.processes;
if (processes.length >> 1) {
cancelmessage = "Cancel All";
renderProcessCount(processes.length);
}
for (var i = 0; i < processes.length; i++) {
var process = processes[i];
renderProcess(process);
if ("onDone" in process) {
newProcessMap[process.id] = process;
}
}
$('<a href="javascript:{}"></a>')
.addClass("notification-action")
.text(cancelmessage)
.click(function() {
self._cancelAll();
$(this).text("Canceling...").unbind();
})
.appendTo(statusDiv);
var self = this;
var newProcessMap = {};
this._div.stop(true, false).empty();
if (!newData.processes.length) {
Refine.setTitle();
this._div.fadeOut(200);
} else {
this._div.fadeIn(200);
var cancelmessage = "Cancel"
var noticeDiv = $('<div id="notification"></div>').appendTo(this._div);
var descriptionSpan = $('<span></span>').appendTo(noticeDiv);
var statusDiv = $('<div></div>').appendTo(noticeDiv);
$('<img src="images/small-spinner.gif" />')
.addClass("notification-loader")
.appendTo(statusDiv);
var progressSpan = $('<span></span>').appendTo(statusDiv);
var countSpan = $('<span></span>').appendTo(statusDiv);
var renderProcess = function(process) {
if (process.status != "pending") {
Refine.setTitle(process.progress + "% complete");
descriptionSpan.text(process.description);
progressSpan.text(process.progress + '% complete');
}
};
var renderProcessCount = function(count) {
var pendingcount = count - 1;
countSpan.text(', ' + pendingcount + ' pending processes');
};
var processes = newData.processes;
if (processes.length >> 1) {
cancelmessage = "Cancel All";
renderProcessCount(processes.length);
}
if ((this._data) && this._data.processes.length > 0) {
var oldProcesses = this._data.processes;
for (var i = 0; i < oldProcesses.length; i++) {
var process = oldProcesses[i];
if ("onDone" in process && !(process.id in newProcessMap)) {
this._perform(process.onDone);
}
}
for (var i = 0; i < processes.length; i++) {
var process = processes[i];
renderProcess(process);
if ("onDone" in process) {
newProcessMap[process.id] = process;
}
}
this._data = newData;
if (this._data.processes.length && !this._timerID) {
this._timerID = window.setTimeout(function() {
self._timerID = null;
self.update();
}, 500);
} else {
this._runOnDones();
$('<a href="javascript:{}"></a>')
.addClass("notification-action")
.text(cancelmessage)
.click(function() {
self._cancelAll();
$(this).text("Canceling...").unbind();
})
.appendTo(statusDiv);
}
if ((this._data) && this._data.processes.length > 0) {
var oldProcesses = this._data.processes;
for (var i = 0; i < oldProcesses.length; i++) {
var process = oldProcesses[i];
if ("onDone" in process && !(process.id in newProcessMap)) {
this._perform(process.onDone);
}
}
}
this._data = newData;
if (this._data.processes.length && !this._timerID) {
this._timerID = window.setTimeout(function() {
self._timerID = null;
self.update();
}, 500);
} else {
this._runOnDones();
}
};
ProcessPanel.prototype._perform = function(jobs) {
for (var i = 0; i < jobs.length; i++) {
var job = jobs[i];
if (job.action == "createFacet") {
try {
ui.browsingEngine.addFacet(
job.facetType,
job.facetConfig,
job.facetOptions
);
} catch (e) {
//
}
}
for (var i = 0; i < jobs.length; i++) {
var job = jobs[i];
if (job.action == "createFacet") {
try {
ui.browsingEngine.addFacet(
job.facetType,
job.facetConfig,
job.facetOptions
);
} catch (e) {
//
}
}
}
};
ProcessPanel.prototype._runOnDones = function() {
var updateOptions = this._updateOptions;
var onDones = this._onDones;
this._updateOptions = {};
this._onDones = [];
Refine.update(updateOptions, function() {
for (var i = 0; i < onDones.length; i++) {
try {
onDones[i]();
} catch (e) {
Refine.reportException(e);
}
}
});
var updateOptions = this._updateOptions;
var onDones = this._onDones;
this._updateOptions = {};
this._onDones = [];
Refine.update(updateOptions, function() {
for (var i = 0; i < onDones.length; i++) {
try {
onDones[i]();
} catch (e) {
Refine.reportException(e);
}
}
});
};

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,28 +29,28 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
var Scripting = {
};
Scripting.parse = function(expression) {
var colon = expression.indexOf(":");
if (colon > 0) {
var l = expression.substring(0, colon);
if (l == "gel") { // backward compatible
l = "grel";
}
if (theProject.scripting.hasOwnProperty(l)) {
return {
language: l,
expression: expression.substring(colon + 1)
};
}
var colon = expression.indexOf(":");
if (colon > 0) {
var l = expression.substring(0, colon);
if (l == "gel") { // backward compatible
l = "grel";
}
return {
language: "grel",
expression: expression
};
if (theProject.scripting.hasOwnProperty(l)) {
return {
language: l,
expression: expression.substring(colon + 1)
};
}
}
return {
language: "grel",
expression: expression
};
};

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,25 +29,25 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
function SummaryBar(div) {
this._div = div;
this._initializeUI();
this._div = div;
this._initializeUI();
}
SummaryBar.prototype._initializeUI = function() {
};
SummaryBar.prototype.updateResultCount = function() {
var summaryText;
var units = theProject.rowModel.mode == "row-based" ? "rows" : "records";
if (theProject.rowModel.filtered == theProject.rowModel.total) {
summaryText = (theProject.rowModel.total) + ' ' + units;
} else {
summaryText = (theProject.rowModel.filtered) + ' matching ' + units + ' <span id="summary-total">(' + (theProject.rowModel.total) + ' total)</span>';
}
$('<span>').html(summaryText).appendTo(this._div.empty());
var summaryText;
var units = theProject.rowModel.mode == "row-based" ? "rows" : "records";
if (theProject.rowModel.filtered == theProject.rowModel.total) {
summaryText = (theProject.rowModel.total) + ' ' + units;
} else {
summaryText = (theProject.rowModel.filtered) + ' matching ' + units + ' <span id="summary-total">(' + (theProject.rowModel.total) + ' total)</span>';
}
$('<span>').html(summaryText).appendTo(this._div.empty());
};

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,105 +29,105 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
function ReconFreebaseQueryPanel(column, service, container) {
this._column = column;
this._service = service;
this._container = container;
this._constructUI();
this._column = column;
this._service = service;
this._container = container;
this._constructUI();
}
ReconFreebaseQueryPanel.prototype.activate = function() {
this._panel.show();
this._panel.show();
};
ReconFreebaseQueryPanel.prototype.deactivate = function() {
this._panel.hide();
this._panel.hide();
};
ReconFreebaseQueryPanel.prototype.dispose = function() {
this._panel.remove();
this._panel = null;
this._column = null;
this._service = null;
this._container = null;
this._panel.remove();
this._panel = null;
this._column = null;
this._service = null;
this._container = null;
};
ReconFreebaseQueryPanel.prototype._constructUI = function() {
var self = this;
this._panel = $(DOM.loadHTML("core", "scripts/reconciliation/freebase-query-panel.html")).appendTo(this._container);
this._elmts = DOM.bind(this._panel);
this._wireEvents();
var self = this;
this._panel = $(DOM.loadHTML("core", "scripts/reconciliation/freebase-query-panel.html")).appendTo(this._container);
this._elmts = DOM.bind(this._panel);
this._wireEvents();
};
ReconFreebaseQueryPanel.prototype._wireEvents = function() {
var self = this;
this._elmts.strictNamespaceInput
.suggest({ type: '/type/namespace' })
.bind("fb-select", function(e, data) {
self._panel.find('input[name="recon-dialog-strict-choice"][value="key"]').attr("checked", "true");
self._panel.find('input[name="recon-dialog-strict-namespace-choice"][value="other"]').attr("checked", "true");
});
var self = this;
this._elmts.strictNamespaceInput
.suggest({ type: '/type/namespace' })
.bind("fb-select", function(e, data) {
self._panel.find('input[name="recon-dialog-strict-choice"][value="key"]').attr("checked", "true");
self._panel.find('input[name="recon-dialog-strict-namespace-choice"][value="other"]').attr("checked", "true");
});
};
ReconFreebaseQueryPanel.prototype.start = function() {
var bodyParams;
var match = $('input[name="recon-dialog-strict-choice"]:checked')[0].value;
if (match == "key") {
var namespaceChoice = $('input[name="recon-dialog-strict-namespace-choice"]:checked')[0];
var namespace;
if (namespaceChoice.value == "other") {
var suggest = this._elmts.strictNamespaceInput.data("data.suggest");
if (!suggest) {
alert("Please specify a namespace.");
return;
}
namespace = {
id: suggest.id,
name: suggest.name
};
} else {
namespace = {
id: namespaceChoice.value,
name: namespaceChoice.getAttribute("nsName")
};
}
bodyParams = {
columnName: this._column.name,
config: JSON.stringify({
mode: "freebase/strict",
match: "key",
namespace: namespace
})
};
} else if (match == "id") {
bodyParams = {
columnName: this._column.name,
config: JSON.stringify({
mode: "freebase/strict",
match: "id"
})
};
} else if (match == "guid") {
bodyParams = {
columnName: this._column.name,
config: JSON.stringify({
mode: "freebase/strict",
match: "guid"
})
};
var bodyParams;
var match = $('input[name="recon-dialog-strict-choice"]:checked')[0].value;
if (match == "key") {
var namespaceChoice = $('input[name="recon-dialog-strict-namespace-choice"]:checked')[0];
var namespace;
if (namespaceChoice.value == "other") {
var suggest = this._elmts.strictNamespaceInput.data("data.suggest");
if (!suggest) {
alert("Please specify a namespace.");
return;
}
namespace = {
id: suggest.id,
name: suggest.name
};
} else {
namespace = {
id: namespaceChoice.value,
name: namespaceChoice.getAttribute("nsName")
};
}
Refine.postCoreProcess(
"reconcile",
{},
bodyParams,
{ cellsChanged: true, columnStatsChanged: true }
);
bodyParams = {
columnName: this._column.name,
config: JSON.stringify({
mode: "freebase/strict",
match: "key",
namespace: namespace
})
};
} else if (match == "id") {
bodyParams = {
columnName: this._column.name,
config: JSON.stringify({
mode: "freebase/strict",
match: "id"
})
};
} else if (match == "guid") {
bodyParams = {
columnName: this._column.name,
config: JSON.stringify({
mode: "freebase/strict",
match: "guid"
})
};
}
Refine.postCoreProcess(
"reconcile",
{},
bodyParams,
{ cellsChanged: true, columnStatsChanged: true }
);
};

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,202 +29,202 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
function ReconDialog(column, types) {
this._column = column;
this._serviceRecords = [];
this._selectedServiceRecordIndex = -1;
this._createDialog();
this._column = column;
this._serviceRecords = [];
this._selectedServiceRecordIndex = -1;
this._createDialog();
}
ReconDialog.prototype._createDialog = function() {
var self = this;
var dialog = $(DOM.loadHTML("core", "scripts/reconciliation/recon-dialog.html"));
var self = this;
var dialog = $(DOM.loadHTML("core", "scripts/reconciliation/recon-dialog.html"));
this._elmts = DOM.bind(dialog);
this._elmts.dialogHeader.text('Reconcile column "' + this._column.name + '"');
this._elmts.addStandardServiceButton.click(function() { self._onAddStandardService(); });
this._elmts.addNamespacedServiceButton.click(function() { self._onAddNamespacedService(); });
this._elmts.reconcileButton.click(function() { self._onOK(); });
this._elmts.cancelButton.click(function() { self._dismiss(); });
this._level = DialogSystem.showDialog(dialog);
this._populateDialog();
this._elmts = DOM.bind(dialog);
this._elmts.dialogHeader.text('Reconcile column "' + this._column.name + '"');
this._elmts.addStandardServiceButton.click(function() { self._onAddStandardService(); });
this._elmts.addNamespacedServiceButton.click(function() { self._onAddNamespacedService(); });
this._elmts.reconcileButton.click(function() { self._onOK(); });
this._elmts.cancelButton.click(function() { self._dismiss(); });
this._level = DialogSystem.showDialog(dialog);
this._populateDialog();
};
ReconDialog.prototype._onOK = function() {
if (this._selectedServiceRecordIndex >= 0) {
var record = this._serviceRecords[this._selectedServiceRecordIndex];
if (record.handler) {
record.handler.start();
}
if (this._selectedServiceRecordIndex >= 0) {
var record = this._serviceRecords[this._selectedServiceRecordIndex];
if (record.handler) {
record.handler.start();
}
this._dismiss();
}
this._dismiss();
};
ReconDialog.prototype._dismiss = function() {
for (var i = 0; i < this._serviceRecords.length; i++) {
var record = this._serviceRecords[i];
if (record.handler) {
record.handler.dispose();
}
for (var i = 0; i < this._serviceRecords.length; i++) {
var record = this._serviceRecords[i];
if (record.handler) {
record.handler.dispose();
}
this._serviceRecords = null;
DialogSystem.dismissUntil(this._level - 1);
}
this._serviceRecords = null;
DialogSystem.dismissUntil(this._level - 1);
};
ReconDialog.prototype._cleanDialog = function() {
for (var i = 0; i < this._serviceRecords.length; i++) {
var record = this._serviceRecords[i];
if (record.handler) {
record.handler.deactivate();
}
record.selector.remove();
for (var i = 0; i < this._serviceRecords.length; i++) {
var record = this._serviceRecords[i];
if (record.handler) {
record.handler.deactivate();
}
this._serviceRecords = [];
this._selectedServiceRecordIndex = -1;
record.selector.remove();
}
this._serviceRecords = [];
this._selectedServiceRecordIndex = -1;
};
ReconDialog.prototype._populateDialog = function() {
var self = this;
var services = ReconciliationManager.getAllServices();
if (services.length > 0) {
var renderService = function(service) {
var record = {
service: service,
handler: null
};
record.selector = $('<a>')
.attr("href", "javascript:{}")
.addClass("recon-dialog-service-selector")
.text(service.name)
.appendTo(self._elmts.serviceList)
.click(function() {
self._selectService(record);
});
$('<a>')
.html("&nbsp;")
.addClass("recon-dialog-service-selector-remove")
.prependTo(record.selector)
.click(function() {
ReconciliationManager.unregisterService(service, function() {
self._refresh(-1);
});
});
self._serviceRecords.push(record);
};
for (var i = 0; i < services.length; i++) {
renderService(services[i]);
}
var self = this;
var services = ReconciliationManager.getAllServices();
if (services.length > 0) {
var renderService = function(service) {
var record = {
service: service,
handler: null
};
record.selector = $('<a>')
.attr("href", "javascript:{}")
.addClass("recon-dialog-service-selector")
.text(service.name)
.appendTo(self._elmts.serviceList)
.click(function() {
self._selectService(record);
});
$('<a>')
.html("&nbsp;")
.addClass("recon-dialog-service-selector-remove")
.prependTo(record.selector)
.click(function() {
ReconciliationManager.unregisterService(service, function() {
self._refresh(-1);
});
});
self._serviceRecords.push(record);
};
for (var i = 0; i < services.length; i++) {
renderService(services[i]);
}
}
};
ReconDialog.prototype._selectService = function(record) {
for (var i = 0; i < this._serviceRecords.length; i++) {
if (record === this._serviceRecords[i]) {
if (i !== this._selectedServiceRecordIndex) {
if (this._selectedServiceRecordIndex >= 0) {
var oldRecord = this._serviceRecords[this._selectedServiceRecordIndex];
if (oldRecord.handler) {
oldRecord.selector.removeClass("selected");
oldRecord.handler.deactivate();
}
}
this._elmts.servicePanelMessage.hide();
record.selector.addClass("selected");
if (record.handler) {
record.handler.activate();
} else {
var handlerConstructor = eval(record.service.ui.handler);
record.handler = new handlerConstructor(
this._column, record.service, this._elmts.servicePanelContainer);
}
this._selectedServiceRecordIndex = i;
return;
}
for (var i = 0; i < this._serviceRecords.length; i++) {
if (record === this._serviceRecords[i]) {
if (i !== this._selectedServiceRecordIndex) {
if (this._selectedServiceRecordIndex >= 0) {
var oldRecord = this._serviceRecords[this._selectedServiceRecordIndex];
if (oldRecord.handler) {
oldRecord.selector.removeClass("selected");
oldRecord.handler.deactivate();
}
}
this._elmts.servicePanelMessage.hide();
record.selector.addClass("selected");
if (record.handler) {
record.handler.activate();
} else {
var handlerConstructor = eval(record.service.ui.handler);
record.handler = new handlerConstructor(
this._column, record.service, this._elmts.servicePanelContainer);
}
this._selectedServiceRecordIndex = i;
return;
}
}
}
};
ReconDialog.prototype._refresh = function(newSelectIndex) {
this._cleanDialog();
this._populateDialog();
if (newSelectIndex >= 0) {
this._selectService(this._serviceRecords[newSelectIndex]);
}
this._cleanDialog();
this._populateDialog();
if (newSelectIndex >= 0) {
this._selectService(this._serviceRecords[newSelectIndex]);
}
};
ReconDialog.prototype._onAddStandardService = function() {
var self = this;
var dialog = $(DOM.loadHTML("core", "scripts/reconciliation/add-standard-service-dialog.html"));
var elmts = DOM.bind(dialog);
var level = DialogSystem.showDialog(dialog);
var dismiss = function() {
DialogSystem.dismissUntil(level - 1);
};
elmts.cancelButton.click(dismiss);
elmts.addButton.click(function() {
var url = $.trim(elmts.input[0].value);
if (url.length > 0) {
ReconciliationManager.registerStandardService(url, function(index) {
self._refresh(index);
});
}
dismiss();
});
elmts.input.focus().select();
var self = this;
var dialog = $(DOM.loadHTML("core", "scripts/reconciliation/add-standard-service-dialog.html"));
var elmts = DOM.bind(dialog);
var level = DialogSystem.showDialog(dialog);
var dismiss = function() {
DialogSystem.dismissUntil(level - 1);
};
elmts.cancelButton.click(dismiss);
elmts.addButton.click(function() {
var url = $.trim(elmts.input[0].value);
if (url.length > 0) {
ReconciliationManager.registerStandardService(url, function(index) {
self._refresh(index);
});
}
dismiss();
});
elmts.input.focus().select();
};
ReconDialog.prototype._onAddNamespacedService = function() {
var self = this;
var dialog = $(DOM.loadHTML("core", "scripts/reconciliation/add-namespaced-service-dialog.html"));
var elmts = DOM.bind(dialog);
var level = DialogSystem.showDialog(dialog);
var dismiss = function() {
DialogSystem.dismissUntil(level - 1);
};
elmts.namespaceInput
.suggest({ type: '/type/namespace' })
.bind("fb-select", function(e, data) {
elmts.typeInput.focus();
});
elmts.typeInput.suggestT({ type: '/type/type' });
elmts.cancelButton.click(dismiss);
elmts.addButton.click(function() {
var namespaceData = elmts.namespaceInput.data("data.suggest");
var typeData = elmts.typeInput.data("data.suggest");
if (namespaceData) {
var url = "http://4.standard-reconcile.dfhuynh.user.dev.freebaseapps.com/namespace_reconcile?namespace=" +
escape(namespaceData.id);
if (typeData) {
url += "&type=" + typeData.id;
}
ReconciliationManager.registerStandardService(url, function(index) {
self._refresh(index);
});
}
dismiss();
});
elmts.namespaceInput.focus().data("suggest").textchange();
var self = this;
var dialog = $(DOM.loadHTML("core", "scripts/reconciliation/add-namespaced-service-dialog.html"));
var elmts = DOM.bind(dialog);
var level = DialogSystem.showDialog(dialog);
var dismiss = function() {
DialogSystem.dismissUntil(level - 1);
};
elmts.namespaceInput
.suggest({ type: '/type/namespace' })
.bind("fb-select", function(e, data) {
elmts.typeInput.focus();
});
elmts.typeInput.suggestT({ type: '/type/type' });
elmts.cancelButton.click(dismiss);
elmts.addButton.click(function() {
var namespaceData = elmts.namespaceInput.data("data.suggest");
var typeData = elmts.typeInput.data("data.suggest");
if (namespaceData) {
var url = "http://4.standard-reconcile.dfhuynh.user.dev.freebaseapps.com/namespace_reconcile?namespace=" +
escape(namespaceData.id);
if (typeData) {
url += "&type=" + typeData.id;
}
ReconciliationManager.registerStandardService(url, function(index) {
self._refresh(index);
});
}
dismiss();
});
elmts.namespaceInput.focus().data("suggest").textchange();
};

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,130 +29,130 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
var ReconciliationManager = {
customServices : [], // services registered by core and extensions
standardServices : [], // services registered by user
_urlMap : {}
customServices : [], // services registered by core and extensions
standardServices : [], // services registered by user
_urlMap : {}
};
ReconciliationManager.isFreebaseId = function(s) {
return s == "http://rdf.freebase.com/ns/type.object.id";
return s == "http://rdf.freebase.com/ns/type.object.id";
};
ReconciliationManager.isFreebaseMid = function(s) {
return s == "http://rdf.freebase.com/ns/type.object.mid";
return s == "http://rdf.freebase.com/ns/type.object.mid";
};
ReconciliationManager.isFreebaseIdOrMid = function(s) {
return ReconciliationManager.isFreebaseMid(s) || ReconciliationManager.isFreebaseId(s);
return ReconciliationManager.isFreebaseMid(s) || ReconciliationManager.isFreebaseId(s);
};
ReconciliationManager._rebuildMap = function() {
var map = {};
$.each(ReconciliationManager.getAllServices(), function(i, service) {
if ("url" in service) {
map[service.url] = service;
}
});
ReconciliationManager._urlMap = map;
var map = {};
$.each(ReconciliationManager.getAllServices(), function(i, service) {
if ("url" in service) {
map[service.url] = service;
}
});
ReconciliationManager._urlMap = map;
};
ReconciliationManager.getServiceFromUrl = function(url) {
return ReconciliationManager._urlMap[url];
return ReconciliationManager._urlMap[url];
};
ReconciliationManager.getAllServices = function() {
return ReconciliationManager.customServices.concat(ReconciliationManager.standardServices);
return ReconciliationManager.customServices.concat(ReconciliationManager.standardServices);
};
ReconciliationManager.registerService = function(service) {
ReconciliationManager.customServices.push(service);
ReconciliationManager._rebuildMap();
return ReconciliationManager.customServices.length - 1;
ReconciliationManager.customServices.push(service);
ReconciliationManager._rebuildMap();
return ReconciliationManager.customServices.length - 1;
};
ReconciliationManager.registerStandardService = function(url, f) {
var dismissBusy = DialogSystem.showBusy();
$.getJSON(
url + (url.contains("?") ? "&" : "?") + "callback=?",
null,
function(data) {
data.url = url;
data.ui = { "handler" : "ReconStandardServicePanel" };
index = ReconciliationManager.customServices.length +
ReconciliationManager.standardServices.length;
ReconciliationManager.standardServices.push(data);
ReconciliationManager._rebuildMap();
ReconciliationManager.save();
dismissBusy();
if (f) {
f(index);
}
},
"jsonp"
);
var dismissBusy = DialogSystem.showBusy();
$.getJSON(
url + (url.contains("?") ? "&" : "?") + "callback=?",
null,
function(data) {
data.url = url;
data.ui = { "handler" : "ReconStandardServicePanel" };
index = ReconciliationManager.customServices.length +
ReconciliationManager.standardServices.length;
ReconciliationManager.standardServices.push(data);
ReconciliationManager._rebuildMap();
ReconciliationManager.save();
dismissBusy();
if (f) {
f(index);
}
},
"jsonp"
);
};
ReconciliationManager.unregisterService = function(service, f) {
for (var i = 0; i < ReconciliationManager.customServices.length; i++) {
if (ReconciliationManager.customServices[i] === service) {
ReconciliationManager.customServices.splice(i, 1);
break;
}
for (var i = 0; i < ReconciliationManager.customServices.length; i++) {
if (ReconciliationManager.customServices[i] === service) {
ReconciliationManager.customServices.splice(i, 1);
break;
}
for (var i = 0; i < ReconciliationManager.standardServices.length; i++) {
if (ReconciliationManager.standardServices[i] === service) {
ReconciliationManager.standardServices.splice(i, 1);
break;
}
}
for (var i = 0; i < ReconciliationManager.standardServices.length; i++) {
if (ReconciliationManager.standardServices[i] === service) {
ReconciliationManager.standardServices.splice(i, 1);
break;
}
ReconciliationManager.save(f);
}
ReconciliationManager.save(f);
};
ReconciliationManager.save = function(f) {
$.ajax({
async: false,
type: "POST",
url: "/command/core/set-preference?" + $.param({
name: "reconciliation.standardServices"
}),
data: { "value" : JSON.stringify(ReconciliationManager.standardServices) },
success: function(data) {
if (f) { f(); }
},
dataType: "json"
});
$.ajax({
async: false,
type: "POST",
url: "/command/core/set-preference?" + $.param({
name: "reconciliation.standardServices"
}),
data: { "value" : JSON.stringify(ReconciliationManager.standardServices) },
success: function(data) {
if (f) { f(); }
},
dataType: "json"
});
};
(function() {
ReconciliationManager.customServices.push({
"name" : "Freebase Query-based Reconciliation",
"ui" : { "handler" : "ReconFreebaseQueryPanel" }
});
$.ajax({
async: false,
url: "/command/core/get-preference?" + $.param({
name: "reconciliation.standardServices"
}),
success: function(data) {
if (data.value && data.value != "null") {
ReconciliationManager.standardServices = JSON.parse(data.value);
ReconciliationManager._rebuildMap();
} else {
ReconciliationManager.registerStandardService(
"http://4.standard-reconcile.dfhuynh.user.dev.freebaseapps.com/reconcile");
}
},
dataType: "json"
});
ReconciliationManager.customServices.push({
"name" : "Freebase Query-based Reconciliation",
"ui" : { "handler" : "ReconFreebaseQueryPanel" }
});
$.ajax({
async: false,
url: "/command/core/get-preference?" + $.param({
name: "reconciliation.standardServices"
}),
success: function(data) {
if (data.value && data.value != "null") {
ReconciliationManager.standardServices = JSON.parse(data.value);
ReconciliationManager._rebuildMap();
} else {
ReconciliationManager.registerStandardService(
"http://4.standard-reconcile.dfhuynh.user.dev.freebaseapps.com/reconcile");
}
},
dataType: "json"
});
})();

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,298 +29,298 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
function ReconStandardServicePanel(column, service, container) {
this._column = column;
this._service = service;
this._container = container;
this._types = [];
this._constructUI();
this._column = column;
this._service = service;
this._container = container;
this._types = [];
this._constructUI();
}
ReconStandardServicePanel.prototype._guessTypes = function(f) {
var self = this;
var dismissBusy = DialogSystem.showBusy();
$.post(
"/command/core/guess-types-of-column?" + $.param({
project: theProject.id,
columnName: this._column.name,
service: this._service.url
}),
null,
function(data) {
self._types = data.types;
var self = this;
var dismissBusy = DialogSystem.showBusy();
if (self._types.length === 0 && "defaultTypes" in self._service) {
var defaultTypes = {};
$.each(self._service["defaultTypes"], function() {
defaultTypes[this.id] = this.name;
});
$.each(self._types, function() {
delete defaultTypes[typeof this == "string" ? this : this.id];
});
for (var id in defaultTypes) {
if (defaultTypes.hasOwnProperty(id)) {
self._types.push({
id: id,
name: defaultTypes[id].name
});
}
}
}
dismissBusy();
f();
$.post(
"/command/core/guess-types-of-column?" + $.param({
project: theProject.id,
columnName: this._column.name,
service: this._service.url
}),
null,
function(data) {
self._types = data.types;
if (self._types.length === 0 && "defaultTypes" in self._service) {
var defaultTypes = {};
$.each(self._service["defaultTypes"], function() {
defaultTypes[this.id] = this.name;
});
$.each(self._types, function() {
delete defaultTypes[typeof this == "string" ? this : this.id];
});
for (var id in defaultTypes) {
if (defaultTypes.hasOwnProperty(id)) {
self._types.push({
id: id,
name: defaultTypes[id].name
});
}
}
);
}
dismissBusy();
f();
}
);
};
ReconStandardServicePanel.prototype._constructUI = function() {
var self = this;
this._panel = $(DOM.loadHTML("core", "scripts/reconciliation/standard-service-panel.html")).appendTo(this._container);
this._elmts = DOM.bind(this._panel);
this._elmts.rawServiceLink.attr("href", this._service.url);
this._guessTypes(function() {
self._populatePanel();
self._wireEvents();
});
var self = this;
this._panel = $(DOM.loadHTML("core", "scripts/reconciliation/standard-service-panel.html")).appendTo(this._container);
this._elmts = DOM.bind(this._panel);
this._elmts.rawServiceLink.attr("href", this._service.url);
this._guessTypes(function() {
self._populatePanel();
self._wireEvents();
});
};
ReconStandardServicePanel.prototype.activate = function() {
this._panel.show();
this._panel.show();
};
ReconStandardServicePanel.prototype.deactivate = function() {
this._panel.hide();
this._panel.hide();
};
ReconStandardServicePanel.prototype.dispose = function() {
this._panel.remove();
this._panel = null;
this._column = null;
this._service = null;
this._container = null;
this._panel.remove();
this._panel = null;
this._column = null;
this._service = null;
this._container = null;
};
ReconStandardServicePanel.prototype._populatePanel = function() {
var self = this;
/*
* Populate types
*/
if (this._types.length > 0) {
var typeTableContainer = $('<div>')
.addClass("grid-layout layout-tightest")
.appendTo(this._elmts.typeContainer);
var typeTable = $('<table></table>').appendTo(typeTableContainer)[0];
var createTypeChoice = function(type, check) {
var typeID = typeof type == "string" ? type : type.id;
var typeName = typeof type == "string" ? type : (type.name || type.id);
var tr = typeTable.insertRow(typeTable.rows.length);
var td0 = tr.insertCell(0);
var td1 = tr.insertCell(1);
td0.width = "1%";
var radio = $('<input type="radio" name="type-choice">')
.attr("value", typeID)
.attr("typeName", typeName)
.appendTo(td0)
.click(function() {
self._rewirePropertySuggests(this.value);
});
if (check) {
radio.attr("checked", "true");
}
if (typeName == typeID) {
$(td1).html(typeName);
} else {
$(td1).html(
typeName +
'<br/>' +
'<span class="type-id">' + typeID + '</span>');
}
};
for (var i = 0; i < this._types.length; i++) {
createTypeChoice(this._types[i], i === 0);
}
} else {
$('<div>')
.addClass("recon-dialog-standard-service-panel-message")
.text("Sorry, we can't suggest any type for your data. Please specify a type yourself below.")
.appendTo(this._elmts.typeContainer);
this._panel
.find('input[name="type-choice"][value=""]')
.attr("checked", "true");
this._elmts.typeInput.focus();
var self = this;
/*
* Populate types
*/
if (this._types.length > 0) {
var typeTableContainer = $('<div>')
.addClass("grid-layout layout-tightest")
.appendTo(this._elmts.typeContainer);
var typeTable = $('<table></table>').appendTo(typeTableContainer)[0];
var createTypeChoice = function(type, check) {
var typeID = typeof type == "string" ? type : type.id;
var typeName = typeof type == "string" ? type : (type.name || type.id);
var tr = typeTable.insertRow(typeTable.rows.length);
var td0 = tr.insertCell(0);
var td1 = tr.insertCell(1);
td0.width = "1%";
var radio = $('<input type="radio" name="type-choice">')
.attr("value", typeID)
.attr("typeName", typeName)
.appendTo(td0)
.click(function() {
self._rewirePropertySuggests(this.value);
});
if (check) {
radio.attr("checked", "true");
}
if (typeName == typeID) {
$(td1).html(typeName);
} else {
$(td1).html(
typeName +
'<br/>' +
'<span class="type-id">' + typeID + '</span>');
}
};
for (var i = 0; i < this._types.length; i++) {
createTypeChoice(this._types[i], i === 0);
}
/*
* Populate properties
*/
var detailTableContainer = $('<div>')
.addClass("grid-layout layout-tightest")
.appendTo(this._elmts.detailContainer);
var detailTable = $(
'<table>' +
'<tr><th>Column</th><th>Include?</th><th>As Property</th></tr>' +
'</table>'
).appendTo(detailTableContainer)[0];
function renderDetailColumn(column) {
var tr = detailTable.insertRow(detailTable.rows.length);
var td0 = tr.insertCell(0);
var td1 = tr.insertCell(1);
var td2 = tr.insertCell(2);
$(td0).html(column.name);
$('<input type="checkbox" />')
.attr("columnName", column.name)
.appendTo(td1);
$('<input size="25" name="property" />')
.attr("columnName", column.name)
.appendTo(td2);
}
var columns = theProject.columnModel.columns;
for (var i = 0; i < columns.length; i++) {
var column = columns[i];
if (column !== this._column) {
renderDetailColumn(column);
}
} else {
$('<div>')
.addClass("recon-dialog-standard-service-panel-message")
.text("Sorry, we can't suggest any type for your data. Please specify a type yourself below.")
.appendTo(this._elmts.typeContainer);
this._panel
.find('input[name="type-choice"][value=""]')
.attr("checked", "true");
this._elmts.typeInput.focus();
}
/*
* Populate properties
*/
var detailTableContainer = $('<div>')
.addClass("grid-layout layout-tightest")
.appendTo(this._elmts.detailContainer);
var detailTable = $(
'<table>' +
'<tr><th>Column</th><th>Include?</th><th>As Property</th></tr>' +
'</table>'
).appendTo(detailTableContainer)[0];
function renderDetailColumn(column) {
var tr = detailTable.insertRow(detailTable.rows.length);
var td0 = tr.insertCell(0);
var td1 = tr.insertCell(1);
var td2 = tr.insertCell(2);
$(td0).html(column.name);
$('<input type="checkbox" />')
.attr("columnName", column.name)
.appendTo(td1);
$('<input size="25" name="property" />')
.attr("columnName", column.name)
.appendTo(td2);
}
var columns = theProject.columnModel.columns;
for (var i = 0; i < columns.length; i++) {
var column = columns[i];
if (column !== this._column) {
renderDetailColumn(column);
}
}
};
ReconStandardServicePanel.prototype._wireEvents = function() {
var self = this;
var input = this._elmts.typeInput.unbind();
if ("suggest" in this._service && "type" in this._service.suggest) {
var suggestOptions = $.extend({}, this._service.suggest.type);
input.suggestT(suggestOptions);
} else if (this._isInFreebaseSchemaSpace()) {
input.suggestT({ type : '/type/type' });
}
input.bind("fb-select", function(e, data) {
self._panel
.find('input[name="type-choice"][value=""]')
.attr("checked", "true");
self._rewirePropertySuggests(data.id);
});
this._rewirePropertySuggests((this._types.length > 0) ? this._types[0] : null);
var self = this;
var input = this._elmts.typeInput.unbind();
if ("suggest" in this._service && "type" in this._service.suggest) {
var suggestOptions = $.extend({}, this._service.suggest.type);
input.suggestT(suggestOptions);
} else if (this._isInFreebaseSchemaSpace()) {
input.suggestT({ type : '/type/type' });
}
input.bind("fb-select", function(e, data) {
self._panel
.find('input[name="type-choice"][value=""]')
.attr("checked", "true");
self._rewirePropertySuggests(data.id);
});
this._rewirePropertySuggests((this._types.length > 0) ? this._types[0] : null);
};
ReconStandardServicePanel.prototype._rewirePropertySuggests = function(type) {
var inputs = this._panel
.find('input[name="property"]')
.unbind();
if ("suggest" in this._service && "property" in this._service.suggest) {
var suggestOptions = $.extend({}, this._service.suggest.property);
if (type) {
suggestOptions.ac_param = { schema: typeof type == "string" ? type : type.id };
}
inputs.suggestP(suggestOptions);
} else if (this._isInFreebaseSchemaSpace()) {
inputs.suggestP({
type: '/type/property',
ac_param: {
schema: (type) ? (typeof type == "string" ? type : type.id) : "/common/topic"
}
});
var inputs = this._panel
.find('input[name="property"]')
.unbind();
if ("suggest" in this._service && "property" in this._service.suggest) {
var suggestOptions = $.extend({}, this._service.suggest.property);
if (type) {
suggestOptions.ac_param = { schema: typeof type == "string" ? type : type.id };
}
inputs.suggestP(suggestOptions);
} else if (this._isInFreebaseSchemaSpace()) {
inputs.suggestP({
type: '/type/property',
ac_param: {
schema: (type) ? (typeof type == "string" ? type : type.id) : "/common/topic"
}
});
}
};
ReconStandardServicePanel.prototype._isInFreebaseIdentifierSpace = function() {
return ReconciliationManager.isFreebaseIdOrMid(this._service.identifierSpace);
return ReconciliationManager.isFreebaseIdOrMid(this._service.identifierSpace);
};
ReconStandardServicePanel.prototype._isInFreebaseSchemaSpace = function() {
return ReconciliationManager.isFreebaseId(this._service.schemaSpace);
return ReconciliationManager.isFreebaseId(this._service.schemaSpace);
};
ReconStandardServicePanel.prototype.start = function() {
var self = this;
var type = this._elmts.typeInput.data("data.suggest");
if (!(type)) {
type = {
id: this._elmts.typeInput[0].value,
name: this._elmts.typeInput[0].value
};
var self = this;
var type = this._elmts.typeInput.data("data.suggest");
if (!(type)) {
type = {
id: this._elmts.typeInput[0].value,
name: this._elmts.typeInput[0].value
};
}
var choices = this._panel.find('input[name="type-choice"]:checked');
if (choices !== null && choices.length > 0) {
if (choices[0].value == '-') {
type = null;
} else if (choices[0].value != "") {
type = {
id: choices[0].value,
name: choices.attr("typeName")
};
}
var choices = this._panel.find('input[name="type-choice"]:checked');
if (choices !== null && choices.length > 0) {
if (choices[0].value == '-') {
type = null;
} else if (choices[0].value != "") {
type = {
id: choices[0].value,
name: choices.attr("typeName")
};
}
}
var columnDetails = [];
$.each(
this._panel.find('input[name="property"]'),
function() {
var property = $(this).data("data.suggest");
if (property && property.id) {
columnDetails.push({
column: this.getAttribute("columnName"),
property: {
id: property.id,
name: property.name
}
});
} else {
var property = $.trim(this.value);
if (property) {
columnDetails.push({
column: this.getAttribute("columnName"),
property: {
id: property,
name: property
}
});
}
}
var columnDetails = [];
$.each(
this._panel.find('input[name="property"]'),
function() {
var property = $(this).data("data.suggest");
if (property && property.id) {
columnDetails.push({
column: this.getAttribute("columnName"),
property: {
id: property.id,
name: property.name
}
});
} else {
var property = $.trim(this.value);
if (property) {
columnDetails.push({
column: this.getAttribute("columnName"),
property: {
id: property,
name: property
}
});
}
);
Refine.postCoreProcess(
"reconcile",
{},
{
columnName: this._column.name,
config: JSON.stringify({
mode: "standard-service",
service: this._service.url,
identifierSpace: this._service.identifierSpace,
schemaSpace: this._service.schemaSpace,
type: (type) ? { id: type.id, name: type.name } : null,
autoMatch: this._elmts.automatchCheck[0].checked,
columnDetails: columnDetails
})
},
{ cellsChanged: true, columnStatsChanged: true }
);
}
}
);
Refine.postCoreProcess(
"reconcile",
{},
{
columnName: this._column.name,
config: JSON.stringify({
mode: "standard-service",
service: this._service.url,
identifierSpace: this._service.identifierSpace,
schemaSpace: this._service.schemaSpace,
type: (type) ? { id: type.id, name: type.name } : null,
autoMatch: this._elmts.automatchCheck[0].checked,
columnDetails: columnDetails
})
},
{ cellsChanged: true, columnStatsChanged: true }
);
};

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,27 +29,27 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
Ajax = {};
Ajax.chainGetJSON = function() {
var a = arguments;
var i = 0;
var next = function() {
if (i <= a.length - 3) {
var url = a[i++];
var data = a[i++];
var callback = a[i++];
$.getJSON(url, data, function(o) {
callback(o);
next();
}, "json");
} else if (i < a.length) {
var finalCallback = a[i++];
finalCallback();
}
};
next();
var a = arguments;
var i = 0;
var next = function() {
if (i <= a.length - 3) {
var url = a[i++];
var data = a[i++];
var callback = a[i++];
$.getJSON(url, data, function(o) {
callback(o);
next();
}, "json");
} else if (i < a.length) {
var finalCallback = a[i++];
finalCallback();
}
};
next();
};

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,22 +29,22 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
(function() {
/*
* Make suggest widgets clean up when removed.
*/
var oldInit = $.suggest.suggest.prototype._init;
$.suggest.suggest.prototype._init = function() {
oldInit.call(this);
var self = this;
this.input.bind("remove", function() {
self._destroy();
});
};
/*
* Make suggest widgets clean up when removed.
*/
var oldInit = $.suggest.suggest.prototype._init;
$.suggest.suggest.prototype._init = function() {
oldInit.call(this);
var self = this;
this.input.bind("remove", function() {
self._destroy();
});
};
/*
* Property suggest
*/
@ -56,44 +56,44 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
$.suggest.suggest.prototype,
{
create_item: function(data, response_data) {
var css = this.options.css;
var li = $("<li>").addClass(css.item);
var name = $("<div>")
.addClass(css.item_name)
.append(
$("<label>").append(
$.suggest.strongify(
data.name || data.guid, response_data.prefix
)
)
);
data.name = name.text(); // this converts html escaped strings like "&amp;" back to "&"
li.append(name);
name.prepend($("<div>").addClass(css.item_type).text(data.id));
return li;
var css = this.options.css;
var li = $("<li>").addClass(css.item);
var name = $("<div>")
.addClass(css.item_name)
.append(
$("<label>").append(
$.suggest.strongify(
data.name || data.guid, response_data.prefix
)
)
);
data.name = name.text(); // this converts html escaped strings like "&amp;" back to "&"
li.append(name);
name.prepend($("<div>").addClass(css.item_type).text(data.id));
return li;
}
}
)
);
var originalSuggestP = $.suggest.suggestP;
$.suggest.suggestP = function(input, options) {
originalSuggestP.call(this, input, options);
if ("ac_param" in options) {
var ac_param = options.ac_param;
if ("schema" in ac_param) {
this.options.ac_param.schema = ac_param.schema;
}
originalSuggestP.call(this, input, options);
if ("ac_param" in options) {
var ac_param = options.ac_param;
if ("schema" in ac_param) {
this.options.ac_param.schema = ac_param.schema;
}
}
};
$.suggest.suggestP.prototype = originalSuggestP.prototype;
$.extend(
$.suggest.suggestP,
{
@ -101,15 +101,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
true,
{},
$.suggest.suggest.defaults, {
service_url: Refine.refineHelperService,
service_path: "/suggest_property",
flyout_service_url: "http://www.freebase.com",
css: { pane: "fbs-pane fbs-pane-property" }
service_url: Refine.refineHelperService,
service_path: "/suggest_property",
flyout_service_url: "http://www.freebase.com",
css: { pane: "fbs-pane fbs-pane-property" }
}
)
}
);
/*
* Type suggest
*/
@ -121,27 +121,27 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
$.suggest.suggest.prototype,
{
create_item: function(data, response_data) {
var css = this.options.css;
var css = this.options.css;
var li = $("<li>").addClass(css.item);
var li = $("<li>").addClass(css.item);
var name = $("<div>")
.addClass(css.item_name)
.append(
$("<label>")
.append($.suggest.strongify(data.name || data.guid, response_data.prefix)));
var name = $("<div>")
.addClass(css.item_name)
.append(
$("<label>")
.append($.suggest.strongify(data.name || data.guid, response_data.prefix)));
data.name = name.text(); // this converts html escaped strings like "&amp;" back to "&"
li.append(name);
data.name = name.text(); // this converts html escaped strings like "&amp;" back to "&"
li.append(name);
name.prepend($("<div>").addClass(css.item_type).text(data.id));
return li;
name.prepend($("<div>").addClass(css.item_type).text(data.id));
return li;
}
}
)
);
$.extend(
$.suggest.suggestT,
{
@ -149,7 +149,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
true,
{},
$.suggest.suggest.defaults, {
css: { pane: "fbs-pane fbs-pane-type" }
css: { pane: "fbs-pane fbs-pane-type" }
}
)
}

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,95 +29,95 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
DialogSystem = {
_layers: []
};
DialogSystem.showDialog = function(elmt, onCancel) {
var overlay = $('<div>&nbsp;</div>')
.addClass("dialog-overlay")
.css("z-index", 101 + DialogSystem._layers.length * 2)
.appendTo(document.body);
var container = $('<div></div>')
.addClass("dialog-container")
.css("z-index", 102 + DialogSystem._layers.length * 2)
.appendTo(document.body);
elmt.css("visibility", "hidden").appendTo(container);
container.css("top", Math.round((overlay.height() - elmt.height()) / 2) + "px");
elmt.css("visibility", "visible");
container.draggable({ handle: '.dialog-header', cursor: 'move' });
var layer = {
overlay: overlay,
container: container,
onCancel: onCancel
};
DialogSystem._layers.push(layer);
var level = DialogSystem._layers.length;
layer.keyHandler = function(evt) {
if (evt.keyCode == 27 && !evt.shiftKey && !evt.metaKey && !evt.altKey && !evt.ctrlKey &&
evt.target.tagName.toLowerCase() != "input" &&
evt.target.tagName.toLowerCase() != "textarea") {
DialogSystem.dismissUntil(level - 1);
evt.stopImmediatePropagation();
evt.stopPropagation();
evt.preventDefault();
return false;
}
};
$(document).stack("keydown", layer.keyHandler);
return level;
var overlay = $('<div>&nbsp;</div>')
.addClass("dialog-overlay")
.css("z-index", 101 + DialogSystem._layers.length * 2)
.appendTo(document.body);
var container = $('<div></div>')
.addClass("dialog-container")
.css("z-index", 102 + DialogSystem._layers.length * 2)
.appendTo(document.body);
elmt.css("visibility", "hidden").appendTo(container);
container.css("top", Math.round((overlay.height() - elmt.height()) / 2) + "px");
elmt.css("visibility", "visible");
container.draggable({ handle: '.dialog-header', cursor: 'move' });
var layer = {
overlay: overlay,
container: container,
onCancel: onCancel
};
DialogSystem._layers.push(layer);
var level = DialogSystem._layers.length;
layer.keyHandler = function(evt) {
if (evt.keyCode == 27 && !evt.shiftKey && !evt.metaKey && !evt.altKey && !evt.ctrlKey &&
evt.target.tagName.toLowerCase() != "input" &&
evt.target.tagName.toLowerCase() != "textarea") {
DialogSystem.dismissUntil(level - 1);
evt.stopImmediatePropagation();
evt.stopPropagation();
evt.preventDefault();
return false;
}
};
$(document).stack("keydown", layer.keyHandler);
return level;
};
DialogSystem.dismissAll = function() {
DialogSystem.dismissUntil(0);
DialogSystem.dismissUntil(0);
};
DialogSystem.dismissUntil = function(level) {
for (var i = DialogSystem._layers.length - 1; i >= level; i--) {
var layer = DialogSystem._layers[i];
$(document).unbind("keydown", layer.keyHandler);
layer.overlay.remove();
layer.container.remove();
layer.container.unbind();
if (layer.onCancel) {
try {
layer.onCancel();
} catch (e) {
Refine.reportException(e);
}
}
for (var i = DialogSystem._layers.length - 1; i >= level; i--) {
var layer = DialogSystem._layers[i];
$(document).unbind("keydown", layer.keyHandler);
layer.overlay.remove();
layer.container.remove();
layer.container.unbind();
if (layer.onCancel) {
try {
layer.onCancel();
} catch (e) {
Refine.reportException(e);
}
}
DialogSystem._layers = DialogSystem._layers.slice(0, level);
}
DialogSystem._layers = DialogSystem._layers.slice(0, level);
};
DialogSystem.createDialog = function() {
return $('<div></div>').addClass("dialog-frame");
return $('<div></div>').addClass("dialog-frame");
};
DialogSystem.showBusy = function(message) {
var frame = DialogSystem.createDialog();
frame.addClass("dialog-busy");
var body = $('<div>').attr('id', 'loading-message').appendTo(frame);
$('<img>').attr("src", "images/large-spinner.gif").appendTo(body);
$('<span>').text(" " + (message || "Working...")).appendTo(body);
var level = DialogSystem.showDialog(frame);
return function() {
DialogSystem.dismissUntil(level - 1);
};
var frame = DialogSystem.createDialog();
frame.addClass("dialog-busy");
var body = $('<div>').attr('id', 'loading-message').appendTo(frame);
$('<img>').attr("src", "images/large-spinner.gif").appendTo(body);
$('<span>').text(" " + (message || "Working...")).appendTo(body);
var level = DialogSystem.showDialog(frame);
return function() {
DialogSystem.dismissUntil(level - 1);
};
};

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,62 +29,62 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
var DOM = {};
DOM.bind = function(elmt) {
var map = {};
for (var i = 0; i < elmt.length; i++) {
DOM._bindDOMElement(elmt[i], map);
}
return map;
var map = {};
for (var i = 0; i < elmt.length; i++) {
DOM._bindDOMElement(elmt[i], map);
}
return map;
};
DOM._bindDOMElement = function(elmt, map) {
var bind = elmt.getAttribute("bind");
if (bind !== null && bind.length > 0) {
map[bind] = $(elmt);
}
if (elmt.hasChildNodes()) {
DOM._bindDOMChildren(elmt, map);
}
var bind = elmt.getAttribute("bind");
if (bind !== null && bind.length > 0) {
map[bind] = $(elmt);
}
if (elmt.hasChildNodes()) {
DOM._bindDOMChildren(elmt, map);
}
};
DOM._bindDOMChildren = function(elmt, map) {
var node = elmt.firstChild;
while (node !== null) {
var node2 = node.nextSibling;
if (node.nodeType == 1) {
DOM._bindDOMElement(node, map);
}
node = node2;
var node = elmt.firstChild;
while (node !== null) {
var node2 = node.nextSibling;
if (node.nodeType == 1) {
DOM._bindDOMElement(node, map);
}
node = node2;
}
};
DOM._loadedHTML = {};
DOM.loadHTML = function(module, path) {
var fullPath = ModuleWirings[module] + path;
if (!(fullPath in DOM._loadedHTML)) {
$.ajax({
async: false,
url: fullPath,
dataType: "html",
success: function(html) {
DOM._loadedHTML[fullPath] = html;
}
})
}
return DOM._loadedHTML[fullPath];
var fullPath = ModuleWirings[module] + path;
if (!(fullPath in DOM._loadedHTML)) {
$.ajax({
async: false,
url: fullPath,
dataType: "html",
success: function(html) {
DOM._loadedHTML[fullPath] = html;
}
})
}
return DOM._loadedHTML[fullPath];
};
DOM.getHPaddings = function(elmt) {
return elmt.outerWidth() - elmt.width();
return elmt.outerWidth() - elmt.width();
};
DOM.getVPaddings = function(elmt) {
return elmt.outerHeight() - elmt.height();
return elmt.outerHeight() - elmt.height();
};

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,264 +29,264 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
MenuSystem = {
_layers: [],
_overlay: null
_layers: [],
_overlay: null
};
MenuSystem.showMenu = function(elmt, onDismiss) {
if (!MenuSystem._overlay) {
MenuSystem._overlay = $('<div>&nbsp;</div>')
.addClass("menu-overlay")
.appendTo(document.body)
.click(MenuSystem.dismissAll);
if (!MenuSystem._overlay) {
MenuSystem._overlay = $('<div>&nbsp;</div>')
.addClass("menu-overlay")
.appendTo(document.body)
.click(MenuSystem.dismissAll);
}
elmt.css("z-index", 1010 + MenuSystem._layers.length).appendTo(document.body);
var layer = {
elmt: elmt,
onDismiss: onDismiss
};
MenuSystem._layers.push(layer);
var level = MenuSystem._layers.length;
layer.keyHandler = function(evt) {
if (evt.keyCode == 27 && !evt.shiftKey && !evt.metaKey && !evt.altKey && !evt.ctrlKey &&
evt.target.tagName.toLowerCase() != "input" &&
evt.target.tagName.toLowerCase() != "textarea") {
MenuSystem.dismissUntil(level - 1);
evt.stopImmediatePropagation();
evt.stopPropagation();
evt.preventDefault();
return false;
}
elmt.css("z-index", 1010 + MenuSystem._layers.length).appendTo(document.body);
var layer = {
elmt: elmt,
onDismiss: onDismiss
};
MenuSystem._layers.push(layer);
var level = MenuSystem._layers.length;
layer.keyHandler = function(evt) {
if (evt.keyCode == 27 && !evt.shiftKey && !evt.metaKey && !evt.altKey && !evt.ctrlKey &&
evt.target.tagName.toLowerCase() != "input" &&
evt.target.tagName.toLowerCase() != "textarea") {
MenuSystem.dismissUntil(level - 1);
evt.stopImmediatePropagation();
evt.stopPropagation();
evt.preventDefault();
return false;
}
};
$(document).stack("keydown", layer.keyHandler);
return level;
};
$(document).stack("keydown", layer.keyHandler);
return level;
};
MenuSystem.dismissAll = function() {
MenuSystem.dismissUntil(0);
if (MenuSystem._overlay !== null) {
MenuSystem._overlay.remove();
MenuSystem._overlay = null;
}
MenuSystem.dismissUntil(0);
if (MenuSystem._overlay !== null) {
MenuSystem._overlay.remove();
MenuSystem._overlay = null;
}
};
MenuSystem.dismissUntil = function(level) {
for (var i = MenuSystem._layers.length - 1; i >= level; i--) {
var layer = MenuSystem._layers[i];
$(document).unbind("keydown", layer.keyHandler);
layer.elmt.remove();
layer.elmt.unbind();
layer.onDismiss();
}
MenuSystem._layers = MenuSystem._layers.slice(0, level);
for (var i = MenuSystem._layers.length - 1; i >= level; i--) {
var layer = MenuSystem._layers[i];
$(document).unbind("keydown", layer.keyHandler);
layer.elmt.remove();
layer.elmt.unbind();
layer.onDismiss();
}
MenuSystem._layers = MenuSystem._layers.slice(0, level);
};
MenuSystem.createMenu = function() {
return $('<div></div>').addClass("menu-container");
return $('<div></div>').addClass("menu-container");
};
MenuSystem.createMenuItem = function() {
return $('<a href="javascript:{}"></a>').addClass("menu-item");
return $('<a href="javascript:{}"></a>').addClass("menu-item");
};
MenuSystem.positionMenuAboveBelow = function(menu, elmt) {
var offset = elmt.offset();
var windowWidth = $(window).width();
var windowHeight = $(window).height();
if (offset.top + elmt.outerHeight() - document.body.scrollTop + menu.outerHeight() > windowHeight - 10) {
menu.css("top", (offset.top - menu.outerHeight()) + "px");
} else {
menu.css("top", (offset.top + elmt.outerHeight()) + "px");
}
if (offset.left - document.body.scrollLeft + menu.outerWidth() > windowWidth - 10) {
menu.css("left", (offset.left + elmt.outerWidth() - menu.outerWidth()) + "px");
} else {
menu.css("left", offset.left + "px");
}
var offset = elmt.offset();
var windowWidth = $(window).width();
var windowHeight = $(window).height();
if (offset.top + elmt.outerHeight() - document.body.scrollTop + menu.outerHeight() > windowHeight - 10) {
menu.css("top", (offset.top - menu.outerHeight()) + "px");
} else {
menu.css("top", (offset.top + elmt.outerHeight()) + "px");
}
if (offset.left - document.body.scrollLeft + menu.outerWidth() > windowWidth - 10) {
menu.css("left", (offset.left + elmt.outerWidth() - menu.outerWidth()) + "px");
} else {
menu.css("left", offset.left + "px");
}
};
MenuSystem.positionMenuLeftRight = function(menu, elmt) {
var offset = elmt.offset();
var windowWidth = $(window).width();
var windowHeight = $(window).height();
if (offset.top - document.body.scrollTop + menu.outerHeight() > windowHeight - 10) {
menu.css("top", (offset.top + elmt.outerHeight() - menu.outerHeight()) + "px");
} else {
menu.css("top", offset.top + "px");
}
if (offset.left + elmt.outerWidth() - document.body.scrollLeft + menu.outerWidth() > windowWidth - 10) {
menu.css("left", Math.max(10, offset.left - menu.outerWidth()) + "px");
} else {
menu.css("left", (offset.left + elmt.outerWidth()) + "px");
}
var offset = elmt.offset();
var windowWidth = $(window).width();
var windowHeight = $(window).height();
if (offset.top - document.body.scrollTop + menu.outerHeight() > windowHeight - 10) {
menu.css("top", (offset.top + elmt.outerHeight() - menu.outerHeight()) + "px");
} else {
menu.css("top", offset.top + "px");
}
if (offset.left + elmt.outerWidth() - document.body.scrollLeft + menu.outerWidth() > windowWidth - 10) {
menu.css("left", Math.max(10, offset.left - menu.outerWidth()) + "px");
} else {
menu.css("left", (offset.left + elmt.outerWidth()) + "px");
}
};
MenuSystem.createAndShowStandardMenu = function(items, elmt, options) {
options = options || {
horizontal: false
};
var menu = MenuSystem.createMenu();
if ("width" in options) {
menu.width(options.width);
}
var createMenuItem = function(item) {
if ("label" in item) {
var menuItem = MenuSystem.createMenuItem().appendTo(menu);
if ("submenu" in item) {
menuItem.html(
'<table width="100%" cellspacing="0" cellpadding="0" class="menu-item-layout"><tr>' +
'<td>' + item.label + '</td>' +
'<td width="1%"><img src="/images/right-arrow.png" /></td>' +
'</tr></table>'
);
menuItem.mouseenter(function() {
MenuSystem.dismissUntil(level);
menuItem.addClass("menu-expanded");
var options = {
horizontal: true,
onDismiss: function() {
menuItem.removeClass("menu-expanded");
}
};
if ("width" in item) {
options.width = item.width;
}
MenuSystem.createAndShowStandardMenu(item.submenu, this, options);
});
} else {
menuItem.html(item.label).click(function(evt) {
item.click.call(this, evt);
MenuSystem.dismissAll();
});
if ("tooltip" in item) {
menuItem.attr("title", item.tooltip);
}
menuItem.mouseenter(function() {
MenuSystem.dismissUntil(level);
});
options = options || {
horizontal: false
};
var menu = MenuSystem.createMenu();
if ("width" in options) {
menu.width(options.width);
}
var createMenuItem = function(item) {
if ("label" in item) {
var menuItem = MenuSystem.createMenuItem().appendTo(menu);
if ("submenu" in item) {
menuItem.html(
'<table width="100%" cellspacing="0" cellpadding="0" class="menu-item-layout"><tr>' +
'<td>' + item.label + '</td>' +
'<td width="1%"><img src="/images/right-arrow.png" /></td>' +
'</tr></table>'
);
menuItem.mouseenter(function() {
MenuSystem.dismissUntil(level);
menuItem.addClass("menu-expanded");
var options = {
horizontal: true,
onDismiss: function() {
menuItem.removeClass("menu-expanded");
}
} else if ("heading" in item) {
$('<div></div>').addClass("menu-section").text(item.heading).appendTo(menu);
} else {
$('<hr />').appendTo(menu);
};
if ("width" in item) {
options.width = item.width;
}
MenuSystem.createAndShowStandardMenu(item.submenu, this, options);
});
} else {
menuItem.html(item.label).click(function(evt) {
item.click.call(this, evt);
MenuSystem.dismissAll();
});
if ("tooltip" in item) {
menuItem.attr("title", item.tooltip);
}
};
for (var i = 0; i < items.length; i++) {
createMenuItem(items[i]);
}
var level = MenuSystem.showMenu(menu, "onDismiss" in options ? options.onDismiss : function(){});
if (options.horizontal) {
MenuSystem.positionMenuLeftRight(menu, $(elmt));
menuItem.mouseenter(function() {
MenuSystem.dismissUntil(level);
});
}
} else if ("heading" in item) {
$('<div></div>').addClass("menu-section").text(item.heading).appendTo(menu);
} else {
MenuSystem.positionMenuAboveBelow(menu, $(elmt));
$('<hr />').appendTo(menu);
}
return level;
};
for (var i = 0; i < items.length; i++) {
createMenuItem(items[i]);
}
var level = MenuSystem.showMenu(menu, "onDismiss" in options ? options.onDismiss : function(){});
if (options.horizontal) {
MenuSystem.positionMenuLeftRight(menu, $(elmt));
} else {
MenuSystem.positionMenuAboveBelow(menu, $(elmt));
}
return level;
};
MenuSystem.find = function(rootItems, path, levels) {
var menuItems = rootItems;
for (var p = 0; p < path.length && p < levels; p++) {
var segment = path[p];
var subMenuItems;
for (var i = 0; i < menuItems.length; i++) {
var menuItem = menuItems[i];
if (menuItem.id == segment) {
if ("submenu" in menuItem) {
subMenuItems = menuItem.submenu;
} else {
return undefined;
}
break;
}
}
if (subMenuItems) {
menuItems = subMenuItems;
var menuItems = rootItems;
for (var p = 0; p < path.length && p < levels; p++) {
var segment = path[p];
var subMenuItems;
for (var i = 0; i < menuItems.length; i++) {
var menuItem = menuItems[i];
if (menuItem.id == segment) {
if ("submenu" in menuItem) {
subMenuItems = menuItem.submenu;
} else {
return undefined;
return undefined;
}
break;
}
}
return menuItems;
if (subMenuItems) {
menuItems = subMenuItems;
} else {
return undefined;
}
}
return menuItems;
};
MenuSystem.appendTo = function(rootItems, path, what) {
var menuItems = MenuSystem.find(rootItems, path, path.length);
if (menuItems) {
if (what instanceof Array) {
$.merge(menuItems, what);
} else {
menuItems.push(what);
}
var menuItems = MenuSystem.find(rootItems, path, path.length);
if (menuItems) {
if (what instanceof Array) {
$.merge(menuItems, what);
} else {
menuItems.push(what);
}
}
};
MenuSystem.insertBefore = function(rootItems, path, what) {
var menuItems = MenuSystem.find(rootItems, path, path.length - 1);
if ((menuItems) && path.length > 0) {
var spliceArgs = [ 0, 0 ];
if (what instanceof Array) {
$.merge(spliceArgs, what);
} else {
spliceArgs.push(what);
}
var segment = path[path.length - 1];
for (var i = 0; i < menuItems.length; i++) {
var menuItem = menuItems[i];
if (menuItem.id == segment) {
spliceArgs[0] = i;
break;
}
}
Array.prototype.splice.apply(menuItems, spliceArgs);
var menuItems = MenuSystem.find(rootItems, path, path.length - 1);
if ((menuItems) && path.length > 0) {
var spliceArgs = [ 0, 0 ];
if (what instanceof Array) {
$.merge(spliceArgs, what);
} else {
spliceArgs.push(what);
}
var segment = path[path.length - 1];
for (var i = 0; i < menuItems.length; i++) {
var menuItem = menuItems[i];
if (menuItem.id == segment) {
spliceArgs[0] = i;
break;
}
}
Array.prototype.splice.apply(menuItems, spliceArgs);
}
};
MenuSystem.insertAfter = function(rootItems, path, what) {
var menuItems = MenuSystem.find(rootItems, path, path.length - 1);
if ((menuItems) && path.length > 0) {
var spliceArgs = [ menuItems.length, 0 ];
if (what instanceof Array) {
$.merge(spliceArgs, what);
} else {
spliceArgs.push(what);
}
var segment = path[path.length - 1];
for (var i = 0; i < menuItems.length; i++) {
var menuItem = menuItems[i];
if (menuItem.id == segment) {
spliceArgs[0] = i + 1;
break;
}
}
Array.prototype.splice.apply(menuItems, spliceArgs);
var menuItems = MenuSystem.find(rootItems, path, path.length - 1);
if ((menuItems) && path.length > 0) {
var spliceArgs = [ menuItems.length, 0 ];
if (what instanceof Array) {
$.merge(spliceArgs, what);
} else {
spliceArgs.push(what);
}
var segment = path[path.length - 1];
for (var i = 0; i < menuItems.length; i++) {
var menuItem = menuItems[i];
if (menuItem.id == segment) {
spliceArgs[0] = i + 1;
break;
}
}
Array.prototype.splice.apply(menuItems, spliceArgs);
}
};

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,28 +29,28 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
function cloneDeep(o) {
if (o === undefined || o === null) {
return o;
} else if (o instanceof Function) {
return o;
} else if (o instanceof Array) {
var a = [];
for (var i = 0; i < o.length; i++) {
a.push(cloneDeep(o[i]));
}
return a;
} else if (o instanceof Object) {
var a = {};
for (var n in o) {
if (o.hasOwnProperty(n)) {
a[n] = cloneDeep(o[n]);
}
}
return a;
} else {
return o;
if (o === undefined || o === null) {
return o;
} else if (o instanceof Function) {
return o;
} else if (o instanceof Array) {
var a = [];
for (var i = 0; i < o.length; i++) {
a.push(cloneDeep(o[i]));
}
return a;
} else if (o instanceof Object) {
var a = {};
for (var n in o) {
if (o.hasOwnProperty(n)) {
a[n] = cloneDeep(o[n]);
}
}
return a;
} else {
return o;
}
}

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,20 +29,20 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
String.prototype.trim = function() {
return this.replace(/^\s+/, '').replace(/\s+$/, '');
return this.replace(/^\s+/, '').replace(/\s+$/, '');
};
String.prototype.startsWith = function(s) {
return this.length >= s.length && this.substring(0, s.length) == s;
return this.length >= s.length && this.substring(0, s.length) == s;
};
String.prototype.endsWith = function(s) {
return this.length >= s.length && this.substring(this.length - s.length) == s;
return this.length >= s.length && this.substring(this.length - s.length) == s;
};
String.prototype.contains = function(s) {
return this.indexOf(s) >= 0;
return this.indexOf(s) >= 0;
};

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,89 +29,89 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
URL = {
schemes: { // 1 means followed by ://, 0 means followed by just :
"callto":0,
"chrome":1,
"file":1,
"ftp":1,
"http":1,
"https":1,
"imap":1,
"info":0,
"irc":1,
"jar":0,
"javascript":0,
"lastfm":1,
"ldap":1,
"ldaps":1,
"mailto":0,
"news":0,
"nntp":1,
"pop":1,
"sftp":1,
"skype":0,
"smb":1,
"ssh":1,
"svn":1,
"svn+ssh":1,
"telnet":1,
"view-source":0
}
schemes: { // 1 means followed by ://, 0 means followed by just :
"callto":0,
"chrome":1,
"file":1,
"ftp":1,
"http":1,
"https":1,
"imap":1,
"info":0,
"irc":1,
"jar":0,
"javascript":0,
"lastfm":1,
"ldap":1,
"ldaps":1,
"mailto":0,
"news":0,
"nntp":1,
"pop":1,
"sftp":1,
"skype":0,
"smb":1,
"ssh":1,
"svn":1,
"svn+ssh":1,
"telnet":1,
"view-source":0
}
};
(function() {
var minLength = 100;
var maxLength = 0;
for (var n in URL.schemes) {
minLength = Math.min(minLength, n.length);
maxLength = Math.max(maxLength, n.length);
}
URL.minSchemeLength = minLength;
URL.maxSchemeLength = maxLength;
var minLength = 100;
var maxLength = 0;
for (var n in URL.schemes) {
minLength = Math.min(minLength, n.length);
maxLength = Math.max(maxLength, n.length);
}
URL.minSchemeLength = minLength;
URL.maxSchemeLength = maxLength;
})();
URL.getParameters = function() {
var r = {};
var params = window.location.search;
if (params.length > 1) {
params = params.substr(1).split("&");
$.each(params, function() {
pair = this.split("=");
r[pair[0]] = unescape(pair[1]);
});
}
return r;
var r = {};
var params = window.location.search;
if (params.length > 1) {
params = params.substr(1).split("&");
$.each(params, function() {
pair = this.split("=");
r[pair[0]] = unescape(pair[1]);
});
}
return r;
};
URL.looksLikeUrl = function(s) {
if (s.length > URL.minSchemeLength + 1) {
var sep = s.substring(0, URL.maxSchemeLength + 3).indexOf(":");
if (sep >= URL.minSchemeLength) {
var scheme = s.substring(0, sep).toLowerCase();
if (scheme in URL.schemes) {
return URL.schemes[scheme] == 0 ||
s.substring(sep + 1, sep + 3) == "//";
}
}
if (s.length > URL.minSchemeLength + 1) {
var sep = s.substring(0, URL.maxSchemeLength + 3).indexOf(":");
if (sep >= URL.minSchemeLength) {
var scheme = s.substring(0, sep).toLowerCase();
if (scheme in URL.schemes) {
return URL.schemes[scheme] == 0 ||
s.substring(sep + 1, sep + 3) == "//";
}
}
return false;
}
return false;
};
URL.getHostname = function(){
var url = location.href; // entire url including querystring - also: window.location.href;
var baseURL = url.substring(0, url.indexOf('/',7));//7 is the length of http://
return baseURL;
var url = location.href; // entire url including querystring - also: window.location.href;
var baseURL = url.substring(0, url.indexOf('/',7));//7 is the length of http://
return baseURL;
};
URL.urlify = function(str) {
if(!str) {
return '';
}
return escape(str.replace(/\W/g, '_'));
if(!str) {
return '';
}
return escape(str.replace(/\W/g, '_'));
};

View File

@ -3,20 +3,20 @@
<div class="dialog-header" bind="dialogHeader"></div>
<div class="dialog-body" bind="dialogBody">
<div class="grid-layout layout-normal layout-full"><table cols="2">
<tr>
<td width="1%" style="white-space: pre;">New column name</td>
<td><input bind="columnNameInput" size="40" /></td>
<td width="1%" style="white-space: pre;">Throttle delay</td>
<td><input bind="throttleDelayInput" size="10" value="5000" /> milliseconds</td>
</tr>
<tr>
<td width="1%" style="white-space: pre;">On error</td>
<td colspan="3"><input type="radio" name="dialog-onerror-choice" value="set-to-blank" checked /> set to blank
<input type="radio" name="dialog-onerror-choice" value="store-error" /> store error</td>
</tr>
<tr><td colspan="4"><h3>Formulate the URLs to fetch:</h3></td></tr>
<tr><td colspan="4">$EXPRESSION_PREVIEW_WIDGET$</td></tr>
<tr>
<td width="1%" style="white-space: pre;">New column name</td>
<td><input bind="columnNameInput" size="40" /></td>
<td width="1%" style="white-space: pre;">Throttle delay</td>
<td><input bind="throttleDelayInput" size="10" value="5000" /> milliseconds</td>
</tr>
<tr>
<td width="1%" style="white-space: pre;">On error</td>
<td colspan="3"><input type="radio" name="dialog-onerror-choice" value="set-to-blank" checked /> set to blank
<input type="radio" name="dialog-onerror-choice" value="store-error" /> store error</td>
</tr>
<tr><td colspan="4"><h3>Formulate the URLs to fetch:</h3></td></tr>
<tr><td colspan="4">$EXPRESSION_PREVIEW_WIDGET$</td></tr>
</table></div>
</div>
<div class="dialog-footer" bind="dialogFooter">

View File

@ -3,15 +3,15 @@
<div class="dialog-header" bind="dialogHeader"></div>
<div class="dialog-body" bind="dialogBody">
<div class="grid-layout layout-normal layout-full"><table cols="2">
<tr>
<td width="1%" style="white-space: pre;">New column name</td>
<td><input bind="columnNameInput" size="40" /></td>
</tr>
<tr>
<td width="1%" style="white-space: pre;">On error</td>
<td><input type="radio" name="create-column-dialog-onerror-choice" value="set-to-blank" checked /> set to blank <input type="radio" name="create-column-dialog-onerror-choice" value="store-error" /> store error <input type="radio" name="create-column-dialog-onerror-choice" value="keep-original" /> keep original</td>
</tr>
<tr><td colspan="2">$EXPRESSION_PREVIEW_WIDGET$</td></tr>
<tr>
<td width="1%" style="white-space: pre;">New column name</td>
<td><input bind="columnNameInput" size="40" /></td>
</tr>
<tr>
<td width="1%" style="white-space: pre;">On error</td>
<td><input type="radio" name="create-column-dialog-onerror-choice" value="set-to-blank" checked /> set to blank <input type="radio" name="create-column-dialog-onerror-choice" value="store-error" /> store error <input type="radio" name="create-column-dialog-onerror-choice" value="keep-original" /> keep original</td>
</tr>
<tr><td colspan="2">$EXPRESSION_PREVIEW_WIDGET$</td></tr>
</table></div>
</div>
<div class="dialog-footer" bind="dialogFooter">

File diff suppressed because it is too large Load Diff

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,322 +29,322 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
function DataTableColumnHeaderUI(dataTableView, column, columnIndex, td) {
this._dataTableView = dataTableView;
this._column = column;
this._columnIndex = columnIndex;
this._td = td;
this._render();
this._dataTableView = dataTableView;
this._column = column;
this._columnIndex = columnIndex;
this._td = td;
this._render();
}
DataTableColumnHeaderUI._extenders = [];
/*
To extend, call
DataTableColumnHeaderUI.extendMenu(function(column, columnHeaderUI, menu) {
...
MenuSystem.appendTo(menu, path, newItems);
});
*/
To extend, call
DataTableColumnHeaderUI.extendMenu(function(column, columnHeaderUI, menu) {
...
MenuSystem.appendTo(menu, path, newItems);
});
*/
DataTableColumnHeaderUI.extendMenu = function(extender) {
DataTableColumnHeaderUI._extenders.push(extender);
DataTableColumnHeaderUI._extenders.push(extender);
};
DataTableColumnHeaderUI.prototype.getColumn = function() {
return this._column;
return this._column;
};
DataTableColumnHeaderUI.prototype._render = function() {
var self = this;
var td = $(this._td);
td.html(DOM.loadHTML("core", "scripts/views/data-table/column-header.html"));
var elmts = DOM.bind(td);
elmts.nameContainer.text(this._column.name);
elmts.dropdownMenu.click(function() {
self._createMenuForColumnHeader(this);
});
if ("reconStats" in this._column) {
var stats = this._column.reconStats;
if (stats.nonBlanks > 0) {
var newPercent = Math.ceil(100 * stats.newTopics / stats.nonBlanks);
var matchPercent = Math.ceil(100 * stats.matchedTopics / stats.nonBlanks);
var unreconciledPercent = Math.ceil(100 * (stats.nonBlanks - stats.matchedTopics - stats.newTopics) / stats.nonBlanks);
var title = matchPercent + "% matched, " + newPercent + "% new, " + unreconciledPercent + "% to be reconciled";
var whole = $('<div>')
.addClass("column-header-recon-stats-bar")
.attr("title", title)
.appendTo(elmts.reconStatsContainer.show());
$('<div>')
.addClass("column-header-recon-stats-blanks")
.width(Math.round((stats.newTopics + stats.matchedTopics) * 100 / stats.nonBlanks) + "%")
.appendTo(whole);
$('<div>')
.addClass("column-header-recon-stats-matched")
.width(Math.round(stats.matchedTopics * 100 / stats.nonBlanks) + "%")
.appendTo(whole);
}
var self = this;
var td = $(this._td);
td.html(DOM.loadHTML("core", "scripts/views/data-table/column-header.html"));
var elmts = DOM.bind(td);
elmts.nameContainer.text(this._column.name);
elmts.dropdownMenu.click(function() {
self._createMenuForColumnHeader(this);
});
if ("reconStats" in this._column) {
var stats = this._column.reconStats;
if (stats.nonBlanks > 0) {
var newPercent = Math.ceil(100 * stats.newTopics / stats.nonBlanks);
var matchPercent = Math.ceil(100 * stats.matchedTopics / stats.nonBlanks);
var unreconciledPercent = Math.ceil(100 * (stats.nonBlanks - stats.matchedTopics - stats.newTopics) / stats.nonBlanks);
var title = matchPercent + "% matched, " + newPercent + "% new, " + unreconciledPercent + "% to be reconciled";
var whole = $('<div>')
.addClass("column-header-recon-stats-bar")
.attr("title", title)
.appendTo(elmts.reconStatsContainer.show());
$('<div>')
.addClass("column-header-recon-stats-blanks")
.width(Math.round((stats.newTopics + stats.matchedTopics) * 100 / stats.nonBlanks) + "%")
.appendTo(whole);
$('<div>')
.addClass("column-header-recon-stats-matched")
.width(Math.round(stats.matchedTopics * 100 / stats.nonBlanks) + "%")
.appendTo(whole);
}
}
};
DataTableColumnHeaderUI.prototype._createMenuForColumnHeader = function(elmt) {
var self = this;
var menu = [
var self = this;
var menu = [
{
id: "core/facet",
label: "Facet",
width: "170px",
submenu: []
},
{},
{
id: "core/edit-cells",
label: "Edit cells",
width: "170px",
submenu: []
},
{
id: "core/edit-column",
label: "Edit column",
submenu: []
},
{
id: "core/transpose",
label: "Transpose",
submenu: []
},
{},
(
this._dataTableView._getSortingCriterionForColumn(this._column.name) == null ?
{
id: "core/facet",
label: "Facet",
width: "170px",
submenu: []
},
{},
id: "core/sort",
"label": "Sort...",
"click": function() {
self._showSortingCriterion(null, self._dataTableView._getSortingCriteriaCount() > 0)
}
} :
{
id: "core/edit-cells",
label: "Edit cells",
width: "170px",
submenu: []
},
{
id: "core/edit-column",
label: "Edit column",
submenu: []
},
{
id: "core/transpose",
label: "Transpose",
submenu: []
},
{},
(
this._dataTableView._getSortingCriterionForColumn(this._column.name) == null ?
{
id: "core/sort",
"label": "Sort...",
"click": function() {
self._showSortingCriterion(null, self._dataTableView._getSortingCriteriaCount() > 0)
}
} :
{
id: "core/sort",
label: "Sort",
submenu: this.createSortingMenu()
}
),
{
id: "core/view",
label: "View",
tooltip: "Collapse/expand columns to make viewing the data more convenient",
submenu: [
{
label: "Collapse this column",
click: function() {
self._dataTableView._collapsedColumnNames[self._column.name] = true;
self._dataTableView.render();
}
},
{
label: "Collapse all other columns",
click: function() {
var collapsedColumnNames = {};
for (var i = 0; i < theProject.columnModel.columns.length; i++) {
if (i != self._columnIndex) {
collapsedColumnNames[theProject.columnModel.columns[i].name] = true;
}
}
self._dataTableView._collapsedColumnNames = collapsedColumnNames;
self._dataTableView.render();
}
},
{
label: "Collapse all columns to left",
click: function() {
for (var i = 0; i < self._columnIndex; i++) {
self._dataTableView._collapsedColumnNames[theProject.columnModel.columns[i].name] = true;
}
self._dataTableView.render();
}
},
{
label: "Collapse all columns to right",
click: function() {
for (var i = self._columnIndex + 1; i < theProject.columnModel.columns.length; i++) {
self._dataTableView._collapsedColumnNames[theProject.columnModel.columns[i].name] = true;
}
self._dataTableView.render();
}
}
]
},
{},
{
id: "core/reconcile",
label: "Reconcile",
tooltip: "Match this column's cells to topics on Freebase",
width: "170px",
submenu: []
id: "core/sort",
label: "Sort",
submenu: this.createSortingMenu()
}
];
for (var i = 0; i < DataTableColumnHeaderUI._extenders.length; i++) {
DataTableColumnHeaderUI._extenders[i].call(null, this._column, this, menu);
),
{
id: "core/view",
label: "View",
tooltip: "Collapse/expand columns to make viewing the data more convenient",
submenu: [
{
label: "Collapse this column",
click: function() {
self._dataTableView._collapsedColumnNames[self._column.name] = true;
self._dataTableView.render();
}
},
{
label: "Collapse all other columns",
click: function() {
var collapsedColumnNames = {};
for (var i = 0; i < theProject.columnModel.columns.length; i++) {
if (i != self._columnIndex) {
collapsedColumnNames[theProject.columnModel.columns[i].name] = true;
}
}
self._dataTableView._collapsedColumnNames = collapsedColumnNames;
self._dataTableView.render();
}
},
{
label: "Collapse all columns to left",
click: function() {
for (var i = 0; i < self._columnIndex; i++) {
self._dataTableView._collapsedColumnNames[theProject.columnModel.columns[i].name] = true;
}
self._dataTableView.render();
}
},
{
label: "Collapse all columns to right",
click: function() {
for (var i = self._columnIndex + 1; i < theProject.columnModel.columns.length; i++) {
self._dataTableView._collapsedColumnNames[theProject.columnModel.columns[i].name] = true;
}
self._dataTableView.render();
}
}
]
},
{},
{
id: "core/reconcile",
label: "Reconcile",
tooltip: "Match this column's cells to topics on Freebase",
width: "170px",
submenu: []
}
MenuSystem.createAndShowStandardMenu(menu, elmt, { width: "120px", horizontal: false });
];
for (var i = 0; i < DataTableColumnHeaderUI._extenders.length; i++) {
DataTableColumnHeaderUI._extenders[i].call(null, this._column, this, menu);
}
MenuSystem.createAndShowStandardMenu(menu, elmt, { width: "120px", horizontal: false });
};
DataTableColumnHeaderUI.prototype.createSortingMenu = function() {
var self = this;
var criterion = this._dataTableView._getSortingCriterionForColumn(this._column.name);
var criteriaCount = this._dataTableView._getSortingCriteriaCount();
var hasOtherCriteria = criterion == null ? (criteriaCount > 0) : criteriaCount > 1;
var items = [
{
"label": "Sort...",
"click": function() {
self._showSortingCriterion(criterion, hasOtherCriteria)
}
}
];
if (criterion != null) {
items.push({
"label": "Reverse",
"click": function() {
criterion.reverse = !criterion.reverse;
self._dataTableView._addSortingCriterion(criterion);
}
});
items.push({
"label": "Remove sort",
"click": function() {
self._dataTableView._removeSortingCriterionOfColumn(criterion.column);
}
});
var self = this;
var criterion = this._dataTableView._getSortingCriterionForColumn(this._column.name);
var criteriaCount = this._dataTableView._getSortingCriteriaCount();
var hasOtherCriteria = criterion == null ? (criteriaCount > 0) : criteriaCount > 1;
var items = [
{
"label": "Sort...",
"click": function() {
self._showSortingCriterion(criterion, hasOtherCriteria)
}
}
return items;
];
if (criterion != null) {
items.push({
"label": "Reverse",
"click": function() {
criterion.reverse = !criterion.reverse;
self._dataTableView._addSortingCriterion(criterion);
}
});
items.push({
"label": "Remove sort",
"click": function() {
self._dataTableView._removeSortingCriterionOfColumn(criterion.column);
}
});
}
return items;
};
DataTableColumnHeaderUI.prototype._showSortingCriterion = function(criterion, hasOtherCriteria) {
criterion = criterion || {
column: this._column.name,
valueType: "string",
caseSensitive: false,
errorPosition: 1,
blankPosition: 2
};
var self = this;
var frame = $(DOM.loadHTML("core", "scripts/views/data-table/sorting-criterion-dialog.html"));
var elmts = DOM.bind(frame);
elmts.dialogHeader.text('Sort by ' + this._column.name);
elmts.valueTypeOptions
.find("input[type='radio'][value='" + criterion.valueType + "']")
.attr("checked", "checked");
var setValueType = function(valueType) {
var forward = elmts.directionForwardLabel;
var reverse = elmts.directionReverseLabel;
if (valueType == "string") {
forward.html("a - z");
reverse.html("z - a");
} else if (valueType == "number") {
forward.html("smallest first");
reverse.html("largest first");
} else if (valueType == "date") {
forward.html("earliest first");
reverse.html("latest first");
} else if (valueType == "boolean") {
forward.html("false then true");
reverse.html("true then false");
}
};
elmts.valueTypeOptions
.find("input[type='radio']")
.change(function() {
setValueType(this.value);
});
if (criterion.valueType == "string" && criterion.caseSensitive) {
elmts.caseSensitiveCheckbox.attr("checked", "checked");
}
elmts.directionOptions
.find("input[type='radio'][value='" + (criterion.reverse ? "reverse" : "forward") + "']")
.attr("checked", "checked");
criterion = criterion || {
column: this._column.name,
valueType: "string",
caseSensitive: false,
errorPosition: 1,
blankPosition: 2
};
if (hasOtherCriteria) {
elmts.sortAloneContainer.show();
var self = this;
var frame = $(DOM.loadHTML("core", "scripts/views/data-table/sorting-criterion-dialog.html"));
var elmts = DOM.bind(frame);
elmts.dialogHeader.text('Sort by ' + this._column.name);
elmts.valueTypeOptions
.find("input[type='radio'][value='" + criterion.valueType + "']")
.attr("checked", "checked");
var setValueType = function(valueType) {
var forward = elmts.directionForwardLabel;
var reverse = elmts.directionReverseLabel;
if (valueType == "string") {
forward.html("a - z");
reverse.html("z - a");
} else if (valueType == "number") {
forward.html("smallest first");
reverse.html("largest first");
} else if (valueType == "date") {
forward.html("earliest first");
reverse.html("latest first");
} else if (valueType == "boolean") {
forward.html("false then true");
reverse.html("true then false");
}
var validValuesHtml = '<li kind="value">Valid values</li>';
var blankValuesHtml = '<li kind="blank">Blanks</li>';
var errorValuesHtml = '<li kind="error">Errors</li>';
var positionsHtml;
if (criterion.blankPosition < 0) {
if (criterion.errorPosition > 0) {
positionsHtml = [ blankValuesHtml, validValuesHtml, errorValuesHtml ];
} else if (criterion.errorPosition < criterion.blankPosition) {
positionsHtml = [ errorValuesHtml, blankValuesHtml, validValuesHtml ];
} else {
positionsHtml = [ blankValuesHtml, errorValuesHtml, validValuesHtml ];
}
};
elmts.valueTypeOptions
.find("input[type='radio']")
.change(function() {
setValueType(this.value);
});
if (criterion.valueType == "string" && criterion.caseSensitive) {
elmts.caseSensitiveCheckbox.attr("checked", "checked");
}
elmts.directionOptions
.find("input[type='radio'][value='" + (criterion.reverse ? "reverse" : "forward") + "']")
.attr("checked", "checked");
if (hasOtherCriteria) {
elmts.sortAloneContainer.show();
}
var validValuesHtml = '<li kind="value">Valid values</li>';
var blankValuesHtml = '<li kind="blank">Blanks</li>';
var errorValuesHtml = '<li kind="error">Errors</li>';
var positionsHtml;
if (criterion.blankPosition < 0) {
if (criterion.errorPosition > 0) {
positionsHtml = [ blankValuesHtml, validValuesHtml, errorValuesHtml ];
} else if (criterion.errorPosition < criterion.blankPosition) {
positionsHtml = [ errorValuesHtml, blankValuesHtml, validValuesHtml ];
} else {
if (criterion.errorPosition < 0) {
positionsHtml = [ errorValuesHtml, validValuesHtml, blankValuesHtml ];
} else if (criterion.errorPosition < criterion.blankPosition) {
positionsHtml = [ validValuesHtml, errorValuesHtml, blankValuesHtml ];
} else {
positionsHtml = [ validValuesHtml, blankValuesHtml, errorValuesHtml ];
}
positionsHtml = [ blankValuesHtml, errorValuesHtml, validValuesHtml ];
}
elmts.blankErrorPositions.html(positionsHtml.join("")).sortable().disableSelection();
var level = DialogSystem.showDialog(frame);
var dismiss = function() { DialogSystem.dismissUntil(level - 1); };
setValueType(criterion.valueType);
elmts.cancelButton.click(dismiss);
elmts.okButton.click(function() {
var criterion2 = {
column: self._column.name,
valueType: elmts.valueTypeOptions.find("input[type='radio']:checked")[0].value,
reverse: elmts.directionOptions.find("input[type='radio']:checked")[0].value == "reverse"
};
var valuePosition, blankPosition, errorPosition;
elmts.blankErrorPositions.find("li").each(function(index, elmt) {
var kind = this.getAttribute("kind");
if (kind == "value") {
valuePosition = index;
} else if (kind == "blank") {
blankPosition = index;
} else if (kind == "error") {
errorPosition = index;
}
});
criterion2.blankPosition = blankPosition - valuePosition;
criterion2.errorPosition = errorPosition - valuePosition;
if (criterion2.valueType == "string") {
criterion2.caseSensitive = elmts.caseSensitiveCheckbox[0].checked;
}
self._dataTableView._addSortingCriterion(
criterion2, elmts.sortAloneContainer.find("input")[0].checked);
dismiss();
} else {
if (criterion.errorPosition < 0) {
positionsHtml = [ errorValuesHtml, validValuesHtml, blankValuesHtml ];
} else if (criterion.errorPosition < criterion.blankPosition) {
positionsHtml = [ validValuesHtml, errorValuesHtml, blankValuesHtml ];
} else {
positionsHtml = [ validValuesHtml, blankValuesHtml, errorValuesHtml ];
}
}
elmts.blankErrorPositions.html(positionsHtml.join("")).sortable().disableSelection();
var level = DialogSystem.showDialog(frame);
var dismiss = function() { DialogSystem.dismissUntil(level - 1); };
setValueType(criterion.valueType);
elmts.cancelButton.click(dismiss);
elmts.okButton.click(function() {
var criterion2 = {
column: self._column.name,
valueType: elmts.valueTypeOptions.find("input[type='radio']:checked")[0].value,
reverse: elmts.directionOptions.find("input[type='radio']:checked")[0].value == "reverse"
};
var valuePosition, blankPosition, errorPosition;
elmts.blankErrorPositions.find("li").each(function(index, elmt) {
var kind = this.getAttribute("kind");
if (kind == "value") {
valuePosition = index;
} else if (kind == "blank") {
blankPosition = index;
} else if (kind == "error") {
errorPosition = index;
}
});
criterion2.blankPosition = blankPosition - valuePosition;
criterion2.errorPosition = errorPosition - valuePosition;
if (criterion2.valueType == "string") {
criterion2.caseSensitive = elmts.caseSensitiveCheckbox[0].checked;
}
self._dataTableView._addSortingCriterion(
criterion2, elmts.sortAloneContainer.find("input")[0].checked);
dismiss();
});
};

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,318 +29,319 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
DataTableColumnHeaderUI.extendMenu(function(column, columnHeaderUI, menu) {
var doTextTransform = function(expression, onError, repeat, repeatCount) {
Refine.postCoreProcess(
"text-transform",
{
columnName: column.name,
expression: expression,
onError: onError,
repeat: repeat,
repeatCount: repeatCount
},
null,
{ cellsChanged: true }
);
var doTextTransform = function(expression, onError, repeat, repeatCount) {
Refine.postCoreProcess(
"text-transform",
{
columnName: column.name,
expression: expression,
onError: onError,
repeat: repeat,
repeatCount: repeatCount
},
null,
{ cellsChanged: true }
);
};
var doTextTransformPrompt = function() {
var frame = $(
DOM.loadHTML("core", "scripts/views/data-table/text-transform-dialog.html")
.replace("$EXPRESSION_PREVIEW_WIDGET$", ExpressionPreviewDialog.generateWidgetHtml()));
var elmts = DOM.bind(frame);
elmts.dialogHeader.text("Custom text transform on column " + column.name);
var level = DialogSystem.showDialog(frame);
var dismiss = function() { DialogSystem.dismissUntil(level - 1); };
elmts.cancelButton.click(dismiss);
elmts.okButton.click(function() {
doTextTransform(
previewWidget.getExpression(true),
$('input[name="text-transform-dialog-onerror-choice"]:checked')[0].value,
elmts.repeatCheckbox[0].checked,
elmts.repeatCountInput[0].value
);
dismiss();
});
var o = DataTableView.sampleVisibleRows(column);
var previewWidget = new ExpressionPreviewDialog.Widget(
elmts,
column.cellIndex,
o.rowIndices,
o.values,
null
);
previewWidget._prepareUpdate = function(params) {
params.repeat = elmts.repeatCheckbox[0].checked;
params.repeatCount = elmts.repeatCountInput[0].value;
};
var doTextTransformPrompt = function() {
var frame = $(
DOM.loadHTML("core", "scripts/views/data-table/text-transform-dialog.html")
.replace("$EXPRESSION_PREVIEW_WIDGET$", ExpressionPreviewDialog.generateWidgetHtml()));
elmts.repeatCheckbox.click(function() {
previewWidget.update();
});
};
var elmts = DOM.bind(frame);
elmts.dialogHeader.text("Custom text transform on column " + column.name);
var doFillDown = function() {
Refine.postCoreProcess(
"fill-down",
{
columnName: column.name
},
null,
{ modelsChanged: true }
);
};
var level = DialogSystem.showDialog(frame);
var dismiss = function() { DialogSystem.dismissUntil(level - 1); };
var doBlankDown = function() {
Refine.postCoreProcess(
"blank-down",
{
columnName: column.name
},
null,
{ modelsChanged: true }
);
};
elmts.cancelButton.click(dismiss);
elmts.okButton.click(function() {
doTextTransform(
previewWidget.getExpression(true),
$('input[name="text-transform-dialog-onerror-choice"]:checked')[0].value,
elmts.repeatCheckbox[0].checked,
elmts.repeatCountInput[0].value
);
dismiss();
});
var o = DataTableView.sampleVisibleRows(column);
var previewWidget = new ExpressionPreviewDialog.Widget(
elmts,
column.cellIndex,
o.rowIndices,
o.values,
null
);
previewWidget._prepareUpdate = function(params) {
params.repeat = elmts.repeatCheckbox[0].checked;
params.repeatCount = elmts.repeatCountInput[0].value;
};
elmts.repeatCheckbox.click(function() {
previewWidget.update();
});
};
var doFillDown = function() {
Refine.postCoreProcess(
"fill-down",
{
columnName: column.name
},
null,
{ modelsChanged: true }
);
};
var doBlankDown = function() {
Refine.postCoreProcess(
"blank-down",
{
columnName: column.name
},
null,
{ modelsChanged: true }
);
};
var doJoinMultiValueCells = function() {
var separator = window.prompt("Enter separator to use between values", ", ");
if (separator !== null) {
Refine.postCoreProcess(
"join-multi-value-cells",
{
columnName: column.name,
keyColumnName: theProject.columnModel.keyColumnName,
separator: separator
},
null,
{ rowsChanged: true }
);
}
};
var doSplitMultiValueCells = function() {
var separator = window.prompt("What separator currently separates the values?", ",");
if (separator !== null) {
Refine.postCoreProcess(
"split-multi-value-cells",
{
columnName: column.name,
keyColumnName: theProject.columnModel.keyColumnName,
separator: separator,
mode: "plain"
},
null,
{ rowsChanged: true }
);
}
};
MenuSystem.appendTo(menu, [ "core/edit-cells" ], [
var doJoinMultiValueCells = function() {
var separator = window.prompt("Enter separator to use between values", ", ");
if (separator !== null) {
Refine.postCoreProcess(
"join-multi-value-cells",
{
id: "core/text-transform",
label: "Transform...",
click: function() { doTextTransformPrompt(); }
columnName: column.name,
keyColumnName: theProject.columnModel.keyColumnName,
separator: separator
},
null,
{ rowsChanged: true }
);
}
};
var doSplitMultiValueCells = function() {
var separator = window.prompt("What separator currently separates the values?", ",");
if (separator !== null) {
Refine.postCoreProcess(
"split-multi-value-cells",
{
columnName: column.name,
keyColumnName: theProject.columnModel.keyColumnName,
separator: separator,
mode: "plain"
},
null,
{ rowsChanged: true }
);
}
};
MenuSystem.appendTo(menu, [ "core/edit-cells" ], [
{
id: "core/text-transform",
label: "Transform...",
click: function() { doTextTransformPrompt(); }
},
{
id: "core/common-transforms",
label: "Common transforms",
submenu: [
{
id: "core/trim-whitespace",
label: "Trim leading and trailing whitespace",
click: function() { doTextTransform("value.trim()", "store-blank", false, ""); }
},
{
id: "core/common-transforms",
label: "Common transforms",
submenu: [
{
id: "core/trim-whitespace",
label: "Trim leading and trailing whitespace",
click: function() { doTextTransform("value.trim()", "store-blank", false, ""); }
},
{
id: "core/collapse-whitespace",
label: "Collapse consecutive whitespace",
click: function() { doTextTransform("value.replace(/\\s+/,' ')", "store-blank", false, ""); }
},
{},
{
id: "core/unescape-html-entities",
label: "Unescape HTML entities",
click: function() { doTextTransform("value.unescape('html')", "store-blank", true, 10); }
},
{},
{
id: "core/to-titlecase",
label: "To titlecase",
click: function() { doTextTransform("value.toTitlecase()", "store-blank", false, ""); }
},
{
id: "core/to-uppercase",
label: "To uppercase",
click: function() { doTextTransform("value.toUppercase()", "store-blank", false, ""); }
},
{
id: "core/to-lowercase",
label: "To lowercase",
click: function() { doTextTransform("value.toLowercase()", "store-blank", false, ""); }
},
{},
{
id: "core/to-number",
label: "To number",
click: function() { doTextTransform("value.toNumber()", "store-blank", false, ""); }
},
{
id: "core/to-date",
label: "To date",
click: function() { doTextTransform("value.toDate()", "store-blank", false, ""); }
},
{
id: "core/to-text",
label: "To text",
click: function() { doTextTransform("value.toString()", "store-blank", false, ""); }
},
{},
{
id: "core/to-blank",
label: "Blank out cells",
click: function() { doTextTransform("null", "store-blank", false, ""); }
}
]
id: "core/collapse-whitespace",
label: "Collapse consecutive whitespace",
click: function() { doTextTransform("value.replace(/\\s+/,' ')", "store-blank", false, ""); }
},
{},
{
id: "core/fill-down",
label: "Fill down",
click: doFillDown
},
{
id: "core/blank-down",
label: "Blank down",
click: doBlankDown
id: "core/unescape-html-entities",
label: "Unescape HTML entities",
click: function() { doTextTransform("value.unescape('html')", "store-blank", true, 10); }
},
{},
{
id: "core/split-multi-valued-cells",
label: "Split multi-valued cells...",
click: doSplitMultiValueCells
id: "core/to-titlecase",
label: "To titlecase",
click: function() { doTextTransform("value.toTitlecase()", "store-blank", false, ""); }
},
{
id: "core/join-multi-valued-cells",
label: "Join multi-valued cells...",
click: doJoinMultiValueCells
id: "core/to-uppercase",
label: "To uppercase",
click: function() { doTextTransform("value.toUppercase()", "store-blank", false, ""); }
},
{
id: "core/to-lowercase",
label: "To lowercase",
click: function() { doTextTransform("value.toLowercase()", "store-blank", false, ""); }
},
{},
{
id: "core/cluster",
label: "Cluster and edit...",
click: function() { new ClusteringDialog(column.name, "value"); }
}
]);
var doTransposeColumnsIntoRows = function() {
var dialog = $(DOM.loadHTML("core", "scripts/views/data-table/transpose-columns-into-rows.html"));
var elmts = DOM.bind(dialog);
elmts.dialogHeader.text('Transpose Cells Across Columns into Rows');
var level = DialogSystem.showDialog(dialog);
var dismiss = function() {
DialogSystem.dismissUntil(level - 1);
};
var columns = theProject.columnModel.columns;
elmts.cancelButton.click(function() { dismiss(); });
elmts.okButton.click(function() {
var config = {
startColumnName: elmts.fromColumnSelect[0].value,
columnCount: elmts.toColumnSelect[0].value,
combinedColumnName: $.trim(elmts.combinedColumnNameInput[0].value),
prependColumnName: elmts.prependColumnNameCheckbox[0].checked,
separator: elmts.separatorInput[0].value,
ignoreBlankCells: elmts.ignoreBlankCellsCheckbox[0].checked
};
Refine.postCoreProcess(
"transpose-columns-into-rows",
config,
null,
{ modelsChanged: true }
);
dismiss();
});
for (var i = 0; i < columns.length; i++) {
var column2 = columns[i];
var option = $('<option>').attr("value", column2.name).text(column2.name).appendTo(elmts.fromColumnSelect);
if (column2.name == column.name) {
option.attr("selected", "true");
}
}
var populateToColumn = function() {
elmts.toColumnSelect.empty();
var toColumnName = elmts.fromColumnSelect[0].value;
var j = 0;
for (; j < columns.length; j++) {
var column2 = columns[j];
if (column2.name == toColumnName) {
break;
}
}
for (var k = j + 1; k < columns.length; k++) {
var column2 = columns[k];
var option = $('<option>').attr("value", k - j + 1).text(column2.name).appendTo(elmts.toColumnSelect);
if (k == columns.length - 1) {
option.attr("selected", "true");
}
}
};
populateToColumn();
elmts.fromColumnSelect.bind("change", populateToColumn);
};
var doTransposeRowsIntoColumns = function() {
var rowCount = window.prompt("How many rows to transpose?", "2");
if (rowCount != null) {
try {
rowCount = parseInt(rowCount);
} catch (e) {
// ignore
}
if (isNaN(rowCount) || rowCount < 2) {
alert("Expected an integer at least 2.");
} else {
var config = {
columnName: column.name,
rowCount: rowCount
};
Refine.postCoreProcess(
"transpose-rows-into-columns",
config,
null,
{ modelsChanged: true }
);
}
}
};
MenuSystem.appendTo(menu, [ "core/transpose" ], [
{
id: "core/transpose-columns-into-rows",
label: "Cells across columns into rows...",
click: doTransposeColumnsIntoRows
id: "core/to-number",
label: "To number",
click: function() { doTextTransform("value.toNumber()", "store-blank", false, ""); }
},
{
id: "core/transpose-rows-into-columns",
label: "Cells in rows into columns...",
click: doTransposeRowsIntoColumns
id: "core/to-date",
label: "To date",
click: function() { doTextTransform("value.toDate()", "store-blank", false, ""); }
},
{
id: "core/to-text",
label: "To text",
click: function() { doTextTransform("value.toString()", "store-blank", false, ""); }
},
{},
{
id: "core/to-blank",
label: "Blank out cells",
click: function() { doTextTransform("null", "store-blank", false, ""); }
}
]);
]
},
{},
{
id: "core/fill-down",
label: "Fill down",
click: doFillDown
},
{
id: "core/blank-down",
label: "Blank down",
click: doBlankDown
},
{},
{
id: "core/split-multi-valued-cells",
label: "Split multi-valued cells...",
click: doSplitMultiValueCells
},
{
id: "core/join-multi-valued-cells",
label: "Join multi-valued cells...",
click: doJoinMultiValueCells
},
{},
{
id: "core/cluster",
label: "Cluster and edit...",
click: function() { new ClusteringDialog(column.name, "value"); }
}
]);
var doTransposeColumnsIntoRows = function() {
var dialog = $(DOM.loadHTML("core", "scripts/views/data-table/transpose-columns-into-rows.html"));
var elmts = DOM.bind(dialog);
elmts.dialogHeader.text('Transpose Cells Across Columns into Rows');
var level = DialogSystem.showDialog(dialog);
var dismiss = function() {
DialogSystem.dismissUntil(level - 1);
};
var columns = theProject.columnModel.columns;
elmts.cancelButton.click(function() { dismiss(); });
elmts.okButton.click(function() {
var config = {
startColumnName: elmts.fromColumnSelect[0].value,
columnCount: elmts.toColumnSelect[0].value,
combinedColumnName: $.trim(elmts.combinedColumnNameInput[0].value),
prependColumnName: elmts.prependColumnNameCheckbox[0].checked,
separator: elmts.separatorInput[0].value,
ignoreBlankCells: elmts.ignoreBlankCellsCheckbox[0].checked
};
Refine.postCoreProcess(
"transpose-columns-into-rows",
config,
null,
{ modelsChanged: true }
);
dismiss();
});
for (var i = 0; i < columns.length; i++) {
var column2 = columns[i];
var option = $('<option>').attr("value", column2.name).text(column2.name).appendTo(elmts.fromColumnSelect);
if (column2.name == column.name) {
option.attr("selected", "true");
}
}
var populateToColumn = function() {
elmts.toColumnSelect.empty();
var toColumnName = elmts.fromColumnSelect[0].value;
var j = 0;
for (; j < columns.length; j++) {
var column2 = columns[j];
if (column2.name == toColumnName) {
break;
}
}
for (var k = j + 1; k < columns.length; k++) {
var column2 = columns[k];
var option = $('<option>').attr("value", k - j + 1).text(column2.name).appendTo(elmts.toColumnSelect);
if (k == columns.length - 1) {
option.attr("selected", "true");
}
}
};
populateToColumn();
elmts.fromColumnSelect.bind("change", populateToColumn);
};
var doTransposeRowsIntoColumns = function() {
var rowCount = window.prompt("How many rows to transpose?", "2");
if (rowCount != null) {
try {
rowCount = parseInt(rowCount);
} catch (e) {
// ignore
}
if (isNaN(rowCount) || rowCount < 2) {
alert("Expected an integer at least 2.");
} else {
var config = {
columnName: column.name,
rowCount: rowCount
};
Refine.postCoreProcess(
"transpose-rows-into-columns",
config,
null,
{ modelsChanged: true }
);
}
}
};
MenuSystem.appendTo(menu, [ "core/transpose" ], [
{
id: "core/transpose-columns-into-rows",
label: "Cells across columns into rows...",
click: doTransposeColumnsIntoRows
},
{
id: "core/transpose-rows-into-columns",
label: "Cells in rows into columns...",
click: doTransposeRowsIntoColumns
}
]
);
});

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,260 +29,261 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
DataTableColumnHeaderUI.extendMenu(function(column, columnHeaderUI, menu) {
var columnIndex = Refine.columnNameToColumnIndex(column.name);
var doAddColumn = function() {
var frame = $(
DOM.loadHTML("core", "scripts/views/data-table/add-column-dialog.html")
.replace("$EXPRESSION_PREVIEW_WIDGET$", ExpressionPreviewDialog.generateWidgetHtml()));
var columnIndex = Refine.columnNameToColumnIndex(column.name);
var doAddColumn = function() {
var frame = $(
DOM.loadHTML("core", "scripts/views/data-table/add-column-dialog.html")
.replace("$EXPRESSION_PREVIEW_WIDGET$", ExpressionPreviewDialog.generateWidgetHtml()));
var elmts = DOM.bind(frame);
elmts.dialogHeader.text("Add column based on column " + column.name);
var elmts = DOM.bind(frame);
elmts.dialogHeader.text("Add column based on column " + column.name);
var level = DialogSystem.showDialog(frame);
var dismiss = function() { DialogSystem.dismissUntil(level - 1); };
var level = DialogSystem.showDialog(frame);
var dismiss = function() { DialogSystem.dismissUntil(level - 1); };
elmts.cancelButton.click(dismiss);
elmts.okButton.click(function() {
var columnName = $.trim(elmts.columnNameInput[0].value);
if (!columnName.length) {
alert("You must enter a column name.");
return;
}
elmts.cancelButton.click(dismiss);
elmts.okButton.click(function() {
var columnName = $.trim(elmts.columnNameInput[0].value);
if (!columnName.length) {
alert("You must enter a column name.");
return;
}
Refine.postCoreProcess(
"add-column",
{
baseColumnName: column.name,
expression: previewWidget.getExpression(true),
newColumnName: columnName,
columnInsertIndex: columnIndex + 1,
onError: $('input[name="create-column-dialog-onerror-choice"]:checked')[0].value
},
null,
{ modelsChanged: true }
);
dismiss();
});
Refine.postCoreProcess(
"add-column",
{
baseColumnName: column.name,
expression: previewWidget.getExpression(true),
newColumnName: columnName,
columnInsertIndex: columnIndex + 1,
onError: $('input[name="create-column-dialog-onerror-choice"]:checked')[0].value
},
null,
{ modelsChanged: true }
);
dismiss();
});
var o = DataTableView.sampleVisibleRows(column);
var previewWidget = new ExpressionPreviewDialog.Widget(
elmts,
column.cellIndex,
o.rowIndices,
o.values,
null
);
};
var o = DataTableView.sampleVisibleRows(column);
var previewWidget = new ExpressionPreviewDialog.Widget(
elmts,
column.cellIndex,
o.rowIndices,
o.values,
null
);
};
var doAddColumnByFetchingURLs = function() {
var frame = $(
DOM.loadHTML("core", "scripts/views/data-table/add-column-by-fetching-urls-dialog.html")
.replace("$EXPRESSION_PREVIEW_WIDGET$", ExpressionPreviewDialog.generateWidgetHtml()));
var doAddColumnByFetchingURLs = function() {
var frame = $(
DOM.loadHTML("core", "scripts/views/data-table/add-column-by-fetching-urls-dialog.html")
.replace("$EXPRESSION_PREVIEW_WIDGET$", ExpressionPreviewDialog.generateWidgetHtml()));
var elmts = DOM.bind(frame);
elmts.dialogHeader.text("Add column by fetching URLs based on column " + column.name);
var elmts = DOM.bind(frame);
elmts.dialogHeader.text("Add column by fetching URLs based on column " + column.name);
var level = DialogSystem.showDialog(frame);
var dismiss = function() { DialogSystem.dismissUntil(level - 1); };
var level = DialogSystem.showDialog(frame);
var dismiss = function() { DialogSystem.dismissUntil(level - 1); };
elmts.cancelButton.click(dismiss);
elmts.okButton.click(function() {
var columnName = $.trim(elmts.columnNameInput[0].value);
if (!columnName.length) {
alert("You must enter a column name.");
return;
}
elmts.cancelButton.click(dismiss);
elmts.okButton.click(function() {
var columnName = $.trim(elmts.columnNameInput[0].value);
if (!columnName.length) {
alert("You must enter a column name.");
return;
}
Refine.postCoreProcess(
"add-column-by-fetching-urls",
{
baseColumnName: column.name,
urlExpression: previewWidget.getExpression(true),
newColumnName: columnName,
columnInsertIndex: columnIndex + 1,
delay: elmts.throttleDelayInput[0].value,
onError: $('input[name="dialog-onerror-choice"]:checked')[0].value
},
null,
{ modelsChanged: true }
);
dismiss();
});
Refine.postCoreProcess(
"add-column-by-fetching-urls",
{
baseColumnName: column.name,
urlExpression: previewWidget.getExpression(true),
newColumnName: columnName,
columnInsertIndex: columnIndex + 1,
delay: elmts.throttleDelayInput[0].value,
onError: $('input[name="dialog-onerror-choice"]:checked')[0].value
},
null,
{ modelsChanged: true }
);
dismiss();
});
var o = DataTableView.sampleVisibleRows(column);
var previewWidget = new ExpressionPreviewDialog.Widget(
elmts,
column.cellIndex,
o.rowIndices,
o.values,
null
);
};
var doRemoveColumn = function() {
Refine.postCoreProcess(
"remove-column",
{
columnName: column.name
},
null,
{ modelsChanged: true }
);
};
var o = DataTableView.sampleVisibleRows(column);
var previewWidget = new ExpressionPreviewDialog.Widget(
elmts,
column.cellIndex,
o.rowIndices,
o.values,
null
);
};
var doRenameColumn = function() {
var newColumnName = window.prompt("Enter new column name", column.name);
if (newColumnName !== null) {
Refine.postCoreProcess(
"rename-column",
{
oldColumnName: column.name,
newColumnName: newColumnName
},
null,
{ modelsChanged: true }
);
var doRemoveColumn = function() {
Refine.postCoreProcess(
"remove-column",
{
columnName: column.name
},
null,
{ modelsChanged: true }
);
};
var doRenameColumn = function() {
var newColumnName = window.prompt("Enter new column name", column.name);
if (newColumnName !== null) {
Refine.postCoreProcess(
"rename-column",
{
oldColumnName: column.name,
newColumnName: newColumnName
},
null,
{ modelsChanged: true }
);
}
};
var doMoveColumnTo = function(index) {
Refine.postCoreProcess(
"move-column",
{
columnName: column.name,
index: index
},
null,
{ modelsChanged: true }
);
};
var doMoveColumnBy = function(change) {
Refine.postCoreProcess(
"move-column",
{
columnName: column.name,
index: Refine.columnNameToColumnIndex(column.name) + change
},
null,
{ modelsChanged: true }
);
};
var doSplitColumn = function() {
var frame = $(DOM.loadHTML("core", "scripts/views/data-table/split-column-dialog.html"));
var elmts = DOM.bind(frame);
elmts.dialogHeader.text("Split column " + column.name + " into several columns");
var level = DialogSystem.showDialog(frame);
var dismiss = function() { DialogSystem.dismissUntil(level - 1); };
elmts.cancelButton.click(dismiss);
elmts.okButton.click(function() {
var mode = $("input[name='split-by-mode']:checked")[0].value;
var config = {
columnName: column.name,
mode: mode,
guessCellType: elmts.guessCellTypeInput[0].checked,
removeOriginalColumn: elmts.removeColumnInput[0].checked
};
if (mode == "separator") {
config.separator = elmts.separatorInput[0].value;
if (!(config.separator)) {
alert("Please specify a separator.");
return;
}
};
var doMoveColumnTo = function(index) {
Refine.postCoreProcess(
"move-column",
{
columnName: column.name,
index: index
},
null,
{ modelsChanged: true }
);
};
config.regex = elmts.regexInput[0].checked;
var doMoveColumnBy = function(change) {
Refine.postCoreProcess(
"move-column",
{
columnName: column.name,
index: Refine.columnNameToColumnIndex(column.name) + change
},
null,
{ modelsChanged: true }
);
};
var doSplitColumn = function() {
var frame = $(DOM.loadHTML("core", "scripts/views/data-table/split-column-dialog.html"));
var elmts = DOM.bind(frame);
elmts.dialogHeader.text("Split column " + column.name + " into several columns");
var level = DialogSystem.showDialog(frame);
var dismiss = function() { DialogSystem.dismissUntil(level - 1); };
elmts.cancelButton.click(dismiss);
elmts.okButton.click(function() {
var mode = $("input[name='split-by-mode']:checked")[0].value;
var config = {
columnName: column.name,
mode: mode,
guessCellType: elmts.guessCellTypeInput[0].checked,
removeOriginalColumn: elmts.removeColumnInput[0].checked
};
if (mode == "separator") {
config.separator = elmts.separatorInput[0].value;
if (!(config.separator)) {
alert("Please specify a separator.");
return;
}
config.regex = elmts.regexInput[0].checked;
var s = elmts.maxColumnsInput[0].value;
if (s) {
var n = parseInt(s,10);
if (!isNaN(n)) {
config.maxColumns = n;
}
}
} else {
var s = "[" + elmts.lengthsTextarea[0].value + "]";
try {
var a = JSON.parse(s);
} catch (e) {
alert("The given field lengths are not properly formatted.");
return;
}
var lengths = [];
$.each(a, function(i,n) { if (typeof n == "number") lengths.push(n); });
if (lengths.length === 0) {
alert("No field length is specified.");
return;
}
config.fieldLengths = JSON.stringify(lengths);
}
Refine.postCoreProcess(
"split-column",
config,
null,
{ modelsChanged: true }
);
dismiss();
});
};
MenuSystem.appendTo(menu, [ "core/edit-column" ], [
{
id: "core/split-column",
label: "Split into several columns...",
click: doSplitColumn
},
{},
{
id: "core/add-column",
label: "Add column based on this column...",
click: doAddColumn
},
{
id: "core/add-column-by-fetching-urls",
label: "Add column by fetching URLs...",
click: doAddColumnByFetchingURLs
},
{},
{
id: "core/rename-column",
label: "Rename this column",
click: doRenameColumn
},
{
id: "core/remove-column",
label: "Remove this column",
click: doRemoveColumn
},
{},
{
id: "core/move-column-to-beginning",
label: "Move column to beginning",
click: function() { doMoveColumnTo(0); }
},
{
id: "core/move-column-to-end",
label: "Move column to end",
click: function() { doMoveColumnTo(theProject.columnModel.columns.length - 1); }
},
{
id: "core/move-column-to-left",
label: "Move column left",
click: function() { doMoveColumnBy(-1); }
},
{
id: "core/move-column-to-right",
label: "Move column right",
click: function() { doMoveColumnBy(1); }
var s = elmts.maxColumnsInput[0].value;
if (s) {
var n = parseInt(s,10);
if (!isNaN(n)) {
config.maxColumns = n;
}
}
]);
} else {
var s = "[" + elmts.lengthsTextarea[0].value + "]";
try {
var a = JSON.parse(s);
} catch (e) {
alert("The given field lengths are not properly formatted.");
return;
}
var lengths = [];
$.each(a, function(i,n) { if (typeof n == "number") lengths.push(n); });
if (lengths.length === 0) {
alert("No field length is specified.");
return;
}
config.fieldLengths = JSON.stringify(lengths);
}
Refine.postCoreProcess(
"split-column",
config,
null,
{ modelsChanged: true }
);
dismiss();
});
};
MenuSystem.appendTo(menu, [ "core/edit-column" ], [
{
id: "core/split-column",
label: "Split into several columns...",
click: doSplitColumn
},
{},
{
id: "core/add-column",
label: "Add column based on this column...",
click: doAddColumn
},
{
id: "core/add-column-by-fetching-urls",
label: "Add column by fetching URLs...",
click: doAddColumnByFetchingURLs
},
{},
{
id: "core/rename-column",
label: "Rename this column",
click: doRenameColumn
},
{
id: "core/remove-column",
label: "Remove this column",
click: doRemoveColumn
},
{},
{
id: "core/move-column-to-beginning",
label: "Move column to beginning",
click: function() { doMoveColumnTo(0); }
},
{
id: "core/move-column-to-end",
label: "Move column to end",
click: function() { doMoveColumnTo(theProject.columnModel.columns.length - 1); }
},
{
id: "core/move-column-to-left",
label: "Move column left",
click: function() { doMoveColumnBy(-1); }
},
{
id: "core/move-column-to-right",
label: "Move column right",
click: function() { doMoveColumnBy(1); }
}
]
);
});

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,254 +29,254 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
DataTableColumnHeaderUI.extendMenu(function(column, columnHeaderUI, menu) {
var doFilterByExpressionPrompt = function(expression, type) {
DataTableView.promptExpressionOnVisibleRows(
column,
(type == "list" ? "Custom Facet on column " : "Custom Numeric Facet on column") + column.name,
expression,
function(expression) {
var config = {
"name" : column.name,
"columnName" : column.name,
"expression" : expression
};
if (type == "range") {
config.mode = "range";
}
var doFilterByExpressionPrompt = function(expression, type) {
DataTableView.promptExpressionOnVisibleRows(
column,
(type == "list" ? "Custom Facet on column " : "Custom Numeric Facet on column") + column.name,
expression,
function(expression) {
var config = {
"name" : column.name,
"columnName" : column.name,
"expression" : expression
};
if (type == "range") {
config.mode = "range";
}
ui.browsingEngine.addFacet(type, config);
ui.browsingEngine.addFacet(type, config);
}
);
};
MenuSystem.appendTo(menu, [ "core/facet" ], [
{
id: "core/text-facet",
label: "Text facet",
click: function() {
ui.browsingEngine.addFacet(
"list",
{
"name": column.name,
"columnName": column.name,
"expression": "value"
}
);
};
MenuSystem.appendTo(menu, [ "core/facet" ], [
{
id: "core/text-facet",
label: "Text facet",
click: function() {
ui.browsingEngine.addFacet(
"list",
{
"name": column.name,
"columnName": column.name,
"expression": "value"
}
);
}
},
{
id: "core/numeric-facet",
label: "Numeric facet",
click: function() {
ui.browsingEngine.addFacet(
"range",
{
"name": column.name,
"columnName": column.name,
"expression": "value",
"mode": "range"
}
},
{
id: "core/numeric-facet",
label: "Numeric facet",
click: function() {
ui.browsingEngine.addFacet(
"range",
{
"name": column.name,
"columnName": column.name,
"expression": "value",
"mode": "range"
}
);
);
}
},
{
id: "core/time-facet",
label: "Timeline facet",
click: function() {
ui.browsingEngine.addFacet(
"timerange",
{
"name": column.name,
"columnName": column.name,
"expression": "value",
"mode": "range"
}
},
);
}
},
{
id: "core/scatterplot-facet",
label: "Scatterplot facet",
click: function() {
new ScatterplotDialog(column.name);
}
},
{},
{
id: "core/custom-text-facet",
label: "Custom text facet...",
click: function() {
doFilterByExpressionPrompt(null, "list");
}
},
{
id: "core/custom-numeric-facet",
label: "Custom numeric facet...",
click: function() {
doFilterByExpressionPrompt(null, "range");
}
},
{
id: "core/customized-facets",
label: "Customized facets",
submenu: [
{
id: "core/time-facet",
label: "Timeline facet",
click: function() {
ui.browsingEngine.addFacet(
"timerange",
{
"name": column.name,
"columnName": column.name,
"expression": "value",
"mode": "range"
}
);
}
},
{
id: "core/scatterplot-facet",
label: "Scatterplot facet",
click: function() {
new ScatterplotDialog(column.name);
}
id: "core/word-facet",
label: "Word facet",
click: function() {
ui.browsingEngine.addFacet(
"list",
{
"name": column.name,
"columnName": column.name,
"expression": "value.split(' ')"
}
);
}
},
{},
{
id: "core/custom-text-facet",
label: "Custom text facet...",
click: function() {
doFilterByExpressionPrompt(null, "list");
}
},
{
id: "core/custom-numeric-facet",
label: "Custom numeric facet...",
click: function() {
doFilterByExpressionPrompt(null, "range");
}
},
{
id: "core/customized-facets",
label: "Customized facets",
submenu: [
id: "core/duplicates-facet",
label: "Duplicates facet",
click: function() {
ui.browsingEngine.addFacet(
"list",
{
id: "core/word-facet",
label: "Word facet",
click: function() {
ui.browsingEngine.addFacet(
"list",
{
"name": column.name,
"columnName": column.name,
"expression": "value.split(' ')"
}
);
}
},
{},
{
id: "core/duplicates-facet",
label: "Duplicates facet",
click: function() {
ui.browsingEngine.addFacet(
"list",
{
"name": column.name,
"columnName": column.name,
"expression": "facetCount(value, 'value', '" +
column.name + "') > 1"
}
);
}
},
{},
{
id: "core/numeric-log-facet",
label: "Numeric log facet",
click: function() {
ui.browsingEngine.addFacet(
"range",
{
"name": column.name,
"columnName": column.name,
"expression": "value.log()",
"mode": "range"
}
);
}
},
{
id: "core/bounded-numeric-log-facet",
label: "1-bounded numeric log facet",
click: function() {
ui.browsingEngine.addFacet(
"range",
{
"name": column.name,
"columnName": column.name,
"expression": "log(max(1, value))",
"mode": "range"
}
);
}
},
{},
{
id: "core/text-length-facet",
label: "Text length facet",
click: function() {
ui.browsingEngine.addFacet(
"range",
{
"name": column.name,
"columnName": column.name,
"expression": "value.length()",
"mode": "range"
}
);
}
},
{
id: "core/log-text-length-facet",
label: "Log of text length facet",
click: function() {
ui.browsingEngine.addFacet(
"range",
{
"name": column.name,
"columnName": column.name,
"expression": "value.length().log()",
"mode": "range"
}
);
}
},
{
id: "core/unicode-charcode-facet",
label: "Unicode char-code facet",
click: function() {
ui.browsingEngine.addFacet(
"range",
{
"name": column.name,
"columnName": column.name,
"expression": "value.unicode()",
"mode": "range"
}
);
}
},
{},
{
id: "core/error-facet",
label: "Facet by error",
click: function() {
ui.browsingEngine.addFacet(
"list",
{
"name": column.name,
"columnName": column.name,
"expression": "isError(value)"
}
);
}
},
{
id: "core/blank-facet",
label: "Facet by blank",
click: function() {
ui.browsingEngine.addFacet(
"list",
{
"name": column.name,
"columnName": column.name,
"expression": "isBlank(value)"
}
);
}
"name": column.name,
"columnName": column.name,
"expression": "facetCount(value, 'value', '" +
column.name + "') > 1"
}
]
}
]);
MenuSystem.insertAfter(menu, [ "core/facet" ], [
);
}
},
{},
{
label: "Text filter",
click: function() {
ui.browsingEngine.addFacet(
"text",
{
"name" : column.name,
"columnName" : column.name,
"mode" : "text",
"caseSensitive" : false
}
);
}
id: "core/numeric-log-facet",
label: "Numeric log facet",
click: function() {
ui.browsingEngine.addFacet(
"range",
{
"name": column.name,
"columnName": column.name,
"expression": "value.log()",
"mode": "range"
}
);
}
},
{
id: "core/bounded-numeric-log-facet",
label: "1-bounded numeric log facet",
click: function() {
ui.browsingEngine.addFacet(
"range",
{
"name": column.name,
"columnName": column.name,
"expression": "log(max(1, value))",
"mode": "range"
}
);
}
},
{},
{
id: "core/text-length-facet",
label: "Text length facet",
click: function() {
ui.browsingEngine.addFacet(
"range",
{
"name": column.name,
"columnName": column.name,
"expression": "value.length()",
"mode": "range"
}
);
}
},
{
id: "core/log-text-length-facet",
label: "Log of text length facet",
click: function() {
ui.browsingEngine.addFacet(
"range",
{
"name": column.name,
"columnName": column.name,
"expression": "value.length().log()",
"mode": "range"
}
);
}
},
{
id: "core/unicode-charcode-facet",
label: "Unicode char-code facet",
click: function() {
ui.browsingEngine.addFacet(
"range",
{
"name": column.name,
"columnName": column.name,
"expression": "value.unicode()",
"mode": "range"
}
);
}
},
{},
{
id: "core/error-facet",
label: "Facet by error",
click: function() {
ui.browsingEngine.addFacet(
"list",
{
"name": column.name,
"columnName": column.name,
"expression": "isError(value)"
}
);
}
},
{
id: "core/blank-facet",
label: "Facet by blank",
click: function() {
ui.browsingEngine.addFacet(
"list",
{
"name": column.name,
"columnName": column.name,
"expression": "isBlank(value)"
}
);
}
}
]);
]
}
]);
MenuSystem.insertAfter(menu, [ "core/facet" ], [
{
label: "Text filter",
click: function() {
ui.browsingEngine.addFacet(
"text",
{
"name" : column.name,
"columnName" : column.name,
"mode" : "text",
"caseSensitive" : false
}
);
}
}
]);
});

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,389 +29,389 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
DataTableColumnHeaderUI.extendMenu(function(column, columnHeaderUI, menu) {
var doReconcile = function() {
new ReconDialog(column);
};
var doReconcile = function() {
new ReconDialog(column);
};
var doReconDiscardJudgments = function() {
Refine.postCoreProcess(
"recon-discard-judgments",
{ columnName: column.name, clearData: false },
var doReconDiscardJudgments = function() {
Refine.postCoreProcess(
"recon-discard-judgments",
{ columnName: column.name, clearData: false },
null,
{ cellsChanged: true, columnStatsChanged: true }
);
};
var doClearReconData = function() {
Refine.postCoreProcess(
"recon-discard-judgments",
{ columnName: column.name, clearData: true },
null,
{ cellsChanged: true, columnStatsChanged: true }
);
}
var doReconMatchBestCandidates = function() {
Refine.postCoreProcess(
"recon-match-best-candidates",
{ columnName: column.name },
null,
{ cellsChanged: true, columnStatsChanged: true }
);
};
var doReconMarkNewTopics = function(shareNewTopics) {
Refine.postCoreProcess(
"recon-mark-new-topics",
{ columnName: column.name, shareNewTopics: shareNewTopics },
null,
{ cellsChanged: true, columnStatsChanged: true }
);
};
var doSearchToMatch = function() {
var frame = DialogSystem.createDialog();
frame.width("400px");
var header = $('<div></div>').addClass("dialog-header").text("Search for Match").appendTo(frame);
var body = $('<div></div>').addClass("dialog-body").appendTo(frame);
var footer = $('<div></div>').addClass("dialog-footer").appendTo(frame);
$('<p></p>').text("Search Freebase for a topic to match all filtered cells:").appendTo(body);
var input = $('<input />').appendTo($('<p></p>').appendTo(body));
input.suggest({}).bind("fb-select", function(e, data) {
var query = {
"id" : data.id,
"type" : []
};
var baseUrl = "http://api.freebase.com/api/service/mqlread";
var url = baseUrl + "?" + $.param({ query: JSON.stringify({ query: query }) }) + "&callback=?";
$.getJSON(
url,
null,
function(o) {
var types = "result" in o ? o.result.type : [];
Refine.postCoreProcess(
"recon-match-specific-topic-to-cells",
{
columnName: column.name,
topicID: data.id,
topicGUID: data.guid,
topicName: data.name,
types: types.join(",")
},
null,
{ cellsChanged: true, columnStatsChanged: true }
);
};
var doClearReconData = function() {
Refine.postCoreProcess(
"recon-discard-judgments",
{ columnName: column.name, clearData: true },
null,
{ cellsChanged: true, columnStatsChanged: true }
);
);
DialogSystem.dismissUntil(level - 1);
}
);
});
$('<button class="button"></button>').text("Cancel").click(function() {
DialogSystem.dismissUntil(level - 1);
}).appendTo(footer);
var level = DialogSystem.showDialog(frame);
input.focus().data("suggest").textchange();
};
var doCopyAcrossColumns = function() {
var frame = $(DOM.loadHTML("core", "scripts/views/data-table/copy-recon-across-columns-dialog.html"));
var elmts = DOM.bind(frame);
elmts.dialogHeader.text("Copy recon judgments from column " + column.name);
var columns = theProject.columnModel.columns;
for (var i = 0; i < columns.length; i++) {
var column2 = columns[i];
if (column !== column2) {
$('<option>').attr("value", column2.name).text(column2.name).appendTo(elmts.toColumnSelect);
}
}
var doReconMatchBestCandidates = function() {
var level = DialogSystem.showDialog(frame);
var dismiss = function() { DialogSystem.dismissUntil(level - 1); };
elmts.cancelButton.click(dismiss);
elmts.okButton.click(function() {
var config = {
fromColumnName: column.name,
toColumnName: [],
judgment: [],
applyToJudgedCells: elmts.applyToJudgedCellsCheckbox[0].checked
};
if (elmts.newCheckbox[0].checked) {
config.judgment.push("new");
}
if (elmts.matchCheckbox[0].checked) {
config.judgment.push("matched");
}
elmts.toColumnSelect.find("option").each(function() {
if (this.selected) {
config.toColumnName.push(this.value);
}
});
if (config.toColumnName.length == 0) {
alert("Please select some other column to copy to.");
} else if (config.judgment.length == 0) {
alert("Please select at least one kind of judgment to copy.");
} else {
Refine.postCoreProcess(
"recon-match-best-candidates",
{ columnName: column.name },
null,
{ cellsChanged: true, columnStatsChanged: true }
"recon-copy-across-columns",
null,
config,
{ rowsChanged: true }
);
};
dismiss();
}
});
};
var doReconMarkNewTopics = function(shareNewTopics) {
Refine.postCoreProcess(
"recon-mark-new-topics",
{ columnName: column.name, shareNewTopics: shareNewTopics },
null,
{ cellsChanged: true, columnStatsChanged: true }
);
};
var doSearchToMatch = function() {
var frame = DialogSystem.createDialog();
frame.width("400px");
var header = $('<div></div>').addClass("dialog-header").text("Search for Match").appendTo(frame);
var body = $('<div></div>').addClass("dialog-body").appendTo(frame);
var footer = $('<div></div>').addClass("dialog-footer").appendTo(frame);
$('<p></p>').text("Search Freebase for a topic to match all filtered cells:").appendTo(body);
var input = $('<input />').appendTo($('<p></p>').appendTo(body));
input.suggest({}).bind("fb-select", function(e, data) {
var query = {
"id" : data.id,
"type" : []
};
var baseUrl = "http://api.freebase.com/api/service/mqlread";
var url = baseUrl + "?" + $.param({ query: JSON.stringify({ query: query }) }) + "&callback=?";
$.getJSON(
url,
null,
function(o) {
var types = "result" in o ? o.result.type : [];
Refine.postCoreProcess(
"recon-match-specific-topic-to-cells",
{
columnName: column.name,
topicID: data.id,
topicGUID: data.guid,
topicName: data.name,
types: types.join(",")
},
null,
{ cellsChanged: true, columnStatsChanged: true }
);
DialogSystem.dismissUntil(level - 1);
MenuSystem.appendTo(menu, [ "core/reconcile" ], [
{
id: "core/reconcile",
label: "Start reconciling...",
tooltip: "Reconcile text in this column with topics on Freebase",
click: doReconcile
},
{},
{
id: "core/facets",
label: "Facets",
submenu: [
{
id: "core/by-judgment",
label: "By judgment",
click: function() {
ui.browsingEngine.addFacet(
"list",
{
"name" : column.name + ": judgment",
"columnName" : column.name,
"expression" : 'forNonBlank(cell.recon.judgment, v, v, if(isNonBlank(value), "(unreconciled)", "(blank)"))'
},
{
"scroll" : false
}
);
});
$('<button class="button"></button>').text("Cancel").click(function() {
DialogSystem.dismissUntil(level - 1);
}).appendTo(footer);
var level = DialogSystem.showDialog(frame);
input.focus().data("suggest").textchange();
};
var doCopyAcrossColumns = function() {
var frame = $(DOM.loadHTML("core", "scripts/views/data-table/copy-recon-across-columns-dialog.html"));
var elmts = DOM.bind(frame);
elmts.dialogHeader.text("Copy recon judgments from column " + column.name);
var columns = theProject.columnModel.columns;
for (var i = 0; i < columns.length; i++) {
var column2 = columns[i];
if (column !== column2) {
$('<option>').attr("value", column2.name).text(column2.name).appendTo(elmts.toColumnSelect);
}
}
var level = DialogSystem.showDialog(frame);
var dismiss = function() { DialogSystem.dismissUntil(level - 1); };
elmts.cancelButton.click(dismiss);
elmts.okButton.click(function() {
var config = {
fromColumnName: column.name,
toColumnName: [],
judgment: [],
applyToJudgedCells: elmts.applyToJudgedCellsCheckbox[0].checked
};
if (elmts.newCheckbox[0].checked) {
config.judgment.push("new");
}
if (elmts.matchCheckbox[0].checked) {
config.judgment.push("matched");
}
elmts.toColumnSelect.find("option").each(function() {
if (this.selected) {
config.toColumnName.push(this.value);
}
});
if (config.toColumnName.length == 0) {
alert("Please select some other column to copy to.");
} else if (config.judgment.length == 0) {
alert("Please select at least one kind of judgment to copy.");
} else {
Refine.postCoreProcess(
"recon-copy-across-columns",
null,
config,
{ rowsChanged: true }
);
dismiss();
}
});
};
MenuSystem.appendTo(menu, [ "core/reconcile" ], [
{
id: "core/reconcile",
label: "Start reconciling...",
tooltip: "Reconcile text in this column with topics on Freebase",
click: doReconcile
}
},
{},
{
id: "core/facets",
label: "Facets",
submenu: [
id: "core/by-best-candidates-score",
label: "Best candidate's score",
click: function() {
ui.browsingEngine.addFacet(
"range",
{
id: "core/by-judgment",
label: "By judgment",
click: function() {
ui.browsingEngine.addFacet(
"list",
{
"name" : column.name + ": judgment",
"columnName" : column.name,
"expression" : 'forNonBlank(cell.recon.judgment, v, v, if(isNonBlank(value), "(unreconciled)", "(blank)"))'
},
{
"scroll" : false
}
);
}
},
{},
{
id: "core/by-best-candidates-score",
label: "Best candidate's score",
click: function() {
ui.browsingEngine.addFacet(
"range",
{
"name" : column.name + ": best candidate's score",
"columnName" : column.name,
"expression" : "cell.recon.best.score",
"mode" : "range"
},
{
}
);
}
"name" : column.name + ": best candidate's score",
"columnName" : column.name,
"expression" : "cell.recon.best.score",
"mode" : "range"
},
{
id: "core/by-best-candidates-type-match",
label: "Best candidate's type match",
click: function() {
ui.browsingEngine.addFacet(
"list",
{
"name" : column.name + ": best candidate's types match?",
"columnName" : column.name,
"expression" : 'forNonBlank(cell.recon.features.typeMatch, v, v, if(isNonBlank(value), "(unreconciled)", "(blank)"))'
},
{
"scroll" : false
}
);
}
},
{
id: "core/by-best-candidates-name-match",
label: "Best candidate's name match",
click: function() {
ui.browsingEngine.addFacet(
"list",
{
"name" : column.name + ": best candidate's name match?",
"columnName" : column.name,
"expression" : 'forNonBlank(cell.recon.features.nameMatch, v, v, if(isNonBlank(value), "(unreconciled)", "(blank)"))'
},
{
"scroll" : false
}
);
}
},
{},
{
id: "core/by-best-candidates-name-edit-distance",
label: "Best candidate's name edit distance",
click: function() {
ui.browsingEngine.addFacet(
"range",
{
"name" : column.name + ": best candidate's name edit distance",
"columnName" : column.name,
"expression" : "cell.recon.features.nameLevenshtein",
"mode" : "range"
},
{
}
);
}
},
{
id: "core/by-best-candidates-name-word-similarity",
label: "Best candidate's name word similarity",
click: function() {
ui.browsingEngine.addFacet(
"range",
{
"name" : column.name + ": best candidate's name word similarity",
"columnName" : column.name,
"expression" : "cell.recon.features.nameWordDistance",
"mode" : "range"
},
{
}
);
}
},
{},
{
id: "core/by-best-candidates-types",
label: "Best candidate's types",
click: function() {
ui.browsingEngine.addFacet(
"list",
{
"name" : column.name + ": best candidate's types",
"columnName" : column.name,
"expression" : 'forNonBlank(cell.recon.best.type, v, v, if(isNonBlank(value), "(unreconciled)", "(blank)"))'
}
);
}
}
]
);
}
},
{
id: "core/qa-facets",
label: "QA facets",
submenu: [
id: "core/by-best-candidates-type-match",
label: "Best candidate's type match",
click: function() {
ui.browsingEngine.addFacet(
"list",
{
id: "core/by-qa-results",
label: "QA results",
click: function() {
ui.browsingEngine.addFacet(
"list",
{
"name" : column.name + " QA Results",
"columnName" : column.name,
"expression" : "cell.recon.features.qaResult"
}
);
}
"name" : column.name + ": best candidate's types match?",
"columnName" : column.name,
"expression" : 'forNonBlank(cell.recon.features.typeMatch, v, v, if(isNonBlank(value), "(unreconciled)", "(blank)"))'
},
{
id: "core/by-judgment-actions",
label: "Judgment actions",
click: function() {
ui.browsingEngine.addFacet(
"list",
{
"name" : column.name + " Judgment Actions",
"columnName" : column.name,
"expression" : "cell.recon.judgmentAction"
}
);
}
},
{
id: "core/by-judgment-history-entries",
label: "Judgment history entries",
click: function() {
ui.browsingEngine.addFacet(
"list",
{
"name" : column.name + " History Entries",
"columnName" : column.name,
"expression" : "cell.recon.judgmentHistoryEntry"
}
);
}
"scroll" : false
}
]
);
}
},
{
id: "core/actions",
label: "Actions",
submenu: [
id: "core/by-best-candidates-name-match",
label: "Best candidate's name match",
click: function() {
ui.browsingEngine.addFacet(
"list",
{
id: "core/match-to-best-candidate",
label: "Match each cell to its best candidate",
tooltip: "Match each cell to its best candidate in this column for all current filtered rows",
click: doReconMatchBestCandidates
"name" : column.name + ": best candidate's name match?",
"columnName" : column.name,
"expression" : 'forNonBlank(cell.recon.features.nameMatch, v, v, if(isNonBlank(value), "(unreconciled)", "(blank)"))'
},
{
id: "core/match-to-new-topic",
label: "Create a new topic for each cell",
tooltip: "Mark to create one new topic for each cell in this column for all current filtered rows",
click: function() {
doReconMarkNewTopics(false);
}
},
{},
{
id: "core/match-similar-to-new-topic",
label: "Create one new topic for similar cells",
tooltip: "Mark to create one new topic for each group of similar cells in this column for all current filtered rows",
click: function() {
doReconMarkNewTopics(true);
}
},
{
id: "core/match-to-specific",
label: "Match all filtered cells to...",
tooltip: "Search for a topic to match all filtered cells to",
click: doSearchToMatch
},
{},
{
id: "core/discard-judgments",
label: "Discard reconciliation judgments",
tooltip: "Discard reconciliation judgments in this column for all current filtered rows",
click: doReconDiscardJudgments
},
{
id: "core/clear-recon-data",
label: "Clear reconciliation data",
tooltip: "Clear reconciliation data in this column for all current filtered rows",
click: doClearReconData
"scroll" : false
}
]
);
}
},
{},
{
id: "core/copy-across-columns",
label: "Copy reconciliation data...",
tooltip: "Copy this column's reconciliation data to other columns",
click: doCopyAcrossColumns
id: "core/by-best-candidates-name-edit-distance",
label: "Best candidate's name edit distance",
click: function() {
ui.browsingEngine.addFacet(
"range",
{
"name" : column.name + ": best candidate's name edit distance",
"columnName" : column.name,
"expression" : "cell.recon.features.nameLevenshtein",
"mode" : "range"
},
{
}
);
}
},
{
id: "core/by-best-candidates-name-word-similarity",
label: "Best candidate's name word similarity",
click: function() {
ui.browsingEngine.addFacet(
"range",
{
"name" : column.name + ": best candidate's name word similarity",
"columnName" : column.name,
"expression" : "cell.recon.features.nameWordDistance",
"mode" : "range"
},
{
}
);
}
},
{},
{
id: "core/by-best-candidates-types",
label: "Best candidate's types",
click: function() {
ui.browsingEngine.addFacet(
"list",
{
"name" : column.name + ": best candidate's types",
"columnName" : column.name,
"expression" : 'forNonBlank(cell.recon.best.type, v, v, if(isNonBlank(value), "(unreconciled)", "(blank)"))'
}
);
}
}
]);
]
},
{
id: "core/qa-facets",
label: "QA facets",
submenu: [
{
id: "core/by-qa-results",
label: "QA results",
click: function() {
ui.browsingEngine.addFacet(
"list",
{
"name" : column.name + " QA Results",
"columnName" : column.name,
"expression" : "cell.recon.features.qaResult"
}
);
}
},
{
id: "core/by-judgment-actions",
label: "Judgment actions",
click: function() {
ui.browsingEngine.addFacet(
"list",
{
"name" : column.name + " Judgment Actions",
"columnName" : column.name,
"expression" : "cell.recon.judgmentAction"
}
);
}
},
{
id: "core/by-judgment-history-entries",
label: "Judgment history entries",
click: function() {
ui.browsingEngine.addFacet(
"list",
{
"name" : column.name + " History Entries",
"columnName" : column.name,
"expression" : "cell.recon.judgmentHistoryEntry"
}
);
}
}
]
},
{
id: "core/actions",
label: "Actions",
submenu: [
{
id: "core/match-to-best-candidate",
label: "Match each cell to its best candidate",
tooltip: "Match each cell to its best candidate in this column for all current filtered rows",
click: doReconMatchBestCandidates
},
{
id: "core/match-to-new-topic",
label: "Create a new topic for each cell",
tooltip: "Mark to create one new topic for each cell in this column for all current filtered rows",
click: function() {
doReconMarkNewTopics(false);
}
},
{},
{
id: "core/match-similar-to-new-topic",
label: "Create one new topic for similar cells",
tooltip: "Mark to create one new topic for each group of similar cells in this column for all current filtered rows",
click: function() {
doReconMarkNewTopics(true);
}
},
{
id: "core/match-to-specific",
label: "Match all filtered cells to...",
tooltip: "Search for a topic to match all filtered cells to",
click: doSearchToMatch
},
{},
{
id: "core/discard-judgments",
label: "Discard reconciliation judgments",
tooltip: "Discard reconciliation judgments in this column for all current filtered rows",
click: doReconDiscardJudgments
},
{
id: "core/clear-recon-data",
label: "Clear reconciliation data",
tooltip: "Clear reconciliation data in this column for all current filtered rows",
click: doClearReconData
}
]
},
{},
{
id: "core/copy-across-columns",
label: "Copy reconciliation data...",
tooltip: "Copy this column's reconciliation data to other columns",
click: doCopyAcrossColumns
}
]);
});

View File

@ -3,41 +3,41 @@
<div class="dialog-header" bind="dialogHeader"></div>
<div class="dialog-body" bind="dialogBody">
<div class="grid-layout layout-normal layout-full "><table>
<tr>
<td>Sort cell values as</td>
<td>Position blanks and errors</td>
</tr>
<tr>
<td>
<div class="grid-layout layout-tightest grid-layout-for-text" bind="valueTypeOptions"><table>
<tr>
<td width="1"><input type="radio" name="sorting-dialog-value-type" value="string" /></td>
<td>text <input type="checkbox" class="inline" bind="caseSensitiveCheckbox" /> case-sensitive</td>
</tr>
<tr>
<td width="1"><input type="radio" name="sorting-dialog-value-type" value="number" /></td>
<td>numbers</td>
</tr>
<tr>
<td width="1"><input type="radio" name="sorting-dialog-value-type" value="date" /></td>
<td>dates</td>
</tr>
<tr>
<td width="1"><input type="radio" name="sorting-dialog-value-type" value="boolean" /></td>
<td>booleans</td>
</tr>
</table></div>
</td>
<td>
<ul class="sorting-dialog-blank-error-positions" bind="blankErrorPositions"></ul>
<p>Drag and drop to re-order</p>
</td>
</tr>
<tr><td colspan="2" bind="directionOptions">
<input type="radio" class="inline" name="sorting-dialog-direction" value="forward" /><label bind="directionForwardLabel">forward</label>
<input type="radio" class="inline" name="sorting-dialog-direction" value="reverse" /><label bind="directionReverseLabel">reverse</label>
<span bind="sortAloneContainer" style="display:none;"><input type="checkbox" class="inline" /><label>sort by this column alone</label></span>
</td></tr>
<tr>
<td>Sort cell values as</td>
<td>Position blanks and errors</td>
</tr>
<tr>
<td>
<div class="grid-layout layout-tightest grid-layout-for-text" bind="valueTypeOptions"><table>
<tr>
<td width="1"><input type="radio" name="sorting-dialog-value-type" value="string" /></td>
<td>text <input type="checkbox" class="inline" bind="caseSensitiveCheckbox" /> case-sensitive</td>
</tr>
<tr>
<td width="1"><input type="radio" name="sorting-dialog-value-type" value="number" /></td>
<td>numbers</td>
</tr>
<tr>
<td width="1"><input type="radio" name="sorting-dialog-value-type" value="date" /></td>
<td>dates</td>
</tr>
<tr>
<td width="1"><input type="radio" name="sorting-dialog-value-type" value="boolean" /></td>
<td>booleans</td>
</tr>
</table></div>
</td>
<td>
<ul class="sorting-dialog-blank-error-positions" bind="blankErrorPositions"></ul>
<p>Drag and drop to re-order</p>
</td>
</tr>
<tr><td colspan="2" bind="directionOptions">
<input type="radio" class="inline" name="sorting-dialog-direction" value="forward" /><label bind="directionForwardLabel">forward</label>
<input type="radio" class="inline" name="sorting-dialog-direction" value="reverse" /><label bind="directionReverseLabel">reverse</label>
<span bind="sortAloneContainer" style="display:none;"><input type="checkbox" class="inline" /><label>sort by this column alone</label></span>
</td></tr>
</table></div>
</div>
<div class="dialog-footer" bind="dialogFooter">

View File

@ -3,50 +3,50 @@
<div class="dialog-header" bind="dialogHeader"></div>
<div class="dialog-body" bind="dialogBody">
<div class="grid-layout layout-looser layout-full"><table><tr>
<td>
<div class="grid-layout layout-tighter"><table>
<tr>
<td colspan="3"><h3>How to Split Column</h3></td>
</tr>
<tr>
<td width="1%"><input type="radio" checked="true" name="split-by-mode" value="separator" /></td>
<td colspan="2">by separator</td>
</tr>
<tr><td></td>
<td>Separator</td>
<td style="white-space: pre;"><input size="15" value="," bind="separatorInput" /> <input type="checkbox" bind="regexInput" /> regular expression</td>
</tr>
<tr><td></td>
<td>Split into</td>
<td style="white-space: pre;"><input size="3" bind="maxColumnsInput" /> columns at most (leave blank for no limit)</td>
</tr>
<tr>
<td width="1%"><input type="radio" name="split-by-mode" value="lengths" /></td>
<td colspan="2">by field lengths</td>
</tr>
<tr><td></td>
<td colspan="2"><textarea style="width: 100%;" bind="lengthsTextarea"></textarea></td>
</tr>
<tr><td></td>
<td colspan="2">List of integers separated by commas, e.g., 5, 7, 15</td>
</tr>
</table></div>
</td>
<td>
<div class="grid-layout layout-tighter"><table>
<tr>
<td colspan="3"><h3>After Splitting</h3></td>
</tr>
<tr>
<td width="1%"><input type="checkbox" checked="true" bind="guessCellTypeInput" /></td>
<td colspan="2">Guess cell type</td>
</tr>
<tr>
<td width="1%"><input type="checkbox" checked="true" bind="removeColumnInput" /></td>
<td colspan="2">Remove this column</td>
</tr>
</table></div>
</td>
<td>
<div class="grid-layout layout-tighter"><table>
<tr>
<td colspan="3"><h3>How to Split Column</h3></td>
</tr>
<tr>
<td width="1%"><input type="radio" checked="true" name="split-by-mode" value="separator" /></td>
<td colspan="2">by separator</td>
</tr>
<tr><td></td>
<td>Separator</td>
<td style="white-space: pre;"><input size="15" value="," bind="separatorInput" /> <input type="checkbox" bind="regexInput" /> regular expression</td>
</tr>
<tr><td></td>
<td>Split into</td>
<td style="white-space: pre;"><input size="3" bind="maxColumnsInput" /> columns at most (leave blank for no limit)</td>
</tr>
<tr>
<td width="1%"><input type="radio" name="split-by-mode" value="lengths" /></td>
<td colspan="2">by field lengths</td>
</tr>
<tr><td></td>
<td colspan="2"><textarea style="width: 100%;" bind="lengthsTextarea"></textarea></td>
</tr>
<tr><td></td>
<td colspan="2">List of integers separated by commas, e.g., 5, 7, 15</td>
</tr>
</table></div>
</td>
<td>
<div class="grid-layout layout-tighter"><table>
<tr>
<td colspan="3"><h3>After Splitting</h3></td>
</tr>
<tr>
<td width="1%"><input type="checkbox" checked="true" bind="guessCellTypeInput" /></td>
<td colspan="2">Guess cell type</td>
</tr>
<tr>
<td width="1%"><input type="checkbox" checked="true" bind="removeColumnInput" /></td>
<td colspan="2">Remove this column</td>
</tr>
</table></div>
</td>
</table></div>
</div>
<div class="dialog-footer" bind="dialogFooter">

View File

@ -3,13 +3,13 @@
<div class="dialog-header" bind="dialogHeader"></div>
<div class="dialog-body" bind="dialogBody">
<div class="grid-layout layout-tight layout-full"><table>
<tr><td colspan="4">$EXPRESSION_PREVIEW_WIDGET$</td></tr>
<tr style="white-space: pre;">
<td width="1%">On error</td>
<td><input type="radio" name="text-transform-dialog-onerror-choice" value="set-to-blank" checked /> set to blank<br/><input type="radio" name="text-transform-dialog-onerror-choice" value="store-error" /> store error<br/><input type="radio" name="text-transform-dialog-onerror-choice" value="keep-original" /> keep original</td>
<td width="1%"><input type="checkbox" bind="repeatCheckbox" /></td>
<td>Re-transform up to <input bind="repeatCountInput" value="10" size="2" /> times until no change</td>
</tr>
<tr><td colspan="4">$EXPRESSION_PREVIEW_WIDGET$</td></tr>
<tr style="white-space: pre;">
<td width="1%">On error</td>
<td><input type="radio" name="text-transform-dialog-onerror-choice" value="set-to-blank" checked /> set to blank<br/><input type="radio" name="text-transform-dialog-onerror-choice" value="store-error" /> store error<br/><input type="radio" name="text-transform-dialog-onerror-choice" value="keep-original" /> keep original</td>
<td width="1%"><input type="checkbox" bind="repeatCheckbox" /></td>
<td>Re-transform up to <input bind="repeatCountInput" value="10" size="2" /> times until no change</td>
</tr>
</table>
</div>
</div>

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,132 +29,132 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
function HistogramWidget(elmt, options) {
this._elmt = elmt;
this._options = options;
this._range = null;
this._binMatrix = null;
this._initializeUI();
this._elmt = elmt;
this._options = options;
this._range = null;
this._binMatrix = null;
this._initializeUI();
}
HistogramWidget.prototype.update = function(min, max, step, binMatrix) {
if (typeof min == "undefined" ||
typeof binMatrix == "undefined" ||
binMatrix.length === 0 ||
binMatrix[0].length === 0) {
this._range = null;
this._binMatrix = null;
this._elmt.hide();
} else {
this._range = { min: min, max: max, step: step };
this._binMatrix = binMatrix;
this._peak = 0;
for (var r = 0; r < binMatrix.length; r++) {
var row = binMatrix[r];
for (var c = 0; c < row.length; c++) {
this._peak = Math.max(this._peak, row[c]);
}
}
this._update();
if (typeof min == "undefined" ||
typeof binMatrix == "undefined" ||
binMatrix.length === 0 ||
binMatrix[0].length === 0) {
this._range = null;
this._binMatrix = null;
this._elmt.hide();
} else {
this._range = { min: min, max: max, step: step };
this._binMatrix = binMatrix;
this._peak = 0;
for (var r = 0; r < binMatrix.length; r++) {
var row = binMatrix[r];
for (var c = 0; c < row.length; c++) {
this._peak = Math.max(this._peak, row[c]);
}
}
this._update();
}
};
HistogramWidget.prototype._update = function() {
if (this._binMatrix !== null) {
this._elmt.show();
this._resize();
this._render();
}
if (this._binMatrix !== null) {
this._elmt.show();
this._resize();
this._render();
}
};
HistogramWidget.prototype._initializeUI = function() {
this._elmt
.empty()
.hide()
.addClass("histogram-widget")
.html(
'<canvas bind="canvas"></canvas>'
);
this._elmts = DOM.bind(this._elmt);
this._elmt
.empty()
.hide()
.addClass("histogram-widget")
.html(
'<canvas bind="canvas"></canvas>'
);
this._elmts = DOM.bind(this._elmt);
};
HistogramWidget.prototype._resize = function() {
var height = "height" in this._options ? this._options.height : 50;
this._elmts.canvas.attr("height", height);
this._elmts.canvas.attr("width", this._elmts.canvas.width());
this._elmt.height(height);
var height = "height" in this._options ? this._options.height : 50;
this._elmts.canvas.attr("height", height);
this._elmts.canvas.attr("width", this._elmts.canvas.width());
this._elmt.height(height);
};
HistogramWidget.prototype._render = function() {
var self = this;
var options = this._options;
var canvas = this._elmts.canvas[0];
var ctx = canvas.getContext('2d');
ctx.fillStyle = "white";
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.save();
ctx.translate(0, canvas.height);
ctx.scale(1, -1);
var stepPixels = canvas.width / this._binMatrix[0].length;
var stepScale = stepPixels / this._range.step;
/*
* Draw axis
*/
ctx.save();
ctx.strokeStyle = "emptyBinColor" in options ? options.emptyBinColor : "#faa";
ctx.lineWidth = 1;
ctx.moveTo(0, 0);
ctx.lineTo(canvas.width, 0);
ctx.stroke();
ctx.restore();
var self = this;
var options = this._options;
/*
* Draw bins
*/
var makeColor = function(i) {
var n = Math.floor(15 * (self._binMatrix.length - i) / self._binMatrix.length);
var h = n.toString(16);
return "#" + h + h + h;
};
var renderRow = function(row, color) {
ctx.save();
ctx.lineWidth = 0;
ctx.fillStyle = color;
for (var c = 0; c < row.length; c++) {
var x = self._range.min + c * self._range.step;
var y = row[c];
if (y > 0) {
var left = c * stepPixels;
var width = Math.ceil(stepPixels);
var height = Math.max(2, Math.ceil(y * canvas.height / self._peak));
ctx.fillRect(left, 0, width, height);
}
}
ctx.restore();
};
for (var r = 0; r < this._binMatrix.length; r++) {
renderRow(
this._binMatrix[r],
"binColors" in options && r < options.binColors.length ?
options.binColors[r] :
makeColor(r)
);
var canvas = this._elmts.canvas[0];
var ctx = canvas.getContext('2d');
ctx.fillStyle = "white";
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.save();
ctx.translate(0, canvas.height);
ctx.scale(1, -1);
var stepPixels = canvas.width / this._binMatrix[0].length;
var stepScale = stepPixels / this._range.step;
/*
* Draw axis
*/
ctx.save();
ctx.strokeStyle = "emptyBinColor" in options ? options.emptyBinColor : "#faa";
ctx.lineWidth = 1;
ctx.moveTo(0, 0);
ctx.lineTo(canvas.width, 0);
ctx.stroke();
ctx.restore();
/*
* Draw bins
*/
var makeColor = function(i) {
var n = Math.floor(15 * (self._binMatrix.length - i) / self._binMatrix.length);
var h = n.toString(16);
return "#" + h + h + h;
};
var renderRow = function(row, color) {
ctx.save();
ctx.lineWidth = 0;
ctx.fillStyle = color;
for (var c = 0; c < row.length; c++) {
var x = self._range.min + c * self._range.step;
var y = row[c];
if (y > 0) {
var left = c * stepPixels;
var width = Math.ceil(stepPixels);
var height = Math.max(2, Math.ceil(y * canvas.height / self._peak));
ctx.fillRect(left, 0, width, height);
}
}
ctx.restore();
};
for (var r = 0; r < this._binMatrix.length; r++) {
renderRow(
this._binMatrix[r],
"binColors" in options && r < options.binColors.length ?
options.binColors[r] :
makeColor(r)
);
}
ctx.restore();
};

View File

@ -7,13 +7,13 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
@ -29,204 +29,204 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
function SliderWidget(elmt, options) {
this._elmt = elmt;
this._options = options || {};
this._range = {
min: 0,
max: 1,
step: 1,
from: 0,
to: 0
};
this._drag = null;
var self = this;
this._mouseMoveHandler = function(evt) {
return self._onMouseMove(evt);
};
this._mouseUpHandler = function(evt) {
return self._onMouseUp(evt);
};
this._initializeUI();
this._update();
this._elmt = elmt;
this._options = options || {};
this._range = {
min: 0,
max: 1,
step: 1,
from: 0,
to: 0
};
this._drag = null;
var self = this;
this._mouseMoveHandler = function(evt) {
return self._onMouseMove(evt);
};
this._mouseUpHandler = function(evt) {
return self._onMouseUp(evt);
};
this._initializeUI();
this._update();
}
SliderWidget.prototype.update = function(min, max, step, from, to) {
if (step <= 0) {
step = 1;
}
max = Math.max(max, min + step);
from = Math.max(min, from);
to = Math.min(max, to);
this._range = {
min: min,
max: max,
step: step,
from: from,
to: to
};
this._update();
if (step <= 0) {
step = 1;
}
max = Math.max(max, min + step);
from = Math.max(min, from);
to = Math.min(max, to);
this._range = {
min: min,
max: max,
step: step,
from: from,
to: to
};
this._update();
};
SliderWidget.prototype._initializeUI = function() {
this._elmt.addClass("slider-widget");
this._leftTintedRect = $("<div>").addClass("slider-widget-tint left").appendTo(this._elmt);
this._rightTintedRect = $("<div>").addClass("slider-widget-tint right").appendTo(this._elmt);
this._highlightRect = $("<div>").addClass("slider-widget-highlight slider-widget-draggable").attr("part", "highlight").appendTo(this._elmt);
this._leftBracket = $("<div>").addClass("slider-widget-bracket slider-widget-draggable left").attr("part", "left").appendTo(this._elmt);
this._rightBracket = $("<div>").addClass("slider-widget-bracket slider-widget-draggable right").attr("part", "right").appendTo(this._elmt);
var self = this;
this._elmt.find(".slider-widget-draggable")
.mousedown(function(evt) {
return self._onMouseDown(evt, this.getAttribute("part"));
});
this._highlightRect.dblclick(function(evt) {
if (self._range.from > self._range.min || self._range.to < self._range.max) {
self._range.from = self._range.min;
self._range.to = self._range.max;
self._update();
self._trigger("stop");
}
});
this._elmt
.mousemove(function(evt) {
return self._onMouseMove(evt);
})
.mouseup(function(evt) {
return self._onMouseUp(evt);
});
this._elmt.addClass("slider-widget");
this._leftTintedRect = $("<div>").addClass("slider-widget-tint left").appendTo(this._elmt);
this._rightTintedRect = $("<div>").addClass("slider-widget-tint right").appendTo(this._elmt);
this._highlightRect = $("<div>").addClass("slider-widget-highlight slider-widget-draggable").attr("part", "highlight").appendTo(this._elmt);
this._leftBracket = $("<div>").addClass("slider-widget-bracket slider-widget-draggable left").attr("part", "left").appendTo(this._elmt);
this._rightBracket = $("<div>").addClass("slider-widget-bracket slider-widget-draggable right").attr("part", "right").appendTo(this._elmt);
var self = this;
this._elmt.find(".slider-widget-draggable")
.mousedown(function(evt) {
return self._onMouseDown(evt, this.getAttribute("part"));
});
this._highlightRect.dblclick(function(evt) {
if (self._range.from > self._range.min || self._range.to < self._range.max) {
self._range.from = self._range.min;
self._range.to = self._range.max;
self._update();
self._trigger("stop");
}
});
this._elmt
.mousemove(function(evt) {
return self._onMouseMove(evt);
})
.mouseup(function(evt) {
return self._onMouseUp(evt);
});
};
SliderWidget.prototype._onMouseDown = function(evt, part) {
if (this._drag) {
return;
}
$(document).mousemove(this._mouseMoveHandler);
$(document).mouseup(this._mouseUpHandler);
this._drag = {
sureDrag: false,
overlay: $('<div>').addClass("slider-widget-overlay").appendTo(document.body)
};
if ("highlight" == part) {
this._drag.elmt = this._highlightRect;
this._drag.value = this._range.from;
$(this._drag.overlay).css("cursor", "move");
} else if ("left" == part) {
this._drag.elmt = this._leftBracket;
$(this._drag.overlay).css("cursor", "e-resize");
} else if ("right" == part) {
this._drag.elmt = this._rightBracket;
$(this._drag.overlay).css("cursor", "w-resize");
}
this._drag.what = part;
this._drag.from = this._range.from;
this._drag.to = this._range.to;
this._drag.down = {
x: evt.pageX,
y: evt.pageY
};
if (this._drag) {
return;
}
$(document).mousemove(this._mouseMoveHandler);
$(document).mouseup(this._mouseUpHandler);
this._drag = {
sureDrag: false,
overlay: $('<div>').addClass("slider-widget-overlay").appendTo(document.body)
};
if ("highlight" == part) {
this._drag.elmt = this._highlightRect;
this._drag.value = this._range.from;
$(this._drag.overlay).css("cursor", "move");
} else if ("left" == part) {
this._drag.elmt = this._leftBracket;
$(this._drag.overlay).css("cursor", "e-resize");
} else if ("right" == part) {
this._drag.elmt = this._rightBracket;
$(this._drag.overlay).css("cursor", "w-resize");
}
this._drag.what = part;
this._drag.from = this._range.from;
this._drag.to = this._range.to;
this._drag.down = {
x: evt.pageX,
y: evt.pageY
};
};
SliderWidget.prototype._onMouseUp = function(evt) {
if (!(this._drag)) {
return;
}
$(document).unbind("mousemove", this._mouseMoveHandler);
$(document).unbind("mouseup", this._mouseUpHandler);
if (this._drag.sureDrag) {
this._update();
this._trigger("stop");
}
this._drag.overlay.remove();
this._drag = null;
if (!(this._drag)) {
return;
}
$(document).unbind("mousemove", this._mouseMoveHandler);
$(document).unbind("mouseup", this._mouseUpHandler);
if (this._drag.sureDrag) {
this._update();
this._trigger("stop");
}
this._drag.overlay.remove();
this._drag = null;
};
SliderWidget.prototype._trigger = function(eventName) {
this._elmt.trigger(eventName, [{ from: this._range.from, to: this._range.to }]);
this._elmt.trigger(eventName, [{ from: this._range.from, to: this._range.to }]);
};
SliderWidget.prototype._onMouseMove = function(evt) {
if (!(this._drag)) {
return;
}
var drag = this._drag;
var range = this._range;
var offset = this._elmt.offset();
var xDiff = evt.pageX - drag.down.x;
var yDiff = evt.pageX - drag.down.y;
if (Math.abs(xDiff) >= 2) {
drag.sureDrag = true;
}
var pixelWidth = this._elmt.width();
var scale = pixelWidth / (range.max - range.min);
var vDiff = xDiff / scale;
var adjustFrom = function() {
range.from = drag.from + Math.floor(vDiff / range.step) * range.step;
range.from = Math.max(Math.min(range.from, range.max), range.min);
};
var adjustTo = function() {
range.to = drag.to + Math.floor(vDiff / range.step) * range.step;
range.to = Math.max(Math.min(range.to, range.max), range.min);
};
if (drag.what == "left") {
adjustFrom();
range.to = Math.min(Math.max(range.to, range.from + range.step), range.max);
} else if (drag.what == "right") {
adjustTo();
range.from = Math.max(Math.min(range.from, range.to - range.step), range.min);
} else {
adjustFrom();
adjustTo();
}
this._update();
this._trigger("slide");
evt.preventDefault();
return false;
if (!(this._drag)) {
return;
}
var drag = this._drag;
var range = this._range;
var offset = this._elmt.offset();
var xDiff = evt.pageX - drag.down.x;
var yDiff = evt.pageX - drag.down.y;
if (Math.abs(xDiff) >= 2) {
drag.sureDrag = true;
}
var pixelWidth = this._elmt.width();
var scale = pixelWidth / (range.max - range.min);
var vDiff = xDiff / scale;
var adjustFrom = function() {
range.from = drag.from + Math.floor(vDiff / range.step) * range.step;
range.from = Math.max(Math.min(range.from, range.max), range.min);
};
var adjustTo = function() {
range.to = drag.to + Math.floor(vDiff / range.step) * range.step;
range.to = Math.max(Math.min(range.to, range.max), range.min);
};
if (drag.what == "left") {
adjustFrom();
range.to = Math.min(Math.max(range.to, range.from + range.step), range.max);
} else if (drag.what == "right") {
adjustTo();
range.from = Math.max(Math.min(range.from, range.to - range.step), range.min);
} else {
adjustFrom();
adjustTo();
}
this._update();
this._trigger("slide");
evt.preventDefault();
return false;
};
SliderWidget.prototype._update = function() {
var range = this._range;
var pixelWidth = this._elmt.width();
var scale = pixelWidth / (range.max - range.min);
var valueToPixel = function(x) {
return (x - range.min) * scale;
};
var fromPixel = Math.floor(valueToPixel(range.from));
var toPixel = Math.floor(valueToPixel(range.to));
if (range.from == range.min && range.to == range.max) {
this._leftTintedRect.hide();
this._rightTintedRect.hide();
} else {
this._leftTintedRect.show().width(fromPixel);
this._rightTintedRect.show().width(pixelWidth - toPixel);
}
this._highlightRect.css("left", (fromPixel - 1) + "px").width(toPixel - fromPixel);
this._leftBracket.css("left", fromPixel + "px");
this._rightBracket.css("left", toPixel + "px");
var range = this._range;
var pixelWidth = this._elmt.width();
var scale = pixelWidth / (range.max - range.min);
var valueToPixel = function(x) {
return (x - range.min) * scale;
};
var fromPixel = Math.floor(valueToPixel(range.from));
var toPixel = Math.floor(valueToPixel(range.to));
if (range.from == range.min && range.to == range.max) {
this._leftTintedRect.hide();
this._rightTintedRect.hide();
} else {
this._leftTintedRect.show().width(fromPixel);
this._rightTintedRect.show().width(pixelWidth - toPixel);
}
this._highlightRect.css("left", (fromPixel - 1) + "px").width(toPixel - fromPixel);
this._leftBracket.css("left", fromPixel + "px");
this._rightBracket.css("left", toPixel + "px");
};

View File

@ -312,111 +312,117 @@ input.lightweight {
div.grid-layout > table {
border-collapse: separate;
}
border-collapse: separate;
}
div.grid-layout.layout-full > table {
width: 100%;
max-width: 100% !important;
}
div.grid-layout > table > tbody > tr > th, div.grid-layout > table > tbody > tr > td {
padding: 0px;
text-align: left;
vertical-align: baseline;
}
div.grid-layout.grid-layout-for-text > table > tbody > tr > th, div.grid-layout.grid-layout-for-text > table > tbody > tr > td {
vertical-align: middle;
}
div.grid-layout.grid-layout-for-ui > table > tbody > tr > th, div.grid-layout.grid-layout-for-ui > table > tbody > tr > td {
vertical-align: top;
}
width: 100%;
max-width: 100% !important;
}
div.grid-layout > table > tbody > tr > th,
div.grid-layout > table > tbody > tr > td {
padding: 0px;
text-align: left;
vertical-align: baseline;
}
div.grid-layout.grid-layout-for-text > table > tbody > tr > th,
div.grid-layout.grid-layout-for-text > table > tbody > tr > td {
vertical-align: middle;
}
div.grid-layout.grid-layout-for-ui > table > tbody > tr > th,
div.grid-layout.grid-layout-for-ui > table > tbody > tr > td {
vertical-align: top;
}
div.grid-layout.layout-normal {
margin: -10px;
}
margin: -10px;
}
div.grid-layout.layout-normal > table {
border-spacing: 10px;
}
border-spacing: 10px;
}
div.grid-layout.layout-tight {
margin: -7px;
}
margin: -7px;
}
div.grid-layout.layout-tight > table {
border-spacing: 7px;
}
border-spacing: 7px;
}
div.grid-layout.layout-tighter {
margin: -5px;
}
margin: -5px;
}
div.grid-layout.layout-tighter > table {
border-spacing: 5px;
}
border-spacing: 5px;
}
div.grid-layout.layout-tightest {
margin: -3px;
}
margin: -3px;
}
div.grid-layout.layout-tightest > table {
border-spacing: 3px;
}
border-spacing: 3px;
}
div.grid-layout.layout-loose {
margin: -15px;
}
margin: -15px;
}
div.grid-layout.layout-loose > table {
border-spacing: 15px;
}
border-spacing: 15px;
}
div.grid-layout.layout-looser {
margin: -20px;
}
margin: -20px;
}
div.grid-layout.layout-looser > table {
border-spacing: 20px;
}
border-spacing: 20px;
}
div.input-container {
padding: 3px;
}
padding: 3px;
}
div.input-container > input, div.input-container > textarea {
display: block;
width: 100%;
padding: 2px;
border: 1px inset;
margin-left: -3px;
margin-top: -3px;
vertical-align: top;
}
display: block;
width: 100%;
padding: 2px;
border: 1px inset;
margin-left: -3px;
margin-top: -3px;
vertical-align: top;
}
input.code, textarea.code {
font-family: monospace;
}
font-family: monospace;
}
img {
vertical-align: middle;
}
vertical-align: middle;
}
.hidden {
display: none;
}
display: none;
}
.fbs-pane, .fbs-flyout-pane {
z-index: 2000;
}
z-index: 2000;
}
.ui-widget {
font-family: inherit;
font-size: inherit;
}
.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button {
font-family: inherit;
font-size: inherit;
}
font-family: inherit;
font-size: inherit;
}
.ui-widget input,
.ui-widget select,
.ui-widget textarea,
.ui-widget button {
font-family: inherit;
font-size: inherit;
}
p.body-text {
margin-bottom: 1em;
}
}
.relative-frame {
position: relative;
width: 100%;
height: 100%;
overflow: hidden;
}
}

View File

@ -34,86 +34,86 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@import-less url("../theme.less");
.clustering-dialog-table-container {
height: 450px;
overflow: auto;
border: 1px solid #aaa;
}
height: 450px;
overflow: auto;
border: 1px solid #aaa;
}
table.clustering-dialog-entry-table {
border-collapse: collapse;
width: 100%;
}
border-collapse: collapse;
width: 100%;
}
table.clustering-dialog-entry-table > tbody > tr.header {
background: #ccc;
font-weight: bold;
}
background: #ccc;
font-weight: bold;
}
table.clustering-dialog-entry-table > tbody > tr > td {
padding: 2px 5px;
}
padding: 2px 5px;
}
table.clustering-dialog-entry-table > tbody > tr.odd > td {
background: #eee;
}
background: #eee;
}
table.clustering-dialog-entry-table > tbody > tr.even > td {
background: white;
}
background: white;
}
table.clustering-dialog-entry-table input {
border: 1px solid #ccc;
padding: 0 0.1em;
}
border: 1px solid #ccc;
padding: 0 0.1em;
}
table.clustering-dialog-entry-table a {
text-decoration: none;
}
text-decoration: none;
}
table.clustering-dialog-entry-table ul {
margin: 1em 0em 0em 0em;
}
margin: 1em 0em 0em 0em;
}
table.clustering-dialog-entry-table a:hover {
text-decoration: underline
}
text-decoration: underline
}
.clustering-dialog-entry-count {
color: #aaa;
margin-left: 0.5em;
}
color: #aaa;
margin-left: 0.5em;
}
.clustering-dialog-controls {
margin-bottom: 0.5em;
margin-right: 2em;
}
margin-bottom: 0.5em;
margin-right: 2em;
}
.clustering-dialog-controls td {
padding-right: 0.5em;
}
padding-right: 0.5em;
}
.clustering-dialog-facet {
margin-bottom: 1em;
}
margin-bottom: 1em;
}
.clustering-dialog-facet-header {
font-weight: bold;
}
font-weight: bold;
}
.clustering-dialog-facet-histogram {
overflow: hidden;
}
overflow: hidden;
}
.clustering-dialog-facet-slider {
margin: 5px;
}
margin: 5px;
}
.clustering-dialog-facet-selection {
text-align: center;
color: #888;
}
text-align: center;
color: #888;
}
.clustering-dialog-value-focus {
text-align: right;
font-size: 80%;
}
text-align: right;
font-size: 80%;
}
.clustering-dialog-value-focus a {
text-decoration: none;
visibility: hidden;
}
text-decoration: none;
visibility: hidden;
}

View File

@ -34,16 +34,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@import-less url("../theme.less");
.column-reordering-dialog-column {
border: 1px solid #aaa;
background: #eee;
padding: 3px;
margin: 2px;
cursor: move;
}
border: 1px solid #aaa;
background: #eee;
padding: 3px;
margin: 2px;
cursor: move;
}
.column-reordering-dialog-column-container {
height: 375px;
border: 1px solid #eee;
padding: 10px;
overflow: auto;
}
height: 375px;
border: 1px solid #eee;
padding: 10px;
overflow: auto;
}

View File

@ -34,86 +34,86 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@import-less url("../theme.less");
#expression-preview-tabs .ui-tabs-nav li a {
padding: 0.15em 1em;
}
padding: 0.15em 1em;
}
textarea.expression-preview-code {
font-family: monospace;
height: 5em;
vertical-align: top;
}
font-family: monospace;
height: 5em;
vertical-align: top;
}
.expression-preview-parsing-status {
color: @light_grey;
}
color: @light_grey;
}
.expression-preview-parsing-status.error {
color: red;
}
color: red;
}
#expression-preview-tabs-preview,
#expression-preview-tabs-help,
#expression-preview-tabs-history,
#expression-preview-tabs-starred {
padding: @padding_tight;
overflow: hidden;
}
padding: @padding_tight;
overflow: hidden;
}
#expression-preview-tabs-preview > div,
#expression-preview-tabs-help > div,
#expression-preview-tabs-history > div,
#expression-preview-tabs-starred {
height: 200px;
overflow: auto;
}
height: 200px;
overflow: auto;
}
#expression-preview-tabs-preview td, #expression-preview-tabs-preview th,
#expression-preview-tabs-help td, #expression-preview-tabs-help th,
#expression-preview-tabs-history td, #expression-preview-tabs-history th,
#expression-preview-tabs-starred td, #expression-preview-tabs-starred th {
padding: @padding_tight;
}
padding: @padding_tight;
}
.expression-preview-table-wrapper {
padding: @padding_normal;
}
padding: @padding_normal;
}
.expression-preview-container td {
padding: 2px 5px;
border-top: 1px solid #ccc;
}
padding: 2px 5px;
border-top: 1px solid #ccc;
}
td.expression-preview-heading {
border-top: none;
background: #ddd;
font-weight: bold;
}
border-top: none;
background: #ddd;
font-weight: bold;
}
td.expression-preview-value {
max-width: 250px !important;
overflow-x: hidden;
}
max-width: 250px !important;
overflow-x: hidden;
}
.expression-preview-special-value {
color: #aaa;
}
color: #aaa;
}
.expression-preview-help-container h3 {
margin-top: @padding_looser;
margin-bottom: @padding_normal;
border-bottom: 1px solid @light_grey;
}
margin-top: @padding_looser;
margin-bottom: @padding_normal;
border-bottom: 1px solid @light_grey;
}
.expression-preview-doc-item-title {
font-weight: bold;
text-align: right;
}
font-weight: bold;
text-align: right;
}
.expression-preview-doc-item-params {
}
}
.expression-preview-doc-item-returns {
}
}
.expression-preview-doc-item-desc {
color: #666;
}
color: #666;
}

View File

@ -34,46 +34,46 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@import-less url("../theme.less");
.scatterplot-dialog-selectors-container {
}
}
.scatterplot-dialog-selectors-container .buttonset {
margin-right: 1em;
}
margin-right: 1em;
}
.scatterplot-dialog-table-container {
margin: 2px 0em;
height: 500px;
overflow: auto;
border: 1px solid #aaa;
}
margin: 2px 0em;
height: 500px;
overflow: auto;
border: 1px solid #aaa;
}
table.scatterplot-matrix-table {
border-collapse: collapse;
}
border-collapse: collapse;
}
table.scatterplot-matrix-table > tbody > tr > td {
text-align: center;
vertical-align: middle;
}
text-align: center;
vertical-align: middle;
}
table.scatterplot-matrix-table td.current_column {
font-weight: bold;
font-size: 105%;
}
font-weight: bold;
font-size: 105%;
}
table.scatterplot-matrix-table div.current_column {
background-color: #fbede3;
}
background-color: #fbede3;
}
table.scatterplot-matrix-table .column_header {
text-align: right;
padding: 0em 0.5em;
}
text-align: right;
padding: 0em 0.5em;
}
table.scatterplot-matrix-table .scatterplot img {
border: 1px solid #eee;
}
border: 1px solid #eee;
}
table.scatterplot-matrix-table .scatterplot img.hover {
background-color: #eeffee;
}
background-color: #eeffee;
}

View File

@ -39,10 +39,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
padding: 0;
overflow: hidden;
visibility: hidden;
}
}
#left-panel {
}
}
#left-panel-body {
margin-left: @padding_tight;
@ -55,18 +55,18 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
padding: 0;
padding-top: @padding_looser;
font-size: 1.3em;
}
}
#action-area-tabs > li {
display: block;
padding-top: @padding_tight;
padding-bottom: @padding_tight;
padding-left: @padding_normal;
cursor: pointer;
}
}
#action-area-tabs > li.selected {
background: @chrome_primary;
.rounded_corners_left();
}
}
#project-links {
font-size: 1.3em;
@ -114,4 +114,4 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
left: 0;
width: 100%;
height: 100%;
}
}

View File

@ -48,7 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
}
#create-project-ui-source-selection-message > h3 {
margin-bottom: @padding_normal;
}
}
#create-project-ui-source-selection-layout {
width: 100%;
@ -95,4 +95,4 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
width: 100%;
height: 100%;
visibility: hidden;
}
}

View File

@ -36,24 +36,24 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#default-importing-progress-panel {
font-size: 1.3em;
padding: @padding_loose;
}
}
#default-importing-progress-bar-frame {
border: 1px solid @chrome_primary;
padding: @padding_tighter;
width: 300px;
}
}
#default-importing-progress-bar-body {
background: @chrome_primary;
height: 1em;
position: relative;
width: 30%;
}
}
#default-importing-progress-bar-body.indefinite {
background: #eee;
width: 100%;
}
}
#default-importing-iframe {
position: fixed;
@ -61,23 +61,23 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
height: 200px;
left: -300px;
top: -300px;
}
}
#default-importing-error-panel {
font-size: 1.3em;
padding: @padding_loose;
}
}
#default-importing-error-message {
}
}
#default-importing-error-stack {
font-family: monospace;
whitespace: pre;
padding: @padding_normal;
border: 1px solid @chrome_primary;
}
}
.default-importing-wizard-header {
font-size: 1.3em;
background: @chrome_primary;
padding: @padding_tight;
}
}

View File

@ -38,13 +38,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
position: absolute;
background: @chrome_secondary;
padding: @padding_looser;
}
}
.default-importing-file-selection-file-panel {
font-size: 1.3em;
position: absolute;
background: white;
overflow: auto;
}
}
.default-importing-file-selection-file-panel > table {
border-collapse: collapse;
width: 100%;
@ -52,22 +52,22 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.default-importing-file-selection-file-panel > table > tbody > tr > td,
.default-importing-file-selection-file-panel > table > tbody > tr > th {
padding: @padding_tight @padding_normal;
}
}
.default-importing-file-selection-file-panel > table > tbody > tr > th {
text-align: left;
background: @faint_grey;
}
}
.default-importing-file-selection-file-panel > table > tbody > tr.odd {
background: @fainter_grey;
}
}
.default-importing-file-selection-control-panel h2 {
font-size: 110%;
margin-top: 3em;
margin-bottom: 0.75em;
}
}
.default-importing-file-selection-file-panel > table > tbody > tr >
td.default-importing-file-selection-filename.highlighted {
td.default-importing-file-selection-filename.highlighted {
background: #fffee0;
}
}

View File

@ -37,7 +37,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
font-size: 1.1em;
position: absolute;
overflow: auto;
}
}
.default-importing-progress-data-panel {
position: absolute;
@ -46,7 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
padding: 3em;
background: rgba(255, 255, 255, 0.7);
text-align: center;
}
}
.default-importing-parsing-control-panel {
font-size: 1.3em;
@ -54,39 +54,39 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
overflow: auto;
border-top: 5px solid @chrome_primary;
background: @chrome_secondary;
}
}
.default-importing-parsing-control-panel > table {
width: 100%;
border-collapse: collapse;
}
}
td.default-importing-parsing-control-panel-formats {
padding: @padding_looser 0;
width: 250px;
}
}
.default-importing-parsing-control-panel-formats-message {
margin-left: @padding_looser;
margin-bottom: @padding_looser;
padding: 0 @padding_normal;
font-size: 1.3em;
}
}
.default-importing-parsing-control-panel-format {
margin-left: @padding_looser;
padding: @padding_tight @padding_normal;
.rounded_corners_left();
color: @link_primary;
cursor: pointer;
}
}
.default-importing-parsing-control-panel-format.selected {
background: white;
font-weight: bold;
color: black;
}
}
td.default-importing-parsing-control-panel-options-panel {
background: white;
padding: @padding_looser;
.rounded_corners_left();
}
}

View File

@ -35,9 +35,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.default-importing-web-url {
width: 60em;
}
}
#default-importing-clipboard-textarea {
width: 50em;
height: 30em;
}
}

View File

@ -37,29 +37,29 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
position: relative;
font-family: monospace;
font-size: 150%;
}
}
table.data-table.fixed-width-preview-data-table {
font-size: inherit;
}
}
table.data-table.fixed-width-preview-data-table > tbody > tr {
border-bottom: 1px solid #ccc;
}
}
table.data-table.fixed-width-preview-data-table > tbody > tr > td.column-header {
background: none;
}
}
table.data-table.fixed-width-preview-data-table > tbody > tr > td,
table.data-table.fixed-width-preview-data-table > tbody > tr > td.column-header {
border: none;
padding: 2px 0px;
white-space: pre;
}
}
table.data-table.fixed-width-preview-data-table > tbody > tr > td.even,
table.data-table.fixed-width-preview-data-table > tbody > tr > td.column-header.even {
background: #eee;
}
}
.fixed-width-preview-column-separator-outer {
position: absolute;
@ -70,14 +70,14 @@ table.data-table.fixed-width-preview-data-table > tbody > tr > td.column-header.
padding: 0px 3px;
cursor: ew-resize;
overflow: visible;
}
}
.fixed-width-preview-column-separator-inner {
position: relative;
height: 100%;
width: 1px;
background: red;
overflow: visible;
}
}
.fixed-width-preview-column-separator-inner > div {
position: absolute;
top: 50px;
@ -87,4 +87,4 @@ table.data-table.fixed-width-preview-data-table > tbody > tr > td.column-header.
width: 13px;
height: 13px;
cursor: pointer;
}
}

View File

@ -36,4 +36,4 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#project-upload-form {
padding: @padding_loose;
font-size: 1.3em;
}
}

View File

@ -38,45 +38,45 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
font-size: 130%;
color: #666;
padding: 20px;
}
}
.json-parser-ui-select-dom {
padding: 20px;
font-family: monospace;
font-size: 130%;
}
}
.json-parser-ui-select-dom .node {
cursor: pointer;
padding: 2px;
border: 1px solid rgba(0,0,0,0);
}
}
.json-parser-ui-select-dom .indented {
margin-left: 2em;
}
}
.json-parser-ui-select-dom .field-name {
font-weight: bold;
}
}
.json-parser-ui-select-dom .delimiter {
color: blue;
}
}
.json-parser-ui-select-dom .punctuation {
color: #aaa;
}
}
.json-parser-ui-select-dom .literal {
color: #888;
}
}
.json-parser-ui-select-dom .children {
margin-left: 20px;
}
}
.json-parser-ui-select-dom .node.highlight {
background: #fffee0;
border: 1px dashed red;
}
}

View File

@ -38,29 +38,29 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
font-size: 150%;
color: #666;
padding: 20px;
}
}
.xml-parser-ui-select-dom {
padding: 20px;
font-family: monospace;
font-size: 150%;
}
}
.xml-parser-ui-select-dom .elmt {
cursor: pointer;
padding: 2px;
border: 1px solid rgba(0,0,0,0);
}
}
.xml-parser-ui-select-dom .text {
color: #888;
}
}
.xml-parser-ui-select-dom .children {
margin-left: 20px;
}
}
.xml-parser-ui-select-dom .elmt.highlight {
background: #fffee0;
border: 1px dashed red;
}
}

View File

@ -58,15 +58,15 @@ li.facet-container {
}
a.facet-title-remove {
display: block;
width: 12px;
height: 12px;
margin: 2px 0 0 0;
text-decoration: none;
background-image: url(../../images/close-map.png);
background-repeat: no-repeat;
background-position: 0px 0px;
}
display: block;
width: 12px;
height: 12px;
margin: 2px 0 0 0;
text-decoration: none;
background-image: url(../../images/close-map.png);
background-repeat: no-repeat;
background-position: 0px 0px;
}
a.facet-title-remove:hover {
background-position: -12px 0px;
@ -142,26 +142,26 @@ a.facet-title-remove:hover {
}
.facet-choice {
padding: 2px 5px;
clear: both;
}
padding: 2px 5px;
clear: both;
}
.facet-choice:hover {
background: @fill_secondary;
}
}
.facet-choice-selected .facet-choice-label {
font-weight: bold;
color: #ff6a00;
}
font-weight: bold;
color: #ff6a00;
}
.facet-mode-inverted .facet-choice-selected .facet-choice-label {
text-decoration: line-through;
color: black;
}
text-decoration: line-through;
color: black;
}
.facet-choice-link.facet-mode-inverted {
text-decoration: line-through;
color: black;
}
text-decoration: line-through;
color: black;
}
.facet-choice-count, .facet-range-choice-count {
padding-left: 5px;
@ -178,15 +178,15 @@ a.facet-choice-link {
}
img.facet-choice-link {
text-align: baseline;
cursor: pointer;
margin-left: 2px;
float: right;
}
text-align: baseline;
cursor: pointer;
margin-left: 2px;
float: right;
}
.facet-range-body {
padding: 5px;
}
padding: 5px;
}
.facet-range-message {
color: @metadata_grey;
@ -222,122 +222,120 @@ img.facet-choice-link {
.facet-text-body {
padding: 5px;
}
padding: 5px;
}
.facet-scatterplot-plot-container {
margin: 5px 0px 5px 5px;
border: 1px solid #bbb;
}
margin: 5px 0px 5px 5px;
border: 1px solid #bbb;
}
.facet-scatterplot-plot {
position: relative;
}
position: relative;
}
.facet-scatterplot-image {
position: absolute;
}
position: absolute;
}
.facet-scatterplot-body td {
vertical-align: middle;
}
vertical-align: middle;
}
.facet-scatterplot-selectors-container .scatterplot-selectors {
text-align: center;
}
text-align: center;
}
.facet-scatterplot-selectors-container .scatterplot-export-plot {
font-size: 95%;
margin-top: 3em;
}
font-size: 95%;
margin-top: 3em;
}
.facet-scatterplot-selectors-container .scatterplot-selectors .buttonset {
margin: 0.8em 0em;
}
margin: 0.8em 0em;
}
.scatterplot-selectors .ui-button-text-only .ui-button-text {
font-size: 90%;
padding: 0.0em 0.4em 0.1em 0.3em;
}
font-size: 90%;
padding: 0.0em 0.4em 0.1em 0.3em;
}
.scatterplot-selectors .buttonset {
margin: 0px;
}
margin: 0px;
}
.scatterplot-selectors .buttonset .ui-corner-top {
-moz-border-radius-topleft: 0.5em;
-webkit-border-top-left-radius: 0.5em;
border-top-left-radius: 0.5em;
-moz-border-radius-topright: 0.5em;
-webkit-border-top-right-radius: 0.5em;
border-top-right-radius: 0.5em;
}
-moz-border-radius-topleft: 0.5em;
-webkit-border-top-left-radius: 0.5em;
border-top-left-radius: 0.5em;
-moz-border-radius-topright: 0.5em;
-webkit-border-top-right-radius: 0.5em;
border-top-right-radius: 0.5em;
}
.scatterplot-selectors .buttonset .ui-corner-bottom {
-moz-border-radius-bottomleft: 0.5em;
-webkit-border-bottom-left-radius: 0.5em;
border-bottom-left-radius: 0.5em;
-moz-border-radius-bottomright: 0.5em;
-webkit-border-bottom-right-radius: 0.5em;
border-bottom-right-radius: 0.5em;
}
-moz-border-radius-bottomleft: 0.5em;
-webkit-border-bottom-left-radius: 0.5em;
border-bottom-left-radius: 0.5em;
-moz-border-radius-bottomright: 0.5em;
-webkit-border-bottom-right-radius: 0.5em;
border-bottom-right-radius: 0.5em;
}
.scatterplot-selectors .buttonset .ui-corner-right {
-moz-border-radius-topright: 0.5em;
-webkit-border-top-right-radius: 0.5em;
border-top-right-radius: 0.5em;
-moz-border-radius-bottomright: 0.5em;
-webkit-border-bottom-right-radius: 0.5em;
border-bottom-right-radius: 0.5em;
}
-moz-border-radius-topright: 0.5em;
-webkit-border-top-right-radius: 0.5em;
border-top-right-radius: 0.5em;
-moz-border-radius-bottomright: 0.5em;
-webkit-border-bottom-right-radius: 0.5em;
border-bottom-right-radius: 0.5em;
}
.scatterplot-selectors .buttonset .ui-corner-left {
-moz-border-radius-topleft: 0.5em;
-webkit-border-top-left-radius: 0.5em;
border-top-left-radius: 0.5em;
-moz-border-radius-bottomleft: 0.5em;
-webkit-border-bottom-left-radius: 0.5em;
border-bottom-left-radius: 0.5em;
}
-moz-border-radius-topleft: 0.5em;
-webkit-border-top-left-radius: 0.5em;
border-top-left-radius: 0.5em;
-moz-border-radius-bottomleft: 0.5em;
-webkit-border-bottom-left-radius: 0.5em;
border-bottom-left-radius: 0.5em;
}
.scatterplot-selectors .scatterplot-dim-selector label {
width: 32px;
height: 16px;
}
width: 32px;
height: 16px;
}
.scatterplot-selectors .scatterplot-rot-selector label {
width: 22px;
height: 18px;
background-image: url("../../images/scatterplot-icons.png");
}
width: 22px;
height: 18px;
background-image: url("../../images/scatterplot-icons.png");
}
.scatterplot-selectors .scatterplot-rot-selector label.rot-ccw-label {
background-position: -5px -5px;
}
background-position: -5px -5px;
}
.scatterplot-selectors .scatterplot-rot-selector label.rot-none-label {
background-position: -28px -4px;
}
background-position: -28px -4px;
}
.scatterplot-selectors .scatterplot-rot-selector label.rot-cw-label {
background-position: -48px -3px;
}
background-position: -48px -3px;
}
.scatterplot-selectors .scatterplot-dot-selector label {
width: 22px;
height: 18px;
background-image: url("../../images/scatterplot-icons.png");
}
width: 22px;
height: 18px;
background-image: url("../../images/scatterplot-icons.png");
}
.scatterplot-selectors .scatterplot-dot-selector label.dot-small-label {
background-position: -5px -25px;
}
background-position: -5px -25px;
}
.scatterplot-selectors .scatterplot-dot-selector label.dot-regular-label {
background-position: -27px -25px;
}
background-position: -27px -25px;
}
.scatterplot-selectors .scatterplot-dot-selector label.dot-big-label {
background-position: -48px -25px;
}
background-position: -48px -25px;
}

View File

@ -34,30 +34,29 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@import-less url("../theme.less");
#process-panel {
position: fixed;
top: 0px;
z-index: 1000;
background: #DBE8EB;
border: 1px solid #aaa;
border-top: none;
-moz-border-radius-bottomleft: 10px;
-webkit-border-bottom-left-radius: 10px;
-moz-border-radius-bottomright: 10px;
-webkit-border-bottom-right-radius: 10px;
}
position: fixed;
top: 0px;
z-index: 1000;
background: #DBE8EB;
border: 1px solid #aaa;
border-top: none;
-moz-border-radius-bottomleft: 10px;
-webkit-border-bottom-left-radius: 10px;
-moz-border-radius-bottomright: 10px;
-webkit-border-bottom-right-radius: 10px;
}
.process-panel-inner {
padding-bottom: 10px;
}
padding-bottom: 10px;
}
.process-panel-head {
padding: 2px 10px;
border-bottom: 1px solid #ccc;
}
padding: 2px 10px;
border-bottom: 1px solid #ccc;
}
.process-panel-body {
max-height: 70px;
overflow: auto;
padding: 10px;
}
max-height: 70px;
overflow: auto;
padding: 10px;
}

View File

@ -35,10 +35,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
background: -webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#e3e3e3));
background: -moz-linear-gradient(top, #f9f9f9, #e3e3e3);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f9f9f9', endColorstr='#e3e3e3');
}
}
.button:active, a.button:active {
background: -webkit-gradient(linear, left top, left bottom, from(#e3e3e3), to(#f9f9f9));
background: -moz-linear-gradient(top, #e3e3e3, #f9f9f9);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#e3e3e3', endColorstr='#f9f9f9');
}
}

View File

@ -34,46 +34,46 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@import-less url("../theme.less");
.recon-dialog-service-list {
border: 1px solid #aaa;
padding: 1px;
overflow: auto;
width: 200px;
height: 500px;
}
border: 1px solid #aaa;
padding: 1px;
overflow: auto;
width: 200px;
height: 500px;
}
a.recon-dialog-service-selector {
display: block;
padding: 10px;
text-decoration: none;
color: black;
}
display: block;
padding: 10px;
text-decoration: none;
color: black;
}
a.recon-dialog-service-selector:hover {
background: #eee;
}
background: #eee;
}
a.recon-dialog-service-selector.selected {
background: #eee;
font-weight: bold;
}
background: #eee;
font-weight: bold;
}
.recon-dialog-service-panel-message {
text-align: center;
font-size: 200%;
padding: 50px 0;
color: #aaa;
}
text-align: center;
font-size: 200%;
padding: 50px 0;
color: #aaa;
}
a.recon-dialog-service-selector-remove {
float: right;
position: relative;
top: -5px;
left: 5px;
width: 12px;
height: 12px;
text-decoration: none;
background-image: url(../../images/close-map.png);
background-repeat: no-repeat;
background-position: 0px 0px;
}
float: right;
position: relative;
top: -5px;
left: 5px;
width: 12px;
height: 12px;
text-decoration: none;
background-image: url(../../images/close-map.png);
background-repeat: no-repeat;
background-position: 0px 0px;
}
a.recon-dialog-service-selector-remove:hover {
background-position: -12px 0px;
}
background-position: -12px 0px;
}

View File

@ -34,21 +34,21 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@import-less url("../theme.less");
.recon-dialog-standard-service-panel-message {
text-align: center;
font-size: 150%;
padding: 20px 0;
color: #aaa;
}
text-align: center;
font-size: 150%;
padding: 20px 0;
color: #aaa;
}
.recon-dialog-standard-service-panel .type-id {
color: #888;
}
color: #888;
}
.recon-dialog-standard-service-panel .type-container,
.recon-dialog-standard-service-panel .detail-container {
border: 1px solid #ccc;
padding: 10px;
max-height: 300px;
height: 300px !important;
overflow: auto;
}
border: 1px solid #ccc;
padding: 10px;
max-height: 300px;
height: 300px !important;
overflow: auto;
}

View File

@ -34,5 +34,5 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@import-less url("../theme.less");
.fbs-pane-property, .fbs-pane-type {
width: 400px;
}
width: 400px;
}

View File

@ -34,10 +34,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@import-less url("../theme.less");
.slider-widget {
position: relative;
overflow: visible;
margin: 5px;
}
position: relative;
overflow: visible;
margin: 5px;
}
.slider-widget-tint {
position: absolute;
@ -49,42 +49,42 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
}
.slider-widget-tint.left {
left: 0;
}
left: 0;
}
.slider-widget-tint.right {
right: 0;
}
right: 0;
}
.slider-widget-highlight {
position: absolute;
padding: 0;
border: 1px solid #000;
top: -2px;
height: 100%;
cursor: move;
}
position: absolute;
padding: 0;
border: 1px solid #000;
top: -2px;
height: 100%;
cursor: move;
}
.slider-widget-bracket {
position: absolute;
top: 0;
width: 12px;
height: 100%;
}
position: absolute;
top: 0;
width: 12px;
height: 100%;
}
.slider-widget-bracket.left {
background: url(../../images/slider-handle.png) no-repeat center right;
margin-left: -8px;
cursor: e-resize;
}
background: url(../../images/slider-handle.png) no-repeat center right;
margin-left: -8px;
cursor: e-resize;
}
.slider-widget-bracket.right {
background: url(../../images/slider-handle.png) no-repeat center left;
margin-left: -4px;
cursor: w-resize;
}
background: url(../../images/slider-handle.png) no-repeat center left;
margin-left: -4px;
cursor: w-resize;
}
.slider-widget-overlay {
position: fixed;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
background: white;
opacity: 0.01;
}
position: fixed;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
background: white;
opacity: 0.01;
}