var cookiesVersion = 1;
var currentReloadSymbolsRequest = null;
var searchThread = null;
var supportedTickers = [];
var selectedTicker = null;
var noSymbolPage = 1;
var noSymbolPageCount = 0;
var noSymbolSYPerPage = 12;
var noSymbolPGDisplayed = 17;
var noSymbolPGStartMove = 2; // < (noSymbolPGDisplayed / 2) !
var tabMappings = {
analyst_ratings: 'AnalystRatings',
insider_transactions: 'InsiderTransactions',
hedge_fund_activity: 'HedgeFundActivity',
blogger_opinions: 'BloggerOpinions',
no_symbol: 'NoSymbol'
};
var currentTabKey = 'no_symbol';
var targetAjaxUrl = 'tipranksajax.php';
var targetTrackAjaxUrl = 'trackerax.php';
var symbolURL = 'https://secure.lightspeed.com/tipranks.php?s=symbol';
var infoWidgetMappings = {
analyst_ratings: '
TipRanks is a comprehensive investing tool that allows private investors and day traders to see the measured performance of anyone who provides financial advice.
Find the best performing analysts in each sector.
',
insider_transactions: 'TipRanks is a comprehensive investing tool that allows private investors and day traders to see the measured performance of anyone who provides financial advice.
Many investors follow institutional holdings and insider trading to gain valuable insights.
',
hedge_fund_activity: 'TipRanks is a comprehensive investing tool that allows private investors and day traders to see the measured performance of anyone who provides financial advice.
See Hedge Fund managers with the best portfolio returns. View their quarterly activity to maximize your returns.
TipRanks measures the performance of hedge funds based on information submitted to the SEC. Any hedge fund managing over $100M is required to submit a 13F form to the SEC which lists their current holdings at the end of each fiscal quarter. TipRanks uses this information to determine how each hedge fund performed in comparison to other hedge funds and to the S&P 500. Top hedge funds are determined by those that generate the highest return based on their stock portfolio.*Showing top performing hedge fund managers transactions measured over the past 3 years.
',
blogger_opinions: 'TipRanks is a comprehensive investing tool that allows private investors and day traders to see the measured performance of anyone who provides financial advice.
See who the best performing financial bloggers are in the market.
',
no_symbol: 'You haven\'t selected any symbol yet. This page shows all available symbols.
Please use search at the top to select desired symbol or select them from the list.
'
};
var sessionUp = function(){
var targetUrl = 'https://secure.lightspeed.com/pingsession.php';
$.ajax({
type: 'GET',
url: targetUrl,
dataType: 'html',
success: function(data){
// ok
},
error: function(jqXHR, textStatus, errorThrown){
window.location.href = 'index.php';
}
});
};
function number_format(number, decimals, dec_point, thousands_sep) {
var n = !isFinite(+number) ? 0 : +number,
prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,
dec = (typeof dec_point === 'undefined') ? '.' : dec_point,
toFixedFix = function (n, prec) {
// Fix for IE parseFloat(0.55).toFixed(0) = 0;
var k = Math.pow(10, prec);
return Math.round(n * k) / k;
},
s = (prec ? toFixedFix(n, prec) : Math.round(n)).toString().split('.');
if (s[0].length > 3) {
s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);
}
if ((s[1] || '').length < prec) {
s[1] = s[1] || '';
s[1] += new Array(prec - s[1].length + 1).join('0');
}
return s.join(dec);
}
function populateInfoWidgetContent(tabId)
{
$('div.tipranks-info').find('p').remove();
$('div.tipranks-info').prepend(infoWidgetMappings[tabId]);
}
$.maxZIndex = $.fn.maxZIndex = function(opt) {
var def = { inc: 10, group: "*" };
$.extend(def, opt);
var zmax = 0;
$(def.group).each(function() {
var cur = parseInt($(this).css('z-index'));
zmax = cur > zmax ? cur : zmax;
});
if (!this.jquery)
return zmax;
return this.each(function() {
zmax += def.inc;
$(this).css("z-index", zmax);
});
}
function stringifySidePercent(percent)
{
var r = '';
if(percent == 0){
r = '0% Neutral';
} else if(percent < 0){
r = '-' + Math.abs(percent) + '% Downside';
} else {
r = '+' + Math.abs(percent) + '% Upside';
}
return r;
}
function stringifySidePercentMain(percent)
{
var r = '';
if(percent == 0){
r = '';
} else if(percent < 0){
r = '▼(-' + Math.abs(percent) + '% Down.)';
} else {
r = '▲(' + Math.abs(percent) + '% Upside)';
}
return r;
}
function Ucfirst(string)
{
return string.charAt(0).toUpperCase() + string.slice(1);
}
function starGen(numOfStars)
{
var S = '';
var numS = Math.round(numOfStars);
var numSE = 5 - numS;
for(var r = 0; r < numS; r++){
S += '★';
}
for(var r = 0; r < numSE; r++){
S += '☆';
}
return S;
}
function holdingValue(price)
{
if(typeof(price) == 'undefined' || price == null) return '-';
if(price.length == 0) return '-';
var rPrice = parseFloat(price) / 1000000;
var fPrice = number_format(rPrice, 2, '.', ',');
var xPrice = '$' + fPrice + 'M';
return xPrice;
}
function parseBloggerDate(string)
{
var strC = string.split('-');
var ndate = strC[1] + '/' + strC[2] + '/' + strC[0];
return ndate;
}
function publishTickerTabAnalystRatingsGraphs()
{
$.ajax({
url: targetAjaxUrl,
type: 'post',
data: {
action: 'consensus_overview_stock',
ticker: selectedTicker
},
dataType: 'json',
beforeSend: function(){},
success: function(data){
if(data.length == 0){
var _analystConsensusHTML = '';
_analystConsensusHTML += 'No Data
';
$('#analyst_ratings div.ar-chart-1 div.smloader').replaceWith(_analystConsensusHTML);
} else {
var globalTargetAvgPrice = null;
var globalTargetLowPrice = null;
var globalTargetHighPrice = null;
var typeOfConsensus = 'all'; // temporary - make it like lst implementation
if(typeOfConsensus == 'all'){
var acStr = data.analystConsensus.consensus;
var acAnCnt = data.analystConsensus.numberOfRatings;
//console.log('all analyst target: ' + data.analystConsensus.priceTarget);
globalTargetAvgPrice = data.analystConsensus.priceTarget;
globalTargetLowPrice = data.analystConsensus.lowPriceTarget;
globalTargetHighPrice = data.analystConsensus.highPriceTarget;
} else {
var acStr = data.topAnalystConsensus.consensus;
var acAnCnt = data.topAnalystConsensus.numberOfRatings;
//console.log('best performing target: ' + data.topAnalystConsensus.priceTarget);
globalTargetAvgPrice = data.topAnalystConsensus.priceTarget;
globalTargetLowPrice = data.topAnalystConsensus.lowPriceTarget;
globalTargetHighPrice = data.topAnalystConsensus.highPriceTarget;
}
if(acStr == null) acStr = 'None';
var acStrLc = acStr.toLowerCase();
var acCLS = 'hold';
if(acStrLc.indexOf('buy') > -1){
acCLS = 'buy';
} else if(acStrLc.indexOf('sell') > -1){
acCLS = 'sell';
} else if(acStrLc.indexOf('none') > -1){
acCLS = 'none';
}
var acAnCntStr = 'Based on ' + acAnCnt + ' Analyst Ratings';
var _analystConsensusHTML = '';
_analystConsensusHTML += '' + acStr + '
';
_analystConsensusHTML += '' + acAnCntStr + '
';
$('#analyst_ratings div.ar-chart-1 div.smloader').replaceWith(_analystConsensusHTML);
$.ajax({
url: targetAjaxUrl,
type: 'post',
data: {
action: 'graph_analyst_price_target',
ticker: selectedTicker
},
dataType: 'json',
beforeSend: function(){},
success: function(data){
if(data){
data.priceTarget.low = globalTargetLowPrice;
data.priceTarget.high = globalTargetHighPrice;
var dataobj = {prices: data.prices, priceTarget: data.priceTarget, currentPrice: data.currentPrice};
var priceside_high = (((parseFloat(dataobj.priceTarget.high) / parseFloat(dataobj.currentPrice)) - 1) * 100).toFixed(2);
var priceside_avg = (((parseFloat(globalTargetAvgPrice) / parseFloat(dataobj.currentPrice)) - 1) * 100).toFixed(2);
var priceside_low = (((parseFloat(dataobj.priceTarget.low) / parseFloat(dataobj.currentPrice)) - 1) * 100).toFixed(2);
var cl_priceside_high = (priceside_high < 0) ? 'low' : 'high';
var cl_priceside_avg = (priceside_avg < 0) ? 'low' : 'high';
var cl_priceside_low = (priceside_low < 0) ? 'low' : 'high';
var grHTML = '';
grHTML += '';
grHTML += '
';
grHTML += '
';
grHTML += ' Avg, price target ';
grHTML += ' ';
grHTML += ' ';
grHTML += ' ';
grHTML += '
';
grHTML += '
';
grHTML += '
';
grHTML += '
';
grHTML += ' ';
grHTML += ' ';
grHTML += '
';
grHTML += ' High ';
grHTML += ' ';
grHTML += ' '+stringifySidePercent(priceside_high)+' ';
grHTML += ' ';
grHTML += '
';
grHTML += ' ';
grHTML += ' ';
grHTML += ' ';
grHTML += '
';
grHTML += ' Avg ';
grHTML += ' ';
grHTML += ' '+stringifySidePercent(priceside_avg)+' ';
grHTML += ' ';
grHTML += '
';
grHTML += ' ';
grHTML += ' ';
grHTML += ' ';
grHTML += '
';
grHTML += ' Low ';
grHTML += ' ';
grHTML += ' '+stringifySidePercent(priceside_low)+' ';
grHTML += ' ';
grHTML += '
';
grHTML += ' ';
grHTML += ' ';
grHTML += '
';
grHTML += '
';
if(globalTargetAvgPrice == null || globalTargetLowPrice == null || globalTargetHighPrice == null){
grHTML = '';
grHTML += '
';
grHTML += ' Currently not enough data available to determine analyst price target.';
grHTML += '
';
grHTML += '
';
$('#analyst_ratings div.ar-chart-2 div.smloader').replaceWith(grHTML);
} else {
$('#analyst_ratings div.ar-chart-2 div.smloader').replaceWith(grHTML);
d3AnalystPTGraph('analyst_dark_graph', dataobj, 'dark');
$('#apt_current_price').html('$' + globalTargetAvgPrice.toFixed(2));
$('#apt_current_side').html(stringifySidePercentMain(priceside_avg));
$('#apt_high_price').html('$' + dataobj.priceTarget.high.toFixed(2));
$('#apt_avg_price').html('$' + globalTargetAvgPrice.toFixed(2));
$('#apt_low_price').html('$' + dataobj.priceTarget.low.toFixed(2));
}
} else {
var _analystConsensusHTML = '';
_analystConsensusHTML += 'No Data
';
$('#analyst_ratings div.ar-chart-2 div.smloader').replaceWith(_analystConsensusHTML);
}
},
error: function(jqXHR, textStatus, errorThrown){
var _analystConsensusHTML = '';
_analystConsensusHTML += 'No Data
';
$('#analyst_ratings div.ar-chart-2 div.smloader').replaceWith(_analystConsensusHTML);
},
complete: function(){}
});
}
},
error: function(jqXHR, textStatus, errorThrown){
var _analystConsensusHTML = '';
_analystConsensusHTML += 'No Data
';
$('#analyst_ratings div.ar-chart-1 div.smloader').replaceWith(_analystConsensusHTML);
},
complete: function(){}
});
}
var publishAnalystRatings = function(tabId){
var analystTableContainer = $('#analyst_ratings div.ar-content');
analystTableContainer.empty().append('
');
$('#analyst_ratings div.ar-chart-1').html('
');
$('#analyst_ratings div.ar-chart-2').html('
');
$.ajax({
url: targetAjaxUrl,
type: 'post',
data: {
action: 'analyst_rating_stock',
ticker: selectedTicker
},
dataType: 'json',
beforeSend: function(){},
success: function(data){
if(data){
if(data.length > 0){
_gHTML = '';
_gHTML += '
Analyst Name
';
_gHTML += '
Firm
';
_gHTML += '
Ranking
';
_gHTML += '
Position
';
_gHTML += '
Price Target
';
_gHTML += '
Action
';
_gHTML += '
Date
';
_gHTML += '
Article
';
_gHTML += '
';
for(var t = 0; t < data.length; t++){
var a = data[t];
var analystName = a.analystName;
var firmName = a.firmName;
var numOfStars = a.numOfStars;
var recommendation = a.recommendation;
var priceTarget = a.priceTarget;
var analystAction = a.analystAction;
var recommendationDate = a.recommendationDate;
var articleTitle = a.articleTitle;
var articleSite = a.articleSite;
var url = a.url;
var showStars = starGen(numOfStars);
var lcRecommendation = recommendation.toLowerCase();
var showPrice = (priceTarget == null) ? '-' : '$' + parseFloat(priceTarget).toFixed(2);
var showanalystAction = (analystAction == null) ? '-' : analystAction;
var expertUID = a.expertUID;
var urlCL = '';
if(url == null){
urlCL = 'rwempty';
} else {
if(url == '' || (url.toLowerCase()).indexOf('tipranks') !== -1){
urlCL = 'rwempty';
}
}
_gHTML += '';
_gHTML += '
';
_gHTML += '
' + firmName + '
';
_gHTML += '
' + showStars + '
';
_gHTML += '
' + recommendation + '
';
_gHTML += '
' + showPrice + '
';
_gHTML += '
' + showanalystAction + '
';
_gHTML += '
' + recommendationDate + '
';
_gHTML += '
';
_gHTML += '
';
_gHTML += '
';
_gHTML += '
';
}
analystTableContainer.empty().append(_gHTML);
publishTickerTabAnalystRatingsGraphs();
} else {
analystTableContainer.empty();
_gHTML = '';
_gHTML += '
Nothing to display here
';
_gHTML += '
No data to display for ' + selectedTicker + '.
';
_gHTML += '
';
analystTableContainer.append(_gHTML);
}
} else {
analystTableContainer.empty();
_gHTML = '';
_gHTML += '
Nothing to display here
';
_gHTML += '
No data to display for ' + selectedTicker + '.
';
_gHTML += '
';
analystTableContainer.append(_gHTML);
}
},
error: function(jqXHR, textStatus, errorThrown){
analystTableContainer.empty();
_gHTML = '';
_gHTML += '
Nothing to display here
';
_gHTML += '
Please try again later.
';
_gHTML += '
';
analystTableContainer.append(_gHTML);
},
complete: function(){}
});
// analyst more
$('body').off('click', 'a.anrAnName').on('click', 'a.anrAnName', function(e){
e.preventDefault();
var expertUID = $(this).attr('rel');
$('div.subsymanalst').remove();
$(this).parent().parent().after('');
$(document).scrollTop($(this).parent().parent().offset().top - 70);
var analystContainerRow = $(this).parent().parent().next();
$.ajax({
url: targetAjaxUrl,
type: 'post',
data: {
action: 'analyst_expert',
expert: expertUID
},
dataType: 'json',
beforeSend: function(){},
success: function(data){
analystContainerRow.empty();
if(data){
if(data.profile){
var analystName = data.profile.analystName;
var firmName = data.profile.firmName;
var stars = starGen(data.profile.numOfStars);
var analystRank = data.profile.analystRank;
var numberOfRankedExperts = data.profile.numberOfRankedExperts;
var _analystHTML = '';
_analystHTML += '';
_analystHTML += '
';
_analystHTML += '
' + analystName + ', Wall Street Analyst at ' + firmName + ' ';
//_analystHTML += '
Wall Street Analyst at ' + firmName + '
';
_analystHTML += '
';
_analystHTML += '
';
//_analystHTML += '
Rating: ' + stars + '
';
//_analystHTML += '
Ranked #' + analystRank + ' out of ' + numberOfRankedExperts + ' Analysts
';
_analystHTML += '
';
_analystHTML += '
';
_analystHTML += '
';
_analystHTML += 'Rating History ';
_analystHTML += '';
if(data.ratinghistory.length > 0){
_analystHTML += '
';
_analystHTML += '
Company Name
';
_analystHTML += '
Operation
';
_analystHTML += '
Price Target
';
_analystHTML += '
Cur. Price
';
_analystHTML += '
Status
';
_analystHTML += '
Date
';
_analystHTML += '
Article
';
_analystHTML += '
';
}
for(var i = 0; i < data.ratinghistory.length; i++){
var a = data.ratinghistory[i];
var companyName = a.companyName;
var operation = a.operation;
var lcOperation = operation.toLowerCase();
var priceTarget = (a.priceTarget == null) ? '-' : ('$' + parseFloat(a.priceTarget));
var stockTicker = a.stockTicker;
var sector = a.sector;
var status = a.status;
var dt = (status == 'Open') ? a.openDate : a.closeDate;
var ln = (status == 'Open') ? a.openUrl : a.closeUrl;
var lnt = analystName + ' on (' + stockTicker + ') ' + companyName;
var tickerUrl = symbolURL + '#' + stockTicker;
var urlCL = '';
if(ln == null){
urlCL = 'rwempty';
} else {
if(ln == '' || (ln.toLowerCase()).indexOf('tipranks') !== -1){
urlCL = 'rwempty';
}
}
var dtSPL = dt.split('/');
var tdt = new Date(dtSPL[2], dtSPL[0]-1, dtSPL[1], 23, 59, 59);
var wdt = jQuery.timeago(tdt);
var targetNetChange = 0;
if(a.priceTarget != null){
if(a.currentPrice != null){
targetNetChange = parseFloat(a.priceTarget) - parseFloat(a.currentPrice);
}
}
var targetPercentChange = 0;
if(a.currentPrice != null){
if(targetNetChange != 0){
targetPercentChange = targetNetChange / parseFloat(a.currentPrice);
targetPercentChange = Math.round(targetPercentChange * 100); // Math.round(targetPercentChange * 100) / 100;
}
}
var position = '-';
var positionCLS = '';
if(targetPercentChange < 0){
position = '▼(-' + Math.abs(targetPercentChange) + '% Downside)';
positionCLS = 'downside';
} else if(targetPercentChange > 0){
position = '▲(' + Math.abs(targetPercentChange) + '% Upside)';
positionCLS = 'upside';
} else {
position = '-';
}
var stringCurrentPrice = '-';
if(a.currentPrice != null){
stringCurrentPrice = '$' + (Math.round(parseFloat(a.currentPrice) * 100) / 100);
}
_analystHTML += '
';
_analystHTML += '
';
_analystHTML += '
' + operation + '
';
_analystHTML += '
' + priceTarget + ' ' + position + '
';
_analystHTML += '
' + stringCurrentPrice + '
';
_analystHTML += '
' + status + '
';
_analystHTML += '
' + wdt + '
';
_analystHTML += '
';
_analystHTML += '
';
}
_analystHTML += '
';
_analystHTML += 'Covered Stocks ';
_analystHTML += '';
if(data.profile.stocks.length > 0){
_analystHTML += '
';
_analystHTML += '
Symbol
';
_analystHTML += '
Company
';
_analystHTML += '
ISIN
';
_analystHTML += '
Sector
';
_analystHTML += '
';
}
for(var i = 0; i < data.profile.stocks.length; i++){
var b = data.profile.stocks[i];
var bticker = b.ticker;
var bcompanyName = b.companyName;
var bsector = b.sector;
var bisin = b.isin;
var bsymUrl = symbolURL + '#' + bticker;
_analystHTML += '
';
_analystHTML += '
';
_analystHTML += '
' + bcompanyName + '
';
_analystHTML += '
' + bisin + '
';
_analystHTML += '
' + bsector + '
';
_analystHTML += '
';
}
_analystHTML += '
';
analystContainerRow.append(_analystHTML);
analystContainerRow.addClass('expandedbottom');
} else {
analystContainerRow.empty();
_gHTML = '';
_gHTML += '
Nothing to display here
';
_gHTML += '
No data available at this time - please try again later.
';
_gHTML += '
';
analystContainerRow.append(_gHTML);
}
} else {
analystContainerRow.empty();
_gHTML = '';
_gHTML += '
Nothing to display here
';
_gHTML += '
No data available at this time - please try again later.
';
_gHTML += '
';
analystContainerRow.append(_gHTML);
}
},
error: function(jqXHR, textStatus, errorThrown){
analystContainerRow.empty();
_gHTML = '';
_gHTML += '
Nothing to display here
';
_gHTML += '
No data available at this time - please try again later.
';
_gHTML += '
';
analystContainerRow.append(_gHTML);
},
complete: function(){}
});
});
// link symbol deep
$('body').off('click', 'div.analyst-cn a').on('click', 'div.analyst-cn a', function(e){
e.preventDefault();
var symbol = $(this).text();
window.location.hash = symbol;
$('html, body').scrollTop(0);
selectSymbol(symbol);
});
$('body').off('click', 'div.analyst-sy a').on('click', 'div.analyst-sy a', function(e){
e.preventDefault();
var symbol = $(this).text();
window.location.hash = symbol;
$('html, body').scrollTop(0);
selectSymbol(symbol);
});
// link disclaimer
$('body').off('click', 'div.ar-artcl a').on('click', 'div.ar-artcl a', function(e){
e.preventDefault();
var linkLink = $(this).attr('href');
var linkTitle = $(this).attr('rel');
if(linkLink == '' || linkLink == 'null' || linkLink == 'undefined' || linkLink == 'NaN' || linkTitle == null || linkTitle == 'null' || linkTitle == '' || (linkLink.toLowerCase()).indexOf('tipranks') !== -1){
// skip it
} else {
$('body').append('
');
$("#readwhylink_disclaimerbackground").maxZIndex({ inc: 5 });
$("#readwhylink_disclaimerbackground").off('click').on('click', function(e){
$("#readwhylink_disclaimerwin").remove();
$("#readwhylink_disclaimerbackground").remove();
});
var _disclaimerlinkshtml = '';
_disclaimerlinkshtml += '';
_disclaimerlinkshtml += '
' + linkTitle + '
';
_disclaimerlinkshtml += '
You are leaving the web site of Lightspeed and entering a third party web site not affiliated with Lightspeed or any of its affiliates ("Lightspeed"). No information contained in the linked site has been endorsed or approved by Lightspeed and Lightspeed is not responsible for the content. No information contained in the linked site constitutes a recommendation by Lightspeed to buy, sell or hold any security, financial product or instrument discussed therein.
';
_disclaimerlinkshtml += '
The link is being provided for your information only and no information obtained through the linked site should be construed as an offer, or a solicitation of an offer, to buy or sell securities by Lightspeed.
';
_disclaimerlinkshtml += '
By making available this link, Lightspeed does not offer or provide any investment advice or opinion regarding the nature, potential, value, suitability or profitability of any particular security, portfolio of securities, transaction or investment strategy, and you shall be fully responsible for any investment decisions you make, and such decisions will be based solely on your evaluation of your financial circumstances, investment objectives, risk tolerance, and liquidity needs.
';
_disclaimerlinkshtml += '
';
_disclaimerlinkshtml += 'GO! ';
_disclaimerlinkshtml += 'Cancel ';
_disclaimerlinkshtml += '
';
_disclaimerlinkshtml += '
';
$('body').append(_disclaimerlinkshtml);
$('#readwhylink_disclaimerwin span.linkagreebutton').off('click').on('click', function(e){
window.open(linkLink);
$("#readwhylink_disclaimerwin").remove();
$("#readwhylink_disclaimerbackground").remove();
});
$('#readwhylink_disclaimerwin span.linkdisagreebutton').off('click').on('click', function(e){
$("#readwhylink_disclaimerwin").remove();
$("#readwhylink_disclaimerbackground").remove();
});
$("#readwhylink_disclaimerwin").maxZIndex({ inc: 5 });
}
});
// close analyst boxes
$('body').off('click', 'a.analyst-info-close').on('click', 'a.analyst-info-close', function(e){
e.preventDefault();
$('div.subsymanalst').remove();
});
// recommendation links
$('body').off('click', 'a.analyst-article').on('click', 'a.analyst-article', function(e){
e.preventDefault();
var linkLink = $(this).attr('href');
var linkTitle = $(this).attr('rel');
if(linkLink == '' || linkLink == 'null' || linkLink == 'undefined' || linkLink == 'NaN' || linkTitle == null || linkTitle == 'null' || linkTitle == '' || (linkLink.toLowerCase()).indexOf('tipranks') !== -1){
// skip it
} else {
$('body').append('
');
$("#readwhylink_disclaimerbackground").maxZIndex({ inc: 5 });
$("#readwhylink_disclaimerbackground").off('click').on('click', function(e){
$("#readwhylink_disclaimerwin").remove();
$("#readwhylink_disclaimerbackground").remove();
});
var _disclaimerlinkshtml = '';
_disclaimerlinkshtml += '';
_disclaimerlinkshtml += '
' + linkTitle + '
';
_disclaimerlinkshtml += '
You are leaving the web site of Lightspeed and entering a third party web site not affiliated with Lightspeed or any of its affiliates ("Lightspeed"). No information contained in the linked site has been endorsed or approved by Lightspeed and Lightspeed is not responsible for the content. No information contained in the linked site constitutes a recommendation by Lightspeed to buy, sell or hold any security, financial product or instrument discussed therein.
';
_disclaimerlinkshtml += '
The link is being provided for your information only and no information obtained through the linked site should be construed as an offer, or a solicitation of an offer, to buy or sell securities by Lightspeed.
';
_disclaimerlinkshtml += '
By making available this link, Lightspeed does not offer or provide any investment advice or opinion regarding the nature, potential, value, suitability or profitability of any particular security, portfolio of securities, transaction or investment strategy, and you shall be fully responsible for any investment decisions you make, and such decisions will be based solely on your evaluation of your financial circumstances, investment objectives, risk tolerance, and liquidity needs.
';
_disclaimerlinkshtml += '
';
_disclaimerlinkshtml += 'GO! ';
_disclaimerlinkshtml += 'Cancel ';
_disclaimerlinkshtml += '
';
_disclaimerlinkshtml += '
';
$('body').append(_disclaimerlinkshtml);
$('#readwhylink_disclaimerwin span.linkagreebutton').off('click').on('click', function(e){
window.open(linkLink);
$("#readwhylink_disclaimerwin").remove();
$("#readwhylink_disclaimerbackground").remove();
});
$('#readwhylink_disclaimerwin span.linkdisagreebutton').off('click').on('click', function(e){
$("#readwhylink_disclaimerwin").remove();
$("#readwhylink_disclaimerbackground").remove();
});
$("#readwhylink_disclaimerwin").maxZIndex({ inc: 5 });
}
});
};
function publishTickerTabInsiderActivityGraphs(transObj, insiderYearlyTrans)
{
$('#gauge_hedgefunds_activity svg').remove();
$('#gauge_insider_activity svg').remove();
// skip showing summ for transactions (lst line below graphs)
/*var grHTML = '';
grHTML += '';
grHTML += ' ';
grHTML += ' ';
grHTML += ' Total Transactions last 12 months.';
grHTML += ' ';
grHTML += '
';
grHTML += '';
grHTML += ' ';
grHTML += ' ';
grHTML += ' Informative Transactions.';
grHTML += ' ';
grHTML += '
';
grHTML += '';
grHTML += ' ';
grHTML += ' ';
grHTML += ' Uninformative Transactions.';
grHTML += ' ';
grHTML += '
';
$('#insider_transactions div.it-chart-2 div.smloader').replaceWith(grHTML);*/
$.ajax({
url: targetAjaxUrl,
type: 'post',
data: {
action: 'consensus_overview_stock',
ticker: selectedTicker
},
dataType: 'json',
beforeSend: function(){},
success: function(data){
if(data){
if(data.insiderConsensus){
var consensus = data.insiderConsensus.consensus;
var numberOfTransactions = data.insiderConsensus.numberOfTransactions;
var sectorAvgSignalStrength = data.insiderConsensus.sectorAvgSignalStrength;
var signalStrength = data.insiderConsensus.signalStrength;
if(numberOfTransactions == null || !numberOfTransactions || numberOfTransactions == '') numberOfTransactions = 0;
if(signalStrength == null || !signalStrength || signalStrength == '') signalStrength = 0;
var clS = 'neutral';
if(consensus == 'Negative Sentiment') clS = 'negative';
if(consensus == 'Positive Sentiment') clS = 'positive';
var numTransBaseText = 'Based on ' + numberOfTransactions + ' Insider trans.';
if(consensus == null || !consensus || consensus == ''){
clS = 'neutral';
numTransBaseText = 'No data available for ' + selectedTicker;
consensus = 'Not available';
}
var grHTML = '';
grHTML += '';
grHTML += '
' + consensus + '
';
grHTML += '
' + numTransBaseText + '
';
grHTML += '
';
grHTML += '
';
$('#insider_transactions div.it-chart-2 div.smloader').replaceWith(grHTML);
d3Gauge('#gauge_insider_activity', signalStrength, sectorAvgSignalStrength);
$.ajax({
url: targetAjaxUrl,
type: 'post',
data: {
action: 'graph_insider_transactions',
ticker: selectedTicker
},
dataType: 'json',
beforeSend: function(){},
success: function(data){
if(data){
var areThereCounts = 0;
for(var z = 0; z < insiderYearlyTrans.length; z++){
if(parseFloat(insiderYearlyTrans[z].buyCount) > 0 || parseFloat(insiderYearlyTrans[z].sellCount) > 0) areThereCounts++;
}
if(areThereCounts > 0){
data['corporateInsiderTransactions'] = insiderYearlyTrans;
var grHTML = '';
grHTML += '
';
$('#insider_transactions div.it-chart-1 div.smloader').replaceWith(grHTML);
d3InsidersFINGraph('div.insiders_graph_1', data);
} else {
var grHTML = '';
grHTML += 'No data available for '+selectedTicker+'
';
$('#insider_transactions div.it-chart-1 div.smloader').replaceWith(grHTML);
}
} else {
var grHTML = '';
grHTML += 'No data available for '+selectedTicker+'
';
$('#insider_transactions div.it-chart-1 div.smloader').replaceWith(grHTML);
}
},
error: function(jqXHR, textStatus, errorThrown){
var grHTML = '';
grHTML += 'No data available for '+selectedTicker+'
';
$('#insider_transactions div.it-chart-1 div.smloader').replaceWith(grHTML);
},
complete: function(){}
});
}
}
},
error: function(jqXHR, textStatus, errorThrown){},
complete: function(){}
});
}
var publishInsiderTransactions = function(tabId){
var insidersTableContainer = $('#insider_transactions div.it-content');
insidersTableContainer.empty().append('
');
$('#insider_transactions div.it-chart-1').html('
');
$('#insider_transactions div.it-chart-2').html('
');
$.ajax({
url: targetAjaxUrl,
type: 'post',
data: {
action: 'insider_activity',
ticker: selectedTicker
},
dataType: 'json',
beforeSend: function(){},
success: function(data){
if(data){
if(data.transactions){
if(data.transactions.length > 0){
_gHTML = '';
_gHTML += '
Insider Name
';
_gHTML += '
Position at ' + selectedTicker + '
';
_gHTML += '
Rank
';
_gHTML += '
Transaction
';
_gHTML += '
Amount
';
_gHTML += '
Date
';
_gHTML += '
';
for(var t = 0; t < data.transactions.length; t++){
var a = data.transactions[t];
var insiderName = a.insiderName;
var position = a.position;
var stars = a.stars;
var transaction = a.transaction;
var amount = a.amount;
var date = a.date;
var showPos = (position == null) ? '' : position;
var showStars = starGen(stars);
var showTrans = Ucfirst(transaction);
var showAmount = (amount == null) ? '-' : '$' + number_format(amount, 2, '.', ',');
var expertUID = a.expertUid;
_gHTML += '';
_gHTML += '
';
_gHTML += '
' + showPos + '
';
_gHTML += '
' + showStars + '
';
_gHTML += '
' + showTrans + '
';
_gHTML += '
' + showAmount + '
';
_gHTML += '
' + date + '
';
_gHTML += '
';
}
insidersTableContainer.empty().append(_gHTML);
var insiderYearlyTrans = data.yearlyInsiderTransactions;
var transObj = {
total: parseInt(data.transactions.length),
informative: parseInt(data.discretionaryTransactions),
uninformative: parseInt(data.uninformativeTransactions)
};
publishTickerTabInsiderActivityGraphs(transObj, insiderYearlyTrans);
} else {
insidersTableContainer.empty();
_gHTML = '';
_gHTML += '
Nothing to display here
';
_gHTML += '
No data to display for ' + selectedTicker + '.
';
_gHTML += '
';
insidersTableContainer.append(_gHTML);
var insiderYearlyTrans = data.yearlyInsiderTransactions;
var transObj = {
total: parseInt(data.transactions.length),
informative: parseInt(data.discretionaryTransactions),
uninformative: parseInt(data.uninformativeTransactions)
};
publishTickerTabInsiderActivityGraphs(transObj, insiderYearlyTrans);
}
} else {
insidersTableContainer.empty();
_gHTML = '';
_gHTML += '
Nothing to display here
';
_gHTML += '
No data to display for ' + selectedTicker + '.
';
_gHTML += '
';
insidersTableContainer.append(_gHTML);
}
} else {
insidersTableContainer.empty();
_gHTML = '';
_gHTML += '
Nothing to display here
';
_gHTML += '
No data to display for ' + selectedTicker + '.
';
_gHTML += '
';
insidersTableContainer.append(_gHTML);
}
},
error: function(jqXHR, textStatus, errorThrown){
insidersTableContainer.empty();
_gHTML = '';
_gHTML += '
Nothing to display here
';
_gHTML += '
Please try again later.
';
_gHTML += '
';
insidersTableContainer.append(_gHTML);
},
complete: function(){}
});
// link symbol deep
$('body').off('click', 'div.analyst-cn a').on('click', 'div.analyst-cn a', function(e){
e.preventDefault();
var symbol = $(this).text();
window.location.hash = symbol;
$('html, body').scrollTop(0);
selectSymbol(symbol);
});
// analyst more
$('body').off('click', 'a.intAnName').on('click', 'a.intAnName', function(e){
e.preventDefault(); // do nothing for now
var expertUID = $(this).attr('rel');
var expertFullName = $(this).text();
$('div.subsymanalst').remove();
$(this).parent().parent().after('');
$(document).scrollTop($(this).parent().parent().offset().top - 70);
var analystContainerRow = $(this).parent().parent().next();
$.ajax({
url: targetAjaxUrl,
type: 'post',
data: {
action: 'analyst_expert',
expert: expertUID
},
dataType: 'json',
beforeSend: function(){},
success: function(data){
analystContainerRow.empty();
if(data){
if(data.profile){
var analystName = (typeof data.profile.analystName == 'undefined') ? expertFullName : data.profile.analystName;
var firmName = (typeof data.profile.firmName == 'undefined') ? '' : data.profile.firmName;
var stars = (typeof data.profile.numOfStars == 'undefined') ? '' : starGen(data.profile.numOfStars);
var analystRank = (typeof data.profile.analystRank == 'undefined') ? '' : data.profile.analystRank;
var numberOfRankedExperts = (typeof data.profile.numberOfRankedExperts == 'undefined') ? '' : data.profile.numberOfRankedExperts;
var wallAT = (firmName == '') ? '' : ', Wall Street Analyst at ' + firmName + ' ';
var _analystHTML = '';
_analystHTML += '';
_analystHTML += '
';
_analystHTML += '
' + analystName + wallAT + ' ';
//_analystHTML += '
Wall Street Analyst at ' + firmName + '
';
_analystHTML += '
';
_analystHTML += '
';
//_analystHTML += '
Rating: ' + stars + '
';
//_analystHTML += '
Ranked #' + analystRank + ' out of ' + numberOfRankedExperts + ' Analysts
';
_analystHTML += '
';
_analystHTML += '
';
_analystHTML += '
';
if(data.ratinghistory.length > 0){
_analystHTML += 'Rating History ';
_analystHTML += '';
_analystHTML += '
';
_analystHTML += '
Company Name
';
_analystHTML += '
Operation
';
_analystHTML += '
Price Target
';
_analystHTML += '
Cur. Price
';
_analystHTML += '
Status
';
_analystHTML += '
Date
';
_analystHTML += '
Article
';
_analystHTML += '
';
for(var i = 0; i < data.ratinghistory.length; i++){
var a = data.ratinghistory[i];
var companyName = a.companyName;
var operation = a.operation;
var lcOperation = operation.toLowerCase();
var priceTarget = (a.priceTarget == null) ? '-' : ('$' + parseFloat(a.priceTarget));
var stockTicker = a.stockTicker;
var sector = a.sector;
var status = a.status;
var dt = (status == 'Open') ? a.openDate : a.closeDate;
var ln = (status == 'Open') ? a.openUrl : a.closeUrl;
var lnt = analystName + ' on (' + stockTicker + ') ' + companyName;
var tickerUrl = symbolURL + '#' + stockTicker;
var urlCL = '';
if(ln == null){
urlCL = 'rwempty';
} else {
if(ln == '' || (ln.toLowerCase()).indexOf('tipranks') !== -1){
urlCL = 'rwempty';
}
}
var dtSPL = dt.split('/');
var tdt = new Date(dtSPL[2], dtSPL[0]-1, dtSPL[1], 23, 59, 59);
var wdt = jQuery.timeago(tdt);
var targetNetChange = 0;
if(a.priceTarget != null){
if(a.currentPrice != null){
targetNetChange = parseFloat(a.priceTarget) - parseFloat(a.currentPrice);
}
}
var targetPercentChange = 0;
if(a.currentPrice != null){
if(targetNetChange != 0){
targetPercentChange = targetNetChange / parseFloat(a.currentPrice);
targetPercentChange = Math.round(targetPercentChange * 100); // Math.round(targetPercentChange * 100) / 100;
}
}
var position = '-';
var positionCLS = '';
if(targetPercentChange < 0){
position = '▼(-' + Math.abs(targetPercentChange) + '% Downside)';
positionCLS = 'downside';
} else if(targetPercentChange > 0){
position = '▲(' + Math.abs(targetPercentChange) + '% Upside)';
positionCLS = 'upside';
} else {
position = '-';
}
var stringCurrentPrice = '-';
if(a.currentPrice != null){
stringCurrentPrice = '$' + (Math.round(parseFloat(a.currentPrice) * 100) / 100);
}
_analystHTML += '
';
_analystHTML += '
';
_analystHTML += '
' + operation + '
';
_analystHTML += '
' + priceTarget + ' ' + position + '
';
_analystHTML += '
' + stringCurrentPrice + '
';
_analystHTML += '
' + status + '
';
_analystHTML += '
' + wdt + '
';
_analystHTML += '
';
_analystHTML += '
';
}
_analystHTML += '
';
} else {
_analystHTML += 'No Rating History Data Available ';
}
if(data.profile.stocks){
_analystHTML += 'Covered Stocks ';
_analystHTML += '';
if(data.profile.stocks.length > 0){
_analystHTML += '
';
_analystHTML += '
Symbol
';
_analystHTML += '
Company
';
_analystHTML += '
ISIN
';
_analystHTML += '
Sector
';
_analystHTML += '
';
}
for(var i = 0; i < data.profile.stocks.length; i++){
var b = data.profile.stocks[i];
var bticker = b.ticker;
var bcompanyName = b.companyName;
var bsector = b.sector;
var bisin = b.isin;
var bsymUrl = symbolURL + '#' + bticker;
_analystHTML += '
';
_analystHTML += '
';
_analystHTML += '
' + bcompanyName + '
';
_analystHTML += '
' + bisin + '
';
_analystHTML += '
' + bsector + '
';
_analystHTML += '
';
}
_analystHTML += '
';
}
analystContainerRow.append(_analystHTML);
analystContainerRow.addClass('expandedbottom');
} else {
analystContainerRow.empty();
_gHTML = '';
_gHTML += '
Nothing to display here
';
_gHTML += '
No data available at this time - please try again later.
';
_gHTML += '
';
analystContainerRow.append(_gHTML);
}
} else {
analystContainerRow.empty();
_gHTML = '';
_gHTML += '
Nothing to display here
';
_gHTML += '
No data available at this time - please try again later.
';
_gHTML += '
';
analystContainerRow.append(_gHTML);
}
},
error: function(jqXHR, textStatus, errorThrown){
analystContainerRow.empty();
_gHTML = '';
_gHTML += '
Nothing to display here
';
_gHTML += '
No data available at this time - please try again later.
';
_gHTML += '
';
analystContainerRow.append(_gHTML);
},
complete: function(){}
});
});
// close analyst boxes
$('body').off('click', 'a.analyst-info-close').on('click', 'a.analyst-info-close', function(e){
e.preventDefault();
$('div.subsymanalst').remove();
});
// recommendation links
$('body').off('click', 'a.analyst-article').on('click', 'a.analyst-article', function(e){
e.preventDefault();
var linkLink = $(this).attr('href');
var linkTitle = $(this).attr('rel');
if(linkLink == '' || linkLink == 'null' || linkLink == 'undefined' || linkLink == 'NaN' || linkTitle == null || linkTitle == 'null' || linkTitle == '' || (linkLink.toLowerCase()).indexOf('tipranks') !== -1){
// skip it
} else {
$('body').append('
');
$("#readwhylink_disclaimerbackground").maxZIndex({ inc: 5 });
$("#readwhylink_disclaimerbackground").off('click').on('click', function(e){
$("#readwhylink_disclaimerwin").remove();
$("#readwhylink_disclaimerbackground").remove();
});
var _disclaimerlinkshtml = '';
_disclaimerlinkshtml += '';
_disclaimerlinkshtml += '
' + linkTitle + '
';
_disclaimerlinkshtml += '
You are leaving the web site of Lightspeed and entering a third party web site not affiliated with Lightspeed or any of its affiliates ("Lightspeed"). No information contained in the linked site has been endorsed or approved by Lightspeed and Lightspeed is not responsible for the content. No information contained in the linked site constitutes a recommendation by Lightspeed to buy, sell or hold any security, financial product or instrument discussed therein.
';
_disclaimerlinkshtml += '
The link is being provided for your information only and no information obtained through the linked site should be construed as an offer, or a solicitation of an offer, to buy or sell securities by Lightspeed.
';
_disclaimerlinkshtml += '
By making available this link, Lightspeed does not offer or provide any investment advice or opinion regarding the nature, potential, value, suitability or profitability of any particular security, portfolio of securities, transaction or investment strategy, and you shall be fully responsible for any investment decisions you make, and such decisions will be based solely on your evaluation of your financial circumstances, investment objectives, risk tolerance, and liquidity needs.
';
_disclaimerlinkshtml += '
';
_disclaimerlinkshtml += 'GO! ';
_disclaimerlinkshtml += 'Cancel ';
_disclaimerlinkshtml += '
';
_disclaimerlinkshtml += '
';
$('body').append(_disclaimerlinkshtml);
$('#readwhylink_disclaimerwin span.linkagreebutton').off('click').on('click', function(e){
window.open(linkLink);
$("#readwhylink_disclaimerwin").remove();
$("#readwhylink_disclaimerbackground").remove();
});
$('#readwhylink_disclaimerwin span.linkdisagreebutton').off('click').on('click', function(e){
$("#readwhylink_disclaimerwin").remove();
$("#readwhylink_disclaimerbackground").remove();
});
$("#readwhylink_disclaimerwin").maxZIndex({ inc: 5 });
}
});
};
function publishHedgeFundActivityGraphs(){
$.ajax({
url: targetAjaxUrl,
type: 'post',
data: {
action: 'consensus_overview_stock',
ticker: selectedTicker
},
dataType: 'json',
beforeSend: function(){},
success: function(data){
if(data){
if(data.hedgeFundConsensus){
var consensus = data.hedgeFundConsensus.consensus;
var holdingsChange = data.hedgeFundConsensus.holdingsChange;
var numberOfHedgeFunds = data.hedgeFundConsensus.numberOfHedgeFunds;
var sentiment = data.hedgeFundConsensus.sentiment;
var clS = 'neutral';
if(consensus == 'Negative Sentiment') clS = 'negative';
if(consensus == 'Positive Sentiment') clS = 'positive';
var grHTML = '';
grHTML += '';
grHTML += '
' + consensus + '
';
grHTML += '
Based on the activity of ' + numberOfHedgeFunds + ' HF in the last Qr.
';
grHTML += '
';
grHTML += '
';
$('#hedge_fund_activity div.hfa-chart-2').html(grHTML);
d3Gauge('#gauge_hedgefunds_activity', sentiment);
if(holdingsChange){
var HFchangeMil = (parseFloat(holdingsChange) / 1000000).toFixed(2);
var fullHFsentence = '';
if(HFchangeMil < 0){
fullHFsentence = '▼ Hedge Funds Decreased by '+Math.abs(HFchangeMil)+'M Shares in the Last Quarter';
} else if(HFchangeMil > 0){
fullHFsentence = '▲ Hedge Funds Increased by '+Math.abs(HFchangeMil)+'M Shares in the Last Quarter';
} else {
fullHFsentence = 'No change for '+selectedTicker+' in the Last Quarter';
}
} else {
var fullHFsentence = 'No data for '+selectedTicker;
}
$('#hedge_fund_change_txcontainer').html(fullHFsentence);
// load big hedge funds graph
$.ajax({
url: targetAjaxUrl,
type: 'post',
data: {
action: 'graph_hedgefundsholdings_quarter',
ticker: selectedTicker
},
dataType: 'json',
beforeSend: function(){},
success: function(data){
if(data){
if(data.currentPrice){
if(data.prices){
if(data.hedgeFundHoldings){
//console.log(data);
$('#hedge_fund_activity div.hfa-chart-1').html('
');
d3HedgeFundsFINGraph('div.hedgefund_graph_1', data);
/*var hfHTML = '';
hfHTML += '
';
$('#ticker_hedgefund_activity_holdings_per_quarter_blck div.innerc div.innercc div.smloader').replaceWith(hfHTML);
d3HedgeFundsFINGraph('div.hedgefund_graph_1', data);*/
}
}
}
}
},
error: function(jqXHR, textStatus, errorThrown){},
complete: function(){}
});
}
}
},
error: function(jqXHR, textStatus, errorThrown){},
complete: function(){}
});
}
var publishHedgeFundActivity = function(tabId){
$('#gauge_hedgefunds_activity svg').remove();
$('#gauge_insider_activity svg').remove();
$('#hedge_fund_change_txcontainer').html('');
//var dev_cookie = Cookies.get('dev_cookie');
//if(typeof dev_cookie == 'undefined'){
// resource disabled for production
//} else {
// DELETE ME (insert this in template file!!!!!!!!!!!!!!!!!!!!!!!)
var _inject = '';
_inject += '
Trend
';
_inject += '
';
_inject += '
';
_inject += '';
_inject += '
Chart 1
';
_inject += '
';
_inject += '
';
_inject += '
';
$('#hedge_fund_activity').empty().append(_inject);
// DELETE ME
var hfTableContainer = $('#hedge_fund_activity div.hfa-content');
hfTableContainer.empty().append('
');
$('#hedge_fund_activity div.hfa-chart-1').html('
');
$('#hedge_fund_activity div.hfa-chart-2').html('
');
$.ajax({
url: targetAjaxUrl,
type: 'post',
data: {
action: 'hedge_fund_activity',
ticker: selectedTicker
},
dataType: 'json',
beforeSend: function(){},
success: function(data){
//console.log(data.institutionalHoldings);
if(data.length == 0){
hfTableContainer.empty();
_gHTML = '';
_gHTML += '
Nothing to display here
';
_gHTML += '
No data to display for ' + selectedTicker + '.
';
_gHTML += '
';
hfTableContainer.append(_gHTML);
} else {
if(data.lastQSharesTraded == 0 || data.lastQSharesTraded == null || data.holdingData == null || data.institutionalHoldings == null){
hfTableContainer.empty();
_gHTML = '';
_gHTML += '
Nothing to display here
';
_gHTML += '
No data to display for ' + selectedTicker + '.
';
_gHTML += '
';
hfTableContainer.append(_gHTML);
} else {
var tableData = data.institutionalHoldings;
hfTableContainer.empty();
_gHTML = '';
_gHTML += '
Hedge Fund Name
';
_gHTML += '
Manager Name
';
_gHTML += '
Rank
';
_gHTML += '
Action
';
_gHTML += '
Holding Change
';
_gHTML += '
Holding Value
';
_gHTML += '
';
for(var t = 0; t < tableData.length; t++){
var td = tableData[t];
var institutionName = td.institutionName;
var managerName = td.managerName;
var expertUID = td.expertUID;
var stars = starGen(td.stars);
var action = td.action;
var lc_action = action.toLowerCase().trim();
var cl_action = '';
if(lc_action == 'added' || lc_action == 'opened position' || lc_action == 'new'){
cl_action = ' hfa-a-added';
} else if(lc_action == 'reduced' || lc_action == 'sold out' || lc_action == 'closed position'){
cl_action = ' hfa-a-reduced';
}
var holdingChange = parseFloat(td.holdingChange);
var cl_holCh = ' hfa-hc-neutral';
if(holdingChange < 0){
cl_holCh = ' hfa-hc-negative';
holdingChange = '-' + Math.abs(holdingChange) + '%';
} else if(holdingChange > 0){
cl_holCh = ' hfa-hc-positive';
holdingChange = '+' + Math.abs(holdingChange) + '%';
} else {
cl_holCh = ' hfa-hc-positive';
holdingChange = '0.00%';
}
var reportedValue = td.reportedValue;
_gHTML += '';
_gHTML += '
' + institutionName + '
';
_gHTML += '
' + managerName + '
';
// _gHTML += '
';
_gHTML += '
' + stars + '
';
_gHTML += '
' + action + '
';
_gHTML += '
' + holdingChange + '
';
_gHTML += '
' + holdingValue(reportedValue) + '
';
_gHTML += '
';
}
hfTableContainer.append(_gHTML);
publishHedgeFundActivityGraphs();
}
}
},
error: function(jqXHR, textStatus, errorThrown){
hfTableContainer.empty();
_gHTML = '';
_gHTML += '
Nothing to display here
';
_gHTML += '
No data to display for ' + selectedTicker + '.
';
_gHTML += '
';
hfTableContainer.append(_gHTML);
},
complete: function(){}
});
//
//
// Currently cannot get portfolio activity for these experts
//
//
/*$('body').off('click', 'a.hfrAnName').on('click', 'a.hfrAnName', function(e){
e.preventDefault();
var expertUID = $(this).attr('rel');
$('div.subsymanalst').remove();
$(this).parent().parent().after('');
$(document).scrollTop($(this).parent().parent().offset().top - 70);
var analystContainerRow = $(this).parent().parent().next();
$.ajax({
url: targetAjaxUrl,
type: 'post',
data: {
action: 'analyst_rating_history',
expert: expertUID
},
dataType: 'json',
beforeSend: function(){},
success: function(data){
analystContainerRow.empty();
console.log(data);
if(data){
if(data.profile){
console.log(data.profile);
} else {
analystContainerRow.empty();
_gHTML = '';
_gHTML += '
Nothing to display here
';
_gHTML += '
No data available at this time - please try again later.
';
_gHTML += '
';
analystContainerRow.append(_gHTML);
}
} else {
analystContainerRow.empty();
_gHTML = '';
_gHTML += '
Nothing to display here
';
_gHTML += '
No data available at this time - please try again later.
';
_gHTML += '
';
analystContainerRow.append(_gHTML);
}
},
error: function(jqXHR, textStatus, errorThrown){
analystContainerRow.empty();
_gHTML = '';
_gHTML += '
Nothing to display here
';
_gHTML += '
No data available at this time - please try again later.
';
_gHTML += '
';
analystContainerRow.append(_gHTML);
},
complete: function(){}
});
});*/
//}
};
function publishBloggerOpinionsGraphs(){
$.ajax({
url: targetAjaxUrl,
type: 'post',
data: {
action: 'blogger_consensus',
ticker: selectedTicker
},
dataType: 'json',
beforeSend: function(){},
success: function(data){
if(data){
// distro graph
if(data.blogsDistribution){
var blogsDistribution = data.blogsDistribution;
var websites = [];
for(var i = 0; i < blogsDistribution.length; i++){
var sitename = blogsDistribution[i].site;
var siteperc = parseFloat(blogsDistribution[i].percentage);
var el = {label: sitename, count: siteperc};
websites.push(el);
}
//console.log(websites);
var grHTML = '';
grHTML += '
';
$('#blogger_opinions div.bo-chart-2 div.smloader').replaceWith(grHTML);
d3SegmentArcSingle('#arc_blogger_site_distribution', websites);
}
// sentiment graph
if(data.bearishRatio){
var bearishRatio = data.bearishRatio; // 0.05
var bullishRatio = parseFloat(data.bullishRatio); // 0.95
var sectorBullRatio = parseFloat(data.sectorBullRatio); // 0.766 average value!
var numOfBloggers = data.numOfBloggers; // 23
var consensus = data.consensus; // "Bullish"
var btncl = 'neutral';
if(consensus.toLowerCase() == 'bullish') btncl = 'positive';
if(consensus.toLowerCase() == 'bearish') btncl = 'negative';
var grHTML = '';
grHTML += '';
grHTML += '
';
grHTML += '
' + consensus + '
';
grHTML += '
Based on ' + numOfBloggers + ' Blogger Opinions
';
grHTML += '
';
grHTML += '
';
grHTML += '
';
grHTML += '
';
grHTML += '
';
$('#blogger_opinions div.bo-chart-1 div.smloader').replaceWith(grHTML);
d3TubeBullish('#tube_blogger_site_sentiment', bullishRatio, sectorBullRatio);
}
}
},
error: function(jqXHR, textStatus, errorThrown){},
complete: function(){}
});
}
var publishBloggerOpinions = function(tabId){
/*$('#gauge_hedgefunds_activity svg').remove();
$('#gauge_insider_activity svg').remove();
$('#hedge_fund_change_txcontainer').html('');*/
//var dev_cookie = Cookies.get('dev_cookie');
//if(typeof dev_cookie == 'undefined'){
// resource disabled for production
//} else {
// DELETE ME (insert this in template file!!!!!!!!!!!!!!!!!!!!!!!)
var _inject = '';
_inject += '
Chart 1
';
_inject += '
Chart 2
';
_inject += '
';
_inject += '
';
$('#blogger_opinions').empty().append(_inject);
// DELETE ME
var boTableContainer = $('#blogger_opinions div.bo-content');
boTableContainer.empty().append('
');
$('#blogger_opinions div.bo-chart-1').html('
');
$('#blogger_opinions div.bo-chart-2').html('
');
$.ajax({
url: targetAjaxUrl,
type: 'post',
data: {
action: 'blogger_ratings',
ticker: selectedTicker
},
dataType: 'json',
beforeSend: function(){},
success: function(data){
if(data){
if(data.length == 0){
boTableContainer.empty();
_gHTML = '';
_gHTML += '
Nothing to display here
';
_gHTML += '
No data to display for ' + selectedTicker + '.
';
_gHTML += '
';
boTableContainer.append(_gHTML);
} else {
var tableData = data.institutionalHoldings;
boTableContainer.empty();
_gHTML = '';
_gHTML += '
Blogger Name
';
_gHTML += '
Site
';
_gHTML += '
Rank
';
_gHTML += '
Opinion
';
_gHTML += '
Date
';
_gHTML += '
Article Source
';
_gHTML += '
';
for(var t = 0; t < data.length; t++){
var bo = data[t];
var bloggerName = bo.bloggerName;
var firmName = bo.firmName;
var recommendation = bo.recommendation;
var lc_rcmd = recommendation.toLowerCase();
var recommendationDate = parseBloggerDate(bo.recommendationDate);
var expertUID = bo.expertUID;
var url = bo.url;
var fTit = bloggerName + ' :: ' + selectedTicker;
var boLn = '';
if(url){
if(url == '' || (url.toLowerCase()).indexOf('tipranks') !== -1){
//
} else {
boLn = 'Read Why ';
}
}
var expertPictureURL = bo.expertPictureURL;
var numOfStars = starGen(bo.numOfStars);
_gHTML += '';
_gHTML += '
' + bloggerName + '
';
_gHTML += '
' + firmName + '
';
_gHTML += '
' + numOfStars + '
';
_gHTML += '
' + recommendation + '
';
_gHTML += '
' + recommendationDate + '
';
_gHTML += '
' + boLn + '
';
_gHTML += '
';
}
boTableContainer.append(_gHTML);
publishBloggerOpinionsGraphs();
}
} else {
boTableContainer.empty();
_gHTML = '';
_gHTML += '
Nothing to display here
';
_gHTML += '
No data to display for ' + selectedTicker + '.
';
_gHTML += '
';
boTableContainer.append(_gHTML);
}
},
error: function(jqXHR, textStatus, errorThrown){
boTableContainer.empty();
_gHTML = '';
_gHTML += '
Nothing to display here
';
_gHTML += '
No data to display for ' + selectedTicker + '.
';
_gHTML += '
';
boTableContainer.append(_gHTML);
},
complete: function(){}
});
$('body').off('click', 'div.bo-as a').on('click', 'div.bo-as a', function(e){
e.preventDefault();
var linkLink = $(this).attr('href');
var linkTitle = $(this).attr('rel');
if(linkLink == '' || linkLink == 'null' || linkLink == 'undefined' || linkLink == 'NaN' || linkTitle == null || linkTitle == 'null' || (linkLink.toLowerCase()).indexOf('tipranks') !== -1){
// skip it
} else {
$('body').append('
');
$("#readwhylink_disclaimerbackground").maxZIndex({ inc: 5 });
$("#readwhylink_disclaimerbackground").off('click').on('click', function(e){
$("#readwhylink_disclaimerwin").remove();
$("#readwhylink_disclaimerbackground").remove();
});
var _disclaimerlinkshtml = '';
_disclaimerlinkshtml += '';
_disclaimerlinkshtml += '
' + linkTitle + '
';
_disclaimerlinkshtml += '
You are leaving the web site of Lightspeed and entering a third party web site not affiliated with Lightspeed or any of its affiliates ("Lightspeed"). No information contained in the linked site has been endorsed or approved by Lightspeed and Lightspeed is not responsible for the content. No information contained in the linked site constitutes a recommendation by Lightspeed to buy, sell or hold any security, financial product or instrument discussed therein.
';
_disclaimerlinkshtml += '
The link is being provided for your information only and no information obtained through the linked site should be construed as an offer, or a solicitation of an offer, to buy or sell securities by Lightspeed.
';
_disclaimerlinkshtml += '
By making available this link, Lightspeed does not offer or provide any investment advice or opinion regarding the nature, potential, value, suitability or profitability of any particular security, portfolio of securities, transaction or investment strategy, and you shall be fully responsible for any investment decisions you make, and such decisions will be based solely on your evaluation of your financial circumstances, investment objectives, risk tolerance, and liquidity needs.
';
_disclaimerlinkshtml += '
';
_disclaimerlinkshtml += 'GO! ';
_disclaimerlinkshtml += 'Cancel ';
_disclaimerlinkshtml += '
';
_disclaimerlinkshtml += '
';
$('body').append(_disclaimerlinkshtml);
$('#readwhylink_disclaimerwin span.linkagreebutton').off('click').on('click', function(e){
window.open(linkLink);
$("#readwhylink_disclaimerwin").remove();
$("#readwhylink_disclaimerbackground").remove();
});
$('#readwhylink_disclaimerwin span.linkdisagreebutton').off('click').on('click', function(e){
$("#readwhylink_disclaimerwin").remove();
$("#readwhylink_disclaimerbackground").remove();
});
$("#readwhylink_disclaimerwin").maxZIndex({ inc: 5 });
}
});
//}
};
function regenerateNoSymbolNav(reloadSymbols)
{
var incP = ((noSymbolPGDisplayed - 1) / 2);
var potLeft = noSymbolPage - incP;
var potRight = noSymbolPage + incP;
if(potLeft < 0){
leftP = noSymbolPage - (incP - Math.abs(potLeft)) + 1;
if(noSymbolPage > noSymbolPGStartMove + 1){
leftP = noSymbolPage - noSymbolPGStartMove;
}
} else if(potRight > noSymbolPageCount){
leftP = noSymbolPage - (incP + Math.abs(potRight - noSymbolPageCount));
if((incP - Math.abs(potRight - noSymbolPageCount)) > noSymbolPGStartMove + 1){
leftP -= noSymbolPGStartMove;
}
} else {
leftP = noSymbolPage - incP;
}
rightP = leftP + (noSymbolPGDisplayed - 1);
var tH = '';
tH += ' Previous ';
for(var c = 0; c < noSymbolPGDisplayed; c++){
var pageNumber = leftP + c;
var pageClass = (pageNumber == noSymbolPage) ? ' class="no-symbol-page-active"' : '';
tH += '' + pageNumber + ' ';
}
tH += 'Next ';
$('#topnosymbolnav').empty().append(tH);
$('#bottomnosymbolnav').empty().append(tH);
// load new slice and symbols
var sliceFrom = (noSymbolPage * noSymbolSYPerPage) - noSymbolSYPerPage;
var sliceTo = noSymbolPage * noSymbolSYPerPage;
var currentSlice = supportedTickers.slice(sliceFrom, sliceTo);
if(reloadSymbols == true){
var nosyC = $('div.no-symbol-content');
var sC = '';
for(var i = 0; i < currentSlice.length; i++){
var cS = currentSlice[i];
sC += '';
sC += '
';
sC += '
';
sC += '
';
sC += '
';
sC += '
';
}
nosyC.empty().append(sC);
}
// request additional data
var tickerSet = currentSlice.join(',');
currentReloadSymbolsRequest = $.ajax({
url: targetAjaxUrl,
type: 'post',
data: {
action: 'tickerset_more',
tickers: tickerSet
},
dataType: 'json',
beforeSend: function(){
if(currentReloadSymbolsRequest != null) currentReloadSymbolsRequest.abort();
},
success: function(data){
if(data){
for(var key in data){
var companyName = data[key].companyName;
var currentPrice = data[key].currentPrice;
var netChange = data[key].netChange;
var percentChange = data[key].percentChange;
var priceToDisplay = (currentPrice == null) ? '-' : '$' + parseFloat(currentPrice).toFixed(2);
if(percentChange == null) percentChange = 0;
var position = '-';
var positionCLS = '';
if(percentChange < 0){
position = '▼(-' + Math.abs(percentChange) + '% Downside)';
positionCLS = 'downside';
} else if(percentChange > 0){
position = '▲(' + Math.abs(percentChange) + '% Upside)';
positionCLS = 'upside';
} else {
position = '-';
}
var lookupElement = $('div.no-symbol-content').find('a[rel="'+key+'"]').eq(0).parent().parent();
lookupElement.find('span.no-symbol-company').html(companyName);
lookupElement.find('span.no-symbol-price').html(priceToDisplay);
lookupElement.find('span.no-symbol-updown').html(position);
if(position != '-') lookupElement.find('span.no-symbol-updown').addClass(positionCLS);
}
}
},
error: function(jqXHR, textStatus, errorThrown){},
complete: function(){}
});
}
var publishNoSymbol = function(tabId){
// what we do with regular tabs
$('.tab-active').removeClass('tab-active');
$('.tr-content').children().removeClass('tr-container-active');
$('.tr-content').children().hide();
var container = $('#' + tabId);
container.empty().addClass('tr-container-active').show().append('
');
// load supported tickers
$.ajax({
url: targetAjaxUrl,
type: 'post',
data: {
action: 'supported_tickers'
},
dataType: 'json',
beforeSend: function(){},
success: function(data){
supportedTickers = data;
// load positions
$.ajax({
url: targetAjaxUrl,
type: 'post',
data: {
action: 'trader_positions'
},
dataType: 'json',
beforeSend: function(){},
success: function(data){
if(data){
if(data.length > 0){
var gHTML = '';
gHTML += 'Holdings Delay +15 min ';
gHTML += '';
gHTML += '
';
gHTML += '
Symbol
';
gHTML += '
Description
';
gHTML += '
Current Price
';
gHTML += '
Avg. Target Price
';
gHTML += '
% Up/Down
';
gHTML += '
Analyst Consensus
';
gHTML += '
Insiders Consensus
';
gHTML += '
Hedge Funds Consensus
';
gHTML += '
Blogger Ratings
';
gHTML += '
';
for(var i = 0; i < data.length; i++){
// main
var a = data[i];
var symbol = a['symbol'];
var companyName = a['companyName'];
var currentPrice = a['currentPrice'];
var analyst_target_price = a['analyst_target_price'];
var priceside_avg = a['priceside_avg'];
var analyst_consensus = a['analyst_consensus'];
var insider_consensus = a['insider_consensus'];
var hedgefund_consensus = a['hedgefund_consensus'];
var blogger_consensus = a['blogger_consensus'];
// other
var account_number = a['account_number'];
var netChange = a['netChange'];
var percentChange = a['percentChange'];
// data prepare (company)
var companyShow = (companyName == null || companyName == '') ? '' : companyName;
var cncompanyShow = companyShow.split(' ');
var cnAcompanyShow = cncompanyShow.slice(0, 3);
companyShow = cnAcompanyShow.join(' ');
// data prepare (prices)
currentPrice = (currentPrice == null || currentPrice == '') ? '' : '$' + parseFloat(currentPrice).toFixed(2);
analyst_target_price = (analyst_target_price == null || analyst_target_price == '') ? '' : '$' + parseFloat(analyst_target_price).toFixed(2);
// data prepare (priceside)
if(priceside_avg == null || priceside_avg == ''){
priceside_avg = '';
} else {
var psa = parseFloat(priceside_avg);
var clpsa = 'neutral';
if(psa < 0) clpsa = 'low';
if(psa > 0) clpsa = 'high';
priceside_avg = '
' + stringifySidePercentMain(psa) + ' ';
}
// data prepare (others)
analyst_consensus = (analyst_consensus == null || analyst_consensus == '') ? '' : analyst_consensus;
insider_consensus = (insider_consensus == null || insider_consensus == '') ? '' : insider_consensus;
hedgefund_consensus = (hedgefund_consensus == null || hedgefund_consensus == '') ? '' : hedgefund_consensus;
blogger_consensus = (blogger_consensus == null || blogger_consensus == '') ? '' : blogger_consensus;
insider_consensus = insider_consensus.replace(' Sentiment', '');
hedgefund_consensus = hedgefund_consensus.replace(' Sentiment', '');
// data prepare (analyst consensus)
var acStrLc = analyst_consensus.toLowerCase();
var acCLS = 'none';
if(acStrLc.indexOf('buy') > -1){
acCLS = 'buy';
} else if(acStrLc.indexOf('sell') > -1){
acCLS = 'sell';
} else if(acStrLc.indexOf('hold') > -1){
acCLS = 'hold';
}
if(analyst_consensus != '') analyst_consensus = '
' + analyst_consensus + ' ';
// data prepare (hedge funds)
var hfCL = 'neutral';
var hfStrLc = hedgefund_consensus.toLowerCase();
if(hfStrLc.indexOf('positive') > -1){
hfCL = 'positive';
} else if(hfStrLc.indexOf('negative') > -1){
hfCL = 'negative';
}
if(hedgefund_consensus != '') hedgefund_consensus = '
' + hedgefund_consensus + ' ';
// data prepare (insiders)
var insCL = 'neutral';
var insStrLc = insider_consensus.toLowerCase();
if(insStrLc.indexOf('positive') > -1){
insCL = 'positive';
} else if(insStrLc.indexOf('negative') > -1){
insCL = 'negative';
}
if(insider_consensus != '') insider_consensus = '
' + insider_consensus + ' ';
// data prepare (bloggers)
var blgCL = 'neutral';
var blgStrLc = blogger_consensus.toLowerCase();
if(blgStrLc.indexOf('bullish') > -1){
blgCL = 'bullish';
} else if(blgStrLc.indexOf('bearish') > -1){
blgCL = 'bearish';
} else if(blgStrLc.indexOf('neutral') > -1){
blgCL = 'neutral';
}
if(blogger_consensus != '') blogger_consensus = '
' + blogger_consensus + ' ';
// data prepare (N/A)
if(companyShow == '') companyShow = '
N/A ';
if(currentPrice == '') currentPrice = '
N/A ';
if(analyst_target_price == '') analyst_target_price = '
N/A ';
if(priceside_avg == '') priceside_avg = '
N/A ';
if(analyst_consensus == '') analyst_consensus = '
N/A ';
if(insider_consensus == '') insider_consensus = '
N/A ';
if(hedgefund_consensus == '') hedgefund_consensus = '
N/A ';
if(blogger_consensus == '') blogger_consensus = '
N/A ';
// table
gHTML += '
';
gHTML += '
';
gHTML += '
' + companyShow + '
';
gHTML += '
' + currentPrice + '
';
gHTML += '
' + analyst_target_price + '
';
gHTML += '
' + priceside_avg + '
';
gHTML += '
' + analyst_consensus + '
';
gHTML += '
' + insider_consensus + '
';
gHTML += '
' + hedgefund_consensus + '
';
gHTML += '
' + blogger_consensus + '
';
gHTML += '
';
}
gHTML += '
';
container.find('div.preloader').replaceWith(gHTML);
} else {
var _gHTML = '';
_gHTML += '';
_gHTML += '
This window will display the equity holdings in your account.
';
_gHTML += '
Currently no holdings are found, please click the above and enter a symbol to begin your research.
';
_gHTML += '
';
container.find('div.preloader').replaceWith(_gHTML);
}
} else {
var _gHTML = '';
_gHTML += '';
_gHTML += '
This window will display the equity holdings in your account.
';
_gHTML += '
Currently no holdings are found, please click the above and enter a symbol to begin your research.
';
_gHTML += '
';
container.find('div.preloader').replaceWith(_gHTML);
}
/*if(data){
var c = 0;
for(k in data) {
c++;
}
if(c > 0){
var gHTML = '';
for(accountNumber in data){
var accPosSet = data[accountNumber];
gHTML += '' + accountNumber + ' Positions ';
gHTML += '';
gHTML += '
';
gHTML += '
Symbol
';
gHTML += '
Description
';
gHTML += '
Quantity
';
gHTML += '
Close Price
';
gHTML += '
Total Market Value
';
gHTML += '
Date
';
gHTML += '
';
for(var t = 0; t < accPosSet.length; t++){
var pRow = accPosSet[t];
var stringDate = pRow.Processdate;
var splDt = stringDate.split(' ');
var undDate = splDt[0];
var zuxDt = undDate.split('-');
var posDate = zuxDt[1] + '/' + zuxDt[2] + '/' + zuxDt[0];
gHTML += '
';
gHTML += '
';
gHTML += '
' + pRow.Description + '
';
gHTML += '
' + pRow.Quantity + '
';
gHTML += '
' + pRow.ClosePrice + '
';
gHTML += '
' + pRow.TotalMarketValue + '
';
gHTML += '
' + posDate + '
';
gHTML += '
';
}
gHTML += '
';
}
container.find('div.preloader').replaceWith(gHTML);
} else {
var _gHTML = '';
_gHTML += '';
_gHTML += '
No Positions Found
';
_gHTML += '
Use search field above to research symbols.
';
_gHTML += '
';
container.find('div.preloader').replaceWith(_gHTML);
}
} else {
var _gHTML = '';
_gHTML += '';
_gHTML += '
No Positions
';
_gHTML += '
Use search field above to research symbols.
';
_gHTML += '
';
container.find('div.preloader').replaceWith(_gHTML);
}*/
},
error: function(jqXHR, textStatus, errorThrown){
var _gHTML = '';
_gHTML += '';
_gHTML += '
This window will display the equity holdings in your account.
';
_gHTML += '
Currently no holdings are found, please click the above and enter a symbol to begin your research.
';
_gHTML += '
';
container.find('div.preloader').replaceWith(_gHTML);
},
complete: function(){}
});
$('body').off('click', 'div.no-symbol-position-table a').on('click', 'div.no-symbol-position-table a', function(e){
e.preventDefault();
var symbol = $(this).text();
window.location.hash = symbol;
$('html, body').scrollTop(0);
selectedTicker = symbol;
selectSymbol(symbol);
});
},
error: function(jqXHR, textStatus, errorThrown){},
complete: function(){}
});
/*$.ajax({
url: targetAjaxUrl,
type: 'post',
data: {
action: 'supported_tickers'
},
dataType: 'json',
beforeSend: function(){},
success: function(data){
supportedTickers = data;
noSymbolPageCount = data.length / noSymbolSYPerPage;
if(Math.floor(noSymbolPageCount) < noSymbolPageCount) noSymbolPageCount = Math.floor(noSymbolPageCount) + 1;
var sliceFrom = (noSymbolPage * noSymbolSYPerPage) - noSymbolSYPerPage;
var sliceTo = noSymbolPage * noSymbolSYPerPage;
var currentSlice = data.slice(sliceFrom, sliceTo);
// create containers
var gH = '
';
gH += '';
for(var i = 0; i < currentSlice.length; i++){
var cS = currentSlice[i];
gH += '
';
gH += '
';
gH += '
';
gH += '
';
gH += '
';
gH += '
';
}
gH += '
';
gH += '
';
container.find('div.preloader').replaceWith(gH);
regenerateNoSymbolNav(false);
$('body').off('click', 'div.no-symbol-pages-container a').on('click', 'div.no-symbol-pages-container a', function(e){
e.preventDefault();
var r = $(this).attr('rel');
if(r == 'left'){
if((noSymbolPage - 1) > 0) noSymbolPage = noSymbolPage - 1;
regenerateNoSymbolNav(true);
} else if(r == 'right'){
if((noSymbolPage + 1) <= noSymbolPageCount) noSymbolPage = noSymbolPage + 1;
regenerateNoSymbolNav(true);
} else {
if(parseInt(r) != noSymbolPage){
noSymbolPage = parseInt(r);
regenerateNoSymbolNav(true);
}
}
});
$('body').off('click', 'div.no-symbol-content a').on('click', 'div.no-symbol-content a', function(e){
e.preventDefault();
selectedTicker = $(this).attr('rel');
selectSymbol(selectedTicker);
});
},
error: function(jqXHR, textStatus, errorThrown){},
complete: function(){}
});*/
};
function sendUsageStatistic(tabid)
{
$.ajax({
url: targetTrackAjaxUrl,
type: 'post',
data: {
pageid: tabid
},
dataType: 'html',
beforeSend: function(){},
success: function(data){},
error: function(jqXHR, textStatus, errorThrown){},
complete: function(){}
});
}
function inArray(needle, haystack){
var length = haystack.length;
for(var i = 0; i < length; i++) {
if(haystack[i] == needle) return true;
}
return false;
}
function publishTab(tabId)
{
sendUsageStatistic(tabId);
var tabAction = 'publish' + tabMappings[tabId];
window[tabAction](tabId);
$('div.specsearch_header').show();
populateInfoWidgetContent(tabId);
}
function findSymbol(searchString)
{
searchString = searchString.replace(/\W/g,'');
if(typeof searchString == 'undefined') searchString = '';
if(searchString.length > 0){
searchString = searchString.toUpperCase();
var listedTickers = [];
if(searchString.length == 1){ // only beginning on letter
for(var j = 0; j < supportedTickers.length; j++){
if(supportedTickers[j].indexOf(searchString) === 0){
listedTickers.push(supportedTickers[j]);
}
}
} else { // containing letter
for(var j = 0; j < supportedTickers.length; j++){
if(supportedTickers[j].indexOf(searchString) !== -1){
listedTickers.push(supportedTickers[j]);
}
}
}
listedTickers = listedTickers.slice(0, 6);
if(listedTickers.length > 0){
$('#specsearch').removeClass('nosymbolfound');
$('#searchboxresults').empty();
$('#searchboxresults').show();
for(var j = 0; j < listedTickers.length; j++){
reg = new RegExp(searchString, 'gi');
fsr = listedTickers[j].replace(reg, function(str){return ''+str+' '});
$('#searchboxresults').append(''+fsr+' '+'
');
}
var implodedTickers = listedTickers.join(',');
$.ajax({
url: targetAjaxUrl,
type: 'post',
data: {
action: 'get_unknown_ticker_list',
tickers: implodedTickers
},
dataType: 'json',
beforeSend: function(){
$('#searchboxresults div.boxresrow').each(function(){
$(this).append(' ');
});
},
success: function(data){
if(data){
for(var key in data){
var companyName = (data[key].companyName == null) ? '' : data[key].companyName;
var currentPrice = (data[key].currentPrice == null) ? 0 : data[key].currentPrice;
var showPrice = '';
if(currentPrice == 0){
showPrice = ' - ';
} else {
showPrice = ' ($' + parseFloat(currentPrice).toFixed(2) + ') - ';
}
var showString = '' + showPrice + companyName + ' ';
$('#searchboxresults div.boxresrow').each(function(){
var t = $(this).find('input').eq(0).val();
if(t == key){
$(this).find('img').remove();
$(this).find('span.boxedspanaddres').remove();
$(this).append(showString);
}
});
}
}
},
error: function(jqXHR, textStatus, errorThrown){
//
},
complete: function(){}
});
} else {
$('#searchboxresults div.boxresrow').removeClass('highlighted');
$('#specsearch').addClass('nosymbolfound');
$('#searchboxresults').hide();
}
//console.log(listedTickers);
} else {
$('#searchboxresults div.boxresrow').removeClass('highlighted');
$('#searchboxresults').hide();
}
}
function selectSymbol(ticker)
{
// update hash
window.location.hash = ticker;
// replace "no_symbol" page with "analyst_ratings" page if needed
if(currentTabKey == 'no_symbol'){
$('#no_symbol').hide();
$('.tab-active').removeClass('tab-active');
$('div.side-nav-symbol a[rel="analyst_ratings"]').addClass('tab-active');
$('#analyst_ratings').addClass('tr-container-active');
$('#analyst_ratings').show();
publishTab('analyst_ratings');
currentTabKey = 'analyst_ratings';
} else {
// reloading data by re-publishing tabs
publishTab(currentTabKey);
}
// return specsearch widget to previous state
$('#specsearch').val('');
$('#searchboxresults').empty();
$('#searchboxresults').hide();
$('.specsearch_search').hide();
$('.specsearch_text').show();
$('.specsearch_info').show();
// update specsearch selected symbol
$('.specsearch_text').html('' + ticker + ' ');
// load more data
$.ajax({
url: targetAjaxUrl,
type: 'post',
data: {
action: 'ticker_more',
symbol: ticker
},
dataType: 'json',
beforeSend: function(){},
success: function(data){
if(data){
var companyName = data.companyName;
var currentPrice = data.currentPrice;
var netChange = data.netChange;
var percentChange = (data.percentChange == null) ? 0 : parseFloat(data.percentChange);
var market = data.market;
var companyShow = (companyName == null || companyName == '') ? '' : companyName;
var marketShow = (market == null) ? '' : market;
var priceShow = (currentPrice == null) ? '-' : '$' + parseFloat(currentPrice).toFixed(2);
var position = '-';
var positionCLS = '';
if(percentChange < 0){
position = '▼(-' + Math.abs(percentChange * 100) + '% Downside)';
positionCLS = 'downside';
} else if(percentChange > 0){
position = '▲(' + Math.abs(percentChange * 100) + '% Upside)';
positionCLS = 'upside';
} else {
position = '-';
}
// try to make company name smaller in lenght
var cncompanyShow = companyShow.split(' ');
var cnAcompanyShow = cncompanyShow.slice(0, 3);
companyShow = cnAcompanyShow.join(' ');
// display full line
var _H = '';
_H += '' + companyShow + ' (' + ticker + ') ';
_H += '' + marketShow + ' ';
_H += '' + priceShow + ' ';
_H += '' + position + ' ';
_H += 'Delay +15 min ';
$('.specsearch_text').html(_H);
}
},
error: function(jqXHR, textStatus, errorThrown){},
complete: function(){}
});
}
$(function(){
$('.nav-tab').on('click', function(e){
e.preventDefault();
if(selectedTicker == null || selectedTicker == ''){
alert('Please search or select Symbol first.');
} else {
// tab
var tabId = $(this).attr('rel');
$('.tab-active').removeClass('tab-active');
$(this).addClass('tab-active');
// tab related content
$('.tr-content').children().removeClass('tr-container-active');
$('.tr-content').children().hide();
$('#'+tabId).addClass('tr-container-active');
$('#'+tabId).show();
// publish tab
currentTabKey = tabId;
publishTab(tabId);
}
});
// is symbol in url
var hash = window.location.hash;
if(hash){
hash = hash.replace('#', '').trim();
if(hash == '' || hash == null){
publishTab('no_symbol');
currentTabKey = 'no_symbol';
} else {
selectedTicker = hash;
currentTabKey = 'analyst_ratings';
selectSymbol(selectedTicker);
}
} else {
publishTab('no_symbol');
currentTabKey = 'no_symbol';
}
// show search box
$('.specsearch_text').add('.specsearch_info').on('click', function(){
$('.specsearch_text').hide();
$('.specsearch_info').hide();
$('.specsearch_search').show();
$('.specsearch_search input').focus();
});
$('.specsearch_search input').on('blur', function(){
// ??
});
$('.specsearch_search input').on('keyup', function(e){
clearTimeout(searchThread);
var code = e.which;
if(code==13){ // enter
e.preventDefault();
var anyH = $('#searchboxresults').find('.highlighted').eq(0).length;
if(anyH == 0){ // nothing selected
var selVal = $('#specsearch').val().toUpperCase();
} else { // something selected
var selVal = $('#searchboxresults').find('.highlighted').eq(0).find('input').eq(0).val();
}
if(inArray(selVal, supportedTickers)){
selectedTicker = selVal;
selectSymbol(selVal);
} else {
$('#specsearch').blur();
alert("Please choose or type valid symbol!");
}
} else if(code == 40 || code == 38){ // down up
e.preventDefault();
var stl = $(this).val().length * 2;
$(this)[0].setSelectionRange(stl, stl);
if($('#searchboxresults').is(':visible')){
var anyH = $('#searchboxresults').find('.highlighted').eq(0).length;
if(code == 40){ // down
if(anyH == 0){
$('#searchboxresults div.boxresrow:first').addClass('highlighted');
} else {
var curEL = $('#searchboxresults').find('.highlighted').eq(0);
var nextEL = curEL.next();
curEL.removeClass('highlighted');
if(nextEL.length == 0){
$('#searchboxresults div.boxresrow:first').addClass('highlighted');
} else {
nextEL.addClass('highlighted');
}
}
}
if(code == 38){ // up
if(anyH == 0){
$('#searchboxresults div.boxresrow:last').addClass('highlighted');
} else {
var curEL = $('#searchboxresults').find('.highlighted').eq(0);
var prevEL = curEL.prev();
curEL.removeClass('highlighted');
if(prevEL.length == 0){
$('#searchboxresults div.boxresrow:last').addClass('highlighted');
} else {
prevEL.addClass('highlighted');
}
}
}
}
} else if(code == 27){ // escape
e.preventDefault();
$('.specsearch_search').hide();
$('.specsearch_text').show();
$('.specsearch_info').show();
} else {
var $this = $(this);
searchThread = setTimeout(function(){
findSymbol( $this.val() )
}, 35);
}
});
// possible click on symbol results
$('body').off('click', 'div.boxresrow').on('click', 'div.boxresrow', function(){
var selVal = $(this).find('input').eq(0).val();
selectedTicker = selVal;
selectSymbol(selVal);
});
// get supported tickers
if(hash){ // if no symbol in url, this will be loaded by "no_symbol" hidden tab
$.ajax({
url: targetAjaxUrl,
type: 'post',
data: {
action: 'supported_tickers'
},
dataType: 'json',
beforeSend: function(){},
success: function(data){
supportedTickers = data;
},
error: function(jqXHR, textStatus, errorThrown){},
complete: function(){}
});
}
// move to top on page load
$('html, body').scrollTop(0);
// info manager
$('#btn-show-info').on('click', function(e){
e.preventDefault();
if(!$('.tipranks-info').is(':visible')){
$(this).fadeOut(100);
$('.tipranks-info').fadeIn(300);
Cookies.set('tr-inf-shw-op', 1, { expires: 14 });
}
});
$('.tipranks-info-close').on('click', function(e){
e.preventDefault();
//console.log('tipranks-info-close');
$(this).parent('.tipranks-info').fadeOut(300);
$('#btn-show-info').fadeIn(100);
Cookies.set('tr-inf-shw-op', 0, { expires: 14 });
});
// keep session alive
setInterval(sessionUp, 50000); // 30 seconds
});