Added query parameter API to plugin server
Change-Id: I8f79aeab8d281ac02f9a1b490351f020556ffcfb
diff --git a/Changes b/Changes
index 9d22d33..cdebaa8 100755
--- a/Changes
+++ b/Changes
@@ -1,4 +1,4 @@
-0.39 2020-09-14
+0.39 2020-09-18
- Add information on secret file to Readme.
- Change default API endpoint to korap.ids-mannheim.de.
- Fix label for toggle plugins.
@@ -12,6 +12,7 @@
- Add support for icons in plugin definition (hebasta).
- Change buttonGroup API to accept class and
icon definitions.
+ - Added query parameter API to plugin server.
WARNING: If you relied on the former default API endpoint
being http://localhost:9999/, this will break your
diff --git a/dev/demo/export.html b/dev/demo/export.html
index 4de4ad5..ebd9539 100644
--- a/dev/demo/export.html
+++ b/dev/demo/export.html
@@ -15,7 +15,8 @@
<script data-main="export.js" src="../js/lib/require.js" async="async"></script>
</head>
<body>
- <p>To run this demo start the <a href= https://korap.ids-mannheim.de/gerrit/admin/repos/KorAP/KalamarExportPlugin> Plugin Server</a> as Java Application or with the jar file in the /target folder.</p>
+ <p>To run this demo start the <a href= https://korap.ids-mannheim.de/gerrit/admin/repos/KorAP/KalamarExportPlugin> Plugin Server</a> as Java Application or with the jar file in the /target folder.</p>
+ <p>Click <a href="?q=Wasser&ql=poliqarp">?q=Wasser&ql=poliqarp</a> for a meaningful query.</p>
<div id="resultinfo" class="found"></div>
diff --git a/dev/js/src/plugin/server.js b/dev/js/src/plugin/server.js
index cb49364..f862770 100644
--- a/dev/js/src/plugin/server.js
+++ b/dev/js/src/plugin/server.js
@@ -415,7 +415,7 @@
};
}
- // Get Query form information
+ // Get Query information from from
else if (d.key == 'QueryForm') {
let doc = document;
let v = d["value"] = {};
@@ -430,6 +430,17 @@
if (el = KorAP.vc) {
v["cq"] = el.toQuery();
};
+ }
+
+ // Get Query information from parameters
+ else if (d.key == 'QueryParam') {
+
+ // Supported in all modern browsers
+ var p = new URLSearchParams(window.location.search);
+ let v = d["value"] = {};
+ v["q"] = p.get('q');
+ v["ql"] = p.get('ql');
+ v["cq"] = p.get('cq');
};
};