(function () { var Social = function () { var elem = { socialInstanceNewAccount: null, socialSubmitNewAccount: null, socialListAccounts: null, socialSubmitAccountTest: null } var test = { newAccount: function () { var data = { instance: elem.socialInstanceNewAccount.val() } test.sendRequest('POST', data, '/user/account', test.newAccountResult) }, newAccountResult: function (data) { if (data.status !== 1) { return } window.open(data.result.authorizationUrl, 'gettoken', 'width=500,height=550') // test.getAccounts() }, getAccounts: function () { test.sendRequest('GET', {}, '/user/accounts', test.getAccountsResult) }, getAccountsResult: function (data) { if (data.status !== 1) { return } elem.socialListAccounts.empty() for (var i = 0; i < data.result.accounts.length; i++) { var item = data.result.accounts[i] elem.socialListAccounts.append( $('