2018-01-08 21:14:13 +01:00
|
|
|
// Load the localization file
|
|
|
|
var dictionary = {};
|
|
|
|
$.ajax({
|
|
|
|
url : "command/core/load-language?",
|
|
|
|
type : "POST",
|
|
|
|
async : false,
|
|
|
|
data : {
|
|
|
|
module : "wikidata",
|
|
|
|
// lang : lang
|
|
|
|
},
|
|
|
|
success : function(data) {
|
2018-11-21 18:26:10 +01:00
|
|
|
dictionary = data['dictionary'];
|
|
|
|
lang = data['lang'];
|
2018-01-08 21:14:13 +01:00
|
|
|
}
|
|
|
|
});
|
2018-11-21 18:26:10 +01:00
|
|
|
$.i18n().load(dictionary, lang);
|
2018-01-08 21:14:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2017-09-05 23:49:17 +02:00
|
|
|
ExporterManager.MenuItems.push({});
|
2017-09-05 16:26:32 +02:00
|
|
|
ExporterManager.MenuItems.push(
|
2017-09-05 23:49:17 +02:00
|
|
|
{
|
2018-10-28 15:19:48 +01:00
|
|
|
id:"performWikibaseEdits",
|
2020-04-14 09:57:52 +02:00
|
|
|
label: $.i18n('wikidata-extension/wikidata-edits'),
|
2018-10-28 15:19:48 +01:00
|
|
|
click: function() { PerformEditsDialog.checkAndLaunch(); }
|
|
|
|
});
|
|
|
|
ExporterManager.MenuItems.push(
|
|
|
|
{
|
|
|
|
id:"exportQuickStatements",
|
2020-04-14 09:57:52 +02:00
|
|
|
label: $.i18n('wikidata-extension/qs-file'),
|
2018-10-28 15:19:48 +01:00
|
|
|
click: function() { WikibaseExporterMenuBar.checkSchemaAndExport("quickstatements"); }
|
|
|
|
});
|
|
|
|
ExporterManager.MenuItems.push(
|
|
|
|
{
|
|
|
|
id:"exportWikibaseSchema",
|
2020-03-23 11:14:02 +01:00
|
|
|
label: $.i18n('wikidata-extension/wikidata-schema'),
|
2018-10-28 15:19:48 +01:00
|
|
|
click: function() { WikibaseExporterMenuBar.checkSchemaAndExport("wikibase-schema"); }
|
2017-09-05 23:49:17 +02:00
|
|
|
}
|
2017-09-05 16:26:32 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
WikibaseExporterMenuBar = {};
|
|
|
|
|
|
|
|
WikibaseExporterMenuBar.exportTo = function(format) {
|
2018-10-28 15:19:48 +01:00
|
|
|
var targetUrl = null;
|
|
|
|
if (format ==="quickstatements") {
|
|
|
|
targetUrl = "statements.txt";
|
|
|
|
} else {
|
|
|
|
targetUrl = "schema.json";
|
|
|
|
}
|
2017-09-05 16:26:32 +02:00
|
|
|
var form = document.createElement("form");
|
|
|
|
$(form).css("display", "none")
|
|
|
|
.attr("method", "post")
|
2018-10-28 15:19:48 +01:00
|
|
|
.attr("action", "command/core/export-rows/"+targetUrl)
|
2019-07-23 11:31:17 +02:00
|
|
|
.attr("target", "gridworks-export-"+format);
|
2017-09-05 16:26:32 +02:00
|
|
|
$('<input />')
|
|
|
|
.attr("name", "engine")
|
2020-08-06 13:47:31 +02:00
|
|
|
.val(JSON.stringify(ui.browsingEngine.getJSON()))
|
2017-09-05 16:26:32 +02:00
|
|
|
.appendTo(form);
|
|
|
|
$('<input />')
|
|
|
|
.attr("name", "project")
|
2020-08-06 13:47:31 +02:00
|
|
|
.val(theProject.id)
|
2017-09-05 16:26:32 +02:00
|
|
|
.appendTo(form);
|
|
|
|
$('<input />')
|
|
|
|
.attr("name", "format")
|
2020-08-06 13:47:31 +02:00
|
|
|
.val(format)
|
2017-09-05 16:26:32 +02:00
|
|
|
.appendTo(form);
|
|
|
|
|
|
|
|
document.body.appendChild(form);
|
|
|
|
|
|
|
|
window.open("about:blank", "gridworks-export");
|
|
|
|
form.submit();
|
|
|
|
|
|
|
|
document.body.removeChild(form);
|
|
|
|
};
|
|
|
|
|
2018-10-28 15:19:48 +01:00
|
|
|
WikibaseExporterMenuBar.checkSchemaAndExport = function(format) {
|
2018-07-13 19:21:38 +02:00
|
|
|
var onSaved = function(callback) {
|
2018-10-28 15:19:48 +01:00
|
|
|
WikibaseExporterMenuBar.exportTo(format);
|
2018-07-13 19:21:38 +02:00
|
|
|
};
|
|
|
|
if (!SchemaAlignmentDialog.isSetUp()) {
|
|
|
|
SchemaAlignmentDialog.launch(null);
|
|
|
|
} else if (SchemaAlignmentDialog._hasUnsavedChanges) {
|
|
|
|
SchemaAlignmentDialog._save(onSaved);
|
|
|
|
} else {
|
|
|
|
onSaved();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-05 16:26:32 +02:00
|
|
|
//extend the column header menu
|
|
|
|
$(function(){
|
|
|
|
|
2017-09-05 23:49:17 +02:00
|
|
|
ExtensionBar.MenuItems.push(
|
|
|
|
{
|
|
|
|
"id":"reconcile",
|
2018-11-21 18:30:00 +01:00
|
|
|
"label": $.i18n('wikidata-extension/menu-label'),
|
2017-09-05 23:49:17 +02:00
|
|
|
"submenu" : [
|
|
|
|
{
|
2017-09-15 12:51:29 +02:00
|
|
|
id: "wikidata/edit-schema",
|
2018-11-21 18:30:00 +01:00
|
|
|
label: $.i18n('wikidata-extension/edit-wikidata-schema'),
|
2017-09-05 23:49:17 +02:00
|
|
|
click: function() { SchemaAlignmentDialog.launch(false); }
|
|
|
|
},
|
2018-11-01 19:30:24 +01:00
|
|
|
{
|
|
|
|
id:"wikidata/manage-account",
|
2018-11-21 18:30:00 +01:00
|
|
|
label: $.i18n('wikidata-extension/manage-wikidata-account'),
|
2018-11-01 19:30:24 +01:00
|
|
|
click: function() { ManageAccountDialog.checkAndLaunch(); }
|
|
|
|
},
|
|
|
|
{},
|
2018-11-01 16:01:08 +01:00
|
|
|
{
|
|
|
|
id: "wikidata/import-schema",
|
2018-11-21 18:30:00 +01:00
|
|
|
label: $.i18n('wikidata-extension/import-wikidata-schema'),
|
2018-11-01 16:01:08 +01:00
|
|
|
click: function() { ImportSchemaDialog.launch(); }
|
|
|
|
},
|
2018-11-01 19:30:24 +01:00
|
|
|
{
|
|
|
|
id:"wikidata/export-schema",
|
2018-11-21 18:30:00 +01:00
|
|
|
label: $.i18n('wikidata-extension/export-schema'),
|
2018-11-01 19:30:24 +01:00
|
|
|
click: function() { WikibaseExporterMenuBar.checkSchemaAndExport("wikibase-schema"); }
|
2017-09-15 12:51:29 +02:00
|
|
|
},
|
2018-10-28 15:19:48 +01:00
|
|
|
{},
|
2017-09-15 12:51:29 +02:00
|
|
|
{
|
|
|
|
id:"wikidata/perform-edits",
|
2018-11-21 18:30:00 +01:00
|
|
|
label: $.i18n('wikidata-extension/perform-edits-on-wikidata'),
|
2017-09-15 12:51:29 +02:00
|
|
|
click: function() { PerformEditsDialog.checkAndLaunch(); }
|
|
|
|
},
|
2017-09-05 23:49:17 +02:00
|
|
|
{
|
2017-09-15 12:51:29 +02:00
|
|
|
id:"wikidata/export-qs",
|
2018-11-21 18:30:00 +01:00
|
|
|
label: $.i18n('wikidata-extension/export-to-qs'),
|
2018-10-28 15:19:48 +01:00
|
|
|
click: function() { WikibaseExporterMenuBar.checkSchemaAndExport("quickstatements"); }
|
|
|
|
},
|
2017-09-15 12:51:29 +02:00
|
|
|
|
2017-09-05 23:49:17 +02:00
|
|
|
]
|
|
|
|
}
|
|
|
|
);
|
2017-09-05 16:26:32 +02:00
|
|
|
});
|
|
|
|
|