#include "main.h"
#include "normal.h"
#include "util.h"
+#include "scripts/scripts.h"
#include "ext-proxy.h"
typedef struct {
idreturn = ext_proxy_eval_script_sync(c, "vimb_input_mode_element.id");
g_variant_get(idreturn, "(bs)", &idSuccess, &id);
+ /**
+ * Special case: the input element does not have an id assigned to it
+ **/
if( !idSuccess || !id || strlen(id) == 0) {
element_map_key = element_map_next_key++;
- char *js_command = g_strdup_printf(
- "if ( typeof(vimb_editor_map) !== 'object' ) { var vimb_editor_map = new Map; } "
- "vimb_editor_map.set(\"%lu\", vimb_input_mode_element)"
- , element_map_key);
+ char *js_command = g_strdup_printf(JS_SET_EDITOR_MAP_ELEMENT, element_map_key);
ext_proxy_eval_script(c, js_command, NULL);
g_free(js_command);
}
}
if( data->element_id && strlen(data->element_id) > 0 ) {
- jscode_enable = g_strdup_printf(
- "document.getElementById(\"%s\").disabled=false;"
- "document.getElementById(\"%s\").focus()"
- , data->element_id, data->element_id);
+ jscode_enable = g_strdup_printf(JS_FOCUS_ELEMENT_BY_ID,
+ data->element_id, data->element_id);
} else {
- jscode_enable = g_strdup_printf(
- "vimb_editor_map.get(\"%lu\").disabled=false;"
- "vimb_editor_map.get(\"%lu\").focus()"
- , data->element_map_key, data->element_map_key);
+ jscode_enable = g_strdup_printf(JS_FOCUS_EDITOR_MAP_ELEMENT,
+ data->element_map_key, data->element_map_key);
}
ext_proxy_eval_script(data->c, jscode_enable, NULL);
g_free(jscode_enable);