Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cribjs-editor
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Cédric Le Ninivin
cribjs-editor
Commits
280a3d53
Commit
280a3d53
authored
Sep 22, 2020
by
Cédric Le Ninivin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add dedicated page to add documents
parent
a4bfc088
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
147 additions
and
1 deletion
+147
-1
gadget/gadget_cribjs_page_add.html
gadget/gadget_cribjs_page_add.html
+44
-0
gadget/gadget_cribjs_page_add.js
gadget/gadget_cribjs_page_add.js
+94
-0
gadget/gadget_cribjs_page_url_list.html
gadget/gadget_cribjs_page_url_list.html
+1
-0
gadget/gadget_cribjs_page_url_list.js
gadget/gadget_cribjs_page_url_list.js
+8
-1
No files found.
gadget/gadget_cribjs_page_add.html
0 → 100644
View file @
280a3d53
<!DOCTYPE html>
<html>
<head>
<meta
http-equiv=
"Content-type"
content=
"text/html; charset=utf-8"
/>
<meta
name=
"viewport"
content=
"width=device-width, user-scalable=no"
/>
<title>
CribJS Header
</title>
<!-- renderjs -->
<script
src=
"../lib/rsvp.js"
type=
"text/javascript"
></script>
<script
src=
"../lib/renderjs.js"
type=
"text/javascript"
></script>
<script
src=
"../lib/jio-latest.js"
type=
"text/javascript"
></script>
<script
src=
"../lib/mimetype.js"
type=
"text/javascript"
></script>
<script
src=
"./gadget_global.js"
type=
"text/javascript"
></script>
<!-- Custom -->
<script
src=
"./gadget_cribjs_page_add.js"
type=
"text/javascript"
></script>
</head>
<body>
<div
class=
"nav_content editor"
>
<div
class=
"container"
>
<h3>
Edit
</h3>
<div
class=
"row"
>
<form
class=
"crib-add form-inline"
>
<div
class=
"form-group"
>
<label>
URL:
<input
name=
"url"
class=
"url form-control"
type=
"text"
size=
"50"
value=
""
placeholder=
"Enter the new URL"
>
</label>
</div>
<div
class=
"form-group"
>
<label>
File:
<input
name=
"file"
class=
"file form-control"
type=
"file"
>
</label>
</div>
<div
class=
"form-group"
>
<button
type=
"submit"
name=
"add"
class=
"btn btn-default"
>
Add
</button>
</div>
</form>
</div>
</div>
</div>
</body>
</html>
\ No newline at end of file
gadget/gadget_cribjs_page_add.js
0 → 100644
View file @
280a3d53
/*global window, RSVP, console */
/*jslint nomen: true, indent: 2, maxerr: 3*/
(
function
(
window
,
rJS
,
loopEventListener
,
jIO
,
mimeType
)
{
"
use strict
"
;
function
addContent
(
gadget
,
event
,
logFunction
)
{
var
url
=
gadget
.
props
.
element
.
querySelector
(
"
form.crib-add .url
"
).
value
,
file_list
=
gadget
.
props
.
element
.
querySelector
(
"
form.crib-add .file
"
)
.
files
,
promise_list
=
[],
file
;
if
(
logFunction
===
undefined
)
{
logFunction
=
console
.
log
;
}
if
(
file_list
.
length
===
0
)
{
logFunction
(
"
No File to Load
"
);
if
(
!
url
)
{
logFunction
(
"
Please Provide a File
"
);
}
promise_list
.
push
(
gadget
.
crib_sw_put
(
url
,
{
content
:
[],
type
:
mimeType
.
lookup
(
url
,
false
,
"
application/octet-stream
"
)
})
);
}
else
{
if
(
!
url
)
{
url
=
file_list
[
0
].
name
;
}
promise_list
.
push
(
gadget
.
crib_sw_put
(
url
,
{
content
:
file_list
[
0
],
type
:
mimeType
.
lookup
(
url
,
false
,
"
application/octet-stream
"
)
})
);
}
return
RSVP
.
Queue
()
.
push
(
function
()
{
return
RSVP
.
all
(
promise_list
);
})
.
push
(
function
()
{
return
gadget
.
redirect
({
page
:
"
editor
"
,
url
:
url
});
});
}
rJS
(
window
)
.
ready
(
function
(
g
)
{
g
.
props
=
{};
return
g
.
getElement
()
.
push
(
function
(
element
)
{
g
.
props
.
element
=
element
;
g
.
props
.
start_deferred
=
RSVP
.
defer
();
});
})
.
declareAcquiredMethod
(
"
crib_sw_put
"
,
"
crib_sw_put
"
)
.
declareAcquiredMethod
(
"
redirect
"
,
"
redirect
"
)
.
declareMethod
(
'
render
'
,
function
(
options
)
{
var
gadget
=
this
;
if
(
options
===
undefined
)
options
=
{};
gadget
.
props
.
options
=
options
;
if
(
options
.
url
!==
undefined
)
{
gadget
.
props
.
element
.
querySelector
(
"
form.crib-add .url
"
)
.
value
=
options
.
url
;
}
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
gadget
.
props
.
start_deferred
.
resolve
();
});
})
.
declareService
(
function
()
{
var
gadget
=
this
;
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
gadget
.
props
.
start_deferred
.
promise
;
})
.
push
(
function
()
{
var
promise_list
=
[];
// promise to get content from URL
promise_list
.
push
(
loopEventListener
(
gadget
.
props
.
element
.
querySelector
(
"
.crib-add
"
),
'
submit
'
,
false
,
function
(
event
)
{
return
addContent
(
gadget
,
event
);
}
));
return
RSVP
.
all
(
promise_list
);
});
});
}(
window
,
rJS
,
loopEventListener
,
jIO
,
mimeType
));
\ No newline at end of file
gadget/gadget_cribjs_page_url_list.html
View file @
280a3d53
...
...
@@ -23,6 +23,7 @@
<input
name=
"search-pattern"
class=
"search-pattern form-control"
type=
"text"
size=
"50"
value=
""
>
</label>
<button
type=
"submit"
name=
"list-contents"
class=
"btn btn-default"
>
Search
</button>
<button
type=
"submit"
name=
"add"
class=
"btn btn-info"
>
Add
</button>
</div>
<table
class=
"table table-striped table-condensed"
>
<thead>
...
...
gadget/gadget_cribjs_page_url_list.js
View file @
280a3d53
...
...
@@ -136,7 +136,14 @@
'
submit
'
,
false
,
function
(
event
)
{
gadget
.
redirect
({
if
(
event
.
submitter
.
name
===
"
add
"
)
{
return
gadget
.
redirect
({
page
:
"
add
"
,
url
:
gadget
.
props
.
element
.
querySelector
(
"
.search-pattern
"
)
.
value
});
}
return
gadget
.
redirect
({
page
:
"
url_list
"
,
pattern
:
gadget
.
props
.
element
.
querySelector
(
"
.search-pattern
"
)
.
value
...
...
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