Cleanup and remove TODO that is done

This commit is contained in:
John Crepezzi 2011-11-18 17:14:03 -05:00
parent 7709e12500
commit f48cc45928

View file

@ -1,19 +1,15 @@
///// represents a single document ///// represents a single document
var heist_document = function() { var heist_document = function() {
this.locked = false; this.locked = false;
}; };
// Get this document from the server and lock it here
heist_document.prototype.load = function(key, callback) { heist_document.prototype.load = function(key, callback) {
var _this = this; var _this = this;
$.ajax('/documents/' + key, { $.ajax('/documents/' + key, {
type: 'get', type: 'get',
dataType: 'json', dataType: 'json',
success: function(res) { success: function(res) {
_this.locked = true; _this.locked = true;
_this.data = res.data; _this.data = res.data;
@ -24,30 +20,23 @@ heist_document.prototype.load = function(key, callback) {
language: high.language language: high.language
}); });
}, },
error: function(err) { error: function(err) {
callback(false); callback(false);
} }
}); });
}; };
// Save this document to the server and lock it here
heist_document.prototype.save = function(data, callback) { heist_document.prototype.save = function(data, callback) {
if (this.locked) { if (this.locked) {
return false; return false;
} }
this.data = data; this.data = data;
var _this = this; var _this = this;
$.ajax('/documents', { $.ajax('/documents', {
type: 'post', type: 'post',
data: data, data: data,
dataType: 'json', dataType: 'json',
success: function(res) { success: function(res) {
_this.locked = true; _this.locked = true;
var high = hljs.highlightAuto(data); var high = hljs.highlightAuto(data);
@ -57,22 +46,17 @@ heist_document.prototype.save = function(data, callback) {
language: high.language language: high.language
}); });
} }
}); });
}; };
///// represents the paste application ///// represents the paste application
var heist = function(appName) { var heist = function(appName) {
this.appName = appName; this.appName = appName;
this.$textarea = $('textarea'); this.$textarea = $('textarea');
this.$box = $('#box'); this.$box = $('#box');
this.$code = $('#box code'); this.$code = $('#box code');
this.configureShortcuts(); this.configureShortcuts();
}; };
// TODO add key of commands // TODO add key of commands
@ -166,7 +150,6 @@ heist.prototype.configureShortcuts = function() {
}; };
// TODO handle not found gracefully
// TODO refuse to lock empty documents // TODO refuse to lock empty documents
///// Tab behavior in the textarea - 2 spaces per tab ///// Tab behavior in the textarea - 2 spaces per tab