window.addEventListener( 'message', function( event ) { if ( event.origin.indexOf( 'webdisclosure' ) > 0 ) { var h = +event.data || 0; console.log( 'SymexPostMessage: ' + h ); if ( h > 0 ) { jQuery( '.symex-iframe' ).css( 'height', h ); } } } ); var globalLang = []; globalLang[ 0 ] = 'Mis à jour il y a moins d\'une minute'; globalLang[ 1 ] = 'Mis à jour il y a 1 minute'; globalLang[ 2 ] = 'Mis à jour il y a _MINS_ minutes'; // Pagination globalLang[ 3 ] = []; globalLang[ 3 ][ 'btnGo' ] = 'AFFICHER'; globalLang[ 3 ][ 'labGo' ] = 'Aller à la page'; globalLang[ 3 ][ 'next' ] = 'Suivant'; globalLang[ 3 ][ 'phGo' ] = 'Ex : 20'; globalLang[ 3 ][ 'prev' ] = 'Précédent'; // `WgStockData` tabs globalLang[ 4 ] = []; globalLang[ 4 ][ 'tab_1' ] = 'Évolution Des Cours'; globalLang[ 4 ][ 'tab_2' ] = 'Graphique comparé'; globalLang[ 4 ][ 'tab_3' ] = 'Analyse technique'; var globalLib = { toNumber: function( price ) { price = ( price || 0 ).toString().replace( ',', '.' ); price = price.toString().replace( eval( '/\\s+/g' ), '' ); price = parseFloat( price ) || 0; if ( price < 0 ) { price *= -1; } return price; }, cmpFunc: function( v1, v2 ) { v1 = ( v1 || 0 ).toString().replace( ',', '.' ); v2 = ( v2 || 0 ).toString().replace( ',', '.' ); var v1Num = parseFloat( v1.replace( /\s+/g, '' ) ); var v2Num = parseFloat( v2.replace( /\s+/g, '' ) ); if ( ! isNaN( v1Num ) && ! isNaN( v2Num ) ) { return v1Num < v2Num ? -1 : 1; } // Alt.: v1.localeCompare( v2 ); return v1 < v2 ? -1 : 1; }, googleAnalytics: function( url ) { // ! Temporary stoped if ( 0 && typeof ga !== 'undefined' ) { ga( 'send', 'pageview', { 'page': url } ); } }, runChart: function( chartSel, options, reload ) { var chartObj = jQuery( chartSel ); if ( chartObj.length !== 1 ) { return false; } if ( ! options ) { options = {}; } var customer = options.customer || 'lerevenu-v2'; var height = options.height || 200; var lang = options.lang || 'fr'; var period = options.period || 'months'; var ticker = options.ticker || ''; var qty = options.qty || 1; var volume = options.volume || 0; var width = chartObj.width(); if ( ! reload && chartObj.data( 'width' ) == width ) { return true; } chartObj.html( ' ' ); var url = '//charts.symex.be/historical/chart.php'; if ( period === 'intra' || period === 'week' ) { url = '//charts.symex.be/intraday/chart.php'; } url += '?customer=' + customer; url += '&period=' + period; url += '&qty=' + qty; url += '&lang=' + lang; url += '&height=' + height; url += '&width=' + width; url += '&ticker=' + ticker; url += '&vol=' + volume; var chart = ''; chart += ''; chartObj.data( 'width', width ); chartObj.html( chart ); }, runChartAT: function( chartSel, options, reload ) { var chartObj = jQuery( chartSel ); if ( chartObj.length !== 1 ) { return false; } if ( ! options ) { options = {}; } var customer = options.customer || 'lerevenu'; var period_chart_ = options.period_chart_ || '6m'; var height = options.height || 500; var lang = options.lang || 'fr'; var period = options.period || 'years'; var ticker = options.ticker || ''; var qty = options.qty || 1; var width = chartObj.width(); if ( ! reload && chartObj.data( 'width' ) == width ) { return true; } chartObj.html( ' ' ); var url = '//anatech.finork.com/historical/chart.php'; url += '?customer=' + customer; url += '&period=' + period; url += '&period_chart_=' + period_chart_; url += '&qty=' + qty; url += '&lang=' + lang; url += '&height=' + height; url += '&width=' + width; url += '&ticker=' + ticker; var chart = ''; chart += ''; chartObj.data( 'width', width ); chartObj.html( chart ); }, genPgData: function( pgObj ) { if ( pgObj && pgObj.cntPages && pgObj.page ) { // Extend the pagination object pgObj.lang = globalLang[ 3 ]; pgObj.pgs = []; pgObj.showFirst = pgObj.page >= 5 && pgObj.cntPages > 5; pgObj.showLast = pgObj.page <= pgObj.cntPages - 4 && pgObj.cntPages > 5; pgObj.showNext = pgObj.page < pgObj.cntPages; pgObj.showPrev = pgObj.page > 1; if ( pgObj.showFirst && pgObj.showLast ) { pgObj.pgs.push( pgObj.page - 1 ); pgObj.pgs.push( pgObj.page ); pgObj.pgs.push( pgObj.page + 1 ); } else if ( ! pgObj.showFirst ) { // Show first 5 pages var iLimit = 5; if ( pgObj.cntPages < 5 ) { iLimit = pgObj.cntPages; } for ( var i = 1; i <= iLimit; i ++ ) { pgObj.pgs.push( i ); } } else if ( ! pgObj.showLast ) { // Show last 5 pages for ( var i = pgObj.cntPages - 4; i <= pgObj.cntPages; i ++ ) { pgObj.pgs.push( i ); } } } return pgObj }, prismaAds: function( objId, typeId ) { var obj = jQuery( '#' + objId ); if ( ! obj.length ) { return null; } var adsObj = obj.find( 'div' ); if ( ! adsObj.length ) { return null; } var types = []; types[ 0 ] = '{"type": "Pave-Haut", "device": "desktop"}'; types[ 1 ] = '{"type": "Banniere-Basse"}'; types[ 2 ] = '{"type": "Banniere-Haute"}'; var adsData = types[ typeId || 0 ]; adsObj.addClass( 'ads-core-placer' ); adsObj.attr( 'data-ads-core', adsData ); pmsCoreAds.push( function() { coreAds.onDemand( objId ); } ); console.log( 'Prisma Ads: ' + objId ); }, setTimer: function() { if ( ! globalLib.initTime ) { globalLib.initTime = ( new Date() ).getTime(); } var now = ( new Date() ).getTime(); var diffMins = parseInt( ( now - globalLib.initTime ) / 60000 ); var txt = globalLang[ 0 ]; if ( diffMins === 1 ) { txt = globalLang[ 1 ]; } else if ( diffMins > 1 ) { txt = globalLang[ 2 ]; txt = txt.replace( '_MINS_', diffMins ); } return txt; } }; var globalApp = angular.module( 'globalApp', [] ); globalApp.config( function( $locationProvider ) { $locationProvider.html5Mode( false ); }); // ----------------------------------------- // ----- Components version 2 ( role: page ) // ----------------------------------------- globalApp.component( 'pfPortfoliosCreation', { templateUrl: '/components/pf.v2/portfolios-creation.html', controller: [ '$http', '$location', function( $http, $location ) { var this_ = this; this_.canCreate = false; this_.isLoading = false; this_.isSending = null; this_.lang = null; this_.urls = []; this_.userData = null; this_.pfData = { name: '', value: '' }; var loadData = function() { this_.isLoading = true; $http .post( '/rest/pf.v2/portfolios-creation.php' ) .then( function( response ) { this_.isLoading = false; this_.lang = response.data.lang; this_.urls = response.data.urls; if ( response.data.isAuth ) { this_.canCreate = response.data.canCreate; this_.userData = response.data.userData; } } ); }; this_.createPf = function() { var flagStop = this_.isSending || ! this_.pfData.name; if ( flagStop ) { return; } this_.isSending = true; $http .post( '/rest/pf.v2/_pf-create.php', this_.pfData ) .then( function( response ) { var url = this_.urls[ 0 ]; if ( response.data.status && response.data.id ) { url = this_.urls[ 1 ] + '#!?id=' + response.data.id; } document.location.href = url; } ); }; // Go... this_.$onInit = function() { loadData(); globalLib.googleAnalytics( $location.url() ); }; }] }); globalApp.component( 'pfPortfoliosList', { templateUrl: '/components/pf.v2/portfolios-list.html', controller: [ '$http', '$location', function( $http, $location ) { var this_ = this; this_.isLoading = false; this_.lang = null; this_.listPf = []; this_.listWl = []; this_.urls = []; this_.userData = null; var loadData = function() { this_.isLoading = true; $http .post( '/rest/pf.v2/portfolios-list.php' ) .then( function( response ) { this_.isLoading = false; this_.lang = response.data.lang; this_.urls = response.data.urls; if ( response.data.isAuth ) { this_.listPf = response.data.listPf; this_.listWl = response.data.listWl; this_.userData = response.data.userData; } } ); }; this_.$onInit = function() { loadData(); globalLib.googleAnalytics( $location.url() ); }; } ] } ); globalApp.component( 'pfPortfoliosState', { templateUrl: '/components/pf.v2/portfolios-state.html', controller: [ '$http', '$location', '$scope', function( $http, $location, $scope ) { var this_ = this; this_.orderBy = 'name'; this_.cmpFunc = function( v1, v2 ) { return globalLib.cmpFunc( v1.value, v2.value ); }; this_.setOrder = function( val ) { if ( this_.orderBy === val ) { this_.orderBy = '-' + val; } else if ( this_.orderBy === ( '-' + val ) ) { this_.orderBy = val; } else { this_.orderBy = val; } }; var loadData = function() { this_.isLoading = true; $http .post( '/rest/pf.v2/portfolios-state.php', { id: $location.search().id || 0 } ) .then( function( response ) { this_.isLoading = false; this_.lang = response.data.lang; this_.urls = response.data.urls; if ( response.data.isAuth ) { this_.listPf = response.data.listPf; this_.pfActions = response.data.pfActions; this_.pfData = response.data.pfData; this_.portfolioId = response.data.portfolioId; this_.userData = response.data.userData; // Set data for the form this_.editPfData.id = this_.pfData.id; this_.editPfData.action = null; this_.editPfData.name = this_.pfData.name; this_.editPfData.value = '0.00'; // Reset transactions list this_.activePanel = 'pos'; this_.langTrans = null; this_.listTrans = null; this_.pgTrans = null; } } ); }; this_.isLoading = null; this_.isSending = null; this_.editPfData = { id: null, action: null, value: null, name: null }; this_.transPfData = {}; this_.transPfData.action = ''; this_.transPfData.id = 0; this_.transPfData.name = ''; this_.transPfData.pays = ''; this_.transPfData.price = 0; this_.transPfData.qty = 1; this_.transPfData.ticker = ''; this_.updatePf = function() { $http .post( '/rest/pf.v2/_pf-update.php', this_.editPfData ) .then( function() { $( '#pf-edit-form-modal' ).modal( 'hide' ); loadData(); } ); }; // Delete portfolios this_.deleteFlag = false; this_.deletePf = function() { if ( this_.deleteFlag === false ) { this_.deleteFlag = true; return; } if ( this_.isSending === true ) { return; } this_.isSending = true; $http .post( '/rest/pf.v2/_pf-delete.php', { id: this_.pfData.id } ) .then( function( response ) { document.location.href = this_.urls[ 2 ]; } ); }; // Manage transactions this_.showTransForm = function( data, action ) { this_.transPfData.action = action; this_.transPfData.id = this_.pfData.id; this_.transPfData.name = data.name; this_.transPfData.pays = data.pays; this_.transPfData.price = globalLib.toNumber( data.curPrice ); this_.transPfData.qty = action === 'Buy' ? 1 : data.cntShares; this_.transPfData.ticker = data.ticker; // ! Timeout not needed jQuery( '#pf-form-modal' ).modal( 'show' ); }; this_.closeTransForm = function() { jQuery( '#pf-form-modal' ).modal( 'hide' ); // Refresh the data loadData(); }; this_.setPortfolio = function() { var p = $location.search(); p.id = this_.portfolioId; $location.search( p ); }; // Management of transactions this_.activePanel = 'pos'; // [ `pos`, `trans` ] this_.langTrans = null; this_.listTrans = null; this_.pgTrans = null; this_.loadTrans = function( id, page ) { $http .post( '/rest/pf.v2/portfolios-transactions.php', { id: id, page: page } ) // .then( function( response ) { if ( response.data.isAuth ) { this_.langTrans = response.data.langTrans; this_.listTrans = response.data.listTrans; this_.pgTrans = response.data.pgTrans; } } ); }; this_.showTransList = function( panel, event ) { this_.activePanel = panel; if ( panel === 'trans' ) { if ( ! this_.listTrans ) { this_.loadTrans( this_.pfData.id, 1 ); } } }; this_.setTransPage = function( page ) { this_.langTrans = null; this_.listTrans = null; this_.pgTrans = null; this_.loadTrans( this_.pfData.id, page ); }; this_.printPf = function() { var area = jQuery( '#pf-print-area' ).clone(); var body = jQuery( 'body' ); if ( area.length === 1 ) { area.addClass( 'symex-print-area' ); body.addClass( 'symex-printer' ).append( area ); window.print(); area.remove(); body.removeClass( 'symex-printer' ); } }; // Events listeners / callbacks $scope.$on( '$locationChangeSuccess', function() { loadData(); globalLib.googleAnalytics( $location.url() ); } ); } ] } ); globalApp.component( 'spAwardsMarkets', { templateUrl: '/components/sp.v2/awards-markets.html', controller: [ '$http', '$location', '$scope', '$timeout', function( $http, $location, $scope, $timeout ) { var this_ = this; this_.criterias = []; this_.indexes = []; this_.isLoading = false; this_.lang = null; this_.markets = []; this_.orderBy = ''; this_.periods = []; this_.pg = null; this_.sectors = []; this_.stocks = []; this_.urls = []; this_.data = {}; this_.data.criteria = null; this_.data.index = null; this_.data.market = null; this_.data.period = null; this_.data.sector = null; var loadData = function() { jQuery( window ).scrollTop( 0 ); this_.isLoading = true; $http .post( '/rest/sp.v2/awards-markets.php', $location.search() ) .then( function( response ) { this_.criterias = response.data.criterias; this_.indexes = response.data.indexes; this_.isLoading = false; this_.lang = response.data.lang; this_.markets = response.data.markets; this_.orderBy = response.data.orderBy; this_.periods = response.data.periods; this_.pg = globalLib.genPgData( response.data.pg ); this_.sectors = response.data.sectors; this_.stocks = response.data.stocks; this_.urls = response.data.urls; // Set filters // ! 0 to null hack for `select` tags this_.data.criteria = response.data.criteria_ || null; this_.data.index = response.data.index_; this_.data.market = response.data.market_; this_.data.period = response.data.period_; this_.data.sector = response.data.sector_ || null; $timeout( function() { globalLib.prismaAds( 'lr-ads-awards-markets' ); } ); } ); }; this_.cmpFunc = function( v1, v2 ) { return globalLib.cmpFunc( v1.value, v2.value ); }; this_.setOrder = function( val ) { var valNext = ''; if ( this_.orderBy === val ) { valNext = '-' + val; } else if ( this_.orderBy === ( '-' + val ) ) { valNext = val; } else { valNext = val; } var p = $location.search(); p.criteria = null; p.order = valNext; p.page = null; $location.search( p ); }; this_.setCriteria = function() { var p = $location.search(); p.criteria = this_.data.criteria; p.order = null; p.page = null; $location.search( p ); }; this_.setIndex = function() { var p = $location.search(); p.index = this_.data.index; p.market = null; p.page = null; $location.search( p ); }; this_.setMarket = function() { var p = $location.search(); p.market = this_.data.market; p.index = null; p.page = null; $location.search( p ); }; this_.setPage = function( page ) { var p = $location.search(); p.page = page; $location.search( p ); }; this_.setPeriod = function() { var p = $location.search(); p.period = this_.data.period; p.page = null; $location.search( p ); }; this_.setSector = function() { var p = $location.search(); p.sector = this_.data.sector; p.page = null; $location.search( p ); }; $scope.$on( '$locationChangeSuccess', function() { loadData(); globalLib.googleAnalytics( $location.url() ); } ); } ] } ); globalApp.component( 'spCommodities', { templateUrl: '/components/sp.v2/commodities.html', controller: [ '$http', '$location', function( $http, $location ) { var this_ = this; this_.isLoading = false; this_.lang = null; this_.onFocus = null; this_.stocks = null; this_.urls = []; this_.orderBy = { agricultures: 'name', energy: 'name', metals: 'name' }; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp.v2/commodities.php', $location.search() ) .then( function( response ) { this_.isLoading = false; this_.lang = response.data.lang; this_.onFocus = response.data.onFocus; this_.stocks = response.data.stocks; this_.urls = response.data.urls; } ); }; this_.cmpFunc = function( v1, v2 ) { return globalLib.cmpFunc( v1.value, v2.value ); }; this_.setOrder = function( key, val ) { if ( this_.orderBy[ key ] === val ) { this_.orderBy[ key ] = '-' + val; } else if ( this_.orderBy[ key ] === ( '-' + val ) ) { this_.orderBy[ key ] = val; } else { this_.orderBy[ key ] = val; } }; this_.$onInit = function() { loadData(); globalLib.googleAnalytics( $location.url() ); }; } ] } ); globalApp.component( 'spCommodityData', { templateUrl: '/components/sp.v2/commodity-data.html', bindings: { ticker: '@' }, controller: [ '$http', '$location', function( $http, $location ) { var this_ = this; this_.isLoading = false; this_.lang = null; this_.orderByVars = 'periodSort'; this_.stock = null; this_.urls = []; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp.v2/commodity-data.php', { ticker: this_.ticker }) .then( function( response ) { this_.isLoading = false; this_.lang = response.data.lang; this_.stock = response.data.stock; this_.urls = response.data.urls; } ); }; this_.cmpFunc = function( v1, v2 ) { return globalLib.cmpFunc( v1.value, v2.value ); }; this_.setOrder = function( field, val ) { if ( this_[ field ] === val ) { this_[ field ] = '-' + val; } else if ( this_[ field ] === ( '-' + val ) ) { this_[ field ] = val; } else { this_[ field ] = val; } }; this_.$onInit = function() { loadData(); globalLib.googleAnalytics( $location.url() ); }; } ] } ); globalApp.component( 'spCurrencies', { templateUrl: '/components/sp.v2/currencies.html', controller: [ '$http', '$interval', '$location', '$timeout', function( $http, $interval, $location, $timeout ) { var this_ = this; this_.calcCurrs = null; this_.isLoading = false; this_.isSending = false; this_.lang = null; this_.listCurrs = []; this_.listCoefs = null; this_.mainCurrs = []; this_.onFocus = null; this_.urls = []; this_.calcData = {}; this_.calcData.currA = 'EUR'; this_.calcData.currB = 'GBP'; this_.calcData.value = 1; this_.calcData.date = ''; this_.calcRes = {}; this_.calcRes.coef = 0; this_.calcRes.total = 0; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp.v2/currencies.php' ) .then( function( response ) { this_.calcCurrs = response.data.calcCurrs; this_.isLoading = false; this_.lang = response.data.lang; this_.listCurrs = response.data.listCurrs; this_.listCoefs = response.data.listCoefs; this_.mainCurrs = response.data.mainCurrs; this_.onFocus = response.data.onFocus; this_.urls = response.data.urls; $timeout( function() { globalLib.prismaAds( 'lr-ads-currencies' ); } ); } ); }; this_.calcCoef = function() { if ( this_.isSending ) { return; } this_.isSending = true; $http .post( '/rest/sp.v2/_calc-currencies.php', this_.calcData ) .then( function( response ) { this_.isSending = false; this_.calcRes.coef = response.data.coef; this_.calcRes.total = response.data.total; } ); }; this_.$onInit = function() { loadData(); globalLib.googleAnalytics( $location.url() ); }; } ] } ); globalApp.component( 'spCurrencyData', { templateUrl: '/components/sp.v2/currency-data.html', bindings: { ticker: '@' }, controller: [ '$http', '$location', function( $http, $location ) { var this_ = this; this_.isLoading = false; this_.lang = null; this_.orderByVars = 'periodSort'; this_.stock = null; this_.urls = []; this_.cmpFunc = function( v1, v2 ) { return globalLib.cmpFunc( v1.value, v2.value ); }; this_.setOrder = function( field, val ) { if ( this_[ field ] === val ) { this_[ field ] = '-' + val; } else if ( this_[ field ] === ( '-' + val ) ) { this_[ field ] = val; } else { this_[ field ] = val; } }; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp.v2/currency-data.php', { ticker: this_.ticker }) .then( function( response ) { this_.isLoading = false; this_.lang = response.data.lang; this_.stock = response.data.stock; this_.urls = response.data.urls; } ); }; this_.$onInit = function() { loadData(); globalLib.googleAnalytics( $location.url() ); }; } ] } ); globalApp.component( 'spCrypto', { templateUrl: '/components/sp.v2/crypto.html', controller: [ '$http', '$location', '$scope', function( $http, $location, $scope ) { var this_ = this; this_.isLoading = false; this_.lang = null; this_.letters = null; this_.onFocus = null; this_.orderBy = ''; this_.pg = null; this_.stocks = []; this_.urls = []; this_.data = {}; this_.data.letter = null; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp.v2/crypto.php', $location.search() ) .then( function( response ) { this_.isLoading = false; this_.lang = response.data.lang; this_.letters = response.data.letters; this_.onFocus = response.data.onFocus; this_.orderBy = response.data.orderBy; this_.pg = globalLib.genPgData( response.data.pg ); this_.stocks = response.data.stocks; this_.urls = response.data.urls; // Set filters // ! 0 to null hack for `select` tags this_.data.letter = response.data.letter_; } ); }; this_.setOrder = function( val ) { var valNext = ''; if ( val && this_.orderBy === val ) { valNext = '-' + val; } else if ( val && this_.orderBy === ( '-' + val ) ) { valNext = val; } else { valNext = val; } var p = $location.search(); p.order = valNext; p.page = 1; $location.search( p ); }; this_.setLetter = function( letter ) { this_.data.letter = letter; var p = $location.search(); p.letter = letter; p.page = null; $location.search( p ); }; this_.setPage = function( page ) { var p = $location.search(); p.page = page; $location.search( p ); jQuery( window ).scrollTop( 0 ); }; $scope.$on( '$locationChangeSuccess', function() { loadData(); globalLib.googleAnalytics( $location.url() ); } ); } ] } ); globalApp.component( 'spCryptoData', { templateUrl: '/components/sp.v2/crypto-data.html', bindings: { ticker: '@' }, controller: [ '$http', '$location', function( $http, $location ) { var this_ = this; this_.isLoading = false; this_.lang = null; this_.orderByVars = 'periodSort'; this_.stock = null; this_.urls = []; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp.v2/crypto-data.php', { ticker: this_.ticker } ) .then( function( response ) { this_.isLoading = false; this_.lang = response.data.lang; this_.stock = response.data.stock; this_.urls = response.data.urls; } ); }; this_.cmpFunc = function( v1, v2 ) { return globalLib.cmpFunc( v1.value, v2.value ); }; this_.setOrder = function( field, val ) { if ( this_[ field ] === val ) { this_[ field ] = '-' + val; } else if ( this_[ field ] === ( '-' + val ) ) { this_[ field ] = val; } else { this_[ field ] = val; } }; this_.$onInit = function() { loadData(); globalLib.googleAnalytics( $location.url() ); }; } ] } ); globalApp.component( 'spFundData', { templateUrl: '/components/sp.v2/fund-data.html', bindings: { ticker: '@' }, controller: [ '$http', '$location', '$timeout', function( $http, $location, $timeout ) { var this_ = this; this_.isLoading = false; this_.lang = null; this_.orderByVars = 'periodSort'; this_.stock = null; this_.urls = []; this_.cmpFunc = function( v1, v2 ) { return globalLib.cmpFunc( v1.value, v2.value ); }; this_.setOrder = function( field, val ) { if ( this_[ field ] === val ) { this_[ field ] = '-' + val; } else if ( this_[ field ] === ( '-' + val ) ) { this_[ field ] = val; } else { this_[ field ] = val; } }; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp.v2/fund-data.php', { ticker: this_.ticker } ) .then( function( response ) { this_.isLoading = false; this_.lang = response.data.lang; this_.stock = response.data.stock; this_.urls = response.data.urls; } ); }; this_.$onInit = function() { loadData(); globalLib.googleAnalytics( $location.url() ); }; } ] } ); globalApp.component( 'spFunds', { templateUrl: '/components/sp.v2/funds.html', controller: [ '$http', '$location', '$scope', function( $http, $location, $scope ) { var this_ = this; this_.cats = []; this_.currencies = []; this_.isLoading = false; this_.lang = null; this_.letters = []; this_.orderBy = ''; this_.pg = null; this_.promoters = []; this_.stocks = []; this_.data = {}; this_.data.cat = null; this_.data.currency = null; this_.data.letter = null; this_.data.pea = null; this_.data.promoter = null; var loadData = function() { var url = '/rest/sp.v2/funds.php'; if ( ! this_.lang ) { url += '?initRequest'; } this_.isLoading = true; $http .post( url, $location.search() ) .then( function( response ) { if ( response.data.cats.length ) { this_.cats = response.data.cats; } if ( response.data.currencies.length ) { this_.currencies = response.data.currencies; } if ( response.data.letters ) { this_.letters = response.data.letters; } if ( response.data.promoters.length ) { this_.promoters = response.data.promoters; } this_.isLoading = false; this_.lang = response.data.lang; this_.orderBy = response.data.orderBy; this_.pg = globalLib.genPgData( response.data.pg ); this_.stocks = response.data.stocks; // Set filters // ! 0 to null hack for `select` tags this_.data.cat = response.data.cat_ || null; this_.data.currency = response.data.currency_ || null; this_.data.letter = response.data.letter_ || null; this_.data.pea = response.data.pea_; this_.data.promoter = response.data.promoter_ || null; } ); } this_.setCat = function() { var p = $location.search(); p.cat = this_.data.cat; p.page = null; $location.search( p ); }; this_.setCurrency = function() { var p = $location.search(); p.currency = this_.data.currency; p.page = null; $location.search( p ); }; this_.setLetter = function( letter ) { this_.data.letter = letter; var p = $location.search(); p.letter = letter; p.page = null; $location.search( p ); }; this_.setOrder = function( val ) { var valNext = ''; if ( this_.orderBy === val ) { valNext = '-' + val; } else if ( this_.orderBy === ( '-' + val ) ) { valNext = val; } else { valNext = val; } var p = $location.search(); p.order = valNext; p.page = 1; $location.search( p ); }; this_.setPage = function( page ) { var p = $location.search(); p.page = page; $location.search( p ); $( window ).scrollTop( 0 ); }; this_.setPea = function() { var p = $location.search(); p.pea = this_.data.pea ? 1 : 0; p.page = null; $location.search( p ); }; this_.setPromoter = function() { var p = $location.search(); p.promoter = this_.data.promoter; p.page = null; $location.search( p ); }; $scope.$on( '$locationChangeSuccess', function() { loadData(); globalLib.googleAnalytics( $location.url() ); } ); } ] } ); globalApp.component( 'spHomepage', { templateUrl: '/components/sp.v2/homepage.html', bindings: { listType: '<' }, controller: [ '$http', '$location', '$timeout', function( $http, $location, $timeout ) { var this_ = this; this_.isLoading = false; this_.lang = null; this_.newsView = 1; this_.stockData = null; this_.urls = []; this_.btnClasses = []; this_.btnClasses[ 0 ] = 'bg-dark text-white'; this_.btnClasses[ 1 ] = 'bg-light'; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp.v2/homepage.php' ) .then( function( response ) { this_.isLoading = false; this_.lang = response.data.lang; this_.stockData = response.data.stockData; this_.urls = response.data.urls; $timeout( function() { globalLib.prismaAds( 'lr-ads-homepage-1', 2 ); globalLib.prismaAds( 'lr-ads-homepage-2', 1 ); globalLib.prismaAds( 'lr-ads-homepage-3' ); } ); } ); }; this_.$onInit = function() { loadData(); globalLib.googleAnalytics( $location.url() ); }; } ] } ); globalApp.component( 'spIndexesMarkets', { templateUrl: '/components/sp.v2/indexes-markets.html', bindings: { listType: '<' }, controller: [ '$http', '$location', '$timeout', function( $http, $location, $timeout ) { var this_ = this; this_.isLoading = false; this_.lang = null; this_.listType = 0; this_.orderBy = 'name'; this_.stockData = null; this_.stocks = []; this_.urls = []; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp.v2/indexes-markets.php', { listType: this_.listType } ) .then( function( response ) { this_.isLoading = false; this_.lang = response.data.lang; this_.listType = response.data.listType; this_.stocks = response.data.stocks; this_.stockData = response.data.stockData; this_.urls = response.data.urls; $timeout( function() { globalLib.prismaAds( 'lr-ads-indexes-markets', 1 ); } ); } ); }; this_.cmpFunc = function( v1, v2 ) { return globalLib.cmpFunc( v1.value, v2.value ); }; this_.setOrder = function( val ) { if ( this_.orderBy === val ) { this_.orderBy = '-' + val; } else if ( this_.orderBy === ( '-' + val ) ) { this_.orderBy = val; } else { this_.orderBy = val; } }; this_.$onInit = function() { loadData(); globalLib.googleAnalytics( $location.url() ); }; } ] } ); globalApp.component( 'spIndexData', { templateUrl: '/components/sp.v2/index-data.html', bindings: { ticker: '@' }, controller: [ '$http', '$location', '$timeout', function( $http, $location, $timeout ) { var this_ = this; this_.isLoading = false; this_.lang = null; this_.orderBy = 'periodSort'; this_.stock = null; this_.urls = []; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp.v2/index-data.php', { ticker: this_.ticker } ) .then( function( response ) { this_.isLoading = false; this_.lang = response.data.lang; this_.stock = response.data.stock; this_.urls = response.data.urls; $timeout( function() { globalLib.prismaAds( 'lr-ads-index-data' ); } ); } ); }; this_.cmpFunc = function( v1, v2 ) { return globalLib.cmpFunc( v1.value, v2.value ); }; this_.setOrder = function( val ) { if ( this_.orderBy === val ) { this_.orderBy = '-' + val; } else if ( this_.orderBy === ( '-' + val ) ) { this_.orderBy = val; } else { this_.orderBy = val; } }; this_.$onInit = function() { loadData(); globalLib.googleAnalytics( $location.url() ); }; } ] } ); globalApp.component( 'spCompanyData', { templateUrl: '/components/sp.v2/company-data.html?v1', bindings: { ticker: '@' }, controller: [ '$http', '$location', '$timeout', function( $http, $location, $timeout ) { var this_ = this; this_.factset = null; this_.isLoading = false; this_.lang = null; this_.orderByVars = 'periodSort'; this_.stock = null; this_.urls = []; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp.v2/company-data.php', { ticker: this_.ticker } ) .then( function( response ) { this_.factset = response.data.factset; this_.isLoading = false; this_.lang = response.data.lang; this_.stock = response.data.stock; this_.urls = response.data.urls; $timeout( function() { globalLib.prismaAds( 'lr-ads-company-data' ); } ); } ); }; this_.cmpFunc = function( v1, v2 ) { return globalLib.cmpFunc( v1.value, v2.value ); }; this_.setOrder = function( field, val ) { if ( this_[ field ] === val ) { this_[ field ] = '-' + val; } else if ( this_[ field ] === ( '-' + val ) ) { this_[ field ] = val; } else { this_[ field ] = val; } }; this_.$onInit = function() { loadData(); globalLib.googleAnalytics( $location.url() ); }; } ] } ); globalApp.component( 'spEventsCompanies', { templateUrl: '/components/sp.v2/events-companies.html', controller: [ '$http', '$location', '$scope', '$timeout', function( $http, $location, $scope, $timeout ) { var this_ = this; this_.events = []; this_.isLoading = false; this_.lang = null; this_.months = []; this_.orderBy = ''; this_.pg = null; this_.types = []; this_.urls = []; this_.data = {}; this_.data.month = null; this_.data.type = null; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp.v2/events-companies.php', $location.search() ) .then( function( response ) { this_.events = response.data.events; this_.isLoading = false; this_.lang = response.data.lang; this_.months = response.data.months; this_.orderBy = response.data.orderBy; this_.pg = response.data.pg; this_.types = response.data.types; this_.urls = response.data.urls; // Set filters // ! 0 to null hack for `select` tags this_.data.month = response.data.month_; this_.data.searched = response.data.searched; this_.data.type = response.data.type_ || null; $timeout( function() { globalLib.prismaAds( 'lr-ads-events-companies' ); } ); } ); }; this_.cmpFunc = function( v1, v2 ) { return globalLib.cmpFunc( v1.value, v2.value ); }; this_.setOrder = function( val ) { var valNext = ''; if ( this_.orderBy === val ) { valNext = '-' + val; } else if ( this_.orderBy === ( '-' + val ) ) { valNext = val; } else { valNext = val; } var p = $location.search(); p.order = valNext; p.page = 1; $location.search( p ); }; this_.setMonth = function() { var p = $location.search(); p.month = this_.data.month; p.page = null; $location.search( p ); }; this_.setPage = function( page ) { var p = $location.search(); p.page = page; $location.search( p ); // jQuery( window ).scrollTop( 0 ); }; this_.setSearched = function( reset ) { var p = $location.search(); if ( reset === true ) { this_.data.searched = ''; } p.searched = this_.data.searched || null; p.page = null; $location.search( p ); }; this_.setType = function() { var p = $location.search(); p.type = this_.data.type; p.page = null; $location.search( p ); }; $scope.$on( '$locationChangeSuccess', function() { jQuery( window ).scrollTop( 0 ); loadData(); globalLib.googleAnalytics( $location.url() ); } ); } ] } ); globalApp.component( 'spEventsCountries', { templateUrl: '/components/sp.v2/events-countries.html', controller: [ '$http', '$location', '$scope', '$timeout', function( $http, $location, $scope, $timeout ) { var this_ = this; this_.cntEvents = 0; this_.cntEventsNext = 0; this_.events = []; this_.eventsNext = []; this_.isLoading = false; this_.lang = null; this_.pageView = 1; this_.urls = []; this_.setView = function( viewId ) { this_.pageView = viewId; }; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp.v2/events-countries.php', $location.search() ) .then( function( response ) { this_.cntEvents = response.data.cntEvents; this_.cntEventsNext = response.data.cntEventsNext; this_.events = response.data.events; this_.eventsNext = response.data.eventsNext; this_.isLoading = false; this_.lang = response.data.lang; this_.urls = response.data.urls; $timeout( function() { globalLib.prismaAds( 'lr-ads-events-countries' ); } ); } ); }; $scope.$on( '$locationChangeSuccess', function() { loadData(); globalLib.googleAnalytics( $location.url() ); } ); } ] } ); globalApp.component( 'spEventsOperations', { templateUrl: '/components/sp.v2/events-operations.html', controller: [ '$http', '$location', '$scope', '$timeout', function( $http, $location, $scope, $timeout ) { var this_ = this; this_.events = []; this_.isLoading = false; this_.lang = null; this_.months = []; this_.orderBy = ''; this_.pg = null; this_.types = []; this_.urls = []; this_.data = {}; this_.data.month = null; this_.data.type = null; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp.v2/events-operations.php', $location.search() ) .then( function( response ) { this_.events = response.data.events; this_.isLoading = false; this_.lang = response.data.lang; this_.months = response.data.months; this_.orderBy = response.data.orderBy; this_.pg = response.data.pg; this_.types = response.data.types; this_.urls = response.data.urls; // Set filters // ! 0 to null hack for `select` tags this_.data.month = response.data.month_; this_.data.searched = response.data.searched; this_.data.type = response.data.type_ || null; $timeout( function() { globalLib.prismaAds( 'lr-ads-events-operations' ); } ); } ); }; this_.cmpFunc = function( v1, v2 ) { return globalLib.cmpFunc( v1.value, v2.value ); }; this_.setOrder = function( val ) { var valNext = ''; if ( this_.orderBy === val ) { valNext = '-' + val; } else if ( this_.orderBy === ( '-' + val ) ) { valNext = val; } else { valNext = val; } var p = $location.search(); p.order = valNext; p.page = 1; $location.search( p ); }; this_.setMonth = function() { var p = $location.search(); p.month = this_.data.month; p.page = null; $location.search( p ); }; this_.setPage = function( page ) { var p = $location.search(); p.page = page; $location.search( p ); // jQuery( window ).scrollTop( 0 ); }; this_.setSearched = function( reset ) { var p = $location.search(); if ( reset === true ) { this_.data.searched = ''; } p.searched = this_.data.searched || null; p.page = null; $location.search( p ); }; this_.setType = function() { var p = $location.search(); p.type = this_.data.type; p.page = null; $location.search( p ); }; $scope.$on( '$locationChangeSuccess', function() { jQuery( window ).scrollTop( 0 ); loadData(); globalLib.googleAnalytics( $location.url() ); } ); } ] } ); globalApp.component( 'spLabRevenue', { templateUrl: '/components/sp.v2/lab-revenue.html', controller: [ '$http', '$location', '$sce', '$timeout', function( $http, $location, $sce, $timeout ) { var this_ = this; this_.isLoading = false; this_.lang = null; this_.orderBy = 'name'; this_.sectors = []; this_.selectedStock = ''; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp.v2/lab-revenue.php', $location.search() ) .then( function( response ) { this_.isLoading = false; this_.lang = response.data.lang; this_.sectors = response.data.sectors; } ); }; this_.cmpFunc = function( v1, v2 ) { return globalLib.cmpFunc( v1.value, v2.value ); }; this_.getStocks = function( sectorData ) { if ( sectorData.isLoading || sectorData.stocks ) { return null; } sectorData.isLoading = true; $http .post( '/rest/sp.v2/_lab-revenue-stocks.php', { secId: sectorData.id } ) .then( function( response ) { sectorData.isLoading = false; sectorData.stocks = response.data.stocks; } ); }; this_.setOrder = function( val ) { if ( this_.orderBy === val ) { this_.orderBy = '-' + val; } else if ( this_.orderBy === ( '-' + val ) ) { this_.orderBy = val; } else { this_.orderBy = val; } }; this_.setWidth = function() { $timeout( function() { var pWidth = jQuery( '[data-role=page]').outerWidth(); pWidth -= 40; jQuery( '.dyn-width' ).css( 'max-width', pWidth ); } ); }; this_.toggleStock = function( uniqCode ) { if ( this_.selectedStock !== uniqCode ) { // Show this_.selectedStock = uniqCode; this_.setWidth(); } else { // Hide this_.selectedStock = ''; } }; this_.toHtml = function( html ) { return $sce.trustAsHtml( html ); }; // Events listeners this_.$onInit = function() { loadData(); globalLib.googleAnalytics( $location.url() ); }; this_.$postLink = function() { jQuery( window ).on( 'resize.spLabRevenue', function() { this_.setWidth(); } ); }; this_.$onDestroy = function() { jQuery( window ).off( 'resize.spLabRevenue' ); }; } ] } ); globalApp.component( 'spNewsContent', { templateUrl: '/components/sp.v2/news-content.html', bindings: { id: '@', type: '@' }, controller: [ '$http', '$location', '$sce', '$timeout', function( $http, $location, $sce, $timeout ) { var this_ = this; this_.isLoading = false; this_.lang = null; this_.newsData = null; this_.urls = []; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp.v2/news-content.php', { id: this_.id, type: this_.type } ) .then( function( response ) { this_.isLoading = false; this_.lang = response.data.lang; this_.newsData = response.data.newsData; this_.url = response.data.url; $timeout( function() { globalLib.prismaAds( 'lr-ads-news-content-1', 2 ); globalLib.prismaAds( 'lr-ads-news-content-2' ); } ); } ); }; this_.toHtml = function( html ) { return $sce.trustAsHtml( html ); }; this_.$onInit = function() { loadData(); globalLib.googleAnalytics( $location.url() ); }; } ] } ); globalApp.component( 'spNewsRumors', { templateUrl: '/components/sp.v2/news-rumors.html', controller: [ '$anchorScroll', '$http', '$location', '$sce', '$timeout', function( $anchorScroll, $http, $location, $sce, $timeout ) { var this_ = this; this_.isLoading = false; this_.lang = null; this_.news = []; this_.urls = []; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp.v2/news-rumors.php', $location.search() ) .then( function( response ) { this_.isLoading = false; this_.lang = response.data.lang; this_.news = response.data.news; this_.url = response.data.url; $timeout( function() { globalLib.prismaAds( 'lr-ads-news-rumors-1', 2 ); globalLib.prismaAds( 'lr-ads-news-rumors-2' ); var offset = jQuery( 'header.header' ).outerHeight(); $anchorScroll.yOffset = offset || 139; $anchorScroll(); } ); } ); }; this_.toHtml = function( html ) { return $sce.trustAsHtml( html ); }; this_.$onInit = function() { loadData(); globalLib.googleAnalytics( $location.url() ); }; } ] } ); globalApp.component( 'spNewsSymex', { templateUrl: '/components/sp.v2/news-symex.html', controller: [ '$http', '$location', '$sce', '$scope', '$timeout', function( $http, $location, $sce, $scope, $timeout ) { var this_ = this; this_.isLoading = false; this_.lang = null; this_.news = []; this_.pg = null; this_.urls = []; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp.v2/news-symex.php', $location.search() ) .then( function( response ) { this_.isLoading = false; this_.lang = response.data.lang; this_.news = response.data.news; this_.pg = globalLib.genPgData( response.data.pg ); this_.url = response.data.url; $timeout( function() { globalLib.prismaAds( 'lr-ads-news-symex-1', 2 ); globalLib.prismaAds( 'lr-ads-news-symex-2' ); } ); } ); }; this_.setPage = function( page ) { var p = $location.search(); p.page = page; $location.search( p ); }; this_.toHtml = function( html ) { return $sce.trustAsHtml( html ); }; $scope.$on( '$locationChangeSuccess', function() { jQuery( window ).scrollTop( 0 ); loadData(); globalLib.googleAnalytics( $location.url() ); } ); this_.$onInit = function() { loadData(); globalLib.googleAnalytics( $location.url() ); }; } ] } ); globalApp.component( 'spQuotations', { templateUrl: '/components/sp.v2/quotations.html', controller: [ '$http', '$location', '$scope', '$timeout', function( $http, $location, $scope, $timeout ) { var this_ = this; this_.indexes = []; this_.isLoading = false; this_.lang = null; this_.letters = null; this_.markets = []; this_.orderBy = ''; this_.pg = null; this_.stocks = []; this_.urls = []; this_.data = {}; this_.data.index = null; this_.data.letter = null; this_.data.market = null; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp.v2/quotations.php', $location.search() ) .then( function( response ) { this_.indexes = response.data.indexes; this_.isLoading = false; this_.lang = response.data.lang; this_.letters = response.data.letters; this_.markets = response.data.markets; this_.orderBy = response.data.orderBy; this_.pg = globalLib.genPgData( response.data.pg ); this_.stocks = response.data.stocks; this_.urls = response.data.urls; // Set filters // ! 0 to null hack for `select` tags this_.data.index = response.data.index_ || null; this_.data.letter = response.data.letter_ || null; this_.data.market = response.data.market_ || null; $timeout( function() { globalLib.prismaAds( 'lr-ads-quotations' ); } ); } ); }; this_.cmpFunc = function( v1, v2 ) { return globalLib.cmpFunc( v1.value, v2.value ); }; this_.setOrder = function( val ) { var valNext = ''; if ( this_.orderBy === val ) { valNext = '-' + val; } else if ( this_.orderBy === ( '-' + val ) ) { valNext = val; } else { valNext = val; } var p = $location.search(); p.order = valNext; p.page = 1; $location.search( p ); }; this_.setIndex = function() { var p = $location.search(); p.index = this_.data.index; p.market = null; p.page = null; $location.search( p ); }; this_.setLetter = function( letter ) { this_.data.letter = letter; var p = $location.search(); p.index = null; p.letter = letter; p.page = null; $location.search( p ); }; this_.setMarket = function() { var p = $location.search(); p.market = this_.data.market; p.index = null; p.page = null; $location.search( p ); }; this_.setPage = function( page ) { var p = $location.search(); p.page = page; $location.search( p ); jQuery( window ).scrollTop( 0 ); }; $scope.$on( '$locationChangeSuccess', function() { loadData(); globalLib.googleAnalytics( $location.url() ); } ); } ] } ); globalApp.component( 'spSearch', { templateUrl: '/components/sp.v2/search.html', controller: [ '$http', '$location', '$scope', function( $http, $location, $scope ) { var this_ = this; this_.cntActions = 0; this_.cntCerts = 0; this_.cntCryptos = 0; this_.cntFunds = 0; this_.cntTotal = 0; this_.cntTrackers = 0; this_.cntWarrs = 0; this_.isAuth = false; this_.isLoading = false; this_.isSending = false; this_.lang = null; this_.langWl = null; this_.listWl = []; this_.pg = null; this_.searched = ''; this_.stocks = []; this_.urls = []; this_.data = { searched: null, type: $location.search().type || '' }; this_.transPfData = { action: null, name: null, pays: null, price: null, qty: null, ticker: null }; this_.addWlData = { id: null, name: null, pays: null, ticker: null }; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp.v2/search.php', $location.search() ) .then( function( response ) { this_.cntActions = response.data.cntActions; this_.cntCerts = response.data.cntCerts; this_.cntCryptos = response.data.cntCryptos; this_.cntFunds = response.data.cntFunds; this_.cntTotal = response.data.cntTotal; this_.cntTrackers = response.data.cntTrackers; this_.cntWarrs = response.data.cntWarrs; this_.isLoading = false; this_.isAuth = response.data.isAuth; this_.lang = response.data.lang; this_.langWl = response.data.langWl; this_.listWl = response.data.listWl; this_.pg = globalLib.genPgData( response.data.pg ); this_.searched = response.data.searched; this_.stocks = response.data.stocks; this_.urls = response.data.urls; this_.data.searched = response.data.searched; this_.data.type = response.data.type; } ); }; this_.setSearched = function() { var p = $location.search(); p.searched = this_.data.searched; p.page = null; $location.search( p ); }; this_.setType = function( type ) { var p = $location.search(); this_.data.type = type; p.type = type; p.page = null; $location.search( p ); }; this_.setPage = function( page ) { var p = $location.search(); p.page = page; $location.search( p ); jQuery( window ).scrollTop( 0 ); }; this_.showTransForm = function( data ) { this_.transPfData.action = 'Buy'; this_.transPfData.ticker = data.ticker; this_.transPfData.pays = data.pays; this_.transPfData.name = data.name; this_.transPfData.price = globalLib.toNumber( data.close ); this_.transPfData.qty = 1; jQuery( '#pf-form-modal' ).modal( 'show' ); }; this_.showWlForm = function( data ) { if ( ! this_.addWlData.id && this_.listWl.length ) { this_.addWlData.id = this_.listWl[ 0 ].id; } this_.addWlData.ticker = data.ticker; this_.addWlData.pays = data.pays; this_.addWlData.name = data.name; jQuery( '#wl-add-form-modal' ).modal( 'show' ); }; this_.addToWlist = function() { if ( this_.isSending === true ) { return; } this_.isSending = true; $http .post( '/rest/wl/_add.php', this_.addWlData ) .then( function( response ) { var url = this_.urls[ 2 ]; url += '#!?id=' + this_.addWlData.id; document.location.href = url; } ); }; $scope.$on( '$locationChangeSuccess', function() { loadData(); globalLib.googleAnalytics( $location.url() ); } ); } ] } ); globalApp.component( 'spTaxData', { templateUrl: '/components/sp.v2/tax-data.html', bindings: { period: '@' }, controller: [ '$http', '$location', '$scope', '$timeout', function( $http, $location, $scope, $timeout ) { var this_ = this; this_.chartOps = null; this_.chartPeriods = []; this_.isLoading = false; this_.lang = null; this_.markets = []; this_.orderBy = 'periodSort'; this_.periodText = ''; this_.pgView = 1; this_.taxData = null; this_.urls = []; this_.data = {}; this_.data.market = null; var loadData = function() { this_.isLoading = true; var postData = angular.copy( $location.search() ); postData.period = this_.period; $http .post( '/rest/sp.v2/tax-data.php', postData ) .then( function( response ) { this_.chartOps = response.data.chartOps; this_.chartPeriods = response.data.chartPeriods; this_.isLoading = false; this_.lang = response.data.lang; this_.markets = response.data.markets; this_.periodText = response.data.periodText; this_.taxData = response.data.taxData; this_.urls = response.data.urls; // Set filters // ! 0 to null hack for `select` tags this_.data.market = response.data.market_; if ( this_.taxData ) { $timeout( function() { globalLib.runChart( '.tax-data-chart', this_.chartOps ); } ); } } ); }; this_.cmpFunc = function( v1, v2 ) { return globalLib.cmpFunc( v1.value, v2.value ); }; this_.setChartPeriod = function( perQty ) { var period = ''; var qty = parseInt( perQty.substring( 1 ) ) || 0; var tmpPeriod = perQty.substring( 0, 1 ) || ''; if ( tmpPeriod === 'm' ) { period = 'months'; } else if ( tmpPeriod === 'y' ) { period = 'years'; } if ( ! period || ! qty ) { return null; } this_.chartOps.period = period; this_.chartOps.perQty = perQty; this_.chartOps.qty = qty; globalLib.runChart( '.tax-data-chart', this_.chartOps, true ); }; this_.setOrder = function( val ) { if ( this_.orderBy === val ) { this_.orderBy = '-' + val; } else if ( this_.orderBy === ( '-' + val ) ) { this_.orderBy = val; } else { this_.orderBy = val; } }; this_.setMarket = function() { var p = $location.search(); p.market = this_.data.market; $location.search( p ); }; $scope.$on( '$locationChangeSuccess', function() { loadData(); globalLib.googleAnalytics( $location.url() ); } ); this_.$postLink = function() { jQuery( window ).on( 'resize.taxDataChart', function() { globalLib.runChart( '.tax-data-chart', this_.chartOps ); }); }; this_.$onDestroy = function() { jQuery( window ).off( 'resize.taxDataChart' ); }; } ] } ); globalApp.component( 'spTaxes', { templateUrl: '/components/sp.v2/taxes.html', controller: [ '$http', '$location', '$scope', function( $http, $location, $scope ) { var this_ = this; this_.isLoading = false; this_.lang = null; this_.markets = []; this_.orderBy = 'periodSort'; this_.taxes = []; this_.urls = []; this_.data = {}; this_.data.market = null; var googleChartData = []; var googleChartOpts = {}; var googleChart = function( chartData, chartOpts ) { if ( window.google ) { googleChartDraw( chartData, chartOpts ); return; } var url = 'https://www.gstatic.com/charts/loader.js'; jQuery.getScript( url, function() { google.charts.load( 'current', { 'packages': ['corechart'], language: 'fr' } ); google.charts.setOnLoadCallback( function() { googleChartDraw( chartData, chartOpts ); } ); } ); }; var googleChartDraw = function( chartData, chartOpts ) { var chartObj = document.getElementById( 'taxes-google-chart' ); if ( ! chartObj ) { return; } var data = google.visualization.arrayToDataTable( chartData ); var chart = new google.visualization.LineChart( chartObj ); chart.draw( data, chartOpts ); }; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp.v2/taxes.php', $location.search() ) .then( function( response ) { this_.isLoading = false; this_.lang = response.data.lang; this_.markets = response.data.markets; this_.taxes = response.data.taxes; this_.urls = response.data.urls; // Set filters // ! 0 to null hack for `select` tags this_.data.market = response.data.market_; googleChartData = response.data.gChartData; googleChartOpts = response.data.gChartOpts; setTimeout( function() { googleChart( googleChartData, googleChartOpts ); } ); } ); }; this_.cmpFunc = function( v1, v2 ) { return globalLib.cmpFunc( v1.value, v2.value ); }; this_.setOrder = function( val ) { if ( this_.orderBy === val ) { this_.orderBy = '-' + val; } else if ( this_.orderBy === ( '-' + val ) ) { this_.orderBy = val; } else { this_.orderBy = val; } }; this_.setMarket = function() { var p = $location.search(); p.market = this_.data.market; $location.search( p ); }; $scope.$on( '$locationChangeSuccess', function() { loadData(); globalLib.googleAnalytics( $location.url() ); } ); } ] } ); globalApp.component( 'spWarrants', { templateUrl: '/components/sp.v2/warrants.html', controller: [ '$http', '$location', '$scope', function( $http, $location, $scope ) { var this_ = this; this_.isLoading = false; this_.lang = null; this_.listType = 1; this_.months = []; this_.orderBy = 'name'; this_.pg = null; this_.stocks = []; this_.years = []; this_.data = {}; this_.data.issuer_ = null; this_.data.month = null; this_.data.underlying_ = null; this_.data.year = null; var loadData = function() { var url = '/rest/sp.v2/warrants.php'; if ( ! this_.lang ) { url += '?initRequest'; } this_.isLoading = true; $http .post( url, $location.search() ) .then( function( response ) { if ( response.data.underlyings ) { this_.underlyings = response.data.underlyings; } if ( response.data.issuers ) { this_.issuers = response.data.issuers; } this_.isLoading = false; this_.lang = response.data.lang; this_.months = response.data.months; this_.orderBy = response.data.orderBy; this_.pg = globalLib.genPgData( response.data.pg ); this_.stocks = response.data.stocks; this_.years = response.data.years; this_.data.issuer_ = response.data.issuer_ || null; this_.data.month = response.data.month_ || null; this_.data.underlying_ = response.data.underlying_ || null; this_.data.year = response.data.year_ || null; } ); }; this_.setDate = function( key ) { var p = $location.search(); p[ key ] = this_.data[ key ]; p.page = null; $location.search( p ); }; this_.setIssuer = function() { var p = $location.search(); p.issuer = this_.data.issuer_; p.page = null; $location.search( p ); }; this_.setOrder = function( val ) { var valNext = ''; if ( this_.orderBy === val ) { valNext = '-' + val; } else if ( this_.orderBy === ( '-' + val ) ) { valNext = val; } else { valNext = val; } var p = $location.search(); p.order = valNext; p.page = null; $location.search( p ); }; this_.setPage = function( page ) { var p = $location.search(); p.page = page; $location.search( p ); jQuery( window ).scrollTop( 0 ); }; this_.setUnderlying = function() { var p = $location.search(); p.underlying = this_.data.underlying_; p.page = null; $location.search( p ); }; $scope.$on( '$locationChangeSuccess', function() { loadData(); globalLib.googleAnalytics( $location.url() ); } ); } ] } ); globalApp.component( 'spWarrantData', { templateUrl: '/components/sp.v2/warrant-data.html', bindings: { ticker: '@' }, controller: [ '$http', '$location', '$timeout', function( $http, $location, $timeout ) { var this_ = this; this_.isLoading = false; this_.lang = null; this_.stock = null; this_.urls = []; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp.v2/warrant-data.php', { ticker: this_.ticker } ) .then( function( response ) { this_.isLoading = false; this_.lang = response.data.lang; this_.stock = response.data.stock; this_.urls = response.data.urls; } ); }; this_.$onInit = function() { loadData(); globalLib.googleAnalytics( $location.url() ); }; } ] } ); globalApp.component( 'wlWatchlistsCreation', { templateUrl: '/components/wl.v2/watchlists-creation.html', controller: [ '$http', '$location', function( $http, $location ) { var this_ = this; this_.canCreate = false; this_.isLoading = false; this_.isSending = null; this_.lang = null; this_.urls = []; this_.userData = null; this_.wlData = { name: '' }; var loadData = function() { this_.isLoading = true; $http .post( '/rest/wl.v2/watchlists-creation.php' ) .then( function( response ) { this_.isLoading = false; this_.lang = response.data.lang; this_.urls = response.data.urls; if ( response.data.isAuth ) { this_.canCreate = response.data.canCreate; this_.userData = response.data.userData; } } ); }; this_.createWl = function() { var flagStop = this_.isSending || ! this_.wlData.name; if ( flagStop ) { return; } this_.isSending = true; $http .post( '/rest/wl.v2/_wl-create.php', this_.wlData ) .then( function( response ) { var url = this_.urls[ 0 ]; if ( response.data.status && response.data.id ) { url = this_.urls[ 1 ] + '#!?id=' + response.data.id; } document.location.href = url; } ); }; // Go... this_.$onInit = function() { loadData(); globalLib.googleAnalytics( $location.url() ); }; }] }); globalApp.component( 'wlWatchlistsState', { templateUrl: '/components/wl.v2/watchlists-state.html', controller: [ '$http', '$location', '$scope', function( $http, $location, $scope ) { var this_ = this; this_.deleteFlag = false; this_.isLoading = false; this_.isSending = false; this_.watchlistId = 0; this_.deleteWlPosData = { id: 0, name: '', ticker: '', pays: '' }; this_.editWlData = { id: 0, name: '' }; this_.orderBy = 'name'; this_.cmpFunc = function( v1, v2 ) { return globalLib.cmpFunc( v1.value, v2.value ); }; this_.setOrder = function( val ) { if ( this_.orderBy === val ) { this_.orderBy = '-' + val; } else if ( this_.orderBy === ( '-' + val ) ) { this_.orderBy = val; } else { this_.orderBy = val; } }; var loadData = function() { this_.isLoading = true; $http .post( '/rest/wl.v2/watchlists-state.php', { id: parseInt( $location.search().id ) || 0 } ) .then( function( response ) { this_.isLoading = false; this_.lang = response.data.lang; this_.urls = response.data.urls; if ( response.data.isAuth ) { this_.listWl = response.data.listWl; this_.userData = response.data.userData; this_.watchlistId = response.data.watchlistId; this_.wlData = response.data.wlData; // Set data for the forms this_.editWlData.id = this_.wlData.id; this_.editWlData.name = this_.wlData.name; this_.deleteWlPosData.id = this_.wlData.id; } } ); }; this_.updateWl = function() { if ( this_.isSending === true ) { return; } this_.isSending = true; $http .post( '/rest/wl.v2/_wl-update.php', this_.editWlData ) .then( function( response ) { $( '#wl-edit-form-modal' ).modal( 'hide' ); this_.isSending = false; loadData(); }); }; this_.showDeleteForm = function( data ) { this_.deleteWlPosData.name = data.name; this_.deleteWlPosData.ticker = data.ticker; this_.deleteWlPosData.pays = data.pays; $( '#wl-delete-form-modal' ).modal( 'show' ); }; this_.deletePos = function() { if ( this_.isSending === true ) { return; } this_.isSending = true; $http .post( '/rest/wl/_wl-delete-pos.php', this_.deleteWlPosData ) .then( function( response ) { $( '#wl-delete-form-modal' ).modal( 'hide' ); this_.isSending = false; loadData(); }); }; this_.deleteWatchlist = function() { if ( ! this_.deleteFlag ) { this_.deleteFlag = true; return; } if ( this_.isSending === true ) { return; } this_.isSending = true; // Debug // alert( this_.wlData.id ); // return; $http .post( '/rest/wl/_wl-delete-wl.php', { id: this_.wlData.id } ) .then( function( response ) { document.location.href = this_.urls[ 3 ]; } ); }; this_.setWatchlist = function() { var p = $location.search(); p.id = this_.watchlistId; $location.search( p ); }; this_.printWl = function() { var area = jQuery( '#wl-print-area' ).clone(); var body = jQuery( 'body' ); if ( area.length === 1 ) { area.addClass( 'symex-print-area' ); body.addClass( 'symex-printer' ).append( area ); window.print(); area.remove(); body.removeClass( 'symex-printer' ); } }; $scope.$on( '$locationChangeSuccess', function() { loadData(); globalLib.googleAnalytics( $location.url() ); }); }] }); // ------------------------------------------- // ----- Components version 2 ( role: widget ) // ------------------------------------------- globalApp.component( 'pfWgAddForm', { templateUrl: '/components/pf.v2/wg-add-form.html', bindings: { action: '<', callback: '&', hidePfs: '<', pays: '<', pfId: '<', price: '<', qty: '<', ticker: '<', useCallback: '<' }, controller: [ '$http', '$location', function( $http, $location ) { var this_ = this; this_.currencyPf = ''; this_.isAuth = false; this_.isLoading = null; this_.isSending = null; this_.lang = null; this_.listPf = []; this_.urls = []; this_.pfData = {}; this_.pfData.action = 'Buy'; this_.pfData.date = new Date(); this_.pfData.id = 0; this_.pfData.pays = ''; this_.pfData.price = 0; this_.pfData.qty = 1; this_.pfData.taxes = 0; this_.pfData.ticker = ''; this_.toNumber = globalLib.toNumber; this_.calcAmount = function() { var a = this_.toNumber( this_.pfData.price ); var b = parseInt( this_.pfData.qty ) || 0; return ( a * b ).toFixed( 2 ); }; this_.calcTotal = function() { var a = this_.toNumber( this_.pfData.price ); var b = parseInt( this_.pfData.qty ) || 0; var c = this_.toNumber( this_.pfData.taxes ); return ( ( a * b ) + c ).toFixed( 2 ); }; var loadData = function() { this_.isLoading = true; $http .post( '/rest/pf.v2/wg-add-form.php', { ticker: this_.ticker } ) .then( function( response ) { this_.isLoading = false; if ( response.data.isAuth === true ) { this_.currencyPf = response.data.currencyPf; this_.isAuth = true; this_.lang = response.data.lang; this_.listPf = response.data.listPf; this_.urls = response.data.urls; // AngularJS input[date] ngModel requires date object // JavaScript date object serialization ( to JSON ) // The format will be: `Y-m-d\TH:i:s.vZ` // ! Set `pfData` properties that depend on the server this_.pfData.date = new Date( response.data.date ); if ( ! this_.pfData.id && this_.listPf.length ) { this_.pfData.id = this_.listPf[ 0 ].id; } } else { this_.lang = response.data.lang; this_.urls = response.data.urls; } } ); }; this_.saveData = function() { if ( this_.isSending === true ) { return; } this_.isSending = true; this_.pfData.price = this_.toNumber( this_.pfData.price ); this_.pfData.qty = this_.toNumber( this_.pfData.qty ); this_.pfData.taxes = this_.toNumber( this_.pfData.taxes ); $http .post( '/rest/pf.v2/_pf-transactions.php', this_.pfData ) .then( function() { this_.isSending = false; if ( this_.useCallback ) { this_.callback(); } else { var url = this_.urls[ 0 ] + '#!?id=' + this_.pfData.id; document.location.href = url; } } ); }; this_.$onInit = function() { loadData(); }; this_.$onChanges = function() { // ! `$onChanges` will be invoked/exec before `$onInit` this_.action = this_.action || 'Buy'; this_.hidePfs = this_.hidePfs || false; this_.pays = this_.pays || ''; this_.pfId = this_.pfId || 0; this_.price = this_.toNumber( this_.price ); this_.qty = this_.qty || 1; this_.ticker = this_.ticker || ''; this_.useCallback = this_.useCallback || false; this_.pfData.action = this_.action; this_.pfData.id = this_.pfId; this_.pfData.pays = this_.pays; this_.pfData.price = this_.toNumber( this_.price ); this_.pfData.qty = this_.qty; this_.pfData.ticker = this_.ticker; if ( ! this_.pfData.id && this_.listPf.length ) { this_.pfData.id = this_.listPf[ 0 ].id; } }; } ] } ); globalApp.component( 'spWgAwards', { templateUrl: '/components/sp.v2/wg-awards.html', controller: [ '$http', function( $http ) { var this_ = this; this_.index = ''; this_.isLoading = false; this_.lang = null; this_.tabs = []; this_.stocksDown = []; this_.stocksStats = []; this_.stocksUp = []; this_.urls = []; this_.loadData = function( index ) { this_.isLoading = true; $http .post( '/rest/sp.v2/wg-awards.php', { index: index }) .then( function( response ) { this_.index = response.data.index; this_.isLoading = false; this_.lang = response.data.lang; this_.tabs = response.data.tabs; this_.stocksDown = response.data.stocksDown; this_.stocksStats = response.data.stocksStats; this_.stocksUp = response.data.stocksUp; this_.urls = response.data.urls; }); }; // Go... this_.loadData(); }] }); globalApp.component( 'spWgConsensus', { templateUrl: '/components/sp.v2/wg-consensus.html', bindings: { ticker: '<', pays: '<' }, controller: [ '$http', function( $http ) { var this_ = this; this_.isAuth = false; this_.isLoading = false; this_.consensus = null; this_.lang = null; this_.urls = []; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp.v2/wg-consensus.php', { ticker: this_.ticker, pays: this_.pays }) .then( function( response ) { this_.isAuth = response.data.isAuth; this_.isLoading = false; this_.consensus = response.data.consensus; this_.lang = response.data.lang; this_.urls = response.data.urls; } ); }; this_.$onInit = function() { loadData(); }; } ] } ); globalApp.component( 'spWgEvents', { templateUrl: '/components/sp.v2/wg-events.html', bindings: { ownerType: '@', parentId: '@', pays: '<', ticker: '<' }, controller: [ '$http', function( $http ) { var this_ = this; this_.events = []; this_.isLoading = false; this_.lang = null; this_.urls = []; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp.v2/wg-events.php', { ownerType: this_.ownerType || '', pays: this_.pays || '', ticker: this_.ticker || '' } ) .then( function( response ) { if ( ! response.data.events.length ) { jQuery( '#' + this_.parentId ).remove(); return null; } this_.events = response.data.events; this_.isLoading = false; this_.lang = response.data.lang; this_.urls = response.data.urls; } ); }; this_.$onInit = function() { loadData(); }; } ] } ); globalApp.component( 'spWgStockData', { templateUrl: '/components/sp.v2/wg-stock-data.html', bindings: { pays: '<', skip: '<', ticker: '<' }, controller: [ '$http', '$interval', '$timeout', function( $http, $interval, $timeout ) { var this_ = this; this_.chartCmp_stocks = []; this_.chartOps = null; this_.chartOps_2 = null; this_.chartOps_3 = null; this_.chartPeriods = null; this_.dateNow = ''; this_.isLoading = false; this_.lang = null; this_.stockData = null; this_.timer = null; this_.urls = []; this_.wgView = 1; this_.loadData = function( index ) { this_.isLoading = true; $http .post( '/rest/sp.v2/wg-stock-data.php', { pays: this_.pays, ticker: this_.ticker } ) .then( function( response ) { this_.chartOps = response.data.chartOps; this_.chartOps_2 = response.data.chartOps_2; this_.chartOps_3 = response.data.chartOps_3; this_.chartPeriods = response.data.chartPeriods; this_.dateDiff = ''; this_.dateNow = response.data.dateNow; this_.isLoading = false; this_.lang = response.data.lang; this_.stockData = response.data.stockData; this_.urls = response.data.urls; this_.chartCmp_stocks.push( { name: this_.stockData.name, tickPays: this_.chartOps_2.ticker } ); // Run the charts $timeout( function() { globalLib.runChart( '.wg-stock-data-chart', this_.chartOps ); this_.dateDiff = globalLib.setTimer(); this_.timer = $interval( function() { this_.dateDiff = globalLib.setTimer(); }, 10000 ); }, 100 ); }); }; this_.chartCmp_addStock = function( stockData, inx ) { if ( stockData && inx ) { this_.chartCmp_stocks[ inx ] = { name: stockData.name, tickPays: stockData.tickPays }; this_.chartCmp_run(); } else { this_.chartCmp_stocks.push( null ); } }; this_.chartCmp_removeStock = function( inx ) { if ( inx > 0 ) { this_.chartCmp_stocks.splice( inx, 1 ); this_.chartCmp_run(); } }; this_.chartCmp_run = function() { var ticks = []; this_.chartCmp_stocks.forEach( function( val, inx ) { if ( val ) { ticks.push( val.tickPays ); } } ); this_.chartOps_2.ticker = ticks.join( ';' ); globalLib.runChart( '.wg-stock-data-chart-2', this_.chartOps_2, true ); }; this_.setChartPeriod = function( perQty ) { var period = ''; var qty = parseInt( perQty.substring( 1 ) ) || 0; var tmpPeriod = perQty.substring( 0, 1 ) || ''; if ( tmpPeriod === 'i' ) { period = 'intra'; } else if ( tmpPeriod === 'w' ) { period = 'week'; } else if ( tmpPeriod === 'm' ) { period = 'months'; } else if ( tmpPeriod === 'y' ) { period = 'years'; } if ( ! period || ! qty ) { return null; } this_.chartOps.period = period; this_.chartOps.perQty = perQty; this_.chartOps.qty = qty; this_.chartOps_2.period = period; this_.chartOps_2.perQty = perQty; this_.chartOps_2.qty = qty; // ! Hidden charts will not be run globalLib.runChart( '.wg-stock-data-chart', this_.chartOps, true ); globalLib.runChart( '.wg-stock-data-chart-2', this_.chartOps_2, true ); }; this_.setWgView = function( viewId ) { if ( this_.wgView === viewId ) { return; } this_.wgView = viewId; window.dataLayer = window.dataLayer || []; window.dataLayer.push( { 'event': 'graphique', 'type': globalLang[ 4 ][ 'tab_' + viewId ] || '', 'graphName': this_.stockData.name } ); $timeout( function() { // ! Hidden charts will not be run globalLib.runChart( '.wg-stock-data-chart', this_.chartOps ); globalLib.runChart( '.wg-stock-data-chart-2', this_.chartOps_2 ); globalLib.runChartAT( '.wg-stock-data-chart-3', this_.chartOps_3 ); } ); } this_.$onInit = function() { this.loadData(); }; this_.$postLink = function() { jQuery( window ).on( 'resize.wgStockDataChart', function() { // ! Hidden charts will not be run globalLib.runChart( '.wg-stock-data-chart', this_.chartOps ); globalLib.runChart( '.wg-stock-data-chart-2', this_.chartOps_2 ); globalLib.runChartAT( '.wg-stock-data-chart-3', this_.chartOps_3 ); }); }; this_.$onDestroy = function() { jQuery( window ).off( 'resize.wgStockDataChart' ); if ( this_.timer ) { $interval.cancel( this_.timer ); } }; } ] }); globalApp.component( 'spWgIndexComposition', { templateUrl: '/components/sp.v2/wg-index-composition.html', bindings: { ticker: '<' }, controller: [ '$http', '$location', '$scope', function( $http, $location, $scope ) { var this_ = this; this_.isLoading = false; this_.lang = null; this_.orderBy = ''; this_.pg = null; this_.stocks = []; this_.urls = []; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp.v2/wg-index-composition.php', { order: $location.search().order || '', page: $location.search().page || 1, ticker: this_.ticker } ) .then( function( response ) { this_.isLoading = false; this_.lang = response.data.lang; this_.orderBy = response.data.orderBy; this_.pg = response.data.pg; this_.stocks = response.data.stocks; this_.urls = response.data.urls; } ); }; this_.setOrder = function( val ) { var valNext = ''; if ( this_.orderBy === val ) { valNext = '-' + val; } else if ( this_.orderBy === ( '-' + val ) ) { valNext = val; } else { valNext = val; } var p = $location.search(); p.order = valNext; p.page = 1; $location.search( p ); }; this_.setPage = function( page ) { var p = $location.search(); p.page = page; $location.search( p ); var objTitle = jQuery( '[data-role=index-composition-title]' ); if ( objTitle.length ) { jQuery( window ).scrollTop( objTitle.offset().top - 65 ); } }; this_.$onInit = function() { loadData(); }; $scope.$on( '$locationChangeSuccess', function() { loadData(); } ); } ] } ); globalApp.component( 'spWgNewsList', { templateUrl: '/components/sp.v2/wg-news-list.html', bindings: { type: '@' }, controller: [ '$http', '$sce', function( $http, $sce ) { var this_ = this; this_.isLoading = false; this_.lang = null; this_.news = []; this_.tmplId = 1; this_.urls = []; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp.v2/wg-news-list.php', { type: this_.type || '' } ) .then( function( response ) { this_.isLoading = false; if ( response.data.lang ) { this_.lang = response.data.lang; this_.news = response.data.news; this_.tmplId = response.data.tmplId; this_.urls = response.data.urls; } }); }; this_.toHtml = function( html ) { return $sce.trustAsHtml( html ); }; this_.$onInit = function() { loadData(); }; }] }); globalApp.component( 'spWgNewsPrivate', { templateUrl: '/components/sp.v2/wg-news-private.html', controller: [ '$http', '$sce', function( $http, $sce ) { var this_ = this; this_.isLoading = false; this_.lang = null; this_.news = []; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp.v2/wg-news-private.php' ) .then( function( response ) { this_.isLoading = false; if ( response.data.lang ) { this_.lang = response.data.lang; this_.news = response.data.news; } }); }; this_.toHtml = function( html ) { return $sce.trustAsHtml( html ); }; this_.$onInit = function() { loadData(); }; }] }); globalApp.component( 'spWgNewsStock', { templateUrl: '/components/sp.v2/wg-news-stock.html', bindings: { isin: '<', name: '<', parentId: '@' }, controller: [ '$anchorScroll', '$http', '$location', '$sce', '$scope', '$timeout', function( $anchorScroll, $http, $location, $sce, $scope, $timeout ) { var this_ = this; this_.isLoading = false; this_.lang = null; this_.news = []; this_.pg = null; this_.urls = []; var loadData = function() { this_.isLoading = true; var postData = angular.copy( $location.search() ); postData.isin = this_.isin; $http .post( '/rest/sp.v2/wg-news-stock.php', postData ) .then( function( response ) { var lang = response.data.lang; lang[ 0 ] = lang[ 0 ].replace( '_NAME_', this_.name ); this_.isLoading = false; this_.lang = lang; this_.news = response.data.news; this_.pg = response.data.pg; this_.url = response.data.url; } ); }; this_.setPage = function( page ) { var p = $location.search(); p.newsPage = page; $location.search( p ); }; this_.toHtml = function( html ) { return $sce.trustAsHtml( html ); }; $scope.$on( '$locationChangeSuccess', function() { var scrollTop = 0; var obj_1 = jQuery( '#wg-news-stock' ); var obj_2 = jQuery( 'header.header' ); if ( obj_1.length && obj_2 ) { scrollTop = obj_1.offset().top; scrollTop -= obj_2.outerHeight(); } jQuery( window ).scrollTop( scrollTop ); loadData(); globalLib.googleAnalytics( $location.url() ); } ); this_.$onInit = function() { loadData(); }; } ] } ); globalApp.component( 'wlWgAddForm', { templateUrl: '/components/wl.v2/wg-add-form.html', bindings: { ticker: '<', pays: '<' }, controller: [ '$http', '$location', function( $http, $location ) { var this_ = this; this_.isAuth = false; this_.isLoading = false; this_.isSending = false; this_.lang = null; this_.listWl = []; this_.urls = []; this_.wlData = {}; this_.wlData.ticker = ''; this_.wlData.pays = ''; this_.wlData.id = 0; var loadData = function() { this_.isLoading = true; $http .post( '/rest/wl.v2/wg-add-form.php', { ticker: this_.ticker } ) .then( function( response ) { this_.isAuth = response.data.isAuth; this_.isLoading = false; if ( this_.isAuth ) { this_.lang = response.data.lang; this_.listWl = response.data.listWl; this_.urls = response.data.urls; this_.wlData.id = 0; this_.wlData.pays = this_.pays; this_.wlData.ticker = this_.ticker; if ( this_.listWl.length ) { this_.wlData.id = this_.listWl[ 0 ].id; } } else { this_.lang = response.data.lang; this_.urls = response.data.urls; } } ); }; this_.saveData = function() { if ( this_.isSending === true ) { return; } this_.isSending = true; $http .post( '/rest/wl.v2/_add.php', this_.wlData ) .then( function( response ) { var url = this_.urls[ 0 ]; url += '#!?id=' + this_.wlData.id; document.location.href = url; } ); }; this_.$onInit = function() { loadData(); }; } ] } ); // -------------------------------- // ----- Components version 1 ----- // -------------------------------- globalApp.component( 'page404', { templateUrl: '/components/404.html', controller: [ '$location', function( $location ) { globalLib.googleAnalytics( $location.url() ); }] }); globalApp.component( 'spSharePriceMarkets', { templateUrl: '/components/sp/share-price-markets.html', controllerAs: 'spCompanies', controller: [ '$http', '$location', '$scope', function( $http, $location, $scope ) { var this_ = this; this_.data = {}; this_.data.market = null; this_.data.index = null; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp/share-price-markets.php', $location.search() ) .then( function( response ) { this_.isLoading = false; if ( response.data.lang ) { this_.lang = response.data.lang; this_.markets = response.data.markets; this_.indexes = response.data.indexes; this_.stocks = response.data.stocks; this_.urls = response.data.urls; this_.pg = response.data.pg; this_.data.market = response.data.market_; this_.data.index = response.data.index_; } }); } this_.setMarket = function() { var p = $location.search(); p.market = this_.data.market; p.index = null; p.page = null; $location.search( p ); }; this_.setIndex = function() { var p = $location.search(); p.index = this_.data.index; p.market = null; p.page = null; $location.search( p ); }; this_.setPage = function( page ) { var p = $location.search(); p.page = page; $location.search( p ); $( window ).scrollTop( 0 ); }; $scope.$on( '$locationChangeSuccess', function() { loadData(); globalLib.googleAnalytics( $location.url() ); }); }] }); globalApp.component( 'spWgIndexes', { templateUrl: '/components/sp/wg-indexes.html', controllerAs: 'spWgIndexes', controller: [ '$http', '$timeout', function( $http, $timeout ) { var this_ = this; var tmpTicker = null; var tmpPays = null; var tmpWidth = null; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp/wg-indexes.php' ) .then( function( response ) { this_.isLoading = false; if ( response.data.lang ) { this_.lang = response.data.lang; this_.stocks = response.data.stocks; $timeout( function() { this_.chart( this_.stocks[ 0 ].ticker, this_.stocks[ 0 ].pays ); }, 100 ); } }); }; this_.chart = function( ticker, pays ) { if ( ticker && pays ) { // We call this function without params only when window resize event... tmpTicker = ticker; tmpPays = pays; tmpWidth = null; } var ticker = ticker || tmpTicker; var pays = pays || tmpPays; var obj = $( '.sp-wg-indexes-' + ticker + '-' + pays ); if ( obj.length !== 1 ) { return false; } if ( tmpWidth && tmpWidth === obj.parents( 'table' ).find( 'tr.chart td' ).width() ) { return; } var tr = ''; tr += ''; tr += ' '; tr += ""; obj.parents( 'table' ).find( 'tr.chart' ).remove(); obj.parents( 'tr' ).after( tr ); var height = 180; var width = obj.parents( 'table' ).find( 'tr.chart td' ).width(); tmpWidth = width; if ( width < 180 ) { return; } var url = ''; url += '//charts.symex.be/intraday/chart.php'; url += '?customer=lerevenu'; url += '&period=intra'; url += '&qty=1'; url += '&lang=fr'; url += '&height=' + height; url += '&width=' + width; url += '&ticker=' + ticker + ',' + pays; var chart = ''; chart += ''; obj.parents( 'table' ).find( 'tr.chart td' ).html( chart ); }; this_.$onInit = function() { loadData(); }; this_.$postLink = function() { $( window ).on( 'resize.spWgIndexesChart', function() { this_.chart(); }); }; this_.$onDestroy = function() { $( window ).off( 'resize.spWgIndexesChart' ); }; }] }); globalApp.component( 'spWgIndexesFr', { templateUrl: '/components/sp/wg-indexes-fr.html', controllerAs: 'spWgIndexesFr', controller: [ '$http', function( $http ) { var this_ = this; this_.loadData = function( index ) { this_.isLoading = true; $http .post( '/rest/sp/wg-indexes-fr.php' ) .then( function( response ) { this_.isLoading = false; if ( response.data.lang ) { this_.lang = response.data.lang; this_.stocks = response.data.stocks; this_.urls = response.data.urls; } }); }; // Go... this_.loadData(); }] }); globalApp.component( 'spCompanyChart', { templateUrl: '/components/sp/company-chart.html', bindings: { ticker: '@' }, controllerAs: 'spCompanyChart', controller: [ '$http', '$location', function( $http, $location ) { var this_ = this; var chart = function( reload ) { var obj = $( '[data-role=stock-data-chart]' ); if ( obj.length !== 1 ) { return false; } var width = obj.width(); var height = this_.chartSettings.height; var ticker = this_.chartSettings.ticker; if ( width < 500 ) { height = this_.chartSettings.heightSmart; } if ( ! reload && this_.chartSettings.width == width ) { return true; } for ( var i in this_.chartSettings.ticks ) { if ( this_.chartSettings.ticks[ i ].isSet ) { ticker += ( ';' + this_.chartSettings.ticks[ i ].code ); } } var baseUrl = this_.chartSettings.histoUrl; if ( this_.chartSettings.period === 'intra' || this_.chartSettings.period === 'week' ) { baseUrl = this_.chartSettings.intraUrl; } obj.html( ' ' ); var url = ''; url += baseUrl; url += '?customer=' + this_.chartSettings.customer; url += '&period=' + this_.chartSettings.period; url += '&qty=' + this_.chartSettings.qty; url += '&vol=' + this_.chartSettings.vol; url += '&sum=' + ( width < 500 ? 0 : this_.chartSettings.sum ); url += '&lang=' + this_.chartSettings.lang; url += '&height=' + height; url += '&width=' + width; url += '&ticker=' + ticker; var chart = ''; chart += ''; this_.chartSettings.width = width; obj.html( chart ); }; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp/company-chart.php', { ticker: this_.ticker }) .then( function( response ) { this_.isLoading = false; if ( response.data.lang ) { this_.lang = response.data.lang; this_.urls = response.data.urls; this_.chartSettings = response.data.chartSettings; this_.stock = response.data.stock; // Run the chart if ( this_.chartSettings ) { chart(); } } }); }; this_.setCompare = function( event ) { var obj = $( event.target ); var ticker = obj.data( 'ticker' ); for ( var i in this_.chartSettings.ticks ) { if ( this_.chartSettings.ticks[ i ].code === ticker ) { if ( obj.hasClass( 'active' ) ) { obj.removeClass( 'active' ); this_.chartSettings.ticks[ i ].isSet = false; } else { obj.addClass( 'active' ); this_.chartSettings.ticks[ i ].isSet = true; } } } chart( true ); }; this_.setChartPeriod = function( event ) { var obj = $( event.target ); var period = obj.data( 'period' ); var p = period.split( ',' )[ 0 ]; var q = period.split( ',' )[ 1 ]; this_.chartSettings.period = p; this_.chartSettings.qty = q; obj.parent().find( 'a' ).removeClass( 'active' ); obj.addClass( 'active' ); chart( true ); }; this_.$onInit = function() { loadData(); globalLib.googleAnalytics( $location.url() ); }; this_.$postLink = function() { $( window ).on( 'resize.stockDataChart', function() { chart(); }); }; this_.$onDestroy = function() { $( window ).off( 'resize.stockDataChart' ); }; }] }); globalApp.component( 'spCompanyNews', { templateUrl: '/components/sp/company-news.html', bindings: { ticker: '@' }, controllerAs: 'spCompanyNews', controller: [ '$http', '$location', '$scope', function( $http, $location, $scope ) { var this_ = this; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp/company-news.php', { ticker: this_.ticker, page: $location.search().page || null }) .then( function( response ) { this_.isLoading = false; if ( response.data.lang ) { this_.lang = response.data.lang; this_.urls = response.data.urls; this_.news = response.data.news; this_.pg = response.data.pg; this_.stock = response.data.stock; } }); }; this_.setPage = function( page ) { var p = $location.search(); p.page = page; $location.search( p ); $( window ).scrollTop( 0 ); }; this_.$onInit = function() { loadData(); }; $scope.$on( '$locationChangeSuccess', function() { loadData(); globalLib.googleAnalytics( $location.url() ); }); }] }); globalApp.component( 'spWgSector', { templateUrl: '/components/sp/wg-sector.html', bindings: { id: '<' }, controllerAs: 'spWgSector', controller: [ '$http', function( $http ) { var this_ = this; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp/wg-sector.php', { id: this_.id }) .then( function( response ) { this_.isLoading = false; if ( response.data.lang ) { this_.lang = response.data.lang; this_.urls = response.data.urls; this_.stocks = response.data.stocks; } }); }; this_.$onInit = function() { loadData(); }; }] }); globalApp.component( 'spSharePriceSectors', { templateUrl: '/components/sp/share-price-sectors.html', controllerAs: 'spCompanies', controller: [ '$http', '$location', '$scope', function( $http, $location, $scope ) { var this_ = this; this_.data = {}; this_.data.market = null; this_.data.index = null; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp/share-price-sectors.php', $location.search() ) .then( function( response ) { this_.isLoading = false; if ( response.data.lang ) { this_.lang = response.data.lang; this_.sectors = response.data.sectors; this_.stocks = response.data.stocks; this_.urls = response.data.urls; this_.pg = response.data.pg; this_.data.sector = response.data.sector_; } }); } this_.setSector = function() { var p = $location.search(); p.sector = this_.data.sector; p.page = null; $location.search( p ); }; this_.setPage = function( page ) { var p = $location.search(); p.page = page; $location.search( p ); $( window ).scrollTop( 0 ); }; $scope.$on( '$locationChangeSuccess', function() { loadData(); globalLib.googleAnalytics( $location.url() ); }); // Go... // loadData(); }] }); globalApp.component( 'spWgAgenda', { templateUrl: '/components/sp/wg-agenda.html', bindings: { isin: '<' }, controllerAs: 'spWgAgenda', controller: [ '$http', '$sce', function( $http, $sce ) { var this_ = this; this_.toHtml = function( html ) { return $sce.trustAsHtml( html ); }; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp/wg-agenda.php', { isin: this_.isin }) .then( function( response ) { this_.isLoading = false; if ( response.data.lang ) { this_.lang = response.data.lang; this_.agenda = response.data.agenda; } }); }; this_.$onInit = function() { loadData(); }; }] }); globalApp.component( 'spWgVideos', { templateUrl: '/components/sp/wg-videos.html', bindings: { isin: '<' }, controllerAs: 'spWgVideos', controller: [ '$http', '$timeout', function( $http, $timeout ) { var this_ = this; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp/wg-videos.php', { isin: this_.isin }) .then( function( response ) { this_.isLoading = false; if ( response.data.lang ) { this_.lang = response.data.lang; this_.urls = response.data.urls; this_.videos = response.data.videos; $( '#wg-videos-carousel' ) .carousel() .on( 'slid.bs.carousel', function( event ) { var i = $( event.relatedTarget ).index(); $( this ) .find( 'a.symex-carousel-indicator' ) .removeClass( 'active' ) .eq( i ) .addClass( 'active' ); }); } }); }; this_.$onInit = function() { loadData(); }; this_.$onDestroy = function() { $( '#wg-videos-carousel' ).off( 'slid.bs.carousel' ); }; }] }); globalApp.component( 'spAwardsSectors', { templateUrl: '/components/sp/awards-sectors.html', controllerAs: 'spCompanies', controller: [ '$http', '$location', '$scope', function( $http, $location, $scope ) { var this_ = this; this_.data = {}; this_.data.sector = null; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp/awards-sectors.php', $location.search() ) .then( function( response ) { this_.isLoading = false; if ( response.data.lang ) { this_.lang = response.data.lang; this_.sectors = response.data.sectors; this_.criterias = response.data.criterias; this_.periods = response.data.periods; this_.stocks = response.data.stocks; this_.urls = response.data.urls; this_.pg = response.data.pg; this_.data.sector = response.data.sector_; this_.data.criteria = response.data.criteria_; this_.data.period = response.data.period_; } }); } this_.setSector = function() { var p = $location.search(); p.sector = this_.data.sector; p.page = null; $location.search( p ); }; this_.setCriteria = function() { var p = $location.search(); p.criteria = this_.data.criteria; p.page = null; $location.search( p ); }; this_.setPeriod = function() { var p = $location.search(); p.period = this_.data.period; p.page = null; $location.search( p ); }; this_.setPage = function( page ) { var p = $location.search(); p.page = page; $location.search( p ); $( window ).scrollTop( 0 ); }; $scope.$on( '$locationChangeSuccess', function() { loadData(); globalLib.googleAnalytics( $location.url() ); }); // Go... // loadData(); }] }); globalApp.component( 'spIndexChart', { templateUrl: '/components/sp/index-chart.html', bindings: { ticker: '@' }, controllerAs: 'spIC', controller: [ '$http', '$location', function( $http, $location ) { var this_ = this; var chart = function( reload ) { var obj = $( '[data-role=stock-data-chart]' ); if ( obj.length !== 1 ) { return false; } var width = obj.width(); var height = this_.chartSettings.height; var ticker = this_.chartSettings.ticker; if ( width < 500 ) { height = this_.chartSettings.heightSmart; } if ( ! reload && this_.chartSettings.width == width ) { return true; } for ( var i in this_.chartSettings.ticks ) { if ( this_.chartSettings.ticks[ i ].isSet ) { ticker += ( ';' + this_.chartSettings.ticks[ i ].code ); } } var baseUrl = this_.chartSettings.histoUrl; if ( this_.chartSettings.period === 'intra' || this_.chartSettings.period === 'week' ) { baseUrl = this_.chartSettings.intraUrl; } obj.html( ' ' ); var url = ''; url += baseUrl; url += '?customer=' + this_.chartSettings.customer; url += '&period=' + this_.chartSettings.period; url += '&qty=' + this_.chartSettings.qty; url += '&vol=' + this_.chartSettings.vol; url += '&sum=' + ( width < 500 ? 0 : this_.chartSettings.sum ); url += '&lang=' + this_.chartSettings.lang; url += '&height=' + height; url += '&width=' + width; url += '&ticker=' + ticker; var chart = ''; chart += ''; this_.chartSettings.width = width; obj.html( chart ); }; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp/index-chart.php', { ticker: this_.ticker }) .then( function( response ) { this_.isLoading = false; if ( response.data.lang ) { this_.lang = response.data.lang; this_.urls = response.data.urls; this_.chartSettings = response.data.chartSettings; this_.stock = response.data.stock; // Run the chart if ( this_.chartSettings ) { chart(); } } }); }; this_.setCompare = function( event ) { var obj = $( event.target ); var ticker = obj.data( 'ticker' ); for ( var i in this_.chartSettings.ticks ) { if ( this_.chartSettings.ticks[ i ].code === ticker ) { if ( obj.hasClass( 'active' ) ) { obj.removeClass( 'active' ); this_.chartSettings.ticks[ i ].isSet = false; } else { obj.addClass( 'active' ); this_.chartSettings.ticks[ i ].isSet = true; } } } chart( true ); }; this_.setChartPeriod = function( event ) { var obj = $( event.target ); var period = obj.data( 'period' ); var p = period.split( ',' )[ 0 ]; var q = period.split( ',' )[ 1 ]; this_.chartSettings.period = p; this_.chartSettings.qty = q; obj.parent().find( 'a' ).removeClass( 'active' ); obj.addClass( 'active' ); chart( true ); }; this_.$onInit = function() { loadData(); globalLib.googleAnalytics( $location.url() ); }; this_.$postLink = function() { $( window ).on( 'resize.stockDataChart', function() { chart(); }); }; this_.$onDestroy = function() { $( window ).off( 'resize.stockDataChart' ); }; }] }); globalApp.component( 'pfWgPortfolios', { templateUrl: '/components/pf/wg-portfolios.php', controllerAs: 'pfWgPortfolios', controller: [ '$http', function( $http ) { var this_ = this; var loadData = function() { this_.isLoading = true; $http .post( '/rest/pf/wg-portfolios.php' ) .then( function( response ) { this_.isLoading = false; if ( response.data.lang ) { this_.lang = response.data.lang; this_.urls = response.data.urls; if ( response.data.isAuth ) { this_.listPf = response.data.listPf; $( '#wg-portfolios-carousel' ) .carousel() .on( 'slid.bs.carousel', function( event ) { var i = $( event.relatedTarget ).index(); $( this ) .find( 'a.symex-carousel-indicator' ) .removeClass( 'active' ) .eq( i ) .addClass( 'active' ); }); } } }); }; this_.$onInit = function() { loadData(); }; this_.$onDestroy = function() { $( '#wg-portfolios-carousel' ).off( 'slid.bs.carousel' ); }; }] }); globalApp.component( 'spCompanyInfo', { templateUrl: '/components/sp/company-info.html', bindings: { ticker: '@' }, controllerAs: 'spCI', controller: [ '$http', '$sce', '$location', function( $http, $sce, $location ) { var this_ = this; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp/company-info.php', { ticker: this_.ticker }) .then( function( response ) { this_.isLoading = false; if ( response.data.lang ) { this_.lang = response.data.lang; this_.urls = response.data.urls; this_.stockInfo = response.data.stockInfo; this_.stock = response.data.stock; } }); }; this_.toHtml = function( html ) { return $sce.trustAsHtml( html ); }; this_.$onInit = function() { loadData(); globalLib.googleAnalytics( $location.url() ); }; }] }); globalApp.component( 'spObligations', { templateUrl: '/components/sp/obligations.html', controllerAs: 'spOblig', controller: [ '$http', '$location', '$scope', function( $http, $location, $scope ) { var this_ = this; this_.data = {}; this_.data.market = null; this_.data.maturity = null; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp/obligations.php', $location.search() ) .then( function( response ) { this_.isLoading = false; if ( response.data.lang ) { this_.lang = response.data.lang; this_.markets = response.data.markets; this_.maturities = response.data.maturities; this_.stocks = response.data.stocks; this_.pg = response.data.pg; this_.data.market = response.data.market_; this_.data.maturity = response.data.maturity_; } }); } this_.setMarket = function() { var p = $location.search(); p.market = this_.data.market; p.page = null; $location.search( p ); }; this_.setMaturity = function() { var p = $location.search(); p.maturity = this_.data.maturity; p.page = null; $location.search( p ); }; this_.setPage = function( page ) { var p = $location.search(); p.page = page; $location.search( p ); $( window ).scrollTop( 0 ); }; $scope.$on( '$locationChangeSuccess', function() { loadData(); globalLib.googleAnalytics( $location.url() ); }); }] }); globalApp.component( 'spObligationData', { templateUrl: '/components/sp/obligation-data.html', bindings: { ticker: '@' }, controllerAs: 'spObData', controller: [ '$http', '$location', '$timeout', function( $http, $location, $timeout ) { var this_ = this; var chart = function( ticker, pays ) { var obj = $( '[data-role=obligation-data-chart]' ); if ( obj.length !== 1 ) { return false; } var height = 300; var width = obj.width(); if ( obj.data( 'width' ) == width ) { return true; } obj.html( ' ' ); var url = ''; url += '//charts.symex.be/historical/chart.php'; url += '?customer=lerevenu'; url += '&period=years'; url += '&qty=1'; url += '&lang=fr'; url += '&height=' + height; url += '&width=' + width; url += '&ticker=' + ticker + ',' + pays; var chart = ''; chart += ''; obj.data( 'width', width ); obj.html( chart ); }; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp/obligation-data.php', { ticker: this_.ticker }) .then( function( response ) { this_.isLoading = false; if ( response.data.lang ) { this_.lang = response.data.lang; this_.stock = response.data.stock; // Run the chart if ( this_.stock ) { $timeout( function() { chart( this_.stock.ticker, this_.stock.pays ); }, 50 ); } } }); }; this_.$onInit = function() { loadData(); globalLib.googleAnalytics( $location.url() ); }; this_.$postLink = function() { $( window ).on( 'resize.obligationDataChart', function() { chart( this_.stock.ticker, this_.stock.pays ); }); }; this_.$onDestroy = function() { $( window ).off( 'resize.obligationDataChart' ); }; }] }); globalApp.component( 'spObligationChart', { templateUrl: '/components/sp/obligation-chart.html', bindings: { ticker: '@' }, controllerAs: 'spOC', controller: [ '$http', '$location', function( $http, $location ) { var this_ = this; var chart = function( reload ) { var obj = $( '[data-role=obligation-chart]' ); if ( obj.length !== 1 ) { return false; } var width = obj.width(); var height = this_.chartSettings.height; var ticker = this_.chartSettings.ticker; if ( width < 500 ) { height = this_.chartSettings.heightSmart; } if ( ! reload && this_.chartSettings.width == width ) { return true; } for ( var i in this_.chartSettings.ticks ) { if ( this_.chartSettings.ticks[ i ].isSet ) { ticker += ( ';' + this_.chartSettings.ticks[ i ].code ); } } var baseUrl = this_.chartSettings.histoUrl; obj.html( ' ' ); var url = ''; url += baseUrl; url += '?customer=' + this_.chartSettings.customer; url += '&period=' + this_.chartSettings.period; url += '&qty=' + this_.chartSettings.qty; url += '&vol=' + this_.chartSettings.vol; url += '&sum=' + ( width < 500 ? 0 : this_.chartSettings.sum ); url += '&lang=' + this_.chartSettings.lang; url += '&height=' + height; url += '&width=' + width; url += '&ticker=' + ticker; var chart = ''; chart += ''; this_.chartSettings.width = width; obj.html( chart ); }; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp/obligation-chart.php', { ticker: this_.ticker }) .then( function( response ) { this_.isLoading = false; if ( response.data.lang ) { this_.lang = response.data.lang; this_.chartSettings = response.data.chartSettings; this_.stock = response.data.stock; // Run the chart if ( this_.chartSettings ) { chart(); } } }); }; this_.setCompare = function( event ) { var obj = $( event.target ); var ticker = obj.data( 'ticker' ); for ( var i in this_.chartSettings.ticks ) { if ( this_.chartSettings.ticks[ i ].code === ticker ) { if ( obj.hasClass( 'active' ) ) { obj.removeClass( 'active' ); this_.chartSettings.ticks[ i ].isSet = false; } else { obj.addClass( 'active' ); this_.chartSettings.ticks[ i ].isSet = true; } } } chart( true ); }; this_.setChartPeriod = function( event ) { var obj = $( event.target ); var period = obj.data( 'period' ); var p = period.split( ',' )[ 0 ]; var q = period.split( ',' )[ 1 ]; this_.chartSettings.period = p; this_.chartSettings.qty = q; obj.parent().find( 'a' ).removeClass( 'active' ); obj.addClass( 'active' ); chart( true ); }; this_.$onInit = function() { loadData(); globalLib.googleAnalytics( $location.url() ); }; this_.$postLink = function() { $( window ).on( 'resize.obligationChart', function() { chart(); }); }; this_.$onDestroy = function() { $( window ).off( 'resize.obligationChart' ); }; }] }); globalApp.component( 'spTrackers', { templateUrl: '/components/sp/trackers.html', controllerAs: 'spTrackers', controller: [ '$http', '$location', '$scope', function( $http, $location, $scope ) { var this_ = this; this_.data = {}; this_.data.issuer = null; this_.data.market = null; this_.data.currency = null; this_.data.pea = null; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp/trackers.php', $location.search() ) .then( function( response ) { this_.isLoading = false; if ( response.data.lang ) { this_.lang = response.data.lang; this_.issuers = response.data.issuers; this_.markets = response.data.markets; this_.currencies = response.data.currencies; this_.stocks = response.data.stocks; this_.pg = response.data.pg; this_.data.issuer = response.data.issuer_; this_.data.market = response.data.market_; this_.data.currency = response.data.currency_; this_.data.pea = response.data.pea_; } }); } this_.setIssuer = function() { var p = $location.search(); p.issuer = this_.data.issuer; p.page = null; $location.search( p ); }; this_.setMarket = function() { var p = $location.search(); p.market = this_.data.market; p.page = null; $location.search( p ); }; this_.setCurrency = function() { var p = $location.search(); p.currency = this_.data.currency; p.page = null; $location.search( p ); }; this_.setPea = function() { var p = $location.search(); p.pea = this_.data.pea ? 1 : 0; p.page = null; $location.search( p ); }; this_.setPage = function( page ) { var p = $location.search(); p.page = page; $location.search( p ); $( window ).scrollTop( 0 ); }; $scope.$on( '$locationChangeSuccess', function() { loadData(); globalLib.googleAnalytics( $location.url() ); }); }] }); globalApp.component( 'spTrackerData', { templateUrl: '/components/sp/tracker-data.html', bindings: { ticker: '@' }, controllerAs: 'spTrackerData', controller: [ '$http', '$location', '$timeout', function( $http, $location, $timeout ) { var this_ = this; var chart = function( ticker, pays ) { var obj = $( '[data-role=tracker-data-chart]' ); if ( obj.length !== 1 ) { return false; } var height = 300; var width = obj.width(); if ( obj.data( 'width' ) == width ) { return true; } obj.html( ' ' ); var url = ''; url += '//charts.symex.be/historical/chart.php'; url += '?customer=lerevenu'; url += '&period=years'; url += '&qty=1'; url += '&lang=fr'; url += '&height=' + height; url += '&width=' + width; url += '&ticker=' + ticker + ',' + pays; var chart = ''; chart += ''; obj.data( 'width', width ); obj.html( chart ); }; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp/tracker-data.php', { ticker: this_.ticker }) .then( function( response ) { this_.isLoading = false; if ( response.data.lang ) { this_.lang = response.data.lang; this_.stock = response.data.stock; // Run the chart if ( this_.stock ) { $timeout( function() { chart( this_.stock.ticker, this_.stock.pays ); }, 50 ); } } }); }; this_.$onInit = function() { loadData(); globalLib.googleAnalytics( $location.url() ); }; this_.$postLink = function() { $( window ).on( 'resize.trackerDataChart', function() { chart( this_.stock.ticker, this_.stock.pays ); }); }; this_.$onDestroy = function() { $( window ).off( 'resize.trackerDataChart' ); }; }] }); globalApp.component( 'spTrackerChart', { templateUrl: '/components/sp/tracker-chart.html', bindings: { ticker: '@' }, controllerAs: 'spTC', controller: [ '$http', '$location', function( $http, $location ) { var this_ = this; var chart = function( reload ) { var obj = $( '[data-role=tracker-chart]' ); if ( obj.length !== 1 ) { return false; } var width = obj.width(); var height = this_.chartSettings.height; var ticker = this_.chartSettings.ticker; if ( width < 500 ) { height = this_.chartSettings.heightSmart; } if ( ! reload && this_.chartSettings.width == width ) { return true; } for ( var i in this_.chartSettings.ticks ) { if ( this_.chartSettings.ticks[ i ].isSet ) { ticker += ( ';' + this_.chartSettings.ticks[ i ].code ); } } var baseUrl = this_.chartSettings.histoUrl; obj.html( ' ' ); var url = ''; url += baseUrl; url += '?customer=' + this_.chartSettings.customer; url += '&period=' + this_.chartSettings.period; url += '&qty=' + this_.chartSettings.qty; url += '&vol=' + this_.chartSettings.vol; url += '&sum=' + ( width < 500 ? 0 : this_.chartSettings.sum ); url += '&lang=' + this_.chartSettings.lang; url += '&height=' + height; url += '&width=' + width; url += '&ticker=' + ticker; var chart = ''; chart += ''; this_.chartSettings.width = width; obj.html( chart ); }; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp/tracker-chart.php', { ticker: this_.ticker }) .then( function( response ) { this_.isLoading = false; if ( response.data.lang ) { this_.lang = response.data.lang; this_.chartSettings = response.data.chartSettings; this_.stock = response.data.stock; // Run the chart if ( this_.chartSettings ) { chart(); } } }); }; this_.setCompare = function( event ) { var obj = $( event.target ); var ticker = obj.data( 'ticker' ); for ( var i in this_.chartSettings.ticks ) { if ( this_.chartSettings.ticks[ i ].code === ticker ) { if ( obj.hasClass( 'active' ) ) { obj.removeClass( 'active' ); this_.chartSettings.ticks[ i ].isSet = false; } else { obj.addClass( 'active' ); this_.chartSettings.ticks[ i ].isSet = true; } } } chart( true ); }; this_.setChartPeriod = function( event ) { var obj = $( event.target ); var period = obj.data( 'period' ); var p = period.split( ',' )[ 0 ]; var q = period.split( ',' )[ 1 ]; this_.chartSettings.period = p; this_.chartSettings.qty = q; obj.parent().find( 'a' ).removeClass( 'active' ); obj.addClass( 'active' ); chart( true ); }; this_.$onInit = function() { loadData(); globalLib.googleAnalytics( $location.url() ); }; this_.$postLink = function() { $( window ).on( 'resize.trackerChart', function() { chart(); }); }; this_.$onDestroy = function() { $( window ).off( 'resize.trackerChart' ); }; }] }); globalApp.component( 'wlWgWatchlists', { templateUrl: '/components/wl/wg-watchlists.php', controllerAs: 'wlWgWl', controller: [ '$http', function( $http ) { var this_ = this; var loadData = function() { this_.isLoading = true; $http .post( '/rest/wl/wg-watchlists.php' ) .then( function( response ) { this_.isLoading = false; if ( response.data.lang ) { this_.lang = response.data.lang; this_.urls = response.data.urls; if ( response.data.isAuth ) { this_.listWl = response.data.listWl; $( '#wg-wls-carousel' ) .carousel() .on( 'slid.bs.carousel', function( event ) { var i = $( event.relatedTarget ).index(); $( this ) .find( 'a.symex-carousel-indicator' ) .removeClass( 'active' ) .eq( i ) .addClass( 'active' ); }); } } }); }; this_.$onInit = function() { loadData(); }; this_.$onDestroy = function() { $( '#wg-wls-carousel' ).off( 'slid.bs.carousel' ); }; }] }); globalApp.component( 'spCurrencyChart', { templateUrl: '/components/sp/currency-chart.html', bindings: { ticker: '@' }, controllerAs: 'spCurrsChart', controller: [ '$http', '$location', '$timeout', function( $http, $location, $timeout ) { var this_ = this; var chart = function( reload ) { var obj = $( '[data-role=currency-chart]' ); if ( obj.length !== 1 ) { return false; } var width = obj.width(); var height = this_.chartSettings.height; var ticker = this_.chartSettings.ticker; if ( width < 500 ) { height = this_.chartSettings.heightSmart; } if ( ! reload && this_.chartSettings.width == width ) { return true; } for ( var i in this_.chartSettings.ticks ) { if ( this_.chartSettings.ticks[ i ].isSet ) { ticker += ( ';' + this_.chartSettings.ticks[ i ].code ); } } var baseUrl = this_.chartSettings.histoUrl; if ( this_.chartSettings.period === 'intra' || this_.chartSettings.period === 'week' ) { baseUrl = this_.chartSettings.intraUrl; } obj.html( ' ' ); var url = ''; url += baseUrl; url += '?customer=' + this_.chartSettings.customer; url += '&period=' + this_.chartSettings.period; url += '&qty=' + this_.chartSettings.qty; url += '&vol=' + this_.chartSettings.vol; url += '&sum=' + ( width < 500 ? 0 : this_.chartSettings.sum ); url += '&lang=' + this_.chartSettings.lang; url += '&height=' + height; url += '&width=' + width; url += '&ticker=' + ticker; var chart = ''; chart += ''; this_.chartSettings.width = width; obj.html( chart ); }; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp/currency-chart.php', { ticker: this_.ticker }) .then( function( response ) { this_.isLoading = false; if ( response.data.lang ) { this_.lang = response.data.lang; this_.urls = response.data.urls; this_.chartSettings = response.data.chartSettings; this_.stock = response.data.stock; // Run the chart if ( this_.chartSettings.ticker ) { $timeout( function() { chart(); }, 50 ); } } }); }; this_.setCompare = function( event ) { var obj = $( event.target ); var ticker = obj.data( 'ticker' ); for ( var i in this_.chartSettings.ticks ) { if ( this_.chartSettings.ticks[ i ].code === ticker ) { if ( obj.hasClass( 'active' ) ) { obj.removeClass( 'active' ); this_.chartSettings.ticks[ i ].isSet = false; } else { obj.addClass( 'active' ); this_.chartSettings.ticks[ i ].isSet = true; } } } chart( true ); }; this_.setChartPeriod = function( event ) { var obj = $( event.target ); var period = obj.data( 'period' ); var p = period.split( ',' )[ 0 ]; var q = period.split( ',' )[ 1 ]; this_.chartSettings.period = p; this_.chartSettings.qty = q; obj.parent().find( 'a' ).removeClass( 'active' ); obj.addClass( 'active' ); chart( true ); }; this_.$onInit = function() { loadData(); globalLib.googleAnalytics( $location.url() ); }; this_.$postLink = function() { $( window ).on( 'resize.currsChart', function() { chart(); }); }; this_.$onDestroy = function() { $( window ).off( 'resize.currsChart' ); }; }] }); globalApp.component( 'spWarrantChart', { templateUrl: '/components/sp/warrant-chart.html', bindings: { ticker: '@' }, controllerAs: 'spWC', controller: [ '$http', '$location', function( $http, $location ) { var this_ = this; var chart = function( reload ) { var obj = $( '[data-role=warrant-chart]' ); if ( obj.length !== 1 ) { return false; } var width = obj.width(); var height = this_.chartSettings.height; var ticker = this_.chartSettings.ticker; if ( width < 500 ) { height = this_.chartSettings.heightSmart; } if ( ! reload && this_.chartSettings.width == width ) { return true; } for ( var i in this_.chartSettings.ticks ) { if ( this_.chartSettings.ticks[ i ].isSet ) { ticker += ( ';' + this_.chartSettings.ticks[ i ].code ); } } var baseUrl = this_.chartSettings.histoUrl; obj.html( ' ' ); var url = ''; url += baseUrl; url += '?customer=' + this_.chartSettings.customer; url += '&period=' + this_.chartSettings.period; url += '&qty=' + this_.chartSettings.qty; url += '&vol=' + this_.chartSettings.vol; url += '&sum=' + ( width < 500 ? 0 : this_.chartSettings.sum ); url += '&lang=' + this_.chartSettings.lang; url += '&height=' + height; url += '&width=' + width; url += '&ticker=' + ticker; var chart = ''; chart += ''; this_.chartSettings.width = width; obj.html( chart ); }; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp/warrant-chart.php', { ticker: this_.ticker }) .then( function( response ) { this_.isLoading = false; if ( response.data.lang ) { this_.lang = response.data.lang; this_.chartSettings = response.data.chartSettings; this_.stock = response.data.stock; // Run the chart if ( this_.chartSettings ) { chart(); } } }); }; this_.setCompare = function( event ) { var obj = $( event.target ); var ticker = obj.data( 'ticker' ); for ( var i in this_.chartSettings.ticks ) { if ( this_.chartSettings.ticks[ i ].code === ticker ) { if ( obj.hasClass( 'active' ) ) { obj.removeClass( 'active' ); this_.chartSettings.ticks[ i ].isSet = false; } else { obj.addClass( 'active' ); this_.chartSettings.ticks[ i ].isSet = true; } } } chart( true ); }; this_.setChartPeriod = function( event ) { var obj = $( event.target ); var period = obj.data( 'period' ); var p = period.split( ',' )[ 0 ]; var q = period.split( ',' )[ 1 ]; this_.chartSettings.period = p; this_.chartSettings.qty = q; obj.parent().find( 'a' ).removeClass( 'active' ); obj.addClass( 'active' ); chart( true ); }; this_.$onInit = function() { loadData(); globalLib.googleAnalytics( $location.url() ); }; this_.$postLink = function() { $( window ).on( 'resize.warrantChart', function() { chart(); }); }; this_.$onDestroy = function() { $( window ).off( 'resize.warrantChart' ); }; }] }); globalApp.component( 'spFundChart', { templateUrl: '/components/sp/fund-chart.html', bindings: { ticker: '@' }, controllerAs: 'spFC', controller: [ '$http', '$location', function( $http, $location ) { var this_ = this; var chart = function( reload ) { var obj = $( '[data-role=fund-chart]' ); if ( obj.length !== 1 ) { return false; } var width = obj.width(); var height = this_.chartSettings.height; var ticker = this_.chartSettings.ticker; if ( width < 500 ) { height = this_.chartSettings.heightSmart; } if ( ! reload && this_.chartSettings.width == width ) { return true; } for ( var i in this_.chartSettings.ticks ) { if ( this_.chartSettings.ticks[ i ].isSet ) { ticker += ( ';' + this_.chartSettings.ticks[ i ].code ); } } var baseUrl = this_.chartSettings.histoUrl; obj.html( ' ' ); var url = ''; url += baseUrl; url += '?customer=' + this_.chartSettings.customer; url += '&period=' + this_.chartSettings.period; url += '&qty=' + this_.chartSettings.qty; url += '&vol=' + this_.chartSettings.vol; url += '&sum=' + ( width < 500 ? 0 : this_.chartSettings.sum ); url += '&lang=' + this_.chartSettings.lang; url += '&height=' + height; url += '&width=' + width; url += '&ticker=' + ticker; var chart = ''; chart += ''; this_.chartSettings.width = width; obj.html( chart ); }; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp/fund-chart.php', { ticker: this_.ticker }) .then( function( response ) { this_.isLoading = false; if ( response.data.lang ) { this_.lang = response.data.lang; this_.chartSettings = response.data.chartSettings; this_.stock = response.data.stock; // Run the chart if ( this_.chartSettings ) { chart(); } } }); }; this_.setCompare = function( event ) { var obj = $( event.target ); var ticker = obj.data( 'ticker' ); for ( var i in this_.chartSettings.ticks ) { if ( this_.chartSettings.ticks[ i ].code === ticker ) { if ( obj.hasClass( 'active' ) ) { obj.removeClass( 'active' ); this_.chartSettings.ticks[ i ].isSet = false; } else { obj.addClass( 'active' ); this_.chartSettings.ticks[ i ].isSet = true; } } } chart( true ); }; this_.setChartPeriod = function( event ) { var obj = $( event.target ); var period = obj.data( 'period' ); var p = period.split( ',' )[ 0 ]; var q = period.split( ',' )[ 1 ]; this_.chartSettings.period = p; this_.chartSettings.qty = q; obj.parent().find( 'a' ).removeClass( 'active' ); obj.addClass( 'active' ); chart( true ); }; this_.$onInit = function() { loadData(); globalLib.googleAnalytics( $location.url() ); }; this_.$postLink = function() { $( window ).on( 'resize.fundChart', function() { chart(); }); }; this_.$onDestroy = function() { $( window ).off( 'resize.fundChart' ); }; }] }); globalApp.component( 'spFundComposition', { templateUrl: '/components/sp/fund-composition.html', bindings: { ticker: '@' }, controllerAs: 'spFundComp', controller: [ '$http', '$location', function( $http, $location ) { var this_ = this; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp/fund-composition.php', { ticker: this_.ticker }) .then( function( response ) { this_.isLoading = false; if ( response.data.lang ) { this_.lang = response.data.lang; this_.stock = response.data.stock; } }); }; this_.$onInit = function() { loadData(); globalLib.googleAnalytics( $location.url() ); }; }] }); globalApp.component( 'spCommodityChart', { templateUrl: '/components/sp/commodity-chart.html', bindings: { ticker: '@' }, controllerAs: 'spCommChart', controller: [ '$http', '$location', function( $http, $location ) { var this_ = this; var chart = function( reload ) { var obj = $( '[data-role=comm-chart]' ); if ( obj.length !== 1 ) { return false; } var width = obj.width(); var height = this_.chartSettings.height; var ticker = this_.chartSettings.ticker; if ( width < 500 ) { height = this_.chartSettings.heightSmart; } if ( ! reload && this_.chartSettings.width == width ) { return true; } for ( var i in this_.chartSettings.ticks ) { if ( this_.chartSettings.ticks[ i ].isSet ) { ticker += ( ';' + this_.chartSettings.ticks[ i ].code ); } } var baseUrl = this_.chartSettings.histoUrl; obj.html( ' ' ); var url = ''; url += baseUrl; url += '?customer=' + this_.chartSettings.customer; url += '&period=' + this_.chartSettings.period; url += '&qty=' + this_.chartSettings.qty; url += '&vol=' + this_.chartSettings.vol; url += '&sum=' + ( width < 500 ? 0 : this_.chartSettings.sum ); url += '&lang=' + this_.chartSettings.lang; url += '&height=' + height; url += '&width=' + width; url += '&ticker=' + ticker; var chart = ''; chart += ''; this_.chartSettings.width = width; obj.html( chart ); }; var loadData = function() { this_.isLoading = true; $http .post( '/rest/sp/commodity-chart.php', { ticker: this_.ticker }) .then( function( response ) { this_.isLoading = false; if ( response.data.lang ) { this_.lang = response.data.lang; this_.chartSettings = response.data.chartSettings; this_.stock = response.data.stock; // Run the chart if ( this_.chartSettings ) { chart(); } } }); }; this_.setCompare = function( event ) { var obj = $( event.target ); var ticker = obj.data( 'ticker' ); for ( var i in this_.chartSettings.ticks ) { if ( this_.chartSettings.ticks[ i ].code === ticker ) { if ( obj.hasClass( 'active' ) ) { obj.removeClass( 'active' ); this_.chartSettings.ticks[ i ].isSet = false; } else { obj.addClass( 'active' ); this_.chartSettings.ticks[ i ].isSet = true; } } } chart( true ); }; this_.setChartPeriod = function( event ) { var obj = $( event.target ); var period = obj.data( 'period' ); var p = period.split( ',' )[ 0 ]; var q = period.split( ',' )[ 1 ]; this_.chartSettings.period = p; this_.chartSettings.qty = q; obj.parent().find( 'a' ).removeClass( 'active' ); obj.addClass( 'active' ); chart( true ); }; this_.$onInit = function() { loadData(); globalLib.googleAnalytics( $location.url() ); }; this_.$postLink = function() { $( window ).on( 'resize.commChart', function() { chart(); }); }; this_.$onDestroy = function() { $( window ).off( 'resize.commChart' ); }; }] }); globalApp.component( 'spWgSearch', { templateUrl: '/components/sp.v2/wg-search.html', bindings: { onSelect: '&', txtInfo: '<', type: '@' }, controller: [ '$http', '$timeout', // function( $http, $timeout ) { var this_ = this; this_.data = {}; this_.data.searched = null; this_.data.type = null; this_.flagShow = false; this_.isLoading = null; this_.stocks = null; this_.urls = null; this_.search = function() { if ( ! this_.data.searched || this_.data.searched.length < 2 ) { return; } this_.isLoading = true; $http .post( '/rest/sp.v2/wg-search.php', this_.data ) .then( function( response ) { this_.isLoading = false; this_.stocks = response.data.stocks; this_.urls = response.data.urls; } ); }; this_.setStock = function( stockObj ) { this_.onSelect( { data: stockObj } ); this_.data.searched = ''; this_.flagShow = false; this_.stocks = null; }; // ! Bindings are available only after init event this_.$onInit = function() { this_.data.type = this_.type; jQuery( 'body' ).on( 'click.wgSearch', function( event ) { if ( ! jQuery( event.target ).parents( '.wg-search' ).length ) { $timeout( function() { this_.flagShow = false; } ); } } ); }; this_.$onDestroy = function() { jQuery( 'body' ).off( 'click.wgSearch' ); }; } ] } ); globalApp.component( 'spCommunications', { templateUrl: '/components/sp/communications.html', controller: [ '$http', '$location', '$sce', function( $http, $location, $sce ) { var this_ = this; this_.isLoading = null; this_.lang = null; this_.urls = null; this_.toUrl = function( url ) { return $sce.trustAsResourceUrl( url ); }; var loadData = function() { this_.isLoading = true; $http // .post( '/rest/sp/communications.php' ) // .then( function( response ) { this_.isLoading = false; this_.lang = response.data.lang; this_.urls = response.data.urls; } ); }; this_.$onInit = function() { loadData(); }; } ] } ); globalApp.component( 'spCommsContent', { templateUrl: '/components/sp/comms-content.html', bindings: { id: '@', ticker: '@' }, controller: [ '$http', '$location', '$sce', function( $http, $location, $sce ) { var this_ = this; this_.isLoading = null; this_.lang = null; this_.stock = null; this_.urls = null; this_.toUrl = function( url ) { return $sce.trustAsResourceUrl( url ); }; var loadData = function() { this_.isLoading = true; $http // .post( '/rest/sp/comms-content.php', { id: this_.id, ticker: this_.ticker } ) // .then( function( response ) { this_.isLoading = false; this_.lang = response.data.lang; this_.stock = response.data.stock; this_.urls = response.data.urls; } ); }; this_.$onInit = function() { loadData(); }; } ] } ); globalApp.component( 'spCompanyComms', { templateUrl: '/components/sp/company-comms.html', bindings: { ticker: '@' }, controller: [ '$http', '$location', '$sce', function( $http, $location, $sce ) { var this_ = this; this_.isLoading = null; this_.lang = null; this_.stock = null; this_.urls = null; this_.toUrl = function( url ) { return $sce.trustAsResourceUrl( url ); }; var loadData = function() { this_.isLoading = true; $http // .post( '/rest/sp/company-comms.php', { ticker: this_.ticker } ) // .then( function( response ) { this_.isLoading = false; this_.lang = response.data.lang; this_.stock = response.data.stock; this_.urls = response.data.urls; } ); }; this_.$onInit = function() { loadData(); }; } ] } );