Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yoho-blk
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
1
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
biao
9 years ago
Commit
ff86e593e1f78ac25b17017a8b96f214a2d49317
2 parents
c7adb785
2870d5dd
Merge branch 'release/1.0' of
http://git.yoho.cn/fe/yoho-blk
into release/1.0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
22 deletions
public/js/plugins/upload.js
public/js/plugins/upload.js
View file @
ff86e59
...
...
@@ -16,6 +16,8 @@ var $result,
$upload
,
$filename
;
var
uping
;
var
num
,
inter
,
callback
;
...
...
@@ -26,42 +28,45 @@ $result = $('#yoho-upload-result');
$upload
=
$
(
'#yoho-upload'
);
$filename
=
$upload
.
find
(
'.file-name'
);
function
up
(
opt
)
{
if
(
uping
)
{
return
;
}
$filename
.
click
();
if
(
opt
&&
typeof
opt
.
callback
===
'function'
)
{
callback
=
opt
.
callback
;
}
else
{
callback
=
''
;
}
}
function
getResponse
(
cb
)
{
num
=
0
;
inter
=
setInterval
(
function
()
{
var
res
=
$result
[
0
].
contentDocument
.
body
.
innerText
||
''
;
if
(
res
)
{
if
(
num
>
20
||
res
)
{
uping
=
false
;
clearInterval
(
inter
);
}
num
++
;
if
(
res
)
{
clearInterval
(
inter
);
$result
[
0
].
contentDocument
.
body
.
innerText
=
''
;
if
(
cb
)
{
return
cb
(
$
.
parseJSON
(
res
));
}
}
if
(
num
>
20
||
res
)
{
clearInterval
(
inter
);
}
num
++
;
},
500
);
}
function
up
(
opt
)
{
$filename
.
click
();
if
(
opt
)
{
callback
=
null
;
callback
=
opt
.
callback
;
}
else
{
callback
=
''
;
}
$filename
.
off
(
'change'
).
on
(
'change'
,
function
()
{
$upload
.
submit
();
getResponse
(
callback
);
});
}
$filename
.
change
(
function
()
{
uping
=
true
;
$upload
.
submit
();
getResponse
(
callback
);
});
exports
.
up
=
up
;
...
...
Please
register
or
login
to post a comment