better save in the demo
This commit is contained in:
parent
f782e59f76
commit
d884b44d48
1 changed files with 25 additions and 1 deletions
|
|
@ -199,7 +199,31 @@ var commands = env.editor.commands;
|
||||||
commands.addCommand({
|
commands.addCommand({
|
||||||
name: "save",
|
name: "save",
|
||||||
bindKey: {win: "Ctrl-S", mac: "Command-S"},
|
bindKey: {win: "Ctrl-S", mac: "Command-S"},
|
||||||
exec: function() {alert("Fake Save File");}
|
exec: function(arg) {
|
||||||
|
var session = env.editor.session;
|
||||||
|
name = session.name.match(/[^\/]+$/)
|
||||||
|
localStorage.setItem(
|
||||||
|
"saved_file:" + name,
|
||||||
|
session.getValue()
|
||||||
|
);
|
||||||
|
env.editor.cmdLine.setValue("saved "+ name);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
commands.addCommand({
|
||||||
|
name: "load",
|
||||||
|
bindKey: {win: "Ctrl-O", mac: "Command-O"},
|
||||||
|
exec: function(arg) {
|
||||||
|
var session = env.editor.session;
|
||||||
|
name = session.name.match(/[^\/]+$/)
|
||||||
|
var value = localStorage.getItem("saved_file:" + name);
|
||||||
|
if (typeof value == "string") {
|
||||||
|
session.setValue(value);
|
||||||
|
env.editor.cmdLine.setValue("loaded "+ name);
|
||||||
|
} else {
|
||||||
|
env.editor.cmdLine.setValue("no previuos value saved for "+ name);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var keybindings = {
|
var keybindings = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue