Changeset 20598
- Timestamp:
- 05/09/16 22:11:02 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/classes/clusters/generic.js
r20597 r20598 50 50 $(".run-button").html("CONNECTING...").prop("disabled", true); 51 51 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) { //{{{ 55 54 $(".run-button").html("RUN").prop("disabled", false); 56 } 57 58 request.upload.onprogress = function(event) { 55 } //}}} 56 request.upload.onprogress = function(event) { //{{{ 59 57 var progress = (event.loaded / event.total * 100).toFixed(0); 60 58 $(".run-button").html("UPLOADING: " + progress + "%"); 61 } 62 63 request.onprogress = function (event) { 59 } //}}} 60 request.onprogress = function (event) { //{{{ 64 61 //Receive updates by parsing message length as a 32-bit hex string of form 0x*09ABCDEF)) 65 62 var startIndex = request.position; … … 78 75 } 79 76 } 80 }; 81 82 request.onload = function (event) { 77 }; //}}} 78 request.onload = function (event) { //{{{ 83 79 //get context to this.str2ab to avoid duplciation 80 console.log(event); 84 81 function str2ab(str) { 85 82 var buf = new Uint8Array(str.length); … … 88 85 } 89 86 return buf; 90 } //}}} 91 //if (request.responseText.slice(request.position, request.position + 1) == "0x") request.position = request.position + 10; 87 } 92 88 var buffer2 = str2ab(window.atob(request.responseText.slice(request.position + 10))); 93 89 var returnBuffer = new Uint8Array(buffer2); 94 var returnBuffer_size =returnBuffer.byteLength;90 var returnBuffer_size = returnBuffer.byteLength; 95 91 try { 96 md.results = parseresultsfrombuffer(returnBuffer,returnBuffer_size);92 md.results = parseresultsfrombuffer(returnBuffer,returnBuffer_size); 97 93 } 98 94 catch (e) { … … 101 97 $(".run-button").html("RUN").prop("disabled", false); 102 98 callbackfunction(); 103 }; 99 }; //}}} 104 100 105 101 var npbuffer = this.str2ab(md.cluster.np.toString()); … … 124 120 125 121 var binbuffer = new Uint8Array(fid.rawbuffer()); //seems that 16 array bytes length could be incompatible. 126 127 128 122 var binlength = new Uint32Array(1); 129 123 binlength[0] = binbuffer.byteLength; 130 124 131 125 var data = new Blob([nplength,npbuffer,runtimenamelength,runtimenamebuffer,namelength,namebuffer,toolkitslength,toolkitsbuffer,solutionlength,solutionbuffer,binlength,binbuffer]); 132 //if (typeof(download) != "undefined") download(fid.rawbuffer());133 126 134 127 request.open("POST", this.url, true); … … 136 129 request.send(data); 137 130 138 return;139 140 131 } //}}} 141 132 this.ab2str = function(buf) { //{{{ 142 133 return String.fromCharCode.apply(null, new Uint16Array(buf)); 143 } 144 this.str2ab = function(str) { 134 } //}}} 135 this.str2ab = function(str) { //{{{ 145 136 var buf = new Uint8Array(str.length); 146 137 for (var i=0, strLen=str.length; i < strLen; i++) {
Note:
See TracChangeset
for help on using the changeset viewer.