|
|
|
@ -32,7 +32,8 @@ haste_document.prototype.load = function(key, callback, lang) { |
|
|
|
|
callback({ |
|
|
|
|
value: high.value, |
|
|
|
|
key: key, |
|
|
|
|
language: high.language || lang |
|
|
|
|
language: high.language || lang, |
|
|
|
|
lineCount: res.data.split("\n").length |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
error: function(err) { |
|
|
|
@ -59,7 +60,8 @@ haste_document.prototype.save = function(data, callback) { |
|
|
|
|
callback({ |
|
|
|
|
value: high.value, |
|
|
|
|
key: res.key, |
|
|
|
|
language: high.language |
|
|
|
|
language: high.language, |
|
|
|
|
lineCount: data.split("\n").length |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
@ -73,6 +75,7 @@ var haste = function(appName, options) { |
|
|
|
|
this.$textarea = $('textarea'); |
|
|
|
|
this.$box = $('#box'); |
|
|
|
|
this.$code = $('#box code'); |
|
|
|
|
this.$linenos = $('#linenos'); |
|
|
|
|
this.options = options; |
|
|
|
|
this.configureShortcuts(); |
|
|
|
|
this.configureButtons(); |
|
|
|
@ -126,6 +129,7 @@ haste.prototype.newDocument = function(hideHistory) { |
|
|
|
|
this.$textarea.val('').show('fast', function() { |
|
|
|
|
this.focus(); |
|
|
|
|
}); |
|
|
|
|
this.removeLineNumbers(); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// Map of common extensions
|
|
|
|
@ -156,6 +160,21 @@ haste.prototype.lookupTypeByExtension = function(ext) { |
|
|
|
|
return haste.extensionMap[ext] || ext; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// Add line numbers to the document
|
|
|
|
|
// For the specified number of lines
|
|
|
|
|
haste.prototype.addLineNumbers = function(lineCount) { |
|
|
|
|
var h = ''; |
|
|
|
|
for (var i = 0; i < lineCount; i++) { |
|
|
|
|
h += (i + 1).toString() + '<br/>'; |
|
|
|
|
} |
|
|
|
|
$('#linenos').html(h); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// Remove the line numbers
|
|
|
|
|
haste.prototype.removeLineNumbers = function() { |
|
|
|
|
$('#linenos').html('>'); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// Load a document and show it
|
|
|
|
|
haste.prototype.loadDocument = function(key) { |
|
|
|
|
// Split the key up
|
|
|
|
@ -170,6 +189,7 @@ haste.prototype.loadDocument = function(key) { |
|
|
|
|
_this.fullKey(); |
|
|
|
|
_this.$textarea.val('').hide(); |
|
|
|
|
_this.$box.show().focus(); |
|
|
|
|
_this.addLineNumbers(ret.lineCount); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
_this.newDocument(); |
|
|
|
@ -201,6 +221,7 @@ haste.prototype.lockDocument = function() { |
|
|
|
|
_this.fullKey(); |
|
|
|
|
_this.$textarea.val('').hide(); |
|
|
|
|
_this.$box.show().focus(); |
|
|
|
|
_this.addLineNumbers(ret.lineCount); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|