Do not modify form if not existent
Change-Id: I0bb9fb1909edc850b57039e0b5efc55cc5587fb9
diff --git a/dev/js/src/init.js b/dev/js/src/init.js
index 58c604d..1e9a805 100644
--- a/dev/js/src/init.js
+++ b/dev/js/src/init.js
@@ -433,11 +433,10 @@
var queryPanel = queryPanelClass.create();
// Get input field
- var sform = d.getElementById("searchform");
var vcView = d.getElementById('vc-view')
- if (sform && vcView) {
+ if (form && vcView) {
// The views are below the query bar
- sform.insertBefore(queryPanel.element(), vcView);
+ form.insertBefore(queryPanel.element(), vcView);
KorAP.Panel['query'] = queryPanel;
};
@@ -475,11 +474,15 @@
if (json && json.length > 0) {
// Add state manager
- const input = d.getElementById("searchform").addE("input");
+ form = d.getElementById("searchform");
+ if (!form) {
+ return;
+ };
+
+ const input = form.addE("input");
input.setAttribute("name","state");
KorAP.States = stateManagerClass.create(input);
-
// Load Plugin Server first
KorAP.Plugin = pluginClass.create();