Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
generateur-slogans
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
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
LQDN Adminsys
generateur-slogans
Commits
3e1fce1b
Verified
Commit
3e1fce1b
authored
Nov 06, 2017
by
Thibaut Broggi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a GET parameter to change language
parent
a9221f22
Pipeline
#1493
passed with stage
in 41 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
22 deletions
+30
-22
srv.js
srv.js
+9
-2
static/canvas.js
static/canvas.js
+21
-20
No files found.
srv.js
View file @
3e1fce1b
...
...
@@ -14,9 +14,16 @@ app.set('view engine', 'pug');
app
.
use
(
express
.
static
(
'
./static
'
));
app
.
use
(
function
(
req
,
res
,
next
)
{
let
locale
=
req
.
headers
[
'
accept-language
'
]
||
''
;
let
locale
=
req
.
query
.
lang
||
req
.
headers
[
'
accept-language
'
]
||
''
;
req
.
i18n
=
new
i18n
();
req
.
i18n
.
setLocale
(
locale
.
indexOf
(
'
en
'
)
!==
-
1
&&
locale
.
indexOf
(
'
en
'
)
<
locale
.
indexOf
(
'
fr
'
)
?
'
en
'
:
'
fr
'
);
if
(
locale
.
indexOf
(
'
en
'
)
!==
-
1
&&
locale
.
indexOf
(
'
fr
'
)
!==
-
1
)
req
.
i18n
.
setLocale
(
locale
.
indexOf
(
'
en
'
)
<
locale
.
indexOf
(
'
fr
'
)
?
'
en
'
:
'
fr
'
);
else
if
(
locale
.
indexOf
(
'
en
'
)
!==
-
1
&&
locale
.
indexOf
(
'
fr
'
)
===
-
1
)
req
.
i18n
.
setLocale
(
'
en
'
);
else
req
.
i18n
.
setLocale
(
'
fr
'
);
next
();
});
...
...
static/canvas.js
View file @
3e1fce1b
...
...
@@ -18,6 +18,14 @@ let width = canvas.width;
let
height
=
canvas
.
height
;
let
fontSize
=
44
;
let
params
=
{};
if
(
window
.
location
.
search
)
{
let
splitParams
=
window
.
location
.
search
.
split
(
'
?
'
)[
1
].
split
(
'
&
'
);
for
(
let
i
in
splitParams
)
{
params
[
splitParams
[
i
].
split
(
'
=
'
)[
0
]]
=
decodeURIComponent
(
splitParams
[
i
].
split
(
'
=
'
)[
1
]);
}
}
let
get
=
function
(
url
,
cb
)
{
let
xmlHttp
=
new
XMLHttpRequest
();
xmlHttp
.
onreadystatechange
=
function
()
{
...
...
@@ -40,7 +48,7 @@ let getImage = function(id, cb) {
}
let
language
=
function
()
{
return
navigator
.
language
.
indexOf
(
'
en
'
)
!==
-
1
?
'
en
'
:
'
fr
'
;
return
(
params
.
lang
||
navigator
.
language
)
.
indexOf
(
'
en
'
)
!==
-
1
?
'
en
'
:
'
fr
'
;
}
let
_
=
function
(
str
)
{
...
...
@@ -144,12 +152,6 @@ window.addEventListener('load', 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
)
{
params
[
splitParams
[
i
].
split
(
'
=
'
)[
0
]]
=
decodeURIComponent
(
splitParams
[
i
].
split
(
'
=
'
)[
1
]);
}
if
(
params
[
'
bgColor
'
])
document
.
querySelector
(
'
.colorpicker input[name="bgColor"][value="
'
+
params
[
'
bgColor
'
]
+
'
"]
'
).
checked
=
true
;
if
(
params
[
'
fgColor
'
])
...
...
@@ -162,7 +164,6 @@ window.addEventListener('load', 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
inputs
=
document
.
querySelectorAll
(
'
.colorpicker input[type="radio"], #step3 input[type="radio"], #step4 input[type="radio"]
'
);
...
...
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