Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
86ce42ab
Commit
86ce42ab
authored
4 years ago
by
Ali-D-Akbar
Browse files
Options
Downloads
Patches
Plain Diff
PROD-2194
parent
774f2956
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lms/static/js/jquery.ajaxfileupload.js
+39
-39
39 additions, 39 deletions
lms/static/js/jquery.ajaxfileupload.js
with
39 additions
and
39 deletions
lms/static/js/jquery.ajaxfileupload.js
+
39
−
39
View file @
86ce42ab
...
...
@@ -12,9 +12,9 @@ jQuery.extend({
},
createUploadIframe
:
function
(
id
,
uri
){
//create frame
var
frameId
=
'
jUploadFrame
'
+
id
;
var
frameId
=
'
jUploadFrame
'
+
id
;
if
(
window
.
ActiveXObject
)
{
var
io
=
document
.
createElement
(
'
<iframe id="
'
+
frameId
+
'
" name="
'
+
frameId
+
'
" />
'
);
var
io
=
document
.
createElement
(
'
<iframe id="
'
+
frameId
+
'
" name="
'
+
frameId
+
'
" />
'
);
// xss-lint: disable=javascript-concat-html
if
(
typeof
uri
==
'
boolean
'
){
io
.
src
=
'
javascript:false
'
;
}
...
...
@@ -36,68 +36,68 @@ jQuery.extend({
},
createUploadForm
:
function
(
id
,
fileElementId
)
{
//create form
//create form
var
formId
=
'
jUploadForm
'
+
id
;
var
fileId
=
'
jUploadFile
'
+
id
;
var
form
=
$
(
'
<form action="" method="POST" name="
'
+
formId
+
'
" id="
'
+
formId
+
'
" enctype="multipart/form-data"></form>
'
);
var
form
=
$
(
'
<form action="" method="POST" name="
'
+
formId
+
'
" id="
'
+
formId
// xss-lint: disable=javascript-concat-html
+
'
" enctype="multipart/form-data"></form>
'
);
// xss-lint: disable=javascript-concat-html
var
oldElement
=
$
(
'
#
'
+
fileElementId
);
var
newElement
=
$
(
oldElement
).
clone
();
$
(
oldElement
).
attr
(
'
id
'
,
fileId
);
$
(
oldElement
).
before
(
newElement
);
$
(
oldElement
).
appendTo
(
form
);
$
(
oldElement
).
before
(
newElement
);
// xss-lint: disable=javascript-jquery-insertion
$
(
oldElement
).
appendTo
(
form
);
// xss-lint: disable=javascript-jquery-insert-into-target
//set attributes
$
(
form
).
css
(
'
position
'
,
'
absolute
'
);
$
(
form
).
css
(
'
top
'
,
'
-1200px
'
);
$
(
form
).
css
(
'
left
'
,
'
-1200px
'
);
$
(
form
).
appendTo
(
'
body
'
);
$
(
form
).
appendTo
(
'
body
'
);
// xss-lint: disable=javascript-jquery-insert-into-target
return
form
;
},
ajaxFileUpload
:
function
(
s
)
{
// TODO introduce global settings, allowing the client to modify them for all requests, not only timeout
// TODO introduce global settings, allowing the client to modify them for all requests, not only timeout
s
=
jQuery
.
extend
({},
jQuery
.
ajaxSettings
,
s
);
var
id
=
new
Date
().
getTime
()
var
id
=
new
Date
().
getTime
()
var
form
=
jQuery
.
createUploadForm
(
id
,
s
.
fileElementId
);
var
io
=
jQuery
.
createUploadIframe
(
id
,
s
.
secureuri
);
var
frameId
=
'
jUploadFrame
'
+
id
;
var
formId
=
'
jUploadForm
'
+
id
;
var
formId
=
'
jUploadForm
'
+
id
;
// Watch for a new set of requests
if
(
s
.
global
&&
!
jQuery
.
active
++
)
{
jQuery
.
event
.
trigger
(
"
ajaxStart
"
);
}
}
var
requestDone
=
false
;
// Create the request object
var
xml
=
{}
var
xml
=
{}
if
(
s
.
global
)
jQuery
.
event
.
trigger
(
"
ajaxSend
"
,
[
xml
,
s
]);
// Wait for a response to come back
var
uploadCallback
=
function
(
isTimeout
)
{
{
var
io
=
document
.
getElementById
(
frameId
);
try
{
try
{
if
(
io
.
contentWindow
){
xml
.
responseText
=
io
.
contentWindow
.
document
.
body
?
xml
.
responseText
=
io
.
contentWindow
.
document
.
body
?
io
.
contentWindow
.
document
.
body
.
textContent
||
io
.
contentWindow
.
document
.
body
.
innerText
:
null
;
xml
.
responseXML
=
io
.
contentWindow
.
document
.
XMLDocument
?
xml
.
responseXML
=
io
.
contentWindow
.
document
.
XMLDocument
?
io
.
contentWindow
.
document
.
XMLDocument
:
io
.
contentWindow
.
document
;
}
else
if
(
io
.
contentDocument
)
{
xml
.
responseText
=
io
.
contentDocument
.
document
.
body
?
xml
.
responseText
=
io
.
contentDocument
.
document
.
body
?
io
.
contentDocument
.
document
.
body
.
textContent
||
document
.
body
.
innerText
:
null
;
xml
.
responseXML
=
io
.
contentDocument
.
document
.
XMLDocument
?
xml
.
responseXML
=
io
.
contentDocument
.
document
.
XMLDocument
?
io
.
contentDocument
.
document
.
XMLDocument
:
io
.
contentDocument
.
document
;
}
}
}
catch
(
e
)
{
jQuery
.
handleError
(
s
,
xml
,
null
,
e
);
}
if
(
xml
||
isTimeout
==
"
timeout
"
)
{
if
(
xml
||
isTimeout
==
"
timeout
"
)
{
requestDone
=
true
;
var
status
;
try
{
...
...
@@ -106,17 +106,17 @@ jQuery.extend({
if
(
status
!=
"
error
"
)
{
// process the data (runs the xml through httpData regardless of callback)
var
data
=
jQuery
.
uploadHttpData
(
xml
,
s
.
dataType
);
var
data
=
jQuery
.
uploadHttpData
(
xml
,
s
.
dataType
);
// If a local callback was specified, fire it and pass it the data
if
(
s
.
success
)
s
.
success
(
data
,
status
);
// Fire the global callback
if
(
s
.
global
)
jQuery
.
event
.
trigger
(
"
ajaxSuccess
"
,
[
xml
,
s
]
);
}
else
jQuery
.
handleError
(
s
,
xml
,
status
);
}
catch
(
e
)
}
catch
(
e
)
{
status
=
"
error
"
;
jQuery
.
handleError
(
s
,
xml
,
status
,
e
);
...
...
@@ -137,14 +137,14 @@ jQuery.extend({
jQuery
(
io
).
unbind
();
setTimeout
(
function
()
{
try
{
try
{
$
(
io
).
remove
();
$
(
form
).
remove
();
$
(
form
).
remove
();
}
catch
(
e
)
{
jQuery
.
handleError
(
s
,
xml
,
null
,
e
);
}
}
},
100
)
xml
=
null
;
}
...
...
@@ -156,7 +156,7 @@ jQuery.extend({
if
(
!
requestDone
)
uploadCallback
(
"
timeout
"
);
},
s
.
timeout
);
}
try
try
{
// var io = $('#' + frameId);
var
form
=
$
(
'
#
'
+
formId
);
...
...
@@ -165,16 +165,16 @@ jQuery.extend({
$
(
form
).
attr
(
'
target
'
,
frameId
);
if
(
form
.
encoding
)
{
form
.
encoding
=
'
multipart/form-data
'
;
form
.
encoding
=
'
multipart/form-data
'
;
}
else
{
{
form
.
enctype
=
'
multipart/form-data
'
;
}
}
$
(
form
).
submit
();
}
catch
(
e
)
{
}
catch
(
e
)
{
jQuery
.
handleError
(
s
,
xml
,
null
,
e
);
}
if
(
window
.
attachEvent
){
...
...
@@ -182,8 +182,8 @@ jQuery.extend({
}
else
{
document
.
getElementById
(
frameId
).
addEventListener
(
'
load
'
,
uploadCallback
,
false
);
}
return
{
abort
:
function
()
{}};
}
return
{
abort
:
function
()
{}};
},
...
...
@@ -198,7 +198,7 @@ jQuery.extend({
eval
(
"
data =
"
+
data
);
// evaluate scripts within html
if
(
type
==
"
html
"
)
jQuery
(
"
<div>
"
).
html
(
data
).
evalScripts
();
jQuery
(
"
<div>
"
).
html
(
data
).
evalScripts
();
// xss-lint: disable=javascript-jquery-html
//alert($('param', data).each(function(){alert($(this).attr('value'));}));
return
data
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment