Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cribjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Cédric Le Ninivin
cribjs
Commits
d756e23e
Commit
d756e23e
authored
Jun 10, 2020
by
Cédric Le Ninivin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make Upload from Zip file functionnal on landing page
parent
2f90a5af
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
86 additions
and
44 deletions
+86
-44
gadget/gadget_landing_cribjs.js
gadget/gadget_landing_cribjs.js
+66
-41
landing.js
landing.js
+20
-3
No files found.
gadget/gadget_landing_cribjs.js
View file @
d756e23e
...
@@ -19,28 +19,8 @@
...
@@ -19,28 +19,8 @@
return
default_value
;
return
default_value
;
}
}
function
loadContentFromZIPURL
(
gadget
,
options
)
{
function
loadZipIntoCrib
(
crib_sw_gadget
,
zip
,
from_path
,
path_to_load
)
{
var
path_to_load
=
options
.
to_path
,
path_to_load_length
,
file_list
,
crib_sw_gadget
,
var
promise_list
=
[],
url_number
=
0
;
from_path
=
options
.
from_path
,
zip_url
=
options
.
zip_url
,
jio_gadget
,
url_list
=
[],
url_number
=
0
;
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
gadget
.
getDeclaredGadget
(
'
crib_sw_gadget
'
);
})
.
push
(
function
(
returned_gadget
)
{
crib_sw_gadget
=
returned_gadget
;
return
fetch
(
zip_url
)
.
then
(
function
(
response
)
{
// 2) filter on 200 OK
if
(
response
.
status
===
200
||
response
.
status
===
0
)
{
return
Promise
.
resolve
(
response
.
blob
());
}
else
{
return
Promise
.
reject
(
new
Error
(
response
.
statusText
));
}
});
})
.
push
(
JSZip
.
loadAsync
)
.
push
(
function
(
zip
)
{
var
promise_list
=
[];
zip
.
forEach
(
function
(
relativePath
,
zipEntry
)
{
zip
.
forEach
(
function
(
relativePath
,
zipEntry
)
{
var
end_url
;
var
end_url
;
url_number
+=
1
;
url_number
+=
1
;
...
@@ -79,6 +59,51 @@
...
@@ -79,6 +59,51 @@
)
)
})
})
return
RSVP
.
all
(
promise_list
)
return
RSVP
.
all
(
promise_list
)
}
function
loadContentFromZIPFile
(
gadget
,
options
)
{
var
path_to_load
=
options
.
to_path
,
from_path
=
options
.
from_path
,
file_list
=
options
.
file_list
;
if
(
file_list
.
length
===
0
)
{
return
"
No File to Load
"
;
}
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
RSVP
.
all
([
gadget
.
getDeclaredGadget
(
'
crib_sw_gadget
'
),
JSZip
.
loadAsync
(
file_list
[
0
])
]);
})
.
push
(
function
(
result_list
)
{
return
loadZipIntoCrib
(
result_list
[
0
],
result_list
[
1
],
from_path
,
path_to_load
);
})
.
push
(
console
.
log
,
console
.
log
)
}
function
loadContentFromZIPURL
(
gadget
,
options
)
{
var
path_to_load
=
options
.
to_path
,
file_list
,
crib_sw_gadget
,
from_path
=
options
.
from_path
,
zip_url
=
options
.
zip_url
,
jio_gadget
,
url_list
=
[],
url_number
=
0
;
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
gadget
.
getDeclaredGadget
(
'
crib_sw_gadget
'
);
})
.
push
(
function
(
returned_gadget
)
{
crib_sw_gadget
=
returned_gadget
;
return
fetch
(
zip_url
)
.
then
(
function
(
response
)
{
// 2) filter on 200 OK
if
(
response
.
status
===
200
||
response
.
status
===
0
)
{
return
Promise
.
resolve
(
response
.
blob
());
}
else
{
return
Promise
.
reject
(
new
Error
(
response
.
statusText
));
}
});
})
.
push
(
JSZip
.
loadAsync
)
.
push
(
function
(
zip
)
{
return
loadZipIntoCrib
(
crib_sw_gadget
,
zip
,
from_path
,
path_to_load
);
})
})
.
push
(
console
.
log
,
console
.
log
)
.
push
(
console
.
log
,
console
.
log
)
}
}
...
@@ -91,7 +116,7 @@
...
@@ -91,7 +116,7 @@
return
loadContentFromZIPURL
(
this
,
options
);
return
loadContentFromZIPURL
(
this
,
options
);
})
})
.
declareMethod
(
'
loadFromZipFile
'
,
function
(
options
)
{
.
declareMethod
(
'
loadFromZipFile
'
,
function
(
options
)
{
return
loadContentFromZIP
URL
(
gadget
,
options
);
return
loadContentFromZIP
File
(
this
,
options
);
})
})
.
allowPublicAcquisition
(
"
getSetting
"
,
function
(
argument_list
)
{
.
allowPublicAcquisition
(
"
getSetting
"
,
function
(
argument_list
)
{
return
getSetting
(
this
,
argument_list
[
0
],
argument_list
[
1
]);
return
getSetting
(
this
,
argument_list
[
0
],
argument_list
[
1
]);
...
...
landing.js
View file @
d756e23e
...
@@ -13,9 +13,6 @@
...
@@ -13,9 +13,6 @@
return
params
;
return
params
;
}
}
function
loadCribJSFromZipFile
(
gadget
,
event
)
{
}
function
makeid
(
length
)
{
function
makeid
(
length
)
{
var
result
=
''
;
var
result
=
''
;
var
characters
=
'
abcdefghijklmnopqrstuvwxyz0123456789
'
;
var
characters
=
'
abcdefghijklmnopqrstuvwxyz0123456789
'
;
...
@@ -26,6 +23,26 @@
...
@@ -26,6 +23,26 @@
return
result
;
return
result
;
}
}
function
loadCribJSFromZipFile
(
gadget
,
event
)
{
return
RSVP
.
Queue
()
.
push
(
function
()
{
return
gadget
.
getDeclaredGadget
(
"
jio_cribjs
"
);
})
.
push
(
function
(
jio_cribjs_gadget
)
{
return
jio_cribjs_gadget
.
loadFromZipFile
({
path
:
document
.
location
.
href
,
file_list
:
gadget
.
props
.
element
.
querySelector
(
"
form.crib-load-from-zip-file .load-zip-file
"
).
files
,
from_path
:
gadget
.
props
.
element
.
querySelector
(
"
form.crib-load-from-zip-file .load-from-zip-path
"
).
value
,
to_path
:
gadget
.
props
.
element
.
querySelector
(
"
form.crib-load-from-zip-file .load-zip-to-path
"
).
value
,
application_id
:
"
cribjs
"
})
})
.
push
(
function
(
url_list
)
{
document
.
location
=
gadget
.
props
.
element
.
querySelector
(
"
form.crib-load-from-zip-file .redirect-url
"
).
value
;
})
.
push
(
console
.
log
,
console
.
log
);
}
function
loadCribJSFromZipUrl
(
gadget
,
event
)
{
function
loadCribJSFromZipUrl
(
gadget
,
event
)
{
return
RSVP
.
Queue
()
return
RSVP
.
Queue
()
.
push
(
function
()
{
.
push
(
function
()
{
...
...
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