1
0
mirror of https://github.com/Tygs/0bin.git synced 2023-08-10 21:13:00 +03:00

Adding paste history

This commit is contained in:
sam 2012-04-28 22:31:15 +07:00
commit 37e444017e
3 changed files with 95 additions and 34 deletions

View File

@ -11,27 +11,27 @@ text-shadow: 0 1px 0 rgba(255, 255, 255, .1), 0 0 30px rgba(255, 255, 255, .125)
transition: all .2s linear;
}
.brand span {
font-size: 48px;
line-height: 0;
font-size: 48px;
line-height: 0;
}
.brand em {
display: inline;
color: #D40202;
margin: 0px !important;
font-size: 27px;
.brand em {
display: inline;
color: #D40202;
margin: 0px !important;
font-size: 27px;
}
/* body & other stuff */
body {
padding-top: 60px;
padding-bottom: 40px;
padding-top: 60px;
padding-bottom: 40px;
}
.sidebar-nav {
padding: 9px 0;
padding: 9px 0;
}
.btn-group {
@ -43,7 +43,7 @@ padding: 9px 0;
}
#paste-content {
background-color:white;
background-color:white;
}
select {
@ -51,29 +51,38 @@ select {
}
label {
display: inline;
margin-left: 18px;
font-style: italic;
font-size: 11px;
color: #888;
display: inline;
margin-left: 18px;
font-style: italic;
font-size: 11px;
color: #888;
}
ul, ol {
padding: 0;
margin: 0;
padding: 0;
margin: 0;
}
p {
margin: 0 0 20px;
}
.grey {
color: #999;
}
.items {
text-align: center;
}
.nav-list {
padding-right: 0px !important;
font-size: 12px;
}
.form-options li{
float: left;
list-style-type: none;
float: left;
list-style-type: none;
}
form textarea {
@ -106,19 +115,20 @@ form {
}
.btn-primary {
position:relative;
top:-4px;
position:relative;
top:-4px;
}
pre {
padding:1em 20px !important;
padding:1em 20px !important;
}
.linenums {
padding-left: 35px;
padding-left: 35px;
}
ol.linenums li {
line-height:14px;
}
@ -126,7 +136,6 @@ ol.linenums li {
ol.linenums span:first-child {
border-left: solid 1px #999;
padding-left:1em;
}
li.L0, li.L1, li.L2, li.L3, li.L4,

View File

@ -14,6 +14,57 @@ zerobin = {
},
make_key: function() {
return sjcl.codec.base64.fromBits(sjcl.random.randomWords(8, 0), 0);
},
get_date: function(){
var date = new Date();
return date.getDate()+"-"+(date.getMonth()+1)+"-"+date.getFullYear();
},
get_time: function(){
var date = new Date();
var h=date.getHours();
var m=date.getMinutes();
var s=date.getSeconds();
if (h<10) {h = "0" + h}
if (m<10) {m = "0" + m}
if (s<10) {s = "0" + s}
return h+":"+m+":"+s;
},
support_localstorage: function(){
if (localStorage){
return true;
}else{
return false;
}
},
store_paste: function(url){
if (zerobin.support_localstorage){
var date = new Date();
var paste = zerobin.get_date()+" "+zerobin.get_time()+";"+url;
if (localStorage.length > 19)
void removeItem(0);
localStorage.setItem(localStorage.length, paste);
}
},
get_pastes: function(){
if (zerobin.support_localstorage){
var pastes = '';
for (i=localStorage.length-1; i>=0; i--)
{
if (localStorage.getItem(i).split(';')[0].split(' ')[0] == zerobin.get_date()){
var display_date = localStorage.getItem(i).split(';')[0].split(' ')[1];
}else{
var display_date = zerobin.get_date();
}
pastes = pastes + '<li><a class="items" href="' + localStorage.getItem(i).split(';')[1] + '">' + display_date + '</a></li>';
}
if (!pastes){
return '<i class="grey">Your previous pastes will be saved in your browser <a href="http://www.w3.org/TR/webstorage/">localStorage</a>.</i>';
}
return pastes;
}else{
return 'Sorry your browser does not support LocalStorage, We cannot display your previous pastes.';
}
}
};
@ -41,7 +92,9 @@ $('button[type=submit]').live("click", function(e){
alert('Paste could not be saved. Please try again later.');
})
.success(function(data) {
window.location = ('/paste/' + data['paste'] + '#' + key);
var paste_url = '/paste/' + data['paste'] + '#' + key;
window.location = (paste_url);
zerobin.store_paste(paste_url);
});
}
@ -106,7 +159,7 @@ $('#content').live('keyup change', function(){
if ($('.paste-option').length == 1) {
$('.paste-option').clone().addClass('down').appendTo('form.well');
}
};
}
});
});

View File

@ -52,10 +52,9 @@
<div class="row">
<div class="span2">
<div class="well sidebar-nav">
<ul class="nav nav-list">
<ul class="nav nav-list previous-pastes">
<li class="nav-header">Previous pastes</li>
<li><a href="#">paste 1</a></li>
<li><a href="#">Paste 2</a></li>
<li class="items"></li>
</ul>
</div><!--/.well -->
</div><!--/span-->