[Xfce4-commits] <midori:master> Do not add the form history style more than once

Christian Dywan noreply at xfce.org
Fri Dec 18 10:24:02 CET 2009


Updating branch refs/heads/master
         to 82697f0afb71741e4e4c5f860b5b409a66062a17 (commit)
       from e1b82af2c7f780e1381d72aa0aa20d4d5033caf3 (commit)

commit 82697f0afb71741e4e4c5f860b5b409a66062a17
Author: Alexander Butenko <a.butenka at gmail.com>
Date:   Thu Dec 17 20:56:46 2009 +0100

    Do not add the form history style more than once

 extensions/formhistory.c |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/extensions/formhistory.c b/extensions/formhistory.c
index 8e1a2cc..b4ec378 100644
--- a/extensions/formhistory.c
+++ b/extensions/formhistory.c
@@ -58,15 +58,20 @@ formhistory_prepare_js ()
 
    jsforms = g_strdup_printf (
         "%s"
-        "window.addEventListener (\"load\", function () { initSuggestions (); }, true);"
+        "window.addEventListener ('load', function () { initSuggestions (); }, true);"
         "window.addEventListener ('DOMContentLoaded',"
         "function () {"
-        "var mystyle = document.createElement(\"style\");"
-        "mystyle.setAttribute(\"type\", \"text/css\");"
-        "mystyle.appendChild(document.createTextNode(\"%s\"));"
-        "var head = document.getElementsByTagName(\"head\")[0];"
-        "if (head) head.appendChild(mystyle);"
-        "else document.documentElement.insertBefore(mystyle, document.documentElement.firstChild);"
+        "   var styles = document.getElementsByTagName('style');"
+        "   for (i=0; i<styles.length; i++) {"
+        "       if (styles[i].getAttribute('title') == 'formhistory')"
+        "           return;"
+        "   }"
+        "   var mystyle = document.createElement('style');"
+        "   mystyle.setAttribute('type', 'text/css');"
+        "   mystyle.setAttribute('title', 'formhistory');"
+        "   mystyle.appendChild(document.createTextNode('%s'));"
+        "   var head = document.getElementsByTagName('head')[0];"
+        "   if (head) head.appendChild(mystyle);"
         "}, true);",
         autosuggest,
         style);



More information about the Xfce4-commits mailing list