diff --git a/static/application.js b/static/application.js
index 7afb014..dab2a5e 100644
--- a/static/application.js
+++ b/static/application.js
@@ -39,10 +39,10 @@ haste_document.prototype.load = function(key, callback, lang) {
high = hljs.highlightAuto(res.data);
}
callback({
+ data: res.data,
value: high.value,
key: key,
- language: high.language || lang,
- lineCount: res.data.split("\n").length
+ language: high.language || lang
});
},
error: function(err) {
@@ -70,8 +70,7 @@ haste_document.prototype.save = function(data, callback) {
callback(null, {
value: high.value,
key: res.key,
- language: high.language,
- lineCount: data.split("\n").length
+ language: high.language
});
},
error: function(res) {
@@ -188,19 +187,46 @@ haste.prototype.lookupTypeByExtension = function(ext) {
// Add line numbers to the document
// For the specified number of lines
-haste.prototype.addLineNumbers = function(lineCount) {
+haste.prototype.addLineNumbers = function(data) {
var h = '';
+ var nlines = 0;
+ var lines = data.split("\n");
+ var lineCount = lines.length;
+ var cwidth = this.getCharacterWidth();
+ var code_width = $("code").width();
+
for (var i = 0; i < lineCount; i++) {
+ if(i>0) {
+ nlines = Math.ceil((cwidth*lines[i-1].length)/code_width);
+ for(j=0;j
';
}
$('#linenos').html(h);
};
+haste.prototype.getCharacterWidth = function() {
+ var $div = $("