From cf71547450bb0608011a9c6bd0e69eb144e08959 Mon Sep 17 00:00:00 2001 From: Alec Perkins Date: Thu, 4 Aug 2011 01:32:51 -0400 Subject: [PATCH] v0.2.0 --- coffeetable-min.js | 28 ++++++++++++++-------------- coffeetable.js | 2 +- src/coffeetable.coffee | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/coffeetable-min.js b/coffeetable-min.js index 8c38ac0..c7aa472 100644 --- a/coffeetable-min.js +++ b/coffeetable-min.js @@ -1,14 +1,14 @@ -(function(){var p,b,q,r,G,H,s,I,y,t,j,l,z,o,J,u,A,B,n,C,K,L,D,E,g,v,w,M;I={autoload_coffee_script:true,autoload_jquery:true,coffeescript_js:"http://code.alecperkins.net/coffeetable/lib/coffee_script-1.1.1-min.js",jquery_js:"http://code.alecperkins.net/coffeetable/lib/jquery-1.6.2-min.js",local_storage:true,ls_key:"coffee-table",clear_on_load:false,replay_on_load:false,multi_line:false,indent:" ",auto_suggest:true,widget_position:"fixed",widget_top:"5px",widget_right:"5px",widget_id:"CoffeeTable-"+ -(new Date).getTime()};typeof console!=="undefined"&&console!==null||(console={log:function(){},dir:function(){}});if(window.log==null)window.log=function(){return console.log.apply(console,arguments)};if(window.dir==null)window.dir=function(){return console.dir.apply(console,arguments)};o={UP:38,DOWN:40,ENTER:13,TAB:9,BACKSPACE:8};w='
clearreplay?

multiline

      '; -b=g=p=null;v=B=y=q=false;l=0;n={jquery_js:false,coffeescript_js:false};j=[];z=function(){if(n.jquery_js&&n.coffeescript_js){p=window.jQuery;w=w.replace(/__ID__/g,g.widget_id);L();g.local_storage&&J();return B=true}};H=function(a,d){var c,e,f,h,k,i,m;if(d.which===o.BACKSPACE&&a.length===0&&b.autosuggest_list.html().length!==0)return b.autosuggest_list.html("");else{f=a.split(".");i=[[window,"window"]];m=f.slice(0,f.length-1);h=0;for(k=m.length;h -0&&i.push([i[i.length-1][0][e],e])}e=[];h=RegExp("^"+f[f.length-1]);m=i[i.length-1][0];for(c in m){k=m[c];f=h.exec(c);if((f!=null?f.length:void 0)>0)e.push([c,typeof k])}e.sort();return K(i,e)}};K=function(a,d){var c,e,f,h;c="";f=0;for(h=a.length;f"+c+"";f=0;for(h=d.length;f"+e[0]+""}return b.autosuggest_list.html(c)};J=function(){var a,d,c,e,f;if(typeof localStorage!=="undefined"&&localStorage!== -null){d=localStorage.getItem(g.ls_key);if(d!=null){d=JSON.parse(d);f=[];c=0;for(e=d.length;c"+m+": "+i+"");if(k)c.addClass("js-error");else e&&c.addClass("cs-error");c.click(function(){u(false,m);return b.textarea.focus()});c.prependTo(b.history_list);e=function(){var x, -N,F;F=[];x=0;for(N=j.length;x"+a+"")}};u=function(a,d){if(a==null)a=false;if(d!=null)l=d+1;if(l===-1||l===0)l=j.length-1;else if(a)l+=1;else l-=1;if(j.length>0){b.textarea.val(j[l].source);b.textarea.selectionStart=0;return b.textarea.selectionEnd=0}};M=function(){var a;if(v=!v){a="4em";b.autosuggest_list.hide()}else{a="";g.auto_suggest&&b.autosuggest_list.show()}b.textarea.css("height",a).focus();return r()};L=function(){var a;a=p(w); -b={widget:a,textarea:a.find("textarea"),autosuggest_list:a.find("ul.autosuggest"),history_list:a.find("ul.history"),button:a.find("button"),div:a.find("div"),clear_history:a.find("span.clear"),replay_history:a.find("span.replay"),a:a.find("a"),toggle_multiline:a.find("input"),p:a.find("p"),li:a.find("li")};b.widget.css({position:""+g.widget_position,top:""+g.widget_top,right:""+g.widget_right});r();G();return a.appendTo("body")};G=function(){b.button.click(function(){if(q=!q){b.div.show();b.p.show(); -b.textarea.focus();return b.button.addClass("active")}else{b.div.hide();b.p.hide();return b.button.removeClass("active")}});b.clear_history.click(function(){return s()});b.replay_history.click(function(){b.history_list.empty();return setTimeout(function(){return D()},100)});b.toggle_multiline.click(function(){return M()});b.textarea.bind("keydown",function(a){var d;d=b.textarea.val();if(this.selectionStart===0)if(a.which===o.UP)u();else a.which===o.DOWN&&u(true);if(a.which===o.ENTER&&(!v||a.shiftKey)){a.preventDefault(); -if(d!==""){t(d);return b.textarea.val("")}}else if(a.which===o.TAB){a.preventDefault();a=this.selectionStart;this.value=this.value.substring(0,a)+g.indent+this.value.substring(a);this.selectionStart=a+g.indent.length;return this.selectionEnd=a+g.indent.length}});b.textarea.bind("keyup",function(a){var d;d=b.textarea.val();if(!g.multi_line&&g.auto_suggest)return H(d,a)});g.multi_line&&b.toggle_multiline.click();return p(window).resize(function(){var a;a=""+(window.innerHeight-140)+"px";b.autosuggest_list.css({"max-height":a, -"max-width":""+(window.innerWidth-255)+"px"});return b.history_list.css("max-height",a)})};window.CoffeeTable={show:function(){b.widget.show();return this},hide:function(){b.widget.hide();return this},clear:function(){s();return this},replay:function(){D();return this},deferInit:function(){y=true;return this},init:function(a){E(a);C();return this}};E=function(a){var d,c,e;g=I;e=[];for(d in a){c=a[d];e.push(g[d]=c)}return e};A=function(a){var d,c;d=document.getElementsByTagName("head")[0];c=document.createElement("script"); -c.type="application/javascript";c.src=g[a];c.async=true;c.onload=function(){n[a]=true;return z()};return d.appendChild(c)};C=function(){var a;if(b!=null)if((a=b.widget)!=null)a.remove();q=false;n.jquery_js=window.jQuery!=null;n.coffeescript_js=window.CoffeeScript!=null;if(!n.coffeescript_js)if(g.autoload_coffee_script)A("coffeescript_js");else throw"CoffeeTable requires coffee_script.js";if(!n.jquery_js)if(g.autoload_jquery)A("jquery_js");else throw"CoffeeTable requires jQuery";return z()};document.addEventListener("DOMContentLoaded", -function(){document.removeEventListener("DOMContentLoaded",arguments.callee,false);if(!y&&!B){E();return C()}},false)}).call(this); +(function(){var p,b,q,H,I,s,J,y,t,j,l,z,o,K,u,A,B,n,C,L,v,M,D,E,F,h,r,w,N,O,P;J={autoload_coffee_script:true,autoload_jquery:true,coffeescript_js:"http://code.alecperkins.net/coffeetable/lib/coffee_script-1.1.1-min.js",jquery_js:"http://code.alecperkins.net/coffeetable/lib/jquery-1.6.2-min.js",local_storage:true,ls_key:"coffee-table",clear_on_load:false,replay_on_load:false,multi_line:false,indent:" ",auto_suggest:true,widget_position:"fixed",widget_top:"5px",widget_right:"5px",widget_id:"CoffeeTable-"+ +(new Date).getTime()};typeof console!=="undefined"&&console!==null||(console={log:function(){},dir:function(){}});if(window.log==null)window.log=function(){return console.log.apply(console,arguments)};if(window.dir==null)window.dir=function(){return console.dir.apply(console,arguments)};o={UP:38,DOWN:40,ENTER:13,TAB:9,BACKSPACE:8,ESCAPE:27};w='
      clearreplay?

      multiline

          '; +b=h=p=null;r=B=y=q=false;l=0;n={jquery_js:false,coffeescript_js:false};j=[];z=function(){if(n.jquery_js&&n.coffeescript_js){p=window.jQuery;w=w.replace(/__ID__/g,h.widget_id);M();h.local_storage&&K();return B=true}};I=function(a,d){var c,e,f,g,k,i,m;if(d.which===o.ESCAPE||d.which===o.BACKSPACE&&a.length===0&&b.autosuggest_list.html().length!==0)return b.autosuggest_list.html("");else{f=a.split(".");i=[[window,"window"]];m=f.slice(0,f.length-1);g=0;for(k=m.length;g0&&i.push([i[i.length-1][0][e],e])}e=[];g=RegExp("^"+f[f.length-1]);m=i[i.length-1][0];for(c in m){k=m[c];f=g.exec(c);if((f!=null?f.length:void 0)>0)e.push([c,typeof k])}e.sort();return L(i,e)}};L=function(a,d){var c,e,f,g;c="";f=0;for(g=a.length;f"+c+"";f=0;for(g=d.length;f"+e[0]+""}b.autosuggest_list.html(c);return E()};K=function(){var a,d,c,e,f;if(typeof localStorage!=="undefined"&& +localStorage!==null){d=localStorage.getItem(h.ls_key);if(d!=null){d=JSON.parse(d);f=[];c=0;for(e=d.length;c").text(""+m+": "+i);if(k)c.addClass("js-error");else e&&c.addClass("cs-error");c.click(function(){u(false,m);return b.textarea.focus()});c.prependTo(b.history_list); +e=function(){var x,Q,G;G=[];x=0;for(Q=j.length;x": +"type CoffeeScript, press ";return b.instructions.text(a)}};u=function(a,d){if(a==null)a=false;if(d!=null)l=d+1;if(l===-1||l===0)l=j.length-1;else if(a)l+=1;else l-=1;if(j.length>0){b.textarea.val(j[l].source);b.textarea.selectionStart=0;return b.textarea.selectionEnd=0}};N=function(){var a;if(r=!r){a="4em";b.autosuggest_list.hide()}else{a="";h.auto_suggest&&b.autosuggest_list.show()}b.textarea.css("height",a).focus();return v()};E=function(){var a;a=""+(window.innerHeight-140)+"px";b.autosuggest_list.css({"max-height":a, +"max-width":""+(window.innerWidth-255)+"px"});return b.history_list.css("max-height",a)};M=function(){var a;a=p(w);b={widget:a,textarea:a.find("textarea"),autosuggest_list:a.find("ul.autosuggest"),history_list:a.find("ul.history"),button:a.find("button"),div:a.find("div"),clear_history:a.find("span.clear"),replay_history:a.find("span.replay"),a:a.find("a"),toggle_multiline:a.find("input"),p:a.find("p.mode"),instructions:a.find("p.instructions"),li:a.find("li")};b.widget.css({position:""+h.widget_position, +top:""+h.widget_top,right:""+h.widget_right});v();H();return a.appendTo("body")};H=function(){b.button.click(function(){if(q=!q){b.div.show();b.p.show();b.textarea.focus();return b.button.addClass("active")}else{b.div.hide();b.p.hide();return b.button.removeClass("active")}});b.clear_history.click(function(){return s()});b.replay_history.click(function(){b.history_list.empty();return setTimeout(function(){return D()},100)});b.toggle_multiline.click(function(){return N()});b.textarea.bind("keydown", +function(a){var d;d=b.textarea.val();if(this.selectionStart===0)if(a.which===o.UP)u();else a.which===o.DOWN&&u(true);if(a.which===o.ENTER&&(!r||a.shiftKey)){a.preventDefault();if(d!==""){t(d);return b.textarea.val("")}}else if(a.which===o.TAB){a.preventDefault();a=this.selectionStart;this.value=this.value.substring(0,a)+h.indent+this.value.substring(a);this.selectionStart=a+h.indent.length;return this.selectionEnd=a+h.indent.length}});b.textarea.bind("keyup",function(a){var d;d=b.textarea.val();if(!h.multi_line&& +h.auto_suggest)return I(d,a)});h.multi_line&&b.toggle_multiline.click();return p(window).resize(function(){return E()})};O=function(){return b.widget.remove()};if((P=window.CoffeeTable)!=null)P.unload();window.CoffeeTable={show:function(){b.widget.show();return this},hide:function(){b.widget.hide();return this},clear:function(){s();return this},replay:function(){D();return this},deferInit:function(){y=true;return this},init:function(a){F(a);C();return this},unload:function(){O();return this},active:function(){return q}}; +F=function(a){var d,c,e;h=J;e=[];for(d in a){c=a[d];e.push(h[d]=c)}return e};A=function(a){var d,c;d=document.getElementsByTagName("head")[0];c=document.createElement("script");c.type="application/javascript";c.src=h[a];c.async=true;c.onload=function(){n[a]=true;return z()};return d.appendChild(c)};C=function(){q=false;n.jquery_js=window.jQuery!=null;n.coffeescript_js=window.CoffeeScript!=null;if(!n.coffeescript_js)if(h.autoload_coffee_script)A("coffeescript_js");else throw"CoffeeTable requires coffee_script.js"; +if(!n.jquery_js)if(h.autoload_jquery)A("jquery_js");else throw"CoffeeTable requires jQuery";return z()};document.addEventListener("DOMContentLoaded",function(){document.removeEventListener("DOMContentLoaded",arguments.callee,false);if(!y&&!B){F();return C()}},false)}).call(this); diff --git a/coffeetable.js b/coffeetable.js index eae4e55..652a920 100644 --- a/coffeetable.js +++ b/coffeetable.js @@ -1,7 +1,7 @@ (function() { /* - # CoffeeTable v0.2.0pre + # CoffeeTable v0.2.0 A drop-in, CoffeeScript-fluent console for web pages. diff --git a/src/coffeetable.coffee b/src/coffeetable.coffee index 611f9c6..32bec45 100644 --- a/src/coffeetable.coffee +++ b/src/coffeetable.coffee @@ -1,6 +1,6 @@ ### -# CoffeeTable v0.2.0pre +# CoffeeTable v0.2.0 A drop-in, CoffeeScript-fluent console for web pages.