Commit 0923cc50 authored by David Gonçalves's avatar David Gonçalves 📖

fixes

parent 0482d8e2
......@@ -138,7 +138,7 @@
</span>
<br/>
<span id="storyname_eng_text">Story name(English): </span><input type="text" id="storyname" />
<input type="submit" id="engtochi_text" value="Eng to Chi" onclick="engtochi()"/>
<input type="submit" id="engtochi_text" value="Eng to Chi" />
<span id="storyname_chi_text">Story name(Chinese): </span><input type="text" id="storynameb5" />
</div>
</body>
......
......@@ -58,9 +58,9 @@ class Editor {
setLines() {
let lines = this.editor.session.getLength();
let linecol = this.editor.selection.getCursor();
$('#lines').html(`<strong>`+lang.lang.editor_line+`<\/strong> ${linecol.row+1}
<strong>`+lang.lang.editor_ch+`<\/strong>${linecol.column} |
<strong>`+lang.lang.editor_totalline+`<\/strong> ${lines}`);
$('#lines').html(`<strong>${window.lang.editor_line}<\/strong> ${linecol.row+1}
<strong>${window.lang.editor_ch}<\/strong>${linecol.column} |
<strong>${window.lang.editor_totalline}<\/strong> ${lines}`);
}
changeTheme(theme) {
......
......@@ -10,7 +10,7 @@ class File {
static fileSupport() {
// Check for the various File API support.
if (!(window.File && window.FileReader && window.FileList && window.Blob)) {
dialog.err(lang.lang.api_error, lang.lang.error);
dialog.err(window.lang.api_error, window.lang.error);
}
}
......@@ -19,7 +19,7 @@ class File {
const data = ace.edit("XMLCode").getValue();
if (!data) {
dialog.err(lang.lang.empty_textarea_error, lang.lang.error);
dialog.err(window.lang.empty_textarea_error, window.lang.error);
return null;
}
......@@ -38,7 +38,7 @@ class File {
fileName = file.name;
}
fileName = prompt(lang.lang.enter_filename_error, fileName); // FIXME Doesn't work in nodejs
fileName = prompt(window.lang.enter_filename_error, fileName); // FIXME Doesn't work in nodejs
......@@ -51,10 +51,10 @@ class File {
fs.writeFile(fileName, blob, function(err) {
if (err) {
dialog.err(err, lang.lang.error);
dialog.err(err, window.lang.error);
}
else {
dialog.info(lang.lang.saved);
dialog.info(window.lang.saved);
}
});
}
......@@ -72,7 +72,7 @@ class File {
if (file.name.substring(file.name.lastIndexOf(".")) != ".xml") {
file = file_tmp;
$("#fileInput").val("");
dialog.err(lang.lang.xml_only_error, lang.lang.error);
dialog.err(window.lang.xml_only_error, window.lang.error);
return false;
} else {
fileType = "text/xml";
......@@ -80,7 +80,7 @@ class File {
document.getElementById('fileDetails').innerHTML =
'<strong>' + fileName + '</strong> (' + fileType + ') - ' +
fileSize + lang.lang.editor_size_lastm + lastModified;
fileSize + window.lang.editor_size_lastm + lastModified;
return true;
}
......
......@@ -89,46 +89,46 @@ function generateExe() {
`;
if (story_number>7 || story_number<1) {
dialog.err(lang.lang.replace_story_error, lang.lang.error);
dialog.err(window.lang.replace_story_error, window.lang.error);
return;
} else {
story_number=parseInt(story_number);
}
if (story_name == "" || story_name == null) {
dialog.err(lang.lang.story_engname_error, lang.lang.error);
dialog.err(window.lang.story_engname_error, window.lang.error);
return;
}
if (story_nameb5 == "" || story_nameb5 == null) {
dialog.err(lang.lang.story_chiname_error, lang.lang.error);
dialog.err(window.lang.story_chiname_error, window.lang.error);
return;
}
const data = File.getDataFromEditor();
if (data === undefined || data === null || data === '' || data.length == 0) {
dialog.err(lang.lang.empty_story_error, lang.lang.error);
dialog.err(window.lang.empty_story_error, window.lang.error);
return;
}
// TODO: XML validation
fs.exists(target_file, exists => {
if (exists) {
dialog.err(lang.lang.exists_error, lang.lang.error);
dialog.err(window.lang.exists_error, window.lang.error);
return;
}
});
if (data.length > 512 * 1000) {
dialog.err(lang.lang.large_size_error, lang.lang.error);
dialog.err(window.lang.large_size_error, window.lang.error);
return;
}
fs.writeFile(target_file, data, err => {
console.log(target_file)
if (err) {
dialog.err(lang.lang.save_error, lang.lang.error);
dialog.err(window.lang.save_error, window.lang.error);
return;
}
create_mod(target_filename);
......@@ -136,7 +136,7 @@ function generateExe() {
//upload storylist
fs.writeFile(target_file_story_list, storylistdata, err => {
if (err) {
dialog.err(lang.lang.savename_error, lang.lang.error);
dialog.err(window.lang.savename_error, window.lang.error);
return;
}
create_mod(target_filename);
......
......@@ -11,6 +11,12 @@ $(document).ready(function () {
// Check for API support
File.fileSupport();
// Set language
lang = new Languages();
lang.loadLanguages();
lang.setLanguage("中文");
window.lang = lang.lang;
// Initialize editor
var editor = new Editor(ace);
......@@ -28,10 +34,9 @@ $(document).ready(function () {
generateExe();
}
});
$('#engtochi_text').on('click', function(e) {
engtochi();
});
// Languages
lang = new Languages();
lang.loadLanguages();
lang.setLanguage("中文");
//console.log(lang.lang_arr[0].language);
});
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