[Xfce4-commits] <midori:master> Implement "autosuggest" in form history and bump the version

Christian Dywan noreply at xfce.org
Sun Jan 10 23:00:02 CET 2010


Updating branch refs/heads/master
         to 2832704f7d9478735836c8dfda98546eb981a6cd (commit)
       from 089315bcaa29aca8ada95ff0f2bdf36aac16a00e (commit)

commit 2832704f7d9478735836c8dfda98546eb981a6cd
Author: Alexander Butenko <a.butenka at gmail.com>
Date:   Sun Jan 10 22:57:17 2010 +0100

    Implement "autosuggest" in form history and bump the version
    
    1. Honor non W3C but commonly used "autosuggest" attribute.
    
    2. Bump version to 1.0. The plugin can be considered stable.

 data/autosuggestcontrol.js |    6 ++++--
 extensions/formhistory.c   |    9 +++++----
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/data/autosuggestcontrol.js b/data/autosuggestcontrol.js
index 23619bc..f045f0f 100644
--- a/data/autosuggestcontrol.js
+++ b/data/autosuggestcontrol.js
@@ -301,9 +301,11 @@ function initSuggestions () {
     {
         var ename = inputs[i].getAttribute("name");
         var eid = inputs[i].getAttribute("id");
+        var autocomplete = inputs[i].getAttribute ("autocomplete");
+
         if (!ename && eid)
             ename=eid;
-        if (inputs[i].type == "text")
-            var smth = new AutoSuggestControl(inputs[i], new FormSuggestions(ename));
+        if (inputs[i].type == "text" && autocomplete != "off")
+            var smth = new AutoSuggestControl (inputs[i], new FormSuggestions (ename));
     }
 };
diff --git a/extensions/formhistory.c b/extensions/formhistory.c
index 7219383..8404ea1 100644
--- a/extensions/formhistory.c
+++ b/extensions/formhistory.c
@@ -191,7 +191,6 @@ formhistory_navigation_decision_cb (WebKitWebView*             web_view,
                                     WebKitWebPolicyDecision*   decision,
                                     MidoriExtension*           extension)
 {
-    JSContextRef js_context = webkit_web_frame_get_global_context (web_frame);
     /* The script returns form data in the form "field_name|,|value|,|field_type".
        We are handling only input fields with 'text' or 'password' type.
        The field separator is "|||" */
@@ -203,7 +202,8 @@ formhistory_navigation_decision_cb (WebKitWebView*             web_view,
                  "        var eid = inputs[i].getAttribute('id');"
                  "        if (!ename && eid)"
                  "            ename=eid;"
-                 "        out += ename+'|,|'+inputs[i].value +'|,|'+inputs[i].type +'|||';"
+                 "        if (inputs[i].getAttribute('autocomplete') != 'off')"
+                 "            out += ename+'|,|'+inputs[i].value +'|,|'+inputs[i].type +'|||';"
                  "    }"
                  "  }"
                  "  return out;"
@@ -212,8 +212,9 @@ formhistory_navigation_decision_cb (WebKitWebView*             web_view,
 
     if (webkit_web_navigation_action_get_reason (action) == WEBKIT_WEB_NAVIGATION_REASON_FORM_SUBMITTED)
     {
+        JSContextRef js_context = webkit_web_frame_get_global_context (web_frame);
         gchar* value = sokoke_js_script_eval (js_context, script, NULL);
-        if (value)
+        if (value && *value)
         {
             gpointer db = g_object_get_data (G_OBJECT (extension), "formhistory-db");
             gchar** inputs = g_strsplit (value, "|||", 0);
@@ -496,7 +497,7 @@ extension_init (void)
 
     if (formhistory_prepare_js ())
     {
-        ver = "0.1";
+        ver = "1.0";
         desc = g_strdup (_("Stores history of entered form data"));
     }
     else



More information about the Xfce4-commits mailing list