Copyright (C) 2009 Jean-François Guchens <zcx000@gmail.com>
This file is licensed under the terms of the expat license, see the file EXPAT.
-->
-
-<body>
- <div id="wrap">
- <form id="search_bar" name="search_bar" action="{search_uri}" method="get">
- <input type="text" name="q" value="{search_title}" onfocus="javascript:this.value='';"
- onblur="javascript:if(this.value=='') this.value='{search_title}';" />
- <button>{search}</button>
- </form>
+ <div id="content">
<div class="shortcut top" id="s1">
<a href="#" onclick="javascript:return getAction('s1');">
<h1>1</h1><h4><span/></h4>
</a>
<p> </p>
</div>
- <div class="shortcut right" id="s9">
- <a href="#" onclick="javascript:return getAction('s9');">
- <h1>9</h1><h4><span/></h4>
- </a>
- <p> </p>
- </div>
+ <div class="shortcut right" id="s9">
+ <a href="#" onclick="javascript:return getAction('s9');">
+ <h1>9</h1><h4><span/></h4>
+ </a>
+ <p> </p>
</div>
+ </div> <!-- #wrap -->
<div class="clear"></div>
+ </div> <!-- #content -->
</body>
</html>
if (!name) return;
$(id).getLast ().set ('html', name);
+
+ console.log ("speeddial-save");
}
var clearShortcut = function (id)
console.log ("speeddial-save");
}
+ var speeddialSearch = function ()
+ {
+ var reg = new RegExp("%s", "g");
+ var search_url = $('search_bar').getProperty ('action');
+ var search_content = $('search_bar').getFirst ().get ('value');
+ window.location.href = search_url.replace (reg, encodeURIComponent (search_content));
+ return false;
+ }
+
+ var getSpeeddialContent = function()
+ {
+ var content = $('content').get ('html');
+ return '<div id="content">' + content + '</div></div></body></html>';
+ }
+
</script>
</head>
+<body>
+ <div id="wrap">
+ <form id="search_bar" name="search_bar" action="{search_uri}"
+ method="get" onsubmit="javascript:return speeddialSearch();">
+ <input type="text" name="q" value="{search_title}" onfocus="javascript:this.value='';"
+ onblur="javascript:if(this.value=='') this.value='{search_title}';" />
+ <button>{search}</button>
+ </form>
gchar* file_content;
gchar* encoded;
gchar* speeddial_body;
- gchar* t_body_fname;
+ gchar* body_fname;
gsize sz;
- t_body_fname = g_strdup_printf ("%s%s", g_get_user_config_dir (),
- "/midori/speeddial-body.html");
+ body_fname = g_strconcat (g_get_user_config_dir (),
+ "/midori/speeddial-body.html", NULL);
- g_file_get_contents (t_body_fname, &speeddial_body, NULL, NULL);
+ g_file_get_contents (body_fname, &speeddial_body, NULL, NULL);
img = gdk_pixbuf_new_from_file_at_scale (filename, 160, 107, FALSE, NULL);
gdk_pixbuf_save_to_buffer (img, &file_content, &sz, "png", NULL, NULL);
replace = g_regex_replace (regex, speeddial_body, -1,
1, replace_by, 0, NULL);
- g_file_set_contents (t_body_fname, replace, -1, NULL);
+ g_file_set_contents (body_fname, replace, -1, NULL);
g_object_unref (img);
g_regex_unref (regex);
g_free (encoded);
g_free (file_content);
- g_free (t_body_fname);
+ g_free (body_fname);
g_free (speeddial_body);
g_free (replace_by);
g_free (replace_from);
gchar* speeddial_head;
gchar* speeddial_body;
gchar* speeddial_html;
- gchar* t_body_fname;
+ gchar* body_fname;
gchar* location_entry_search;
katze_assign (view->uri, g_strdup (""));
res_server = sokoke_get_res_server ();
port = soup_server_get_port (res_server);
res_root = g_strdup_printf ("http://localhost:%d/res", port);
- t_body_fname = g_strconcat (g_get_user_config_dir (),
- "/midori/speeddial-body.html", NULL);
+ body_fname = g_strconcat (g_get_user_config_dir (),
+ "/midori/speeddial-body.html", NULL);
- if (!g_file_test (t_body_fname, G_FILE_TEST_EXISTS))
+ if (!g_file_test (body_fname, G_FILE_TEST_EXISTS))
{
g_file_get_contents (DATADIR "/midori/res/speeddial-body.html",
&speeddial_body, NULL, NULL );
- g_file_set_contents (t_body_fname, speeddial_body, -1, NULL );
+ g_file_set_contents (body_fname, speeddial_body, -1, NULL );
}
else
- g_file_get_contents (t_body_fname, &speeddial_body, NULL, NULL);
+ g_file_get_contents (body_fname, &speeddial_body, NULL, NULL);
speeddial_html = g_strconcat (speeddial_head, speeddial_body, NULL);
+
g_object_get (view->settings, "location-entry-search",
&location_entry_search, NULL);
+
data = sokoke_replace_variables (speeddial_html,
"{res}", res_root,
"{title}", _("Blank page"),
- "{search_uri}", &location_entry_search,
+ "{search_uri}", location_entry_search,
"{search_title}", _("Search"),
"{search}", _("Search"),
"{click_to_add}", _("Click to add a shortcut"),
"{enter_shortcut_address}", _("Enter shortcut address"),
"{enter_shortcut_name}", _("Enter shortcut name"),
"{are_you_sure}", _("Are you sure you want to delete this shortcut?"), NULL);
- g_free (location_entry_search);
+
#if WEBKIT_CHECK_VERSION (1, 1, 6)
webkit_web_frame_load_alternate_string (
g_free (speeddial_html);
g_free (speeddial_head);
g_free (speeddial_body);
- g_free (t_body_fname);
+ g_free (body_fname);
+ g_free (location_entry_search);
}
/* This is not prefectly elegant, but creating an
error page inline is the simplest solution. */
{
JSContextRef js_context = webkit_web_frame_get_global_context (
webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view)));
- gchar* newdom = sokoke_js_script_eval (js_context,"document.body.innerHTML", NULL);
+ gchar* newdom = sokoke_js_script_eval (js_context,"getSpeeddialContent()", NULL);
gchar* fname = g_strconcat (g_get_user_config_dir (), "/midori/speeddial-body.html", NULL);
g_file_set_contents (fname, newdom, -1, NULL);
g_free (fname);