Line 37:
Line 37:
// Get concerns relation :: Parts of this must be moved upstream, MAIN should know that this is the data the renderer will need and provide it
// Get concerns relation :: Parts of this must be moved upstream, MAIN should know that this is the data the renderer will need and provide it
−
var concern_origin = WikibaseProcessor.checkentity( { this_concerns: [ WBEStructure['concernsRelation'], WBEStructure['IDPropLoc'], WBEStructure['IDName'] ] } )['this_concerns'][0];
+
var concern_origin = WikibaseProcessor.checkentity( { this_concerns: [ WBEStructure['concernsRelation'], WBEStructure['IDPropLoc'], WBEStructure['qIDPropName'] ] } )['this_concerns'][0];
// Get defval for entity :: Parts of this must be moved upstream, MAIN should know that this is the data the renderer will need and provide it
// Get defval for entity :: Parts of this must be moved upstream, MAIN should know that this is the data the renderer will need and provide it
Line 112:
Line 112:
mw.loader.using( 'oojs-ui-core' ).done( function () {
mw.loader.using( 'oojs-ui-core' ).done( function () {
−
var button_import = new OO.ui.SelectFileWidget ( {
+
var button_import = new OO.ui.SelectFileWidget( { label: "Import Personal Data", classes: [ 'pduimark' ] } ),
−
label: "Import Personal Data",
−
classes: [ 'pduimark' ]
−
}),
button_export = new OO.ui.ButtonWidget( { label: "Export Personal Data", classes: [ 'pduimark' ] } );
button_export = new OO.ui.ButtonWidget( { label: "Export Personal Data", classes: [ 'pduimark' ] } );
−
button_import.on( 'click', function () {
+
button_import.on( 'change', function () {
−
if (window.webkitURL != null) {
if (window.webkitURL != null) {
−
window.alert("loading file on webkit")
+
console.log("loading file on webkit")
} else {
} else {
−
window.alert("loading file non webkit")
+
console.log("loading file non webkit")
}
}
−
−
});
});
Line 138:
Line 132:
get_record.then( function(result) {
get_record.then( function(result) {
console.log("happening");
console.log("happening");
−
if ( result === undefined ) { window.alert("No data to export") } else { console.log(result) };
+
if ( result === undefined ) { window.alert("No local data to export") } else {
+
+
var filename_tosaveas = "pdiolocalexport_" + result.name.user + "_" + Date.now() + '.json';
+
+
result.id = '';
+
result.name.user = '';
+
+
var export_to_text = JSON.stringify(result);
+
var textFileAsBlob = new Blob([export_to_text], {type:'text/plain'});
+
var downloadLink = document.createElement("a");
+
downloadLink.download = filename_tosaveas;
+
if (window.webkitURL != null)
+
{
+
// Chrome allows the link to be clicked
+
// without actually adding it to the DOM.
+
downloadLink.href = window.webkitURL.createObjectURL(textFileAsBlob);
+
}
+
else
+
{
+
// Firefox requires the link to be added to the DOM
+
// before it can be clicked.
+
downloadLink.href = window.URL.createObjectURL(textFileAsBlob);
+
downloadLink.style.display = "none";
+
document.body.appendChild(downloadLink);
+
}
+
+
downloadLink.click();
−
var filename_tosaveas = "pdiolocalexport_" + result.name.user + "_" + Date.now() + '.json';
−
−
result.id = '';
−
result.name.user = '';
−
−
var export_to_text = JSON.stringify(result);
−
var textFileAsBlob = new Blob([export_to_text], {type:'text/plain'});
−
var downloadLink = document.createElement("a");
−
downloadLink.download = filename_tosaveas;
−
if (window.webkitURL != null)
−
{
−
// Chrome allows the link to be clicked
−
// without actually adding it to the DOM.
−
downloadLink.href = window.webkitURL.createObjectURL(textFileAsBlob);
}
}
−
else
−
{
−
// Firefox requires the link to be added to the DOM
−
// before it can be clicked.
−
downloadLink.href = window.URL.createObjectURL(textFileAsBlob);
−
downloadLink.style.display = "none";
−
document.body.appendChild(downloadLink);
−
}
−
−
downloadLink.click();
});
});