123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- /********************************************************************************************************************************
- * Licensed Materials - Property of IBM *
- * *
- * IBM Cognos Products: AGS *
- * *
- * (C) Copyright IBM Corp. 2005, 2008 *
- * *
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. *
- *********************************************************************************************************************************/
- //attempt to stop people doing two things at once
- //which causes all kinds of bother
- function ApplicationActionManager(){
- //write to the status bar
- this.debug_flag = false;
-
- //track the http_requests
- this.http_count = 0;
-
- this.is_blocked = false;
- //the auto unblocker could get tangled on new requests
- ///give it a unique id (system time)
- this.unblock_id = 0;
- }
- //called by anything doing asynch http requests
- ApplicationActionManager.prototype.httpStart = function(){
- this.http_count++;
-
- if(this.http_count >= 2){
- this.blockActions();
- }if(this.http_count < 0){
- //auto correction, if the calling code gets mangled
- //this.http_count = 1;
- }
- this.debug();
- }
- //called by anything doing asynch http requests
- ApplicationActionManager.prototype.httpStop = function(ex){
- this.http_count--;
-
- if(this.http_count < 2){
- this.allowActions();
- }
-
- this.debug(ex);
- }
- ApplicationActionManager.prototype.isBlocked = function(){
-
- return this.is_blocked;
- }
- ApplicationActionManager.prototype.unBlock = function(id){
-
- if(id == this.unblock_id && id != 0){
- this.unblock_id = 0;
-
- this.is_blocked = false;
-
- //if(this.debug_flag){
- //alert(new Date().getTime() - new Date(id).getTime());
- //}
- }else{
- //if(this.debug_flag){
- // alert("failed unblocker thread");
- //}
- }
-
- this.debug();
- }
- ApplicationActionManager.prototype.debug = function(ex){
-
- if(this.debug_flag){
- window.defaultStatus = "http requests: " + this.http_count + ", " + (this.is_blocked ? "blocked" : "unblocked") + (ex ? " error: " + ex : "");
- }
- }
- ApplicationActionManager.prototype.blockActions = function(){
- this.is_blocked = true;
-
- this.debug();
-
- this.unblock_id = (new Date()).getTime();
-
- //as a get out.... un block in 8 seconds.. why not
- setTimeout("applicationActionManager.unBlock("+this.unblock_id+")", 12000);
-
- return this.unblock_id;
- }
- ApplicationActionManager.prototype.allowActions = function(){
- this.is_blocked = false;
-
- this.debug();
- }
- function setCursorStyle(style){
- getConfigFrame().document.body.style.cursor = style;
- getMessageIFrame().document.body.style.cursor = style;
- }
- function setStatus(message){
- window.defaultStatus = message;
- }
- //this function is passed to the dispatcher so that we keep the http count steady
- function cDispatchErrorHandler(location_name, ex){
- applicationActionManager.httpStop(ex);
- }
- var applicationActionManager = new ApplicationActionManager();
|