|
|
|
@ -13,10 +13,18 @@ function saveme(callback) {
|
|
|
|
|
closeTimeout: 2000
|
|
|
|
|
}).open();
|
|
|
|
|
$("#orig_content").val(note.content);
|
|
|
|
|
});
|
|
|
|
|
if (typeof callback == "function") {
|
|
|
|
|
callback();
|
|
|
|
|
}
|
|
|
|
|
}, function () {
|
|
|
|
|
app.toast.create({
|
|
|
|
|
text: 'Something went wrong, your note might not be synced correctly.',
|
|
|
|
|
closeTimeout: 10000
|
|
|
|
|
}).open();
|
|
|
|
|
if (typeof callback == "function") {
|
|
|
|
|
callback();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sync();
|
|
|
|
@ -29,6 +37,15 @@ function saveme(callback) {
|
|
|
|
|
NOTES.add(note, function (n) {
|
|
|
|
|
$("#note_content").data("noteid", n.noteid);
|
|
|
|
|
finishSave(n, callback);
|
|
|
|
|
}, function (err) {
|
|
|
|
|
if (typeof err == "string") {
|
|
|
|
|
app.dialog.alert(err, "Error");
|
|
|
|
|
} else {
|
|
|
|
|
app.dialog.alert("An unknown error occurred.", "Error");
|
|
|
|
|
}
|
|
|
|
|
if (typeof callback == "function") {
|
|
|
|
|
callback();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
var note = NOTES.get(noteid);
|
|
|
|
@ -39,17 +56,6 @@ function saveme(callback) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function exiteditor() {
|
|
|
|
|
sync();
|
|
|
|
|
if ($("#note_content").val() == "" || $("#note_content").val() === $("#orig_content").val()) {
|
|
|
|
|
router.back({force: true, ignoreCache: true, reload: true});
|
|
|
|
|
} else {
|
|
|
|
|
saveme(function () {
|
|
|
|
|
router.back({force: true, ignoreCache: true, reload: true});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function init() {
|
|
|
|
|
document.getElementById("noteframe").contentWindow.initEditor($("#note_content").val());
|
|
|
|
|
}
|
|
|
|
@ -62,6 +68,17 @@ function sync() {
|
|
|
|
|
$("#note_content").val(document.getElementById("noteframe").contentWindow.getMarkdown());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function exiteditor() {
|
|
|
|
|
sync();
|
|
|
|
|
if ($("#note_content").val() == "" || $("#note_content").val() === $("#orig_content").val()) {
|
|
|
|
|
router.back({force: true, ignoreCache: true, reload: true});
|
|
|
|
|
} else {
|
|
|
|
|
saveme(function () {
|
|
|
|
|
router.back({force: true, ignoreCache: true, reload: true});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$("#noteframe").on("load", function () {
|
|
|
|
|
init();
|
|
|
|
|
});
|