Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dup-tools-front
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
tools
dup-tools-front
Commits
f1c46f53
Commit
f1c46f53
authored
6 years ago
by
Éloïs
Browse files
Options
Downloads
Patches
Plain Diff
[feat] improve css
parent
8d0d7337
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
index.html
+15
-7
15 additions, 7 deletions
index.html
index.js
+36
-33
36 additions, 33 deletions
index.js
main.css
+34
-2
34 additions, 2 deletions
main.css
with
85 additions
and
42 deletions
index.html
+
15
−
7
View file @
f1c46f53
...
...
@@ -18,33 +18,41 @@
<div
id=
"textareas_headers"
>
<div>
<select
name=
"doc_type"
id=
"doc_type"
></select>
<input
type=
"button"
id=
"get_example"
value=
"Get example"
disabled
>
<input
type=
"button"
id=
"get_example"
value=
"Get
document
example"
disabled
>
</div>
</div>
<div
id=
"textareas"
>
<textarea
id=
"textarea_left"
rows=
"25"
cols=
"80"
></textarea>
<input
type=
"button"
id=
"convert_button"
value=
">>>"
>
<div
class=
"blank_separators"
></div>
<div
class=
"vl"
></div>
<div
class=
"blank_separators"
></div>
<textarea
id=
"textarea_right"
rows=
"25"
cols=
"80"
></textarea>
</div>
<div
id=
"textareas_footers"
>
<div>
<b>
<p
id=
"check_result"
>
-
</p>
<p
id=
"check_result"
></p>
</b>
</div>
<div>
<pre
id=
"parse_err"
></pre>
</div>
<div>
<div
class=
"w-50 ta-center"
>
<input
type=
"button"
id=
"verify_button"
value=
"Verify document"
>
</div>
<div
class=
"w-50"
></div>
</div>
</div>
</div>
</main>
<footer>
<a
href=
"https://git.duniter.org/tools/dup-tools-front"
id=
"sourceRibbon"
title=
"Fork me !"
>
<span>
AGPL-3.0
</span>
<span>
Logiciel Libre
</span>
<span>
Remonter aux sources
</span>
<span>
AGPL-3.0
</span>
<span>
Logiciel Libre
</span>
<span>
Remonter aux sources
</span>
</a>
</footer>
</footer>
<script
src=
"./bootstrap.js"
></script>
</body>
...
...
This diff is collapsed.
Click to expand it.
index.js
+
36
−
33
View file @
f1c46f53
...
...
@@ -22,7 +22,7 @@ const CHECK_RESULT_VALID_SIG = 3;
const
doc_type
=
document
.
getElementById
(
'
doc_type
'
);
const
get_example
=
document
.
getElementById
(
'
get_example
'
);
const
textarea_left
=
document
.
getElementById
(
'
textarea_left
'
);
const
convert
_button
=
document
.
getElementById
(
'
convert
_button
'
);
const
verify
_button
=
document
.
getElementById
(
'
verify
_button
'
);
const
textarea_right
=
document
.
getElementById
(
'
textarea_right
'
);
const
check_result
=
document
.
getElementById
(
'
check_result
'
);
const
parse_err
=
document
.
getElementById
(
'
parse_err
'
);
...
...
@@ -37,7 +37,7 @@ for (let i = 1; i <= DOCUMENTS_TYPES_COUNT; i++) {
}
// Create listeners
convert
_button
.
addEventListener
(
"
click
"
,
check_input
);
verify
_button
.
addEventListener
(
"
click
"
,
check_input
);
doc_type
.
addEventListener
(
"
change
"
,
()
=>
{
if
(
doc_type
.
value
!=
ANY_DOC_TYPE
)
{
get_example
.
disabled
=
false
;
...
...
@@ -69,43 +69,46 @@ function create_doc_type_options() {
// Check user input
function
check_input
()
{
const
input
=
textarea_left
.
value
;
const
result
=
wasm
.
parse_doc_and_verify
(
input
,
doc_type
.
value
);
let
output
=
wasm
.
parse_doc_into_json
(
input
,
doc_type
.
value
);
if
(
input
.
length
>
0
)
{
const
result
=
wasm
.
parse_doc_and_verify
(
input
,
doc_type
.
value
);
let
output
=
wasm
.
parse_doc_into_json
(
input
,
doc_type
.
value
);
// Log for debug
console
.
log
(
"
input=
"
+
input
);
console
.
log
(
"
result=
"
+
result
);
console
.
log
(
"
output=
"
+
output
);
// Log for debug
console
.
log
(
"
input=
"
+
input
);
console
.
log
(
"
result=
"
+
result
);
console
.
log
(
"
output=
"
+
output
);
// Clear all texts
textarea_right
.
value
=
""
;
check_result
.
innerText
=
""
;
parse_err
.
innerText
=
""
;
// Clear all texts
textarea_right
.
value
=
""
;
check_result
.
innerText
=
""
;
parse_err
.
innerText
=
""
;
switch
(
result
)
{
case
CHECK_RESULT_UNKNOWN_DOC_TYPE
:
check_result
.
style
.
color
=
'
red
'
;
check_result
.
innerText
=
"
Invalid document. Specify expected document type for more informations.
"
;
break
;
case
CHECK_RESULT_WRONG_FORMAT
:
check_result
.
style
.
color
=
'
red
'
;
check_result
.
innerText
=
"
Wrong format.
"
;
breakText
(
output
,
parse_err
);
break
;
case
CHECK_RESULT_INVALID_SIG
:
check_result
.
style
.
color
=
'
orange
'
;
prettyPrintJsonInTextarea
(
output
,
textarea_right
);
check_result
.
innerText
=
"
Correct format but invalid signature !
"
;
break
;
case
CHECK_RESULT_VALID_SIG
:
check_result
.
style
.
color
=
'
green
'
;
prettyPrintJsonInTextarea
(
output
,
textarea_right
);
check_result
.
innerText
=
"
Valid Document.
"
;
break
;
switch
(
result
)
{
case
CHECK_RESULT_UNKNOWN_DOC_TYPE
:
check_result
.
style
.
color
=
'
red
'
;
check_result
.
innerText
=
"
Format : Invalid
\
u2716
"
;
parse_err
.
innerText
=
"
Specify expected document type for more informations !
"
break
;
case
CHECK_RESULT_WRONG_FORMAT
:
check_result
.
style
.
color
=
'
red
'
;
check_result
.
innerText
=
"
Format : Invalid
\
u2716
"
;
breakText
(
output
,
parse_err
);
break
;
case
CHECK_RESULT_INVALID_SIG
:
check_result
.
style
.
color
=
'
orange
'
;
prettyPrintJson
(
output
,
textarea_right
);
check_result
.
innerHTML
=
"
Format: Valid
\
u2714<br>Signature: Invalid
\
u2716
"
;
break
;
case
CHECK_RESULT_VALID_SIG
:
check_result
.
style
.
color
=
'
green
'
;
prettyPrintJson
(
output
,
textarea_right
);
check_result
.
innerHTML
=
"
Format: Valid
\
u2714<br>Signature: Valid
\
u2714
"
;
break
;
}
}
}
function
prettyPrintJson
InTextarea
(
str
,
elem
)
{
function
prettyPrintJson
(
str
,
elem
)
{
let
obj
=
JSON
.
parse
(
str
);
let
pretty
=
JSON
.
stringify
(
obj
,
undefined
,
4
);
elem
.
value
=
pretty
;
...
...
This diff is collapsed.
Click to expand it.
main.css
+
34
−
2
View file @
f1c46f53
/* Generic class */
.ta-center
{
text-align
:
center
;
}
.w-50
{
width
:
50%
;
}
.vl
{
border-left
:
1px
solid
#ccc
;
}
/* Css */
header
{
text-align
:
center
;
}
...
...
@@ -10,7 +26,7 @@ main {
}
#documents_validator
{
width
:
8
0%
;
width
:
9
0%
;
}
#textareas
{
...
...
@@ -19,6 +35,10 @@ main {
justify-content
:
center
;
}
.blank_separators
{
width
:
20px
;
}
#textareas_headers
#textareas_footers
{
display
:
flex
;
flex-direction
:
column
;
...
...
@@ -35,10 +55,22 @@ main {
textarea
{
width
:
100%
;
white-space
:
pre-line
;
resize
:
none
;
}
#convert_button
{
#verify_button
{
font-size
:
1.2em
;
border
:
1px
solid
green
;
border-radius
:
50px
;
color
:
green
;
background-color
:
rgb
(
255
,
255
,
255
);
margin
:
10px
;
box-shadow
:
0px
0px
15px
black
;
}
#verify_button
:disabled
{
border
:
1px
solid
grey
;
color
:
grey
;
}
#parse_err
{
...
...
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