Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LQDN Adminsys
generateur-slogans
Commits
fb52e7c3
Verified
Commit
fb52e7c3
authored
Oct 09, 2017
by
Thibaut Broggi
Browse files
Fix bugs on page load without parameters
parent
fad47731
Pipeline
#1363
passed with stage
in 33 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
static/canvas.js
View file @
fb52e7c3
...
...
@@ -91,8 +91,6 @@ let draw = function() {
// Update download button
document
.
querySelector
(
'
#save-image
'
).
href
=
canvas
.
toDataURL
();
},
false
);
});
// Edit URL
history
.
replaceState
(
''
,
''
,
window
.
location
.
pathname
+
'
?
'
...
...
@@ -106,15 +104,10 @@ let draw = function() {
// Update tweet button
document
.
getElementById
(
'
tweet-button
'
).
href
=
'
https://twitter.com/intent/tweet?text=Soutenez La Quadrature du Net !
'
+
encodeURIComponent
(
window
.
location
.
href
);
},
false
);
});
}
let
bgColorElems
=
document
.
querySelectorAll
(
'
.colorpicker input[type="radio"], #step3 input[type="radio"], #step4 input[type="radio"]
'
);
for
(
let
i
=
0
;
i
<
bgColorElems
.
length
;
++
i
)
{
bgColorElems
[
i
].
onchange
=
draw
;
}
document
.
getElementById
(
'
step2value
'
).
oninput
=
draw
;
document
.
getElementById
(
'
signature
'
).
oninput
=
draw
;
let
navElems
=
document
.
querySelectorAll
(
'
nav > a
'
);
for
(
let
i
=
0
;
i
<
navElems
.
length
;
++
i
)
{
navElems
[
i
].
onclick
=
function
(
e
)
{
...
...
@@ -139,6 +132,7 @@ window.onload = function() {
document
.
querySelector
(
'
nav > a[href="
'
+
hash
+
'
"]
'
).
click
();
// Update inputs depending on URL params
if
(
window
.
location
.
search
)
{
let
splitParams
=
window
.
location
.
search
.
split
(
'
?
'
)[
1
].
split
(
'
&
'
);
let
params
=
{};
for
(
let
i
in
splitParams
)
{
...
...
@@ -156,6 +150,15 @@ window.onload = function() {
document
.
querySelector
(
'
input[name="icon"][value="
'
+
params
[
'
icon
'
]
+
'
"]
'
).
checked
=
true
;
if
(
params
[
'
signature
'
])
document
.
getElementById
(
'
signature
'
).
value
=
params
[
'
signature
'
];
}
// Add event listeners to inputs
let
bgColorElems
=
document
.
querySelectorAll
(
'
.colorpicker input[type="radio"], #step3 input[type="radio"], #step4 input[type="radio"]
'
);
for
(
let
i
=
0
;
i
<
bgColorElems
.
length
;
++
i
)
{
bgColorElems
[
i
].
onchange
=
draw
;
}
document
.
getElementById
(
'
step2value
'
).
oninput
=
draw
;
document
.
getElementById
(
'
signature
'
).
oninput
=
draw
;
// Update canvas
draw
();
...
...
Write
Preview
Supports
Markdown
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