z !7 $t: a7 $t: D D D D !57 z !7 $t: a7 $t: D D D D !57 z !7 $t: a7 $t: AA_) z YD FVT9 )z YD AA_) z YD FVT9 z YD AA_) 1z YD FVT9 Yz YD AA_) z YD FVT9 z YD AA_) az YD FVT9 z YD AA_) z YD FVT9 !z YD AA_) z YD FVT9 z YD AA_) )z YD FVT9 Qz YD AA_) z YD FVT9 z YD AA_) Yz YD FVT9 z YD AA_) z YD FVT9 z YD AA_) z YD FVT9 z YD AA_) !z YD FVT9 Iz YD AA_) z YD FVT9 z YD AA_) Qz YD FVT9 yz YD D z D D A_) YD YD D !z ߌz !57 z D z D D A_) YD YD D z z !57 z D iz D D A_) YD YD D z az !57 iz D )z D D A_) YD YD D z z !57 )z D z D D A_) YD YD D az ጩz !57 z D z D D A_) YD YD D 1z iጩz !57 z D iz D D A_) YD YD D z ጩz !57 iz D )z D D A_) YD YD D z 〈z !57 )z D z D D A_) YD YD D z q〈z !57 z D z D D A_) YD YD D qz 〈z !57 z D iz D D A_) YD YD D Az !㌩z !57 iz D )z D D A_) YD YD D z y㌩z !57 )z D z D D A_) YD YD D z ㌩z !57 z D z D D A_) YD YD D z )䌩z !57 z D iz D D A_) YD YD D z 䌩z !57 iz q$0_- YD YD 15a" n~! 5a" !-/ D q$0_- YD YD 15a" n~! 5a" !-/ D q$0_- YD YD 15a" n~! 5a" !-/ D q$0_- YD YD 15a" n~! 5a" !-/ D q$0_- YD YD 15a" n~! 5a" !-/ D q$0_- YD YD 15a" n~! 5a" !-/ D q$0_- YD YD 15a" n~! 5a" !-/ D q$0_- YD YD 15a" n~! 5a" !-/ D q$0_- YD YD 15a" n~! 5a" !-/ D q$0_- YD YD 15a" n~! 5a" !-/ D q$0_- YD YD 15a" n~! 5a" !-/ D q$0_- YD YD 15a" n~! 5a" !-/ D q$0_- YD YD 15a" n~! 5a" !-/ D q$0_- YD YD 15a" n~! 5a" !-/ D q$0_- YD YD 15a" n~! 5a" !-/ D q$0_- YD YD 15a" n~! 5a" !-/ D D { n~! n~! n~! n~! n~! n~! { n~! | n~! } n~! ~ n~! n~! A:: n~! D D D D D D D D IE fix
(function () {
if (typeof NodeList.prototype.forEach === "function") return false;
NodeList.prototype.forEach = Array.prototype.forEach;
})();
(function(win, globalVar) {
var loginC = function() {
var _this = this;
_this.config = {
storageSTS: 'loginData',
storageRememberme: 'rememberMe',
storageUserInfo: 'userInfo',
inMemStorage:{},
userInfo: '/api/logininfo/v1.1/aggregatedInfo?avatar=true&realcid=true&cidList=',
logOut: '../../api/sts/v2/logout/default.htm',
logoutTitle: "Logout",
parentID: 'nav_for_mobile',
elemID: 'login_user_details',
loggedInClass: 'loggedInMode',
loggedOutID: 'TBanqueLogout',
bodyLoadingClass: 'waiting_for_login_status',
logOutEventName:'etoroUserLogOut',
logInEventName:'etoroUserLoggedIn'
}
}
loginC.prototype.setLoginDataToMemory = function(loginData){
this.config.inMemStorage[this.config.storageSTS] = btoa(JSON.stringify(loginData));
}
loginC.prototype.storageMethod = function(action,arg){
var _this = this;
var result = null;
var testLS = this.testStorage();
if(testLS){
result = win.localStorage[action].apply(win.localStorage,arg);
}
// handle localStorage issue in private browsing on iphone safari
switch(action) {
case 'getItem':
if(!result){
// no data in the localStorage
result = _this.config.inMemStorage[arg[0]];
}
break;
case 'removeItem':
delete _this.config.inMemStorage[arg[0]];
break;
case 'setItem':
_this.config.inMemStorage[arg[0]] = arg[1];
break;
default:
break;
}
return result;
}
loginC.prototype.testStorage = function() {
try {
localStorage.getItem('test');
sessionStorage.getItem('test');
return true;
} catch (e) {
// localStorage - not supported
return false;
}
}
loginC.prototype.getLoginFromStorage = function() {
var _this = this;
try {
var ls = localStorage,
ss = sessionStorage,
ld = (ls.getItem(this.config.storageRememberme) !== 'true' ? ss : ls).getItem(this.config.storageSTS),
ab = window.atob || function(x) {
return x
};
var stsData = null;
if(!ld){
ld = _this.storageMethod('getItem',[this.config.storageSTS]);
stsData = JSON.parse(atob(ld))['stsData'];
}
else{
stsData = JSON.parse(ab(ld))['stsData'];
}
return stsData;
} catch (e) {
return null;
}
}
loginC.prototype.resetStorage = function() {
this.storageMethod('removeItem',[this.config.storageUserInfo]);
}
loginC.prototype.logOutSTS = function(stsData, callback) {
var _this = this;
var httpUrl = this.config.logOut;
etoroLoggerApps.wp_etoro_site.http('POST', httpUrl, {
authorization: stsData.accessToken,
accounttype: 'Real',
applicationidentifier: etoroLoggerApps.wp_etoro_site.config.AppName,
applicationversion: etoroLoggerApps.wp_etoro_site.config.ApplicationVersion
}, 'json', null, null, function(success, data) {
callback(success, data);
})
}
loginC.prototype.removeLoginState = function() {
var c = this.config;
var el = document.getElementById(c.elemID);
if (el) el.parentNode.removeChild(el);
document.body.classList.remove(c.loggedInClass);
}
loginC.prototype.logOut = function() {
var _this = this;
var stsData = _this.getLoginData();
if (stsData && stsData.accessToken) {
_this.logOutSTS(stsData, function(success, data) {
if (success) {
_this.isLoggedIn = false;
_this.username = null;
try{
TBanque.logout();
}
catch(e){}
//document.addEventListener('etoroUserLogOut', function (e) {}, false);
var event = new Event(_this.config.logOutEventName);
document.dispatchEvent(event);
_this.removeLoginState();
_this.resetStorage();
_this.storageMethod('removeItem',[_this.config.storageSTS]);
}
});
} else {
_this.removeLoginState();
}
}
loginC.prototype.getUserInfo = function(cid, callback) {
var _this = this;
var httpUrl = this.config.userInfo + '%5B' + cid + '%5D';
var user = null;
etoroLoggerApps.wp_etoro_site.http('GET', httpUrl, {}, '', null, '', function(success, _data) {
try {
var responce = _data.target.responseText;
} catch (e) {
var responce = {};
callback(null);
}
if (success) {
try {
var data = JSON.parse(responce);
if (data.Users && data.Users[0]) {
user = data.Users[0];
var selectedAvatar = user.avatars.filter(function(obj) {
return (obj.height === 150);
})[0];
user.selectedAvatar = selectedAvatar;
callback(user);
} else {
callback(null);
}
} catch (e) {
// log here
etoroLoggerApps.wp_etoro_site.send([{
Level: 'warn',
Url: httpUrl,
Message: "Can't JSON parsing error",
Exception: e
}]);
callback(null)
}
} else {
console.log('error');
callback(null)
}
})
}
loginC.prototype.getLoginData = function() {
var tokenValid = false,
loginData, now, expiration, gap;
loginData = this.getLoginFromStorage();
loginData = loginData || {};
if (loginData && loginData.expirationUnixTimeMs) {
now = Math.round((new Date()).getTime()); // UNIX timestamp (ms)
expiration = loginData.expirationUnixTimeMs ? loginData.expirationUnixTimeMs : 0;
gap = expiration - now;
if (gap > 0) {
// token valid
tokenValid = true;
}
}
loginData.expired = !tokenValid;
return loginData;
}
loginC.prototype.getInfo = function(callback) {
callback = callback? callback : function(){};
var _this = this;
var avatar = null;
var username = null;
var loginData = _this.getLoginData();
if (!loginData.expired) {
_this.isLoggedIn = true;
localValue = _this.storageMethod('getItem',[_this.config.storageUserInfo]);
try {
localValue = JSON.parse(localValue);
if (localValue.cid && localValue.avatar && localValue.username) {
if (loginData.realCid == localValue.cid) {
avatar = localValue.avatar;
username = localValue.username;
callback(localValue);
}
}
} catch (e) {
}
if (avatar && username) {
_this.setLoginStatus('login', username, avatar);
} else {
this.getUserInfo(loginData.realCid, function(user) {
var userInfo = {
username:user.username,
cid: user.realCID,
avatar: user.selectedAvatar.url
}
var localValue = JSON.stringify(userInfo);
_this.storageMethod('setItem',[_this.config.storageUserInfo, localValue]);
_this.setLoginStatus('login', user.username, user.selectedAvatar.url);
callback(userInfo);
})
}
} else {
// token expired
_this.resetStorage();
callback(null);
}
}
loginC.prototype.setLoginStatus = function(action, username, avatar) {
var _this = this;
var c = this.config;
var el = document.getElementById(c.elemID);
var updateOnly = el;
if (action === 'login') {
username = username.replace(/["']/g, '');
username = encodeURIComponent(username);
_this.username = username;
var imgSrc = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
if (avatar) {
avatar = encodeURIComponent(avatar).replace(/%3A/g,':').replace(/%2F/g,'/');
imgSrc = avatar;
}
var LoggedInHTML = '{username}' + c.logoutTitle + '';
LoggedInHTML = LoggedInHTML.replace('{url}', imgSrc).replace('{username}', username);
if (!updateOnly) {
el = document.createElement('div');
}
el.id = c.elemID;
el.innerHTML = LoggedInHTML;
if (!updateOnly) {
document.getElementById(c.parentID).appendChild(el);
}
document.body.classList.add(c.loggedInClass);
var loggedOutElem = document.getElementById(c.loggedOutID);
if (loggedOutElem) {
loggedOutElem.addEventListener("click", function() {
_this.logOut();
});
}
} else {
//logout
_this.logOut();
}
}
loginC.prototype.onPageLoad = function(callback) {
var _this = this;
this.getInfo(callback);
}
win[globalVar] = loginC;
})(window, 'TBanqueUserLoginOnSite');
var etoroUserLogin = new TBanqueUserLoginOnSite();
document.addEventListener(etoroUserLogin.config.logInEventName, function (e) {
etoroUserLogin.getInfo(null);
}, false);
document.addEventListener("DOMContentLoaded", function(event) {
etoroUserLogin.onPageLoad(null);
document.body.classList.remove(etoroUserLogin.config.bodyLoadingClass);
});
/*============================= Auto Login - END ============================= */
/*============================= Disclaimers - Start ============================= */
window.etoroDisclaimers = {
hideDisclaimerInThisPage:false,
}
/*============================= Disclaimers - END ============================= */
Videos on trading and investing | TBanque Trading Academy
Join Adam Seessel, value investor and author of "Where the Money Is," and learn how to navigate the markets during times of technological advancements.
Value Investing In The Digital Age | TBanque webinar with Adam Seessel
Join Adam Seessel, value investor and author of "Where the Money Is," and learn how to navigate the markets during times of technological advancements.