From 489946df63b689500d80f5fcc58f1d5f40a17662 Mon Sep 17 00:00:00 2001 From: sam Date: Mon, 21 May 2012 11:04:28 +0200 Subject: [PATCH] Recompressed static to get new featured and fixed bug with non created subpath --- docs/index.rst | 2 +- zerobin/paste.py | 10 +++++----- zerobin/static/css/style.min.css | 2 +- zerobin/static/js/main.min.js | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index 4a7d7db..9c65518 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -28,4 +28,4 @@ .. _Signaler un bug: https://github.com/sametmax/0bin/issues -.. _Report a bug: \ No newline at end of file +.. _Report a bug: https://github.com/sametmax/0bin/issues \ No newline at end of file diff --git a/zerobin/paste.py b/zerobin/paste.py index b52ace9..49247f2 100644 --- a/zerobin/paste.py +++ b/zerobin/paste.py @@ -133,11 +133,11 @@ class Paste(object): os.makedirs(self.build_path(head, tail)) self.DIR_CACHE.add((head, tail)) - elif (head, tail) not in self.DIR_CACHE: - path = self.build_path(head, tail) - self.DIR_CACHE.add((head, tail)) - if not os.path.isdir(path): - os.mkdir(path) + if (head, tail) not in self.DIR_CACHE: + path = self.build_path(head, tail) + self.DIR_CACHE.add((head, tail)) + if not os.path.isdir(path): + os.mkdir(path) # add a timestamp to burn after reading to allow # a quick period of time where you can redirect to the page without diff --git a/zerobin/static/css/style.min.css b/zerobin/static/css/style.min.css index 80d7bee..7ff60ec 100644 --- a/zerobin/static/css/style.min.css +++ b/zerobin/static/css/style.min.css @@ -4,4 +4,4 @@ article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display /* Prettify */ .pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} /* Custom */ -.brand{font-size:38px!important;padding:0 55px 3px!important;text-shadow:0 1px 0 rgba(255,255,255,.1),0 0 30px rgba(255,255,255,.125);-webkit-transition:all .2s linear;-moz-transition:all .2s linear;transition:all .2s linear}.brand span{font-size:48px;line-height:0}.brand em{display:inline;color:#d40202;margin:0!important;font-size:27px}.about{line-height:13px;font-style:italic;text-align:right;padding-top:9px;margin-bottom:0!important}.about span{font-size:10px}body{padding-top:60px;padding-bottom:40px}.sidebar-nav{padding:9px 0}select{width:135px}label{display:inline;margin-left:18px;font-style:italic;font-size:11px;color:#888}ul,ol{padding:0;margin:0}li{margin-left:-9px}p{margin:0 0 20px}.grey{color:#999}.nav-list{padding-right:0!important;font-size:12px}blockquote{width:630px;float:left}h4 p{float:left;font-size:80px;text-shadow:1px 3px 1px #DDD,0 0 4px #333;-webkit-transition:all .2s linear;-moz-transition:all .2s linear;transition:all .2s linear;margin-right:7px;margin-top:3px}h4#pixels-total{position:relative;width:166px;float:right;margin:8px 0 0 0;padding:0 0 0 54px;font-size:1.1em;line-height:1.4;font-weight:normal;color:#777;-webkit-border-top-right-radius:6px;-webkit-border-top-left-radius:20px;-moz-border-top-right-radius:6px;-moz-border-top-left-radius:20px;border-top-right-radius:6px;border-top-left-radius:20px}.greetings{clear:both;margin:0 auto;text-align:center;margin-top:40px}.alert .title{display:block}.btn-group{float:left}html.file-upload p.file-upload{float:left;margin:22px 0 0 21px;display:none}html.file-upload p.file-upload{display:inherit}html.no-file-upload p.file-upload{display:none}input.btn-upload{position:relative;left:-6px;width:100px;z-index:1;margin-top:-13px}input.hide-upload{position:relative;left:-110px;-moz-opacity:0;filter:alpha(opacity:0);opacity:0;z-index:2;width:100px;margin-top:-20px;cursor:pointer;cursor:hand;height:49px}#paste-content{background-color:white;padding:1em}#paste-content.done{background-color:white;padding-top:1em;padding-left:0}.submit-form{display:none}.paste-option{float:right}a#clip-button.hover{cursor:pointer;text-decoration:underline}li.L0,li.L1,li.L2,li.L3,li.L4,li.L5,li.L6,li.L7,li.L8,li.L9{list-style-type:decimal;background:inherit}.prettyprint.linenums{-webkit-box-shadow:inset 40px 0 0 #fbfbfc,inset 41px 0 0 #ececf0;-moz-box-shadow:inset 40px 0 0 #fbfbfc,inset 41px 0 0 #ececf0;box-shadow:inset 40px 0 0 #fbfbfc,inset 41px 0 0 #ececf0}ol.linenums{margin:0 0 0 55px}ol.linenums li{color:#bebec5;line-height:18px;text-shadow:0 1px 0 #fff}.prettyprint{padding:8px;background-color:#f7f7f9;border:1px solid #e1e1e8}pre{font-family:Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,monospace,serif;line-height:21px;font-size:12px}.kwd{color:#66F}.pun,.opn,.clo{color:#0A0}.lit{color:#933}.com{color:#C0C}form{padding-bottom:3em!important;padding-right:17px}form textarea{overflow-y:auto}button.btn,input[type="submit"].btn{margin-left:5px}.well{padding-bottom:40px;padding-right:17px}.legal{margin:0 auto;width:300px;text-align:center;margin-top:30px}.btn{margin-left:5px}.btn-primary,.btn-danger{position:relative;top:-4px}#alert-template{display:none}.progress{display:none}.progress .bar{width:25%;text-indent:10px;text-align:left}.lnk-option canvas{vertical-align:middle;margin-right:10px}.previous-pastes .item{margin-top:5px;vertical-align:middle;line-height:24px;padding-left:1em}li.item{margin-left:-13px;margin-right:-5px}.previous-pastes canvas{display:block;float:left;margin-right:5px}html.local-storage .no-local-storage{display:none}html.no-local-storage .local-storage{display:none}canvas{border:1px solid white} \ No newline at end of file +.brand{font-size:38px!important;padding:0 55px 3px!important;text-shadow:0 1px 0 rgba(255,255,255,.1),0 0 30px rgba(255,255,255,.125);-webkit-transition:all .2s linear;-moz-transition:all .2s linear;transition:all .2s linear}.brand span{font-size:48px;line-height:0}.brand em{display:inline;color:#d40202;margin:0!important;font-size:27px}.about{line-height:13px;font-style:italic;text-align:right;padding-top:9px;margin-bottom:0!important}.about span{font-size:10px}body{padding-top:60px;padding-bottom:40px}.sidebar-nav{padding:9px 0}select{width:135px}label{display:inline;margin-left:18px;font-style:italic;font-size:11px;color:#888}ul,ol{padding:0;margin:0}li{margin-left:-9px}p{margin:0 0 20px}.grey{color:#999}.nav-list{padding-right:0!important;font-size:12px}blockquote{width:630px;float:left}h4 p{float:left;font-size:80px;text-shadow:1px 3px 1px #DDD,0 0 4px #333;-webkit-transition:all .2s linear;-moz-transition:all .2s linear;transition:all .2s linear;margin-right:7px;margin-top:3px}h4#pixels-total{position:relative;width:166px;float:right;margin:8px 0 0 0;padding:0 0 0 54px;font-size:1.1em;line-height:1.4;font-weight:normal;color:#777;-webkit-border-top-right-radius:6px;-webkit-border-top-left-radius:20px;-moz-border-top-right-radius:6px;-moz-border-top-left-radius:20px;border-top-right-radius:6px;border-top-left-radius:20px}.greetings{clear:both;margin:0 auto;text-align:center;margin-top:40px}.alert .title{display:block}.btn-group{float:left}html.file-upload p.file-upload{float:left;margin:22px 0 0 21px;display:none}html.file-upload p.file-upload{display:inherit}html.no-file-upload p.file-upload{display:none}input.btn-upload{position:relative;left:-6px;width:100px;z-index:1;margin-top:-13px}input.hide-upload{position:relative;left:-110px;-moz-opacity:0;filter:alpha(opacity:0);opacity:0;z-index:2;width:100px;margin-top:-20px;cursor:pointer;cursor:hand;height:49px}#paste-content{background-color:white;padding:1em}#paste-content.done{background-color:white;padding-top:1em;padding-left:0}.submit-form{display:none}.paste-option{float:right}a#clip-button.hover{cursor:pointer;text-decoration:underline}li.L0,li.L1,li.L2,li.L3,li.L4,li.L5,li.L6,li.L7,li.L8,li.L9{list-style-type:decimal;background:inherit}.prettyprint.linenums{-webkit-box-shadow:inset 40px 0 0 #fbfbfc,inset 41px 0 0 #ececf0;-moz-box-shadow:inset 40px 0 0 #fbfbfc,inset 41px 0 0 #ececf0;box-shadow:inset 40px 0 0 #fbfbfc,inset 41px 0 0 #ececf0}ol.linenums{margin:0 0 0 55px}ol.linenums li{color:#bebec5;line-height:18px;text-shadow:0 1px 0 #fff}.prettyprint{padding:8px;background-color:#f7f7f9;border:1px solid #e1e1e8}pre{font-family:Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,monospace,serif;line-height:21px;font-size:12px}.kwd{color:#66F}.pun,.opn,.clo{color:#0A0}.lit{color:#933}.com{color:#C0C}form{padding-bottom:3em!important;padding-right:17px}form textarea{overflow-y:auto}button.btn,input[type="submit"].btn{margin-left:5px}.well{padding-bottom:40px;padding-right:17px}.legal{margin:0 auto;width:300px;text-align:center;margin-top:30px}.btn{margin-left:5px}.btn-primary,.btn-danger{position:relative;top:-4px}#alert-template{display:none}.progress{display:none}.progress .bar{width:25%;text-indent:10px;text-align:left}.lnk-option canvas{vertical-align:middle;margin-right:10px}.previous-pastes .item{margin-top:5px;vertical-align:middle;line-height:24px;padding-left:1em}li.item{margin-left:-13px;margin-right:-5px}.previous-pastes canvas{display:block;float:left;margin-right:5px}html.local-storage .no-local-storage{display:none}html.no-local-storage .local-storage{display:none}canvas{border:1px solid white}#wrap-content{display:none}.noscript{text-align:center;color:red;font-weight:bold} \ No newline at end of file diff --git a/zerobin/static/js/main.min.js b/zerobin/static/js/main.min.js index 215283c..9533d04 100644 --- a/zerobin/static/js/main.min.js +++ b/zerobin/static/js/main.min.js @@ -48,4 +48,4 @@ b[d[2]]=d[3]?parseInt(d[3],10):d[2].match(/^(ct|salt|iv)$/)?sjcl.codec.base64.to undefined)c[b[d]]=a[b[d]];return c}};sjcl.encrypt=sjcl.json.encrypt;sjcl.decrypt=sjcl.json.decrypt;sjcl.misc.S={};sjcl.misc.cachedPbkdf2=function(a,b){var c=sjcl.misc.S,d;b=b||{};d=b.iter||1E3;c=c[a]=c[a]||{};d=c[d]=c[d]||{firstSalt:b.salt&&b.salt.length?b.salt.slice(0):sjcl.random.randomWords(2,0)};c=b.salt===undefined?d.firstSalt:b.salt;d[c]=d[c]||sjcl.misc.pbkdf2(a,c,b.iter);return{key:d[c].slice(0),salt:c.slice(0)}}; /* custom */ -(function(){sjcl.random.startCollectors();$.ajaxSetup({cache:true});function a(c){var b=arguments;return function(){return c.apply(c,Array.prototype.slice.call(b,1))}}window.zerobin={version:"0.1",encrypt:function(f,g,d,b,e,c){setTimeout(function(){g=sjcl.codec.utf8String.toBits(g);if(d){d()}setTimeout(function(){g=sjcl.codec.base64.fromBits(g);if(b){b()}setTimeout(function(){g=lzw.compress(g);if(e){e()}setTimeout(function(){g=sjcl.encrypt(f,g);if(c){c(g)}},250)},250)},250)},250)},decrypt:function(f,g,d,b,e,h,c){setTimeout(function(){try{g=sjcl.decrypt(f,g);if(b){b()}setTimeout(function(){try{g=lzw.decompress(g);if(e){e()}setTimeout(function(){try{g=sjcl.codec.base64.toBits(g);if(h){h()}setTimeout(function(){try{g=sjcl.codec.utf8String.fromBits(g);if(c){c(g)}}catch(l){d(l)}},250)}catch(k){d(k)}},250)}catch(j){d(j)}},250)}catch(i){d(i)}},250)},makeKey:function(){return sjcl.codec.base64.fromBits(sjcl.random.randomWords(8,0),0)},getFormatedDate:function(b){b=b||new Date();return((b.getMonth()+1)+"-"+b.getDate()+"-"+b.getFullYear())},getFormatedTime:function(c){c=c||new Date();var e=c.getHours();var b=c.getMinutes();var d=c.getSeconds();if(e<10){e="0"+e}if(b<10){b="0"+b}if(d<10){d="0"+d}return e+":"+b+":"+d},numOrdA:function(d,c){return(d-c)},getLocalStorageKeys:function(b){b="zerobinV"+(b||zerobin.version);var d=[];for(var c in localStorage){if(c.indexOf(b)!==-1){d.push(c)}}d.sort();d.reverse();return d},getTinyURL:function(d,c){var b="http://json-tinyurl.appspot.com/?url=";$.getJSON(b+encodeURIComponent(d)+"&callback=?",function(e){c(e.tinyurl)})},support:{localStorage:(function(){var b=!!(localStorage);$("html").addClass((b?"":"no-")+"local-storage");return b})(),history:(function(){var b=!!(window.history&&history.pushState);$("html").addClass((b?"":"no-")+"history");return b})(),fileUpload:(function(){var b=window;var c=!!(b.File&&b.FileReader&&b.FileList&&b.Blob);$("html").addClass((c?"":"no-")+"file-upload");return c})()},storePaste:function(c,b){b=b||new Date();b=(b.getFullYear()+"-"+(b.getMonth()+1)+"-"+b.getDate()+" "+zerobin.getFormatedTime(b));var d=zerobin.getLocalStorageKeys();if(localStorage.length>19){void localStorage.removeItem(d[19])}localStorage.setItem("zerobinV"+zerobin.version+"#"+b,c)},getPreviousPastes:function(){var c=[],d=zerobin.getLocalStorageKeys(),b=zerobin.getFormatedDate();$.each(d,function(g,f){var j=f.replace(/^[^#]+#/,"");var e=j.match(/^(\d+)-(\d+)-(\d+)\s/);e=e[2]+"-"+e[3]+"-"+e[1];var h="the ";if(e===b){e=j.split(" ")[1];h="at "}c.push({displayDate:e,prefix:h,link:localStorage.getItem(f)})});return c},parseUrl:(function(){var b=document.createElement("div");b.innerHTML="";return function(c){b.firstChild.href=c;b.innerHTML=b.innerHTML;return b.firstChild}})(),getPasteId:function(b){var c=b?zerobin.parseUrl(b):window.location;return c.pathname.replace(/\/|paste/g,"").replace(/\?.*$/,"")},getPasteKey:function(b){var c=b?zerobin.parseUrl(b):window.location;return c.hash.replace("#","").replace(/\?.*$/,"")},getPasteContent:function(){var b="";$("#paste-content li").each(function(c){b=b+$(this).text()+"\n"});return b},count:function(h,d){var g=/(\r?\n|\r)/g;var c=/(\r?\n|\r|\s+)/g;d=d||{};d.lineBreaks=d.lineBreaks||1;var f=h.length,e=f-h.replace(/[\u0100-\uFFFF]/g,"").length,b=f-h.replace(g,"").length;return f+e+Math.max(0,d.lineBreaks*(b-1))},message:function(d,e,f,b,g){$(window).scrollTop(0);if(b){$(".alert-"+d).remove()}var c=$("#alert-template").clone().attr("id",null).addClass("alert alert-"+d);$(".message",c).html(e);if(f){$(".title",c).html(f)}else{$(".title",c).remove()}c.prependTo($("#main")).show("fadeUp",g)},progressBar:function(b){var d=$(b);var c={container:d,elem:d.find(".bar")};c.set=function(f,e){c.elem.text(f).css("width",e)};return c}};$(function(){$(".btn-primary").live("click",function(s){s.preventDefault();var p=$("textarea").val();var n=zerobin.count($("#content").val());var o=n>zerobin.max_size;var r=Math.round(n/1024);var u=Math.round(zerobin.max_size/1024);if(o){zerobin.message("error",('Your file is '+r+"KB. You have reached the maximum size limit of "+u+"KB."),"Warning!",true)}if(!o&&p.trim()){var x=$("input, textarea, select, button").prop("disabled",true);var t=zerobin.progressBar("form.well .progress");t.container.show();t.set("Converting paste to bits...","25%");try{var w=$("#expiration").val();var v=zerobin.makeKey();zerobin.encrypt(v,p,a(t.set,"Encoding to base64...","45%"),a(t.set,"Compressing...","65%"),a(t.set,"Encrypting...","85%"),function(e){t.set("Sending...","95%");var y={content:e,expiration:w};$.post("/paste/create",y).error(function(z){x.prop("disabled",false);t.container.hide();zerobin.message("error","Paste could not be saved. Please try again later.","Error")}).success(function(A){t.set("Redirecting to new paste...","100%");if(A.status==="error"){zerobin.message("error",A.message,"Error");x.prop("disabled",false);t.container.hide()}else{var z="/paste/"+A.paste+"#"+v;if(zerobin.support.localStorage){zerobin.storePaste(z)}window.location=(z)}})})}catch(q){x.prop("disabled",false);t.container.hide();zerobin.message("error","Paste could not be encrypted. Aborting.","Error")}}});var f=$("#paste-content").text().trim();var i=zerobin.getPasteKey();var h=false;if(f&&i){$.getScript("/static/js/vizhash.min.js").done(function(n,o){if(vizhash.supportCanvas){var e=vizhash.canvasHash(zerobin.getPasteId(),24,24);$('').click(function(p){p.preventDefault();if(confirm("This picture is unique to your paste so you can identify it quickly. \n\n Do you want to know more about this?")){window.open("http://is.gd/IJaMRG","_blank")}}).prependTo(".lnk-option").append(e.canvas)}});var l=$("input, textarea, select, button").prop("disabled",true);var g=zerobin.progressBar(".well form .progress");g.container.show();g.set("Decrypting paste...","25%");zerobin.decrypt(i,f,function(){g.container.hide();zerobin.message("error","Could not decrypt data (Wrong key ?)","Error")},a(g.set,"Decompressing...","45%"),a(g.set,"Base64 decoding...","65%"),a(g.set,"From bits to string...","85%"),function(e){$("#paste-content").text(e);e="";g.set("Code coloration...","95%");setTimeout(function(){ZeroClipboard.setMoviePath("/static/js/ZeroClipboard.swf");var o=new ZeroClipboard.Client();var n=function(){o.reposition()};o.addEventListener("mouseup",function(){$("#clip-button").text("Copying paste...");o.setText(zerobin.getPasteContent())});o.addEventListener("complete",function(){$("#clip-button").text("Copy to clipboard");zerobin.message("info","The paste is now in your clipboard","",true,n)});o.glue("clip-button");window.onresize=n;$("#short-url").click(function(p){p.preventDefault();$("#short-url").text("Loading short url...");zerobin.getTinyURL(window.location.toString(),function(q){o.setText(q);$("#copy-success").hide();zerobin.message("success",''+q+"","Short url",true,n);$("#short-url").text("Get short url")})});$(".close").off().live("click",function(p){p.preventDefault();$(this).parent().fadeOut(n)});prettyPrint();$("#paste-content").addClass("done");g.set("Done","100%");g.container.hide();l.prop("disabled",false)},250)})}$(".paste-option select").live("change",function(){$(".paste-option select").val($(this).val())});$("#content").elastic();$("#content").live("keyup change",function(){if($("#content").height()<400){$(".paste-option.down").remove()}else{if($(".paste-option").length===1){$(".paste-option").clone().addClass("down").appendTo("form.well")}}});if(zerobin.support.localStorage){var j=$(".previous-pastes"),m=zerobin.getPreviousPastes();if(m.length){$.getScript("/static/js/vizhash.min.js").done(function(e,n){j.find(".item").remove();$.each(zerobin.getPreviousPastes(),function(q,s){var t=$('
  • ').appendTo(j);var p=$("").attr("href",s.link).text(s.prefix+s.displayDate).appendTo(t);if(vizhash.supportCanvas){var r=zerobin.getPasteId(s.link);var o=vizhash.canvasHash(r,24,24).canvas;p.prepend($(o).addClass("vhash"))}if(s.link.replace(/#[^#]+/,"")===window.location.pathname){t.addClass("active");p.click(function(){window.location.reload()})}})})}}$(".btn-clone").click(function(n){n.preventDefault();$(".submit-form").show();$(".paste-form").hide();$("#content").val(zerobin.getPasteContent()).trigger("change")});$(".clone .btn-danger").click(function(n){n.preventDefault();$(".submit-form").hide();$(".paste-form").show()});if(zerobin.support.fileUpload){var k=function(n){var e=new FileReader();e.onload=function(o){$("#content").val(o.target.result).trigger("change")};e.readAsText(n[0])};var c=$("#file-upload");var b=$(".btn-upload");try{b.val("Uploading...");b.prop("disabled",true);c.change(function(){k(this.files)})}catch(d){zerobin.message("error","Could no upload the file","Error");b.val("Upload File");b.prop("disabled",false)}b.prop("disabled",false);b.val("Upload File");c.mouseover(a($(this).css,"cursor","pointer"))}$(".close").live("click",function(n){n.preventDefault();$(this).parent().fadeOut()});$(".email-link").each(function(o,p){var r=$(this);var e=r.attr("title").replace("__AT__","@");var q=r.text().replace("__AT__","@");var n=$(''+q+"");r.replaceWith(n)})})})(); \ No newline at end of file +(function(){sjcl.random.startCollectors();$.ajaxSetup({cache:true});function a(c){var b=arguments;return function(){return c.apply(c,Array.prototype.slice.call(b,1))}}window.zerobin={version:"0.1",encrypt:function(f,g,d,b,e,c){setTimeout(function(){g=sjcl.codec.utf8String.toBits(g);if(d){d()}setTimeout(function(){g=sjcl.codec.base64.fromBits(g);if(b){b()}setTimeout(function(){g=lzw.compress(g);if(e){e()}setTimeout(function(){g=sjcl.encrypt(f,g);if(c){c(g)}},250)},250)},250)},250)},decrypt:function(f,g,d,b,e,h,c){setTimeout(function(){try{g=sjcl.decrypt(f,g);if(b){b()}setTimeout(function(){try{g=lzw.decompress(g);if(e){e()}setTimeout(function(){try{g=sjcl.codec.base64.toBits(g);if(h){h()}setTimeout(function(){try{g=sjcl.codec.utf8String.fromBits(g);if(c){c(g)}}catch(l){d(l)}},250)}catch(k){d(k)}},250)}catch(j){d(j)}},250)}catch(i){d(i)}},250)},makeKey:function(){return sjcl.codec.base64.fromBits(sjcl.random.randomWords(8,0),0)},getFormatedDate:function(b){b=b||new Date();return((b.getMonth()+1)+"-"+b.getDate()+"-"+b.getFullYear())},getFormatedTime:function(c){c=c||new Date();var e=c.getHours();var b=c.getMinutes();var d=c.getSeconds();if(e<10){e="0"+e}if(b<10){b="0"+b}if(d<10){d="0"+d}return e+":"+b+":"+d},numOrdA:function(d,c){return(d-c)},getLocalStorageKeys:function(b){b="zerobinV"+(b||zerobin.version);var d=[];for(var c in localStorage){if(c.indexOf(b)!==-1){d.push(c)}}d.sort();d.reverse();return d},getTinyURL:function(d,c){var b="http://json-tinyurl.appspot.com/?url=";$.getJSON(b+encodeURIComponent(d)+"&callback=?",function(e){c(e.tinyurl)})},support:{localStorage:(function(){var b=!!(localStorage);$("html").addClass((b?"":"no-")+"local-storage");return b})(),history:(function(){var b=!!(window.history&&history.pushState);$("html").addClass((b?"":"no-")+"history");return b})(),fileUpload:(function(){var b=window;var c=!!(b.File&&b.FileReader&&b.FileList&&b.Blob);$("html").addClass((c?"":"no-")+"file-upload");return c})()},storePaste:function(c,b){b=b||new Date();b=(b.getFullYear()+"-"+(b.getMonth()+1)+"-"+b.getDate()+" "+zerobin.getFormatedTime(b));var d=zerobin.getLocalStorageKeys();if(localStorage.length>19){void localStorage.removeItem(d[19])}localStorage.setItem("zerobinV"+zerobin.version+"#"+b,c)},getPreviousPastes:function(){var c=[],d=zerobin.getLocalStorageKeys(),b=zerobin.getFormatedDate();$.each(d,function(g,f){var j=f.replace(/^[^#]+#/,"");var e=j.match(/^(\d+)-(\d+)-(\d+)\s/);e=e[2]+"-"+e[3]+"-"+e[1];var h="the ";if(e===b){e=j.split(" ")[1];h="at "}c.push({displayDate:e,prefix:h,link:localStorage.getItem(f)})});return c},parseUrl:(function(){var b=document.createElement("div");b.innerHTML="";return function(c){b.firstChild.href=c;b.innerHTML=b.innerHTML;return b.firstChild}})(),getPasteId:function(b){var c=b?zerobin.parseUrl(b):window.location;return c.pathname.replace(/\/|paste/g,"").replace(/\?.*$/,"")},getPasteKey:function(b){var c=b?zerobin.parseUrl(b):window.location;return c.hash.replace("#","").replace(/\?.*$/,"")},getPasteContent:function(){var b="";$("#paste-content li").each(function(c){b=b+$(this).text()+"\n"});return b},count:function(h,d){var g=/(\r?\n|\r)/g;var c=/(\r?\n|\r|\s+)/g;d=d||{};d.lineBreaks=d.lineBreaks||1;var f=h.length,e=f-h.replace(/[\u0100-\uFFFF]/g,"").length,b=f-h.replace(g,"").length;return f+e+Math.max(0,d.lineBreaks*(b-1))},message:function(d,e,f,b,g){$(window).scrollTop(0);if(b){$(".alert-"+d).remove()}var c=$("#alert-template").clone().attr("id",null).addClass("alert alert-"+d);$(".message",c).html(e);if(f){$(".title",c).html(f)}else{$(".title",c).remove()}c.prependTo($("#main")).show("fadeUp",g)},progressBar:function(b){var d=$(b);var c={container:d,elem:d.find(".bar")};c.set=function(f,e){c.elem.text(f).css("width",e)};return c}};$(function(){$(".btn-primary").live("click",function(s){s.preventDefault();var p=$("textarea").val();var n=zerobin.count($("#content").val());var o=n>zerobin.max_size;var r=Math.round(n/1024);var u=Math.round(zerobin.max_size/1024);if(o){zerobin.message("error",('Your file is '+r+"KB. You have reached the maximum size limit of "+u+"KB."),"Warning!",true)}if(!o&&p.trim()){var x=$("input, textarea, select, button").prop("disabled",true);var t=zerobin.progressBar("form.well .progress");t.container.show();t.set("Converting paste to bits...","25%");try{var w=$("#expiration").val();var v=zerobin.makeKey();zerobin.encrypt(v,p,a(t.set,"Encoding to base64...","45%"),a(t.set,"Compressing...","65%"),a(t.set,"Encrypting...","85%"),function(e){t.set("Sending...","95%");var y={content:e,expiration:w};$.post("/paste/create",y).error(function(z){x.prop("disabled",false);t.container.hide();zerobin.message("error","Paste could not be saved. Please try again later.","Error")}).success(function(A){t.set("Redirecting to new paste...","100%");if(A.status==="error"){zerobin.message("error",A.message,"Error");x.prop("disabled",false);t.container.hide()}else{var z="/paste/"+A.paste+"#"+v;if(zerobin.support.localStorage){zerobin.storePaste(z)}window.location=(z)}})})}catch(q){x.prop("disabled",false);t.container.hide();zerobin.message("error","Paste could not be encrypted. Aborting.","Error")}}});var f=$("#paste-content").text().trim();var i=zerobin.getPasteKey();var h=false;if(f&&i){$.getScript("/static/js/vizhash.min.js").done(function(n,o){if(vizhash.supportCanvas){var e=vizhash.canvasHash(zerobin.getPasteId(),24,24);$('').click(function(p){p.preventDefault();if(confirm("This picture is unique to your paste so you can identify it quickly. \n\n Do you want to know more about this?")){window.open("http://is.gd/IJaMRG","_blank")}}).prependTo(".lnk-option").append(e.canvas)}});var l=$("input, textarea, select, button").prop("disabled",true);var g=zerobin.progressBar(".well form .progress");g.container.show();g.set("Decrypting paste...","25%");zerobin.decrypt(i,f,function(){g.container.hide();zerobin.message("error","Could not decrypt data (Wrong key ?)","Error")},a(g.set,"Decompressing...","45%"),a(g.set,"Base64 decoding...","65%"),a(g.set,"From bits to string...","85%"),function(e){$("#paste-content").text(e);e="";g.set("Code coloration...","95%");setTimeout(function(){ZeroClipboard.setMoviePath("/static/js/ZeroClipboard.swf");var o=new ZeroClipboard.Client();var n=function(){o.reposition()};o.addEventListener("mouseup",function(){$("#clip-button").text("Copying paste...");o.setText(zerobin.getPasteContent())});o.addEventListener("complete",function(){$("#clip-button").text("Copy to clipboard");zerobin.message("info","The paste is now in your clipboard","",true,n)});o.glue("clip-button");window.onresize=n;$("#short-url").click(function(p){p.preventDefault();$("#short-url").text("Loading short url...");zerobin.getTinyURL(window.location.toString(),function(q){o.setText(q);$("#copy-success").hide();zerobin.message("success",''+q+"","Short url",true,n);$("#short-url").text("Get short url")})});$(".close").off().live("click",function(p){p.preventDefault();$(this).parent().fadeOut(n)});prettyPrint();$("#paste-content").addClass("done");g.set("Done","100%");g.container.hide();l.prop("disabled",false)},250)})}$(".paste-option select").live("change",function(){$(".paste-option select").val($(this).val())});$("#content").elastic();$("#content").live("keyup change",function(){if($("#content").height()<400){$(".paste-option.down").remove()}else{if($(".paste-option").length===1){$(".paste-option").clone().addClass("down").appendTo("form.well")}}});if(zerobin.support.localStorage){var j=$(".previous-pastes"),m=zerobin.getPreviousPastes();if(m.length){$.getScript("/static/js/vizhash.min.js").done(function(e,n){j.find(".item").remove();$.each(zerobin.getPreviousPastes(),function(q,s){var t=$('
  • ').appendTo(j);var p=$("").attr("href",s.link).text(s.prefix+s.displayDate).appendTo(t);if(vizhash.supportCanvas){var r=zerobin.getPasteId(s.link);var o=vizhash.canvasHash(r,24,24).canvas;p.prepend($(o).addClass("vhash"))}if(s.link.replace(/#[^#]+/,"")===window.location.pathname){t.addClass("active");p.click(function(){window.location.reload()})}})})}}$(".btn-clone").click(function(n){n.preventDefault();$(".submit-form").show();$(".paste-form").hide();$("#content").val(zerobin.getPasteContent()).trigger("change")});$(".clone .btn-danger").click(function(n){n.preventDefault();$(".submit-form").hide();$(".paste-form").show()});if(zerobin.support.fileUpload){var k=function(n){var e=new FileReader();e.onload=function(o){$("#content").val(o.target.result).trigger("change")};e.readAsText(n[0])};var c=$("#file-upload");var b=$(".btn-upload");try{b.val("Uploading...");b.prop("disabled",true);c.change(function(){k(this.files)})}catch(d){zerobin.message("error","Could no upload the file","Error");b.val("Upload File");b.prop("disabled",false)}b.prop("disabled",false);b.val("Upload File");c.mouseover(a($(this).css,"cursor","pointer"))}$(".close").live("click",function(n){n.preventDefault();$(this).parent().fadeOut()});$(".email-link").each(function(o,p){var r=$(this);var e=r.attr("title").replace("__AT__","@");var q=r.text().replace("__AT__","@");var n=$(''+q+"");r.replaceWith(n)});$("#wrap-content").each(function(e,n){$(n).show()})})})(); \ No newline at end of file