summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/hints.c9
-rw-r--r--src/hints.js3
-rw-r--r--src/js.c13
-rw-r--r--src/js.h1
4 files changed, 22 insertions, 4 deletions
diff --git a/src/hints.c b/src/hints.c
index 52fe9e0..9b58bd3 100644
--- a/src/hints.c
+++ b/src/hints.c
@@ -161,13 +161,18 @@ void hints_fire(void)
void hints_follow_link(const gboolean back, int count)
{
- char *pattern = back ? vb.config.prevpattern : vb.config.nextpattern;
+ char *json = g_strdup_printf(
+ "[%s]",
+ back ? vb.config.prevpattern : vb.config.nextpattern
+ );
JSValueRef arguments[] = {
js_string_to_ref(hints.ctx, back ? "prev" : "next"),
- js_string_to_ref(hints.ctx, pattern),
+ js_object_to_ref(hints.ctx, json),
JSValueMakeNumber(hints.ctx, count)
};
+ g_free(json);
+
call_hints_function("followLink", 3, arguments);
}
diff --git a/src/hints.js b/src/hints.js
index 8a0ac78..cb4a503 100644
--- a/src/hints.js
+++ b/src/hints.js
@@ -429,8 +429,7 @@ Object.freeze((function(){
}
/* follow the count last link on pagematching the given regex list */
- function followLink(rel, list, count) {
- var patterns = list.split(",");
+ function followLink(rel, patterns, count) {
/* returns array of matching elements */
function followFrame(frame) {
var i, p, reg, res = [],
diff --git a/src/js.c b/src/js.c
index cd8e6a0..c54c613 100644
--- a/src/js.c
+++ b/src/js.c
@@ -159,6 +159,19 @@ JSValueRef js_string_to_ref(JSContextRef ctx, const char *string)
}
/**
+ * Retrieves a values reference for given json or array string string.
+ */
+JSValueRef js_object_to_ref(JSContextRef ctx, const char *json)
+{
+ JSValueRef ref = NULL;
+ if (evaluate_string(ctx, json, NULL, &ref)) {
+ return ref;
+ }
+ g_warning("Could not parse %s", json);
+ return NULL;
+}
+
+/**
* Runs a string as JavaScript and returns if the call succeed.
* In case the call succeed, the given *result is filled with the result
* value, else with the value reference of the exception.
diff --git a/src/js.h b/src/js.h
index 7ab81c8..491fc50 100644
--- a/src/js.h
+++ b/src/js.h
@@ -30,5 +30,6 @@ char* js_object_call_function(JSContextRef ctx, JSObjectRef obj,
const char *func, int count, JSValueRef params[]);
char *js_ref_to_string(JSContextRef ctx, JSValueRef ref);
JSValueRef js_string_to_ref(JSContextRef ctx, const char *string);
+JSValueRef js_object_to_ref(JSContextRef ctx, const char *json);
#endif /* end of include guard: _JS_H */