Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Bootstrap
bootstrap
Commits
d7754696
Commit
d7754696
authored
10 years ago
by
Heinrich Fenkart
Browse files
Options
Download
Email Patches
Plain Diff
Customizer: Remove file type check from config import
Fixes
#14978
.
parent
03834866
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
docs/assets/js/src/customizer.js
+13
-19
docs/assets/js/src/customizer.js
with
13 additions
and
19 deletions
+13
-19
docs/assets/js/src/customizer.js
+
13
-
19
View file @
d7754696
...
...
@@ -361,32 +361,26 @@ window.onload = function () { // wait for load in a dumb way because B-0
var
file
=
(
e
.
originalEvent
.
hasOwnProperty
(
'
dataTransfer
'
))
?
e
.
originalEvent
.
dataTransfer
.
files
[
0
]
:
e
.
originalEvent
.
target
.
files
[
0
]
if
(
!
file
.
type
.
match
(
'
application/json
'
))
{
return
showAlert
(
'
danger
'
,
'
<strong>Ruh roh.</strong> We can only read <code>.json</code> files. Please try again.
'
,
importDropTarget
)
}
var
reader
=
new
FileReader
()
reader
.
onload
=
(
function
()
{
return
function
(
e
)
{
var
text
=
e
.
target
.
result
reader
.
onload
=
function
(
e
)
{
var
text
=
e
.
target
.
result
try
{
var
json
=
JSON
.
parse
(
text
)
if
(
typeof
json
!=
'
object
'
)
{
throw
new
Error
(
'
JSON data from config file is not an object.
'
)
}
try
{
var
json
=
JSON
.
parse
(
text
)
updateCustomizerFromJson
(
json
)
showAlert
(
'
success
'
,
'
<strong>Woohoo!</strong> Your configuration was successfully uploaded. Tweak your settings, then hit Download.
'
,
importDropTarget
)
}
catch
(
err
)
{
return
showAlert
(
'
danger
'
,
'
<strong>Shucks.</strong> We can only read valid <code>.json</code> files. Please try again.
'
,
importDropTarget
)
if
(
!
$
.
isPlainObject
(
json
))
{
throw
new
Error
(
'
JSON data from config file is not an object.
'
)
}
updateCustomizerFromJson
(
json
)
showAlert
(
'
success
'
,
'
<strong>Woohoo!</strong> Your configuration was successfully uploaded. Tweak your settings, then hit Download.
'
,
importDropTarget
)
}
catch
(
err
)
{
return
showAlert
(
'
danger
'
,
'
<strong>Shucks.</strong> We can only read valid <code>.json</code> files. Please try again.
'
,
importDropTarget
)
}
}
)(
file
)
}
reader
.
readAsText
(
file
)
reader
.
readAsText
(
file
,
'
utf-8
'
)
}
function
handleConfigDragOver
(
e
)
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment