Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Various connection functions to experimental or fixed
- Loading branch information
Showing
7 changed files
with
82 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,33 @@ | ||
function connection_aborted() { | ||
// http://kevin.vanzonneveld.net | ||
// + original by: Brett Zamir (http://brettz9.blogspot.com) | ||
// % note 1: Really should be defined as a closure to avoid re-adding | ||
// % note 1: event listeners (could also remove each time) | ||
// * example 1: connection_aborted(); | ||
// * returns 1: 0 | ||
|
||
var retVal = 0; | ||
if (!this.php_js) { | ||
this.php_js = {}; | ||
} | ||
if (!this.php_js.abortStatus) { | ||
this.php_js.abortStatus = 0; | ||
} | ||
|
||
window.addEventListener('abort', function(e){ | ||
retVal = 1; | ||
}, false); | ||
window.addEventListener('unload', function(e){ | ||
retVal = 1; | ||
}, false); | ||
window.addEventListener('stop', function(e){ | ||
retVal = 1; | ||
}, false); | ||
// These functions should really be set automatically (added with addEventListener once), but for now this function can be used as a trigger to set these checks up | ||
var that = this; | ||
window.onabort = function(e){ | ||
if (!that.php_js.ignoreAbort) { | ||
that.php_js.abortStatus = 1; | ||
} | ||
}; | ||
window.onunload = function(e){ | ||
if (!that.php_js.ignoreAbort) { | ||
that.php_js.abortStatus = 1; | ||
} | ||
}; | ||
window.onstop = function(e){ | ||
if (!that.php_js.ignoreAbort) { | ||
that.php_js.abortStatus = 1; | ||
} | ||
}; | ||
|
||
return retVal; | ||
// return function () {return retVal;} | ||
return this.php_js.abortStatus; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
function connection_status () { | ||
// http://kevin.vanzonneveld.net | ||
// + original by: Brett Zamir (http://brettz9.blogspot.com) | ||
// * example 1: connection_status(); | ||
// * returns 1: 3 | ||
|
||
var ret = 0; // NORMAL | ||
if (this.php_js && this.php_js.abortStatus) { | ||
ret += 1; // ABORTED | ||
} | ||
if (this.php_js && this.php_js.timeoutStatus) { | ||
ret += 2; // TIMEOUT | ||
} | ||
return ret; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
function connection_timeout () { | ||
// http://kevin.vanzonneveld.net | ||
// + original by: Brett Zamir (http://brettz9.blogspot.com) | ||
// * example 1: connection_timeout(); | ||
// * returns 1: 0 | ||
|
||
return this.php_js && this.php_js.timeoutStatus ? 1 : 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters