function getSessionContextVar() {
  var scvi = document.getElementById("showCtxVarInput").value;
  document.getElementById("showContextVar").innerHTML = scvi + " = " + window.parent.qpr.getSessionVariable(scvi);
}

function setSessionContextVar() {
  var scvni = document.getElementById("setCtxVarNameInput").value;
  var scvvi = document.getElementById("setCtxVarValueInput").value;
  parent.qpr.setSessionVariable(scvni, scvvi);
}

function showPageModifiedMarker() {
  document.getElementById("pageModifiedMarker").textContent = "Page modified";
}

window.onload = () => {
  document.getElementById("showCtxVarButton").addEventListener("click", getSessionContextVar);

  document.getElementById("setCtxVarButton").addEventListener("click", setSessionContextVar);

  document.getElementById("pageChangedMarkerButton").addEventListener("click", showPageModifiedMarker);

  if (!window.parent.qpr.getSessionVariable || !window.parent.qpr.setSessionVariable) {
    document.body.innerHTML = "Session variable interface in parent frame is not available.";
  }

  document.getElementById("pageUrl").textContent = window.location.href;

  window.addEventListener("hashchange", () => {
    document.getElementById("pageUrl").textContent = window.location.href;
  });
}