From a0681cbf03de6129b0829444f353b9014b94cdf6 Mon Sep 17 00:00:00 2001
From: Benoit Alessandroni <benoit@happy-dev.fr>
Date: Wed, 13 May 2020 13:19:04 +0200
Subject: [PATCH] Adding proper fix on the interface language

---
 src/scripts/coopstarter.js | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/src/scripts/coopstarter.js b/src/scripts/coopstarter.js
index 28dbd00e..1bd306d5 100644
--- a/src/scripts/coopstarter.js
+++ b/src/scripts/coopstarter.js
@@ -374,13 +374,13 @@ async function manageSelectLanguage() {
 
       //We retrieve element of the url
       var pathAfterThePrefix = window.location.pathname.split('/')[2];
-      var base_url = location.host
+      var baseUrl = location.protocol + '//' + location.host
 
       //If the selected language is french
       let languagesList = await item.component.resource['ldp:contains'];
       languagesList.forEach(async (resource) => {
         if (item.component.value.languages['@id'] == resource['@id']) {
-          var redirect = "http://"+base_url+'/' + (await resource.code).toLowerCase() + '/'+pathAfterThePrefix
+          var redirect = baseUrl + '/' + (await resource.code).toLowerCase() + '/'+pathAfterThePrefix
           document.location.href = redirect
         } 
       });
@@ -494,14 +494,16 @@ function addProperFilterToSearchComponents(targetId) {
       let instance_only = baseElement.querySelectorAll(
         ".instance_database_only"
       )[0];
-      let checkbox_instance_only = instance_only.querySelector("input");
-      if (checkbox_instance_only) {
-        checkbox_instance_only.onclick = function() {
-          if (this.checked) {
-            //We have to retrieve all data-scr needed to make them pointed only on the instance.
-            //How to?
-          }
-        };
+      if (instance_only) {
+        let checkbox_instance_only = instance_only.querySelector("input");
+        if (checkbox_instance_only) {
+          checkbox_instance_only.onclick = function() {
+            if (this.checked) {
+              //We have to retrieve all data-scr needed to make them pointed only on the instance.
+              //How to?
+            }
+          };
+        }
       }
 
       //MORE CRITERIAS
-- 
GitLab