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

added previous pastes saving in localstorage

This commit is contained in:
max 2012-04-28 21:37:00 +07:00
parent c34f475698
commit 1fa7218c7d
3 changed files with 62 additions and 31 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; transition: all .2s linear;
} }
.brand span { .brand span {
font-size: 48px; font-size: 48px;
line-height: 0; 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 & other stuff */
body { body {
padding-top: 60px; padding-top: 60px;
padding-bottom: 40px; padding-bottom: 40px;
} }
.sidebar-nav { .sidebar-nav {
padding: 9px 0; padding: 9px 0;
} }
.btn-group { .btn-group {
@ -43,7 +43,7 @@ padding: 9px 0;
} }
#paste-content { #paste-content {
background-color:white; background-color:white;
} }
select { select {
@ -51,25 +51,33 @@ select {
} }
label { label {
display: inline;
display: inline; margin-left: 18px;
margin-left: 18px; font-style: italic;
font-style: italic; font-size: 11px;
font-size: 11px; color: #888;
color: #888;
} }
ul, ol { ul, ol {
padding: 0; padding: 0;
margin: 0; margin: 0;
} }
p { p {
margin: 0 0 20px; margin: 0 0 20px;
} }
.nav-header { .grey {
font-size: 10px; color: #999;
}
.items {
text-align: center;
}
.nav-list {
padding-right: 0px !important;
font-size: 12px;
} }
.form-options li{ .form-options li{
@ -113,11 +121,11 @@ form {
pre { pre {
padding:1em 20px !important; padding:1em 20px !important;
} }
.linenums { .linenums {
padding-left: 35px; padding-left: 35px;
} }

View File

@ -27,6 +27,14 @@ zerobin = {
} }
data.src = "data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs="; data.src = "data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=";
}, },
get_date: function(){
var date = new Date();
return date.getDate()+"-"+(date.getMonth()+1)+"-"+date.getFullYear();
},
get_time: function(){
var date = new Date();
return date.getHours()+":"+date.getMinutes()+":"+date.getSeconds();
},
support_localstorage: function(){ support_localstorage: function(){
if (localStorage){ if (localStorage){
return true; return true;
@ -36,18 +44,33 @@ zerobin = {
}, },
store_paste: function(url){ store_paste: function(url){
if (zerobin.support_localstorage){ if (zerobin.support_localstorage){
localStorage.setItem(localStorage.length, url); var date = new Date();
var paste = zerobin.get_date()+" "+zerobin.get_time()+";"+url;
if (localStorage.length > 19)
void removeItem(localStorage.length);
localStorage.setItem(localStorage.length, paste);
} }
}, },
get_pastes: function(){ get_pastes: function(){
if (zerobin.support_localstorage){ if (zerobin.support_localstorage){
var val = ''; var date = new Date();
var pastes = '';
var key = '';
for (i=0; i<=localStorage.length-1; i++) for (i=0; i<=localStorage.length-1; i++)
{ {
key = localStorage.key(i); key = localStorage.key(i);
val = val + '<li><a class="items" href="' + localStorage.getItem(key) + '">paste ' + (i+1) + '</a></li>'; if (localStorage.getItem(key).split(';')[0].split(' ')[0] == zerobin.get_date()){
var display_date = localStorage.getItem(key).split(';')[0].split(' ')[1];
}else{
var display_date = zerobin.get_date();
}
pastes = pastes + '<li><a class="items" href="' + localStorage.getItem(key).split(';')[1] + '">' + display_date + '</a></li>';
} }
return val; 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{ }else{
return 'Sorry your browser does not support LocalStorage, We cannot display your previous pastes.'; return 'Sorry your browser does not support LocalStorage, We cannot display your previous pastes.';
} }

View File

@ -54,7 +54,7 @@
<div class="well sidebar-nav"> <div class="well sidebar-nav">
<ul class="nav nav-list previous-pastes"> <ul class="nav nav-list previous-pastes">
<li class="nav-header">Previous pastes</li> <li class="nav-header">Previous pastes</li>
<li><a class="items" href="#"></a></li> <li class="items"></li>
</ul> </ul>
</div><!--/.well --> </div><!--/.well -->
</div><!--/span--> </div><!--/span-->