Commit 33b87cec authored by Tommy Chan's avatar Tommy Chan

prompt

parent 99d8becd
"use strict";
// Access File System
const fs = require('fs');
let file;
class File {
static fileSupport() {
......@@ -22,7 +25,6 @@ class File {
dialog.err(window.lang.empty_textarea_error, window.lang.error);
return null;
}
return data;
}
......@@ -38,25 +40,43 @@ class File {
fileName = file.name;
}
fileName = prompt(window.lang.enter_filename_error, fileName); // FIXME Doesn't work in nodejs
if (!fileName) return;
var dialog2 = require('art-dialog');
var d = dialog2({
title: window.lang.prompt_text,
content: '<input type=\'text\' id=\'promptfilename\' autofocus />',
okValue: window.lang.comfirm_text,
ok: function () {
fileName = document.getElementById('promptfilename').value;
if (!fileName) return;
fileName = fileName + '.xml';
let blob = new Blob([data], {
type: 'text/xml'
});
let blob = new Blob([data], {
type: 'text/xml'
});
fs.writeFile(fileName, blob, function(err) {
if (err) {
dialog.err(err, window.lang.error);
}
else {
dialog.info(window.lang.saved);
}
fs.writeFile(fileName, data, function(err) {
if (err) {
dialog.err(err, window.lang.error);
}
else {
dialog.info(window.lang.saved);
}
});
},
cancelValue: window.lang.cancel_text,
cancel: function () {}
});
d.showModal();
//fileName = prompt(window.lang.enter_filename_error, fileName); // FIXME Doesn't work in nodejs
}
}
......
......@@ -250,7 +250,7 @@ function swf2exe(swfFile, outputFile) {
function (err)
{
if (err) throw err;
dialog.info("Success", "Success");// TODO Lang
dialog.info(window.lang.success, window.lang.success);
});
});
});
......
......@@ -27,5 +27,9 @@
"exists_error":"抱歉,此檔案已經存在。",
"large_size_error":"抱歉,你的檔案太大。",
"save_error":"抱歉,儲存故事時發生錯誤。",
"savename_error":"抱歉,儲存故事名稱時發生錯誤。"
"savename_error":"抱歉,儲存故事名稱時發生錯誤。",
"success":"成功",
"cancel_text":"取消",
"comfirm_text":"確定",
"prompt_text":"請輸入檔案名稱"
}
......@@ -27,5 +27,9 @@
"exists_error":"Sorry, the story file already exists.",
"large_size_error":"Sorry, your story is too large.",
"save_error":"Sorry, there was an error saving your story.",
"savename_error":"Sorry, there was an error saving the story name."
"savename_error":"Sorry, there was an error saving the story name.",
"success":"Success",
"cancel_text":"Cancel",
"comfirm_text":"Comfirm",
"prompt_text":"Please enter a file name"
}
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment