2010-06-24 22:13:51 +02:00
|
|
|
var ReconciliationManager = {
|
|
|
|
"customServices" : [], // services registered by core and extensions
|
|
|
|
"standardServices" : [] // services registered by user
|
|
|
|
};
|
|
|
|
|
|
|
|
ReconciliationManager.getAllServices = function() {
|
|
|
|
return ReconciliationManager.customServices.concat(ReconciliationManager.standardServices);
|
|
|
|
};
|
|
|
|
|
|
|
|
ReconciliationManager.registerService = function(service) {
|
|
|
|
ReconciliationManager.customServices.push(service);
|
2010-06-26 03:10:23 +02:00
|
|
|
|
|
|
|
return ReconciliationManager.customServices.length - 1;
|
2010-06-24 22:13:51 +02:00
|
|
|
};
|
|
|
|
|
2010-06-26 03:10:23 +02:00
|
|
|
ReconciliationManager.registerStandardService = function(url, f) {
|
2010-06-24 22:13:51 +02:00
|
|
|
$.ajax({
|
|
|
|
async: false,
|
|
|
|
url: url + (url.contains("?") ? "&" : "?") + "callback=?",
|
|
|
|
success: function(data) {
|
|
|
|
data.url = url;
|
|
|
|
data.ui = { "handler" : "ReconStandardServicePanel" };
|
|
|
|
|
2010-06-26 03:10:23 +02:00
|
|
|
index = ReconciliationManager.customServices.length +
|
|
|
|
ReconciliationManager.standardServices.length;
|
|
|
|
|
2010-06-24 22:13:51 +02:00
|
|
|
ReconciliationManager.standardServices.push(data);
|
|
|
|
ReconciliationManager.save();
|
2010-06-26 03:10:23 +02:00
|
|
|
|
|
|
|
if (f) {
|
|
|
|
f(index);
|
|
|
|
}
|
2010-06-24 22:13:51 +02:00
|
|
|
},
|
|
|
|
dataType: "jsonp"
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
ReconciliationManager.save = function(f) {
|
|
|
|
$.ajax({
|
|
|
|
async: false,
|
|
|
|
type: "POST",
|
|
|
|
url: "/command/set-preference?" + $.param({
|
|
|
|
name: "standard-reconciliation-services"
|
|
|
|
}),
|
|
|
|
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/get-preference?" + $.param({
|
|
|
|
name: "standard-reconciliation-services"
|
|
|
|
}),
|
|
|
|
success: function(data) {
|
|
|
|
if (data.value && data.value != "null") {
|
|
|
|
ReconciliationManager.standardServices = JSON.parse(data.value);
|
|
|
|
} else {
|
|
|
|
ReconciliationManager.registerStandardService(
|
2010-06-26 03:10:23 +02:00
|
|
|
"http://standard-reconcile.dfhuynh.user.dev.freebaseapps.com/reconcile");
|
2010-06-24 22:13:51 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
dataType: "json"
|
|
|
|
});
|
|
|
|
})();
|