$('#fileCreateConfirmButton').click(function() { var fileTags = ''; var rawTags = $('#newFileNameTags').val().split(','); rawTags.forEach(function(value, index) { if (index === 0) { fileTags = value; } else { fileTags = fileTags + TSCORE.Config.getTagDelimiter() + value; } }); if ($('#tagWithCurrentDate').prop('checked')) { if (fileTags.length < 1) { fileTags = TSCORE.TagUtils.formatDateTime4Tag(new Date()); } else { fileTags = fileTags + TSCORE.Config.getTagDelimiter() + TSCORE.TagUtils.formatDateTime4Tag(new Date()); } } if (fileTags.length > 0) { fileTags = TSCORE.TagUtils.beginTagContainer + fileTags + TSCORE.TagUtils.endTagContainer; } var filePath = TSCORE.currentPath + TSCORE.dirSeparator + $('#newFileName').val() + fileTags + '.' + fileType; TSCORE.IO.saveFilePromise(filePath, fileContent).then(function() { TSPOSTIO.saveTextFile(filePath, isNewFile); }, function(error) { TSCORE.hideLoadingAnimation(); TSCORE.showAlertDialog("Saving " + filePath + " failed."); console.error("Save to file " + filePath + " failed " + error); }); });
function createNewTextFile(filePath, content) { TSCORE.IO.saveFilePromise(filePath, content).then(function(isNewFile) { TSPOSTIO.saveTextFile(filePath, isNewFile); }, function(error) { TSCORE.hideLoadingAnimation(); console.error("Save to file " + filePath + " failed " + error); TSCORE.showAlertDialog("Saving " + filePath + " failed."); }); }