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);
}
}
/* 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 = [],
return ref;
}
+/**
+ * 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
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 */