]>
git.saurik.com Git - cydia.git/blob - Cydia.app/storage.js
1 var colors
= ["#9090e0", "#4d4d70", "#7d7da0", "#7da0e0", "#d0d0f0", "#7070e0"];
3 var list = function (legend
, color
, name
, value
) {
4 legend
.append('<div class="key">' +
5 '<div class="color" style="background-color: ' + color
+ '"><div></div></div>' +
6 '<div class="name">' + name
+ ' (' + Math
.round(value
* 1000) / 10 + '%)</div>' +
10 console
.log(cydia
.statfs("/"));
12 var cut = function (parent
, color
, fraction
, z
) {
13 var deg
= Math
.round(360 * fraction
);
16 parent
.append('<div class="xslice" style="' +
17 'background-color: ' + color
+ ';' +
18 '-webkit-transform: rotate(' + deg
+ 'deg);' +
19 'z-index: ' + z
+ ';' +
23 var chart = function (right
, left
, slices
) {
25 for (var i
= 0; i
!= slices
.length
; ++i
) {
26 var slice
= slices
[i
];
27 var z
= slices
.length
- i
;
29 cut(right
, slice
[0], total
+ 0.5, z
);
31 cut(total
> 0.5 ? left : right
, slice
[0], total
, z
);
35 var setup = function (name
, root
, folders
) {
36 var size
= $("#" + name
+ "-size");
37 var statfs
= cydia
.statfs(root
);
38 var kb
= statfs
[0] * statfs
[1] / 1024;
39 var total
= kb
/ 1024;
49 size
.html(Math
.round(total
* 10) / 10 + " " + unit
);
51 var legend
= $("#" + name
+ "-legend");
57 for (var i
= 0; i
!= folders
.length
; ++i
) {
58 var folder
= folders
[i
];
59 var usage
= cydia
.du(folder
[1]);
62 var color
= colors
[i
+ 2];
63 var percent
= usage
/ kb
;
64 list(legend
, color
, folder
[0], percent
);
65 slices
.push([color
, percent
]);
69 var free
= statfs
[0] * statfs
[2] / 1024;
70 var other
= (kb
- free
- used
) / kb
;
72 slices
.push([colors
[0], other
]);
73 chart($("#" + name
+ "-right"), $("#" + name
+ "-left"), slices
);
75 list(legend
, colors
[0], folders
== null ? "Used" : "Other", other
);
76 list(legend
, colors
[1], "Free", statfs
[2] / statfs
[1]);
80 setup("system", "/", null);
82 setup("private", "/private/var", [
83 ["Themes", "/Library/Themes/"],
84 ["iTunes", "/var/mobile/Media/iTunes_Control/"],
85 ["App Store", "/var/mobile/Applications/"],
86 ["Photos", "/var/mobile/Media/DCIM/"]