Line 104:
Line 104:
var ifel = document.getElementsByClassName('pduimark');
var ifel = document.getElementsByClassName('pduimark');
while( ifel[0] ) {
while( ifel[0] ) {
−
ifel[0].parentNode.removeChild(ifel[0]);
+
ifel[0].parentNode.removeChild(ifel[0]);
};
};
};
};
Line 110:
Line 110:
function notify_porting() {
function notify_porting() {
−
var button_import = new OO.ui.ButtonWidget( { label: "Import local personal data from file", classes: [ 'pduimark' ] } ),
+
var button_import = new OO.ui.ButtonWidget( { label: "Import Personal Data", classes: [ 'pduimark' ] } ),
−
button_export = new OO.ui.ButtonWidget( { label: "Export local personal data to file ", classes: [ 'pduimark' ] } );
+
button_export = new OO.ui.ButtonWidget( { label: "Export Personal Data", classes: [ 'pduimark' ] } );
+
button_import.on( 'click', function () {
−
mw.notify( $( button_import.$element , button_export.$element ) );
+
}
+
+
button_export.on( 'click', function () {
+
+
var get_record = indexedDBobject.EnqueuePDIO('update record');
+
+
get_record.then( function(result) {
+
var filename_tosaveas = "pdiolocalexport_" + result.name.user + "_" + Date.now();
+
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();
+
+
}
+
+
}
+
+
mw.notify( $( button_import.$element + '<br>' + button_export.$element ) );