function FreebaseLoadingDialog() { this._createDialog(); this._signedin = false; } FreebaseLoadingDialog.prototype._createDialog = function() { var self = this; var dialog = $(DOM.loadHTML("core", "scripts/dialogs/freebase-loading-dialog.html")); this._elmts = DOM.bind(dialog); this._elmts.cancelButton.click(function() { self._dismiss(); }); this._elmts.selector.buttonset(); var provider = "www.freebase.com"; var authorization = this._elmts.authorization; var loadButton = this._elmts.loadButton; var check_authorization = function(cont) { $.get("/command/core/check-authorization/" + provider, function(data) { if ("status" in data && data.code == "/api/status/ok") { authorization.html('Signed in as: ' + data.username + ' | Sign Out').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('Sign into Freebase to enable loading').show(); DOM.bind(authorization).signin.click(function() { Sign.signin(function() { check_authorization(cont); },provider); }); } },"json"); }; var check_allowed = function(user_id, cont) { $.get("/command/core/user-badges/" + provider, { "user_id" : user_id }, function(data) { if ("status" in data && data.code == "/api/status/ok") { var badges = data.result['!/type/usergroup/member']; var allowed = false; for (var i = 0; i < badges.length; i++) { var id = badges[i].id; if (id == "/en/metaweb_staff") { allowed = true; break; } } if (typeof cont == "function") cont(allowed); } else { self._show_error("Error checking if user is a staff member", data); } }, "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/core/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/core/preview-protograph?" + $.param({ project: theProject.id }), { protograph: JSON.stringify(theProject.overlayModels.freebaseProtograph || {}), engine: JSON.stringify(ui.browsingEngine.getJSON()) }, function(data) { var body = self._elmts.dialogBody; if ("tripleloader" in data) { body.html( '
Name this data load ¬ required ' +
' | ' +
'Source ID ¬ optional ' +
' | ' +
'
Are you sure this data is ready to be uploaded into Freebase? |