summaryrefslogtreecommitdiffstats
path: root/core/js
diff options
context:
space:
mode:
Diffstat (limited to 'core/js')
-rw-r--r--core/js/js.js22
-rw-r--r--core/js/public/appconfig.js1
-rw-r--r--core/js/share.js2
-rw-r--r--core/js/tests/specs/coreSpec.js24
-rw-r--r--core/js/tests/specs/shareSpec.js14
5 files changed, 43 insertions, 20 deletions
diff --git a/core/js/js.js b/core/js/js.js
index 5f5f540af63..6fd66c9c9bb 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -1712,16 +1712,12 @@ OC.Util = {
*
*/
computerFileSize: function (string) {
- if (typeof string != 'string') {
+ if (typeof string !== 'string') {
return null;
}
- var s = string.toLowerCase();
- var bytes = parseFloat(s)
-
- if (!isNaN(bytes) && isFinite(s)) {
- return bytes;
- }
+ var s = string.toLowerCase().trim();
+ var bytes = null;
var bytesArray = {
'b' : 1,
@@ -1737,12 +1733,18 @@ OC.Util = {
'p' : 1024 * 1024 * 1024 * 1024 * 1024
};
- var matches = s.match(/([kmgtp]?b?)$/i);
- if (matches[1]) {
- bytes = bytes * bytesArray[matches[1]];
+ var matches = s.match(/^[\s+]?([0-9]*)(\.([0-9]+))?( +)?([kmgtp]?b?)$/i);
+ if (matches !== null) {
+ bytes = parseFloat(s);
+ if (!isFinite(bytes)) {
+ return null;
+ }
} else {
return null;
}
+ if (matches[5]) {
+ bytes = bytes * bytesArray[matches[5]];
+ }
bytes = Math.round(bytes);
return bytes;
diff --git a/core/js/public/appconfig.js b/core/js/public/appconfig.js
index d84ddaab404..bba39c8b805 100644
--- a/core/js/public/appconfig.js
+++ b/core/js/public/appconfig.js
@@ -38,6 +38,7 @@ OCP.AppConfig = {
return;
}
+ options = options || {};
$.ajax({
type: method.toUpperCase(),
url: OC.linkToOCS('apps/provisioning_api/api/v1', 2) + 'config/apps' + endpoint,
diff --git a/core/js/share.js b/core/js/share.js
index 913c78bb732..5bde7e63f36 100644
--- a/core/js/share.js
+++ b/core/js/share.js
@@ -302,7 +302,7 @@ OC.Share = _.extend(OC.Share || {}, {
}
action.html('<span> ' + message + '</span>').prepend(icon);
if (owner || recipients) {
- action.find('.remoteAddress').tipsy({gravity: 's'});
+ action.find('.remoteAddress').tooltip({placement: 'top'});
}
}
else {
diff --git a/core/js/tests/specs/coreSpec.js b/core/js/tests/specs/coreSpec.js
index 3380b6be420..dd13cba8e2b 100644
--- a/core/js/tests/specs/coreSpec.js
+++ b/core/js/tests/specs/coreSpec.js
@@ -594,8 +594,14 @@ describe('Core base tests', function() {
it('correctly parses file sizes from a human readable formated string', function() {
var data = [
['125', 125],
- ['125.25', 125.25],
+ ['125.25', 125],
+ ['125.25B', 125],
+ ['125.25 B', 125],
['0 B', 0],
+ ['99999999999999999999999999999999999999999999 B', 99999999999999999999999999999999999999999999],
+ ['0 MB', 0],
+ ['0 kB', 0],
+ ['0kB', 0],
['125 B', 125],
['125b', 125],
['125 KB', 128000],
@@ -605,7 +611,21 @@ describe('Core base tests', function() {
['119.2 GB', 127990025421],
['119.2gb', 127990025421],
['116.4 TB', 127983153473126],
- ['116.4tb', 127983153473126]
+ ['116.4tb', 127983153473126],
+ ['8776656778888777655.4tb', 9.650036181387265e+30],
+ [1234, null],
+ [-1234, null],
+ ['-1234 B', null],
+ ['B', null],
+ ['40/0', null],
+ ['40,30 kb', null],
+ [' 122.1 MB ', 128031130],
+ ['122.1 MB ', 128031130],
+ [' 122.1 MB ', 128031130],
+ [' 122.1 MB ', 128031130],
+ ['122.1 MB ', 128031130],
+ [' 125', 125],
+ [' 125 ', 125],
];
for (var i = 0; i < data.length; i++) {
expect(OC.Util.computerFileSize(data[i][0])).toEqual(data[i][1]);
diff --git a/core/js/tests/specs/shareSpec.js b/core/js/tests/specs/shareSpec.js
index 5c76ea600b8..fbf6eecc8df 100644
--- a/core/js/tests/specs/shareSpec.js
+++ b/core/js/tests/specs/shareSpec.js
@@ -23,10 +23,10 @@
describe('OC.Share tests', function() {
describe('markFileAsShared', function() {
var $file;
- var tipsyStub;
+ var tooltipStub;
beforeEach(function() {
- tipsyStub = sinon.stub($.fn, 'tipsy');
+ tooltipStub = sinon.stub($.fn, 'tooltip');
$file = $('<tr><td class="filename"><div class="thumbnail"></div><span class="name">File name</span></td></tr>');
$file.find('.filename').append(
'<span class="fileactions">' +
@@ -38,7 +38,7 @@ describe('OC.Share tests', function() {
});
afterEach(function() {
$file = null;
- tipsyStub.restore();
+ tooltipStub.restore();
});
describe('displaying the share owner', function() {
function checkOwner(input, output, title) {
@@ -54,8 +54,8 @@ describe('OC.Share tests', function() {
} else {
expect($action.find('.remoteAddress').attr('title')).not.toBeDefined();
}
- expect(tipsyStub.calledOnce).toEqual(true);
- tipsyStub.reset();
+ expect(tooltipStub.calledOnce).toEqual(true);
+ tooltipStub.reset();
}
it('displays the local share owner as is', function() {
@@ -172,8 +172,8 @@ describe('OC.Share tests', function() {
} else {
expect($action.find('.remoteAddress').attr('title')).not.toBeDefined();
}
- expect(tipsyStub.calledOnce).toEqual(true);
- tipsyStub.reset();
+ expect(tooltipStub.calledOnce).toEqual(true);
+ tooltipStub.reset();
}
it('displays the local share owner as is', function() {