aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Whiteland <dave@mysociety.org>2012-11-22 14:45:45 +0000
committerDave Whiteland <dave@mysociety.org>2012-11-22 14:45:45 +0000
commitf9e57821d505f081cd1a3f5c67255c09f0e5e57f (patch)
treea2f1294125347dd458cb97db85c60024a9af2f90
parent231dfcf8b3dac714b9f209dc1b7caf27986cbc3b (diff)
tweaked by Mark to pass jslint; base64 encode manually
-rw-r--r--web/cobrands/fixmybarangay/message_manager_client.js30
1 files changed, 17 insertions, 13 deletions
diff --git a/web/cobrands/fixmybarangay/message_manager_client.js b/web/cobrands/fixmybarangay/message_manager_client.js
index fd2195124..ba7383933 100644
--- a/web/cobrands/fixmybarangay/message_manager_client.js
+++ b/web/cobrands/fixmybarangay/message_manager_client.js
@@ -140,25 +140,29 @@ var message_manager = (function() {
};
function encodeBase64(input) {
- var
- chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
+ var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
INVALID_CHARACTER_ERR = (function () {
- // fabricate a suitable error object
- try { document.createElement('$'); }
- catch (error) { return error; }}());
- // encoder
+ // fabricate a suitable error object
+ try {
+ document.createElement('$');
+ } catch (error) {
+ return error;
+ }
+ }()),
+ block, charCode, idx, map, output;
+ // encoder (with wee change by mhl Mark to satisfy jslint)
// [https://gist.github.com/999166] by [https://github.com/nignag]
- for (
- var block, charCode, idx = 0, map = chars, output = '';
- input.charAt(idx | 0) || (map = '=', idx % 1);
- output += map.charAt(63 & block >> 8 - idx % 1 * 8)
- ) {
+ for (idx = 0, map = chars, output = '';
+ input.charAt(idx | 0) || ((map = '=') && (idx % 1));
+ output += map.charAt(63 & block >> 8 - idx % 1 * 8)) {
charCode = input.charCodeAt(idx += 3/4);
- if (charCode > 0xFF) throw INVALID_CHARACTER_ERR;
+ if (charCode > 0xFF) {
+ throw INVALID_CHARACTER_ERR;
+ }
block = block << 8 | charCode;
}
return output;
- };
+ }
var get_current_auth_credentials = function() {
var base_auth = "";