aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-11-09 00:41:10 +0000
committerewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-11-09 00:41:10 +0000
commit1c96a5471db09748dd8a622a8a65c9df58a45dbb (patch)
tree19c2a3bd8594e0d17a4f5810b634732cffe21821
parentf16d73d27b30618aed474041f5ca44ed4d6cf8aa (diff)
downloadelgg-1c96a5471db09748dd8a622a8a65c9df58a45dbb.tar.gz
elgg-1c96a5471db09748dd8a622a8a65c9df58a45dbb.tar.bz2
jsLinted security.js + using elgg typecheckers rather than ===
git-svn-id: http://code.elgg.org/elgg/trunk@7259 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--js/lib/security.js17
1 files changed, 11 insertions, 6 deletions
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");
};