mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
minor cleanup when testing
This commit is contained in:
@@ -9,14 +9,14 @@ function showOverlay() {
|
||||
document.getElementById("gtn-container").style.visibility = "visible";
|
||||
}
|
||||
|
||||
function getIframeUrl(){
|
||||
function getIframeUrl() {
|
||||
var loc;
|
||||
try {
|
||||
loc = document.getElementById("gtn-embed").contentWindow.location.pathname;
|
||||
} catch (e) {
|
||||
loc = null;
|
||||
}
|
||||
return loc
|
||||
return loc;
|
||||
}
|
||||
|
||||
function getIframeScroll() {
|
||||
@@ -26,20 +26,19 @@ function getIframeScroll() {
|
||||
} catch (e) {
|
||||
loc = 0;
|
||||
}
|
||||
return loc
|
||||
return loc;
|
||||
}
|
||||
|
||||
function restoreLocation() {
|
||||
}
|
||||
function restoreLocation() {}
|
||||
|
||||
function persistLocation() {
|
||||
// Don't save every scroll event.
|
||||
var time = new Date().getTime();
|
||||
if ( time - lastUpdate < 1000 ) {
|
||||
if (time - lastUpdate < 1000) {
|
||||
return;
|
||||
}
|
||||
lastUpdate = time;
|
||||
window.localStorage.setItem('gtn-in-galaxy', `${getIframeScroll()} ${getIframeUrl()}`);
|
||||
window.localStorage.setItem("gtn-in-galaxy", `${getIframeScroll()} ${getIframeUrl()}`);
|
||||
}
|
||||
|
||||
function addIframe() {
|
||||
@@ -62,10 +61,14 @@ function addIframe() {
|
||||
} else {
|
||||
safe = true;
|
||||
|
||||
var storedLocation = window.localStorage.getItem('gtn-in-galaxy');
|
||||
if(storedLocation !== null && storedLocation.split(' ')[1] !== undefined && storedLocation.split(' ')[1].startsWith('/training-material/')) {
|
||||
onloadscroll = storedLocation.split(' ')[0];
|
||||
url = storedLocation.split(' ')[1];
|
||||
var storedLocation = window.localStorage.getItem("gtn-in-galaxy");
|
||||
if (
|
||||
storedLocation !== null &&
|
||||
storedLocation.split(" ")[1] !== undefined &&
|
||||
storedLocation.split(" ")[1].startsWith("/training-material/")
|
||||
) {
|
||||
onloadscroll = storedLocation.split(" ")[0];
|
||||
url = storedLocation.split(" ")[1];
|
||||
} else {
|
||||
url = "/training-material/";
|
||||
}
|
||||
@@ -93,9 +96,9 @@ function addIframe() {
|
||||
});
|
||||
|
||||
// Only setup the listener if it won't crash things.
|
||||
if(safe) {
|
||||
if (safe) {
|
||||
// Listen to the scroll position
|
||||
document.getElementById("gtn-embed").contentWindow.addEventListener('scroll', () => {
|
||||
document.getElementById("gtn-embed").contentWindow.addEventListener("scroll", () => {
|
||||
persistLocation();
|
||||
});
|
||||
}
|
||||
@@ -103,12 +106,12 @@ function addIframe() {
|
||||
// Depends on the iframe being present
|
||||
document.getElementById("gtn-embed").addEventListener("load", () => {
|
||||
// Save our current location when possible
|
||||
if(onloadscroll !== undefined){
|
||||
document.getElementById('gtn-embed').contentWindow.scrollTo(0, parseInt(onloadscroll));
|
||||
if (onloadscroll !== undefined) {
|
||||
document.getElementById("gtn-embed").contentWindow.scrollTo(0, parseInt(onloadscroll));
|
||||
onloadscroll = undefined;
|
||||
}
|
||||
|
||||
if(safe) {
|
||||
if (safe) {
|
||||
persistLocation();
|
||||
}
|
||||
var gtn_tools = $("#gtn-embed").contents().find("span[data-tool]");
|
||||
|
||||
Reference in New Issue
Block a user