Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
EBI-Framework
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ebiwd
EBI-Framework
Commits
0bb432e7
Commit
0bb432e7
authored
7 years ago
by
khawkins98
Browse files
Options
Downloads
Patches
Plain Diff
Draft build of new announcements.js
For #26
parent
1cc23732
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
js/ebi-global-includes/script/4_ebiFrameworkContent.js
+80
-8
80 additions, 8 deletions
js/ebi-global-includes/script/4_ebiFrameworkContent.js
js/ebi-global-includes/script/6_ebiFrameworkInvokeScripts.js
+1
-1
1 addition, 1 deletion
js/ebi-global-includes/script/6_ebiFrameworkInvokeScripts.js
with
81 additions
and
9 deletions
js/ebi-global-includes/script/4_ebiFrameworkContent.js
+
80
−
8
View file @
0bb432e7
...
...
@@ -312,12 +312,84 @@ function ebiFrameworkUpdateFooterMeta() {
init
();
}
function
ebiFrameworkIncludeScripts
()
{
var
downtimeScript
=
'
https://www.ebi.ac.uk/web_guidelines/js/downtime.js?
'
+
Math
.
round
(
new
Date
().
getTime
()
/
3600000
);
putComment
=
document
.
createComment
(
downtimeScript
+
'
automatically inserted
'
);
putScript
=
document
.
createElement
(
'
script
'
);
putScript
.
type
=
'
text/javascript
'
;
putScript
.
src
=
downtimeScript
;
document
.
body
.
appendChild
(
putComment
);
document
.
body
.
appendChild
(
putScript
);
/**
* Load the downtime/announcement messages, if any.
* For more info, see: https://gitlab.ebi.ac.uk/ebiwd/ebi.emblstatic.net-root-assets/tree/master/src
*/
function
ebiFrameworkIncludeAnnouncements
()
{
// var downtimeScript = 'http://origin.dev.ebi.emblstatic.net/announcements.js?' + Math.round(new Date().getTime() / 3600000);
// var downtimeScript = 'http://origin.dev.ebi.emblstatic.net/announcements.js';
// are there matching annoucnements for the current URL
function
detectAnnouncements
(
messages
)
{
var
currentHost
=
window
.
location
.
hostname
,
currentPath
=
window
.
location
.
pathname
;
// don't treat wwwdev as distinct from www
currentHost
=
currentHost
.
replace
(
/wwwdev/g
,
"
www
"
);
// for (var i = 0; i < Object.keys(messages).length; i++) {
// var currentKey = Object.keys(messages)[i]; // www.ebi.ac.uk/*, etc.
// }
// try to show any possible variations of the url
// Note: this is pretty simple stupid, but maybe it's more effective than a sophisticated solution?
injectAnnouncements
(
messages
[
currentHost
]);
injectAnnouncements
(
messages
[
currentHost
+
'
/
'
]);
injectAnnouncements
(
messages
[
currentHost
+
'
/*
'
]);
if
(
currentPath
.
length
>
1
)
{
// don't try to much no path or '/'
injectAnnouncements
(
messages
[
currentHost
+
currentPath
]);
injectAnnouncements
(
messages
[
currentHost
+
currentPath
+
'
*
'
]);
injectAnnouncements
(
messages
[
currentHost
+
currentPath
+
'
/*
'
]);
}
}
// once an annocuncement has been matched to the current page, show it (if there is one)
function
injectAnnouncements
(
message
)
{
console
.
log
(
message
);
if
(
typeof
(
message
)
==
'
undefined
'
)
{
return
false
;
};
var
container
=
(
document
.
getElementById
(
'
main-content-area
'
)
||
document
.
getElementById
(
'
main-content
'
)
||
document
.
getElementById
(
'
main
'
)
||
document
.
getElementById
(
'
content
'
)
||
document
.
getElementById
(
'
contentsarea
'
));
if
(
container
==
null
)
{
// if no suitable container, warn
console
.
warn
(
'
A message needs to be shown on this site, but an appropriate container could not be found.
\n
Message follows:
'
,
'
\n
'
+
message
.
headline
,
'
\n
'
+
message
.
message
,
'
\n
'
+
'
Priority:
'
,
message
.
priority
)
return
false
;
}
var
banner
=
document
.
createElement
(
'
div
'
);
var
wrapper
=
document
.
createElement
(
'
div
'
);
// var inner = document.createElement('div');
// banner.id = "cookie-banner";
banner
.
className
=
"
row
"
;
wrapper
.
className
=
"
row callout
"
+
(
message
.
priority
||
""
);
wrapper
.
innerHTML
=
"
<h3>
"
+
message
.
headline
+
"
</h3>
"
+
message
.
message
+
// "<div id='cookie-dismiss'><button class='close-button' style='top: 0.3rem; color:#fff;' aria-label='Close alert' type='button'><span aria-hidden='true'>×</span></button></div>" +
""
;
container
.
insertBefore
(
banner
,
container
.
firstChild
);
banner
.
appendChild
(
wrapper
);
}
function
loadRemote
(
file
)
{
if
(
window
.
XMLHttpRequest
)
{
xmlhttp
=
new
XMLHttpRequest
();
}
xmlhttp
.
onreadystatechange
=
function
()
{
if
(
xmlhttp
.
readyState
==
4
&&
xmlhttp
.
status
==
200
)
{
eval
(
xmlhttp
.
responseText
);
detectAnnouncements
(
m
)
}
}
xmlhttp
.
open
(
"
GET
"
,
file
,
false
);
xmlhttp
.
send
();
}
loadRemote
(
'
http://origin.dev.ebi.emblstatic.net/announcements.js
'
);
}
This diff is collapsed.
Click to expand it.
js/ebi-global-includes/script/6_ebiFrameworkInvokeScripts.js
+
1
−
1
View file @
0bb432e7
...
...
@@ -15,7 +15,7 @@ function ebiFrameworkInvokeScripts() {
ebiFrameworkInsertEMBLdropdown
();
ebiFrameworkUpdateFoot
();
ebiFrameworkUpdateFooterMeta
();
ebiFrameworkInclude
Scrip
ts
();
ebiFrameworkInclude
Announcemen
ts
();
ebiFrameworkCookieBanner
();
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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