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;
}
.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,25 +51,33 @@ 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;
}
.nav-header {
font-size: 10px;
.grey {
color: #999;
}
.items {
text-align: center;
}
.nav-list {
padding-right: 0px !important;
font-size: 12px;
}
.form-options li{
@ -113,11 +121,11 @@ form {
pre {
padding:1em 20px !important;
padding:1em 20px !important;
}
.linenums {
padding-left: 35px;
padding-left: 35px;
}

View File

@ -27,6 +27,14 @@ zerobin = {
}
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(){
if (localStorage){
return true;
@ -36,18 +44,33 @@ zerobin = {
},
store_paste: function(url){
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(){
if (zerobin.support_localstorage){
var val = '';
if (zerobin.support_localstorage){
var date = new Date();
var pastes = '';
var key = '';
for (i=0; i<=localStorage.length-1; i++)
{
key = localStorage.key(i);
val = val + '<li><a class="items" href="' + localStorage.getItem(key) + '">paste ' + (i+1) + '</a></li>';
key = localStorage.key(i);
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{
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">
<ul class="nav nav-list previous-pastes">
<li class="nav-header">Previous pastes</li>
<li><a class="items" href="#"></a></li>
<li class="items"></li>
</ul>
</div><!--/.well -->
</div><!--/span-->