From 0e292ad21ba9006f2f4afa77440edd1f751670e0 Mon Sep 17 00:00:00 2001 From: John Crepezzi Date: Tue, 29 Nov 2011 10:44:05 -0500 Subject: [PATCH] support .txt type --- static/application.js | 13 +++++++++++-- static/application.min.js | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/static/application.js b/static/application.js index b6a5da1..301c662 100644 --- a/static/application.js +++ b/static/application.js @@ -15,7 +15,16 @@ haste_document.prototype.load = function(key, callback, lang) { _this.key = key; _this.data = res.data; try { - var high = lang ? hljs.highlight(lang, res.data) : hljs.highlightAuto(res.data); + var high; + if (lang === 'txt') { + high = { value: res.data }; + } + else if (lang) { + high = hljs.highlight(lang, res.data); + } + else { + high = hljs.highlightAuto(res.data); + } } catch(err) { // failed highlight, fall back on auto high = hljs.highlightAuto(res.data); @@ -129,7 +138,7 @@ haste.extensionMap = { lua: 'lua', pas: 'delphi', java: 'java', cpp: 'cpp', cc: 'cpp', m: 'objectivec', vala: 'vala', cs: 'cs', sql: 'sql', sm: 'smalltalk', lisp: 'lisp', ini: 'ini', diff: 'diff', bash: 'bash', sh: 'bash', tex: 'tex', erl: 'erlang', hs: 'haskell', - md: 'markdown' + md: 'markdown', txt: '' }; // Look up the extension preferred for a type diff --git a/static/application.min.js b/static/application.min.js index 4176001..9e48890 100644 --- a/static/application.min.js +++ b/static/application.min.js @@ -1 +1 @@ -var haste_document=function(){this.locked=!1};haste_document.prototype.load=function(a,b,c){var d=this;$.ajax("/documents/"+a,{type:"get",dataType:"json",success:function(e){d.locked=!0,d.key=a,d.data=e.data;try{var f=c?hljs.highlight(c,e.data):hljs.highlightAuto(e.data)}catch(g){f=hljs.highlightAuto(e.data)}b({value:f.value,key:a,language:f.language||c})},error:function(a){b(!1)}})},haste_document.prototype.save=function(a,b){if(this.locked)return!1;this.data=a;var c=this;$.ajax("/documents",{type:"post",data:a,dataType:"json",success:function(d){c.locked=!0,c.key=d.key;var e=hljs.highlightAuto(a);b({value:e.value,key:d.key,language:e.language})}})};var haste=function(a,b){this.appName=a,this.baseUrl=window.location.href,this.$textarea=$("textarea"),this.$box=$("#box"),this.$code=$("#box code"),this.options=b,this.configureShortcuts(),this.configureButtons(),b.twitter||$("#box2 .twitter").hide()};haste.prototype.setTitle=function(a){var b=a?this.appName+" - "+a:this.appName;document.title=b},haste.prototype.lightKey=function(){this.configureKey(["new","save"])},haste.prototype.fullKey=function(){this.configureKey(["new","duplicate","twitter","link"])},haste.prototype.configureKey=function(a){var b,c=0;$("#box2 .function").each(function(){b=$(this);for(c=0;c