mirror of
https://github.com/Tygs/0bin.git
synced 2023-08-10 21:13:00 +03:00
Unifying name conventions
This commit is contained in:
parent
65d75f2faf
commit
4c29b45095
@ -109,16 +109,16 @@ zerobin = {
|
|||||||
|
|
||||||
/** Create a random base64 string long enought to be suitable as
|
/** Create a random base64 string long enought to be suitable as
|
||||||
an encryption key */
|
an encryption key */
|
||||||
make_key: function() {
|
makeKey: function() {
|
||||||
return sjcl.codec.base64.fromBits(sjcl.random.randomWords(8, 0), 0);
|
return sjcl.codec.base64.fromBits(sjcl.random.randomWords(8, 0), 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
get_date: function(){
|
getDate: function(){
|
||||||
var date = new Date();
|
var date = new Date();
|
||||||
return date.getDate()+"-"+(date.getMonth()+1)+"-"+date.getFullYear();
|
return date.getDate()+"-"+(date.getMonth()+1)+"-"+date.getFullYear();
|
||||||
},
|
},
|
||||||
|
|
||||||
get_time: function(){
|
getTime: function(){
|
||||||
var date = new Date();
|
var date = new Date();
|
||||||
var h=date.getHours();
|
var h=date.getHours();
|
||||||
var m=date.getMinutes();
|
var m=date.getMinutes();
|
||||||
@ -133,7 +133,7 @@ zerobin = {
|
|||||||
return (a-b);
|
return (a-b);
|
||||||
},
|
},
|
||||||
|
|
||||||
get_keys: function(){
|
getKeys: function(){
|
||||||
var keys = new Array();
|
var keys = new Array();
|
||||||
for(i=0; i<=localStorage.length; i++){
|
for(i=0; i<=localStorage.length; i++){
|
||||||
if(localStorage.key(i) != null)
|
if(localStorage.key(i) != null)
|
||||||
@ -155,19 +155,20 @@ zerobin = {
|
|||||||
$.getJSON(api + encodeURIComponent(longURL) + '&callback=' + callback);
|
$.getJSON(api + encodeURIComponent(longURL) + '&callback=' + callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
support_localstorage: function(){
|
support: {
|
||||||
if (localStorage){
|
localstorage: function(){
|
||||||
return true;
|
return !!(localStorage);
|
||||||
}else{
|
},
|
||||||
return false;
|
history: function(){
|
||||||
|
return !!(window.history && history.pushState);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
store_paste: function(url){
|
storatePaste: function(url){
|
||||||
if (zerobin.support_localstorage){
|
if (zerobin.support.localstorage){
|
||||||
var date = new Date();
|
var date = new Date();
|
||||||
var paste = zerobin.get_date()+" "+zerobin.get_time()+";"+url;
|
var paste = zerobin.getDate()+" "+zerobin.getTime()+";"+url;
|
||||||
var keys = zerobin.get_keys();
|
var keys = zerobin.getKeys();
|
||||||
|
|
||||||
if(keys.length < 1)
|
if(keys.length < 1)
|
||||||
keys[0] = 0;
|
keys[0] = 0;
|
||||||
@ -178,20 +179,20 @@ zerobin = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
get_pastes: function(){
|
getPastes: function(){
|
||||||
if (zerobin.support_localstorage){
|
if (zerobin.support.localstorage){
|
||||||
var pastes = '';
|
var pastes = '';
|
||||||
var keys = zerobin.get_keys();
|
var keys = zerobin.getKeys();
|
||||||
keys.reverse();
|
keys.reverse();
|
||||||
|
|
||||||
for (i=0; i<=keys.length-1; i++)
|
for (i=0; i<=keys.length-1; i++)
|
||||||
{
|
{
|
||||||
var paste = localStorage.getItem(keys[i]);
|
var paste = localStorage.getItem(keys[i]);
|
||||||
if (paste.split(';')[0].split(' ')[0] == zerobin.get_date()){
|
if (paste.split(';')[0].split(' ')[0] == zerobin.getDate()){
|
||||||
var display_date = paste.split(';')[0].split(' ')[1];
|
var display_date = paste.split(';')[0].split(' ')[1];
|
||||||
var on_at = 'at ';
|
var on_at = 'at ';
|
||||||
}else{
|
}else{
|
||||||
var display_date = zerobin.get_date();
|
var display_date = zerobin.getDate();
|
||||||
var on_at = 'on ';
|
var on_at = 'on ';
|
||||||
}
|
}
|
||||||
pastes = pastes + '<li><a class="items" href="' + paste.split(';')[1] + '">' + on_at + display_date + '</a></li>';
|
pastes = pastes + '<li><a class="items" href="' + paste.split(';')[1] + '">' + on_at + display_date + '</a></li>';
|
||||||
@ -243,7 +244,7 @@ $('button[type=submit]').live("click", function(e){
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
var expiration = $('#expiration').val();
|
var expiration = $('#expiration').val();
|
||||||
var key = zerobin.make_key();
|
var key = zerobin.makeKey();
|
||||||
|
|
||||||
zerobin.encrypt(key, paste,
|
zerobin.encrypt(key, paste,
|
||||||
|
|
||||||
@ -266,7 +267,7 @@ $('button[type=submit]').live("click", function(e){
|
|||||||
.success(function(data) {
|
.success(function(data) {
|
||||||
$loading.text('Redirecting to new paste...').css('width', '100%');
|
$loading.text('Redirecting to new paste...').css('width', '100%');
|
||||||
var paste_url = '/paste/' + data['paste'] + '#' + key;
|
var paste_url = '/paste/' + data['paste'] + '#' + key;
|
||||||
zerobin.store_paste(paste_url);
|
zerobin.storatePaste(paste_url);
|
||||||
window.location = (paste_url);
|
window.location = (paste_url);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -334,7 +335,7 @@ if (content && key) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
/* Setup flash clipboard button */
|
/* Setup flash clipboard button */
|
||||||
ZeroClipboard.setMoviePath('/static/js/ZeroClipboard.swf' );
|
ZeroClipboard.setMoviePath('/static/js/ZeroClipboard.swf');
|
||||||
|
|
||||||
var clip = new ZeroClipboard.Client();
|
var clip = new ZeroClipboard.Client();
|
||||||
clip.addEventListener('mouseup', function(){
|
clip.addEventListener('mouseup', function(){
|
||||||
@ -383,7 +384,7 @@ $('#content').live('keyup change', function(){
|
|||||||
});
|
});
|
||||||
|
|
||||||
/* Display previous pastes */
|
/* Display previous pastes */
|
||||||
$('.previous-pastes .items').html(zerobin.get_pastes());
|
$('.previous-pastes .items').html(zerobin.getPastes());
|
||||||
|
|
||||||
/* clone a paste */
|
/* clone a paste */
|
||||||
$('.btn-clone').click(function(e){
|
$('.btn-clone').click(function(e){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user