Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cesium_website
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
websites
cesium_website
Commits
6355b03f
Commit
6355b03f
authored
5 years ago
by
Benoit Lavenier
Browse files
Options
Downloads
Patches
Plain Diff
[enh] Detect Cesium app pattern (#/app/), then redirect to demo.cesium.app
parent
69e82517
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitignore
+2
-1
2 additions, 1 deletion
.gitignore
lib/scripts.js
+34
-9
34 additions, 9 deletions
lib/scripts.js
with
36 additions
and
10 deletions
.gitignore
+
2
−
1
View file @
6355b03f
.htaccess
.idea
This diff is collapsed.
Click to expand it.
lib/scripts.js
+
34
−
9
View file @
6355b03f
/**
* Open the menu, when click on the menu header button
*/
function
openMenu
()
{
var
menu
=
document
.
querySelector
(
"
header nav ul
"
);
var
maxHeight
=
(
menu
.
childElementCount
*
2
+
1
)
+
"
rem
"
;
if
(
menu
.
style
.
height
!=
maxHeight
)
{
menu
.
style
.
height
=
maxHeight
;
}
else
{
menu
.
style
.
height
=
"
0rem
"
;
}
}
document
.
querySelector
(
"
header nav button
"
).
addEventListener
(
"
click
"
,
openMenu
);
/**
* Detect if URL has a Cesium pattern (like '#/app/xxx'), then redirect to https://demo.cesium.app.
* (Useful for OLD links http://g1.duniter.fr/#/app/xxx )
*/
function
detectCesiumHash
()
{
// Workaround to add String.startsWith() if not present
if
(
typeof
String
.
prototype
.
startsWith
!==
'
function
'
)
{
console
.
debug
(
"
Adding String.prototype.startsWith() -> was missing on this platform
"
);
String
.
prototype
.
startsWith
=
function
(
prefix
,
position
)
{
return
this
.
indexOf
(
prefix
,
position
)
===
0
;
};
}
document
.
querySelector
(
"
header nav button
"
).
addEventListener
(
"
click
"
,
openMenu
);
console
.
debug
(
"
[app] Trying to detect Cesium hash in '#/app/' in URL...
"
);
try
{
var
hash
=
window
.
location
.
hash
;
if
(
hash
&&
hash
.
startsWith
(
'
#/app/
'
))
{
var
demoUrl
=
"
https://demo.cesium.app/
"
+
hash
;
console
.
debug
(
"
[app] Cesium hash detected! Redirect to:
"
+
demoUrl
);
window
.
location
=
demoUrl
;
}
}
catch
(
err
)
{
console
.
error
(
err
);
}
}
window
.
addEventListener
(
"
load
"
,
detectCesiumHash
);
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