Changeset 20598


Ignore:
Timestamp:
05/09/16 22:11:02 (9 years ago)
Author:
dlcheng
Message:

CHG (javascript): Fixing timeout length from 3 to 30 seconds. Reformatting code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/classes/clusters/generic.js

    r20597 r20598  
    5050                $(".run-button").html("CONNECTING...").prop("disabled", true);
    5151                request.position = 0; //Keep track of current parsing position in repsonseText
    52                 //TODO: Test timeout conditions (timeout will trigger even if ocnnection is successful, if computation takes too long)
    53                 request.timeout = 3000;
    54                 request.ontimeout = function (event) {
     52                request.timeout = 30000;
     53                request.ontimeout = function (event) { //{{{
    5554                        $(".run-button").html("RUN").prop("disabled", false);
    56                 }
    57                
    58                 request.upload.onprogress = function(event) {
     55                } //}}}
     56                request.upload.onprogress = function(event) { //{{{
    5957                        var progress = (event.loaded / event.total * 100).toFixed(0);
    6058                        $(".run-button").html("UPLOADING: " + progress + "%");
    61         }
    62 
    63                 request.onprogress = function (event) {
     59        } //}}}
     60                request.onprogress = function (event) { //{{{
    6461                        //Receive updates by parsing message length as a 32-bit hex string of form 0x*09ABCDEF))
    6562                        var startIndex = request.position;
     
    7875                                }
    7976                        }
    80                 };
    81                
    82                 request.onload = function (event) {
     77                }; //}}}
     78                request.onload = function (event) { //{{{
    8379                        //get context to this.str2ab to avoid duplciation
     80                        console.log(event);
    8481                        function str2ab(str) {
    8582                                var buf = new Uint8Array(str.length);
     
    8885                                }
    8986                                return buf;
    90                         } //}}}
    91                         //if (request.responseText.slice(request.position, request.position + 1) == "0x") request.position = request.position + 10;
     87                        }
    9288                        var buffer2 = str2ab(window.atob(request.responseText.slice(request.position + 10)));                   
    9389                        var returnBuffer = new Uint8Array(buffer2);
    94                         var returnBuffer_size=returnBuffer.byteLength;
     90                        var returnBuffer_size = returnBuffer.byteLength;
    9591                        try {
    96                                 md.results= parseresultsfrombuffer(returnBuffer,returnBuffer_size);
     92                                md.results = parseresultsfrombuffer(returnBuffer,returnBuffer_size);
    9793                        }
    9894                        catch (e) {
     
    10197                        $(".run-button").html("RUN").prop("disabled", false);
    10298                        callbackfunction();
    103                 };
     99                }; //}}}
    104100               
    105101                var npbuffer = this.str2ab(md.cluster.np.toString());
     
    124120               
    125121                var binbuffer = new Uint8Array(fid.rawbuffer()); //seems that 16 array bytes length could be incompatible.
    126 
    127 
    128122                var binlength = new Uint32Array(1);
    129123                binlength[0] = binbuffer.byteLength;
    130124               
    131125                var data = new Blob([nplength,npbuffer,runtimenamelength,runtimenamebuffer,namelength,namebuffer,toolkitslength,toolkitsbuffer,solutionlength,solutionbuffer,binlength,binbuffer]);
    132                 //if (typeof(download) != "undefined") download(fid.rawbuffer());
    133126       
    134127                request.open("POST", this.url, true);
     
    136129                request.send(data);
    137130               
    138                 return;
    139 
    140131        } //}}}
    141132        this.ab2str = function(buf) { //{{{
    142133                return String.fromCharCode.apply(null, new Uint16Array(buf));
    143         }
    144         this.str2ab = function(str) {
     134        } //}}}
     135        this.str2ab = function(str) { //{{{
    145136                var buf = new Uint8Array(str.length);
    146137                for (var i=0, strLen=str.length; i < strLen; i++) {
Note: See TracChangeset for help on using the changeset viewer.