WebBrowser/Tools/Scripts.py

changeset 6174
bb2989d750ce
parent 6149
e611e45a17d6
child 6645
ad476851d7e0
--- a/WebBrowser/Tools/Scripts.py	Sun Mar 04 13:04:58 2018 +0100
+++ b/WebBrowser/Tools/Scripts.py	Sun Mar 04 14:52:32 2018 +0100
@@ -95,13 +95,18 @@
     """
     source = """
 (function() {
-var external = {};
-
-window.external = external;
-
-window.print = function() {
-    window.location = 'eric:PrintPage';
-};
+    var external = {};
+    external.AddSearchProvider = function(url) {
+        window.location = 'eric:AddSearchProvider?url=' + url;
+    };
+    external.IsSearchProviderInstalled = function(url) {
+        console.warn('NOT IMPLEMENTED: IsSearchProviderInstalled()');
+        return false;
+    };
+    window.external = external;
+    window.print = function() {
+        window.location = 'eric:PrintPage';
+    };
 })()"""
     
     return source
@@ -140,11 +145,11 @@
     source = """
 (function() {{
     var e = document.elementFromPoint({0}, {1});
-    if (!e || e.tagName != 'INPUT')
+    if (!e || e.tagName.toLowerCase() != 'input')
         return;
     var fe = e.parentElement;
     while (fe) {{
-        if (fe.tagName == 'FORM')
+        if (fe.tagName.toLowerCase() != 'form')
             break;
         fe = fe.parentElement;
     }}
@@ -336,10 +341,10 @@
         registerForm(document.forms[i]);
     
     var observer = new MutationObserver(function(mutations) {
-        for (var i = 0; i < mutations.length; ++i)
-            for (var j = 0; j < mutations[i].addedNodes.length; ++j)
-                if (mutations[i].addedNodes[j].tagName == 'FORM')
-                    registerForm(mutations[i].addedNodes[j]);
+        for (var mutation of mutations)
+            for (var node of mutation.addedNodes)
+                if (node.tagName && node.tagName.toLowerCase() == 'form')
+                    registerForm(node);
     });
     observer.observe(document.documentElement, {
         childList: true, subtree: true
@@ -375,8 +380,10 @@
             if (type != 'text' && type != 'password' &&
                 type != 'email')
                 continue;
-            if (input.name == key)
+            if (input.name == key) {{
                 input.value = val;
+                input.dispatchEvent(new Event('change'));
+            }}
         }}
     }}
     

eric ide

mercurial