diff --git a/README.md b/README.md index 3c70261..525fe59 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ 0bin ==== -Have try here: 0bin.net +Have try here: 0bin.net 0bin is client side encrypted pastebin that can run without a database. -It allows anybody to host a pastebin while welcoming any type of content to be pasted in it. The idea is that one can (probably...) not be legally entitled to moderate the pastebin content (http://www.zdnet.com/blog/security/pastebin-to-hunt-for-hacker-pastes-anonymous-cries-censorship/11336) as one has no way to decrypt it. +It allows anybody to host a pastebin while welcoming any type of content to be pasted in it. The idea is that one can (probably...) not be legally entitled to moderate the pastebin content as he/she has no way to decrypt it. -It's an Python implementation of the zerobin project (https://github.com/sebsauvage/ZeroBin/). +It's an Python implementation of the zerobin project. How it works ============= @@ -56,5 +56,5 @@ What does 0bin not implement? ================================= * Request throttling. It would be inefficient to do it at the app level, and web servers have robust implementations. -* Hash collision: the ratio "probability it happens/consequence seriousness" is not worth it (http://stackoverflow.com/questions/201705/how-many-random-elements-before-md5-produces-collisions) -* Comments: for now. It's no the todo list. \ No newline at end of file +* Hash collision: the ratio "probability it happens/consequence seriousness" is not worth it +* Comments: for now. It's on the todo list. \ No newline at end of file diff --git a/static/js/behavior.js b/static/js/behavior.js index 383f149..e88c7d3 100644 --- a/static/js/behavior.js +++ b/static/js/behavior.js @@ -142,15 +142,10 @@ zerobin = { }, /** Get a tinyurl using JSONP */ getTinyURL: function(longURL, success) { - - callback = 'zerobin_tiny_url_callback'; - window[callback] = function(response){ - success(response.tinyurl); - delete window[callback]; - }; - var api = 'http://json-tinyurl.appspot.com/?url='; - $.getJSON(api + encodeURIComponent(longURL) + '&callback=' + callback); + $.getJSON(api + encodeURIComponent(longURL) + '&callback=?', function(data){ + success(data.tinyurl); + }); }, support: { @@ -227,7 +222,7 @@ zerobin = { message: function(type, message, title, flush, callback) { $(window).scrollTop(0); - + if (flush) {$('.alert-'+type).remove()} $message = $('#alert-template').clone().attr('id', null) @@ -373,21 +368,6 @@ if (content && key) { /* Add a continuation to let the UI redraw */ setTimeout(function(){ - /* Setup link to get the paste short url*/ - $('#short-url').click(function(e) { - e.preventDefault(); - $('#short-url').text('Loading short url...'); - zerobin.getTinyURL(window.location.toString(), function(tinyurl){ - clip.setText(tinyurl); - $('#copy-success').hide(); - zerobin.message('success', - '' + tinyurk + '', - 'Short url' - ) - $('#short-url').text('Get short url'); - }); - }); - /* Setup flash clipboard button */ ZeroClipboard.setMoviePath('/static/js/ZeroClipboard.swf'); @@ -403,6 +383,29 @@ if (content && key) { window.onresize = clip.reposition; + + /* Setup link to get the paste short url*/ + $('#short-url').click(function(e) { + e.preventDefault(); + $('#short-url').text('Loading short url...'); + zerobin.getTinyURL(window.location.toString(), function(tinyurl){ + clip.setText(tinyurl); + $('#copy-success').hide(); + zerobin.message('success', + '' + tinyurl + '', + 'Short url', true, function(){clip.reposition()} + ) + $('#short-url').text('Get short url'); + }); + }); + + /* Remap the message close handler to include the clipboard + flash reposition */ + $(".close").die().live('click', function(e){ + e.preventDefault(); + $(this).parent().fadeOut(function(){clip.reposition()}); + }); + /** Syntaxic coloration */ prettyPrint(); @@ -488,7 +491,8 @@ $('#file-upload').mouseover(function(){ /* Alerts */ -$(".close").live('click', function(){ +$(".close").live('click', function(e){ + e.preventDefault(); $(this).parent().fadeOut(); });