From d6a78049f3356d9d645143362eca74434410bf62 Mon Sep 17 00:00:00 2001 From: Azul Date: Tue, 21 Aug 2012 18:07:36 +0200 Subject: first round of making jslint happy --- src/jqueryRest.js | 27 ++++++++++++++------------- src/plainXHR.js | 38 +++++++++++++++++++------------------- 2 files changed, 33 insertions(+), 32 deletions(-) diff --git a/src/jqueryRest.js b/src/jqueryRest.js index 8c8163c..9e7f72b 100644 --- a/src/jqueryRest.js +++ b/src/jqueryRest.js @@ -7,7 +7,7 @@ jqueryRest = function() { function paths(path) { - return path + return path; } // Perform ajax requests at the specified path, with the specified parameters @@ -15,12 +15,13 @@ jqueryRest = function() { function ajaxRequest(relative_path, params, callback) { var full_url = this.geturl() + this.paths(relative_path); - if( window.XMLHttpRequest) + if( window.XMLHttpRequest) { xhr = new XMLHttpRequest(); + } else if (window.ActiveXObject){ - try{ + try { xhr = new ActiveXObject("Microsoft.XMLHTTP"); - }catch (e){} + } catch (e){} } else { @@ -42,7 +43,7 @@ jqueryRest = function() { { session.error_message("Ajax failed."); } - }; + } function parseResponse() { if (responseIsXML()) { @@ -50,16 +51,16 @@ jqueryRest = function() { } else if (responseIsJSON()) { return JSON.parse(xhr.responseText); } - }; + } function responseIsXML() { return (xhr.responseType == 'document') || - (xhr.getResponseHeader("Content-Type").indexOf('application/xml') >= 0) + (xhr.getResponseHeader("Content-Type").indexOf('application/xml') >= 0); } function responseIsJSON() { return (xhr.responseType == 'json') || - (xhr.getResponseHeader("Content-Type").indexOf('application/json') >= 0) + (xhr.getResponseHeader("Content-Type").indexOf('application/json') >= 0); } function parseXML(xml) { @@ -68,7 +69,7 @@ jqueryRest = function() { } else { return parseNodes(xml.childNodes); } - }; + } function parseAttributesOfElement(elem) { var response = {}; @@ -79,7 +80,7 @@ jqueryRest = function() { } } return response; - }; + } function parseNodes(nodes) { var response = {}; @@ -88,7 +89,7 @@ jqueryRest = function() { response[node.tagName] = node.textContent || true; } return response; - }; + } // we do not fetch the salt from the server function register(session, callback) @@ -123,5 +124,5 @@ jqueryRest = function() { handshake: handshake, authenticate: authenticate, upgrade: upgrade - } -} + }; +}; diff --git a/src/plainXHR.js b/src/plainXHR.js index d07416b..c03c90a 100644 --- a/src/plainXHR.js +++ b/src/plainXHR.js @@ -13,8 +13,9 @@ SRP.prototype.Remote = function() { // Calling back the specified function. function ajaxRequest(url, params, callback) { - if( window.XMLHttpRequest) + if( window.XMLHttpRequest) { xhr = new XMLHttpRequest(); + } else if (window.ActiveXObject){ try{ xhr = new ActiveXObject("Microsoft.XMLHTTP"); @@ -40,7 +41,7 @@ SRP.prototype.Remote = function() { { session.error_message("Ajax failed."); } - }; + } function parseResponse() { if (responseIsXML()) { @@ -48,16 +49,16 @@ SRP.prototype.Remote = function() { } else if (responseIsJSON()) { return JSON.parse(xhr.responseText); } - }; + } function responseIsXML() { return (xhr.responseType == 'document') || - (xhr.getResponseHeader("Content-Type").indexOf('application/xml') >= 0) + (xhr.getResponseHeader("Content-Type").indexOf('application/xml') >= 0); } function responseIsJSON() { return (xhr.responseType == 'json') || - (xhr.getResponseHeader("Content-Type").indexOf('application/json') >= 0) + (xhr.getResponseHeader("Content-Type").indexOf('application/json') >= 0); } function parseXML(xml) { @@ -66,7 +67,7 @@ SRP.prototype.Remote = function() { } else { return parseNodes(xml.childNodes); } - }; + } function parseAttributesOfElement(elem) { var response = {}; @@ -77,7 +78,7 @@ SRP.prototype.Remote = function() { } } return response; - }; + } function parseNodes(nodes) { var response = {}; @@ -86,35 +87,34 @@ SRP.prototype.Remote = function() { response[node.tagName] = node.textContent || true; } return response; - }; + } // Drupal version fetches the salt from the server. No idea why but this // should still do it. this.register = function(session, callback) { - var that = this; - ajaxRequest("register/salt/", "I="+session.getI(), receive_salt); - - function receive_salt(response) - { + function receive_salt(response) { if(response.salt) { var s = response.salt; var v = session.getV(s); that.sendVerifier(session, callback); } - }; - } + } + + var that = this; + ajaxRequest("register/salt/", "I="+session.getI(), receive_salt); + }; this.sendVerifier = function(session, callback) { ajaxRequest("register/user/", "v="+session.getV().toString(16), callback); - } + }; this.handshake = function(session, callback) { ajaxRequest("handshake/", "I="+session.getI()+"&A="+session.getAstr(), callback); - } + }; this.authenticate = function(session, callback) { ajaxRequest("authenticate/", "M="+session.getM(), callback); - } -} + }; +}; -- cgit v1.2.3