diff --git a/assets/js/chat_leijuke.js b/assets/js/chat_leijuke.js
deleted file mode 100644
index d30cafe98..000000000
--- a/assets/js/chat_leijuke.js
+++ /dev/null
@@ -1,337 +0,0 @@
-(function (Drupal, drupalSettings) {
- 'use strict';
-
- Drupal.behaviors.chat_leijuke = {
- attach: function (context, settings) {
-
- const leijukeData = drupalSettings.leijuke_data;
-
- for (const chat_selection in leijukeData) {
- const adapter = getAdapter(chat_selection);
- if (!adapter) return;
-
- setTimeout(() => {
- // Only load any leijuke once, in case of ajax triggers.
- if (leijukeData[chat_selection].initialized) {
- console.warn(`Already initialized ${chat_selection}!`);
- return;
- }
-
- new Leijuke(leijukeData[chat_selection], new EuCookieManager, adapter);
- drupalSettings.leijuke_data[chat_selection].initialized = true;
- });
- }
- }
- }
-
- function getAdapter(chatSelection) {
- if (chatSelection.indexOf('genesys') != -1) {
- return new GenesysAdapter;
- }
- console.warn(`No adapter found for ${chatSelection}!`);
- }
-
- class EuCookieManager {
- cookieCheck(cookieNames) {
- let cookiesOk = true;
-
- // If cookies are not available yet, wait for a while.
- if (Drupal.cookieConsent.getConsentStatus(cookieNames) === undefined) {
- let i = 0;
-
- const interval = setInterval(()=> {
- let found = false;
- cookieNames.map((cookieName) => {
- found = Drupal.cookieConsent.getConsentStatus([cookieName]) || false;
- });
-
- if (i >= 3 || found) {
- cookiesOk = found;
- clearInterval(interval);
- }
- i++;
- }, 1000)
- } else {
- cookieNames.map((cookieName) => {
- if (!Drupal.cookieConsent.getConsentStatus([cookieName])) cookiesOk = false;
- });
- }
-
- return cookiesOk;
- }
- cookieSet() {
- if (Drupal.cookieConsent.getConsentStatus(['chat'])) return;
-
- Drupal.cookieConsent.setAcceptedCategories(['chat']);
- }
- }
-
- class GenesysAdapter {
-
- constructor() {
- this.requiredCookies = ['chat'];
- this.bot = false;
- this.persist = true;
- this.hasButton = true;
- }
-
- async getChatExtension() {
- return await new Promise(resolve => {
- let checkChatExtension = setInterval(()=> {
- if (typeof chatExtension != 'undefined') {
- resolve(chatExtension);
- clearInterval(checkChatExtension);
- }
- }, 100);
- });
- }
-
- open(callback) {
- // send open command
- this.getChatExtension().then((ext) => chatExtension.command('WebChat.open').done(callback).fail(console.warn('Failed WebChat open command.')));
- }
-
- onClosed(callback) {
- // subscribe to closed event
- this.getChatExtension().then((ext) => chatExtension.subscribe('WebChat.closed', callback));
- }
-
- onLoaded(callback) {
- // subscribe to ready event
- this.getChatExtension().then((ext) => chatExtension.subscribe('WebChat.ready', callback));
- }
- }
-
- class Leijuke {
- constructor(leijukeData, extCookieManager, chatAdapter) {
-
- this.extCookieManager = extCookieManager;
- this.adapter = chatAdapter;
-
- this.static = {
- selector: `chat-leijuke-${leijukeData.name}`,
- chatSelection: leijukeData.name,
- cookieName: `leijuke.${leijukeData.name}.isOpen`,
- modulePath: leijukeData.modulepath,
- libraries: leijukeData.libraries,
- title: leijukeData.title
- }
-
- this.state = {
- cookies: extCookieManager.cookieCheck(this.adapter.requiredCookies),
- chatLoaded: false,
- isChatOpen: this.isChatOpen(),
- busy: false
- };
-
- if (this.state.cookies) {
- this.loadChat();
- }
-
- this.initWrapper();
- chatAdapter.hasButton && this.render();
- }
-
- prepButton(button) {
-
- button.addEventListener('click', (event) => {
-
- // Debounce button.
- if (this.state.busy) {
- return;
- }
- this.state = {
- ...this.state,
- busy: true,
- };
-
- // If chat was loaded, cookies are ok.
- if (this.state.chatLoaded) {
- this.openChat();
- return;
- }
-
- if (!this.state.cookies) {
- // Implicitly allow chat cookies if clicking Leijuke.
- console.log('Chat cookies allowed implicitly and chat being loaded.');
-
- this.extCookieManager.cookieSet();
- }
-
- this.state = {
- ...this.state,
- cookies: this.extCookieManager.cookieCheck(this.adapter.requiredCookies)
- };
-
- if (this.state.cookies) {
- this.loadChat();
- this.adapter.onLoaded(this.openChat.bind(this));
- } else {
- console.warn('Missing the required cookies to open chat. Missing cookie not allowed to be set implicitly.')
- }
-
- });
- }
-
- openAdapter = () => {
- this.adapter.open(()=>{});
- let acaWidgetInitialized = setInterval(() => {
- if (acaWidget) {
- setTimeout(this.doOpenAdapter, 800);
- clearInterval(acaWidgetInitialized);
- }
- }, 500)
- }
-
- doOpenAdapter = () => this.adapter.open(()=>{});
-
- setLeijukeCookie(cname, cvalue) {
- document.cookie = `${cname}=${cvalue}; path=/; SameSite=Strict; `;
- }
-
- getLeijukeCookie(cname) {
- var name = cname + "=";
- var ca = document.cookie.split(";");
- for (var i = 0; i < ca.length; i++) {
- var c = ca[i];
- while (c.charAt(0) == " ") {
- c = c.substring(1);
- }
- if (c.indexOf(name) == 0) {
- return c.substring(name.length, c.length);
- }
- }
- return "";
- }
-
- openChat() {
- const leijuke = this;
- // Try to open a chat via adapter.
- this.adapter.open((e) => {
- if(leijuke.adapter.persist) {
- leijuke.setLeijukeCookie(leijuke.static.cookieName, true);
- }
- leijuke.state = {
- ...leijuke.state,
- isChatOpen: true,
- busy: false,
- };
- leijuke.render();
- leijuke.adapter.onClosed(leijuke.closeChat.bind(leijuke));
- });
- }
-
- loadChat() {
- const { modulePath, libraries } = this.static;
- libraries.js.map((script) => {
-
- let chatScript = document.createElement('script');
- chatScript.src = script.ext ? script.url : `/${modulePath}/${script.url}`;
- chatScript.type = "text/javascript";
-
- if (script.onload) {
- chatScript.setAttribute('onload', script.onload);
- }
-
- if (script.async) {
- chatScript.setAttribute('async', '');
- }
-
- if (script.dataContainerId) {
- chatScript.setAttribute('data-container-id', script.data_container_id);
- }
-
- // Insert chatScript into head
- let head = document.querySelector('head');
- head.appendChild(chatScript);
- });
-
- if (libraries.hasOwnProperty('css')) {
- libraries.css.map((script) => {
- // Create new link Element for loading css
- let css = document.createElement('link');
- css.rel = 'stylesheet';
- css.href = script.ext ? script.url : `/${modulePath}/${script.url}`;
-
- // Insert chatScript into head
- let head = document.querySelector('head');
- head.append(css);
- });
- }
-
- this.adapter.onLoaded(this.loaded.bind(this));
- }
-
- loaded() {
- this.state = {
- ...this.state,
- chatLoaded: true
- };
- this.render();
- }
-
- closeChat() {
- if(this.adapter.persist) {
- this.setLeijukeCookie(this.static.cookieName, false);
- }
- this.state = {
- ...this.state,
- isChatOpen: false
- };
- this.render();
- }
-
- isChatOpen() {
- if (this.getLeijukeCookie(this.static.cookieName) == "true") {
- this.adapter.onClosed(this.closeChat.bind(this));
- return true;
- }
- return false;
- }
-
- initWrapper() {
- let leijukeWrapper = document.getElementById('chat-leijuke-wrapper');
- if (!leijukeWrapper) {
- leijukeWrapper = document.createElement('aside');
- leijukeWrapper.id = 'chat-leijuke-wrapper';
- document.body.append(leijukeWrapper)
- }
-
- let leijukeTitle = document.createElement('h2');
- leijukeTitle.classList.add('visually-hidden');
- leijukeTitle.innerHTML = Drupal.t('Chat', {}, { context: 'Floating chat title' });
- leijukeWrapper.append(leijukeTitle);
-
- let leijukeInstance = document.createElement('button');
- leijukeInstance.id = this.static.selector;
- leijukeInstance.classList.add('chat-leijuke')
-
- leijukeWrapper.append(leijukeInstance);
-
- this.prepButton(leijukeInstance);
- }
-
- render() {
- const { isChatOpen } = this.state;
-
- const icon = this.adapter.bot ? 'customer-bot-neutral' : 'speechbubble-text';
-
- const element = document.getElementById(this.static.selector);
-
- const innerHTML = `
-
- ${this.static.title}
-
- `;
-
- if (element.innerHTML != innerHTML) {
- element.innerHTML = innerHTML;
- }
-
- element.classList.toggle('hidden', isChatOpen);
-
- }
-
- }
-
-})(Drupal, drupalSettings);
diff --git a/assets/js/genesys_auth_redirect.js b/assets/js/genesys_auth_redirect.js
deleted file mode 100644
index 9cddae7ba..000000000
--- a/assets/js/genesys_auth_redirect.js
+++ /dev/null
@@ -1,120 +0,0 @@
-function isEmpty(str) {
- return (!str || 0 === str.length);
-}
-
-function isBlank(str) {
- return (!str || /^\s*$/.test(str));
-}
-
-String.prototype.isEmpty = function() {
- return (this.length === 0 || !this.trim());
-};
-
-function getCookieChat(cname) {
- var name = cname + "=";
- var ca = document.cookie.split(';');
- for (var i = 0; i < ca.length; i++) {
- var c = ca[i];
- while (c.charAt(0) == ' ') {
- c = c.substring(1);
- }
- if (c.indexOf(name) == 0) {
- return c.substring(name.length, c.length);
- }
- }
- return "";
-}
-
-function callShibboleth()
-{
- var interactionId = '';
- interactionId = getCookieChat("gcReturnSessionId");
- //Current url without querystring:
- var currentPage = location.toString().replace(location.search, "");
- var shibbolethString = "https://asiointi.hel.fi/chat/tunnistus/Shibboleth.sso/KAPALogin?";
- shibbolethString += "target=";
- shibbolethString += "https://asiointi.hel.fi/chat/tunnistus/MagicPagePlain/ReturnProcessor";
- console.log('currentPage:'+currentPage);
- shibbolethString += "%3ForigPage%3D" + currentPage + "?dir%3Din%26gcLoginButtonState%3D1%26errcode%3d0";
- shibbolethString += "%26" + "interactionId" + "%3D" + interactionId;
- window.location = shibbolethString;
-}
-
-var _genesys = {
- onReady: [],
- chat: {
- registration: false,
- localization : 'https://asiointi.hel.fi/chat/sote/custom/chat-suunte-fi.json',
- onReady: [],
- ui: {
- onBeforeChat: function (chat) {
- _genesys.chat.onReady.push(function (chatWidgetApi) {
- chatWidgetApi.restoreChat({
- serverUrl: "https://chat-proxy.hel.fi/chat/sote/cobrowse",
- registration: function (done) {
- done({
- service: 'SUUNTE'
- });
- }
- }).done(function (session) {
- session.setUserData({
- service: 'SUUNTE'
- });
- }).fail(function (par) {
- alert(par.description);
- });
- });
- }
- }
- }
-};
-_genesys.cobrowse = false;
-
-
-var url = window.location.search;
-url = decodeURIComponent(url);
-var referringURL = '';
-var returnURL = '';
-
-/* FILL HERE DRUPAL URL SCOPE UNDER WHICH SUUNTE CHAT IS RUN, COOKIE WOULD BE GOOD TO HAVE URL CONTEXT AS WELL IF MULTIPLE GENESYS CHATS ARE RUN UNDER SAME DOMAIN */
-var helfiChatCookiePath = '/fi/sosiaali-ja-terveyspalvelut/';
-
-// show authenticate button 0 no, 1 yes:
-var int_gcLoginButtonState=0;
-
-// dir = out => transfer to authentication
-if(url.indexOf('?dir=out') !== -1){
- referringURL = document.referrer;
- //setting helper cookie return url:
- document.cookie = "gcReturnUrl="+referringURL+";path="+helfiChatCookiePath;
- callShibboleth();
-}
-
-// dir = in => transfer to back to hel.fi -site from authentication
-if(url.indexOf('?dir=in') !== -1){
- // set gcLoginButtonState -info cookie, if user has authenticated=1, or not..
- var now = new Date();
- var time = now.getTime();
- int_gcLoginButtonState=1;
- time += 180 * 1000;
- now.setTime(time);
- document.cookie = "gcLoginButtonState="+int_gcLoginButtonState +"; expires=" + now.toUTCString() +";path="+helfiChatCookiePath;
-
- // get return url back from hel.fi cookie:
- returnURL = getCookieChat("gcReturnUrl");
-
- // redirect urser back from Vetuma, to hel.fi -site:
- // prevent endless loop, do not redirect back to this transfer page itself!
- if(returnURL!="" && returnURL.indexOf('transfer') == -1 && !isEmpty(returnURL) && !isBlank(returnURL)){
- window.location.href = returnURL + '?redir=done';
- }
- else{
- // search alternative returnURl cookie, set by hel.fi chat page before user clicked authenticate link:
- returnURL = getCookieChat("gcAlternativeReturnUrl");
- if(returnURL!="" && returnURL.indexOf('transfer') == -1 && !isEmpty(returnURL) && !isBlank(returnURL)){
- window.location.href = returnURL + '?redir2=done';
- }
- // default fallback: some error happened. Redirect back to top level contextual main page:
- window.location = helfiChatCookiePath + '?redir3=done';
- }
-}
diff --git a/assets/js/genesys_suunte.js b/assets/js/genesys_suunte.js
deleted file mode 100644
index 9160281be..000000000
--- a/assets/js/genesys_suunte.js
+++ /dev/null
@@ -1,440 +0,0 @@
-var helfiChatCookiePath = '/fi/sosiaali-ja-terveyspalvelut/';
-var helfiChatTransferPath = helfiChatCookiePath + 'genesys-auth-redirect?dir=out';
-var gcReturnSessionId = '';
-
-(function ($, Drupal, drupalSettings) {
- 'use strict';
-
- Drupal.removeChatIcon = function() {
- $(".cx-window-manager").css("display", "none");
- }
-
- Drupal.setGcReturnSessionId = function() {
- // helper cookie to maintain chat session id:
- var gcReturnSessionId = Drupal.getCookieChat("_genesys.widgets.webchat.state.session");
- if (!Drupal.isEmpty(gcReturnSessionId) && !Drupal.isBlank(gcReturnSessionId)) {
- // Found GS-chat session, setting it to helper cookie:
- /* document.cookie = "gcReturnSessionId="+gcReturnSessionId+";path=/helsinki/fi/sosiaali-ja-terveyspalvelut/terveyspalvelut/hammashoito/"; */
- document.cookie =
- "gcReturnSessionId=" + gcReturnSessionId + ";path=" + helfiChatCookiePath;
- } else {
- //console.log("gcReturnSessionId", gcReturnSessionId);
- alert(
- "Virhe, ei voida tunnistaa käyttäjää, koska chat-keskustelu ei ole auki."
- );
- return false;
- }
- // save alternative return url for cookie:
- document.cookie =
- "gcAlternativeReturnUrl=" +
- window.location.href +
- ";path=" +
- helfiChatCookiePath;
- return true;
- }
-
- Drupal.getCookieChat = function(cname) {
- var name = cname + "=";
- var ca = document.cookie.split(";");
- for (var i = 0; i < ca.length; i++) {
- var c = ca[i];
- while (c.charAt(0) == " ") {
- c = c.substring(1);
- }
- if (c.indexOf(name) == 0) {
- return c.substring(name.length, c.length);
- }
- }
- return "";
- }
-
- Drupal.isEmpty = function(str) {
- return !str || 0 === str.length;
- }
-
- Drupal.isBlank = function(str) {
- return !str || /^\s*$/.test(str);
- }
-
- Drupal.behaviors.genesys_suunte = {
- attach: function (context, settings) {
- var helFiChatPageUrl = document.location.href;
- helFiChatPageUrl = helFiChatPageUrl.toLowerCase();
- var helfiChat_lang = document.documentElement.lang;
-
- var accesabilityTexts = {
- fi: {
- userIconAlt: "käyttäjä",
- agentIconAlt: "agentti",
- },
- en: {
- userIconAlt: "user",
- agentIconAlt: "agent",
- },
- sv: {
- userIconAlt: "användare",
- agentIconAlt: "ombud",
- },
- };
-
- var startChatButtonClasses = {
- desktop: {
- fi: {
- open: "cx-webchat-chat-button-open",
- busy: "cx-webchat-chat-button-busy",
- close: "cx-webchat-chat-button-closed",
- },
- sv: {
- open: "cx-webchat-chat-button-open-sv",
- busy: "cx-webchat-chat-button-busy-sv",
- close: "cx-webchat-chat-button-closed-sv",
- },
- en: {
- open: "cx-webchat-chat-button-open-en",
- busy: "cx-webchat-chat-button-busy-en",
- close: "cx-webchat-chat-button-closed-en",
- },
- },
- mobile: {
- fi: {
- open: "cx-webchat-chat-button-mobile-open",
- busy: "cx-webchat-chat-button-mobile-busy",
- close: "cx-webchat-chat-button-mobile-closed",
- },
- sv: {
- open: "cx-webchat-chat-button-mobile-open-sv",
- busy: "cx-webchat-chat-button-mobile-busy-sv",
- close: "cx-webchat-chat-button-mobile-closed-sv",
- },
- en: {
- open: "cx-webchat-chat-button-mobile-open",
- busy: "cx-webchat-chat-button-mobile-busy",
- close: "cx-webchat-chat-button-mobile-closed",
- },
- },
- };
-
- var authEnabled = true;
- var helfiChatLogoElement =
- '
';
-
- var mobileIksButton =
- '