From 1c96a5471db09748dd8a622a8a65c9df58a45dbb Mon Sep 17 00:00:00 2001 From: ewinslow Date: Tue, 9 Nov 2010 00:41:10 +0000 Subject: jsLinted security.js + using elgg typecheckers rather than === git-svn-id: http://code.elgg.org/elgg/trunk@7259 36083f99-b078-4883-b0ff-0f9b5a30f544 --- js/lib/security.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'js/lib/security.js') diff --git a/js/lib/security.js b/js/lib/security.js index bdd762560..ab5c829be 100644 --- a/js/lib/security.js +++ b/js/lib/security.js @@ -41,10 +41,10 @@ elgg.security.refreshToken = function() { */ elgg.security.addToken = function(data) { - //addToken('data=sofar') - if (typeof data == 'string') { + // 'http://example.com?data=sofar' + if (elgg.isString(data)) { var args = []; - if(data) { + if (data) { args.push(data); } args.push("__elgg_ts=" + elgg.security.token.__elgg_ts); @@ -53,12 +53,17 @@ elgg.security.addToken = function(data) { return args.join('&'); } - //addToken({...}) - if (typeof data == 'object' || typeof data == 'undefined') { + // no input! acts like a getter + if (elgg.isUndefined(data)) { + return elgg.security.token; + } + + // {...} + if (elgg.isPlainObject(data)) { return $.extend(data, elgg.security.token); } - //addToken(???) + // oops, don't recognize that! throw new TypeError("elgg.security.addToken not implemented for " + (typeof data) + "s"); }; -- cgit v1.2.3