diff options
author | Anthony Liot <anthony.liot@gmail.com> | 2012-12-28 09:36:13 +0100 |
---|---|---|
committer | Anthony Liot <anthony.liot@gmail.com> | 2012-12-28 09:36:13 +0100 |
commit | 68d5248ff7152368c95a861560ecbb5c734ab1d7 (patch) | |
tree | ee051de33cb48c25501f8e217e1b9120cff6e509 /src/library_browser.js | |
parent | af4716bb662651c26fdbe5ca1fb1e6a4e8384301 (diff) |
Add comment,test,authors. Change indentation and comma space
Modify the indentation
Add Author
Add comment
Add test inside runner.py
Diffstat (limited to 'src/library_browser.js')
-rw-r--r-- | src/library_browser.js | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/src/library_browser.js b/src/library_browser.js index c18edf4a..0525dd49 100644 --- a/src/library_browser.js +++ b/src/library_browser.js @@ -394,45 +394,44 @@ mergeInto(LibraryManager.library, { var http = new XMLHttpRequest(); http.open(_request, _url, true); - http.responseType = 'arraybuffer'; + http.responseType = 'arraybuffer'; // LOAD http.onload = function(e) { - if (http.status == 200) { - FS.createDataFile( _file.substr(0, index), _file.substr(index +1), new Uint8Array(http.response), true, true); - if (onload) FUNCTION_TABLE[onload](arg,file); - } else { - if (onerror) FUNCTION_TABLE[onerror](arg,http.status); - } + if (http.status == 200) { + FS.createDataFile( _file.substr(0, index), _file.substr(index + 1), new Uint8Array(http.response), true, true); + if (onload) FUNCTION_TABLE[onload](arg, file); + } else { + if (onerror) FUNCTION_TABLE[onerror](arg, http.status); + } }; // ERROR http.onerror = function(e) { - if (onerror) FUNCTION_TABLE[onerror](arg,http.status); - }; + if (onerror) FUNCTION_TABLE[onerror](arg, http.status); + }; - // PROGRESS - http.onprogress = function(e) { - var percentComplete = (e.position / e.totalSize)*100; - if (onprogress) FUNCTION_TABLE[onprogress](arg,percentComplete); - }; + // PROGRESS + http.onprogress = function(e) { + var percentComplete = (e.position / e.totalSize)*100; + if (onprogress) FUNCTION_TABLE[onprogress](arg, percentComplete); + }; - try { - if (http.channel instanceof Ci.nsIHttpChannel) - http.channel.redirectionLimit = 0; - } catch (ex) { /* whatever */ } + // Useful because the browser can limit the number of redirection + try { + if (http.channel instanceof Ci.nsIHttpChannel) + http.channel.redirectionLimit = 0; + } catch (ex) { /* whatever */ } if (_request == "POST") { - //Send the proper header information along with the request - http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); - http.setRequestHeader("Content-length", _param.length); - http.setRequestHeader("Connection", "close"); - - http.send(_param); + //Send the proper header information along with the request + http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); + http.setRequestHeader("Content-length", _param.length); + http.setRequestHeader("Connection", "close"); + http.send(_param); } else { - http.send(null); + http.send(null); } - }, emscripten_async_prepare: function(file, onload, onerror) { |