Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e0137de2
authored
Feb 06, 2013
by
Dányi Bence
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
one: cloud.js format fix
parent
8f1a9290
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
93 additions
and
83 deletions
+93
-83
one/static/cloud.js
+93
-83
No files found.
one/static/cloud.js
View file @
e0137de2
...
@@ -73,28 +73,28 @@ $(function() {
...
@@ -73,28 +73,28 @@ $(function() {
$
(
this
).
parent
().
hide
().
parent
().
find
(
'#old-upload-form'
).
show
();
$
(
this
).
parent
().
hide
().
parent
().
find
(
'#old-upload-form'
).
show
();
return
false
;
return
false
;
});
});
$
(
'.quota .used'
).
each
(
function
(){
$
(
'.quota .used'
).
each
(
function
()
{
var
s
=
this
;
var
s
=
this
;
$
(
this
).
css
(
'backgroundColor'
,
function
(
w
){
$
(
this
).
css
(
'backgroundColor'
,
function
(
w
)
{
console
.
log
(
s
,
parseFloat
(
w
));
console
.
log
(
s
,
parseFloat
(
w
));
return
'hsla('
+
(
120
-
parseFloat
(
w
)
/
438
*
120
).
toFixed
(
0
)
+
',100%,50%,0.2)'
;
return
'hsla('
+
(
120
-
parseFloat
(
w
)
/
438
*
120
).
toFixed
(
0
)
+
',100%,50%,0.2)'
;
}(
$
(
this
).
css
(
'width'
)));
}(
$
(
this
).
css
(
'width'
)));
if
(
parseInt
(
$
(
this
).
css
(
'width'
))
>
0
)
if
(
parseInt
(
$
(
this
).
css
(
'width'
))
>
0
)
$
(
this
).
css
(
'borderRight'
,
function
(
w
)
{
$
(
this
).
css
(
'borderRight'
,
function
(
w
){
console
.
log
(
s
,
parseFloat
(
w
));
console
.
log
(
s
,
parseFloat
(
w
));
return
'1px solid hsla('
+
(
120
-
parseFloat
(
w
)
/
438
*
120
).
toFixed
(
0
)
+
',100%,30%,0.4)'
;
return
'1px solid hsla('
+
(
120
-
parseFloat
(
w
)
/
438
*
120
).
toFixed
(
0
)
+
',100%,30%,0.4)'
;
}(
$
(
this
).
css
(
'width'
)));
}(
$
(
this
).
css
(
'width'
)));
});
});
$
(
'#new-folder'
).
click
(
function
(){
$
(
'#new-folder'
).
click
(
function
()
{
$
(
'#new-folder-form input'
)[
0
].
focus
();
$
(
'#new-folder-form input'
)[
0
].
focus
();
})
})
/**
/**
* Convert bytes to human readable format
* Convert bytes to human readable format
*/
*/
function
convert
(
n
,
skip
,
precision
)
{
function
convert
(
n
,
skip
,
precision
)
{
skip
=
skip
|
0
;
skip
=
skip
|
0
;
precision
=
precision
|
2
;
precision
=
precision
|
2
;
var
suffix
=
'B KB MB GB'
.
split
(
' '
);
var
suffix
=
'B KB MB GB'
.
split
(
' '
);
for
(
var
i
=
skip
;
n
>
1024
;
i
++
)
{
for
(
var
i
=
skip
;
n
>
1024
;
i
++
)
{
n
/=
1024
;
n
/=
1024
;
...
@@ -105,7 +105,7 @@ $(function() {
...
@@ -105,7 +105,7 @@ $(function() {
function
Model
()
{
function
Model
()
{
//alias for this
//alias for this
var
self
=
this
;
var
self
=
this
;
var
uploadURLRequestInProgress
=
false
;
var
uploadURLRequestInProgress
=
false
;
//currently displayed files
//currently displayed files
self
.
files
=
ko
.
observableArray
();
self
.
files
=
ko
.
observableArray
();
//all fetched files
//all fetched files
...
@@ -126,13 +126,13 @@ $(function() {
...
@@ -126,13 +126,13 @@ $(function() {
rawHard
:
ko
.
observable
(
0
)
rawHard
:
ko
.
observable
(
0
)
};
};
self
.
quota
.
used
=
ko
.
computed
(
function
()
{
self
.
quota
.
used
=
ko
.
computed
(
function
()
{
return
convert
(
self
.
quota
.
rawUsed
(),
1
);
return
convert
(
self
.
quota
.
rawUsed
(),
1
);
});
});
self
.
quota
.
hard
=
ko
.
computed
(
function
()
{
self
.
quota
.
hard
=
ko
.
computed
(
function
()
{
return
convert
(
self
.
quota
.
rawHard
(),
1
);
return
convert
(
self
.
quota
.
rawHard
(),
1
);
});
});
self
.
quota
.
soft
=
ko
.
computed
(
function
()
{
self
.
quota
.
soft
=
ko
.
computed
(
function
()
{
return
convert
(
self
.
quota
.
rawSoft
(),
1
);
return
convert
(
self
.
quota
.
rawSoft
(),
1
);
});
});
self
.
quota
.
usedBar
=
ko
.
computed
(
function
()
{
self
.
quota
.
usedBar
=
ko
.
computed
(
function
()
{
return
(
self
.
quota
.
rawUsed
()
/
self
.
quota
.
rawHard
()
*
100
).
toFixed
(
0
)
+
'%'
;
return
(
self
.
quota
.
rawUsed
()
/
self
.
quota
.
rawHard
()
*
100
).
toFixed
(
0
)
+
'%'
;
...
@@ -140,9 +140,9 @@ $(function() {
...
@@ -140,9 +140,9 @@ $(function() {
self
.
quota
.
softPos
=
ko
.
computed
(
function
()
{
self
.
quota
.
softPos
=
ko
.
computed
(
function
()
{
return
(
self
.
quota
.
rawSoft
()
/
self
.
quota
.
rawHard
()
*
100
).
toFixed
(
0
)
+
'%'
;
return
(
self
.
quota
.
rawSoft
()
/
self
.
quota
.
rawHard
()
*
100
).
toFixed
(
0
)
+
'%'
;
},
self
);
},
self
);
self
.
sortBy
=
ko
.
observable
(
'name'
);
self
.
sortBy
=
ko
.
observable
(
'name'
);
$
(
'#current-location select'
).
on
(
'change'
,
function
(){
$
(
'#current-location select'
).
on
(
'change'
,
function
()
{
self
.
sortBy
(
$
(
'#current-location select'
).
val
());
self
.
sortBy
(
$
(
'#current-location select'
).
val
());
sortOriginalFiles
();
sortOriginalFiles
();
sortFiles
();
sortFiles
();
...
@@ -151,6 +151,7 @@ $(function() {
...
@@ -151,6 +151,7 @@ $(function() {
/**
/**
* Returns throttled function
* Returns throttled function
*/
*/
function
throttle
(
f
)
{
function
throttle
(
f
)
{
var
disabled
=
false
;
var
disabled
=
false
;
return
function
()
{
return
function
()
{
...
@@ -169,18 +170,22 @@ $(function() {
...
@@ -169,18 +170,22 @@ $(function() {
* Delay the function call for `f` until `g` evaluates true
* Delay the function call for `f` until `g` evaluates true
* Default check interval is 1 sec
* Default check interval is 1 sec
*/
*/
function
delayUntil
(
f
,
g
,
timeout
){
var
timeout
=
timeout
|
1000
;
function
delayUntil
(
f
,
g
,
timeout
)
{
function
check
(){
var
timeout
=
timeout
|
1000
;
var
o
=
arguments
;
if
(
!
g
()){
function
check
()
{
setTimeout
(
function
(){
check
.
apply
(
null
,
o
)},
timeout
);
var
o
=
arguments
;
if
(
!
g
())
{
setTimeout
(
function
()
{
check
.
apply
(
null
,
o
)
},
timeout
);
return
;
return
;
}
}
f
.
apply
(
null
,
o
);
f
.
apply
(
null
,
o
);
}
}
return
function
(){
return
function
()
{
check
.
apply
(
null
,
arguments
);
check
.
apply
(
null
,
arguments
);
}
}
}
}
...
@@ -192,54 +197,54 @@ $(function() {
...
@@ -192,54 +197,54 @@ $(function() {
loadFolder
(
s
.
substr
(
0
,
s
.
substr
(
0
,
s
.
length
-
1
).
lastIndexOf
(
'/'
)
+
1
));
loadFolder
(
s
.
substr
(
0
,
s
.
substr
(
0
,
s
.
length
-
1
).
lastIndexOf
(
'/'
)
+
1
));
}
}
var
sortFiles
=
function
(){
var
sortFiles
=
function
()
{
self
.
files
.
sort
({
self
.
files
.
sort
({
name
:
function
(
a
,
b
){
name
:
function
(
a
,
b
)
{
if
(
a
.
type
===
b
.
type
){
if
(
a
.
type
===
b
.
type
)
{
return
a
.
originalName
.
localeCompare
(
b
.
originalName
);
return
a
.
originalName
.
localeCompare
(
b
.
originalName
);
}
}
if
(
a
.
type
===
'fájl'
){
if
(
a
.
type
===
'fájl'
)
{
return
1
;
return
1
;
}
}
return
-
1
;
return
-
1
;
},
},
date
:
function
(
a
,
b
){
date
:
function
(
a
,
b
)
{
if
(
a
.
type
===
b
.
type
){
if
(
a
.
type
===
b
.
type
)
{
return
new
Date
(
b
.
mTime
).
getTime
()
-
new
Date
(
a
.
mTime
).
getTime
();
return
new
Date
(
b
.
mTime
).
getTime
()
-
new
Date
(
a
.
mTime
).
getTime
();
}
}
if
(
a
.
type
===
'fájl'
){
if
(
a
.
type
===
'fájl'
)
{
return
1
;
return
1
;
}
}
return
-
1
;
return
-
1
;
}
}[
self
.
sortBy
()]);
}
var
sortOriginalFiles
=
function
(){
self
.
allFiles
.
sort
({
name
:
function
(
a
,
b
){
if
(
a
.
TYPE
===
b
.
TYPE
){
return
a
.
NAME
.
localeCompare
(
b
.
NAME
);
}
if
(
a
.
TYPE
===
'F'
){
return
1
;
}
return
-
1
;
},
date
:
function
(
a
,
b
){
if
(
a
.
TYPE
===
b
.
TYPE
){
return
new
Date
(
b
.
MTIME
).
getTime
()
-
new
Date
(
a
.
MTIME
).
getTime
();
}
}
if
(
a
.
TYPE
===
'F'
){
}[
self
.
sortBy
()]);
return
1
;
}
var
sortOriginalFiles
=
function
()
{
self
.
allFiles
.
sort
({
name
:
function
(
a
,
b
)
{
if
(
a
.
TYPE
===
b
.
TYPE
)
{
return
a
.
NAME
.
localeCompare
(
b
.
NAME
);
}
if
(
a
.
TYPE
===
'F'
)
{
return
1
;
}
return
-
1
;
},
date
:
function
(
a
,
b
)
{
if
(
a
.
TYPE
===
b
.
TYPE
)
{
return
new
Date
(
b
.
MTIME
).
getTime
()
-
new
Date
(
a
.
MTIME
).
getTime
();
}
if
(
a
.
TYPE
===
'F'
)
{
return
1
;
}
return
-
1
;
}
}
return
-
1
;
}[
self
.
sortBy
()]);
}
}
}[
self
.
sortBy
()]);
}
/**
/**
* Loads the specified folder
* Loads the specified folder
*/
*/
var
loadFolder
=
throttle
(
function
(
path
)
{
var
loadFolder
=
throttle
(
function
(
path
)
{
self
.
currentPath
(
path
);
self
.
currentPath
(
path
);
self
.
fileLimit
=
5
;
self
.
fileLimit
=
5
;
...
@@ -270,6 +275,7 @@ $(function() {
...
@@ -270,6 +275,7 @@ $(function() {
/**
/**
* After loadFolder completes, this function updates the UI
* After loadFolder completes, this function updates the UI
*/
*/
function
loadFolderDone
(
data
)
{
function
loadFolderDone
(
data
)
{
var
viewData
=
[];
var
viewData
=
[];
var
added
=
0
;
var
added
=
0
;
...
@@ -287,6 +293,7 @@ $(function() {
...
@@ -287,6 +293,7 @@ $(function() {
/**
/**
* Add file to the displayed files list
* Add file to the displayed files list
*/
*/
function
addFile
(
d
)
{
function
addFile
(
d
)
{
var
viewData
;
var
viewData
;
if
(
d
.
TYPE
===
'D'
)
{
if
(
d
.
TYPE
===
'D'
)
{
...
@@ -309,7 +316,7 @@ $(function() {
...
@@ -309,7 +316,7 @@ $(function() {
type
:
'fájl'
,
type
:
'fájl'
,
mTime
:
d
.
MTIME
,
mTime
:
d
.
MTIME
,
getTypeClass
:
'name filetype-text'
,
getTypeClass
:
'name filetype-text'
,
clickHandler
:
function
(
item
,
e
)
{
clickHandler
:
function
(
item
,
e
)
{
toggleDetails
.
call
(
e
.
currentTarget
);
toggleDetails
.
call
(
e
.
currentTarget
);
}
}
};
};
...
@@ -371,11 +378,11 @@ $(function() {
...
@@ -371,11 +378,11 @@ $(function() {
* Renames the specified file
* Renames the specified file
*/
*/
self
.
rename
=
function
(
item
,
e
)
{
self
.
rename
=
function
(
item
,
e
)
{
var
oldName
=
$
(
e
.
target
).
parent
().
parent
().
parent
().
find
(
'.name'
).
html
();
var
oldName
=
$
(
e
.
target
).
parent
().
parent
().
parent
().
find
(
'.name'
).
html
();
$
(
e
.
target
).
parent
().
unbind
(
'click'
).
click
(
function
(){
$
(
e
.
target
).
parent
().
unbind
(
'click'
).
click
(
function
()
{
$
(
e
.
target
).
parent
().
parent
().
parent
().
find
(
'.name'
).
html
(
oldName
);
$
(
e
.
target
).
parent
().
parent
().
parent
().
find
(
'.name'
).
html
(
oldName
);
$
(
e
.
target
).
parent
().
click
(
function
(
e
){
$
(
e
.
target
).
parent
().
click
(
function
(
e
)
{
self
.
rename
(
item
,
e
);
self
.
rename
(
item
,
e
);
});
});
})
})
//$(e.target).parent().parent().parent().unbind('click');
//$(e.target).parent().parent().parent().unbind('click');
...
@@ -402,7 +409,7 @@ $(function() {
...
@@ -402,7 +409,7 @@ $(function() {
* Requests a new upload link from the store server
* Requests a new upload link from the store server
*/
*/
self
.
getUploadURL
=
function
()
{
self
.
getUploadURL
=
function
()
{
uploadURLRequestInProgress
=
true
;
uploadURLRequestInProgress
=
true
;
$
.
ajax
({
$
.
ajax
({
type
:
'POST'
,
type
:
'POST'
,
data
:
'ul='
+
self
.
currentPath
()
+
'&next='
+
encodeURI
(
window
.
location
.
href
),
data
:
'ul='
+
self
.
currentPath
()
+
'&next='
+
encodeURI
(
window
.
location
.
href
),
...
@@ -410,7 +417,7 @@ $(function() {
...
@@ -410,7 +417,7 @@ $(function() {
dataType
:
'json'
,
dataType
:
'json'
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
self
.
uploadURL
(
data
.
url
);
self
.
uploadURL
(
data
.
url
);
uploadURLRequestInProgress
=
false
;
uploadURLRequestInProgress
=
false
;
}
}
})
})
}
}
...
@@ -444,17 +451,17 @@ $(function() {
...
@@ -444,17 +451,17 @@ $(function() {
/**
/**
* Uploads the specified file(s)
* Uploads the specified file(s)
*/
*/
var
readfiles
=
delayUntil
(
function
(
file
)
{
var
readfiles
=
delayUntil
(
function
(
file
)
{
//1 GB file limit
//1 GB file limit
if
(
file
.
size
>
1024
*
1024
*
1024
)
{
if
(
file
.
size
>
1024
*
1024
*
1024
)
{
$
(
'#upload-zone'
).
hide
();
$
(
'#upload-zone'
).
hide
();
$
(
'#upload-error'
).
show
();
$
(
'#upload-error'
).
show
();
$
(
'#upload-error-size'
).
show
();
$
(
'#upload-error-size'
).
show
();
setTimeout
(
function
(){
setTimeout
(
function
()
{
$
(
'#upload-zone'
).
show
();
$
(
'#upload-zone'
).
show
();
$
(
'#upload-error'
).
hide
();
$
(
'#upload-error'
).
hide
();
$
(
'#upload-error-size'
).
hide
();
$
(
'#upload-error-size'
).
hide
();
},
3000
);
},
3000
);
return
;
return
;
}
}
var
formData
=
tests
.
formdata
?
new
FormData
()
:
null
;
var
formData
=
tests
.
formdata
?
new
FormData
()
:
null
;
...
@@ -464,7 +471,9 @@ $(function() {
...
@@ -464,7 +471,9 @@ $(function() {
var
xhr
=
new
XMLHttpRequest
();
var
xhr
=
new
XMLHttpRequest
();
var
start
=
new
Date
().
getTime
();
var
start
=
new
Date
().
getTime
();
xhr
.
open
(
'POST'
,
self
.
uploadURL
());
xhr
.
open
(
'POST'
,
self
.
uploadURL
());
xhr
.
onreadystatechange
=
function
(){
console
.
log
(
xhr
,
arguments
)}
xhr
.
onreadystatechange
=
function
()
{
console
.
log
(
xhr
,
arguments
)
}
xhr
.
onload
=
xhr
.
onerror
=
function
()
{
xhr
.
onload
=
xhr
.
onerror
=
function
()
{
console
.
log
(
xhr
.
status
);
console
.
log
(
xhr
.
status
);
$
(
'.file-upload'
).
removeClass
(
'opened'
);
$
(
'.file-upload'
).
removeClass
(
'opened'
);
...
@@ -509,7 +518,7 @@ $(function() {
...
@@ -509,7 +518,7 @@ $(function() {
}
}
},
function
()
{
},
function
()
{
return
self
.
uploadURL
()
!==
'/'
;
return
self
.
uploadURL
()
!==
'/'
;
},
200
);
},
200
);
/**
/**
* Drag'n'drop listeners
* Drag'n'drop listeners
...
@@ -521,7 +530,7 @@ $(function() {
...
@@ -521,7 +530,7 @@ $(function() {
return
false
;
return
false
;
});
});
document
.
addEventListener
(
'dragover'
,
function
(
e
)
{
document
.
addEventListener
(
'dragover'
,
function
(
e
)
{
if
(
!
uploadURLRequestInProgress
&&
self
.
uploadURL
()
==
'/'
){
if
(
!
uploadURLRequestInProgress
&&
self
.
uploadURL
()
==
'/'
)
{
$
(
'.file-upload .summary'
).
click
();
$
(
'.file-upload .summary'
).
click
();
}
}
e
.
stopPropagation
();
e
.
stopPropagation
();
...
@@ -532,6 +541,7 @@ $(function() {
...
@@ -532,6 +541,7 @@ $(function() {
/**
/**
* Fetch quota information
* Fetch quota information
*/
*/
function
refreshQuota
()
{
function
refreshQuota
()
{
$
.
ajax
({
$
.
ajax
({
'type'
:
'GET'
,
'type'
:
'GET'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment