Hi,
I search for a method how my function detect an event while js is
carry out a loop.
I think it's not really important for a problem solving, but goodness
knows: I want to automate a web-application (GUI in html) from the
client-side. Therefor I use FireFox with xul.
I have several self defined js-objects. The object 'Main' control the
program flow. To control a dialog I use an object 'XYZDlg'. My object
'Browser' interact with a browser-control.
Now, for example, I want to extract data from a web-side (please see
what I basically write subsequent).
My problem is, that the function 'waitUntilPageI sLoaded' not work. If
I use a while-loop js never discover that the side is loaded. If I use
window.setTimeo ut/setIntervall instead of the loop, the function
'waitUntilPageI sLoaded' will be leaving before the side is loaded an
so the function 'getData' cause an error becaus the field with the
data exist not yet.
main.extractXYZ Data();
var Main = function() {
this.extractXYZ Data = function() {
xyzDlg.setSearc hCriteria(value );
xyzDlg.search() ;
db.saveXYZData( XYZDlg.getData( ););
}
}
var XYZDlg = function() {
this.setSearchC riteria= function(pValue ) {
browser.setValu eByID(IDSearchF ield, pValue);
}
this.search= function() {
browser.clickBu tton(IDSearchBu tton);
}
this.getData= function() {
return browser.getFiel dValueByID(IDRe sultField);
}
}
var Browser= function() {
var PageIsLoaded=fa lse;
waitUntilPageIs Loaded() = function() {
while (PageIsLoaded== false) {
//doEvents();
}
}
listObj.onState Change = function(aProgr ess, aRequest, aFlag, aStatus)
{
save(CARRIAGE_R ETURN + LINEFEED +'Browser.onSta teChange()');
if (aFlag & listObj.wpl.STA TE_START) {
PageIsLoaded=fa lse;
// This fires when the load event is initiated
} else {
if (aFlag & listObj.wpl.STA TE_STOP) {
if ( aFlag & listObj.wpl.STA TE_IS_WINDOW ) {
// This fires when ALL load finish
}
if ( aFlag & listObj.wpl.STA TE_IS_NETWORK ) {
// Fires when ALL load are REALLY
over,
PageIsLoaded=tr ue;
}
}
}
return 0;
}
myBrowserContro l.addProgressLi stener( listObj,
Components.inte rfaces.nsIWebPr ogress.NOTIFY_S TATE_WINDOW );
this.setValueBy ID= function(pID, pValue) {
browser.getElem entById(pID).va lue = pValue;
}
this.clickButto n= function(pID) {
browser.getElem entById(pID).cl ick();
waitUntilPageIs Loaded();
}
this.getFieldVa lueByID= function(pID) {
return browser.getElem entById(pID).va lue;
}
}
I search for a method how my function detect an event while js is
carry out a loop.
I think it's not really important for a problem solving, but goodness
knows: I want to automate a web-application (GUI in html) from the
client-side. Therefor I use FireFox with xul.
I have several self defined js-objects. The object 'Main' control the
program flow. To control a dialog I use an object 'XYZDlg'. My object
'Browser' interact with a browser-control.
Now, for example, I want to extract data from a web-side (please see
what I basically write subsequent).
My problem is, that the function 'waitUntilPageI sLoaded' not work. If
I use a while-loop js never discover that the side is loaded. If I use
window.setTimeo ut/setIntervall instead of the loop, the function
'waitUntilPageI sLoaded' will be leaving before the side is loaded an
so the function 'getData' cause an error becaus the field with the
data exist not yet.
main.extractXYZ Data();
var Main = function() {
this.extractXYZ Data = function() {
xyzDlg.setSearc hCriteria(value );
xyzDlg.search() ;
db.saveXYZData( XYZDlg.getData( ););
}
}
var XYZDlg = function() {
this.setSearchC riteria= function(pValue ) {
browser.setValu eByID(IDSearchF ield, pValue);
}
this.search= function() {
browser.clickBu tton(IDSearchBu tton);
}
this.getData= function() {
return browser.getFiel dValueByID(IDRe sultField);
}
}
var Browser= function() {
var PageIsLoaded=fa lse;
waitUntilPageIs Loaded() = function() {
while (PageIsLoaded== false) {
//doEvents();
}
}
listObj.onState Change = function(aProgr ess, aRequest, aFlag, aStatus)
{
save(CARRIAGE_R ETURN + LINEFEED +'Browser.onSta teChange()');
if (aFlag & listObj.wpl.STA TE_START) {
PageIsLoaded=fa lse;
// This fires when the load event is initiated
} else {
if (aFlag & listObj.wpl.STA TE_STOP) {
if ( aFlag & listObj.wpl.STA TE_IS_WINDOW ) {
// This fires when ALL load finish
}
if ( aFlag & listObj.wpl.STA TE_IS_NETWORK ) {
// Fires when ALL load are REALLY
over,
PageIsLoaded=tr ue;
}
}
}
return 0;
}
myBrowserContro l.addProgressLi stener( listObj,
Components.inte rfaces.nsIWebPr ogress.NOTIFY_S TATE_WINDOW );
this.setValueBy ID= function(pID, pValue) {
browser.getElem entById(pID).va lue = pValue;
}
this.clickButto n= function(pID) {
browser.getElem entById(pID).cl ick();
waitUntilPageIs Loaded();
}
this.getFieldVa lueByID= function(pID) {
return browser.getElem entById(pID).va lue;
}
}
Comment