function FreebaseLoadingDialog() { this._createDialog(); } FreebaseLoadingDialog.prototype._createDialog = function() { var self = this; var frame = DialogSystem.createDialog(); frame.width("800px"); var header = $('
').addClass("dialog-header").text('Load Data into Freebase').appendTo(frame); var body = $('
').addClass("dialog-body").appendTo(frame); var footer = $( '' ).appendTo(frame); this._elmts = DOM.bind(frame); var left_footer = this._elmts.left; var center_footer = this._elmts.center; var right_footer = this._elmts.right; var cancel_button = $('').text("Cancel").click(function() { self._dismiss(); }).appendTo(left_footer); var authorization = $('
').addClass("freebase-loading-authorization").hide().appendTo(center_footer); var selector = $('').addClass("freebase-loading-graph-selector").html("Load this data into " + '' + '' ).buttonset().appendTo(right_footer); var load_button = $('').text("Load").appendTo(right_footer); var provider = "www.freebase.com"; var check_authorization = function(autoload) { $.get("/command/check-authorization/" + provider, function(data) { if ("status" in data && data.status == "200 OK") { authorization.html('Signed in as: ' + data.username + ' | Sign Out').show(); DOM.bind(authorization).signout.click(function() { Sign.signout(check_authorization,provider); }); if (autoload) { self._load(); } else { load_button.unbind().click(function() { self._load(); }); } } else { authorization.html("").hide(); load_button.unbind().click(function() { Sign.signin(function() { check_authorization(true); },provider); }); } },"json"); }; $.post( "/command/export-rows", { project: theProject.id, format : "tripleloader" }, function(data) { if (data == null || data == "") { body.html( '
'+ '

This dataset has no triples

' + '

Have you aligned it with the Freebase schemas yet?

' + '
' ); left_footer.hide(); center_footer.hide(); selector.hide(); load_button.text("Close").unbind().click(function() { self._dismiss(); }); } else { body.html( '
' + data + '
' + '
' + '
Describe the data you\'re about to load ¬
' + '' + '
' ); self._elmts = DOM.bind(frame); check_authorization(false); } self._level = DialogSystem.showDialog(frame); } ); }; FreebaseLoadingDialog.prototype._load = function() { var self = this; var freebase = self._elmts.freebase.attr("checked"); if (!freebase || (freebase && confirm("Are you sure this data is clean enough to enter Freebase?"))) { $.post("/command/upload-data", { project: theProject.id, "graph" : (freebase) ? "otg" : "sandbox", "info" : self._elmts.info.val() }, function(data) { var body = $(".dialog-body"); if ("status" in data && data.status == "200 OK") { body.html( '
' + '

Data successfully loaded

' + '

' + data.message + '

' + '
' ); } else { body.html( '
' + '

Error loading data

' + '

' + data.message + '

' + '
' + data.stack.replace(/\\n/g,'\n').replace(/\\t/g,'\t') + '

' + '
' ); } self._elmts.load.text("Close").unbind().click(function() { self._dismiss(); }); self._elmts.cancel.hide(); self._elmts.authorization.hide(); self._elmts.selector.hide(); }, "json" ); } } FreebaseLoadingDialog.prototype._dismiss = function() { DialogSystem.dismissUntil(this._level - 1); };