#include "hints.js.h"
#define HINT_VAR "VpHint"
+#define HINT_FILE "hints.js"
static void hints_run_script(char* js);
static void hints_fire(void);
{
char* value = NULL;
char* error = NULL;
- vp_eval_script(webkit_web_view_get_main_frame(vp.gui.webview), HINTS_JS, &value, &error);
+ vp_eval_script(
+ webkit_web_view_get_main_frame(vp.gui.webview), HINTS_JS, HINT_FILE, &value, &error
+ );
g_free(value);
g_free(error);
}
char* value = NULL;
char* error = NULL;
- vp_eval_script(webkit_web_view_get_main_frame(vp.gui.webview), js, &value, &error);
+ vp_eval_script(
+ webkit_web_view_get_main_frame(vp.gui.webview), js, HINT_FILE, &value, &error
+ );
g_free(value);
g_free(error);
g_free(js);
vp.hints.num = 0;
js = g_strdup_printf(
- "var %s = new VimpHints('%s', '%s', '%s', '%s');",
+ "%s = new VimpHints('%s', '%s', '%s', '%s');",
HINT_VAR,
style->hint_bg,
style->hint_bg_focus,
char* error = NULL;
int mode = vp.hints.mode;
- vp_eval_script(webkit_web_view_get_main_frame(vp.gui.webview), js, &value, &error);
+ vp_eval_script(
+ webkit_web_view_get_main_frame(vp.gui.webview), js, HINT_FILE, &value, &error
+ );
if (error) {
fprintf(stderr, "%s\n", error);
g_free(error);
VimpHints = function Hints(bg, bgf, fg, style) {
+ "use strict";
var config = {
maxHints: 200,
hintCss: style,
char* value = NULL;
char* error = NULL;
- vp_eval_script(webkit_web_view_get_main_frame(vp.gui.webview), js, &value, &error);
+ vp_eval_script(
+ webkit_web_view_get_main_frame(vp.gui.webview), js, core.files[FILES_SCRIPT], &value, &error
+ );
if (error) {
fprintf(stderr, "%s", error);
g_free(error);
}
}
-void vp_eval_script(WebKitWebFrame* frame, char* script, char** value, char** error)
+void vp_eval_script(WebKitWebFrame* frame, char* script, char* file, char** value, char** error)
{
- JSContextRef js = webkit_web_frame_get_global_context(frame);
- JSValueRef exception = NULL;
- JSValueRef result = NULL;
- JSStringRef str = JSStringCreateWithUTF8CString(script);
+ JSStringRef str, file_name;
+ JSValueRef exception = NULL, result = NULL;
+ JSContextRef js;
- result = JSEvaluateScript(js, str, JSContextGetGlobalObject(js), NULL, 0, &exception);
+ js = webkit_web_frame_get_global_context(frame);
+ str = JSStringCreateWithUTF8CString(script);
+ file_name = JSStringCreateWithUTF8CString(file);
+
+ result = JSEvaluateScript(js, str, JSContextGetGlobalObject(js), file_name, 0, &exception);
+ JSStringRelease(file_name);
JSStringRelease(str);
if (result) {
static char* vp_jsref_to_string(JSContextRef context, JSValueRef ref)
{
- char *string;
+ char* string;
JSStringRef str_ref = JSValueToStringCopy(context, ref, NULL);
size_t len = JSStringGetMaximumUTF8CStringSize(str_ref);
void vp_update_urlbar(const char* uri);
void vp_update_status_style(void);
void vp_echo(const MessageType type, gboolean hide, const char *error, ...);
-void vp_eval_script(WebKitWebFrame* frame, char* script, char** value, char** error);
+void vp_eval_script(WebKitWebFrame* frame, char* script, char* file, char** value, char** error);
gboolean vp_set_mode(Mode mode, gboolean clean);
void vp_set_widget_font(GtkWidget* widget, const VpColor* fg, const VpColor* bg, PangoFontDescription* font);
gboolean vp_load_uri(const Arg* arg);