mirror of
https://github.com/flynx/pWiki.git
synced 2025-11-01 11:30:08 +00:00
import/export of data working (needs polish)...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
3ca6a48d4f
commit
65c398969c
@ -2937,6 +2937,9 @@ for(var i=0; i<PAGES; i++){
|
|||||||
|
|
||||||
var Config =
|
var Config =
|
||||||
module.Config = {
|
module.Config = {
|
||||||
|
Import: {
|
||||||
|
text: '<input type="file" onchange="importData()" accept=".json, .pwiki">'
|
||||||
|
},
|
||||||
// XXX need an import button...
|
// XXX need an import button...
|
||||||
Export: {
|
Export: {
|
||||||
text: '<button onclick="exportData()">Export</button>' },
|
text: '<button onclick="exportData()">Export</button>' },
|
||||||
|
|||||||
14
pwiki2.html
14
pwiki2.html
@ -545,7 +545,17 @@ require(['./browser'], function(browser){
|
|||||||
// Export/Import...
|
// Export/Import...
|
||||||
|
|
||||||
// XXX
|
// XXX
|
||||||
var importData = function(){}
|
var importData = function(evt){
|
||||||
|
var files = event.target.files
|
||||||
|
var reader = new FileReader()
|
||||||
|
reader.addEventListener('load', function(evt){
|
||||||
|
var json = JSON.parse(evt.target.result)
|
||||||
|
console.log('LOADING JSON:', json)
|
||||||
|
pwiki.store
|
||||||
|
.load(json)
|
||||||
|
.then(function(){
|
||||||
|
location.reload() }) })
|
||||||
|
reader.readAsText(files[0]) }
|
||||||
|
|
||||||
// XXX
|
// XXX
|
||||||
var exportData = async function(options={}){
|
var exportData = async function(options={}){
|
||||||
@ -561,7 +571,7 @@ var exportData = async function(options={}){
|
|||||||
var blobURL = a.href = URL.createObjectURL(blob)
|
var blobURL = a.href = URL.createObjectURL(blob)
|
||||||
a.download = filename
|
a.download = filename
|
||||||
?? options.filename
|
?? options.filename
|
||||||
?? (Date.timeStamp() +'.pWiki.json')
|
?? (Date.timeStamp() +'.pWiki-export.pwiki')
|
||||||
|
|
||||||
//document.body.appendChild(a)
|
//document.body.appendChild(a)
|
||||||
a.dispatchEvent(new MouseEvent("click"))
|
a.dispatchEvent(new MouseEvent("click"))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user