Anonymous avatar Anonymous committed 0cf610f

regen

Comments (0)

Files changed (2)

static/css/screen.css

 form label {line-height:1em;}
 input[type='submit'], input[type='reset'], input[type='button'], button {font-size:1em;font-weight:bold;}
 textarea {line-height:16px;}
-#snippet-edit label,#snippet-edit input['text'],#snippet-edit select,#snippet-edit input['password'],#snippet-edit {font-size:0.9em;}
+form#snippet-edit,#snippet-edit label,#snippet-edit input[type='text'],#snippet-edit select,#snippet-edit input[type='password'] {font-size:0.9em;}
 #actions ul {list-style:none;}
 #actions form li label {font-weight:normal;font-size:1em;}
 #info {font-size:0.9em;font-weight:bold;}
 #reviews-list li {font-size:0.9em;}
 span.reviewflag.new {font-weight:bold;}
 #notify-snippet {font-weight:bold;font-size:0.8em;}
+#fpassword h2 {font-size:2em;padding:0.3em;margin-bottom:0.75em;}
 .comment-box h1 {font-size:1.6em;line-height:1;margin-bottom:0.5em;}
 .comment-box h2 {font-size:1.4em;margin-bottom:0.75em;}
 .comment-box h3 {font-size:1.2em;line-height:1;margin-bottom:1em;}
 #review_comment_area td.nums,#review_comment_area td.lines {padding:0;oveflow-x:auto;}
 #review_comment_area td.nums {padding-right:1px;}
 td.nums,td.nums table {width:30px;}
