11 lines
43 KiB
JavaScript
11 lines
43 KiB
JavaScript
/**
|
|
* Stock Screener
|
|
* --------------------
|
|
* Version 1.7.0, built on Tuesday, November 21, 2017
|
|
* Copyright (c) Financial Apps and Plugins <info@financialplugins.com>. All rights reserved.
|
|
* Demo: http://financialplugins.com/products/stock-screener/
|
|
* Purchase: https://codecanyon.net/item/stock-screener/18297488?ref=financialtechnology
|
|
* Like: https://www.facebook.com/financialplugins/
|
|
*/
|
|
function numberWithCommas(e){var a=e.toString().split(".");return a[0]=a[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),a.join(".")}function render_cell_numshort_colored(e,a,t,r){switch(data_new=e,val=e,is_convert=!1,val[val.length-1]){case"K":val=1e3*val.slice(0,-1),is_convert=!0;break;case"M":val=1e6*val.slice(0,-1),is_convert=!0;break;case"B":val=1e9*val.slice(0,-1),is_convert=!0;break;case"%":val=val.slice(0,-1)}return isNaN(val)||(val=parseFloat(val),data_new=is_convert?numberFormat(val):numberWithCommas(val.toFixed(2)),val>0?data_new='<span class="font-green">'+data_new+"</span>":val<0&&(data_new='<span class="font-red">'+data_new+"</span>")),data_new}function render_cell_numshort(e,a,t,r){switch(data_new=e,is_convert=!1,val=e,val[val.length-1]){case"K":val=1e3*val.slice(0,-1),is_convert=!0;break;case"M":val=1e6*val.slice(0,-1),is_convert=!0;break;case"B":val=1e9*val.slice(0,-1),is_convert=!0;break;case"%":val=val.slice(0,-1)}return isNaN(val)||(val=parseFloat(val),data_new=is_convert?numberFormat(val):numberWithCommas(val.toFixed(2))),data_new}function render_cell_numshort_colored_int(e,a,t,r){switch(data_new=e,val=e,is_convert=!1,val[val.length-1]){case"K":val=1e3*val.slice(0,-1),is_convert=!0;break;case"M":val=1e6*val.slice(0,-1),is_convert=!0;break;case"B":val=1e9*val.slice(0,-1),is_convert=!0;break;case"%":val=val.slice(0,-1)}return isNaN(val)||(val=parseFloat(val),data_new=is_convert?numberFormat(val,0):numberWithCommas(val.toFixed(0)),val>0?data_new='<span class="font-green">'+data_new+"</span>":val<0&&(data_new='<span class="font-red">'+data_new+"</span>")),data_new}function render_cell_numshort_int(e,a,t,r){switch(data_new=e,is_convert=!1,val=e,val[val.length-1]){case"K":val=1e3*val.slice(0,-1),is_convert=!0;break;case"M":val=1e6*val.slice(0,-1),is_convert=!0;break;case"B":val=1e9*val.slice(0,-1),is_convert=!0;break;case"%":val=val.slice(0,-1)}return isNaN(val)||(val=parseFloat(val),data_new=is_convert?numberFormat(val,0):numberWithCommas(val.toFixed(0))),data_new}function render_cell_percent_colored(e,a,t,r){switch(data_new=e,val=e,val[val.length-1]){case"K":val=1e3*val.slice(0,-1);break;case"M":val=1e6*val.slice(0,-1);break;case"B":val=1e9*val.slice(0,-1);break;case"%":val=val.slice(0,-1)}return isNaN(val)||(val=parseFloat(val),val>0?data_new='<span class="font-green">'+numberFormat(val)+"%</span>":val<0?data_new='<span class="font-red">'+numberFormat(val)+"%</span>":data_new=numberFormat(val)+"%"),data_new}function render_cell_percent(e,a,t,r){switch(data_new=e,val=e,val[val.length-1]){case"K":val=1e3*val.slice(0,-1);break;case"M":val=1e6*val.slice(0,-1);break;case"B":val=1e9*val.slice(0,-1);break;case"%":val=val.slice(0,-1)}return isNaN(val)||(val=parseFloat(val),data_new=numberFormat(val)+"%"),data_new}function render_cell_percent_colored_int(e,a,t,r){switch(data_new=e,val=e,val[val.length-1]){case"K":val=1e3*val.slice(0,-1);break;case"M":val=1e6*val.slice(0,-1);break;case"B":val=1e9*val.slice(0,-1);break;case"%":val=val.slice(0,-1)}return isNaN(val)||(val=parseFloat(val),val>0?data_new='<span class="font-green">'+numberFormat(val,0)+"%</span>":val<0?data_new='<span class="font-red">'+numberFormat(val,0)+"%</span>":data_new=numberFormat(val,0)+"%"),data_new}function render_cell_percent_int(e,a,t,r){switch(data_new=e,val=e,val[val.length-1]){case"K":val=1e3*val.slice(0,-1);break;case"M":val=1e6*val.slice(0,-1);break;case"B":val=1e9*val.slice(0,-1);break;case"%":val=val.slice(0,-1)}return isNaN(val)||(val=parseFloat(val),data_new=numberFormat(val,0)+"%"),data_new}function stringFill(e,a,t,r){return"undefined"==typeof a&&(a=2),"undefined"==typeof t&&(t="0"),"undefined"==typeof r&&(r=-1),e=e.toString(),e.length>=a?e:(1==r?e:"")+new Array(e.length+(a-e.length)).join(t).toString()+(r==-1?e:"")}function timeFormat(e){return isNaN(e)?e:(h=Math.floor(e/60),m=e%60,t="am",h>12&&(t="pm",h-=12),h.toFixed().toString()+":"+stringFill(m.toFixed())+t)}function dateFormat(e){return new Date(1e3*e).toString("MM/dd/yyyy")}function getUnique(e){for(var a={},t=[],r=0,l=e.length;r<l;++r)a.hasOwnProperty(e[r])||(t.push(e[r]),a[e[r]]=1);return t}function numberFormat(e,a){return"undefined"==typeof a&&(a=2),e>=1e9||e<=-1e9?numberWithCommas((e/1e9).toFixed(a))+"B":e>=1e6||e<=-1e6?numberWithCommas((e/1e6).toFixed(a))+"M":e>=1e3||e<=-1e3?numberWithCommas((e/1e3).toFixed(a))+"K":parseFloat(e).toFixed(a)}function percentFormat(e){return e=parseFloat(e).toFixed(2),(e>0?"+":"")+e+"%"}function show_table(){table='<table class="display"><thead><tr>';for(i in data_keys)table+='<th class="column-'+i+(data_key_filter.indexOf(i)>=0?" filterable":"")+'"><span class="head-label">'+data_keys[i]+'</span><span class="filter-desc"></span>'+(data_key_filter.indexOf(i)>=0?'<div data-field="'+i+'" class="filter-btn" tab-index="0"><i class="fa fa-filter"></i></div>':"")+"</th>";table+="</tr></thead><tbody></tbody></table>",table=$(table),$("main.content").append(table),table.on("processing.dt",function(e,a,t){t?$(".linear-activity").removeClass("hide"):$(".linear-activity").addClass("hide")}),$.extend($.fn.dataTable.ext.oSort,{"range-asc":function(e,a){return e=e.replace(/<\/?[^>]+(>|$)/g,""),e=e.replace(/\s*/g,""),a=a.replace(/<\/?[^>]+(>|$)/g,""),a=a.replace(/\s*/g,""),r=/\d*(\.\d*){0,1}\-\d*(\.\d*){0,1}$/,r.test(e)?r.test(a)?(x1=1e12*parseFloat(e.split("-")[0]),x2=1e12*parseFloat(e.split("-")[1]),y1=1e12*parseFloat(a.split("-")[0]),y2=1e12*parseFloat(a.split("-")[1]),e=parseFloat(x1.toFixed(0).toString()+"."+x2.toFixed(0).toString()),a=parseFloat(y1.toFixed(0).toString()+"."+y2.toFixed(0).toString()),e<a?-1:e>a?1:0):-1:1},"range-desc":function(e,a){return e=e.replace(/<\/?[^>]+(>|$)/g,""),e=e.replace(/\s*/g,""),a=a.replace(/<\/?[^>]+(>|$)/g,""),a=a.replace(/\s*/g,""),r=/\d*(\.\d*){0,1}\-\d*(\.\d*){0,1}$/,r.test(e)?r.test(a)?(x1=1e12*parseFloat(e.split("-")[0]),x2=1e12*parseFloat(e.split("-")[1]),y1=1e12*parseFloat(a.split("-")[0]),y2=1e12*parseFloat(a.split("-")[1]),e=parseFloat(x1.toFixed(0).toString()+"."+x2.toFixed(0).toString()),a=parseFloat(y1.toFixed(0).toString()+"."+y2.toFixed(0).toString()),e<a?1:e>a?-1:0):-1:1},"percent-asc":function(e,a){return e=e.replace(/<\/?[^>]+(>|$)/g,""),e=e.replace(/\s*/g,"").replace(/,/g,""),a=a.replace(/<\/?[^>]+(>|$)/g,""),a=a.replace(/\s*/g,"").replace(/,/g,""),r=/^(\+|\-){0,1}\d*((\.|\,)\d*){0,1}\%$/,e==a?0:r.test(e)?r.test(a)?(e=parseFloat(e.slice(0,-1)),a=parseFloat(a.slice(0,-1)),e<a?-1:e>a?1:0):-1:1},"percent-desc":function(e,a){return e=e.replace(/<\/?[^>]+(>|$)/g,""),e=e.replace(/\s*/g,"").replace(/,/g,""),a=a.replace(/<\/?[^>]+(>|$)/g,""),a=a.replace(/\s*/g,"").replace(/,/g,""),r=/^(\+|\-){0,1}\d*((\.|\,)\d*){0,1}\%$/,e==a?0:r.test(e)?r.test(a)?(e=parseFloat(e.slice(0,-1)),a=parseFloat(a.slice(0,-1)),e<a?1:e>a?-1:0):-1:1},"time-asc":function(e,a){return e=e.replace(/<\/?[^>]+(>|$)/g,"").toString().replace(" ",""),a=a.replace(/<\/?[^>]+(>|$)/g,"").toString().replace(" ",""),r=/^\d{1,2}\:\d\d(am|pm){0,1}$/,e==a?0:r.test(e)?r.test(a)?(h=0,m=0,"pm"==e.slice(-2)?(h=12,e=e.slice(0,-2)):"am"==e.slice(-2)&&(e=e.slice(0,-2)),h+=parseInt(e.split(":")[0]),m+=parseInt(e.split(":")[1]),e=60*h+m,h=0,m=0,"pm"==a.slice(-2)?(h=12,a=a.slice(0,-2)):"am"==a.slice(-2)&&(a=a.slice(0,-2)),h+=parseInt(a.split(":")[0]),m+=parseInt(a.split(":")[1]),a=60*h+m,e<a?-1:e>a?1:0):-1:1},"time-desc":function(e,a){return e=e.replace(/<\/?[^>]+(>|$)/g,"").toString().replace(" ",""),a=a.replace(/<\/?[^>]+(>|$)/g,"").toString().replace(" ",""),r=/^\d{1,2}\:\d\d(am|pm){0,1}$/,e==a?0:r.test(e)?r.test(a)?(h=0,m=0,"pm"==e.slice(-2)?(h=12,e=e.slice(0,-2)):"am"==e.slice(-2)&&(e=e.slice(0,-2)),h+=parseInt(e.split(":")[0]),m+=parseInt(e.split(":")[1]),e=60*h+m,h=0,m=0,"pm"==a.slice(-2)?(h=12,a=a.slice(0,-2)):"am"==a.slice(-2)&&(a=a.slice(0,-2)),h+=parseInt(a.split(":")[0]),m+=parseInt(a.split(":")[1]),a=60*h+m,e<a?1:e>a?-1:0):-1:1},"numshort-asc":function(e,a){if("-"!=e&&"—"!=e||(e="N/A"),"-"!=a&&"—"!=a||(a="N/A"),e==a)return 0;if("N/A"==a)return-1;if("N/A"==e)return 1;switch(e=e.replace(/<\/?[^>]+(>|$)/g,"").replace(/,/g,""),a=a.replace(/<\/?[^>]+(>|$)/g,"").replace(/,/g,""),e[e.length-1]){case"K":e=1e3*e.slice(0,-1);break;case"M":e=1e6*e.slice(0,-1);break;case"B":e=1e9*e.slice(0,-1)}switch(a[a.length-1]){case"K":a=1e3*a.slice(0,-1);break;case"M":a=1e6*a.slice(0,-1);break;case"B":a=1e9*a.slice(0,-1)}return e=parseFloat(e),a=parseFloat(a),e<a?-1:e>a?1:0},"numshort-desc":function(e,a){if("-"!=e&&"—"!=e||(e="N/A"),"-"!=a&&"—"!=a||(a="N/A"),e==a)return 0;if("N/A"==a)return-1;if("N/A"==e)return 1;switch(e=e.replace(/<\/?[^>]+(>|$)/g,"").replace(/,/g,""),a=a.replace(/<\/?[^>]+(>|$)/g,"").replace(/,/g,""),e[e.length-1]){case"K":e=1e3*e.slice(0,-1);break;case"M":e=1e6*e.slice(0,-1);break;case"B":e=1e9*e.slice(0,-1)}switch(a[a.length-1]){case"K":a=1e3*a.slice(0,-1);break;case"M":a=1e6*a.slice(0,-1);break;case"B":a=1e9*a.slice(0,-1)}return e=parseFloat(e),a=parseFloat(a),e<a?1:e>a?-1:0},"stringc-asc":function(e,a){return"-"!=e&&"—"!=e||(e="N/A"),"-"!=a&&"—"!=a||(a="N/A"),e==a?0:"N/A"==a?-1:"N/A"==e?1:e<a?-1:e>a?1:0},"stringc-desc":function(e,a){return"-"!=e&&"—"!=e||(e="N/A"),"-"!=a&&"—"!=a||(a="N/A"),e==a?0:"N/A"==a?-1:"N/A"==e?1:e<a?1:e>a?-1:0},"datec-asc":function(e,a){return"-"!=e&&"—"!=e||(e="N/A"),"-"!=a&&"—"!=a||(a="N/A"),r=/^\d{1,2}\/\d{1,2}\/\d\d\d\d$/,e==a?0:r.test(e)?r.test(a)?(e=parseInt(e.split("/")[2]+stringFill(e.split("/")[0])+stringFill(e.split("/")[1])),a=parseInt(a.split("/")[2]+stringFill(a.split("/")[0])+stringFill(a.split("/")[1])),e<a?-1:e>a?1:0):-1:1},"datec-desc":function(e,a){return"-"!=e&&"—"!=e||(e="N/A"),"-"!=a&&"—"!=a||(a="N/A"),r=/^\d{1,2}\/\d{1,2}\/\d\d\d\d$/,e==a?0:r.test(e)?r.test(a)?(e=parseInt(e.split("/")[2]+stringFill(e.split("/")[0])+stringFill(e.split("/")[1])),a=parseInt(a.split("/")[2]+stringFill(a.split("/")[0])+stringFill(a.split("/")[1])),e<a?1:e>a?-1:0):-1:1}}),$.fn.dataTable.ext.search.push(function(e,a,l){if(void 0!=filter_data[cur_market]&&void 0!=filter_data[cur_market][cur_tab]){filters=filter_data[cur_market][cur_tab];for(column in filters)if(void 0!=filters[column]&&(min=filters[column].min,max=filters[column].max,fval=filters[column].val,val=a[data_key_names.indexOf(column)],void 0!=val&&("object"!=typeof fval||0!=fval.length))){if(val=val.replace(/<\/?[^>]+(>|$)/g,""),"N/A"==val||"-"==val||"—"==val)return!1;if(data_key_percent.indexOf(column)>=0){if(val=val.toString().replace(" ","").replace(/,/g,""),val=val.toString().replace("%",""),isNaN(val))return!1;val=parseFloat(parseFloat(val).toFixed(2))}else if(data_key_time.indexOf(column)>=0){if(r=/^\d{1,2}\:\d\d(am|pm){0,1}$/,val=val.toString().replace(" ",""),!r.test(val))return!1;h=0,m=0,"pm"==val.slice(-2)?(h=12,val=val.slice(0,-2)):"am"==t.slice(-2)&&(val=val.slice(0,-2)),h+=parseInt(val.split(":")[0]),m+=parseInt(val.split(":")[1]),val=60*h+m}else if(data_key_date.indexOf(column)>=0)val=new Date(val).getTime()/1e3;else if(data_key_string_simple.indexOf(column)>=0){if(0==fval.toString().length)return!1}else if(data_key_string.indexOf(column)>=0);else{switch(val=val.replace(/,/g,""),val[val.length-1]){case"K":val=1e3*val.slice(0,-1);break;case"M":val=1e6*val.slice(0,-1);break;case"B":val=1e9*val.slice(0,-1)}val=parseFloat(parseFloat(val).toFixed(2))}if(data_key_string_simple.indexOf(column)>=0&&val.toString().toLowerCase().indexOf(fval.toString().toLowerCase())<0||data_key_string.indexOf(column)>=0&&fval.indexOf(val)==-1||data_key_string.indexOf(column)<0&&data_key_string_simple.indexOf(column)<0&&!(isNaN(min)&&isNaN(max)||isNaN(min)&&val<=max||min<=val&&isNaN(max)||min<=val&&val<=max))return!1}}return!0}),tbl_api=table.DataTable({ajax:{url:server_uri+"?cmd=get-data&market="+cur_market,dataSrc:"data"},bProcessing:!1,searching:!0,autoWidth:!1,dom:'<"top">r<"table-inner"t<"table-wait">><"bottom"flip><"clear">',responsive:{details:{type:"column",target:"tr"}},language:{loadingRecords:'<i class="fa fa-circle-o-notch fa-spin loading-big"></i>',paginate:{previous:'<i class="fa fa-angle-left"></i>',next:'<i class="fa fa-angle-right"></i>'}},lengthMenu:[25,50,100,500],columns:[{name:"s",data:"s",type:"stringc"},{name:"n",data:"n",type:"stringc"},{name:"regularMarketPrice",data:"regularMarketPrice",type:"numshort",className:"number",render:render_cell_numshort},{name:"currency",data:"currency",type:"stringc"},{name:"regularMarketChange",data:"regularMarketChange",type:"numshort",className:"number",render:render_cell_numshort_colored},{name:"regularMarketChangePercent",data:"regularMarketChangePercent",type:"percent",className:"number",render:render_cell_percent_colored},{name:"regularMarketVolume",data:"regularMarketVolume",type:"numshort",className:"number",render:render_cell_numshort},{name:"sharesOutstanding",data:"sharesOutstanding",type:"numshort",className:"number",render:render_cell_numshort},{name:"marketCap",data:"marketCap",type:"numshort",className:"number",render:render_cell_numshort},{name:"bid",data:"bid",type:"numshort",className:"number",render:render_cell_numshort},{name:"ask",data:"ask",type:"numshort",className:"number",render:render_cell_numshort},{name:"bidSize",data:"bidSize",type:"numshort",className:"number",render:render_cell_numshort_int},{name:"askSize",data:"askSize",type:"numshort",className:"number",render:render_cell_numshort_int},{name:"regularMarketOpen",data:"regularMarketOpen",type:"numshort",className:"number",render:render_cell_numshort},{name:"regularMarketDayLow",data:"regularMarketDayLow",type:"numshort",className:"number",render:render_cell_numshort},{name:"regularMarketDayHigh",data:"regularMarketDayHigh",type:"numshort",className:"number",render:render_cell_numshort},{name:"regularMarketPreviousClose",data:"regularMarketPreviousClose",type:"numshort",className:"number",render:render_cell_numshort},{name:"fiftyTwoWeekLow",data:"fiftyTwoWeekLow",type:"numshort",className:"number",render:render_cell_numshort},{name:"fiftyTwoWeekHigh",data:"fiftyTwoWeekHigh",type:"numshort",className:"number",render:render_cell_numshort},{name:"fiftyTwoWeekLowChange",data:"fiftyTwoWeekLowChange",type:"numshort",className:"number",render:render_cell_numshort_colored},{name:"fiftyTwoWeekHighChange",data:"fiftyTwoWeekHighChange",type:"numshort",className:"number",render:render_cell_numshort_colored},{name:"fiftyTwoWeekLowChangePercent",data:"fiftyTwoWeekLowChangePercent",type:"percent",className:"number",render:render_cell_percent_colored},{name:"fiftyTwoWeekHighChangePercent",data:"fiftyTwoWeekHighChangePercent",type:"percent",className:"number",render:render_cell_percent_colored},{name:"averageDailyVolume3Month",data:"averageDailyVolume3Month",type:"numshort",className:"number",render:render_cell_numshort_int},{name:"epsTrailingTwelveMonths",data:"epsTrailingTwelveMonths",type:"numshort",className:"number",render:render_cell_numshort_colored},{name:"ebitda",data:"ebitda",type:"numshort",className:"number",render:render_cell_numshort_colored},{name:"trailingPE",data:"trailingPE",type:"numshort",className:"number",render:render_cell_numshort},{name:"pegRatio",data:"pegRatio",type:"numshort",className:"number",render:render_cell_numshort_colored},{name:"bookValue",data:"bookValue",type:"numshort",className:"number",render:render_cell_numshort_colored},{name:"priceToBook",data:"priceToBook",type:"numshort",className:"number",render:render_cell_numshort_colored},{name:"totalCash",data:"totalCash",type:"numshort",className:"number",render:render_cell_numshort},{name:"shortRatio",data:"shortRatio",type:"numshort",className:"number",render:render_cell_numshort},{name:"dividendRate",data:"dividendRate",type:"numshort",className:"number",render:render_cell_numshort},{name:"dividendYield",data:"dividendYield",type:"numshort",className:"number",render:render_cell_numshort},{name:"exDividendDate",data:"exDividendDate",type:"datec"},{name:"fiftyDayAverage",data:"fiftyDayAverage",type:"numshort",className:"number",render:render_cell_numshort},{name:"twoHundredDayAverage",data:"twoHundredDayAverage",type:"numshort",className:"number",render:render_cell_numshort},{name:"fiftyDayAverageChange",data:"fiftyDayAverageChange",type:"numshort",className:"number",render:render_cell_numshort_colored},{name:"fiftyDayAverageChangePercent",data:"fiftyDayAverageChangePercent",type:"numshort",className:"number",render:render_cell_percent_colored},{name:"twoHundredDayAverageChange",data:"twoHundredDayAverageChange",type:"percent",className:"number",render:render_cell_numshort_colored},{name:"twoHundredDayAverageChangePercent",data:"twoHundredDayAverageChangePercent",type:"percent",className:"number",render:render_cell_percent_colored}]}),updateSelectable(),switchTab()}function switchTab(){tbl_api.columns().visible(!1),cols=[];for(i in tab_keys[cur_tab])cols.push(".column-"+tab_keys[cur_tab][i]);tbl_api.columns(cols).visible(!0),$("div.dataTables_wrapper").removeClass("inactive"),$(".linear-activity").addClass("hide"),void 0!=filter_data[cur_market]&&void 0!=filter_data[cur_market][cur_tab]&&void 0!=filter_data[cur_market][cur_tab].s&&void 0!=filter_data[cur_market][cur_tab].s.text?($(".column-s").addClass("filter-set"),$(".column-s .filter-desc").html(filter_data[cur_market][cur_tab].s.text)):($(".column-s").removeClass("filter-set"),$(".column-s .filter-desc").html("")),void 0!=filter_data[cur_market]&&void 0!=filter_data[cur_market][cur_tab]&&void 0!=filter_data[cur_market][cur_tab].n&&void 0!=filter_data[cur_market][cur_tab].n.text?($(".column-n").addClass("filter-set"),$(".column-n .filter-desc").html(filter_data[cur_market][cur_tab].n.text)):($(".column-n").removeClass("filter-set"),$(".column-n .filter-desc").html(""))}function applySelectable(e,a){switch(e){case"time-update":switch(clearInterval(tmr_update),a){case 1:tmr_update=setInterval(function(){tbl_api.ajax.reload(null,!1),$(".refresh-data").attr("title","Last refreshed at "+(new Date).toString("dd MMM yyyy, hh:mm tt"))},6e4);break;case 2:tmr_update=setInterval(function(){tbl_api.ajax.reload(null,!1),$(".refresh-data").attr("title","Last refreshed at "+(new Date).toString("dd MMM yyyy, hh:mm tt"))},3e5);break;case 3:tmr_update=setInterval(function(){tbl_api.ajax.reload(null,!1),$(".refresh-data").attr("title","Last refreshed at "+(new Date).toString("dd MMM yyyy, hh:mm tt"))},6e5)}break;case"stock":cur_market=a,tbl_api.columns().iterator("column",function(e,a){$(tbl_api.column(a).header()).removeClass("filter-set").find(".filter-desc").html("")}),filter_data={},tbl_api.ajax.url(server_uri+"?cmd=get-data&market="+a),tbl_api.ajax.reload(null,!0);break;case"tab":$(".linear-activity").removeClass("hide"),$(".data-view button.active").removeClass("active"),$('button[data-tab="'+a+'"]').addClass("active"),void 0==sorting_data[cur_market]&&(sorting_data[cur_market]={}),sorting_data[cur_market][cur_tab]=tbl_api.order(),cur_tab=a,setTimeout(function(){switchTab(),void 0!=sorting_data[cur_market]&&void 0!=sorting_data[cur_market][cur_tab]&&tbl_api.order(sorting_data[cur_market][cur_tab]),tbl_api.draw()},500);break;case"theme":switch(a){case 0:$("body").removeClass("dark-theme");break;case 1:$("body").addClass("dark-theme")}}}function updateSelectable(){$("select").each(function(){self=$(this),1!=self.data("selectable")&&(idx=selectable_cur_idx,selectable_cur_idx++,self.data("selectable","1"),self.hide(),function(e,a){select=$('<div class="ui-select" data-width="inherit" data-vpull="bottom" data-selectable="1" data-list="autolist-'+a+'" data-value="'+e.val()+'">'+e.find("option:selected").html()+"</div>"),selectable_list["autolist-"+a]={},e.find("option").each(function(){selectable_list["autolist-"+a][$(this).attr("value")]={id:$(this).attr("value"),label:$(this).html(),title:$(this).html()}}),e.after(select),select.on("change",function(){e.val(select.data("value")).change()})}(self,idx))})}var table,tbl_api,server_uri="shares.php",selectable_list={},selectable_cur_idx=0,cur_tab=0,cur_market=0,tmr_update=0;selectable_list.theme_title='<i class="fa fa-paint-brush"></i> <span class="padding-left">Theme</span>',selectable_list.market_title='<i class="fa fa-line-chart"></i> <span class="padding-left">Market</span>',selectable_list.theme=[{id:0,label:'<i class="fa fa-paint-brush"></i>',title:"Light"},{id:1,label:'<i class="fa fa-paint-brush"></i>',title:"Dark"}],selectable_list["time-update_title"]='<i class="fa fa-refresh"></i> <span class="padding-left">Update method</span>',selectable_list["time-update"]=[{id:0,label:'<i class="fa fa-angle-down"></i>',title:"Manual refresh"},{id:1,label:"1m",title:"Refresh every minute"},{id:2,label:"5m",title:"Refresh every 5 minutes"},{id:3,label:"10m",title:"Refresh every 10 minutes"}],selectable_list.tab=[{id:0,label:"Company Details",title:"Company Details"},{id:1,label:"Trading Data",title:"Trading Data"},{id:2,label:"Historical Performance",title:"Historical Performance"},{id:3,label:"Fundamental Analysis",title:"Fundamental Analysis"},{id:4,label:"Technical Analysis",title:"Technical Analysis"}];var data_keys={s:"Symbol",n:"Name",regularMarketPrice:"Last Price",currency:"Currency",regularMarketChange:"Change",regularMarketChangePercent:"% Change",regularMarketVolume:"Volume",sharesOutstanding:"Shares",marketCap:"Market Cap",bid:"Bid",ask:"Ask",bidSize:"Bid Size",askSize:"Ask Size",regularMarketOpen:"Open",regularMarketDayLow:"Day Low",regularMarketDayHigh:"Day High",regularMarketPreviousClose:"Prev Close",fiftyTwoWeekLow:"52 Week Low",fiftyTwoWeekHigh:"52 Week High",fiftyTwoWeekLowChange:"Change 52 Week Low",fiftyTwoWeekHighChange:"Change 52 Week High",fiftyTwoWeekLowChangePercent:"% Change 52 Week Low",fiftyTwoWeekHighChangePercent:"% Change 52 Week High",averageDailyVolume3Month:"Avg Daily Vol 3M",epsTrailingTwelveMonths:"EPS",ebitda:"EBITDA",trailingPE:"PE Ratio",pegRatio:"PEG Ratio",bookValue:"Book Value",priceToBook:"Price / Book",totalCash:"Cash",shortRatio:"Short Ratio",dividendRate:"Div Per Share",dividendYield:"Div Yield",exDividendDate:"Ex-Dividend Date",fiftyDayAverage:"50 Day MA",twoHundredDayAverage:"200 Day MA",fiftyDayAverageChange:"Change 50 Day MA",fiftyDayAverageChangePercent:"% Change 50 Day MA",twoHundredDayAverageChange:"Change 200 Day MA",twoHundredDayAverageChangePercent:"% Change 200 Day MA"},data_key_string_simple=["n"],data_key_string=["s","currency"],data_key_date=["exDividendDate"],data_key_time=[],data_key_percent=["regularMarketChangePercent","fiftyTwoWeekLowChangePercent","fiftyTwoWeekHighChangePercent","fiftyDayAverageChangePercent","twoHundredDayAverageChangePercent"],data_key_names=["s","n","regularMarketPrice","currency","regularMarketChange","regularMarketChangePercent","regularMarketVolume","sharesOutstanding","marketCap","bid","ask","bidSize","askSize","regularMarketOpen","regularMarketDayLow","regularMarketDayHigh","regularMarketPreviousClose","fiftyTwoWeekLow","fiftyTwoWeekHigh","fiftyTwoWeekLowChange","fiftyTwoWeekHighChange","fiftyTwoWeekLowChangePercent","fiftyTwoWeekHighChangePercent","averageDailyVolume3Month","epsTrailingTwelveMonths","ebitda","trailingPE","pegRatio","bookValue","priceToBook","totalCash","shortRatio","dividendRate","dividendYield","exDividendDate","fiftyDayAverage","twoHundredDayAverage","fiftyDayAverageChange","fiftyDayAverageChangePercent","twoHundredDayAverageChange","twoHundredDayAverageChangePercent"],data_key_filter=["s","n","regularMarketPrice","currency","regularMarketChange","regularMarketChangePercent","regularMarketVolume","sharesOutstanding","marketCap","bid","ask","bidSize","askSize","regularMarketOpen","regularMarketDayLow","regularMarketDayHigh","regularMarketPreviousClose","fiftyTwoWeekLow","fiftyTwoWeekHigh","fiftyTwoWeekLowChange","fiftyTwoWeekHighChange","fiftyTwoWeekLowChangePercent","fiftyTwoWeekHighChangePercent","averageDailyVolume3Month","epsTrailingTwelveMonths","ebitda","trailingPE","pegRatio","bookValue","priceToBook","totalCash","shortRatio","dividendRate","dividendYield","exDividendDate","fiftyDayAverage","twoHundredDayAverage","fiftyDayAverageChange","fiftyDayAverageChangePercent","twoHundredDayAverageChange","twoHundredDayAverageChangePercent"],sorting_data={},filter_data={},tab_keys={0:["s","n","regularMarketPrice","currency","regularMarketChange","regularMarketChangePercent","regularMarketVolume","sharesOutstanding","marketCap"],1:["s","n","bid","ask","bidSize","askSize","regularMarketOpen","regularMarketDayLow","regularMarketDayHigh","regularMarketPreviousClose"],2:["s","n","fiftyTwoWeekLow","fiftyTwoWeekHigh","fiftyTwoWeekLowChange","fiftyTwoWeekHighChange","fiftyTwoWeekLowChangePercent","fiftyTwoWeekHighChangePercent","averageDailyVolume3Month"],3:["s","n","epsTrailingTwelveMonths","ebitda","trailingPE","pegRatio","bookValue","priceToBook","totalCash","shortRatio","dividendRate","dividendYield","exDividendDate"],4:["s","n","fiftyDayAverage","twoHundredDayAverage","fiftyDayAverageChange","fiftyDayAverageChangePercent","twoHundredDayAverageChange","twoHundredDayAverageChangePercent"]};$(document).ready(function(){$(".refresh-data").attr("title","Last refreshed at "+(new Date).toString("dd MMM yyyy, hh:mm tt")),$.post(server_uri,{cmd:"get-markets"},function(e){if(e.success){selectable_list.market=[];for(i in e.markets)selectable_list.market.push({id:i,label:'<i class="fa fa-line-chart"></i> <span class="padding-left">'+e.markets[i]+"</span>",title:e.markets[i]});cur_market=selectable_list.market[0].id,$('button[data-list="market"]').data("value",cur_market).html(selectable_list.market[0].label),show_table()}else modal_show("Initialize","Error getting markets")})}),$(document).on("click",".data-view button",function(){$(".data-view button.active").removeClass("active"),$(this).addClass("active"),void 0==sorting_data[cur_market]&&(sorting_data[cur_market]={}),sorting_data[cur_market][cur_tab]=tbl_api.order(),cur_tab=$(this).data("tab"),$("div.dataTables_wrapper").addClass("inactive"),$(".linear-activity").removeClass("hide"),setTimeout(function(){switchTab(),void 0!=sorting_data[cur_market]&&void 0!=sorting_data[cur_market][cur_tab]&&tbl_api.order(sorting_data[cur_market][cur_tab]),tbl_api.draw()},300)}),$(document).on("click","table thead th .filter-btn,table tbody tr .filter-btn",function(e){return e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),self=$(this),function(e,a){var l,s,n=(e.data("value"),e.data("field")),d=data_key_date.indexOf(n)>=0,o=data_key_time.indexOf(n)>=0,c=data_key_percent.indexOf(n)>=0,u=data_key_string.indexOf(n)>=0,_=data_key_string_simple.indexOf(n)>=0,f=numberFormat;c?f=percentFormat:o?f=timeFormat:d?f=dateFormat:(u||_)&&(f=void 0);var p=$(e.parent()).is("span")||$(window).width()<450;ar=getUnique(tbl_api.column(".column-"+e.data("field")).data().toArray());var g=1e14,b=0;for(i in ar)if("N/A"!=ar[i]&&"-"!=ar[i]&&"—"!=ar[i]&&!u){if(c)ar[i]=parseFloat(ar[i].toString().replace("%",""));else if(o){if(r=/^\d{1,2}\:\d\d(am|pm){0,1}$/,t=ar[i].toString().replace(" ",""),!r.test(t))continue;h=0,m=0,"pm"==t.slice(-2)?(h=12,t=t.slice(0,-2)):"am"==t.slice(-2)&&(t=t.slice(0,-2)),h+=parseInt(t.split(":")[0]),m+=parseInt(t.split(":")[1]),t=60*h+m,ar[i]=t}else if(d)ar[i]=new Date(ar[i]).getTime()/1e3;else switch(ar[i][ar[i].length-1]){case"K":ar[i]=1e3*ar[i].slice(0,-1);break;case"M":ar[i]=1e6*ar[i].slice(0,-1);break;case"B":ar[i]=1e9*ar[i].slice(0,-1)}g>parseFloat(ar[i])&&(g=parseFloat(ar[i])),b<parseFloat(ar[i])&&(b=parseFloat(ar[i]))}if(l=$(document.createElement("div")),filter_input_title=$(document.createElement("div")).addClass("filter-title").html(data_keys[n]),l.addClass("popup-filter-input"),l.attr("tabindex","1"),l.append(filter_input_title),reset_btn=$(document.createElement("div")),reset_btn.addClass("reset-btn").html('<i class="fa fa-times"></i>'),l.append(reset_btn),g>b&&!u&&!_)no_data=$('<div class="no-data">No data</div>'),l.append(no_data);else if(u){select=$('<select class="ui dropdown" multiple="" data-placeholder="Select filter(ctrl+click - multiple)..."></select>'),void 0==filter_data[cur_market]&&(filter_data[cur_market]={}),void 0==filter_data[cur_market][cur_tab]&&(filter_data[cur_market][cur_tab]={}),void 0==filter_data[cur_market][cur_tab][n]&&(filter_data[cur_market][cur_tab][n]={}),void 0==filter_data[cur_market][cur_tab][n].val&&(filter_data[cur_market][cur_tab][n].val=[]);for(i in ar)"—"!=ar[i]&&select.append('<option value="'+ar[i]+'"'+(filter_data[cur_market][cur_tab][n].val.indexOf(ar[i])>=0?" selected":"")+">"+ar[i]+"</option>");l.append(select),select.chosen(),select.change(function(){clearTimeout(s),s=setTimeout(function(){void 0==filter_data[cur_market]&&(filter_data[cur_market]={}),void 0==filter_data[cur_market][cur_tab]&&(filter_data[cur_market][cur_tab]={}),void 0==filter_data[cur_market][cur_tab][n]&&(filter_data[cur_market][cur_tab][n]={}),select.val().length>0?(filter_data[cur_market][cur_tab][n].val=select.val(),filter_data[cur_market][cur_tab][n].text=select.val().join(", "),$(".column-"+n).addClass("filter-set"),$(".column-"+n+" .filter-desc").html(select.val().join(", "))):(filter_data[cur_market][cur_tab][n]=void 0,$(".column-"+n).removeClass("filter-set"),$(".column-"+n+" .filter-desc").html("")),tbl_api.draw()},300)})}else _?(vv="",void 0!=filter_data[cur_market]&&void 0!=filter_data[cur_market][cur_tab]&&void 0!=filter_data[cur_market][cur_tab][n]&&void 0!=filter_data[cur_market][cur_tab][n].val&&(vv=filter_data[cur_market][cur_tab][n].val),input=$('<input class="ui input filter-string-simple" value="'+vv+'"/>'),void 0==filter_data[cur_market]&&(filter_data[cur_market]={}),void 0==filter_data[cur_market][cur_tab]&&(filter_data[cur_market][cur_tab]={}),void 0==filter_data[cur_market][cur_tab][n]&&(filter_data[cur_market][cur_tab][n]={}),void 0==filter_data[cur_market][cur_tab][n].val&&(filter_data[cur_market][cur_tab][n].val=[]),l.append(input),input.focus(),input.keyup(function(){clearTimeout(s),s=setTimeout(function(){void 0==filter_data[cur_market]&&(filter_data[cur_market]={}),void 0==filter_data[cur_market][cur_tab]&&(filter_data[cur_market][cur_tab]={}),void 0==filter_data[cur_market][cur_tab][n]&&(filter_data[cur_market][cur_tab][n]={}),input.val().length>0?(filter_data[cur_market][cur_tab][n].val=input.val(),filter_data[cur_market][cur_tab][n].text=input.val(),$(".column-"+n).addClass("filter-set"),$(".column-"+n+" .filter-desc").html(input.val())):(filter_data[cur_market][cur_tab][n]=void 0,$(".column-"+n).removeClass("filter-set"),$(".column-"+n+" .filter-desc").html("")),tbl_api.draw()},300)})):(slider=$(document.createElement("div")),void 0!=filter_data[cur_market]&&void 0!=filter_data[cur_market][cur_tab]&&void 0!=filter_data[cur_market][cur_tab][n]?(cur_min=filter_data[cur_market][cur_tab][n].min,void 0==cur_min&&(cur_min=g),cur_max=filter_data[cur_market][cur_tab][n].max,void 0==cur_max&&(cur_max=b)):(cur_min=g,cur_max=b),slider_lbl_min=$(document.createElement("div")),slider_lbl_max=$(document.createElement("div")),slider_lbl_min.addClass("lbl-from").html(f(g)),slider_lbl_max.addClass("lbl-to").html(f(b)),l.append(slider_lbl_min),l.append(slider_lbl_max),l.append(slider),slider_lbl_range_from=$(document.createElement("input")),slider_lbl_range_to=$(document.createElement("input")),slider_lbl_range=$(document.createElement("div")),slider_lbl_range_from.addClass("lbl-range-from").val(f(cur_min)),slider_lbl_range_to.addClass("lbl-range-to").val(f(cur_max)),slider_lbl_range.addClass("lbl-range").html("-"),l.append(slider_lbl_range_from),l.append(slider_lbl_range_to),l.append(slider_lbl_range),d&&(slider_lbl_range_from.datepicker({dateFormat:"mm/dd/yy",autoclose:!0,beforeShow:function(e,a){setTimeout(function(){$("#ui-datepicker-div").css({position:"absolute",top:slider_lbl_range_from.position().top+slider_lbl_range_from.outerHeight()+10,left:slider_lbl_range_from.position().left})},0),l.append($("#ui-datepicker-div")),$("#ui-datepicker-div").hide()}}),slider_lbl_range_to.datepicker({dateFormat:"mm/dd/yy",autoclose:!0,beforeShow:function(e,a){setTimeout(function(){$("#ui-datepicker-div").css({position:"absolute",top:slider_lbl_range_to.position().top+slider_lbl_range_to.outerHeight()+10,
|
|
left:slider_lbl_range_to.position().left})},0),l.append($("#ui-datepicker-div")),$("#ui-datepicker-div").hide()}})),slider.slider({step:.001,range:!0,orientation:"horizontal",min:parseFloat(g),max:parseFloat(b),values:[parseFloat(cur_min),parseFloat(cur_max)],slide:function(e,a){document.activeElement!=slider_lbl_range_from[0]&&slider_lbl_range_from.val(f(a.values[0])),document.activeElement!=slider_lbl_range_to[0]&&slider_lbl_range_to.val(f(a.values[1])),clearTimeout(s),s=setTimeout(function(){void 0==filter_data[cur_market]&&(filter_data[cur_market]={}),void 0==filter_data[cur_market][cur_tab]&&(filter_data[cur_market][cur_tab]={}),void 0==filter_data[cur_market][cur_tab][n]&&(filter_data[cur_market][cur_tab][n]={}),filter_data[cur_market][cur_tab][n].min=(a.values[0]>1e3||a.values[0]<-1e3)&&Math.round(a.values[0])==Math.round(g)||parseFloat(g).toFixed(2)==parseFloat(a.values[0]).toFixed(2)?void 0:parseFloat(parseFloat(a.values[0]).toFixed(2)),filter_data[cur_market][cur_tab][n].max=(a.values[1]>1e3||a.values[1]<-1e3)&&Math.round(a.values[1])==Math.round(b)||parseFloat(b).toFixed(2)==parseFloat(a.values[1]).toFixed(2)?void 0:parseFloat(parseFloat(a.values[1]).toFixed(2)),void 0!=filter_data[cur_market][cur_tab][n].min||void 0!=filter_data[cur_market][cur_tab][n].max?(tbl_api.draw(),$(".column-"+n).addClass("filter-set"),filter_data[cur_market][cur_tab][n].min==filter_data[cur_market][cur_tab][n].max||void 0==filter_data[cur_market][cur_tab][n].min&&filter_data[cur_market][cur_tab][n].max==g||void 0==filter_data[cur_market][cur_tab][n].max&&filter_data[cur_market][cur_tab][n].min==b?$(".column-"+n+" .filter-desc").html(" = "+f(a.values[1])):void 0==filter_data[cur_market][cur_tab][n].min?$(".column-"+n+" .filter-desc").html(" < "+f(a.values[1])):void 0==filter_data[cur_market][cur_tab][n].max?$(".column-"+n+" .filter-desc").html(" > "+f(a.values[0])):$(".column-"+n+" .filter-desc").html(f(a.values[0])+" - "+f(a.values[1]))):($(".column-"+n).removeClass("filter-set"),$(".column-"+n+" .filter-desc").html(""),filter_data[cur_market][cur_tab][n]=void 0,tbl_api.draw())},300)}}),slider_lbl_range_from.on("keyup change",function(){if(v=$(this).val(),d)v=new Date(v),"Invalid Date"!=v&&(v=v.getTime()/1e3,slider.slider("values",0,v)),slider_lbl_range_from.focus();else if(o)r=/^\d{1,2}\:\d\d(am|pm){0,1}$/,v=v.toString().replace(" ",""),r.test(v)&&(h=0,m=0,"am"==v.slice(-2)?(h=12,v=v.slice(0,-2)):"pm"==v.slice(-2)&&(v=v.slice(0,-2)),h+=parseInt(v.split(":")[0]),m+=parseInt(v.split(":")[1]),v=60*h+m,slider.slider("values",0,v));else if(c)v=parseFloat(v),isNaN(v)||slider.slider("values",0,v);else{switch(v[v.length-1]){case"K":v=1e3*v.slice(0,-1);break;case"M":v=1e6*v.slice(0,-1);break;case"B":v=1e9*v.slice(0,-1)}v=parseFloat(v),isNaN(v)||slider.slider("values",0,v)}slider.slider("option","slide")(null,{values:slider.slider("values")})}),slider_lbl_range_to.on("keyup change",function(){if(v=$(this).val(),d)v=new Date(v),"Invalid Date"!=v&&(v=v.getTime()/1e3,slider.slider("values",1,v)),slider_lbl_range_to.focus();else if(o)r=/^\d{1,2}\:\d\d(am|pm){0,1}$/,v=v.toString().replace(" ",""),r.test(v)&&(h=0,m=0,"am"==v.slice(-2)?(h=12,v=v.slice(0,-2)):"pm"==v.slice(-2)&&(v=v.slice(0,-2)),h+=parseInt(v.split(":")[0]),m+=parseInt(v.split(":")[1]),v=60*h+m,slider.slider("values",1,v));else if(c)v=parseFloat(v),isNaN(v)||slider.slider("values",1,v);else{switch(v[v.length-1]){case"K":v=1e3*v.slice(0,-1);break;case"M":v=1e6*v.slice(0,-1);break;case"B":v=1e9*v.slice(0,-1)}v=parseFloat(v),isNaN(v)||slider.slider("values",1,v)}slider.slider("option","slide")(null,{values:slider.slider("values")})}));reset_btn.click(function(){void 0==filter_data[cur_market]&&(filter_data[cur_market]={}),void 0==filter_data[cur_market][cur_tab]&&(filter_data[cur_market][cur_tab]={}),filter_data[cur_market][cur_tab][n]=void 0,tbl_api.draw(),$(".column-"+n).removeClass("filter-set"),$(".column-"+n+" .filter-desc").html(""),f_close()}),tab_idx=2,l.find("*",function(){$(this).attr("tabindex",tab_idx),tab_idx++}),$("body").append(l),p?(l.css("left","0"),l.css("right","0"),l.css("margin","auto"),l.addClass("pull-center")):e.offset().left>400?(l.css("right","calc( 100vw - "+(e.offset().left+e.outerWidth())+"px )"),l.addClass("pull-right")):e.offset().left<=400&&(l.css("left",e.offset().left+"px"),l.addClass("pull-left")),l.css("top",e.offset().top),l.addClass("show"),l.focus(),f_close=function(){l.addClass("hide"),l.on("animationend webkitAnimationEnd oanimationend MSAnimationEnd",function(){l.remove()})},l.focusout(function(e){var a=$(this);setTimeout(function(){a.find(":focus").length||a[0]==document.activeElement||f_close()},0)})}(self,e),!1}),$(document).on("click",".refresh-data",function(){tbl_api.ajax.reload(null,!1),$(".refresh-data").attr("title","Last refreshed at "+(new Date).toString("dd MMM yyyy, hh:mm tt"))}),$(document).on("click",".dataTable tbody tr td:first-child,.dataTable tbody tr td:nth-child(2)",function(){return tr=$(this).closest("tr"),row_data=tbl_api.row(tr[0]).data(),swal({showConfirmButton:!1,showCancelButton:!1,buttonsStyling:!1,title:"Fetching data on "+row_data.s,html:'<div class="share-info-modal-loading"><span><i class="fa fa-gear fa-spin"></i></span></div>',background:""}),$.post(server_uri,{cmd:"get-share-info",share:row_data.s},function(e){if(e.success){if(data={},void 0!=e.data&&void 0!=e.data.quoteSummary&&void 0!=e.data.quoteSummary.result&&void 0!=e.data.quoteSummary.result[0]&&void 0!=e.data.quoteSummary.result[0].summaryProfile&&(data=e.data.quoteSummary.result[0].summaryProfile),html="",addr=[],void 0!=data.address1&&addr.push(data.address1),void 0!=data.address2&&addr.push(data.address2),void 0!=data.city&&addr.push(data.city),void 0!=data.state&&addr.push(data.state),void 0!=data.zip&&addr.push(data.zip),void 0!=data.country&&addr.push(data.country),html='<div class="modal-share-info"><h2>'+row_data.n+'</h2><div class="modal-share-left"><div class="modal-share-line description"><label>Description: \t</label><div class="text-folding"><div>'+(void 0!=data.longBusinessSummary?data.longBusinessSummary:"-")+'</div></div></div><div class="modal-share-line"><label>Address: \t\t\t</label><span>'+(0!=addr.length?'<a target="_blank" href="https://maps.google.com/?q='+addr.join(",")+'">'+addr.join(", ")+"</a>":"-")+'</span></div><div class="modal-share-line"><label>Phone: \t\t\t\t</label><span>'+(void 0!=data.phone&&data.phone.length>0?data.phone:"-")+'</span></div><div class="modal-share-line"><label>Website: \t\t\t</label><span>'+(void 0!=data.website&&data.website.length>0?'<a target="_blank" href="'+data.website+'">'+data.website+"</a>":"-")+'</span></div><div class="modal-share-line"><label>Industry: \t\t</label><span>'+(void 0!=data.industry&&data.industry.length>0?data.industry:"-")+'</span></div><div class="modal-share-line"><label>Sector: \t\t\t</label><span>'+(void 0!=data.sector&&data.sector.length>0?data.sector:"-")+'</span></div><div class="modal-share-line"><label>Employees: \t\t</label><span>'+(void 0!=data.fullTimeEmployees&&data.fullTimeEmployees.toString().length>0?data.fullTimeEmployees:"-")+'</span></div></div><div class="modal-share-right"><canvas id="chart"></canvas></div></div><div class="modal-share-info-summary"><table><tr><td>Last Trade Price</td><td>Currency</td><td>Change</td><td>Change (%)</td><td>Market Cap</td><td>Volume</td><td>52 Week Low</td><td>52 Week High</td></tr><tr><td><span class="mobile-label">Last Trade Price</span>'+render_cell_numshort(row_data.regularMarketPrice)+'</td><td><span class="mobile-label">Currency</span>'+row_data.currency+'</td><td><span class="mobile-label">Change</span>'+render_cell_numshort_colored(row_data.regularMarketChange)+'</td><td><span class="mobile-label">Change (%)</span>'+render_cell_percent_colored(row_data.regularMarketChangePercent)+'</td><td><span class="mobile-label">Market Cap</span>'+render_cell_numshort(row_data.marketCap)+'</td><td><span class="mobile-label">Volume</span>'+render_cell_numshort_int(row_data.regularMarketVolume)+'</td><td><span class="mobile-label">52 Week Low</span>'+render_cell_numshort(row_data.fiftyTwoWeekLow)+'</td><td><span class="mobile-label">52 Week High</span>'+render_cell_numshort(row_data.fiftyTwoWeekHigh)+"</td></tr></table></div>",swal({allowOutsideClick:!0,width:"",customClass:"modal-share",showConfirmButton:!0,showCancelButton:!1,buttonsStyling:!1,title:"",html:html,background:""}).catch(swal.noop),"undefined"!=typeof e.historical_data.quotes){Chart.defaults.global.defaultFontColor=$("body").hasClass("dark-theme")?"#ffffff":"#3e2723";var a=$(document).find("#chart");new Chart(a.get(0),{type:"line",data:{labels:e.historical_data.dates,datasets:[{label:row_data.n,data:e.historical_data.quotes,borderColor:"rgb(11, 137, 195)",backgroundColor:"rgba(11, 137, 195, 0.3)",fill:!0,borderWidth:1,pointRadius:0}]},options:{responsive:!0,scales:{yAxes:[{ticks:{beginAtZero:!1,min:.95*Math.min.apply(null,e.historical_data.quotes),max:1.05*Math.max.apply(null,e.historical_data.quotes)}}]}}})}}else swal({buttonsStyling:!1,title:"Oops...",text:e.message,type:"error",background:""})}).fail(function(){swal({buttonsStyling:!1,title:"Oops...",text:"Something went wrong!",type:"error",background:""})}),!1}),$(document).on("click",'*[data-selectable="1"]',function(e){e.preventDefault(),e.stopPropagation(),self=$(this),function(e,a){var t;if(val=e.data("value"),e.css("position","relative"),list=e.data("list"),void 0!=selectable_list[list]){if(t=$(document.createElement("div")),t.addClass("table-select-input"),t.data("value",val),t.attr("tabindex","1"),void 0!=selectable_list[list+"_title"]){title=$('<div class="table-select-title ripplelink">'+selectable_list[list+"_title"]+"</div>"),t.append(title);var r,l,s,n;r=$(document.createElement("div")),title.prepend(r),r.addClass("ink"),r.height()||r.width()||(l=Math.max(e.outerWidth(),e.outerHeight()),r.css({height:l,width:l})),s=a.pageX-e.offset().left-r.width()/2,n=a.pageY-e.offset().top-r.height()/2,r.css({top:n+"px",left:s+"px"}).addClass("animate")}for(i in selectable_list[list])t.append('<div class="table-select-input-item ripplelink '+(val==selectable_list[list][i].id?" selected":"")+'" data-value="'+selectable_list[list][i].id+'">'+selectable_list[list][i].title+"</div>");$("body").append(t),"inherit"==e.data("width")&&t.css("width",e.outerWidth()),"right"==e.data("pull")?(t.css("right","calc( 100vw - "+(e.offset().left+e.outerWidth())+"px )"),t.addClass("pull-right")):t.css("left",e.offset().left),"bottom"==e.data("vpull")?(t.css("bottom","calc( 100vh - "+(e.offset().top+e.outerHeight())+"px )"),t.addClass("pull-bottom")):t.css("top",e.offset().top),t.addClass("show"),t.focus(),apply=function(){val=t.data("value"),setTimeout(function(){t.addClass("hide"),t.on("animationend webkitAnimationEnd oanimationend MSAnimationEnd",function(){t.remove()})},500),e.html(selectable_list[list][val].label),e.data("value",val),e.trigger("change"),applySelectable(e.data("field"),e.data("value"))},cancel=function(){t.addClass("hide"),t.on("animationend webkitAnimationEnd oanimationend MSAnimationEnd",function(){t.remove()})},t.focusout(function(e){cancel()}),t.find(".table-select-input-item").on("click",function(){return $(this).hasClass("selected")?cancel():(t.find(".selected").removeClass("selected"),$(this).addClass("selected"),t.data("value",$(this).data("value")),void apply())})}}(self,e)}),$(document).on("click",".ripplelink",function(e){self=$(this),function(e,a){var t,r,l,i;t=$(document.createElement("div")),e.prepend(t),t.addClass("ink"),t.height()||t.width()||(r=Math.max(e.outerWidth(),e.outerHeight()),t.css({height:r,width:r})),l=a.pageX-e.offset().left-t.width()/2,i=a.pageY-e.offset().top-t.height()/2,t.css({top:i+"px",left:l+"px"}).addClass("animate"),t.on("animationend webkitAnimationEnd oanimationend MSAnimationEnd",function(){t.remove(),e.trigger("rippleend")})}(self,e)}); |