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); $.post( "/command/export-rows", { project: theProject.id, format : "tripleloader" }, function(data) { body.html( '
' + data + '
' + '
' + '
Describe the data you\'re about to load ¬
' + '' + '
' ); self._level = DialogSystem.showDialog(frame); } ); var left_footer = footer.find(".left"); var cancel_button = $('').text("Cancel").click(function() { self._dismiss(); }).appendTo(left_footer); var center_footer = footer.find(".center"); var authorization = $('
').addClass("freebase-loading-authorization").hide().appendTo(center_footer); var right_footer = footer.find(".right"); var selector = $('').addClass("freebase-loading-graph-selector").html("Load this data into " + '' + '' ).buttonset().appendTo(right_footer); var load_button = $('').text("Sign In").appendTo(right_footer); this._elmts = DOM.bind(frame); var provider = "www.freebase.com"; var check_authorization = function() { $.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); }); load_button.text("Load").unbind().click(function() { self._load(self); }); } else { authorization.html("").hide(); load_button.text("Sign In").removeAttr("disabled").unbind().click(function() { Sign.signin(check_authorization,provider); }); } },"json"); }; check_authorization(); this._elmts.sandbox.click(function() { //check_authorization(); }); this._elmts.freebase.click(function() { if (!confirm("Are you sure your data is clean enough to enter Freebase?")) { self._elmts.sandbox.attr("checked","checked"); self._elmts.freebase.removeAttr("checked"); selector.find("input").button('refresh'); } //check_authorization(); }); }; FreebaseLoadingDialog.prototype._load = function(self) { $.post("/command/upload-data", { project: theProject.id, "graph" : ($("#freebase-loading-graph-selector-freebase").attr("checked")) ? "otg" : "sandbox", "info" : $("#freebase-loading-tripleloader-info textarea").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!

' + JSON.stringify(data,null,2) + '
'); } $("button#freebase-loading-load").text("Close").unbind().click(function() { self._dismiss(); }); $("button#freebase-loading-cancel").hide(); }, "json" ); } FreebaseLoadingDialog.prototype._dismiss = function() { DialogSystem.dismissUntil(this._level - 1); };