mirror of
https://github.com/Tygs/0bin.git
synced 2023-08-10 21:13:00 +03:00
Give uploading hint, added header to python files andimproved data handling a little
This commit is contained in:
parent
c7b815c471
commit
8828f3cc74
@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: ai ts=4 sts=4 et sw=4
|
||||||
|
|
||||||
|
VERSION = __version__ = "0.1"
|
@ -1,4 +1,6 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: ai ts=4 sts=4 et sw=4
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import math
|
import math
|
||||||
|
2
start.py
2
start.py
@ -1,4 +1,6 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: ai ts=4 sts=4 et sw=4
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Main script including controller, rooting, dependancy management, and
|
Main script including controller, rooting, dependancy management, and
|
||||||
|
@ -33,6 +33,7 @@ zerobin = {
|
|||||||
and all of them are executed in a timed continuation to give
|
and all of them are executed in a timed continuation to give
|
||||||
a change to the UI to respond.
|
a change to the UI to respond.
|
||||||
*/
|
*/
|
||||||
|
version: '0.1',
|
||||||
encrypt: function(key, content, toBase64Callback,
|
encrypt: function(key, content, toBase64Callback,
|
||||||
compressCallback, encryptCallback, doneCallback) {
|
compressCallback, encryptCallback, doneCallback) {
|
||||||
|
|
||||||
@ -135,20 +136,21 @@ zerobin = {
|
|||||||
return sjcl.codec.base64.fromBits(sjcl.random.randomWords(8, 0), 0);
|
return sjcl.codec.base64.fromBits(sjcl.random.randomWords(8, 0), 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
getDate: function(){
|
getFormatedDate: function(date){
|
||||||
var date = new Date();
|
var date = date || new Date();
|
||||||
return date.getDate()+"-"+(date.getMonth()+1)+"-"+date.getFullYear();
|
return ((date.getMonth() +1 ) + '-' +
|
||||||
|
date.getDate() + '-' + date.getFullYear());
|
||||||
},
|
},
|
||||||
|
|
||||||
getTime: function(){
|
getFormatedTime: function(date){
|
||||||
var date = new Date();
|
var date = date || new Date();
|
||||||
var h=date.getHours();
|
var h = date.getHours();
|
||||||
var m=date.getMinutes();
|
var m = date.getMinutes();
|
||||||
var s=date.getSeconds();
|
var s = date.getSeconds();
|
||||||
if (h<10) {h = "0" + h}
|
if (h < 10) {h = "0" + h}
|
||||||
if (m<10) {m = "0" + m}
|
if (m < 10) {m = "0" + m}
|
||||||
if (s<10) {s = "0" + s}
|
if (s < 10) {s = "0" + s}
|
||||||
return h+":"+m+":"+s;
|
return h + ":" + m + ":" + s;
|
||||||
},
|
},
|
||||||
|
|
||||||
numOrdA: function(a, b){
|
numOrdA: function(a, b){
|
||||||
@ -156,8 +158,8 @@ zerobin = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getKeys: function(){
|
getKeys: function(){
|
||||||
var keys = new Array();
|
var keys = [];
|
||||||
for(i=0; i<=localStorage.length; i++){
|
for(i=0; i <= localStorage.length; i++){
|
||||||
if(localStorage.key(i) != null)
|
if(localStorage.key(i) != null)
|
||||||
keys[i] = parseInt(localStorage.key(i),10);
|
keys[i] = parseInt(localStorage.key(i),10);
|
||||||
}
|
}
|
||||||
@ -196,7 +198,8 @@ zerobin = {
|
|||||||
|
|
||||||
storatePaste: function(url){
|
storatePaste: function(url){
|
||||||
if (zerobin.support.localStorage){
|
if (zerobin.support.localStorage){
|
||||||
var paste = zerobin.getDate()+" "+zerobin.getTime()+";"+url;
|
var paste = (zerobin.getFormatedDate() + " " +
|
||||||
|
zerobin.getFormatedTime() + ";" + url);
|
||||||
var keys = zerobin.getKeys();
|
var keys = zerobin.getKeys();
|
||||||
|
|
||||||
if(keys.length < 1){keys[0] = 0}
|
if(keys.length < 1){keys[0] = 0}
|
||||||
@ -213,13 +216,13 @@ zerobin = {
|
|||||||
getPreviousPastes: function(){
|
getPreviousPastes: function(){
|
||||||
var pastes = [],
|
var pastes = [],
|
||||||
keys = zerobin.getKeys(),
|
keys = zerobin.getKeys(),
|
||||||
date = zerobin.getDate(),
|
date = zerobin.getFormatedDate();
|
||||||
prefix = 'on ';
|
|
||||||
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]).split(';');
|
var paste = localStorage.getItem(keys[i]).split(';');
|
||||||
var displayDate = paste[0].split(' ')[0];
|
var displayDate = paste[0].split(' ')[0];
|
||||||
|
var prefix = 'the ';
|
||||||
if (displayDate == date){
|
if (displayDate == date){
|
||||||
displayDate = paste[0].split(' ')[1];
|
displayDate = paste[0].split(' ')[1];
|
||||||
prefix = 'at ';
|
prefix = 'at ';
|
||||||
@ -306,7 +309,7 @@ $(function(){
|
|||||||
posting it using ajax. Then redirect to the address of the
|
posting it using ajax. Then redirect to the address of the
|
||||||
newly created paste, adding the key in the hash.
|
newly created paste, adding the key in the hash.
|
||||||
*/
|
*/
|
||||||
$('.btn-primary').live("click", function(e){
|
$('.btn-primary').on("click", function(e){
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var paste = $('textarea').val();
|
var paste = $('textarea').val();
|
||||||
@ -485,7 +488,7 @@ if (content && key) {
|
|||||||
|
|
||||||
/* Remap the message close handler to include the clipboard
|
/* Remap the message close handler to include the clipboard
|
||||||
flash reposition */
|
flash reposition */
|
||||||
$(".close").die().live('click', function(e){
|
$(".close").off().on('click', function(e){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$(this).parent().fadeOut(reposition);
|
$(this).parent().fadeOut(reposition);
|
||||||
});
|
});
|
||||||
@ -510,7 +513,7 @@ if (content && key) {
|
|||||||
} /* End of "DECRYPTION" */
|
} /* End of "DECRYPTION" */
|
||||||
|
|
||||||
/* Synchronize expiration select boxes value */
|
/* Synchronize expiration select boxes value */
|
||||||
$('.paste-option select').live('change', function(){
|
$('.paste-option select').on('change', function(){
|
||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
$this.val($this.val());
|
$this.val($this.val());
|
||||||
});
|
});
|
||||||
@ -601,20 +604,28 @@ if (zerobin.support.fileUpload) {
|
|||||||
reader.readAsText(files[0]);
|
reader.readAsText(files[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
var $button = $('#file-upload');
|
var $buttonOverlay = $('#file-upload');
|
||||||
|
var $button = $('.btn-upload');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$button.change(function(){upload(this.files)});
|
$button.val('Uploading...');
|
||||||
|
$button.prop('disabled', true);
|
||||||
|
$buttonOverlay.change(function(){upload(this.files)});
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
zerobin.message('error', 'Could no upload the file', 'Error');
|
zerobin.message('error', 'Could no upload the file', 'Error');
|
||||||
|
$button.val('Upload File');
|
||||||
|
$button.prop('disabled', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
$button.mouseover(mkcb($(this).css, 'cursor', 'pointer'));
|
$button.prop('disabled', false);
|
||||||
|
$button.val('Upload File');
|
||||||
|
$buttonOverlay.mouseover(mkcb($(this).css, 'cursor', 'pointer'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Alerts */
|
/* Alerts */
|
||||||
|
|
||||||
$(".close").live('click', function(e){
|
$(".close").on('click', function(e){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$(this).parent().fadeOut();
|
$(this).parent().fadeOut();
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user