From a7e935af9c7e6254ca45e0286b05b5eb6d8283a6 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Tue, 18 Aug 2015 09:43:22 -0400 Subject: Cosmetic refactoring for ESLint --- web/react/utils/client.jsx | 383 ++++++++++++++++++++++----------------------- 1 file changed, 189 insertions(+), 194 deletions(-) (limited to 'web/react/utils/client.jsx') diff --git a/web/react/utils/client.jsx b/web/react/utils/client.jsx index f4c72ba46..b25702589 100644 --- a/web/react/utils/client.jsx +++ b/web/react/utils/client.jsx @@ -14,73 +14,73 @@ module.exports.trackPage = function() { global.window.analytics.page(); }; -function handleError(method_name, xhr, status, err) { - var _LTracker = global.window._LTracker || []; +function handleError(methodName, xhr, status, err) { + var LTracker = global.window.LTracker || []; var e = null; try { e = JSON.parse(xhr.responseText); - } - catch(parse_error) { + } catch(parseError) { + e = null; } - var msg = ""; + var msg = ''; if (e) { - msg = "error in " + method_name + " msg=" + e.message + " detail=" + e.detailed_error + " rid=" + e.request_id; - } - else { - msg = "error in " + method_name + " status=" + status + " statusCode=" + xhr.status + " err=" + err; + msg = 'error in ' + methodName + ' msg=' + e.message + ' detail=' + e.detailed_error + ' rid=' + e.request_id; + } else { + msg = 'error in ' + methodName + ' status=' + status + ' statusCode=' + xhr.status + ' err=' + err; - if (xhr.status === 0) - e = { message: "There appears to be a problem with your internet connection" }; - else - e = { message: "We received an unexpected status code from the server (" + xhr.status + ")"}; + if (xhr.status === 0) { + e = {message: 'There appears to be a problem with your internet connection'}; + } else { + e = {message: 'We received an unexpected status code from the server (' + xhr.status + ')'}; + } } - console.error(msg) - console.error(e); - _LTracker.push(msg); + console.error(msg); //eslint-disable-line no-console + console.error(e); //eslint-disable-line no-console + LTracker.push(msg); - module.exports.track('api', 'api_weberror', method_name, 'message', msg); + module.exports.track('api', 'api_weberror', methodName, 'message', msg); - if (xhr.status == 401) { - if (window.location.href.indexOf("/channels") === 0) { - window.location.pathname = '/login?redirect=' + encodeURIComponent(window.location.pathname+window.location.search); + if (xhr.status === 401) { + if (window.location.href.indexOf('/channels') === 0) { + window.location.pathname = '/login?redirect=' + encodeURIComponent(window.location.pathname + window.location.search); } else { var teamURL = window.location.href.split('/channels')[0]; - window.location.href = teamURL + '/login?redirect=' + encodeURIComponent(window.location.pathname+window.location.search); + window.location.href = teamURL + '/login?redirect=' + encodeURIComponent(window.location.pathname + window.location.search); } } return e; } -module.exports.createTeamFromSignup = function(team_signup, success, error) { +module.exports.createTeamFromSignup = function(teamSignup, success, error) { $.ajax({ - url: "/api/v1/teams/create_from_signup", + url: '/api/v1/teams/create_from_signup', dataType: 'json', contentType: 'application/json', type: 'POST', - data: JSON.stringify(team_signup), + data: JSON.stringify(teamSignup), success: success, - error: function(xhr, status, err) { - e = handleError("createTeamFromSignup", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('createTeamFromSignup', xhr, status, err); error(e); } }); }; -module.exports.createUser = function(user, data, email_hash, success, error) { +module.exports.createUser = function(user, data, emailHash, success, error) { $.ajax({ - url: "/api/v1/users/create?d=" + encodeURIComponent(data) + "&h=" + encodeURIComponent(email_hash), + url: '/api/v1/users/create?d=' + encodeURIComponent(data) + '&h=' + encodeURIComponent(emailHash), dataType: 'json', contentType: 'application/json', type: 'POST', data: JSON.stringify(user), success: success, - error: function(xhr, status, err) { - e = handleError("createUser", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('createUser', xhr, status, err); error(e); } }); @@ -90,14 +90,14 @@ module.exports.createUser = function(user, data, email_hash, success, error) { module.exports.updateUser = function(user, success, error) { $.ajax({ - url: "/api/v1/users/update", + url: '/api/v1/users/update', dataType: 'json', contentType: 'application/json', type: 'POST', data: JSON.stringify(user), success: success, - error: function(xhr, status, err) { - e = handleError("updateUser", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('updateUser', xhr, status, err); error(e); } }); @@ -107,14 +107,14 @@ module.exports.updateUser = function(user, success, error) { module.exports.updatePassword = function(data, success, error) { $.ajax({ - url: "/api/v1/users/newpassword", + url: '/api/v1/users/newpassword', dataType: 'json', contentType: 'application/json', type: 'POST', data: JSON.stringify(data), success: success, - error: function(xhr, status, err) { - e = handleError("newPassword", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('newPassword', xhr, status, err); error(e); } }); @@ -124,14 +124,14 @@ module.exports.updatePassword = function(data, success, error) { module.exports.updateUserNotifyProps = function(data, success, error) { $.ajax({ - url: "/api/v1/users/update_notify", + url: '/api/v1/users/update_notify', dataType: 'json', contentType: 'application/json', type: 'POST', data: JSON.stringify(data), success: success, - error: function(xhr, status, err) { - e = handleError("updateUserNotifyProps", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('updateUserNotifyProps', xhr, status, err); error(e); } }); @@ -139,14 +139,14 @@ module.exports.updateUserNotifyProps = function(data, success, error) { module.exports.updateRoles = function(data, success, error) { $.ajax({ - url: "/api/v1/users/update_roles", + url: '/api/v1/users/update_roles', dataType: 'json', contentType: 'application/json', type: 'POST', data: JSON.stringify(data), success: success, - error: function(xhr, status, err) { - e = handleError("updateRoles", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('updateRoles', xhr, status, err); error(e); } }); @@ -155,19 +155,19 @@ module.exports.updateRoles = function(data, success, error) { }; module.exports.updateActive = function(userId, active, success, error) { - var data = {}; - data["user_id"] = userId; - data["active"] = "" + active; - + var data = {}; + data.user_id = userId; + data.active = '' + active; + $.ajax({ - url: "/api/v1/users/update_active", + url: '/api/v1/users/update_active', dataType: 'json', contentType: 'application/json', type: 'POST', data: JSON.stringify(data), success: success, - error: function(xhr, status, err) { - e = handleError("updateActive", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('updateActive', xhr, status, err); error(e); } }); @@ -177,14 +177,14 @@ module.exports.updateActive = function(userId, active, success, error) { module.exports.sendPasswordReset = function(data, success, error) { $.ajax({ - url: "/api/v1/users/send_password_reset", + url: '/api/v1/users/send_password_reset', dataType: 'json', contentType: 'application/json', type: 'POST', data: JSON.stringify(data), success: success, - error: function(xhr, status, err) { - e = handleError("sendPasswordReset", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('sendPasswordReset', xhr, status, err); error(e); } }); @@ -194,14 +194,14 @@ module.exports.sendPasswordReset = function(data, success, error) { module.exports.resetPassword = function(data, success, error) { $.ajax({ - url: "/api/v1/users/reset_password", + url: '/api/v1/users/reset_password', dataType: 'json', contentType: 'application/json', type: 'POST', data: JSON.stringify(data), success: success, - error: function(xhr, status, err) { - e = handleError("resetPassword", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('resetPassword', xhr, status, err); error(e); } }); @@ -213,24 +213,24 @@ module.exports.logout = function() { module.exports.track('api', 'api_users_logout'); var currentTeamUrl = TeamStore.getCurrentTeamUrl(); BrowserStore.clear(); - window.location.href = currentTeamUrl + "/logout"; + window.location.href = currentTeamUrl + '/logout'; }; module.exports.loginByEmail = function(name, email, password, success, error) { $.ajax({ - url: "/api/v1/users/login", + url: '/api/v1/users/login', dataType: 'json', contentType: 'application/json', type: 'POST', data: JSON.stringify({name: name, email: email, password: password}), - success: function(data, textStatus, xhr) { + success: function onSuccess(data, textStatus, xhr) { module.exports.track('api', 'api_users_login_success', data.team_id, 'email', data.email); success(data, textStatus, xhr); }, - error: function(xhr, status, err) { + error: function onError(xhr, status, err) { module.exports.track('api', 'api_users_login_fail', window.getSubDomain(), 'email', email); - e = handleError("loginByEmail", xhr, status, err); + var e = handleError('loginByEmail', xhr, status, err); error(e); } }); @@ -238,14 +238,14 @@ module.exports.loginByEmail = function(name, email, password, success, error) { module.exports.revokeSession = function(altId, success, error) { $.ajax({ - url: "/api/v1/users/revoke_session", + url: '/api/v1/users/revoke_session', dataType: 'json', contentType: 'application/json', type: 'POST', data: JSON.stringify({id: altId}), success: success, - error: function(xhr, status, err) { - e = handleError("revokeSession", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('revokeSession', xhr, status, err); error(e); } }); @@ -253,13 +253,13 @@ module.exports.revokeSession = function(altId, success, error) { module.exports.getSessions = function(userId, success, error) { $.ajax({ - url: "/api/v1/users/"+userId+"/sessions", + url: '/api/v1/users/' + userId + '/sessions', dataType: 'json', contentType: 'application/json', type: 'GET', success: success, - error: function(xhr, status, err) { - e = handleError("getSessions", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('getSessions', xhr, status, err); error(e); } }); @@ -267,13 +267,13 @@ module.exports.getSessions = function(userId, success, error) { module.exports.getAudits = function(userId, success, error) { $.ajax({ - url: "/api/v1/users/"+userId+"/audits", + url: '/api/v1/users/' + userId + '/audits', dataType: 'json', contentType: 'application/json', type: 'GET', success: success, - error: function(xhr, status, err) { - e = handleError("getAudits", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('getAudits', xhr, status, err); error(e); } }); @@ -281,10 +281,9 @@ module.exports.getAudits = function(userId, success, error) { module.exports.getMeSynchronous = function(success, error) { var currentUser = null; - $.ajax({ async: false, - url: "/api/v1/users/me", + url: '/api/v1/users/me', dataType: 'json', contentType: 'application/json', type: 'GET', @@ -294,14 +293,14 @@ module.exports.getMeSynchronous = function(success, error) { success(data, textStatus, xhr); } }, - error: function(xhr, status, err) { + error: function onError(xhr, status, err) { var ieChecker = window.navigator.userAgent; // This and the condition below is used to check specifically for browsers IE10 & 11 to suppress a 200 'OK' error from appearing on login - if (xhr.status != 200 || !(ieChecker.indexOf("Trident/7.0") > 0 || ieChecker.indexOf("Trident/6.0") > 0)) { + if (xhr.status !== 200 || !(ieChecker.indexOf('Trident/7.0') > 0 || ieChecker.indexOf('Trident/6.0') > 0)) { if (error) { - e = handleError('getMeSynchronous', xhr, status, err); + var e = handleError('getMeSynchronous', xhr, status, err); error(e); - }; - }; + } + } } }); @@ -310,14 +309,14 @@ module.exports.getMeSynchronous = function(success, error) { module.exports.inviteMembers = function(data, success, error) { $.ajax({ - url: "/api/v1/teams/invite_members", + url: '/api/v1/teams/invite_members', dataType: 'json', contentType: 'application/json', type: 'POST', data: JSON.stringify(data), success: success, - error: function(xhr, status, err) { - e = handleError("inviteMembers", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('inviteMembers', xhr, status, err); error(e); } }); @@ -327,14 +326,14 @@ module.exports.inviteMembers = function(data, success, error) { module.exports.updateTeamDisplayName = function(data, success, error) { $.ajax({ - url: "/api/v1/teams/update_name", + url: '/api/v1/teams/update_name', dataType: 'json', contentType: 'application/json', type: 'POST', data: JSON.stringify(data), success: success, - error: function(xhr, status, err) { - e = handleError("updateTeamDisplayName", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('updateTeamDisplayName', xhr, status, err); error(e); } }); @@ -344,14 +343,14 @@ module.exports.updateTeamDisplayName = function(data, success, error) { module.exports.signupTeam = function(email, success, error) { $.ajax({ - url: "/api/v1/teams/signup", + url: '/api/v1/teams/signup', dataType: 'json', contentType: 'application/json', type: 'POST', data: JSON.stringify({email: email}), success: success, - error: function(xhr, status, err) { - e = handleError("singupTeam", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('singupTeam', xhr, status, err); error(e); } }); @@ -361,14 +360,14 @@ module.exports.signupTeam = function(email, success, error) { module.exports.createTeam = function(team, success, error) { $.ajax({ - url: "/api/v1/teams/create", + url: '/api/v1/teams/create', dataType: 'json', contentType: 'application/json', type: 'POST', data: JSON.stringify(team), success: success, - error: function(xhr, status, err) { - e = handleError("createTeam", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('createTeam', xhr, status, err); error(e); } }); @@ -376,14 +375,14 @@ module.exports.createTeam = function(team, success, error) { module.exports.findTeamByName = function(teamName, success, error) { $.ajax({ - url: "/api/v1/teams/find_team_by_name", + url: '/api/v1/teams/find_team_by_name', dataType: 'json', contentType: 'application/json', type: 'POST', data: JSON.stringify({name: teamName}), success: success, - error: function(xhr, status, err) { - e = handleError("findTeamByName", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('findTeamByName', xhr, status, err); error(e); } }); @@ -391,14 +390,14 @@ module.exports.findTeamByName = function(teamName, success, error) { module.exports.findTeamsSendEmail = function(email, success, error) { $.ajax({ - url: "/api/v1/teams/email_teams", + url: '/api/v1/teams/email_teams', dataType: 'json', contentType: 'application/json', type: 'POST', data: JSON.stringify({email: email}), success: success, - error: function(xhr, status, err) { - e = handleError("findTeamsSendEmail", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('findTeamsSendEmail', xhr, status, err); error(e); } }); @@ -408,14 +407,14 @@ module.exports.findTeamsSendEmail = function(email, success, error) { module.exports.findTeams = function(email, success, error) { $.ajax({ - url: "/api/v1/teams/find_teams", + url: '/api/v1/teams/find_teams', dataType: 'json', contentType: 'application/json', type: 'POST', data: JSON.stringify({email: email}), success: success, - error: function(xhr, status, err) { - e = handleError("findTeams", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('findTeams', xhr, status, err); error(e); } }); @@ -423,14 +422,14 @@ module.exports.findTeams = function(email, success, error) { module.exports.createChannel = function(channel, success, error) { $.ajax({ - url: "/api/v1/channels/create", + url: '/api/v1/channels/create', dataType: 'json', contentType: 'application/json', type: 'POST', data: JSON.stringify(channel), success: success, - error: function(xhr, status, err) { - e = handleError("createChannel", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('createChannel', xhr, status, err); error(e); } }); @@ -457,14 +456,14 @@ module.exports.createDirectChannel = function(channel, userId, success, error) { module.exports.updateChannel = function(channel, success, error) { $.ajax({ - url: "/api/v1/channels/update", + url: '/api/v1/channels/update', dataType: 'json', contentType: 'application/json', type: 'POST', data: JSON.stringify(channel), success: success, - error: function(xhr, status, err) { - e = handleError("updateChannel", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('updateChannel', xhr, status, err); error(e); } }); @@ -474,14 +473,14 @@ module.exports.updateChannel = function(channel, success, error) { module.exports.updateChannelDesc = function(data, success, error) { $.ajax({ - url: "/api/v1/channels/update_desc", + url: '/api/v1/channels/update_desc', dataType: 'json', contentType: 'application/json', type: 'POST', data: JSON.stringify(data), success: success, - error: function(xhr, status, err) { - e = handleError("updateChannelDesc", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('updateChannelDesc', xhr, status, err); error(e); } }); @@ -491,14 +490,14 @@ module.exports.updateChannelDesc = function(data, success, error) { module.exports.updateNotifyLevel = function(data, success, error) { $.ajax({ - url: "/api/v1/channels/update_notify_level", + url: '/api/v1/channels/update_notify_level', dataType: 'json', contentType: 'application/json', type: 'POST', data: JSON.stringify(data), success: success, - error: function(xhr, status, err) { - e = handleError("updateNotifyLevel", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('updateNotifyLevel', xhr, status, err); error(e); } }); @@ -506,13 +505,13 @@ module.exports.updateNotifyLevel = function(data, success, error) { module.exports.joinChannel = function(id, success, error) { $.ajax({ - url: "/api/v1/channels/" + id + "/join", + url: '/api/v1/channels/' + id + '/join', dataType: 'json', contentType: 'application/json', type: 'POST', success: success, - error: function(xhr, status, err) { - e = handleError("joinChannel", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('joinChannel', xhr, status, err); error(e); } }); @@ -522,13 +521,13 @@ module.exports.joinChannel = function(id, success, error) { module.exports.leaveChannel = function(id, success, error) { $.ajax({ - url: "/api/v1/channels/" + id + "/leave", + url: '/api/v1/channels/' + id + '/leave', dataType: 'json', contentType: 'application/json', type: 'POST', success: success, - error: function(xhr, status, err) { - e = handleError("leaveChannel", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('leaveChannel', xhr, status, err); error(e); } }); @@ -538,13 +537,13 @@ module.exports.leaveChannel = function(id, success, error) { module.exports.deleteChannel = function(id, success, error) { $.ajax({ - url: "/api/v1/channels/" + id + "/delete", + url: '/api/v1/channels/' + id + '/delete', dataType: 'json', contentType: 'application/json', type: 'POST', success: success, - error: function(xhr, status, err) { - e = handleError("deleteChannel", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('deleteChannel', xhr, status, err); error(e); } }); @@ -554,13 +553,13 @@ module.exports.deleteChannel = function(id, success, error) { module.exports.updateLastViewedAt = function(channelId, success, error) { $.ajax({ - url: "/api/v1/channels/" + channelId + "/update_last_viewed_at", + url: '/api/v1/channels/' + channelId + '/update_last_viewed_at', dataType: 'json', contentType: 'application/json', type: 'POST', success: success, - error: function(xhr, status, err) { - e = handleError("updateLastViewedAt", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('updateLastViewedAt', xhr, status, err); error(e); } }); @@ -573,7 +572,7 @@ function getChannels(success, error) { type: 'GET', success: success, ifModified: true, - error: function(xhr, status, err) { + error: function onError(xhr, status, err) { var e = handleError('getChannels', xhr, status, err); error(e); } @@ -583,12 +582,12 @@ module.exports.getChannels = getChannels; module.exports.getChannel = function(id, success, error) { $.ajax({ - url: "/api/v1/channels/" + id + "/", + url: '/api/v1/channels/' + id + '/', dataType: 'json', type: 'GET', success: success, - error: function(xhr, status, err) { - e = handleError("getChannel", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('getChannel', xhr, status, err); error(e); } }); @@ -598,13 +597,13 @@ module.exports.getChannel = function(id, success, error) { module.exports.getMoreChannels = function(success, error) { $.ajax({ - url: "/api/v1/channels/more", + url: '/api/v1/channels/more', dataType: 'json', type: 'GET', success: success, ifModified: true, - error: function(xhr, status, err) { - e = handleError("getMoreChannels", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('getMoreChannels', xhr, status, err); error(e); } }); @@ -617,7 +616,7 @@ function getChannelCounts(success, error) { type: 'GET', success: success, ifModified: true, - error: function(xhr, status, err) { + error: function onError(xhr, status, err) { var e = handleError('getChannelCounts', xhr, status, err); error(e); } @@ -627,12 +626,12 @@ module.exports.getChannelCounts = getChannelCounts; module.exports.getChannelExtraInfo = function(id, success, error) { $.ajax({ - url: "/api/v1/channels/" + id + "/extra_info", + url: '/api/v1/channels/' + id + '/extra_info', dataType: 'json', type: 'GET', success: success, - error: function(xhr, status, err) { - e = handleError("getChannelExtraInfo", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('getChannelExtraInfo', xhr, status, err); error(e); } }); @@ -640,14 +639,14 @@ module.exports.getChannelExtraInfo = function(id, success, error) { module.exports.executeCommand = function(channelId, command, suggest, success, error) { $.ajax({ - url: "/api/v1/command", + url: '/api/v1/command', dataType: 'json', contentType: 'application/json', type: 'POST', - data: JSON.stringify({channelId: channelId, command: command, suggest: "" + suggest}), + data: JSON.stringify({channelId: channelId, command: command, suggest: '' + suggest}), success: success, - error: function(xhr, status, err) { - e = handleError("executeCommand", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('executeCommand', xhr, status, err); error(e); } }); @@ -655,18 +654,14 @@ module.exports.executeCommand = function(channelId, command, suggest, success, e module.exports.getPosts = function(channelId, offset, limit, success, error, complete) { $.ajax({ - url: "/api/v1/channels/" + channelId + "/posts/" + offset + "/" + limit, + url: '/api/v1/channels/' + channelId + '/posts/' + offset + '/' + limit, dataType: 'json', type: 'GET', ifModified: true, success: success, - error: function(xhr, status, err) { - try { - e = handleError("getPosts", xhr, status, err); - error(e); - } catch(er) { - console.error(er); - } + error: function onError(xhr, status, err) { + var e = handleError('getPosts', xhr, status, err); + error(e); }, complete: complete }); @@ -674,13 +669,13 @@ module.exports.getPosts = function(channelId, offset, limit, success, error, com module.exports.getPost = function(channelId, postId, success, error) { $.ajax({ - url: "/api/v1/channels/" + channelId + "/post/" + postId, + url: '/api/v1/channels/' + channelId + '/post/' + postId, dataType: 'json', type: 'GET', ifModified: false, success: success, - error: function(xhr, status, err) { - e = handleError("getPost", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('getPost', xhr, status, err); error(e); } }); @@ -688,13 +683,13 @@ module.exports.getPost = function(channelId, postId, success, error) { module.exports.search = function(terms, success, error) { $.ajax({ - url: "/api/v1/posts/search", + url: '/api/v1/posts/search', dataType: 'json', type: 'GET', - data: {"terms": terms}, + data: {terms: terms}, success: success, - error: function(xhr, status, err) { - e = handleError("search", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('search', xhr, status, err); error(e); } }); @@ -704,13 +699,13 @@ module.exports.search = function(terms, success, error) { module.exports.deletePost = function(channelId, id, success, error) { $.ajax({ - url: "/api/v1/channels/" + channelId + "/post/" + id + "/delete", + url: '/api/v1/channels/' + channelId + '/post/' + id + '/delete', dataType: 'json', contentType: 'application/json', type: 'POST', success: success, - error: function(xhr, status, err) { - e = handleError("deletePost", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('deletePost', xhr, status, err); error(e); } }); @@ -720,14 +715,14 @@ module.exports.deletePost = function(channelId, id, success, error) { module.exports.createPost = function(post, channel, success, error) { $.ajax({ - url: "/api/v1/channels/"+ post.channel_id + "/create", + url: '/api/v1/channels/' + post.channel_id + '/create', dataType: 'json', contentType: 'application/json', type: 'POST', data: JSON.stringify(post), success: success, - error: function(xhr, status, err) { - e = handleError("createPost", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('createPost', xhr, status, err); error(e); } }); @@ -740,20 +735,20 @@ module.exports.createPost = function(post, channel, success, error) { // channel_type: channel.type, // length: post.message.length, // files: (post.filenames || []).length, - // mentions: (post.message.match("//g") || []).length + // mentions: (post.message.match('//g') || []).length // }); }; module.exports.updatePost = function(post, success, error) { $.ajax({ - url: "/api/v1/channels/"+ post.channel_id + "/update", + url: '/api/v1/channels/' + post.channel_id + '/update', dataType: 'json', contentType: 'application/json', type: 'POST', data: JSON.stringify(post), success: success, - error: function(xhr, status, err) { - e = handleError("updatePost", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('updatePost', xhr, status, err); error(e); } }); @@ -763,14 +758,14 @@ module.exports.updatePost = function(post, success, error) { module.exports.addChannelMember = function(id, data, success, error) { $.ajax({ - url: "/api/v1/channels/" + id + "/add", + url: '/api/v1/channels/' + id + '/add', dataType: 'json', contentType: 'application/json', type: 'POST', data: JSON.stringify(data), success: success, - error: function(xhr, status, err) { - e = handleError("addChannelMember", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('addChannelMember', xhr, status, err); error(e); } }); @@ -780,14 +775,14 @@ module.exports.addChannelMember = function(id, data, success, error) { module.exports.removeChannelMember = function(id, data, success, error) { $.ajax({ - url: "/api/v1/channels/" + id + "/remove", + url: '/api/v1/channels/' + id + '/remove', dataType: 'json', contentType: 'application/json', type: 'POST', data: JSON.stringify(data), success: success, - error: function(xhr, status, err) { - e = handleError("removeChannelMember", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('removeChannelMember', xhr, status, err); error(e); } }); @@ -797,14 +792,14 @@ module.exports.removeChannelMember = function(id, data, success, error) { module.exports.getProfiles = function(success, error) { $.ajax({ - url: "/api/v1/users/profiles", + url: '/api/v1/users/profiles', dataType: 'json', contentType: 'application/json', type: 'GET', success: success, ifModified: true, - error: function(xhr, status, err) { - e = handleError("getProfiles", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('getProfiles', xhr, status, err); error(e); } }); @@ -812,16 +807,16 @@ module.exports.getProfiles = function(success, error) { module.exports.uploadFile = function(formData, success, error) { var request = $.ajax({ - url: "/api/v1/files/upload", + url: '/api/v1/files/upload', type: 'POST', data: formData, cache: false, contentType: false, processData: false, success: success, - error: function(xhr, status, err) { + error: function onError(xhr, status, err) { if (err !== 'abort') { - e = handleError("uploadFile", xhr, status, err); + var e = handleError('uploadFile', xhr, status, err); error(e); } } @@ -834,13 +829,13 @@ module.exports.uploadFile = function(formData, success, error) { module.exports.getPublicLink = function(data, success, error) { $.ajax({ - url: "/api/v1/files/get_public_link", + url: '/api/v1/files/get_public_link', dataType: 'json', type: 'POST', data: JSON.stringify(data), success: success, - error: function(xhr, status, err) { - e = handleError("getPublicLink", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('getPublicLink', xhr, status, err); error(e); } }); @@ -848,15 +843,15 @@ module.exports.getPublicLink = function(data, success, error) { module.exports.uploadProfileImage = function(imageData, success, error) { $.ajax({ - url: "/api/v1/users/newimage", + url: '/api/v1/users/newimage', type: 'POST', data: imageData, cache: false, contentType: false, processData: false, success: success, - error: function(xhr, status, err) { - e = handleError("uploadProfileImage", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('uploadProfileImage', xhr, status, err); error(e); } }); @@ -864,29 +859,29 @@ module.exports.uploadProfileImage = function(imageData, success, error) { module.exports.importSlack = function(fileData, success, error) { $.ajax({ - url: "/api/v1/teams/import_team", + url: '/api/v1/teams/import_team', type: 'POST', data: fileData, cache: false, contentType: false, processData: false, success: success, - error: function(xhr, status, err) { - e = handleError("importTeam", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('importTeam', xhr, status, err); error(e); } }); -} +}; module.exports.getStatuses = function(success, error) { $.ajax({ - url: "/api/v1/users/status", + url: '/api/v1/users/status', dataType: 'json', contentType: 'application/json', type: 'GET', success: success, - error: function(xhr, status, err) { - e = handleError("getStatuses", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('getStatuses', xhr, status, err); error(e); } }); @@ -894,13 +889,13 @@ module.exports.getStatuses = function(success, error) { module.exports.getMyTeam = function(success, error) { $.ajax({ - url: "/api/v1/teams/me", + url: '/api/v1/teams/me', dataType: 'json', type: 'GET', success: success, ifModified: true, - error: function(xhr, status, err) { - e = handleError("getMyTeam", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('getMyTeam', xhr, status, err); error(e); } }); @@ -908,14 +903,14 @@ module.exports.getMyTeam = function(success, error) { module.exports.updateValetFeature = function(data, success, error) { $.ajax({ - url: "/api/v1/teams/update_valet_feature", + url: '/api/v1/teams/update_valet_feature', dataType: 'json', contentType: 'application/json', type: 'POST', data: JSON.stringify(data), success: success, - error: function(xhr, status, err) { - e = handleError("updateValetFeature", xhr, status, err); + error: function onError(xhr, status, err) { + var e = handleError('updateValetFeature', xhr, status, err); error(e); } }); @@ -930,10 +925,10 @@ function getConfig(success, error) { type: 'GET', ifModified: true, success: success, - error: function(xhr, status, err) { + error: function onError(xhr, status, err) { var e = handleError('getConfig', xhr, status, err); error(e); } }); -}; +} module.exports.getConfig = getConfig; -- cgit v1.2.3-1-g7c22