diff options
author | Rob <rob.manea@gmail.com> | 2009-12-03 17:11:21 +0100 |
---|---|---|
committer | Rob <rob.manea@gmail.com> | 2009-12-03 17:11:21 +0100 |
commit | b61c04fd5af9747e2b868ed6d47d86a75e4baa2d (patch) | |
tree | 7f35fb80f43152b80f1656802497745ee49c68cf | |
parent | e81b577aefac01eb2219ee048d84c1ee21106e15 (diff) |
added @<+file.js>@ capability and documentation
-rw-r--r-- | README | 4 | ||||
-rw-r--r-- | uzbl-core.c | 20 |
2 files changed, 21 insertions, 3 deletions
@@ -306,6 +306,10 @@ the java script in @< >@. print The currently viewed document contains @<document.links.length>@ links +The @<>@ substitution can also load JavaScript from a file, syntax: @<+filename>@ + + print JS return value from file: @<+/path/to/file.js>@ + Variable expansion also works within a java script substitution. diff --git a/uzbl-core.c b/uzbl-core.c index edb3e54..2e5e14e 100644 --- a/uzbl-core.c +++ b/uzbl-core.c @@ -266,6 +266,7 @@ expand(const char *s, guint recurse) { } else if(recurse != 1 && etype == EXP_EXPR) { + mycmd = expand(ret, 1); gchar *quoted = g_shell_quote(mycmd); gchar *tmp = g_strdup_printf("%s %s", @@ -293,9 +294,22 @@ expand(const char *s, guint recurse) { } else if(recurse != 2 && etype == EXP_JS) { - mycmd = expand(ret, 2); - eval_js(uzbl.gui.web_view, mycmd, js_ret); - g_free(mycmd); + + /* read JS from file */ + if(ret[0] == '+') { + GArray *tmp = g_array_new(TRUE, FALSE, sizeof(gchar *)); + mycmd = expand(ret+1, 2); + g_array_append_val(tmp, mycmd); + + run_external_js(uzbl.gui.web_view, tmp, js_ret); + g_array_free(tmp, TRUE); + } + /* JS from string */ + else { + mycmd = expand(ret, 2); + eval_js(uzbl.gui.web_view, mycmd, js_ret); + g_free(mycmd); + } if(js_ret->str) { g_string_append(buf, js_ret->str); |