1
0
mirror of http://git.whoc.org.uk/git/password-manager.git synced 2025-10-24 17:27:35 +02:00

Implemented Attachments in client

This commit is contained in:
Dario Chiappetta
2015-11-23 16:10:44 +01:00
parent 8608fb4253
commit 8c59393433
50 changed files with 4862 additions and 272 deletions

View File

@@ -0,0 +1,171 @@
/*
Copyright 2008-2015 Clipperz Srl
This file is part of Clipperz, the online password manager.
For further information about its features and functionalities please
refer to http://www.clipperz.com.
* Clipperz is free software: you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
* Clipperz is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public
License along with Clipperz. If not, see http://www.gnu.org/licenses/.
*/
/**
* filesize
*
* @author Jason Mulligan <jason.mulligan@avoidwork.com>
* @copyright 2015 Jason Mulligan <jason.mulligan@avoidwork.com>
* @license BSD-3-Clause
* @link http://filesizejs.com
* @module filesize
* @version 3.1.3
*/
( global ) => {
const bit = /b$/;
const si = {
bits: [ "B", "kb", "Mb", "Gb", "Tb", "Pb", "Eb", "Zb", "Yb" ],
bytes: [ "B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" ]
};
/**
* filesize
*
* @method filesize
* @param {Mixed} arg String, Int or Float to transform
* @param {Object} descriptor [Optional] Flags
* @return {String} Readable file size String
*/
let filesize = ( arg, descriptor={} ) => {
let result = [];
let skip = false;
let val = 0;
let e, base, bits, ceil, neg, num, output, round, unix, spacer, suffixes;
if ( isNaN( arg ) ) {
throw new Error( "Invalid arguments" );
}
bits = ( descriptor.bits === true );
unix = ( descriptor.unix === true );
base = descriptor.base !== undefined ? descriptor.base : 2;
round = descriptor.round !== undefined ? descriptor.round : unix ? 1 : 2;
spacer = descriptor.spacer !== undefined ? descriptor.spacer : unix ? "" : " ";
suffixes = descriptor.suffixes !== undefined ? descriptor.suffixes : {};
output = descriptor.output !== undefined ? descriptor.output : "string";
e = descriptor.exponent !== undefined ? descriptor.exponent : -1;
num = Number( arg );
neg = ( num < 0 );
ceil = base > 2 ? 1000 : 1024;
// Flipping a negative number to determine the size
if ( neg ) {
num = -num;
}
// Zero is now a special case because bytes divide by 1
if ( num === 0 ) {
result[ 0 ] = 0;
if ( unix ) {
result[ 1 ] = "";
}
else {
result[ 1 ] = "B";
}
}
else {
// Determining the exponent
if ( e === -1 || isNaN( e ) ) {
e = Math.floor( Math.log( num ) / Math.log( ceil ) );
}
// Exceeding supported length, time to reduce & multiply
if ( e > 8 ) {
val = val * ( 1000 * ( e - 8 ) );
e = 8;
}
if ( base === 2 ) {
val = num / Math.pow( 2, ( e * 10 ) );
}
else {
val = num / Math.pow( 1000, e );
}
if ( bits ) {
val = ( val * 8 );
if ( val > ceil ) {
val = val / ceil;
e++;
}
}
result[ 0 ] = Number( val.toFixed( e > 0 ? round : 0 ) );
result[ 1 ] = si[ bits ? "bits" : "bytes" ][ e ];
if ( !skip && unix ) {
if ( bits && bit.test( result[ 1 ] ) ) {
result[ 1 ] = result[ 1 ].toLowerCase();
}
result[ 1 ] = result[ 1 ].charAt( 0 );
if ( result[ 1 ] === "B" ) {
result[ 0 ] = Math.floor( result[ 0 ] );
result[ 1 ] = "";
}
else if ( !bits && result[ 1 ] === "k" ) {
result[ 1 ] = "K";
}
}
}
// Decorating a 'diff'
if ( neg ) {
result[ 0 ] = -result[ 0 ];
}
// Applying custom suffix
result[ 1 ] = suffixes[ result[ 1 ] ] || result[ 1 ];
// Returning Array, Object, or String (default)
if ( output === "array" ) {
return result;
}
if ( output === "exponent" ) {
return e;
}
if ( output === "object" ) {
return { value: result[ 0 ], suffix: result[ 1 ] };
}
return result.join( spacer );
}
// CommonJS, AMD, script tag
if ( typeof exports !== "undefined" ) {
module.exports = filesize;
}
else if ( typeof define === "function" ) {
define( () => {
return filesize;
} );
}
else {
global.filesize = filesize;
}
}( typeof global !== "undefined" ? global : window );

View File

