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,17 +11,17 @@ 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;
}
.brand em {
display: inline;
color: #D40202;
margin: 0px !important;
font-size: 27px;
}
/* body & other stuff */
@ -51,7 +51,6 @@ select {
}
label {
display: inline;
margin-left: 18px;
font-style: italic;
@ -68,8 +67,17 @@ 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{

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 = '';
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>';
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();
}
return val;
pastes = pastes + '<li><a class="items" href="' + localStorage.getItem(key).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.';
}

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-->