-=#review_comment_area table {width:100%;border-spacing:0;border-collapse:collapse;margin:0;padding:0;}
+#review_comment_area table {width:100%;border-spacing:0;border-collapse:collapse;margin:0;padding:0;}
 #review_comment_area td {vertical-align:top;}
 td.nums {background:#F0F0F0 none repeat scroll 0 0;border-right:2px solid;width:30px;}
 td.line-number {cursor:pointer;text-align:right;vertical-align:top;}

static/js/friendpaste.js

-var Showdown={};Showdown.converter=function(){var a;var k;var D;var j=0;this.makeHtml=function(K){a=new Array();k=new Array();D=new Array();K=K.replace(/~/g,"~T");K=K.replace(/\$/g,"~D");K=K.replace(/\r\n/g,"\n");K=K.replace(/\r/g,"\n");K="\n\n"+K+"\n\n";K=C(K);K=K.replace(/^[ \t]+$/mg,"");K=n(K);K=e(K);K=J(K);K=s(K);K=K.replace(/~D/g,"$$");K=K.replace(/~T/g,"~");return K};var e=function(K){var K=K.replace(/^[ ]{0,3}\[(.+)\]:[ \t]*\n?[ \t]*<?(\S+?)>?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|\Z)/gm,function(N,P,O,M,L){P=P.toLowerCase();a[P]=i(O);if(M){return M+L}else{if(L){k[P]=L.replace(/"/g,"&quot;")}}return""});return K};var n=function(M){M=M.replace(/\n/g,"\n\n");var L="p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del";var K="p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math";M=M.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del)\b[^\r]*?\n<\/\2>[ \t]*(?=\n+))/gm,A);M=M.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math)\b[^\r]*?.*<\/\2>[ \t]*(?=\n+)\n)/gm,A);M=M.replace(/(\n[ ]{0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,A);M=M.replace(/(\n\n[ ]{0,3}<!(--[^\r]*?--\s*)+>[ \t]*(?=\n{2,}))/g,A);M=M.replace(/(?:\n\n)([ ]{0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,A);M=M.replace(/\n\n/g,"\n");return M};var A=function(K,L){var M=L;M=M.replace(/\n\n/g,"\n");M=M.replace(/^\n/,"");M=M.replace(/\n+$/g,"");M="\n\n~K"+(D.push(M)-1)+"K\n\n";return M};var J=function(L){L=g(L);var K=q("<hr />");L=L.replace(/^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$/gm,K);L=L.replace(/^[ ]{0,2}([ ]?\-[ ]?){3,}[ \t]*$/gm,K);L=L.replace(/^[ ]{0,2}([ ]?\_[ ]?){3,}[ \t]*$/gm,K);L=H(L);L=b(L);L=w(L);L=n(L);L=h(L);return L};var t=function(K){K=F(K);K=m(K);K=f(K);K=I(K);K=B(K);K=o(K);K=i(K);K=d(K);K=K.replace(/  +\n/g," <br />\n");return K};var m=function(L){var K=/(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|<!(--.*?--\s*)+>)/gi;L=L.replace(K,function(N){var M=N.replace(/(.)<\/?code>(?=.)/g,"$1`");M=z(M,"\\`*_");return M});return L};var B=function(K){K=K.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,G);K=K.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()<?(.*?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,G);K=K.replace(/(\[([^\[\]]+)\])()()()()()/g,G);return K};var G=function(Q,W,V,U,T,S,P,O){if(O==undefined){O=""}var N=W;var L=V;var M=U.toLowerCase();var K=T;var R=O;if(K==""){if(M==""){M=L.toLowerCase().replace(/ ?\n/g," ")}K="#"+M;if(a[M]!=undefined){K=a[M];if(k[M]!=undefined){R=k[M]}}else{if(N.search(/\(\s*\)$/m)>-1){K=""}else{return N}}}K=z(K,"*_");var X='<a href="'+K+'"';if(R!=""){R=R.replace(/"/g,"&quot;");R=z(R,"*_");X+=' title="'+R+'"'}X+=">"+L+"</a>";return X};var I=function(K){K=K.replace(/(!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,v);K=K.replace(/(!\[(.*?)\]\s?\([ \t]*()<?(\S+?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,v);return K};var v=function(Q,W,V,U,T,S,P,O){var N=W;var M=V;var L=U.toLowerCase();var K=T;var R=O;if(!R){R=""}if(K==""){if(L==""){L=M.toLowerCase().replace(/ ?\n/g," ")}K="#"+L;if(a[L]!=undefined){K=a[L];if(k[L]!=undefined){R=k[L]}}else{return N}}M=M.replace(/"/g,"&quot;");K=z(K,"*_");var X='<img src="'+K+'" alt="'+M+'"';R=R.replace(/"/g,"&quot;");R=z(R,"*_");X+=' title="'+R+'"';X+=" />";return X};var g=function(K){K=K.replace(/^(.+)[ \t]*\n=+[ \t]*\n+/gm,function(L,M){return q("<h1>"+t(M)+"</h1>")});K=K.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm,function(M,L){return q("<h2>"+t(L)+"</h2>")});K=K.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm,function(L,O,N){var M=O.length;return q("<h"+M+">"+t(N)+"</h"+M+">")});return K};var r;var H=function(L){L+="~0";var K=/^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;if(j){L=L.replace(K,function(N,Q,P){var R=Q;var O=(P.search(/[*+-]/g)>-1)?"ul":"ol";R=R.replace(/\n{2,}/g,"\n\n\n");var M=r(R);M=M.replace(/\s+$/,"");M="<"+O+">"+M+"</"+O+">\n";return M})}else{K=/(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/g;L=L.replace(K,function(O,S,Q,N){var R=S;var T=Q;var P=(N.search(/[*+-]/g)>-1)?"ul":"ol";var T=T.replace(/\n{2,}/g,"\n\n\n");var M=r(T);M=R+"<"+P+">\n"+M+"</"+P+">\n";return M})}L=L.replace(/~0/,"");return L};r=function(K){j++;K=K.replace(/\n{2,}$/,"\n");K+="~0";K=K.replace(/(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+([^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm,function(N,P,O,M,L){var R=L;var Q=P;var S=O;if(Q||(R.search(/\n{2,}/)>-1)){R=J(u(R))}else{R=H(u(R));R=R.replace(/\n$/,"");R=t(R)}return"<li>"+R+"</li>\n"});K=K.replace(/~0/g,"");j--;return K};var b=function(K){K+="~0";K=K.replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,function(L,N,M){var O=N;var P=M;O=x(u(O));O=C(O);O=O.replace(/^\n+/g,"");O=O.replace(/\n+$/g,"");O="<pre><code>"+O+"\n</code></pre>";return q(O)+P});K=K.replace(/~0/,"");return K};var q=function(K){K=K.replace(/(^\n+|\n+$)/g,"");return"\n\n~K"+(D.push(K)-1)+"K\n\n"};var F=function(K){K=K.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,function(N,P,O,M,L){var Q=M;Q=Q.replace(/^([ \t]*)/g,"");Q=Q.replace(/[ \t]*$/g,"");Q=x(Q);return P+"<code>"+Q+"</code>"});return K};var x=function(K){K=K.replace(/&/g,"&amp;");K=K.replace(/</g,"&lt;");K=K.replace(/>/g,"&gt;");K=z(K,"*_{}[]\\",false);return K};var d=function(K){K=K.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g,"<strong>$2</strong>");K=K.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g,"<em>$2</em>");return K};var w=function(K){K=K.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm,function(L,M){var N=M;N=N.replace(/^[ \t]*>[ \t]?/gm,"~0");N=N.replace(/~0/g,"");N=N.replace(/^[ \t]+$/gm,"");N=J(N);N=N.replace(/(^|\n)/g,"$1  ");N=N.replace(/(\s*<pre>[^\r]+?<\/pre>)/gm,function(O,P){var Q=P;Q=Q.replace(/^  /mg,"~0");Q=Q.replace(/~0/g,"");return Q});return q("<blockquote>\n"+N+"\n</blockquote>")});return K};var h=function(Q){Q=Q.replace(/^\n+/g,"");Q=Q.replace(/\n+$/g,"");var P=Q.split(/\n{2,}/g);var M=new Array();var K=P.length;for(var L=0;L<K;L++){var O=P[L];if(O.search(/~K(\d+)K/g)>=0){M.push(O)}else{if(O.search(/\S/)>=0){O=t(O);O=O.replace(/^([ \t]*)/g,"<p>");O+="</p>";M.push(O)}}}K=M.length;for(var L=0;L<K;L++){while(M[L].search(/~K(\d+)K/)>=0){var N=D[RegExp.$1];N=N.replace(/\$/g,"$$$$");M[L]=M[L].replace(/~K\d+K/,N)}}return M.join("\n\n")};var i=function(K){K=K.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g,"&amp;");K=K.replace(/<(?![a-z\/?\$!])/gi,"&lt;");return K};var f=function(K){K=K.replace(/\\(\\)/g,l);K=K.replace(/\\([`*_{}\[\]()>#+-.!])/g,l);return K};var o=function(K){K=K.replace(/<((https?|ftp|dict):[^'">\s]+)>/gi,'<a href="$1">$1</a>');K=K.replace(/<(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi,function(L,M){return E(s(M))});return K};var E=function(M){function L(O){var N="0123456789ABCDEF";var P=O.charCodeAt(0);return(N.charAt(P>>4)+N.charAt(P&15))}var K=[function(N){return"&#"+N.charCodeAt(0)+";"},function(N){return"&#x"+L(N)+";"},function(N){return N}];M="mailto:"+M;M=M.replace(/./g,function(N){if(N=="@"){N=K[Math.floor(Math.random()*2)](N)}else{if(N!=":"){var O=Math.random();N=(O>0.9?K[2](N):O>0.45?K[1](N):K[0](N))}}return N});M='<a href="'+M+'">'+M+"</a>";M=M.replace(/">.+:/g,'">');return M};var s=function(K){K=K.replace(/~E(\d+)E/g,function(L,N){var M=parseInt(N);return String.fromCharCode(M)});return K};var u=function(K){K=K.replace(/^(\t|[ ]{1,4})/gm,"~0");K=K.replace(/~0/g,"");return K};var C=function(K){K=K.replace(/\t(?=\t)/g,"    ");K=K.replace(/\t/g,"~A~B");K=K.replace(/~B(.+?)~A/g,function(L,O,N){var Q=O;var M=4-Q.length%4;for(var P=0;P<M;P++){Q+=" "}return Q});K=K.replace(/~A/g,"    ");K=K.replace(/~B/g,"");return K};var z=function(O,L,M){var K="(["+L.replace(/([\[\]\\])/g,"\\$1")+"])";if(M){K="\\\\"+K}var N=new RegExp(K,"g");O=O.replace(N,l);return O};var l=function(K,M){var L=M.charCodeAt(0);return"~E"+L+"E"}};var Resizeable=base2.Base.extend({min_height:280,constructor:function(e,d){var b=this;if(d){this.min_height=d}var a=document.createElement("div");a.className="grippie";a.style.cursor="s-resize";base2.DOM.bind(a);document.querySelectorAll(e).forEach(function(f){f.parentNode.appendChild(a);a.addEventListener("mousedown",function(g){g.preventDefault();g.stopPropagation();b.handleResize(g,f);return false},false)})},handleResize:function(h,d){var a=this;var i=d;var j={x:h.screenX,y:h.screenY};var f={width:i.offsetWidth,height:i.offsetHeight};var g=function(l){l.preventDefault();var m=l.screenY-j.y;if(m){var k=f.height+m;if(k>a.min_height){i.style.height=k+"px";f.height=k;j.y=l.screenY}}return false};var b=function(k){document.removeEventListener("mousemove",g,false);this.removeEventListener("mouseup",arguments.callee,false);return false};document.addEventListener("mousemove",g,false);document.addEventListener("mouseup",b,false)}});var Editor=base2.Base.extend({tab_spacing:true,constructor:function(b){this.el=document.querySelector(b);this.lastSelection={};this.lineHeight=16;this.tab_nb_char=4;if(base2.detect("webkit")){this.tab_nb_char+=1}if(this.tab_spacing){this.tabulation="";for(var a=0;a<this.tab_nb_char;a++){this.tabulation+=" "}}else{this.tabulation="\t"}this._tab_detected=false;if(base2.detect("MSIE")){this.el.selectionStart=this.el.selectionEnd=0}this.el.addEventListener("keydown",this.handleKey.bindAsEventListener(this),false)},handleKey:function(a){c=a.keyCode;if(c==9){a.preventDefault();this.tab_selection();a.returnValue=false;return false}else{if(c==13){if(this.do_enter()){a.preventDefault();a.returnValue=false}return false}}return true},tab_selection:function(){if(this._is_tabbing){return}this._is_tabbing=true;var d=this;if(base2.detect("MSIE")){this._getIESelection()}if(!this._tab_detected){this._detect_tab()}var i=this.el.selectionStart;var a=this.el.selectionEnd;var e=this.el.value.substring(i,a);var g=this.el.scrollTop;var h=this.el.scrollLeft;var b=i;var f=a;if(e.length==0){this.el.value=this.el.value.substr(0,i)+this.tabulation+this.el.value.substr(a);b=i+this.tabulation.length;f=b}else{i=Math.max(0,this.el.value.substr(0,i).lastIndexOf("\n")+1);endText=this.el.value.substr(a);startText=this.el.value.substr(0,i);tmp=e.split("\n");e=this.tabulation+tmp.join("\n"+this.tabulation);this.el.value=startText+e+endText;b=i;f=this.el.value.indexOf("\n",startText.length+e.length);if(f==-1){f=this.el.value.length}}this.el.selectionStart=b;this.el.selectionEnd=f;if(base2.detect("MSIE")){this._setIESelection();setTimeout(function(){d._is_tabbing=false},100);this._is_tabbing=false}else{this._is_tabbing=false}this.el.scrollTop=g;this.el.scrollLeft=h},do_enter:function(){if(base2.detect("MSIE")){this._getIESelection()}var f=this.el.scrollTop;var g=this.el.scrollLeft;var h=this.el.selectionStart;var a=this.el.selectionEnd;var e=Math.max(0,this.el.value.substring(0,h).lastIndexOf("\n")+1);var b=this.el.value.substring(e,h);if(b.match(/^[ \t]+$/mg,"")){return false}var d=b.replace(/^([ \t]*).*/gm,"$1");if(d=="\n"||d=="\r"||d.length==0){return false}if(base2.detect("MSIE")||base2.detect("opera")){d="\r\n"+d}else{d="\n"+d}this.el.value=this.el.value.substring(0,h)+d+this.el.value.substring(a);this.area_select(h+d.length,0);this.el.scrollTop=f;this.el.scrollLeft=g;return true},area_select:function(b,a){b=Math.max(0,Math.min(this.el.value.length,b));end=Math.max(b,Math.min(this.el.value.length,b+a));if(base2.detect("MSIE")){this.el.selectionStart=b;this.el.selectionEnd=end;this._setIESelection()}else{if(base2.detect("opera")){this.el.setSelectionRange(0,0)}this.el.setSelectionRange(b,end)}},_detect_tab:function(){if(this.el.value.indexOf("\t")>0){this.tabulation="\t"}else{this.tabulation="";for(var a=0;a<this.tab_nb_char;a++){this.tabulation+=" "}}this._tab_detected=true},_getIESelection:function(){this.el.focus();var a=this.el.createTextRange();var b=a.duplicate();a.moveToBookmark(document.selection.createRange().getBookmark());a.moveEnd("character",this.el.value.length);this.el.selectionStart=this.el.value.length-a.text.length;b.moveToBookmark(document.selection.createRange().getBookmark());b.moveStart("character",-this.el.value.length);this.el.selectionEnd=b.text.length;if(this.el.selectionEnd<this.el.selectionStart){this.el.selectionEnd=this.el.selectionStart}},_setIESelection:function(){var a=this.el.value.substr(0,this.el.selectionStart).split("\n").length-1;var b=this.el.value.substr(0,this.el.selectionEnd).split("\n").length-1;var d=document.selection.createRange();d.moveToElementText(this.el);d.setEndPoint("EndToStart",d);d.collapse(true);d.moveStart("character",this.el.selectionStart-a);d.moveEnd("character",this.el.selectionEnd-b-(this.el.selectionStart-a));d.select()}});var Review=base2.Base.extend({constructor:function(){var b=this;this._reviews={};this.latest_add=null;document.querySelectorAll(".review-flag").forEach(function(e){p=base2.DOM.bind(e.parentNode);offsets=p.getOffsets();e.style.top=offsets.y+"px"});var d=document.createElement("img");d.id="ghost-reviewflag";d.setStyle({position:"absolute",left:"5.5%",cursor:"pointer"});d.classList.add("hidden");d.src="/static/images/comment-ghost.png";document.body.appendChild(d);this.ghostReview=d;this.ghostReview.addEventListener("mousedown",this._sourceMouseDown.bind(this),false);this.ghostReview.addEventListener("mouseup",this._sourceMouseUp.bind(this),false);this.ghostReview.addEventListener("mouseover",this._sourceMouseOver.bind(this),true);this.nb_lines=null;this.sourceRow=null;this.numRow=null;this._loading=false;var a=document.querySelector("table.numsTable");a.addEventListener("mousedown",this._sourceMouseDown.bind(this),false);a.addEventListener("mouseup",this._sourceMouseUp.bind(this),false);a.addEventListener("mouseover",this._sourceMouseOver.bind(this),true);a.addEventListener("mouseout",this._sourceMouseOut.bind(this),true);this.converter=new Showdown.converter();this.canRestart=true;window.addEventListener("close",function(f){b.canRestart=false},false);this._init_stomp()},_init_stomp:function(){var a=this;stomp=new STOMPClient();stomp.onopen=function(){};stomp.onerror=function(b){alert("Error: "+b)};stomp.onerrorframe=function(b){alert("Error: "+b.body)};stomp.onconnectedframe=function(){stomp.subscribe("/paste/"+snippet_id+"/"+revid,{exchange:""});stomp.subscribe("/paste/"+snippet_id,{exchange:""})};stomp.onmessageframe=function(b){a.handle_messages(b)};stomp.onclose=function(){if(a.canRestart){window.setTimeout("stomp.connect('localhost', 61613)",2000)}};stomp.connect("localhost",61613)},_notify:function(b){var a=document.querySelector("#notify-snippet");a.innerHTML=b;if(a.classList.has("hidden")){a.classList.remove("hidden")}setTimeout(function(){a.classList.add("hidden")},30000)},handle_messages:function(a){var j=base2.JSON.parse(a.body);var e=false;if(j.type=="review"){if(this.latest_add&&this.latest_add.nb_line==j.nb_line&&this.latest_add.reviews_count+1==j.reviews_count){e=true}var i=this._reviews[j.nb_line]||null;if(!i){var i=this._numRow(j.nb_line);if(!i){return}this._reviews[j.nb_line]=i}var b=i.querySelector("td");var f=b.querySelector("span.reviewflag");var h=false;if(!f){var g=document.createElement("span");g.classList.add("reviewflag");if(!e){g.classList.add("new")}g.appendChild(document.createTextNode(j.reviews_count));b.appendChild(g);h=true}else{line_count=parseInt(f.innerHTML);if(line_count<j.reviews_count){f.innerHTML=j.reviews_count;if(!f.classList.has("new")&&!e){f.classList.add("new")}if(!e&&j.nb_line==this.currentLineNumber){this.updateComments(j.nb_line)}h=true}}if(h&&!e){var d='a new review has been added to line <a href="#'+j.nb_line+'">#'+j.nb_line+"</a>.";this._notify(d)}}else{if(j.type=="update"){if(j.nb_revision==revid){return}var d='Past has been updated to <a href="/'+snippet_id+"?rev="+j.nb_revision+'">revision '+j.nb_revision+"</a>";this._notify(d)}else{if(j.type=="delete"){var d="Paste has been deleted.";this._notify(d)}}}},_sourceRow:function(a){var b=document.querySelector("td.lines table").rows;--a;return base2.DOM.bind(b[a])},_numRow:function(a){var b=document.querySelector("td.nums table").rows;--a;return base2.DOM.bind(b[a])},_lineNumberForRow:function(b){var a=0;while(b){++a;b=b.previousSibling}return a},_handleKey:function(a){if(a.keyCode==27){this.hideCommentBox();document.removeEventListener("keydown",arguments.callee,false)}},_selectRow:function(a,d){if(a!=this.nb_line){if(this.nb_line){this.numRow.classList.remove("selected");this.sourceRow.classList.remove("selected")}this.nb_line=a;this.numRow=d;this.sourceRow=this._sourceRow(a);this.numRow.classList.add("selected");this.sourceRow.classList.add("selected");if(!d.classList.has("hasreview")){var b=d.getOffsets();this.ghostReview.style.top=b.y-1+"px";this.ghostReview.numLine=a;this.ghostReview.classList.remove("hidden")}else{this.ghostReview.classList.add("hidden")}}},_sourceMouseOver:function(f){f.stopPropagation();var b=f.target;var d=f.target.parentNode;base2.DOM.bind(b);base2.DOM.bind(d);if(b==this.ghostReview&&!b.classList.has("hidden")){a=b.numLine;g=this._numRow(a);this._selectRow(a,g)}else{if(b.classList.has("line-number")||d.classList.has("line-number")){var g=b.enclosingNodeOrSelfWithNodeName("tr");base2.DOM.bind(g);var a=this._lineNumberForRow(g);this._selectRow(a,g)}}return},_sourceMouseOut:function(a){if(!this.nb_line){return}relTarget=base2.DOM.bind(a.relatedTarget||a.toElement);if(typeof relTarget=="undefined"){return}if(this.ghostReview&&relTarget!=this.ghostReview){this.ghostReview.classList.add("hidden")}if(relTarget.tagName=="SPAN"){relTarget=base2.DOM.bind(relTarget.parentNode)}if(!relTarget.classList.has("line-number")){this.numRow.classList.remove("selected");this.sourceRow.classList.remove("selected");this.nb_line=this.sourceRow=this.numRow=null}},_sourceMouseDown:function(b){var a=b.target;base2.DOM.bind(a);if(this.ghostReview&&a==this.ghostReview){this.currentRow=this._numRow(this.ghostReview.numLine);this.currentLineNumber=this.ghostReview.numLine}else{if(a.tagName=="SPAN"){a=base2.DOM.bind(a.parentNode)}if(!a.classList.has("line-number")){return}this.currentRow=base2.DOM.bind(a.enclosingNodeOrSelfWithNodeName("tr"));this.currentLineNumber=this._lineNumberForRow(this.currentRow)}},_sourceMouseUp:function(h){var f=h.target;var g=h.target.parentNode;base2.DOM.bind(f);base2.DOM.bind(g);if(this.ghostReview&&f!=this.ghostReview){if(!f.classList.has("line-number")&&(!g.classList.has("line-number"))){return}}this.el=this.currentRow.querySelector("td");if(this.ghostReview&&!this.ghostReview.classList.has("hidden")){this.ghostReview.classList.add("hidden")}var a=this.el.querySelector("span.reviewflag");if(!a){var d=document.createElement("span");d.classList.add("reviewflag");d.appendChild(document.createTextNode("0"));this.el.appendChild(d)}else{if(a.classList.has("new")){a.classList.remove("new")}}var b=this._lineNumberForRow(this.currentRow);var i=this._sourceRow(b);if(this.currentRow.classList.has("selected")){this.currentRow.classList.remove("selected");this.sourceRow.classList.remove("selected")}i.classList.add("highlighted-line");this.currentRow.classList.add("highlighted-line");this.showCommentBox()},buildCommentBox:function(s){var o=this;this.overlay=document.createElement("div");this.overlay.id="overlay";this.overlay.setStyle({"z-index":"9999"});this.overlay.setOpacity("0");var m=document.createElement("div");m.classList.add("comment-box");m.classList.add("hidden");m.setStyle("z-index: 10000");m.setOpacity("0.9");this.divComment=this.rootLayers=m;document.body.appendChild(this.overlay);document.body.appendChild(this.divComment);var s=this._lineNumberForRow(this.currentRow);var h="/"+snippet_id+"/reviews/"+s;var t="/"+snippet_id+"/review/"+s;if(typeof revid!="undefined"){h+="?rev="+revid;t+="?rev="+revid}var a=document.createElement("form");a.action=t;a.id="freview";var i=document.createElement("h3");i.classList.add("wtitle");i.appendChild(document.createTextNode("Add your review to line "+s+" "));var r=document.createElement("a");r.href="#";r.innerHTML="(markdown syntax supported)";r.addEventListener("click",function(w){w.preventDefault();window.open("http://daringfireball.net/projects/markdown/dingus");w.stopPropagation();return false},false);i.appendChild(r);a.appendChild(i);var f=document.createElement("div");f.id="row-form";var n=document.createElement("textarea");n.id="new_review";n.name="new_review";n.setAttribute("cols",70);n.setAttribute("rows",5);f.appendChild(n);a.appendChild(f);var q=document.createElement("p");var v=document.createElement("span");v.classList.add("rby");var j=document.createElement("label");j.setAttribute("for","rpseudo");j.innerHTML="nickname: ";v.appendChild(j);var d=document.createElement("input");d.type="text";d.id="rpseudo";d.value="anonymous";v.appendChild(d);q.appendChild(v);var e=document.createElement("span");e.classList.add("ractions");var k=document.createElement("input");k.type="submit";k.name=k.id="sreview";k.value="save comment";e.appendChild(k);var l=document.createElement("input");l.type="submit";l.id=l.name="bclose";l.value="close";e.appendChild(l);q.appendChild(e);a.appendChild(q);m.appendChild(a);var u=document.createElement("h3");u.appendChild(document.createTextNode("All comments for this line"));m.appendChild(u);var b=document.createElement("div");b.id="reviews-list";b.classList.add("hidden");m.appendChild(b);var g=document.createElement("div");g.classList.add("loading");g.appendChild(document.createTextNode("loading comments for line"));m.appendChild(g);l.addEventListener("click",function(w){w.preventDefault();o.hideCommentBox();return false},false);k.addEventListener("click",this.add_review.bind(this),false);if(!base2.detect("webkit")){new Resizeable("#new_review",120)}new Ajax.request({url:h,dataType:"json",contentType:"application/json",method:"GET",success:function(A){if(A.ok){if(A.r.reviews){var z=document.createElement("ul");for(var x=0;x<A.r.reviews.length;x++){var w=document.createElement("li");var C=document.createElement("time");C.title="GMT";C.setAttribute("datetime",A.r.reviews[x]["created"]);C.textContent=A.r.reviews[x]["fcreated"];w.innerHTML=o.converter.makeHtml(A.r.reviews[x]["comment"]);var B=document.createElement("div");B.classList.add("metadata");B.appendChild(document.createTextNode(A.r.reviews[x]["nickname"]));B.appendChild(C);w.appendChild(B);z.appendChild(w)}b.appendChild(z);remove(g);b.classList.remove("hidden");localizeDates()}}}})},_make_reviews_list:function(h,d,e){if(!d){d=document.createElement("ul");for(var b=0;b<e.r.length;b++){var a=document.createElement("li");var g=document.createElement("time");g.title="GMT";g.setAttribute("datetime",e.r[b]["created"]);g.textContent=e.r[b]["fcreated"];a.innerHTML=this.converter.makeHtml(e.r[b]["comment"]);var f=document.createElement("div");f.classList.add("metadata");f.appendChild(document.createTextNode(e.r[b]["nickname"]));f.appendChild(g);a.appendChild(f);d.appendChild(a)}h.appendChild(d)}else{for(var b=0;b<e.r.length;b++){var a=document.createElement("li");var g=document.createElement("time");g.title="GMT";g.setAttribute("datetime",e.r[b]["created"]);g.textContent=e.r[b]["fcreated"];a.innerHTML=this.converter.makeHtml(e.r[b]["comment"]);var f=document.createElement("div");f.classList.add("metadata");f.appendChild(document.createTextNode(e.r[b]["nickname"]));f.appendChild(g);a.appendChild(f);d.insertBefore(a,d.firstChild)}}localizeDates()},add_review:function(i){i.preventDefault();var l=this;var a=this.divComment.querySelector("#freview").action;var k=this.divComment.querySelector("textarea");var b=k.value;var g=document.getElementById("rpseudo").value;if(b){var d=this._lineNumberForRow(this.currentRow);var f=this.divComment.querySelector("#reviews-list");var h=f.querySelector("ul");var j=0;if(h){j=h.querySelectorAll("li").length}this.latest_add={nb_line:d,reviews_count:j};new Ajax.request({url:a,dataType:"json",contentType:"application/json",data:this.toJSON({new_review:b,nickname:g,nb_lines:j}),method:"POST",success:function(e){if(e.ok){l._make_reviews_list(f,h,e);k.value="";k.focus()}else{l.latest_add=null}}})}},updateComments:function(f){var b=this;var f=f;if(f!=this.currentLineNumber){return}var g=this.divComment.querySelector("#reviews-list");var e=g.querySelector("ul");var a=0;if(e){a=e.querySelectorAll("li").length}var d="/"+snippet_id+"/reviewset/"+f+"?rev="+revid+"&f="+a;new Ajax.request({url:d,dataType:"json",contentType:"application/json",method:"GET",success:function(h){if(h.ok){if(f!=this.currentLineNumber&&(e&&a!=e.querySelectorAll("li").length)){return}b._make_reviews_list(g,e,h)}}})},hideCommentBox:function(){reviewflag=this.el.querySelector("span.reviewflag");var a=0;if(reviewflag){a=parseInt(reviewflag.innerHTML)}if(a==0){remove(reviewflag)}this.currentLineNumber=null;this.currentRow.classList.remove("highlighted-line");var b=this._lineNumberForRow(this.currentRow);var d=this._sourceRow(b);d.classList.remove("highlighted-line");this.divComment.classList.add("hidden");remove(this.divComment);remove(this.overlay);if(this.hideIfClickOutside){document.removeEventListener("click",this.hideIfClickOutside,false);this.hideIfClickOutside=null}this.isDragging=false;this.divComment.removeEventListener("mousedown",this.beginDragCB,false);document.removeEventListener("mousemove",this.dragCB,false);document.removeEventListener("mouseup",this.endDragCB,false)},setCommentBoxPosition:function(){var b=this.el.getOffsets();var a=[b.y+this.el.outerHeight()+5,b.x+this.el.offsetWidth+20];this.divComment.style.top=a[0]+"px";this.divComment.style.left=a[1]+"px";window.scrollTo(document.body.scrollLeft,b.y-64);this.divComment.classList.remove("hidden");this.divComment.querySelector("textarea").focus()},insideCommentBox:function(a){var b=this.divComment.getOffsets();b.right=b.x+this.divComment.outerWidth();b.bottom=b.y+this.divComment.outerHeight();point=pointer(a);return point.y<b.bottom&&point.y>b.y&&point.x<b.right&&point.x>b.x},currentDelta:function(){return([parseInt(this.divComment.getStyle("left")||"0"),parseInt(this.divComment.getStyle("top")||"0")])},beginDragCB:function(i){var b=this;if(this.isDragging){return false}base2.DOM.bind(i.target);if(!i.target.classList.has("wtitle")){return}var a=pointer(i);this.boxDimensions=this.divComment.getDimensions();if(i.target.getStyle("overflow")!="hidden"){var g=getScrollbarWidth();var f=this.divComment.getOffsets();var h=f.x+this.boxDimensions.width-g;if(a.x>h){return}}this.isDragging=true;this.old_cursor=this.divComment.getStyle("cursor");this.divComment.style.cursor="move";var j=this.divComment.cumulativeOffset();this.offset=[a.x-j.x,a.y-j.y];this.pointer=a;var d=this._getWindowScroll(window);this.scroll=[d.left,d.top];document.body.focus();if(base2.detect("MSIE")){this.old_onselectstart=document.onselectstart;document.onselectstart=function(k){return false}}i.preventDefault();i.stopPropagation();return false},dragCB:function(g){if(!this.isDragging){return}if(!g){g=window.event}var g=g;var a=pointer(g);var i=this.divComment.cumulativeOffset();var h=this.currentDelta();i.x-=h[0];i.y-=h[1];var f=[(a.x-i.x-this.offset[0]),(a.y-i.y-this.offset[1])];this.divComment.style.left=f[0]+"px";this.divComment.style.top=f[1]+"px";if(base2.detect("webkit")){window.scrollBy(0,0)}var b=this;setTimeout(function(){var d=f[1]+b.divComment.outerHeight();var j=f[0]+b.divComment.outerWidth();var e=b._getWindowScroll(window);var l=e.left;var k=e.top;if(j>e.width-15){l=j}if(d>e.height-15){k=d}if(l!=e.left||k!=e.top){window.scrollTo(l,k)}b.pointer=a},0);g.preventDefault();g.stopPropagation()},endDragCB:function(a){if(!this.isDragging){return}this.isDragging=false;if(base2.detect("MSIE")){document.onselectstart=this.old_onselectstart}this.divComment.style.cursor=this.old_cursor},showCommentBox:function(){this.buildCommentBox();this.divComment.classList.remove("hidden");this.setCommentBoxPosition();this.divComment.addEventListener("mousedown",this.beginDragCB.bind(this),false);document.addEventListener("mousemove",this.dragCB.bind(this),false);document.addEventListener("mouseup",this.endDragCB.bind(this),false);var a=this;this.hideIfClickOutside=function(b){var d=base2.DOM.bind(b.target);if(a.ghostReview&&d==a.ghostReview){return}if(d.tagName=="SPAN"){d=d.parentNode}if(d!=a.el&&!a.insideCommentBox(b)){a.hideCommentBox()}};document.addEventListener("click",this.hideIfClickOutside,false);document.addEventListener("keydown",this._handleKey.bind(this),false)},toJSON:function(a){return a!==null?base2.JSON.toString(a):null},_getWindowScroll:function(w){var T,L,W,H;with(w.document){if(w.document.documentElement&&documentElement.scrollTop){T=documentElement.scrollTop;L=documentElement.scrollLeft}else{if(w.document.body){T=body.scrollTop;L=body.scrollLeft}}if(w.innerWidth){W=w.innerWidth;H=w.innerHeight}else{if(w.document.documentElement&&documentElement.clientWidth){W=documentElement.clientWidth;H=documentElement.clientHeight}else{W=body.offsetWidth;H=body.offsetHeight}}}return{top:T,left:L,width:W,height:H}}});var Home=base2.Base.extend({constructor:function(){if(!base2.detect("webkit")){new Resizeable("#paste_snippet")}new Editor("#paste_snippet");this.privacy=document.querySelector(".privacy");this.privacy.addEventListener("click",this.handlePrivacy.bind(this),false);this.showPrivacy=false;if(this.privacy.classList.has("setPrivacy")){this.showPrivacy=true}document.querySelector("#paste_snippet").focus()},handlePrivacy:function(h){var g=document.querySelector("#paste_privacy");var b=document.querySelector("#paste_password");var d=b.parentNode;base2.DOM.bind(d);if(this.showPrivacy&&b.value!=""&&g.options[g.options.selectedIndex].value!="open"){y=window.confirm("Are you sure you want to close privacy settings ? By doing this, you will allow everyone to view and edit paste. Click OK to continue.");if(!y){return}}var f=document.querySelector("#privacy");this.privacy.classList.toggle("setPrivacy");f.classList.toggle("hidden");this.showPrivacy=!this.showPrivacy;var a=function(i){if(d.classList.has("hidden")&&g.options[g.options.selectedIndex].value!="open"){d.classList.remove("hidden")}else{if(!d.classList.has("hidden")&&g.options[g.selectedIndex].value=="open"){d.classList.add("hidden")}}};if(this.showPrivacy){a();g.addEventListener("change",a,false)}else{b.value="";g.options.selectedIndex=0;if(d.classList.has("errors")){d.classList.remove("errors")}try{g.removeEventListener("change",a,false)}catch(h){}}}});var Friendpaste=base2.Base.extend({snippet:null,snippet_edit:null,constructor:function(){var b=this;var e=document.querySelector(".e");var d=document.querySelectorAll(".cancel");var f=document.querySelector(".show-history");if(e){e.addEventListener("click",this.do_edit.bindAsEventListener(this),false)}if(d){d.forEach(function(g){g.addEventListener("click",b.do_cancel.bindAsEventListener(b),false)})}if(f){f.addEventListener("click",this.do_history.bindAsEventListener(this),false)}this.snippet=document.querySelector("#view");this.snippet_edit=document.querySelector("#edit");this.revisions=document.querySelector("#revisions");this.bdelete=document.querySelector("#snippet_actions li.delete");if(this.bdelete!=null){this.block=document.querySelector("#snippet_actions li.lock");this.adelete=document.querySelector("#snippet_actions li.delete a");this.alock=document.querySelector("#snippet_actions li.lock a");this._deleteListener=function(g){g.preventDefault();this.removeEventListener("click",arguments.callee,false);b.alock.removeEventListener("click",b._lockListener,false);b.block.classList.add("disabled");b.deletePaste()};this._lockListener=function(g){g.preventDefault();this.removeEventListener("click",arguments.callee,false);b.adelete.removeEventListener("click",b._deleteListener,false);b.bdelete.classList.add("disabled");b.lockPaste()};this.listenPasteActions()}var a=/#(.+)$/.exec(window.location);if(a&&a[1]=="edit"){this.snippet.classList.add("hidden");this.snippet_edit.classList.remove("hidden")}else{this.editing=true}this.editing=false;this.show_history=false;if(!base2.detect("webkit")){new Resizeable("#paste_snippet")}new Editor("#paste_snippet");new Review();this.setSettings();document.querySelector("#change-theme").addEventListener("change",this.setTheme.bindAsEventListener(this),false);document.querySelector("#show-linenos").addEventListener("click",this.toggleLineNumber.bindAsEventListener(this),false)},listenPasteActions:function(){this.adelete.addEventListener("click",this._deleteListener,false);this.alock.addEventListener("click",this._lockListener,false)},deletePaste:function(){var b=this;var d=this.formPassword("delete","Delete paste");var a=base2.DOM.bind(this.adelete.parentNode);this.adelete.style.display="none";a.appendChild(d);a.querySelector(".password").focus();a.querySelector("input.ano").addEventListener("click",function(f){f.preventDefault();this.removeEventListener("click",arguments.callee,false);b.adelete.style.display="inline";b.block.classList.remove("disabled");remove(d);b.listenPasteActions()},false);return false},lockPaste:function(){var b=this;if(!this.snippet_edit){var d=this.formPassword("unlock","Unlock paste")}else{var d=this.formPassword("lock","Lock paste")}var a=base2.DOM.bind(this.alock.parentNode);a.appendChild(d);a.querySelector(".password").focus();this.alock.style.display="none";a.querySelector("input.ano").addEventListener("click",function(f){f.preventDefault();this.removeEventListener("click",arguments.callee,false);b.alock.style.display="inline";b.bdelete.classList.remove("disabled");remove(d);b.listenPasteActions()},false);return false},formPassword:function(a,b){url="/"+snippet_id+"/"+a;form=document.createElement("form");form.className="fsnippet_action";form.action=url;form.method="POST";h4=document.createElement("h4");h4.appendChild(document.createTextNode(b));form.appendChild(h4);p=document.createElement("p");p.appendChild(document.createTextNode("Enter code entered when you create the paste to confirm:"));form.appendChild(p);label=document.createElement("label");label.setAttribute("for","edit_code");label.appendChild(document.createTextNode("Code: "));form.appendChild(label);input=document.createElement("input");input.type="password";input.name="edit_code";input.className="password";form.appendChild(input);submit=document.createElement("input");submit.name="f"+a;submit.type="submit";submit.value=a.substring(0,1).toUpperCase()+a.substring(1,a.length);submit.className="ayes";form.appendChild(submit);cancel=document.createElement("input");cancel.type="submit";cancel.value="Cancel";cancel.className="ano";form.appendChild(cancel);return form},handleSnippetAction:function(a){},do_edit:function(a){a.preventDefault();this._edit();return false},_edit:function(){this.ghostReview=document.querySelector("#ghost-reviewflag");if(this.ghostReview){this.ghostReview.classList.add("hidden")}this.snippet.classList.add("hidden");this.snippet_edit.classList.remove("hidden");this.editing=true},do_cancel:function(a){a.preventDefault();this._cancel();return false},_cancel:function(){this.editing=false;if(this.ghostReview){this.ghostReview.classList.remove("hidden");this.ghostReview=null}if(this.snippet_edit&&!this.snippet_edit.classList.has("hidden")){this.snippet_edit.classList.add("hidden")}if(!this.revisions.classList.has("hidden")){this.revisions.classList.add("hidden")}this.snippet.classList.remove("hidden")},toggleLineNumber:function(a){document.querySelector("#paste").classList.toggle("hidenos");this.saveSettings()},setSettings:function(){new Ajax.request({url:"/settings",dataType:"json",contentType:"application/json",method:"GET",success:function(a){showlineos=a.settings["showlinenos"];if(typeof(showlineos)!="undefined"){document.querySelector("#show-linenos").checked=a.settings["showlinenos"];if(!a.settings["showlinenos"]){document.querySelector("#paste").classList.add("hidenos")}}if(typeof(a.settings["theme"])!="undefined"&&a.settings["theme"]){theme=a.settings["theme"]}else{theme="default"}document.querySelector("#change-theme").value=theme;document.querySelectorAll('link[rel="stylesheet"][title]').forEach(function(b){if(b.getAttribute("title")=="syntax_theme"){b.href="/static/css/"+theme+".css"}})}})},saveSettings:function(){var d=document.querySelector("#factions");var b=true;var a=document.querySelector("#show-linenos:checked");if(!a){b=false}new Ajax.request({url:d.action,dataType:"json",contentType:"application/json",method:"POST",data:this.toJSON({theme:document.querySelector("#change-theme").value,showlinenos:b}),success:function(e){}})},setTheme:function(b){var a=b.target.value;document.querySelectorAll('link[rel="stylesheet"][title]').forEach(function(d){if(d.getAttribute("title")=="syntax_theme"){d.href="/static/css/"+a+".css"}});this.saveSettings()},do_history:function(b){b.preventDefault();this.ghostReview=document.querySelector("#ghost-reviewflag");if(this.ghostReview){this.ghostReview.classList.add("hidden")}this.show_history=true;url="/"+snippet_id+"/revisions";if(typeof(revid)!="undefined"){url=url+"?rev="+revid}var a=this;new Ajax.get(url,null,function(f,d){document.querySelector(".pasteHistory").innerHTML="";var e="";f.forEach(function(h,g){e+='<tr><td><time title="GMT" datetime="'+h.updated+'">'+h.updated+'</time></td><td class="rev">rev. <a href=\'/'+h.pasteid+"?rev="+h.nb_revision+"'>"+h.nb_revision+'</a></td><td class="changeset"><a href=\'/'+h.pasteid+"/changeset?rev="+h.nb_revision+"'>Diff</a></td><td class=\"view-rev\"><a href='/"+h.pasteid+"?rev="+h.nb_revision+"'>View</a></td></tr>"});e='<table class="revisionstable">'+e+"</table>";document.querySelector(".pasteHistory").innerHTML=e;a.snippet.classList.add("hidden");a.revisions.classList.remove("hidden");localizeDates()},"json");return false},toJSON:function(a){return a!==null?base2.JSON.toString(a):null}});var Diff=base2.Base.extend({constructor:function(){this.sourcetable=document.querySelector(".sourceTable");this.difftabular=document.querySelector(".difftabular");this.switcher=document.querySelector("#switch");this.sourcetable.classList.add("hidden");this.switcher.innerHTML='<span class="stab active">Tabular</span><span class="suni">Unified</span>';this.stab=this.switcher.querySelector(".stab");this.suni=this.switcher.querySelector(".suni");var a=this;this.stab.addEventListener("click",this.setTabular.bindAsEventListener(this),false);this.suni.addEventListener("click",this.setUnified.bindAsEventListener(this),false);this.setSettings();document.querySelector("#show-linenos").addEventListener("click",this.toggleLineNumber.bindAsEventListener(this),false)},setTabular:function(a){a.preventDefault();if(!this.sourcetable.classList.has("hidden")){this.sourcetable.classList.add("hidden")}this.difftabular.classList.remove("hidden");this.suni.classList.remove("active");this.stab.classList.add("active")},setUnified:function(a){a.preventDefault();if(!this.difftabular.classList.has("hidden")){this.difftabular.classList.add("hidden")}this.sourcetable.classList.remove("hidden");this.stab.classList.remove("active");this.suni.classList.add("active")},toggleLineNumber:function(a){document.querySelector("#paste").classList.toggle("hidenos");this.saveSettings()},setSettings:function(){Ajax.request({url:"/settings",dataType:"json",contentType:"application/json",method:"GET",success:function(a){document.querySelector("#show-linenos").checked=a.settings["showlinenos"];if(!a.settings["showlinenos"]){document.querySelector("#paste").classList.add("hidenos")}}})},saveSettings:function(){var d=document.querySelector("#factions");var b=true;var a=document.querySelector("#show-linenos:checked");if(!a){b=false}Ajax.request({url:d.action,dataType:"json",contentType:"application/json",method:"POST",data:this.toJSON({showlinenos:b}),success:function(e){}})},toJSON:function(a){return a!==null?base2.JSON.toString(a):null}});
+var Showdown={};Showdown.converter=function(){var a;var k;var D;var j=0;this.makeHtml=function(K){a=new Array();k=new Array();D=new Array();K=K.replace(/~/g,"~T");K=K.replace(/\$/g,"~D");K=K.replace(/\r\n/g,"\n");K=K.replace(/\r/g,"\n");K="\n\n"+K+"\n\n";K=C(K);K=K.replace(/^[ \t]+$/mg,"");K=n(K);K=e(K);K=J(K);K=s(K);K=K.replace(/~D/g,"$$");K=K.replace(/~T/g,"~");return K};var e=function(K){var K=K.replace(/^[ ]{0,3}\[(.+)\]:[ \t]*\n?[ \t]*<?(\S+?)>?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|\Z)/gm,function(N,P,O,M,L){P=P.toLowerCase();a[P]=i(O);if(M){return M+L}else{if(L){k[P]=L.replace(/"/g,"&quot;")}}return""});return K};var n=function(M){M=M.replace(/\n/g,"\n\n");var L="p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del";var K="p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math";M=M.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del)\b[^\r]*?\n<\/\2>[ \t]*(?=\n+))/gm,A);M=M.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math)\b[^\r]*?.*<\/\2>[ \t]*(?=\n+)\n)/gm,A);M=M.replace(/(\n[ ]{0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,A);M=M.replace(/(\n\n[ ]{0,3}<!(--[^\r]*?--\s*)+>[ \t]*(?=\n{2,}))/g,A);M=M.replace(/(?:\n\n)([ ]{0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,A);M=M.replace(/\n\n/g,"\n");return M};var A=function(K,L){var M=L;M=M.replace(/\n\n/g,"\n");M=M.replace(/^\n/,"");M=M.replace(/\n+$/g,"");M="\n\n~K"+(D.push(M)-1)+"K\n\n";return M};var J=function(L){L=g(L);var K=q("<hr />");L=L.replace(/^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$/gm,K);L=L.replace(/^[ ]{0,2}([ ]?\-[ ]?){3,}[ \t]*$/gm,K);L=L.replace(/^[ ]{0,2}([ ]?\_[ ]?){3,}[ \t]*$/gm,K);L=H(L);L=b(L);L=w(L);L=n(L);L=h(L);return L};var t=function(K){K=F(K);K=m(K);K=f(K);K=I(K);K=B(K);K=o(K);K=i(K);K=d(K);K=K.replace(/  +\n/g," <br />\n");return K};var m=function(L){var K=/(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|<!(--.*?--\s*)+>)/gi;L=L.replace(K,function(N){var M=N.replace(/(.)<\/?code>(?=.)/g,"$1`");M=z(M,"\\`*_");return M});return L};var B=function(K){K=K.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,G);K=K.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()<?(.*?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,G);K=K.replace(/(\[([^\[\]]+)\])()()()()()/g,G);return K};var G=function(Q,W,V,U,T,S,P,O){if(O==undefined){O=""}var N=W;var L=V;var M=U.toLowerCase();var K=T;var R=O;if(K==""){if(M==""){M=L.toLowerCase().replace(/ ?\n/g," ")}K="#"+M;if(a[M]!=undefined){K=a[M];if(k[M]!=undefined){R=k[M]}}else{if(N.search(/\(\s*\)$/m)>-1){K=""}else{return N}}}K=z(K,"*_");var X='<a href="'+K+'"';if(R!=""){R=R.replace(/"/g,"&quot;");R=z(R,"*_");X+=' title="'+R+'"'}X+=">"+L+"</a>";return X};var I=function(K){K=K.replace(/(!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,v);K=K.replace(/(!\[(.*?)\]\s?\([ \t]*()<?(\S+?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,v);return K};var v=function(Q,W,V,U,T,S,P,O){var N=W;var M=V;var L=U.toLowerCase();var K=T;var R=O;if(!R){R=""}if(K==""){if(L==""){L=M.toLowerCase().replace(/ ?\n/g," ")}K="#"+L;if(a[L]!=undefined){K=a[L];if(k[L]!=undefined){R=k[L]}}else{return N}}M=M.replace(/"/g,"&quot;");K=z(K,"*_");var X='<img src="'+K+'" alt="'+M+'"';R=R.replace(/"/g,"&quot;");R=z(R,"*_");X+=' title="'+R+'"';X+=" />";return X};var g=function(K){K=K.replace(/^(.+)[ \t]*\n=+[ \t]*\n+/gm,function(L,M){return q("<h1>"+t(M)+"</h1>")});K=K.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm,function(M,L){return q("<h2>"+t(L)+"</h2>")});K=K.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm,function(L,O,N){var M=O.length;return q("<h"+M+">"+t(N)+"</h"+M+">")});return K};var r;var H=function(L){L+="~0";var K=/^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;if(j){L=L.replace(K,function(N,Q,P){var R=Q;var O=(P.search(/[*+-]/g)>-1)?"ul":"ol";R=R.replace(/\n{2,}/g,"\n\n\n");var M=r(R);M=M.replace(/\s+$/,"");M="<"+O+">"+M+"</"+O+">\n";return M})}else{K=/(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/g;L=L.replace(K,function(O,S,Q,N){var R=S;var T=Q;var P=(N.search(/[*+-]/g)>-1)?"ul":"ol";var T=T.replace(/\n{2,}/g,"\n\n\n");var M=r(T);M=R+"<"+P+">\n"+M+"</"+P+">\n";return M})}L=L.replace(/~0/,"");return L};r=function(K){j++;K=K.replace(/\n{2,}$/,"\n");K+="~0";K=K.replace(/(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+([^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm,function(N,P,O,M,L){var R=L;var Q=P;var S=O;if(Q||(R.search(/\n{2,}/)>-1)){R=J(u(R))}else{R=H(u(R));R=R.replace(/\n$/,"");R=t(R)}return"<li>"+R+"</li>\n"});K=K.replace(/~0/g,"");j--;return K};var b=function(K){K+="~0";K=K.replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,function(L,N,M){var O=N;var P=M;O=x(u(O));O=C(O);O=O.replace(/^\n+/g,"");O=O.replace(/\n+$/g,"");O="<pre><code>"+O+"\n</code></pre>";return q(O)+P});K=K.replace(/~0/,"");return K};var q=function(K){K=K.replace(/(^\n+|\n+$)/g,"");return"\n\n~K"+(D.push(K)-1)+"K\n\n"};var F=function(K){K=K.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,function(N,P,O,M,L){var Q=M;Q=Q.replace(/^([ \t]*)/g,"");Q=Q.replace(/[ \t]*$/g,"");Q=x(Q);return P+"<code>"+Q+"</code>"});return K};var x=function(K){K=K.replace(/&/g,"&amp;");K=K.replace(/</g,"&lt;");K=K.replace(/>/g,"&gt;");K=z(K,"*_{}[]\\",false);return K};var d=function(K){K=K.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g,"<strong>$2</strong>");K=K.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g,"<em>$2</em>");return K};var w=function(K){K=K.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm,function(L,M){var N=M;N=N.replace(/^[ \t]*>[ \t]?/gm,"~0");N=N.replace(/~0/g,"");N=N.replace(/^[ \t]+$/gm,"");N=J(N);N=N.replace(/(^|\n)/g,"$1  ");N=N.replace(/(\s*<pre>[^\r]+?<\/pre>)/gm,function(O,P){var Q=P;Q=Q.replace(/^  /mg,"~0");Q=Q.replace(/~0/g,"");return Q});return q("<blockquote>\n"+N+"\n</blockquote>")});return K};var h=function(Q){Q=Q.replace(/^\n+/g,"");Q=Q.replace(/\n+$/g,"");var P=Q.split(/\n{2,}/g);var M=new Array();var K=P.length;for(var L=0;L<K;L++){var O=P[L];if(O.search(/~K(\d+)K/g)>=0){M.push(O)}else{if(O.search(/\S/)>=0){O=t(O);O=O.replace(/^([ \t]*)/g,"<p>");O+="</p>";M.push(O)}}}K=M.length;for(var L=0;L<K;L++){while(M[L].search(/~K(\d+)K/)>=0){var N=D[RegExp.$1];N=N.replace(/\$/g,"$$$$");M[L]=M[L].replace(/~K\d+K/,N)}}return M.join("\n\n")};var i=function(K){K=K.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g,"&amp;");K=K.replace(/<(?![a-z\/?\$!])/gi,"&lt;");return K};var f=function(K){K=K.replace(/\\(\\)/g,l);K=K.replace(/\\([`*_{}\[\]()>#+-.!])/g,l);return K};var o=function(K){K=K.replace(/<((https?|ftp|dict):[^'">\s]+)>/gi,'<a href="$1">$1</a>');K=K.replace(/<(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi,function(L,M){return E(s(M))});return K};var E=function(M){function L(O){var N="0123456789ABCDEF";var P=O.charCodeAt(0);return(N.charAt(P>>4)+N.charAt(P&15))}var K=[function(N){return"&#"+N.charCodeAt(0)+";"},function(N){return"&#x"+L(N)+";"},function(N){return N}];M="mailto:"+M;M=M.replace(/./g,function(N){if(N=="@"){N=K[Math.floor(Math.random()*2)](N)}else{if(N!=":"){var O=Math.random();N=(O>0.9?K[2](N):O>0.45?K[1](N):K[0](N))}}return N});M='<a href="'+M+'">'+M+"</a>";M=M.replace(/">.+:/g,'">');return M};var s=function(K){K=K.replace(/~E(\d+)E/g,function(L,N){var M=parseInt(N);return String.fromCharCode(M)});return K};var u=function(K){K=K.replace(/^(\t|[ ]{1,4})/gm,"~0");K=K.replace(/~0/g,"");return K};var C=function(K){K=K.replace(/\t(?=\t)/g,"    ");K=K.replace(/\t/g,"~A~B");K=K.replace(/~B(.+?)~A/g,function(L,O,N){var Q=O;var M=4-Q.length%4;for(var P=0;P<M;P++){Q+=" "}return Q});K=K.replace(/~A/g,"    ");K=K.replace(/~B/g,"");return K};var z=function(O,L,M){var K="(["+L.replace(/([\[\]\\])/g,"\\$1")+"])";if(M){K="\\\\"+K}var N=new RegExp(K,"g");O=O.replace(N,l);return O};var l=function(K,M){var L=M.charCodeAt(0);return"~E"+L+"E"}};var Resizeable=base2.Base.extend({min_height:280,constructor:function(e,d){var b=this;if(d){this.min_height=d}var a=document.createElement("div");a.className="grippie";a.style.cursor="s-resize";base2.DOM.bind(a);document.querySelectorAll(e).forEach(function(f){f.parentNode.appendChild(a);a.addEventListener("mousedown",function(g){g.preventDefault();g.stopPropagation();b.handleResize(g,f);return false},false)})},handleResize:function(h,d){var a=this;var i=d;var j={x:h.screenX,y:h.screenY};var f={width:i.offsetWidth,height:i.offsetHeight};var g=function(l){l.preventDefault();var m=l.screenY-j.y;if(m){var k=f.height+m;if(k>a.min_height){i.style.height=k+"px";f.height=k;j.y=l.screenY}}return false};var b=function(k){document.removeEventListener("mousemove",g,false);this.removeEventListener("mouseup",arguments.callee,false);return false};document.addEventListener("mousemove",g,false);document.addEventListener("mouseup",b,false)}});var Editor=base2.Base.extend({tab_spacing:true,constructor:function(b){this.el=document.querySelector(b);this.lastSelection={};this.lineHeight=16;this.tab_nb_char=4;if(base2.detect("webkit")){this.tab_nb_char+=1}if(this.tab_spacing){this.tabulation="";for(var a=0;a<this.tab_nb_char;a++){this.tabulation+=" "}}else{this.tabulation="\t"}this._tab_detected=false;if(base2.detect("MSIE")){this.el.selectionStart=this.el.selectionEnd=0}this.el.addEventListener("keydown",this.handleKey.bindAsEventListener(this),false)},handleKey:function(a){c=a.keyCode;if(c==9){a.preventDefault();this.tab_selection();a.returnValue=false;return false}else{if(c==13){if(this.do_enter()){a.preventDefault();a.returnValue=false}return false}}return true},tab_selection:function(){if(this._is_tabbing){return}this._is_tabbing=true;var d=this;if(base2.detect("MSIE")){this._getIESelection()}if(!this._tab_detected){this._detect_tab()}var i=this.el.selectionStart;var a=this.el.selectionEnd;var e=this.el.value.substring(i,a);var g=this.el.scrollTop;var h=this.el.scrollLeft;var b=i;var f=a;if(e.length==0){this.el.value=this.el.value.substr(0,i)+this.tabulation+this.el.value.substr(a);b=i+this.tabulation.length;f=b}else{i=Math.max(0,this.el.value.substr(0,i).lastIndexOf("\n")+1);endText=this.el.value.substr(a);startText=this.el.value.substr(0,i);tmp=e.split("\n");e=this.tabulation+tmp.join("\n"+this.tabulation);this.el.value=startText+e+endText;b=i;f=this.el.value.indexOf("\n",startText.length+e.length);if(f==-1){f=this.el.value.length}}this.el.selectionStart=b;this.el.selectionEnd=f;if(base2.detect("MSIE")){this._setIESelection();setTimeout(function(){d._is_tabbing=false},100);this._is_tabbing=false}else{this._is_tabbing=false}this.el.scrollTop=g;this.el.scrollLeft=h},do_enter:function(){if(base2.detect("MSIE")){this._getIESelection()}var f=this.el.scrollTop;var g=this.el.scrollLeft;var h=this.el.selectionStart;var a=this.el.selectionEnd;var e=Math.max(0,this.el.value.substring(0,h).lastIndexOf("\n")+1);var b=this.el.value.substring(e,h);if(b.match(/^[ \t]+$/mg,"")){return false}var d=b.replace(/^([ \t]*).*/gm,"$1");if(d=="\n"||d=="\r"||d.length==0){return false}if(base2.detect("MSIE")||base2.detect("opera")){d="\r\n"+d}else{d="\n"+d}this.el.value=this.el.value.substring(0,h)+d+this.el.value.substring(a);this.area_select(h+d.length,0);this.el.scrollTop=f;this.el.scrollLeft=g;return true},area_select:function(b,a){b=Math.max(0,Math.min(this.el.value.length,b));end=Math.max(b,Math.min(this.el.value.length,b+a));if(base2.detect("MSIE")){this.el.selectionStart=b;this.el.selectionEnd=end;this._setIESelection()}else{if(base2.detect("opera")){this.el.setSelectionRange(0,0)}this.el.setSelectionRange(b,end)}},_detect_tab:function(){if(this.el.value.indexOf("\t")>0){this.tabulation="\t"}else{this.tabulation="";for(var a=0;a<this.tab_nb_char;a++){this.tabulation+=" "}}this._tab_detected=true},_getIESelection:function(){this.el.focus();var a=this.el.createTextRange();var b=a.duplicate();a.moveToBookmark(document.selection.createRange().getBookmark());a.moveEnd("character",this.el.value.length);this.el.selectionStart=this.el.value.length-a.text.length;b.moveToBookmark(document.selection.createRange().getBookmark());b.moveStart("character",-this.el.value.length);this.el.selectionEnd=b.text.length;if(this.el.selectionEnd<this.el.selectionStart){this.el.selectionEnd=this.el.selectionStart}},_setIESelection:function(){var a=this.el.value.substr(0,this.el.selectionStart).split("\n").length-1;var b=this.el.value.substr(0,this.el.selectionEnd).split("\n").length-1;var d=document.selection.createRange();d.moveToElementText(this.el);d.setEndPoint("EndToStart",d);d.collapse(true);d.moveStart("character",this.el.selectionStart-a);d.moveEnd("character",this.el.selectionEnd-b-(this.el.selectionStart-a));d.select()}});var Review=base2.Base.extend({constructor:function(){var b=this;this._reviews={};this.latest_add=null;document.querySelectorAll(".review-flag").forEach(function(e){p=base2.DOM.bind(e.parentNode);offsets=p.getOffsets();e.style.top=offsets.y+"px"});var d=document.createElement("img");d.id="ghost-reviewflag";d.setStyle({position:"absolute",left:"5.5%",cursor:"pointer"});d.classList.add("hidden");d.src="/static/images/comment-ghost.png";document.body.appendChild(d);this.ghostReview=d;this.ghostReview.addEventListener("mousedown",this._sourceMouseDown.bind(this),false);this.ghostReview.addEventListener("mouseup",this._sourceMouseUp.bind(this),false);this.ghostReview.addEventListener("mouseover",this._sourceMouseOver.bind(this),true);this.nb_lines=null;this.sourceRow=null;this.numRow=null;this._loading=false;var a=document.querySelector("table.numsTable");a.addEventListener("mousedown",this._sourceMouseDown.bind(this),false);a.addEventListener("mouseup",this._sourceMouseUp.bind(this),false);a.addEventListener("mouseover",this._sourceMouseOver.bind(this),true);a.addEventListener("mouseout",this._sourceMouseOut.bind(this),true);this.converter=new Showdown.converter();this.canRestart=true;window.addEventListener("close",function(f){b.canRestart=false},false);this._init_stomp()},_init_stomp:function(){var a=this;stomp=new STOMPClient();stomp.onopen=function(){};stomp.onerror=function(b){alert("Error: "+b)};stomp.onerrorframe=function(b){alert("Error: "+b.body)};stomp.onconnectedframe=function(){stomp.subscribe("/paste/"+snippet_id+"/"+revid,{exchange:""});stomp.subscribe("/paste/"+snippet_id,{exchange:""})};stomp.onmessageframe=function(b){a.handle_messages(b)};stomp.onclose=function(){if(a.canRestart){window.setTimeout("stomp.connect('localhost', 61613)",2000)}};stomp.connect("localhost",61613)},_notify:function(b){var a=document.querySelector("#notify-snippet");a.innerHTML=b;if(a.classList.has("hidden")){a.classList.remove("hidden")}setTimeout(function(){a.classList.add("hidden")},30000)},handle_messages:function(a){var j=base2.JSON.parse(a.body);var e=false;if(j.type=="review"){if(this.latest_add&&this.latest_add.nb_line==j.nb_line&&this.latest_add.reviews_count+1==j.reviews_count){e=true}var i=this._reviews[j.nb_line]||null;if(!i){var i=this._numRow(j.nb_line);if(!i){return}this._reviews[j.nb_line]=i}var b=i.querySelector("td");var f=b.querySelector("span.reviewflag");var h=false;if(!f){var g=document.createElement("span");g.classList.add("reviewflag");if(!e){g.classList.add("new")}g.appendChild(document.createTextNode(j.reviews_count));b.appendChild(g);h=true}else{line_count=parseInt(f.innerHTML);if(line_count<j.reviews_count){f.innerHTML=j.reviews_count;if(!f.classList.has("new")&&!e){f.classList.add("new")}if(!e&&j.nb_line==this.currentLineNumber){this.updateComments(j.nb_line)}h=true}}if(h&&!e){var d='a new review has been added to line <a href="#'+j.nb_line+'">#'+j.nb_line+"</a>.";this._notify(d)}}else{if(j.type=="update"){if(j.revision==revid){return}var d='Past has been updated to <a href="/'+snippet_id+"?rev="+j.revision+'">revision '+j.revision+"</a>";this._notify(d)}else{if(j.type=="delete"){var d="Paste has been deleted.";this._notify(d)}}}},_sourceRow:function(a){var b=document.querySelector("td.lines table").rows;--a;return base2.DOM.bind(b[a])},_numRow:function(a){var b=document.querySelector("td.nums table").rows;--a;return base2.DOM.bind(b[a])},_lineNumberForRow:function(b){var a=0;while(b){++a;b=b.previousSibling}return a},_handleKey:function(a){if(a.keyCode==27){this.hideCommentBox();document.removeEventListener("keydown",arguments.callee,false)}},_selectRow:function(a,d){if(a!=this.nb_line){if(this.nb_line){this.numRow.classList.remove("selected");this.sourceRow.classList.remove("selected")}this.nb_line=a;this.numRow=d;this.sourceRow=this._sourceRow(a);this.numRow.classList.add("selected");this.sourceRow.classList.add("selected");if(!d.classList.has("hasreview")){var b=d.getOffsets();this.ghostReview.style.top=b.y-1+"px";this.ghostReview.numLine=a;this.ghostReview.classList.remove("hidden")}else{this.ghostReview.classList.add("hidden")}}},_sourceMouseOver:function(f){f.stopPropagation();var b=f.target;var d=f.target.parentNode;base2.DOM.bind(b);base2.DOM.bind(d);if(b==this.ghostReview&&!b.classList.has("hidden")){a=b.numLine;g=this._numRow(a);this._selectRow(a,g)}else{if(b.classList.has("line-number")||d.classList.has("line-number")){var g=b.enclosingNodeOrSelfWithNodeName("tr");base2.DOM.bind(g);var a=this._lineNumberForRow(g);this._selectRow(a,g)}}return},_sourceMouseOut:function(a){if(!this.nb_line){return}relTarget=base2.DOM.bind(a.relatedTarget||a.toElement);if(typeof relTarget=="undefined"){return}if(this.ghostReview&&relTarget!=this.ghostReview){this.ghostReview.classList.add("hidden")}if(relTarget.tagName=="SPAN"){relTarget=base2.DOM.bind(relTarget.parentNode)}if(!relTarget.classList.has("line-number")){this.numRow.classList.remove("selected");this.sourceRow.classList.remove("selected");this.nb_line=this.sourceRow=this.numRow=null}},_sourceMouseDown:function(b){var a=b.target;base2.DOM.bind(a);if(this.ghostReview&&a==this.ghostReview){this.currentRow=this._numRow(this.ghostReview.numLine);this.currentLineNumber=this.ghostReview.numLine}else{if(a.tagName=="SPAN"){a=base2.DOM.bind(a.parentNode)}if(!a.classList.has("line-number")){return}this.currentRow=base2.DOM.bind(a.enclosingNodeOrSelfWithNodeName("tr"));this.currentLineNumber=this._lineNumberForRow(this.currentRow)}},_sourceMouseUp:function(h){var f=h.target;var g=h.target.parentNode;base2.DOM.bind(f);base2.DOM.bind(g);if(this.ghostReview&&f!=this.ghostReview){if(!f.classList.has("line-number")&&(!g.classList.has("line-number"))){return}}this.el=this.currentRow.querySelector("td");if(this.ghostReview&&!this.ghostReview.classList.has("hidden")){this.ghostReview.classList.add("hidden")}var a=this.el.querySelector("span.reviewflag");if(!a){var d=document.createElement("span");d.classList.add("reviewflag");d.appendChild(document.createTextNode("0"));this.el.appendChild(d)}else{if(a.classList.has("new")){a.classList.remove("new")}}var b=this._lineNumberForRow(this.currentRow);var i=this._sourceRow(b);if(this.currentRow.classList.has("selected")){this.currentRow.classList.remove("selected");this.sourceRow.classList.remove("selected")}i.classList.add("highlighted-line");this.currentRow.classList.add("highlighted-line");this.showCommentBox()},buildCommentBox:function(s){var o=this;this.overlay=document.createElement("div");this.overlay.id="overlay";this.overlay.setStyle({"z-index":"9999"});this.overlay.setOpacity("0");var m=document.createElement("div");m.classList.add("comment-box");m.classList.add("hidden");m.setStyle("z-index: 10000");m.setOpacity("0.9");this.divComment=this.rootLayers=m;document.body.appendChild(this.overlay);document.body.appendChild(this.divComment);var s=this._lineNumberForRow(this.currentRow);var h="/"+snippet_id+"/reviews/"+s;var t="/"+snippet_id+"/review/"+s;if(typeof revid!="undefined"){h+="?rev="+revid;t+="?rev="+revid}var a=document.createElement("form");a.action=t;a.id="freview";var i=document.createElement("h3");i.classList.add("wtitle");i.appendChild(document.createTextNode("Add your review to line "+s+" "));var r=document.createElement("a");r.href="#";r.innerHTML="(markdown syntax supported)";r.addEventListener("click",function(w){w.preventDefault();window.open("http://daringfireball.net/projects/markdown/dingus");w.stopPropagation();return false},false);i.appendChild(r);a.appendChild(i);var f=document.createElement("div");f.id="row-form";var n=document.createElement("textarea");n.id="new_review";n.name="new_review";n.setAttribute("cols",70);n.setAttribute("rows",5);f.appendChild(n);a.appendChild(f);var q=document.createElement("p");var v=document.createElement("span");v.classList.add("rby");var j=document.createElement("label");j.setAttribute("for","rpseudo");j.innerHTML="nickname: ";v.appendChild(j);var d=document.createElement("input");d.type="text";d.id="rpseudo";d.value="anonymous";v.appendChild(d);q.appendChild(v);var e=document.createElement("span");e.classList.add("ractions");var k=document.createElement("input");k.type="submit";k.name=k.id="sreview";k.value="save comment";e.appendChild(k);var l=document.createElement("input");l.type="submit";l.id=l.name="bclose";l.value="close";e.appendChild(l);q.appendChild(e);a.appendChild(q);m.appendChild(a);var u=document.createElement("h3");u.appendChild(document.createTextNode("All comments for this line"));m.appendChild(u);var b=document.createElement("div");b.id="reviews-list";b.classList.add("hidden");m.appendChild(b);var g=document.createElement("div");g.classList.add("loading");g.appendChild(document.createTextNode("loading comments for line"));m.appendChild(g);l.addEventListener("click",function(w){w.preventDefault();o.hideCommentBox();return false},false);k.addEventListener("click",this.add_review.bind(this),false);if(!base2.detect("webkit")){new Resizeable("#new_review",120)}new Ajax.request({url:h,dataType:"json",contentType:"application/json",method:"GET",success:function(A){if(A.ok){if(A.r){var z=document.createElement("ul");for(var x=0;x<A.r.length;x++){var w=document.createElement("li");var C=document.createElement("time");C.title="GMT";C.setAttribute("datetime",A.r[x]["created"]);C.textContent=A.r[x]["fcreated"];w.innerHTML=o.converter.makeHtml(A.r[x]["comment"]);var B=document.createElement("div");B.classList.add("metadata");B.appendChild(document.createTextNode(A.r[x]["nickname"]));B.appendChild(C);w.appendChild(B);z.appendChild(w)}b.appendChild(z);remove(g);b.classList.remove("hidden");localizeDates()}}else{remove(g);b.appendChild(document.createTextNode("No reviews yet."));b.classList.remove("hidden")}}})},_make_reviews_list:function(h,d,e){if(!d){d=document.createElement("ul");for(var b=0;b<e.r.length;b++){var a=document.createElement("li");var g=document.createElement("time");g.title="GMT";g.setAttribute("datetime",e.r[b]["created"]);g.textContent=e.r[b]["fcreated"];a.innerHTML=this.converter.makeHtml(e.r[b]["comment"]);var f=document.createElement("div");f.classList.add("metadata");f.appendChild(document.createTextNode(e.r[b]["nickname"]));f.appendChild(g);a.appendChild(f);d.appendChild(a)}h.appendChild(d)}else{for(var b=0;b<e.r.length;b++){var a=document.createElement("li");var g=document.createElement("time");g.title="GMT";g.setAttribute("datetime",e.r[b]["created"]);g.textContent=e.r[b]["fcreated"];a.innerHTML=this.converter.makeHtml(e.r[b]["comment"]);var f=document.createElement("div");f.classList.add("metadata");f.appendChild(document.createTextNode(e.r[b]["nickname"]));f.appendChild(g);a.appendChild(f);d.insertBefore(a,d.firstChild)}}localizeDates()},add_review:function(i){i.preventDefault();var l=this;var a=this.divComment.querySelector("#freview").action;var k=this.divComment.querySelector("textarea");var b=k.value;var g=document.getElementById("rpseudo").value;if(b){var d=this._lineNumberForRow(this.currentRow);var f=this.divComment.querySelector("#reviews-list");var h=f.querySelector("ul");var j=0;if(h){j=h.querySelectorAll("li").length}this.latest_add={nb_line:d,reviews_count:j};new Ajax.request({url:a,dataType:"json",contentType:"application/json",data:this.toJSON({new_review:b,nickname:g,nb_lines:j}),method:"POST",success:function(e){if(e.ok){l._make_reviews_list(f,h,e);k.value="";k.focus()}else{l.latest_add=null}}})}},updateComments:function(f){var b=this;var f=f;if(f!=this.currentLineNumber){return}var g=this.divComment.querySelector("#reviews-list");var e=g.querySelector("ul");var a=0;if(e){a=e.querySelectorAll("li").length}var d="/"+snippet_id+"/reviewset/"+f+"?rev="+revid+"&f="+a;new Ajax.request({url:d,dataType:"json",contentType:"application/json",method:"GET",success:function(h){if(h.ok){if(f!=this.currentLineNumber&&(e&&a!=e.querySelectorAll("li").length)){return}b._make_reviews_list(g,e,h)}}})},hideCommentBox:function(){reviewflag=this.el.querySelector("span.reviewflag");var a=0;if(reviewflag){a=parseInt(reviewflag.innerHTML)}if(a==0){remove(reviewflag)}this.currentLineNumber=null;this.currentRow.classList.remove("highlighted-line");var b=this._lineNumberForRow(this.currentRow);var d=this._sourceRow(b);d.classList.remove("highlighted-line");this.divComment.classList.add("hidden");remove(this.divComment);remove(this.overlay);if(this.hideIfClickOutside){document.removeEventListener("click",this.hideIfClickOutside,false);this.hideIfClickOutside=null}this.isDragging=false;this.divComment.removeEventListener("mousedown",this.beginDragCB,false);document.removeEventListener("mousemove",this.dragCB,false);document.removeEventListener("mouseup",this.endDragCB,false)},setCommentBoxPosition:function(){var b=this.el.getOffsets();var a=[b.y+this.el.outerHeight()+5,b.x+this.el.offsetWidth+20];this.divComment.style.top=a[0]+"px";this.divComment.style.left=a[1]+"px";window.scrollTo(document.body.scrollLeft,b.y-64);this.divComment.classList.remove("hidden");this.divComment.querySelector("textarea").focus()},insideCommentBox:function(a){var b=this.divComment.getOffsets();b.right=b.x+this.divComment.outerWidth();b.bottom=b.y+this.divComment.outerHeight();point=pointer(a);return point.y<b.bottom&&point.y>b.y&&point.x<b.right&&point.x>b.x},currentDelta:function(){return([parseInt(this.divComment.getStyle("left")||"0"),parseInt(this.divComment.getStyle("top")||"0")])},beginDragCB:function(i){var b=this;if(this.isDragging){return false}base2.DOM.bind(i.target);if(!i.target.classList.has("wtitle")){return}var a=pointer(i);this.boxDimensions=this.divComment.getDimensions();if(i.target.getStyle("overflow")!="hidden"){var g=getScrollbarWidth();var f=this.divComment.getOffsets();var h=f.x+this.boxDimensions.width-g;if(a.x>h){return}}this.isDragging=true;this.old_cursor=this.divComment.getStyle("cursor");this.divComment.style.cursor="move";var j=this.divComment.cumulativeOffset();this.offset=[a.x-j.x,a.y-j.y];this.pointer=a;var d=this._getWindowScroll(window);this.scroll=[d.left,d.top];document.body.focus();if(base2.detect("MSIE")){this.old_onselectstart=document.onselectstart;document.onselectstart=function(k){return false}}i.preventDefault();i.stopPropagation();return false},dragCB:function(f){if(!this.isDragging){return}if(!f){f=window.event}var f=f;var a=pointer(f);var h=this.divComment.cumulativeOffset();var g=this.currentDelta();h.x-=g[0];h.y-=g[1];var b=[(a.x-h.x-this.offset[0]),(a.y-h.y-this.offset[1])];this.divComment.style.left=b[0]+"px";this.divComment.style.top=b[1]+"px";if(base2.detect("webkit")){window.scrollBy(0,0)}f.preventDefault();f.stopPropagation()},endDragCB:function(a){if(!this.isDragging){return}this.isDragging=false;if(base2.detect("MSIE")){document.onselectstart=this.old_onselectstart}this.divComment.style.cursor=this.old_cursor},showCommentBox:function(){this.buildCommentBox();this.divComment.classList.remove("hidden");this.setCommentBoxPosition();this.divComment.addEventListener("mousedown",this.beginDragCB.bind(this),false);document.addEventListener("mousemove",this.dragCB.bind(this),false);document.addEventListener("mouseup",this.endDragCB.bind(this),false);var a=this;this.hideIfClickOutside=function(b){var d=base2.DOM.bind(b.target);if(a.ghostReview&&d==a.ghostReview){return}if(d.tagName=="SPAN"){d=d.parentNode}if(d!=a.el&&!a.insideCommentBox(b)){a.hideCommentBox()}};document.addEventListener("click",this.hideIfClickOutside,false);document.addEventListener("keydown",this._handleKey.bind(this),false)},toJSON:function(a){return a!==null?base2.JSON.toString(a):null},_getWindowScroll:function(w){var T,L,W,H;with(w.document){if(w.document.documentElement&&documentElement.scrollTop){T=documentElement.scrollTop;L=documentElement.scrollLeft}else{if(w.document.body){T=body.scrollTop;L=body.scrollLeft}}if(w.innerWidth){W=w.innerWidth;H=w.innerHeight}else{if(w.document.documentElement&&documentElement.clientWidth){W=documentElement.clientWidth;H=documentElement.clientHeight}else{W=body.offsetWidth;H=body.offsetHeight}}}return{top:T,left:L,width:W,height:H}}});var Home=base2.Base.extend({constructor:function(){if(!base2.detect("webkit")){new Resizeable("#paste_snippet")}new Editor("#paste_snippet");this.privacy=document.querySelector(".privacy");this.privacy.addEventListener("click",this.handlePrivacy.bind(this),false);this.showPrivacy=false;if(this.privacy.classList.has("setPrivacy")){this.showPrivacy=true}document.querySelector("#paste_snippet").focus()},handlePrivacy:function(h){var g=document.querySelector("#paste_privacy");var b=document.querySelector("#paste_password");var d=b.parentNode;base2.DOM.bind(d);if(this.showPrivacy&&b.value!=""&&g.options[g.options.selectedIndex].value!="open"){y=window.confirm("Are you sure you want to close privacy settings ? By doing this, you will allow everyone to view and edit paste. Click OK to continue.");if(!y){return}}var f=document.querySelector("#privacy");this.privacy.classList.toggle("setPrivacy");f.classList.toggle("hidden");this.showPrivacy=!this.showPrivacy;var a=function(i){if(d.classList.has("hidden")&&g.options[g.options.selectedIndex].value!="open"){d.classList.remove("hidden")}else{if(!d.classList.has("hidden")&&g.options[g.selectedIndex].value=="open"){d.classList.add("hidden")}}};if(this.showPrivacy){a();g.addEventListener("change",a,false)}else{b.value="";g.options.selectedIndex=0;if(d.classList.has("errors")){d.classList.remove("errors")}try{g.removeEventListener("change",a,false)}catch(h){}}}});var Friendpaste=base2.Base.extend({snippet:null,snippet_edit:null,constructor:function(){var b=this;var e=document.querySelector(".e");var d=document.querySelectorAll(".cancel");var f=document.querySelector(".show-history");if(e){e.addEventListener("click",this.do_edit.bindAsEventListener(this),false)}if(d){d.forEach(function(g){g.addEventListener("click",b.do_cancel.bindAsEventListener(b),false)})}if(f){f.addEventListener("click",this.do_history.bindAsEventListener(this),false)}this.snippet=document.querySelector("#view");this.snippet_edit=document.querySelector("#edit");this.revisions=document.querySelector("#revisions");this.bdelete=document.querySelector("#snippet_actions li.delete");if(this.bdelete!=null){this.block=document.querySelector("#snippet_actions li.lock");this.adelete=document.querySelector("#snippet_actions li.delete a");this.alock=document.querySelector("#snippet_actions li.lock a");this._deleteListener=function(g){g.preventDefault();this.removeEventListener("click",arguments.callee,false);b.alock.removeEventListener("click",b._lockListener,false);b.block.classList.add("disabled");b.deletePaste()};this._lockListener=function(g){g.preventDefault();this.removeEventListener("click",arguments.callee,false);b.adelete.removeEventListener("click",b._deleteListener,false);b.bdelete.classList.add("disabled");b.lockPaste()};this.listenPasteActions()}var a=/#(.+)$/.exec(window.location);if(a&&a[1]=="edit"){this.snippet.classList.add("hidden");this.snippet_edit.classList.remove("hidden")}else{this.editing=true}this.editing=false;this.show_history=false;if(!base2.detect("webkit")){new Resizeable("#paste_snippet")}new Editor("#paste_snippet");new Review();this.setSettings();document.querySelector("#change-theme").addEventListener("change",this.setTheme.bindAsEventListener(this),false);document.querySelector("#show-linenos").addEventListener("click",this.toggleLineNumber.bindAsEventListener(this),false)},listenPasteActions:function(){this.adelete.addEventListener("click",this._deleteListener,false);this.alock.addEventListener("click",this._lockListener,false)},deletePaste:function(){var b=this;var d=this.formPassword("delete","Delete paste");var a=base2.DOM.bind(this.adelete.parentNode);this.adelete.style.display="none";a.appendChild(d);a.querySelector(".password").focus();a.querySelector("input.ano").addEventListener("click",function(f){f.preventDefault();this.removeEventListener("click",arguments.callee,false);b.adelete.style.display="inline";b.block.classList.remove("disabled");remove(d);b.listenPasteActions()},false);return false},lockPaste:function(){var b=this;if(!this.snippet_edit){var d=this.formPassword("unlock","Unlock paste")}else{var d=this.formPassword("lock","Lock paste")}var a=base2.DOM.bind(this.alock.parentNode);a.appendChild(d);a.querySelector(".password").focus();this.alock.style.display="none";a.querySelector("input.ano").addEventListener("click",function(f){f.preventDefault();this.removeEventListener("click",arguments.callee,false);b.alock.style.display="inline";b.bdelete.classList.remove("disabled");remove(d);b.listenPasteActions()},false);return false},formPassword:function(a,b){url="/"+snippet_id+"/"+a;form=document.createElement("form");form.className="fsnippet_action";form.action=url;form.method="POST";h4=document.createElement("h4");h4.appendChild(document.createTextNode(b));form.appendChild(h4);p=document.createElement("p");p.appendChild(document.createTextNode("Enter code entered when you create the paste to confirm:"));form.appendChild(p);label=document.createElement("label");label.setAttribute("for","edit_code");label.appendChild(document.createTextNode("Code: "));form.appendChild(label);input=document.createElement("input");input.type="password";input.name="edit_code";input.className="password";form.appendChild(input);submit=document.createElement("input");submit.name="f"+a;submit.type="submit";submit.value=a.substring(0,1).toUpperCase()+a.substring(1,a.length);submit.className="ayes";form.appendChild(submit);cancel=document.createElement("input");cancel.type="submit";cancel.value="Cancel";cancel.className="ano";form.appendChild(cancel);return form},handleSnippetAction:function(a){},do_edit:function(a){a.preventDefault();this._edit();return false},_edit:function(){this.ghostReview=document.querySelector("#ghost-reviewflag");if(this.ghostReview){this.ghostReview.classList.add("hidden")}this.snippet.classList.add("hidden");this.snippet_edit.classList.remove("hidden");this.editing=true},do_cancel:function(a){a.preventDefault();this._cancel();return false},_cancel:function(){this.editing=false;if(this.ghostReview){this.ghostReview.classList.remove("hidden");this.ghostReview=null}if(this.snippet_edit&&!this.snippet_edit.classList.has("hidden")){this.snippet_edit.classList.add("hidden")}if(!this.revisions.classList.has("hidden")){this.revisions.classList.add("hidden")}this.snippet.classList.remove("hidden")},toggleLineNumber:function(a){document.querySelector("#paste").classList.toggle("hidenos");this.saveSettings()},setSettings:function(){new Ajax.request({url:"/settings",dataType:"json",contentType:"application/json",method:"GET",success:function(a){showlineos=a.settings["showlinenos"];if(typeof(showlineos)!="undefined"){document.querySelector("#show-linenos").checked=a.settings["showlinenos"];if(!a.settings["showlinenos"]){document.querySelector("#paste").classList.add("hidenos")}}if(typeof(a.settings["theme"])!="undefined"&&a.settings["theme"]){theme=a.settings["theme"]}else{theme="default"}document.querySelector("#change-theme").value=theme;document.querySelectorAll('link[rel="stylesheet"][title]').forEach(function(b){if(b.getAttribute("title")=="syntax_theme"){b.href="/static/css/"+theme+".css"}})}})},saveSettings:function(){var d=document.querySelector("#factions");var b=true;var a=document.querySelector("#show-linenos:checked");if(!a){b=false}new Ajax.request({url:d.action,dataType:"json",contentType:"application/json",method:"POST",data:this.toJSON({theme:document.querySelector("#change-theme").value,showlinenos:b}),success:function(e){}})},setTheme:function(b){var a=b.target.value;document.querySelectorAll('link[rel="stylesheet"][title]').forEach(function(d){if(d.getAttribute("title")=="syntax_theme"){d.href="/static/css/"+a+".css"}});this.saveSettings()},do_history:function(b){b.preventDefault();this.ghostReview=document.querySelector("#ghost-reviewflag");if(this.ghostReview){this.ghostReview.classList.add("hidden")}this.show_history=true;url="/"+snippet_id+"/revisions";if(typeof(revid)!="undefined"){url=url+"?rev="+revid}var a=this;new Ajax.get(url,null,function(f,d){document.querySelector(".pasteHistory").innerHTML="";var e="";f.forEach(function(h,g){e+='<tr><td><time title="GMT" datetime="'+h.updated+'">'+h.updated+'</time></td><td class="rev">rev. <a href=\'/'+h.pasteid+"?rev="+h.revid+"'>"+h.revid+'</a></td><td class="changeset"><a href=\'/'+h.pasteid+"/changeset?rev="+h.revid+"'>Diff</a></td><td class=\"view-rev\"><a href='/"+h.pasteid+"?rev="+h.revid+"'>View</a></td></tr>"});e='<table class="revisionstable">'+e+"</table>";document.querySelector(".pasteHistory").innerHTML=e;a.snippet.classList.add("hidden");a.revisions.classList.remove("hidden");localizeDates()},"json");return false},toJSON:function(a){return a!==null?base2.JSON.toString(a):null}});var Diff=base2.Base.extend({constructor:function(){this.sourcetable=document.querySelector(".sourceTable");this.difftabular=document.querySelector(".difftabular");this.switcher=document.querySelector("#switch");this.sourcetable.classList.add("hidden");this.switcher.innerHTML='<span class="stab active">Tabular</span><span class="suni">Unified</span>';this.stab=this.switcher.querySelector(".stab");this.suni=this.switcher.querySelector(".suni");var a=this;this.stab.addEventListener("click",this.setTabular.bindAsEventListener(this),false);this.suni.addEventListener("click",this.setUnified.bindAsEventListener(this),false);this.setSettings();document.querySelector("#show-linenos").addEventListener("click",this.toggleLineNumber.bindAsEventListener(this),false)},setTabular:function(a){a.preventDefault();if(!this.sourcetable.classList.has("hidden")){this.sourcetable.classList.add("hidden")}this.difftabular.classList.remove("hidden");this.suni.classList.remove("active");this.stab.classList.add("active")},setUnified:function(a){a.preventDefault();if(!this.difftabular.classList.has("hidden")){this.difftabular.classList.add("hidden")}this.sourcetable.classList.remove("hidden");this.stab.classList.remove("active");this.suni.classList.add("active")},toggleLineNumber:function(a){document.querySelector("#paste").classList.toggle("hidenos");this.saveSettings()},setSettings:function(){Ajax.request({url:"/settings",dataType:"json",contentType:"application/json",method:"GET",success:function(a){document.querySelector("#show-linenos").checked=a.settings["showlinenos"];if(!a.settings["showlinenos"]){document.querySelector("#paste").classList.add("hidenos")}}})},saveSettings:function(){var d=document.querySelector("#factions");var b=true;var a=document.querySelector("#show-linenos:checked");if(!a){b=false}Ajax.request({url:d.action,dataType:"json",contentType:"application/json",method:"POST",data:this.toJSON({showlinenos:b}),success:function(e){}})},toJSON:function(a){return a!==null?base2.JSON.toString(a):null}});
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.