Commit 79506844 authored by ThorbenQuast's avatar ThorbenQuast
Browse files

fix #2026, extend modification check to the commandline

parent b840e0c8
......@@ -22,6 +22,8 @@ var CommandLine = Emitter.extend({
this.cookieName = null;
this.commandCookie = null;
this.modificationTimeout = null;
},
setup: function(node) {
......@@ -47,9 +49,33 @@ var CommandLine = Emitter.extend({
self.setDefault();
self.renderHistory();
});
//check for modifications
this.commandline.keyup(function() {
clearTimeout(self.modificationTimeout);
var check = self.checkModifications.bind(self);
self.modificationTimeout = setTimeout(check, vispa.device.hasTouch ? 1000 : 500);
});
this.setMenuEntries(); //sets up the buttons in the submit menu
},
checkModifications: function() {
clearTimeout(this.modificationTimeout);
this.modificationTimeout = null;
var isModified = false;
if (this.lastCommand)
isModified = this.getVal() != this.lastCommand.cmd;
else if (this.defaultCommand)
isModified = this.getVal() != this.defaultCommand.cmd;
if (isModified != this.view.isModified()) {
this.view.setModified(isModified);
}
return this;
},
setMenuEntries: function() {
var node;
if (vispa.extensions.extensions.jobmanagement) {
......@@ -68,7 +94,6 @@ var CommandLine = Emitter.extend({
console.log("quick-submit from editor not implemented yet");
}).append(" Quick-submit"));
this.menuNode.append(node);
}
},
......@@ -178,7 +203,7 @@ var CommandLine = Emitter.extend({
if (this.defaultCommand !== null)
this.histNode.append(self.createNode("default", this.defaultCommand.cmd));
if (this.lastCommand !== null)
this.histNode.append(self.createNode("last", this.lastCommand.cmd));
this.histNode.append(self.createNode("last saved", this.lastCommand.cmd));
},
createNode: function(name, cmd) {
......@@ -194,6 +219,7 @@ var CommandLine = Emitter.extend({
$("body").css("cursor", "default");
},
click: function() {
self.commandline.trigger("keyup");
self.commandline.val(cmd);
}
});
......@@ -208,20 +234,18 @@ var CommandLine = Emitter.extend({
this.commandline.val(cmd);
},
handleExecution: function() {
var cmd = this.getVal();
if (!cmd)
return false;
this.saveToCookie(cmd); //save the last command in a cookie
this.pushLast(cmd); //ID for matching is the set path of the file
this.pushEntry(cmd);
this.renderHistory();
return true;
},
handleSave: function(_new) {
_new = _new === undefined ? false : _new;
handleSave: function() {
this.setDefault();
var cmd = this.getVal();
if (cmd) {
this.pushEntry(cmd);
this.saveToCookie(cmd); //save the last command in a cookie
this.pushLast(cmd); //ID for matching is the set path of the file
}
if (_new)
this.setDefault();
this.renderHistory();
}
});
\ No newline at end of file
......@@ -61,6 +61,10 @@ var CodeEditor = Emitter.extend({
self.modifiedProcessing = false;
});
} else if (data.mtime > self.mtime && !self.savingProcessing) {
//these line is added for bug finding purposes
/*} else if (Math.abs(data.mtime - self.mtime) > 0.5 && !self.saving_processing) {
console.log(data.mtime);
console.log(self.mtime); */
self.modifiedProcessing = true;
self.view.confirm(
"The file " + self.path + " has changed on disk." +
......@@ -347,7 +351,7 @@ var CodeEditor = Emitter.extend({
self.lastContent = self.getContent();
self.checkModifications();
self.setMode();
self.view.commandLine.handleSave();
self.view.commandLine.handleSave(option == "new");
self.view.preview.setPath(self.path, true);
if ($.isFunction(callback))
callback();
......
......@@ -112,7 +112,7 @@ var CodeEditorOutput = Emitter.extend({
}
//check the command and process the history
if (!this.view.commandLine.handleExecution()) {
if (!this.view.commandLine.getVal()) {
this.view.alert("Please indicate a valid command for script execution!");
return this;
}
......
Supports Markdown
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