Add response usage to Kalamar plugin

Change-Id: I6b0277771223d49764baaa71e53eaa83b4ea32e7
diff --git a/cmd/termmapper/main.go b/cmd/termmapper/main.go
index 006a009..37de2da 100644
--- a/cmd/termmapper/main.go
+++ b/cmd/termmapper/main.go
@@ -423,32 +423,54 @@
 
 	if data.MapID != "" {
 
-		serviceURL, err := url.Parse(data.ServiceURL)
+		queryServiceURL, err := url.Parse(data.ServiceURL)
 		if err != nil {
 			log.Warn().Err(err).Msg("Failed to join URL path")
 		}
 
 		// Use path.Join to normalize the path part
-		serviceURL.Path = path.Join(serviceURL.Path, data.MapID+"/query")
+		queryServiceURL.Path = path.Join(queryServiceURL.Path, data.MapID+"/query")
+		queryServiceURL.RawQuery = "dir=atob"
+
+		responseServiceURL, err := url.Parse(data.ServiceURL)
+		if err != nil {
+			log.Warn().Err(err).Msg("Failed to join URL path")
+		}
+
+		// Use path.Join to normalize the path part
+		responseServiceURL.Path = path.Join(responseServiceURL.Path, data.MapID+"/response")
 
 		html += `   <script>
   		<!-- activates/deactivates Mapper. -->
   		  
-       let data = {
+       let qdata = {
          'action'  : 'pipe',
-         'service' : '` + serviceURL.String() + `'
+         'service' : '` + queryServiceURL.String() + `'
        };
 
+       let rdata = {
+         'action'  : 'pipe',
+         'service' : '` + responseServiceURL.String() + `'
+       };
+
+
        function pluginit (p) {
          p.onMessage = function(msg) {
            if (msg.key == 'termmapper') {
              if (msg.value) {
-               data['job'] = 'add';
+               qdata['job'] = 'add';
              }
              else {
-               data['job'] = 'del';
+               qdata['job'] = 'del';
              };
-             KorAPlugin.sendMsg(data);
+             KorAPlugin.sendMsg(qdata);
+			 if (msg.value) {
+               rdata['job'] = 'add-after';
+             }
+             else {
+               rdata['job'] = 'del-after';
+             };  
+             KorAPlugin.sendMsg(rdata);
            };
          };
        };
diff --git a/cmd/termmapper/main_test.go b/cmd/termmapper/main_test.go
index 8030b37..530ab68 100644
--- a/cmd/termmapper/main_test.go
+++ b/cmd/termmapper/main_test.go
@@ -1167,7 +1167,7 @@
 
 			// Check that the HTML contains the expected service URL in the JavaScript
 			expectedJSURL := tt.expectedServiceURL + "/test-mapper/query"
-			assert.Contains(t, htmlContent, "'service' : '"+expectedJSURL+"'")
+			assert.Contains(t, htmlContent, "'service' : '"+expectedJSURL)
 
 			// Ensure it's still a valid HTML page
 			assert.Contains(t, htmlContent, "KoralPipe-TermMapper")
@@ -1225,7 +1225,7 @@
 
 	htmlContent := string(body)
 	expectedJSURL := "https://custom.example.com/api/termmapper/config-mapper/query"
-	assert.Contains(t, htmlContent, "'service' : '"+expectedJSURL+"'")
+	assert.Contains(t, htmlContent, "'service' : '"+expectedJSURL)
 }
 
 func TestServiceURLDefaults(t *testing.T) {
@@ -1288,7 +1288,7 @@
 
 	htmlContent := string(body)
 	expectedJSURL := "https://korap.ids-mannheim.de/plugin/termmapper/main-config-mapper/query"
-	assert.Contains(t, htmlContent, "'service' : '"+expectedJSURL+"'")
+	assert.Contains(t, htmlContent, "'service' : '"+expectedJSURL)
 }
 
 func TestGenerateKalamarPluginHTMLWithURLJoining(t *testing.T) {
@@ -1302,31 +1302,31 @@
 			name:       "Service URL without trailing slash",
 			serviceURL: "https://example.com/plugin/termmapper",
 			mapID:      "test-mapper",
-			expected:   "'service' : 'https://example.com/plugin/termmapper/test-mapper/query'",
+			expected:   "'service' : 'https://example.com/plugin/termmapper/test-mapper/query",
 		},
 		{
 			name:       "Service URL with trailing slash",
 			serviceURL: "https://example.com/plugin/termmapper/",
 			mapID:      "test-mapper",
-			expected:   "'service' : 'https://example.com/plugin/termmapper/test-mapper/query'",
+			expected:   "'service' : 'https://example.com/plugin/termmapper/test-mapper/query",
 		},
 		{
 			name:       "Map ID with leading slash",
 			serviceURL: "https://example.com/plugin/termmapper",
 			mapID:      "/test-mapper",
-			expected:   "'service' : 'https://example.com/plugin/termmapper/test-mapper/query'",
+			expected:   "'service' : 'https://example.com/plugin/termmapper/test-mapper/query",
 		},
 		{
 			name:       "Both with slashes",
 			serviceURL: "https://example.com/plugin/termmapper/",
 			mapID:      "/test-mapper",
-			expected:   "'service' : 'https://example.com/plugin/termmapper/test-mapper/query'",
+			expected:   "'service' : 'https://example.com/plugin/termmapper/test-mapper/query",
 		},
 		{
 			name:       "Complex map ID",
 			serviceURL: "https://example.com/api/v1/",
 			mapID:      "complex-mapper-name_123",
-			expected:   "'service' : 'https://example.com/api/v1/complex-mapper-name_123/query'",
+			expected:   "'service' : 'https://example.com/api/v1/complex-mapper-name_123/query",
 		},
 	}