mirror of
https://github.com/toptal/haste-server.git
synced 2024-11-26 12:36:21 +01:00
Push state for new documents fixed
This commit is contained in:
parent
3acc2eb17d
commit
d69839b2fb
@ -12,6 +12,7 @@ winston.remove(winston.transports.Console);
|
|||||||
winston.add(winston.transports.Console, { colorize: true, level: 'verbose' });
|
winston.add(winston.transports.Console, { colorize: true, level: 'verbose' });
|
||||||
|
|
||||||
// TODO preparse static instead of using exists
|
// TODO preparse static instead of using exists
|
||||||
|
// TODO implement command line
|
||||||
|
|
||||||
// Set the server up
|
// Set the server up
|
||||||
http.createServer(function(request, response) {
|
http.createServer(function(request, response) {
|
||||||
|
@ -23,7 +23,12 @@ heist_document.prototype.load = function(key, callback) {
|
|||||||
key: key,
|
key: key,
|
||||||
language: high.language
|
language: high.language
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
error: function(err) {
|
||||||
|
callback(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -70,6 +75,8 @@ var heist = function(appName) {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO add key of commands
|
||||||
|
|
||||||
// Set the page title - include the appName
|
// Set the page title - include the appName
|
||||||
heist.prototype.setTitle = function(ext) {
|
heist.prototype.setTitle = function(ext) {
|
||||||
var title = ext ? this.appName + ' - ' + ext : this.appName;
|
var title = ext ? this.appName + ' - ' + ext : this.appName;
|
||||||
@ -78,9 +85,12 @@ heist.prototype.setTitle = function(ext) {
|
|||||||
|
|
||||||
// Remove the current document (if there is one)
|
// Remove the current document (if there is one)
|
||||||
// and set up for a new one
|
// and set up for a new one
|
||||||
heist.prototype.newDocument = function(ext) {
|
heist.prototype.newDocument = function(hideHistory) {
|
||||||
this.doc = new heist_document();
|
this.doc = new heist_document();
|
||||||
this.$box.hide();
|
this.$box.hide();
|
||||||
|
if (!hideHistory) {
|
||||||
|
window.history.pushState(null, this.appName, '/');
|
||||||
|
}
|
||||||
this.setTitle();
|
this.setTitle();
|
||||||
this.$textarea.val('').show().focus();
|
this.$textarea.val('').show().focus();
|
||||||
}
|
}
|
||||||
@ -96,6 +106,9 @@ heist.prototype.loadDocument = function(key) {
|
|||||||
_this.$textarea.val('').hide();
|
_this.$textarea.val('').hide();
|
||||||
_this.$box.show();
|
_this.$box.show();
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
_this.newDocument();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
window.onpopstate = function(evt) {
|
window.onpopstate = function(evt) {
|
||||||
var path = evt.target.location.pathname;
|
var path = evt.target.location.pathname;
|
||||||
if (path === '/') {
|
if (path === '/') {
|
||||||
app.newDocument();
|
app.newDocument(true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
app.loadDocument(path.substring(1, path.length));
|
app.loadDocument(path.substring(1, path.length));
|
||||||
|
Loading…
Reference in New Issue
Block a user