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:
parent
3c4cb53f69
commit
a3bb45a419
@ -68,12 +68,13 @@ p {
|
||||
margin: 0 0 20px;
|
||||
}
|
||||
|
||||
.nav-header {
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
.form-options li{
|
||||
|
||||
float: left;
|
||||
list-style-type: none;
|
||||
|
||||
float: left;
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
form textarea {
|
||||
@ -106,13 +107,13 @@ form {
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
position:relative;
|
||||
top:-4px;
|
||||
position:relative;
|
||||
top:-4px;
|
||||
}
|
||||
|
||||
|
||||
.linenums{
|
||||
padding:1em 50px;
|
||||
padding:1em 50px;
|
||||
}
|
||||
|
||||
ol.linenums li {
|
||||
@ -122,7 +123,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,
|
||||
|
@ -26,6 +26,31 @@ zerobin = {
|
||||
if(this.width + this.height != 2){no()} else {yes()}
|
||||
}
|
||||
data.src = "data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=";
|
||||
},
|
||||
support_localstorage: function(){
|
||||
if (localStorage){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
},
|
||||
store_paste: function(url){
|
||||
if (zerobin.support_localstorage){
|
||||
localStorage.setItem(localStorage.length, url);
|
||||
}
|
||||
},
|
||||
get_pastes: function(){
|
||||
if (zerobin.support_localstorage){
|
||||
var val = '';
|
||||
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>';
|
||||
}
|
||||
return val;
|
||||
}else{
|
||||
return 'Sorry your browser does not support LocalStorage, We cannot display your previous pastes.';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -50,7 +75,9 @@ $('button[type=submit]').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);
|
||||
});
|
||||
}
|
||||
|
||||
@ -81,7 +108,7 @@ $('#content').elastic();
|
||||
/* Display bottom paste option buttons when needed */
|
||||
if($('#content').height() < 600 ){
|
||||
$('.paste-option.bottom').remove();
|
||||
};
|
||||
}
|
||||
$('#content').live('keyup change', function(){
|
||||
if($('#content').height() < 600 ){
|
||||
$('.paste-option.down').remove();
|
||||
@ -90,8 +117,27 @@ $('#content').live('keyup change', function(){
|
||||
if ($('.paste-option').length == 1) {
|
||||
$('.paste-option').clone().addClass('down').appendTo('form.well');
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
/* Display previous pastes */
|
||||
$('.previous-pastes .items').html(zerobin.get_pastes());
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -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><a class="items" href="#"></a></li>
|
||||
</ul>
|
||||
</div><!--/.well -->
|
||||
</div><!--/span-->
|
||||
|
Loading…
Reference in New Issue
Block a user