mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 10:18:00 +01:00
made submitting forms in macros more reliable
This commit is contained in:
@@ -464,8 +464,8 @@ liberator.Events = function () //{{{
|
|||||||
while (mainThread.hasPendingEvents()) // clear queue
|
while (mainThread.hasPendingEvents()) // clear queue
|
||||||
mainThread.processNextEvent(true);
|
mainThread.processNextEvent(true);
|
||||||
|
|
||||||
// if (liberator.buffer.loaded == 1)
|
if (liberator.buffer.loaded == 1)
|
||||||
// return true;
|
return true;
|
||||||
|
|
||||||
var ms = 15000; // maximum time to wait - TODO: add option
|
var ms = 15000; // maximum time to wait - TODO: add option
|
||||||
var then = new Date().getTime();
|
var then = new Date().getTime();
|
||||||
@@ -749,7 +749,7 @@ liberator.Events = function () //{{{
|
|||||||
if (matches[2].length == 1)
|
if (matches[2].length == 1)
|
||||||
{
|
{
|
||||||
if (!ctrl && !alt && !shift && !meta)
|
if (!ctrl && !alt && !shift && !meta)
|
||||||
return; // an invalid key like <a>
|
return false; // an invalid key like <a>
|
||||||
charCode = matches[2].charCodeAt(0);
|
charCode = matches[2].charCodeAt(0);
|
||||||
}
|
}
|
||||||
else if (matches[2].toLowerCase() == "space")
|
else if (matches[2].toLowerCase() == "space")
|
||||||
@@ -762,7 +762,7 @@ liberator.Events = function () //{{{
|
|||||||
}
|
}
|
||||||
else // an invalid key like <A-xxx> was found, stop propagation here (like Vim)
|
else // an invalid key like <A-xxx> was found, stop propagation here (like Vim)
|
||||||
{
|
{
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
i += matches[0].length + 1;
|
i += matches[0].length + 1;
|
||||||
@@ -781,12 +781,11 @@ liberator.Events = function () //{{{
|
|||||||
var evt = doc.createEvent("KeyEvents");
|
var evt = doc.createEvent("KeyEvents");
|
||||||
evt.initKeyEvent("keypress", true, true, view, ctrl, alt, shift, meta, keyCode, charCode);
|
evt.initKeyEvent("keypress", true, true, view, ctrl, alt, shift, meta, keyCode, charCode);
|
||||||
evt.noremap = noremap;
|
evt.noremap = noremap;
|
||||||
if (elem.dispatchEvent(evt)) // return true in onEvent to stop feeding keys
|
elem.dispatchEvent(evt)
|
||||||
{
|
if (!waitForPageLoaded()) // stop feeding keys if page loading failed
|
||||||
liberator.beep();
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
// this function converts the given event to
|
// this function converts the given event to
|
||||||
@@ -1047,10 +1046,13 @@ liberator.Events = function () //{{{
|
|||||||
// the commandline has focus
|
// the commandline has focus
|
||||||
onKeyPress: function (event)
|
onKeyPress: function (event)
|
||||||
{
|
{
|
||||||
|
/*if (event.ignore)
|
||||||
|
return false;*/
|
||||||
var key = liberator.events.toString(event);
|
var key = liberator.events.toString(event);
|
||||||
if (!key)
|
if (!key)
|
||||||
return true;
|
return true;
|
||||||
// dump(key + " in mode: " + liberator.mode + "\n");
|
//liberator.log(key + " in mode: " + liberator.mode);
|
||||||
|
dump(key + " in mode: " + liberator.mode + "\n");
|
||||||
|
|
||||||
if (liberator.modes.isRecording)
|
if (liberator.modes.isRecording)
|
||||||
{
|
{
|
||||||
@@ -1114,18 +1116,27 @@ liberator.Events = function () //{{{
|
|||||||
{
|
{
|
||||||
if (key == "<Return>")
|
if (key == "<Return>")
|
||||||
{
|
{
|
||||||
if (liberator.modes.isReplaying)
|
/*if (liberator.modes.isReplaying != 44)
|
||||||
{
|
{
|
||||||
// TODO: how to really submit the correct form?
|
// TODO: how to really submit the correct form?
|
||||||
liberator.modes.reset();
|
//content.document.forms[0].submit();
|
||||||
content.document.forms[0].submit();
|
var elem = document.commandDispatcher.focusedElement;
|
||||||
waitForPageLoaded();
|
if (elem)
|
||||||
dump("before return\n");
|
{
|
||||||
event.stopPropagation();
|
liberator.log("dipatching <enter>");
|
||||||
event.preventDefault();
|
event.ignore = true;
|
||||||
return true;
|
try{
|
||||||
|
elem.dispatchEvent(event);
|
||||||
|
} catch (e) { alert(e); }
|
||||||
|
event.stopPropagation();
|
||||||
|
event.preventDefault();
|
||||||
|
liberator.log("dipatched");
|
||||||
|
waitForPageLoaded();
|
||||||
|
liberator.log("page loaded");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else*/
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (key == "<Space>" || key == "<Up>" || key == "<Down>")
|
else if (key == "<Space>" || key == "<Up>" || key == "<Down>")
|
||||||
|
|||||||
Reference in New Issue
Block a user