@@ -0,0 +1,179 @@
/*
Copyright 2008-2015 Clipperz Srl
This file is part of Clipperz, the online password manager.
For further information about its features and functionalities please
refer to http://www.clipperz.com.
* Clipperz is free software: you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
* Clipperz is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public
License along with Clipperz. If not, see http://www.gnu.org/licenses/.
*/
"use strict";
/**
* filesize
*
* @author Jason Mulligan <jason.mulligan@avoidwork.com>
* @copyright 2015 Jason Mulligan <jason.mulligan@avoidwork.com>
* @license BSD-3-Clause
* @link http://filesizejs.com
* @module filesize
* @version 3.1.3
*/
(function (global) {
var bit = /b$/;
var si = {
bits: ["B", "kb", "Mb", "Gb", "Tb", "Pb", "Eb", "Zb", "Yb"],
bytes: ["B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]
};
/**
* filesize
*
* @method filesize
* @param {Mixed} arg String, Int or Float to transform
* @param {Object} descriptor [Optional] Flags
* @return {String} Readable file size String
*/
var filesize = function (arg) {
var descriptor = arguments[1] === undefined ? {} : arguments[1];
var result = [];
var skip = false;
var val = 0;
var e = undefined,
base = undefined,
bits = undefined,
ceil = undefined,
neg = undefined,
num = undefined,
output = undefined,
round = undefined,
unix = undefined,
spacer = undefined,
suffixes = undefined;
if (isNaN(arg)) {
throw new Error("Invalid arguments");
}
bits = descriptor.bits === true;
unix = descriptor.unix === true;
base = descriptor.base !== undefined ? descriptor.base : 2;
round = descriptor.round !== undefined ? descriptor.round : unix ? 1 : 2;
spacer = descriptor.spacer !== undefined ? descriptor.spacer : unix ? "" : " ";
suffixes = descriptor.suffixes !== undefined ? descriptor.suffixes : {};
output = descriptor.output !== undefined ? descriptor.output : "string";
e = descriptor.exponent !== undefined ? descriptor.exponent : -1;
num = Number(arg);
neg = num < 0;
ceil = base > 2 ? 1000 : 1024;
// Flipping a negative number to determine the size
if (neg) {
num = -num;
}
// Zero is now a special case because bytes divide by 1
if (num === 0) {
result[0] = 0;
if (unix) {
result[1] = "";
} else {
result[1] = "B";
}
} else {
// Determining the exponent
if (e === -1 || isNaN(e)) {
e = Math.floor(Math.log(num) / Math.log(ceil));
}
// Exceeding supported length, time to reduce & multiply
if (e > 8) {
val = val * (1000 * (e - 8));
e = 8;
}
if (base === 2) {
val = num / Math.pow(2, e * 10);
} else {
val = num / Math.pow(1000, e);
}
if (bits) {
val = val * 8;
if (val > ceil) {
val = val / ceil;
e++;
}
}
result[0] = Number(val.toFixed(e > 0 ? round : 0));
result[1] = si[bits ? "bits" : "bytes"][e];
if (!skip && unix) {
if (bits && bit.test(result[1])) {
result[1] = result[1].toLowerCase();
}
result[1] = result[1].charAt(0);
if (result[1] === "B") {
result[0] = Math.floor(result[0]);
result[1] = "";
} else if (!bits && result[1] === "k") {
result[1] = "K";
}
}
}
// Decorating a 'diff'
if (neg) {
result[0] = -result[0];
}
// Applying custom suffix
result[1] = suffixes[result[1]] || result[1];
// Returning Array, Object, or String (default)
if (output === "array") {
return result;
}
if (output === "exponent") {
return e;
}
if (output === "object") {
return { value: result[0], suffix: result[1] };
}
return result.join(spacer);
};
// CommonJS, AMD, script tag
if (typeof exports !== "undefined") {
module.exports = filesize;
} else if (typeof define === "function") {
define(function () {
return filesize;
});
} else {
global.filesize = filesize;
}
})(typeof global !== "undefined" ? global : window);

View File

@@ -0,0 +1,29 @@
/*
Copyright 2008-2015 Clipperz Srl
This file is part of Clipperz, the online password manager.
For further information about its features and functionalities please
refer to http://www.clipperz.com.
* Clipperz is free software: you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
* Clipperz is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public
License along with Clipperz. If not, see http://www.gnu.org/licenses/.
*/
/*
2015
@version 3.1.3
*/
"use strict";!function(a){var b=/b$/,c={bits:["B","kb","Mb","Gb","Tb","Pb","Eb","Zb","Yb"],bytes:["B","kB","MB","GB","TB","PB","EB","ZB","YB"]},d=function(a){var d=void 0===arguments[1]?{}:arguments[1],e=[],f=!1,g=0,h=void 0,i=void 0,j=void 0,k=void 0,l=void 0,m=void 0,n=void 0,o=void 0,p=void 0,q=void 0,r=void 0;if(isNaN(a))throw new Error("Invalid arguments");return j=d.bits===!0,p=d.unix===!0,i=void 0!==d.base?d.base:2,o=void 0!==d.round?d.round:p?1:2,q=void 0!==d.spacer?d.spacer:p?"":" ",r=void 0!==d.suffixes?d.suffixes:{},n=void 0!==d.output?d.output:"string",h=void 0!==d.exponent?d.exponent:-1,m=Number(a),l=0>m,k=i>2?1e3:1024,l&&(m=-m),0===m?(e[0]=0,e[1]=p?"":"B"):((-1===h||isNaN(h))&&(h=Math.floor(Math.log(m)/Math.log(k))),h>8&&(g=1e3*g*(h-8),h=8),g=2===i?m/Math.pow(2,10*h):m/Math.pow(1e3,h),j&&(g=8*g,g>k&&(g/=k,h++)),e[0]=Number(g.toFixed(h>0?o:0)),e[1]=c[j?"bits":"bytes"][h],!f&&p&&(j&&b.test(e[1])&&(e[1]=e[1].toLowerCase()),e[1]=e[1].charAt(0),"B"===e[1]?(e[0]=Math.floor(e[0]),e[1]=""):j||"k"!==e[1]||(e[1]="K"))),l&&(e[0]=-e[0]),e[1]=r[e[1]]||e[1],"array"===n?e:"exponent"===n?h:"object"===n?{value:e[0],suffix:e[1]}:e.join(q)};"undefined"!=typeof exports?module.exports=d:"function"==typeof define?define(function(){return d}):a.filesize=d}("undefined"!=typeof global?global:window);
//# sourceMappingURL=filesize.min.js.map

File diff suppressed because one or more lines are too long