wok-next diff zerobin/stuff/zerobin.u @ rev 19435
zerobin: add download button
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Tue Oct 04 15:33:49 2016 +0200 (2016-10-04) |
parents | 139df21c10dd |
children | 8fd5d4c953f6 |
line diff
1.1 --- a/zerobin/stuff/zerobin.u Mon Dec 21 16:28:32 2015 +0100 1.2 +++ b/zerobin/stuff/zerobin.u Tue Oct 04 15:33:49 2016 +0200 1.3 @@ -14,7 +14,7 @@ 1.4 // trafic_limiter : Make sure the IP address makes at most 1 request every 10 seconds. 1.5 // Will return false if IP address made a call less than 10 seconds ago. 1.6 function trafic_limiter_canPass($ip) 1.7 -@@ -144,7 +151,7 @@ 1.8 +@@ -157,7 +164,7 @@ 1.9 } 1.10 1.11 // Make sure last paste from the IP address was more than 10 seconds ago. 1.12 @@ -23,7 +23,7 @@ 1.13 { echo json_encode(array('status'=>1,'message'=>'Please wait 10 seconds between each post.')); exit; } 1.14 1.15 // Make sure content is not too big. 1.16 -@@ -216,7 +223,7 @@ 1.17 +@@ -229,7 +236,7 @@ 1.18 // (We assume that if the user did not enter a nickname, he/she wants 1.19 // to be anonymous and we will not generate the vizhash.) 1.20 $vz = new vizhash16x16(); 1.21 @@ -49,3 +49,44 @@ 1.22 var cipherdata = zeroCipher(randomkey, $('textarea#message').val()); 1.23 var data_to_send = { data: cipherdata, 1.24 expire: $('select#pasteExpiration').val(), 1.25 +@@ -416,6 +416,7 @@ 1.26 + $('button#sendbutton').show(); 1.27 + $('button#clonebutton').hide(); 1.28 + $('button#rawtextbutton').hide(); 1.29 ++ $('button#downloadbutton').hide(); 1.30 + $('div#expiration').show(); 1.31 + $('div#remainingtime').hide(); 1.32 + $('div#burnafterreadingoption').show(); 1.33 +@@ -444,6 +445,7 @@ 1.34 + $('button#clonebutton').show(); 1.35 + } 1.36 + $('button#rawtextbutton').show(); 1.37 ++ $('button#downloadbutton').show(); 1.38 + 1.39 + $('div#expiration').hide(); 1.40 + $('div#burnafterreadingoption').hide(); 1.41 +@@ -463,6 +465,14 @@ 1.42 + var newDoc = document.open('text/html', 'replace'); 1.43 + newDoc.write('<pre>'+paste+'</pre>'); 1.44 + newDoc.close(); 1.45 ++} 1.46 ++ 1.47 ++/** Download raw text 1.48 ++ */ 1.49 ++function downLoad() 1.50 ++{ 1.51 ++ var paste = $('div#cleartext').html(); 1.52 ++ document.location = 'data:Application/octet-stream,' + encodeURIComponent(paste); 1.53 + } 1.54 + 1.55 + /** 1.56 +--- tpl/page.html 1.57 ++++ tpl/page.html 1.58 +@@ -47,6 +47,7 @@ 1.59 + <button id="sendbutton" onclick="send_data();return false;" style="display:none;"><img src="img/icon_send.png#" width="18" height="15" />Send</button> 1.60 + <button id="clonebutton" onclick="clonePaste();return false;" style="display:none;"><img src="img/icon_clone.png#" width="15" height="17" />Clone</button> 1.61 + <button id="rawtextbutton" onclick="rawText();return false;" style="display:none; "><img src="img/icon_raw.png#" width="15" height="15" style="padding:1px 0px 1px 0px;"/>Raw text</button> 1.62 ++ <button id="downloadbutton" onclick="downLoad();return false;" style="display:none; "><img src="img/icon_new.png#" width="11" height="15" style="padding:1px 0px 1px 0px;"/>Download</button> 1.63 + <div id="expiration" style="display:none;">Expires: 1.64 + <select id="pasteExpiration" name="pasteExpiration"> 1.65 + <option value="5min">5 minutes</option>