function URLdecode(e){for(var t="",i=0;i<e.length;i++){var a=e.charAt(i)
if("+"==a)t+=" "
else if("%"==a){var n=e.substring(i+1,i+3)
parseInt("0x"+n)>127?(t+=decodeURI("%"+e.substring(i+1,i+9)),i+=8):(t+=String.fromCharCode(parseInt("0x"+n)),i+=2)}else t+=a}return t}function setCookie(e,t){var i=30,a=new Date
a.setTime(a.getTime()+24*i*60*60*1e3),document.cookie=e+"="+escape(t)+";expires="+a.toGMTString()}function getCookie(e){var t,i=RegExp("(^| )"+e+"=([^;]*)(;|$)")
return(t=document.cookie.match(i))?unescape(t[2]):null}function delCookie(e){var t=new Date
t.setTime(t.getTime()-1)
var i=getCookie(e)
null!=i&&(document.cookie=e+"="+i+";expires="+t.toGMTString())}function iAjax(){var e=null,t=function(e){},i=function(e){},a=null,n=1,o=0
this.startLoading=function(){if(a=$("ajaxloading"),null==a){var e="<div id='ajaxloading' style='position: fixed; top: 50%; left: 0px; right: 0px; height: 40px; color: rgb(255, 255, 255); font-size: 16px; line-height: 40px; display: none; z-index: 999999; background: rgba(120, 180, 220, 0.9);width: 150px;margin: 0 auto;text-align: center;border-radius: 10px;'>Loading...</div>",t=document.createElement("div")
t.id="ajaxloading",document.body.appendChild(t),$("ajaxloading").outerHTML=e,a=$("ajaxloading")}null!=a&&(a.style.display="block",o=setInterval(function(){if("none"!=a.style.display){n>6&&(n=1)
var e=Array(n).join(" · "),t="Loading"+e
a.innerHTML=t,n++}},300))},this.stopLoading=function(){clearInterval(o),null!=a&&(a.style.display="none")},this._init=function(){try{e=new ActiveXObject("Msxml2.XMLHTTP")}catch(t){try{e=new ActiveXObject("Microsoft.XMLHTTP")}catch(t){e=new XMLHttpRequest}}},this.isBusy=!1,this.postform=function(a,n,o,s){this.isBusy=!0,this.startLoading()
var r=document.getElementById(a),l=r.attributes.action.nodeValue,d=new FormData(r)
t=o,i=s,this._init()
var c=encJson(n)
e.open("POST",host+l+"?"+c,!0)
var g=this
e.onreadystatechange=function(){if(4==e.readyState)if(g.isBusy=!1,g.stopLoading(),200==e.status){var t=e.responseText
if(t.length>0){var i=decJson(t)
o&&o(i)}else s&&s(i)}else iToasts.show("网络连接失败",!0)},e.send(d)},this.get=function(t,i,a,n){this.isBusy=!0,this.startLoading(),this._init()
var o=encJson(i)
e.open("GET",host+t+"?"+o,!0)
var s=this
e.onreadystatechange=function(){if(4==e.readyState)if(s.isBusy=!1,s.stopLoading(),200==e.status){var t=e.responseText
if(t.length>0){var i=decJson(t)
a&&a(i)}else n&&n()}else iToasts.show("网络连接失败",!0),n&&n()},e.send(null)}}function iCacheList(){this.data={result:0,error:0,items:[]},this.complete=!1,this.start=0,this.update=function(e,t,i,a,n){if(i>LOADMORE_CACHE||this.data.items.length<1){if(i==LOADMORE_NORMAL&&this.complete)return
i==LOADMORE_REFRESH&&(this.start=0,this.complete=!1)
var o=this,s=new iAjax
t.start=this.start,s.get(e,t,function(e){if(0==e.error)if(o.complete=e.items.length<1,o.start+=e.items.length,i==LOADMORE_REFRESH)o.data=e
else for(var t=0;t<e.items.length;t++)o.data.items.push(e.items[t])
a(e)},function(){n&&n()})}else a(this.data)}}function confirmDlg(e,t,i,a,n,o,s){this.onOk=n,this.onCancel=o
var r="<div id='"+t+"' class='popmenuwrapper'><div class='dialog'><div class='title'>"+i+"</div><div style='color:#333;' class='content'>"+a+"</div><div class='buttons'><span id='jdlgonok' class='btn' onclick='iDlgs.onOk(\""+t+"\");'>"+s+"</span><span class='btn' onclick='iDlgs.onCancel(\""+t+"\");' style='background:#c4c4c4;margin-left:15px;'>取消</span></div></div></div>"
getIgDlgs().innerHTML+=r,popuplist.push(t)}function messageDlg(e,t,i,a){this.onOk=function(){},this.onCancel=function(){}
var n="<div id='"+t+"' class='popmenuwrapper'><div class='dialog'><div class='title'>"+i+"</div><div class='content'>"+a+"</div><div class='buttons'><span id='jdlgonok' class='btn' onclick='iDlgs.onOk(\""+t+"\");'>确定</span></div></div></div>"
getIgDlgs().innerHTML+=n,popuplist.push(t)}function iPopupList(){this.zindex=500,this.plist=[],this.push=function(e){this.pop(e)
var t=$(e)
t&&(this.zindex++,t.style.display="block",t.style.zIndex=this.zindex,this.plist.push(t))},this.pop=function(e){if(0==e){if(this.plist.length>0){var t=this.plist.pop()
return t.style.display="none",!0}return!1}for(var t=$(e),i=0;i<this.plist.length;i++)if(this.plist[i]==t)return t.style.display="none",this.plist.splice(i,1),!0
return t?(t.style.display="none",!0):!1},this.toggle=function(e){var t=$(e)
t&&("none"==t.style.display?this.push(e):this.pop(e))}}function disableButton(e){e.disabled=!0,e.previousColor=e.style.background,e.style.background="#ccc",e.style.cursor="wait"}function enableButton(e){e.disabled=!1,e.style.cursor="pointer",e.style.background=e.previousColor}function canClick(e){return e.lastclicktime&&(new Date).getTime()-e.lastclicktime<500?!1:(e.lastclicktime=(new Date).getTime(),!0)}function checkField(e,t,i,a){var n=document.getElementById(e)
return n.value.length<t||n.value.length>i?(iToasts.show(a,!0),n.focus(),!1):!0}function jSubString(e,t,i){for(var a=0,n="",o=/[^\x00-\xff]/g,s="",r=e.replace(o,"**").length,l=0;r>l&&(s=""+e.charAt(l),null!=s.match(o)?a+=2:a++,!(a>t));l++)n+=s
return i&&r>t&&(n+="..."),n}function getLiveValues(){_DEBUG_=!("undefined"!=typeof hex&&void 0!==hex.applicationDirectoryPath),""==$("marketDataDate").value&&($("marketDataDate").value=(new Date).Format("yyyy-MM-dd"))
var e=parseInt($("marketDataDate").value.replace(/\-/g,""))
if(getLiveValuesthreadCount=0,liveValuesDayfile=_DEBUG_?"E:/stock/0fupan/ddyouzi/data/days/"+e+".txt":hex.applicationDirectoryPath+"/data/days/"+e+".txt",isLoadFromLocal=!1,fs.existsSync(liveValuesDayfile)){var t=fs.readFileSync(liveValuesDayfile,{encoding:"utf8"})
if(liveValues=JSON.parse(t),liveValues.currentTime>=1500)return isLoadFromLocal=!0,void drawCharts()}iDlgs.confirm("系统提示","确定要计算所有股票实时数据吗？全部完成大概需要5-10分钟时间。",function(){realGetLiveValues(e)},function(){})}function initLiveValues(){liveValues={md_positive:0,md_negative:0,md_positive2:0,md_negative2:0,amount:0,aboveAvg:0,avgRiseCount:0,minutes:[]},liveValues.duoKongOptions={color:["red","green","coral","chartreuse","lightgray"],title:{text:"实时多空资金数据"},tooltip:{trigger:"axis"},legend:{data:["多头资金","空头资金","盈利资金","亏损资金","多空净额"]},calculable:!0,xAxis:[{type:"category",boundaryGap:!1,axisLabel:{interval:29},data:[]}],yAxis:[{type:"value",axisLabel:{formatter:"{value} 亿"}}],series:[{name:"多头资金",type:"line",symbol:"none",data:[]},{name:"空头资金",type:"line",symbol:"none",data:[]},{name:"盈利资金",type:"line",symbol:"none",data:[]},{name:"亏损资金",type:"line",symbol:"none",data:[]},{name:"多空净额",type:"line",symbol:"none",smooth:!0,itemStyle:{normal:{color:"lightgray",areaStyle:{type:"default"}}},data:[]}]},liveValues.zhangDieOptions={color:["red","green","coral","chartreuse"],title:{text:"实时涨跌停数据"},tooltip:{trigger:"axis"},legend:{data:["涨停数","跌停数","涨5%数","跌5%数"]},calculable:!0,xAxis:[{type:"category",boundaryGap:!1,axisLabel:{interval:29},data:[]}],yAxis:[{type:"value",axisLabel:{formatter:"{value}"}}],series:[{name:"涨停数",type:"line",symbol:"none",data:[]},{name:"跌停数",type:"line",symbol:"none",data:[]},{name:"涨5%数",type:"line",symbol:"none",data:[]},{name:"跌5%数",type:"line",symbol:"none",data:[]}]}
var e=new Date
e=parseInt(e.Format("hhmm")),getLastTradeDay()!=parseInt((new Date).Format("yyyyMMdd"))&&(e=1501),liveValues.currentTime=e
for(var t=new Date((new Date).Format("yyyy/MM/dd")+" 09:30:00"),i=0;240>i;i++){t.addMinutes(1)
var a=t.Format("hh:mm")
0==i?(liveValues.duoKongOptions.xAxis[0].data[i]=t.Format("MM/dd"),liveValues.zhangDieOptions.xAxis[0].data[i]=t.Format("MM/dd")):(liveValues.duoKongOptions.xAxis[0].data[i]=a,liveValues.zhangDieOptions.xAxis[0].data[i]=a)
var n=parseInt(t.Format("hhmm"))
if(e>n){for(k in liveValues.duoKongOptions.series)liveValues.duoKongOptions.series[k].data[i]=0
for(k in liveValues.zhangDieOptions.series)liveValues.zhangDieOptions.series[k].data[i]=0}1130==n&&t.addMinutes(90)}}function getHistoryMinline(e,t){getLiveValuesthreadCount--
var i=t.substr(2),a=new tdxMinutes(i)
if(0!=a.length)for(var n=a.length-240;n>0;n-=240){var o=new a.get(n)
if(o.day==e){var s=new a.get(n-1),r=100*(o.close/s.close-1)
if(0==s.close||-11>r||r>11)return
for(var l={p1:0,n1:0,p2:0,n2:0},d=n;n+240>d;d++)if(!(d-n>=liveValues.zhangDieOptions.series[0].data.length)){var o=new a.get(d)
if(0!=o.close&&0!=s.close){if(liveValues.amount+=o.amount,o.close>s.close){var c=10+100*(o.close/s.close-1)
l.p1+=Math.floor(c*o.amount/2)}else{var c=100*(o.close/s.close-1)-10
l.n1+=Math.floor(c*o.amount/2)}for(var g=0,u=0,h=n;d>=h;h++){var m=new a.get(h)
if(m.close<o.close){var c=100*(o.close/m.close-1)
u+=Math.floor(c*m.amount)}else{var c=100*(o.close/m.close-1)
g+=Math.floor(c*m.amount)}}Math.round(100*o.close)==Math.round(110*s.close)?liveValues.zhangDieOptions.series[0].data[d-n]++:Math.round(100*o.close)==Math.round(90*s.close)&&liveValues.zhangDieOptions.series[1].data[d-n]++
var p=1.05,f=.95
_DINGZHI_1&&(p=1.02,f=.98),o.close/s.close>p?liveValues.zhangDieOptions.series[2].data[d-n]++:o.close/s.close<f&&liveValues.zhangDieOptions.series[3].data[d-n]++,liveValues.duoKongOptions.series[0].data[d-n]+=l.p1/1e9,liveValues.duoKongOptions.series[1].data[d-n]+=Math.abs(l.n1/1e9),liveValues.duoKongOptions.series[2].data[d-n]+=u/1e9,liveValues.duoKongOptions.series[3].data[d-n]+=Math.abs(g/1e9),liveValues.duoKongOptions.series[4].data[d-n]=liveValues.duoKongOptions.series[0].data[d-n]-liveValues.duoKongOptions.series[1].data[d-n]}}drawCharts()
break}}}function getLiveMinline(e){var t=new jAjax,i="http://gupiao.baidu.com/api/stocks/stocktimeline?from=pc&os_ver=1&cuid=xxx&vv=100&format=json&stock_code="+e
t.json_get(i,function(e){getLiveValuesthreadCount--
var t=null
try{t=JSON.parse(e)}catch(i){}if(null==t)return void iToasts.show("解析错误",!0)
if(!(void 0===t.timeLine||t.timeLine.length<1)){var a=t.timeLine[t.timeLine.length-1],n=100*(a.price/t.preClose-1)
if(a.avgPrice<a.price&&liveValues.aboveAvg++,a.avgPrice>t.preClose&&liveValues.avgRiseCount++,!(-11>n||n>11)){for(var o={p1:0,n1:0,p2:0,n2:0},s=0;s<t.timeLine.length;s++)if(!(16>s||s-16>=liveValues.zhangDieOptions.series[0].data.length)){var r=t.timeLine[s-1],l=t.timeLine[s]
if(liveValues.amount+=l.amount,l.price>r.price){var d=10+100*(l.price/l.preClose-1)
o.p1+=Math.floor(d*l.amount/2)}else{var d=100*(l.price/l.preClose-1)-10
o.n1+=Math.floor(d*l.amount/2)}for(var c=0,g=0,u=16;s>=u;u++){var h=t.timeLine[u]
if(h.price<l.price){var d=100*(l.price/h.price-1)
g+=Math.floor(d*h.amount)}else{var d=100*(l.price/h.price-1)
c+=Math.floor(d*h.amount)}}Math.round(100*l.price)==Math.round(110*l.preClose)?liveValues.zhangDieOptions.series[0].data[s-16]++:Math.round(100*l.price)==Math.round(90*l.preClose)&&liveValues.zhangDieOptions.series[1].data[s-16]++,l.price/l.preClose>1.05?liveValues.zhangDieOptions.series[2].data[s-16]++:l.price/l.preClose<.95&&liveValues.zhangDieOptions.series[3].data[s-16]++,liveValues.duoKongOptions.series[0].data[s-16]+=o.p1/1e9,liveValues.duoKongOptions.series[1].data[s-16]+=Math.abs(o.n1/1e9),liveValues.duoKongOptions.series[2].data[s-16]+=g/1e9,liveValues.duoKongOptions.series[3].data[s-16]+=Math.abs(c/1e9),liveValues.duoKongOptions.series[4].data[s-16]=liveValues.duoKongOptions.series[0].data[s-16]-liveValues.duoKongOptions.series[1].data[s-16]}drawCharts()}}},function(){drawCharts(),getLiveValuesthreadCount--,iToasts.show("联网失败",!0)})}function drawCharts(){if($("liveMarketInfo").innerHTML="未计算股票剩余"+getLiveValuesIndex+" 只",0>=getLiveValuesIndex&&0==getLiveValuesthreadCount){if(!isLoadFromLocal){for(k in liveValues.duoKongOptions.series)for(var e in liveValues.duoKongOptions.series[k].data)liveValues.duoKongOptions.series[k].data[e]=Math.round(liveValues.duoKongOptions.series[k].data[e])
var t=JSON.stringify(liveValues)
fs.writeFileSync(liveValuesDayfile,t)}for(var i=parseInt($("marketDataDays").value)-1,a=new Date($("marketDataDate").value.replace(/\-/g,"/")),e=0;i>e;e++)if(a.addDays(-1),0==a.getDay()&&a.addDays(-2),6==a.getDay()&&a.addDays(-1),liveValuesDayfile=_DEBUG_?"E:/stock/0fupan/ddyouzi/data/days/"+a.Format("yyyyMMdd")+".txt":hex.applicationDirectoryPath+"/data/days/"+a.Format("yyyyMMdd")+".txt",fs.existsSync(liveValuesDayfile)){var n=fs.readFileSync(liveValuesDayfile,{encoding:"utf8"}),o=JSON.parse(n)
liveValues.duoKongOptions.xAxis[0].data=o.duoKongOptions.xAxis[0].data.concat(liveValues.duoKongOptions.xAxis[0].data),liveValues.zhangDieOptions.xAxis[0].data=o.zhangDieOptions.xAxis[0].data.concat(liveValues.zhangDieOptions.xAxis[0].data)
for(k in liveValues.duoKongOptions.series)liveValues.duoKongOptions.series[k].data=o.duoKongOptions.series[k].data.concat(liveValues.duoKongOptions.series[k].data)
for(k in liveValues.zhangDieOptions.series)liveValues.zhangDieOptions.series[k].data=o.zhangDieOptions.series[k].data.concat(liveValues.zhangDieOptions.series[k].data)}liveValues.duoKongOptions.series[0].data.length>2e3?liveValues.duoKongOptions.xAxis[0].axisLabel.interval=119:liveValues.duoKongOptions.series[0].data.length>1e3&&(liveValues.duoKongOptions.xAxis[0].axisLabel.interval=59),liveValues.zhangDieOptions.series[0].data.length>2e3?liveValues.zhangDieOptions.xAxis[0].axisLabel.interval=119:liveValues.zhangDieOptions.series[0].data.length>1e3&&(liveValues.zhangDieOptions.xAxis[0].axisLabel.interval=59)
var s=echarts.init($("liveDuoKongData"))
s.setOption(liveValues.duoKongOptions)
var r=echarts.init($("liveZhangDieData"))
r.setOption(liveValues.zhangDieOptions)}$("spanDuotou").innerHTML=parseInt(liveValues.duoKongOptions.series[0].data[liveValues.duoKongOptions.series[0].data.length-1])+"亿",$("spanKongtou").innerHTML=parseInt(liveValues.duoKongOptions.series[1].data[liveValues.duoKongOptions.series[1].data.length-1])+"亿",$("spanYingli").innerHTML=parseInt(liveValues.duoKongOptions.series[2].data[liveValues.duoKongOptions.series[2].data.length-1])+"亿",$("spanKuisun").innerHTML=parseInt(liveValues.duoKongOptions.series[3].data[liveValues.duoKongOptions.series[3].data.length-1])+"亿",$("spanJinge").innerHTML=parseInt(liveValues.duoKongOptions.series[4].data[liveValues.duoKongOptions.series[4].data.length-1])+"亿",$("spanZhangting").innerHTML=liveValues.zhangDieOptions.series[0].data[liveValues.zhangDieOptions.series[0].data.length-1],$("spanDieting").innerHTML=liveValues.zhangDieOptions.series[1].data[liveValues.zhangDieOptions.series[1].data.length-1],$("spanZhang5").innerHTML=liveValues.zhangDieOptions.series[2].data[liveValues.zhangDieOptions.series[2].data.length-1],$("spanDie5").innerHTML=liveValues.zhangDieOptions.series[3].data[liveValues.zhangDieOptions.series[3].data.length-1]}function showLiveNews(e){$("liveNewsWrapper").style.display="block"==$("liveNewsWrapper").style.display?"none":"block","block"==$("liveNewsWrapper").style.display&&getLiveNews(1)}function calcMoneyDriver(e,t){for(h in alldays)alldays[h].day>=e&&alldays[h].day<=t&&(alldays[h].md_amount=0,alldays[h].md_positive=0,alldays[h].md_negative=0,alldays[h].md_positive2=0,alldays[h].md_negative2=0)
for(var i=tdxFolder+"/T0002/blocknew/ALLA.blk",a=fs.readFileSync(i,{encoding:"utf8"}),n=a.split("\r\n"),o=0;o<n.length;o++){var s=n[o],r=s.substr(1),l=new tdxDays(r),d=new tdxMinutes(r)
if(0!=d.length&&0!=l.length)for(var c=l.length-1;c>0;c--){var g=new l.get(c),u=new l.get(c-1)
if(g.day>=e&&g.day<=t){var h="day"+g.day
if(void 0===alldays[h])continue
alldays[h].md_amount=void 0===alldays[h].md_amount?0:alldays[h].md_amount,alldays[h].md_positive=void 0===alldays[h].md_positive?0:alldays[h].md_positive,alldays[h].md_negative=void 0===alldays[h].md_negative?0:alldays[h].md_negative,alldays[h].md_positive2=void 0===alldays[h].md_positive2?0:alldays[h].md_positive2,alldays[h].md_negative2=void 0===alldays[h].md_negative2?0:alldays[h].md_negative2
var m=100*(g.close/u.close-1)
if(-11>m||m>11)continue
alldays[h].md_amount+=Math.floor(g.amount)
for(var p=d.length-240*(l.length-c),f=p;f<d.length;f++){var y=new d.get(f),v=100*(y.close/(u.close/100)-1)
v>0&&g.day==y.day?alldays[h].md_positive+=Math.floor(v*y.amount):0>v&&g.day==y.day&&(alldays[h].md_negative+=Math.floor(v*y.amount)),v=m-v,v>0&&g.day==y.day?alldays[h].md_positive2+=Math.floor(v*y.amount):0>v&&g.day==y.day&&(alldays[h].md_negative2+=Math.floor(v*y.amount))}}else if(g.day<e)break}}for(h in alldays)alldays[h].day>=e&&alldays[h].day<=t&&(alldays[h].md_amount=parseInt(alldays[h].md_amount/1e8),alldays[h].md_positive=parseInt(alldays[h].md_positive/1e8),alldays[h].md_negative=parseInt(alldays[h].md_negative/1e8),alldays[h].md_positive2=parseInt(alldays[h].md_positive2/1e8),alldays[h].md_negative2=parseInt(alldays[h].md_negative2/1e8))
saveAlldays()}function calcMDToday(){var e=(new Date,getLastTradeDay())
iDlgs.confirm("系统提示","确定要计算今天的资金驱动力吗（"+e+"）？",function(){calcMoneyDriver(e,e),iToasts.show("计算成功",!1)},function(){})}function calcMD(){iDlgs.confirm("系统提示","确定要计算指定日期区间的资金驱动力吗？",function(){var e=parseInt($("startdate").value.replace(/\-/g,"")),t=parseInt($("enddate").value.replace(/\-/g,""))
calcMoneyDriver(e,t),iToasts.show("计算成功",!1)},function(){})}function showTsfupan(e){$("tsfupanWrapper").style.display="block"}function getHistoryTickData(e,t){tsstock.stock.getTick({code:e,date:t},function(e,t){console.log(data)})}function stockCreateImage(e){if(null==userinfo)return void popuplist.push("divuserlogin")
if(!checkvuser())return void popuplist.push("divuserbindsn")
if(!e.disabled){disableButton(e),setTimeout(function(){enableButton(e)},6e3)
var t=$("stockCode").value,i=$("buyTimes").value,a=$("sellTimes").value
tsstock.currentStockCode=t
var n=$("stockBuyDate").value.replace(/\-/g,"/"),o=$("stockSellDate").value.replace(/\-/g,"/"),s=parseFloat($("stockBuyPrice").value),r=parseFloat($("stockSellPrice").value),l=(r>s?"盈利+":"亏损")+(100*(r/s-1)).toFixed(2)+"%"
if($("stockProfitPoint").innerHTML=l,$("stockProfitPoint").style.color=r>s?"red":"green",void 0!==gmAllStocks.items[t]){gmTradeFupan.useCount++
var d=$("stockBuyDate").value.replace(/\-/g,"")
if(d in alldays){var c=alldays[d]
$("divIndexBuyMemo").innerHTML="<b style='color:#ccc'>买入日两市</b> 涨停:"+c.zt+" 开板:"+c.kb+" 跌停:"+c.dt,1==gConfig.cfgShowLTStocks&&($("divBuyMemo").innerHTML="当日强势股："+gmFupan.getLongtouStr(c,{}))}if(d=$("stockSellDate").value.replace(/\-/g,""),d in alldays){var c=alldays[d]
$("divIndexSellMemo").innerHTML="<b style='color:#ccc'>卖出日两市</b> 涨停:"+c.zt+" 开板:"+c.kb+" 跌停:"+c.dt,1==gConfig.cfgShowLTStocks&&($("divSellMemo").innerHTML="当日强势股："+gmFupan.getLongtouStr(c,{}))}var g={}
g.code=tsstock.codeToTdxIndex(t),g.name="对应大盘"
var u={stock:g,isGetIndex:!0,buydate:n,selldate:o,buytimes:i,selltimes:a,datacount:40,KChartDivId:"tsfupanIndexKline",TBChartDivId:"tsfupanIndexTicklineBuy",TSChartDivId:"tsfupanIndexTicklineSell"}
tsstock.getHistoryKlineFromTdx(u),g.code=t,g.name=gmAllStocks.items[g.code].n,gCurrentStock=g,gCurrentStock.profitRateStr=l
var h={stock:g,isGetIndex:!1,buydate:n,selldate:o,buytimes:i,selltimes:a,buyprice:s,sellprice:r,datacount:40,KChartDivId:"tsfupanStockKline",TBChartDivId:"tsfupanStockTicklineBuy",TSChartDivId:"tsfupanStockTicklineSell"}
tsstock.getHistoryKlineFromTdx(h)}else iToasts.show("Invalid stock code!",!0),EnableButton(e)}}function stockSnapShot(e){hex.snapshot({left:0,top:0,right:gmTradeFupan.chartWidth+80,bottom:gmTradeFupan.chartHeight+10},function(e,t,i,a,n){if(!e)return void iToasts.show("failed!",!0)
var o=a,s="png",r=function(e){e=e.toLowerCase().replace(/jpg/i,"jpeg")
var t=e.match(/png|jpeg|bmp|gif/)[0]
return"image/"+t}
o=o.replace(r(s),"image/octet-stream")
var l=function(e,t){var i=document.createElementNS("http://www.w3.org/1999/xhtml","a")
i.href=e,i.download=t
var a=document.createEvent("MouseEvents")
a.initMouseEvent("click",!0,!1,window,0,0,0,0,0,!1,!1,!1,!1,0,null),i.dispatchEvent(a)},d=$("stockBuyDate").value.replace(/\-/g,"")+"-"+gCurrentStock.code+"-"+gCurrentStock.name+"-"+gCurrentStock.profitRateStr+"."+s
l(o,d)})}function showtsModifyBSTime(){tsstock.currentStockCode!=$("stockCode").value&&($("buyTimes").value="",$("sellTimes").value=""),$("frmModifyBSTimes").style.display="block"}function showModifyMemo(e){$("frmModifyMemo").style.display="block",$("modify_memo").value=$(e).innerHTML,$("memo_modify_confirm").onclick=function(){$(e).innerHTML=$("modify_memo").value,$("frmModifyMemo").style.display="none"}}function initMemoMove(e){e.isdown=!1,e.onmousedown=function(){return e.isdown=!0,e.startX=event.x,e.startY=event.y,!1},e.onmouseup=function(){return e.isdown=!1,!1},e.onmousemove=function(t){e.isdown&&(e.style.left=e.offsetLeft+event.x-e.startX+"px",e.style.top=e.offsetTop+event.y-e.startY+"px",e.startX=event.x,e.startY=event.y)}}function onModifyProfile(){if(!checkDateField($("modifyprofile-birthday")))return void iToasts.show("请输入格式正确的日期,如：2008-08-08",!0)
for(var e=document.getElementsByName("gender"),t=0,i=0;i<e.length;i++)e[i].checked&&(t=e[i].value)
if(checkField("modifyprofile-nickname",2,32,"请输入昵称")){var a=$("modifyprofile-nickname").value,n=$("modifyprofile-birthday").value,o=$("modifyprofile-icon").avatar,s=($$("#modifyprofile-attackmastery.selected")[0].attributes.amvalue.nodeValue,$$("#modifyprofile-defensemastery.selected")[0].attributes.dmvalue.nodeValue,{act:"modify",nickname:a,gender:t,birthday:n,avatar:o}),r=new iAjax
r.get("/appv2/usercenter",s,function(e){0==e.error?(setUserInfo(e.userinfo),showUserCenter(),iToasts.show("修改成功",!1)):(setUserInfo(userinfo),iToasts.show("修改失败",!0))}),popuplist.pop("divmodifyprofile")}}function setUserInfo(e){userinfo=e,userinfo?userinfo.SNId>0?($("ghright").innerHTML="<div  >	欢迎 <span style='color:#00c1de;font-weight:bold;'>"+userinfo.NickName+"</span>，今天是"+(new Date).format("yyyy-MM-dd")+"日，祝投资顺利 <span class='btn' style='padding:2px 15px; margin-left:50px; background:none;color:#09c;' onclick='logout(this)'>退出登录</span></div>",3==userinfo.SNId&&($("btnUploadHotStocks").style.display="inline-block")):$("ghright").innerHTML="<div  >	欢迎 <span style='color:#00c1de;font-weight:bold;'>"+userinfo.NickName+"</span>，请<span class='btn' style='padding:2px 15px;' onclick='popuplist.push(\"divuserbindsn\");'>输入软件序列号</span>或<span class='btn' style='padding:2px 15px;' onclick='openurl(\"https://shop103451980.taobao.com/search.htm\");'>购买软件</span><span class='btn' style='padding:2px 15px; margin-left:50px; background:none;' onclick='logout(this)'>退出登录</span></div>":$("ghright").innerHTML="<div  >您尚未登录， 请<span class='btn' style='padding:2px 15px;' onclick='popuplist.push(\"divuserlogin\");'>登录</span> 或<span class='btn' style='padding:2px 15px;' onclick='popuplist.push(\"divuserregister\");'>注册</span></div>"}function appstart(){var e=new iAjax,t={act:"appstart"}
e.get(gdadaurl,t,function(e){setUserInfo(0==e.error?e.userinfo:null)},function(){setUserInfo(null)})}function logout(e){e.disabled||iDlgs.confirm("退出确认","确定退出当前已登录的账号吗？",function(){var t=new iAjax
disableButton(e)
var i={act:"logout"}
t.get(gdadaurl,i,function(t){enableButton(e),0==t.error?(setUserInfo(null),popuplist.push("divuserlogin"),popuplist.pop("divuserprofile"),iToasts.show("已退出登录",!1)):iToasts.show("退出失败",!1)},function(){enableButton(e)})},function(){})}function bindsn(e){if(!e.disabled&&checkField("bindsnusersn",32,32,"请输入软件序列号")){var t=/^[a-zA-Z0-9]+$/,i=$("bindsnusersn").value
if(!t.test(i))return $("bindsnusersn").focus(),void iToasts.show("请输入正确的软件序列号",!0)
var a=new iAjax
disableButton(e)
var n={act:"bindsn",sn:i}
a.get(gdadaurl,n,function(t){enableButton(e),0==t.error?(setUserInfo(t.userinfo),popuplist.pop("divuserbindsn"),iToasts.show("绑定成功",!1)):iToasts.show("绑定失败，请检查软件序列号是否正确或者已经被使用",!0)},function(){enableButton(e)})}}function login(e){if(!e.disabled&&checkField("loginusername",2,64,"请输入电子邮箱")){var t=/^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/,i=$("loginusername").value
if(!t.test(i))return $("loginusername").focus(),void iToasts.show("请输入正确的电子邮箱地址",!0)
if(checkField("loginpassword",2,64,"请输入登录密码")){var a=$("loginpassword").value
localStorage.setItem("loginusername",$("loginusername").value)
var n=new iAjax
disableButton(e)
var o={act:"login",username:i,password:a}
n.get(gdadaurl,o,function(t){enableButton(e),0==t.error?(setUserInfo(t.userinfo),popuplist.pop("divuserlogin"),popuplist.pop("divuserregister"),iToasts.show("登录成功",!1),gConfig.cfgUserName=$("loginusername").value,saveObjectToFile(gConfig,gConfigFile)):iToasts.show("登录失败，请检查账号和密码",!0)},function(){enableButton(e)})}}}function register(e){if(!e.disabled&&checkField("registerusername",2,64,"请输入电子邮箱")){var t=/^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/,i=$("registerusername").value
if(!t.test(i))return $("registerusername").focus(),void iToasts.show("请输入正确的电子邮箱地址",!0)
if(checkField("registerpassword",2,64,"请输入登录密码")){if($("registerpassword").value!=$("registerpassword2").value)return $("registerpassword").focus(),void iToasts.show("两次输入的密码不一样",!0)
if(checkField("registernickname",2,64,"请输入用户昵称")){var a=$("registerpassword").value,n=$("registernickname").value,o=new iAjax
disableButton(e)
var s={act:"register",username:i,password:a,nickname:n}
o.get(gdadaurl,s,function(t){enableButton(e),0==t.error?(setUserInfo(t.userinfo),popuplist.pop("divuserregister"),popuplist.pop("divuserlogin"),iToasts.show(t.msg,!1)):iToasts.show(t.msg,!0)},function(){enableButton(e)})}}}}function copyDefaultDataFile(e){var t=e+"_"
!fs.existsSync(e)&&fs.existsSync(t)&&fs.writeFileSync(e,fs.readFileSync(t))}function initApp(){gmConfig.init(),fs.existsSync(gConfig.tdxFolder)||iToasts.show("未指定通达信主目录",!0),gmUpdate.init(),gmHqreappear.init(),gmAllStocks.init(),gmTradeFupan.init(),gmTcgl.init(),gmFupan.init(),gmGuxing.init(),gmLhb.init(),appstart(),empty(gConfig.cfgUserName)||($("loginusername").value=gConfig.cfgUserName)}function showGTab(e){var t=gCurrentTab.getAttribute("tab")
$(t).style.display="none",gCurrentTab.className="tabH1",gCurrentTab=e
var i=e.getAttribute("tab")
switch(e.className="tabH1selected",$(i).style.display="block",i){case"tslhbWrapper":gmLhb.showCurrentLhb()
break
case"tsdaysfupanWrapper":gmFupan.autoUpdateFupan()}}function checkvuser(){var e=(new Date).getHours()
return null!=userinfo&&0==userinfo.SNId&&e>8?!1:!0}function openurl(e){hex.openExternal(e)}function saveObjectToFile(e,t){var i=JSON.stringify(e)
fs.writeFileSync(t,i)}function saveTextToFile(e,t){fs.writeFileSync(t,e)}function readObjectFromFile(e){if(fs.existsSync(e)){var t=fs.readFileSync(e,{encoding:"utf8"})
return JSON.parse(t)}return{}}function readTextFromFile(e){return fs.existsSync(e)?fs.readFileSync(e,{encoding:"utf8"}):""}function mycryp(e){const t=require("crypto"),i=t.createHash(m5crypto)
return i.update(e),i.digest("hex")}function delayRunPrompt(e,t){$("delayRunPromptWrapper").style.display="block",$("divDelayRunPrompt").innerHTML="正在加载全部"+gmAllStocks.codes.length+"只股票数据并计算中，请耐心等待...",setTimeout(function(){t(),$("delayRunPromptWrapper").style.display="none"},e)}function hasPermission(e){return-1!=userinfo.Permissions.indexOf(e)}function empty(e){return void 0===e||""==e||null==e||0==e||0==e}var gmAddonIndex={}
gmAddonIndex.topAmountStocks=[],gmAddonIndex.init=function(){},gmAddonIndex.calcDay=function(){for(var e=$("addons_index_stocks").value.split(" "),t=$("addons_index_day").value,i=$("addons_index_preclose").value,a=t.replace(/\-/g,""),n=0,o=0,s=0,r=0,l=0,d=0,c=0;c<e.length;c++){var g=e[c]
if(6==g.length){var u=new gmTdx.tdxDays(g),h=gmTdx.getDayIndex(u,a)
if(h>=1&&h<u.length){var m=new u.get(h),p=new u.get(h-1)
n+=m.open/p.high-1,o+=m.high/p.high-1,s+=m.low/p.high-1,r+=m.close/p.high-1,l+=m.amount,d++}}}n=i*(1+n/d),o=i*(1+o/d),s=i*(1+s/d),r=i*(1+r/d)
var f=t.replace(/\-/g,"/")+"	"+n.toFixed(2)+"	"+o.toFixed(2)+"	"+s.toFixed(2)+"	"+r.toFixed(2)+"	"+d+"	"+l+"	"+e
$("addons_index_result").value=f},gmAddonIndex.calcIndex=function(){for(var e=gAppFolder+"/dadadata/jlindexdata.txt",t=gAppFolder+"/dadadata/jlindextdx.txt",i=gConfig.tdxFolder+"/vipdoc/sz/lday/sz397003.day",a=gAppFolder+"/dadadata/ztindexdata.txt",n=20150101,o=readObjectFromFile(e),s=readObjectFromFile(a),r=0,l=new gmTdx.tdxDays("999999"),d=l.length-1;d>0;d--){var c=new l.get(d)
if(c.day<n)break
r=d,void 0===o[""+c.day]&&(o[""+c.day]={open:0,high:0,low:0,close:0,count:0,ok:0}),void 0===s[""+c.day]&&(s[""+c.day]={open:0,high:0,low:0,close:0,count:0,ok:0})}for(var g=0;g<gmAllStocks.codes.length;g++){var u=gmAllStocks.codes[g],l=new gmTdx.tdxDays(u)
if(0!=l.length)for(var d=l.length-2;d>5;d--){var c=new l.get(d)
if(c.day<n)break
var h=new l.get(d+1),m=""+h.day
if(1!=o[m].ok){var p=new l.get(d-1)
if(gmTdx.isRiseLimit(c.high,p.close)){for(var f=1,y=c.high==c.low&&c.amount<2e8,v=y?1:0,b=d-1;b>0;b--){var x=new l.get(b),_=new l.get(b-1)
if(!gmTdx.isRiseLimit(x.close,_.close))break
y=x.high==x.low&&x.amount<2e8||_.close/_.open>1.22||x.close/x.open>1.22,v=y?v+1:0,f++}y&&(f-=v),f>0&&(s[m].open+=h.open/c.high,s[m].high+=h.high/c.high,s[m].low+=h.low/c.high,s[m].close+=h.close/c.high,s[m].count++),f>1&&(o[m].open+=h.open/c.high,o[m].high+=h.high/c.high,o[m].low+=h.low/c.high,o[m].close+=h.close/c.high,o[m].count++)}}}}for(var l=new gmTdx.tdxDays("999999"),L="",k={},T={},w=32*(l.length-r),F=new Buffer(w),S=0,d=r;d<l.length;d++){var c=new l.get(d),A=""+c.day
if(0==o[A].ok){if(o[A].ok=1,s[A].ok=1,d==r)k={open:9999,high:9999,low:9999,close:9999,count:0,codes:"-"},T={open:9999,high:9999,low:9999,close:9999,count:0,codes:"-"}
else{var C=new l.get(d-1)
k=o[""+C.day],T=s[""+C.day]}o[A].open=0==o[A].count?k.close:parseFloat((k.close*o[A].open/o[A].count).toFixed(2)),o[A].high=0==o[A].count?k.close:parseFloat((k.close*o[A].high/o[A].count).toFixed(2)),o[A].low=0==o[A].count?k.close:parseFloat((k.close*o[A].low/o[A].count).toFixed(2)),o[A].close=0==o[A].count?k.close:parseFloat((k.close*o[A].close/o[A].count).toFixed(2))}L+=A+"	"+o[A].open.toFixed(2)+"	"+o[A].high.toFixed(2)+"	"+o[A].low.toFixed(2)+"	"+o[A].close.toFixed(2)+"	"+o[A].count+"	"+o[A].count+"	 \r\n",gmAddonIndex.setTdxDay(F,S,c.day,o[A].open,o[A].high,o[A].low,o[A].close,o[A].count,o[A].count,k.close),S++}saveObjectToFile(o,e),saveTextToFile(L,t),fs.writeFileSync(i,F),iToasts.show("成功",!1)},gmAddonIndex.addTopAmountStock=function(e){var t=100
if(gmAddonIndex.topAmountStocks.length<1)gmAddonIndex.topAmountStocks.push(e)
else{for(var i=!1,a=0;a<gmAddonIndex.topAmountStocks.length;a++)if(amt>=gmAddonIndex.topAmountStocks[a].a){gmAddonIndex.topAmountStocks.splice(a,0,e),gmAddonIndex.topAmountStocks.length>t&&gmAddonIndex.topAmountStocks.splice(t,t),i=!0
break}!i&&gmAddonIndex.topAmountStocks.length<t&&gmAddonIndex.topAmountStocks.push(e)}},gmAddonIndex.calcLbAndQsIndex=function(){for(var e=gConfig.tdxFolder+"/vipdoc/sz/lday/sz397111.day",t=new Buffer(65536),i=0,a=20170101,n=parseInt($("enddate").value.replace(/\-/g,"")),o=0,s=a;n>=s;s++){var r=""+s
if(r in alldays){for(var l=alldays[r],d=0,c=0,g=0;g<l.qss.length;g++)d+=l.qss[g].qs
for(var g=0;g<l.lts.length;g++)c+=l.lts[g].lb*l.lts[g].lb
o=0==o?d:o
var u=o,h=d,m=u>h?u:h,p=u>h?h:u
gmAddonIndex.setTdxDay(t,i,s,u,m,p,h,c,c,o),i++,o=d}}var f=new Buffer(32*i)
t.copy(f,0,0,32*i),fs.writeFileSync(e,f)},gmAddonIndex.calcHYIndex=function(){for(var e=gAppFolder+"/dadadata/hyindexdata.txt",t=gAppFolder+"/dadadata/hyindextdx.txt",i=gConfig.tdxFolder+"/vipdoc/sz/lday/sz397009.day",a=readObjectFromFile(e),n=20160901,o=0,s=new gmTdx.tdxDays("999999"),r=s.length-1;r>0;r--){var l=new s.get(r)
if(l.day<n)break
o=r,void 0===a[""+l.day]&&(a[""+l.day]={open:0,high:0,low:0,close:0,count:0,ok:0})}for(var d=0;d<gmAllStocks.codes.length;d++){var c=gmAllStocks.codes[d],s=new gmTdx.tdxDays(c)
if(0!=s.length)for(var r=s.length-2;r>5;r--){var l=new s.get(r)
if(l.day<n)break
var g=new s.get(r+1),u=""+g.day
if(1!=a[u].ok){var h=new s.get(r-1)
l.amount>15e8&&h.amount>15e8&&(a[u].open+=g.open/l.close,a[u].high+=g.high/l.close,a[u].low+=g.low/l.close,a[u].close+=g.close/l.close,a[u].count++)}}}for(var s=new gmTdx.tdxDays("999999"),m="",p={},f=32*(s.length-o),y=new Buffer(f),v=0,r=o;r<s.length;r++){var l=new s.get(r),b=""+l.day
if(0==a[b].ok){if(a[b].ok=1,r==o)p={open:9999,high:9999,low:9999,close:9999,count:0,codes:"-"}
else{var x=new s.get(r-1)
p=a[""+x.day]}a[b].open=0==a[b].count?p.close:parseFloat((p.close*a[b].open/a[b].count).toFixed(2)),a[b].high=0==a[b].count?p.close:parseFloat((p.close*a[b].high/a[b].count).toFixed(2)),a[b].low=0==a[b].count?p.close:parseFloat((p.close*a[b].low/a[b].count).toFixed(2)),a[b].close=0==a[b].count?p.close:parseFloat((p.close*a[b].close/a[b].count).toFixed(2))}m+=b+"	"+a[b].open.toFixed(2)+"	"+a[b].high.toFixed(2)+"	"+a[b].low.toFixed(2)+"	"+a[b].close.toFixed(2)+"	"+a[b].count+"	"+a[b].count+"	 \r\n",gmAddonIndex.setTdxDay(y,v,l.day,a[b].open,a[b].high,a[b].low,a[b].close,a[b].count,a[b].count,p.close),v++}saveObjectToFile(a,e),saveTextToFile(m,t),fs.writeFileSync(i,y),iToasts.show("计算活跃指数成功",!1)},gmAddonIndex.calcFWIndex=function(){for(var e=gAppFolder+"/dadadata/fwindexdata.txt",t=(gConfig.tdxFolder+"/vipdoc/sz/lday/sz397006.day",readObjectFromFile(e)),i=20160901,a=0,n=new gmTdx.tdxDays("999999"),o=n.length-1;o>0;o--){var s=new n.get(o)
if(s.day<i)break
a=o,void 0===t[""+s.day]&&(t[""+s.day]={open:0,high:0,low:0,close:0,count:0,ok:0})}for(var r=0;r<gmAllStocks.codes.length;r++){var l=gmAllStocks.codes[r],n=new gmTdx.tdxDays(l)
if(0!=n.length)for(var o=n.length-2;o>5;o--){var s=new n.get(o)
if(s.day<i)break
var d=new n.get(o+1),c=""+d.day
if(1!=jlbdays[c].ok){var g=new n.get(o-1)
if(gmTdx.isRiseLimit(s.high,g.close)){for(var u=1,h=s.high==s.low&&s.amount<2e8,m=h?1:0,p=o-1;p>0;p--){var f=new n.get(p),y=new n.get(p-1)
if(!gmTdx.isRiseLimit(f.close,y.close))break
h=f.high==f.low&&f.amount<2e8||y.close/y.open>1.22||f.close/f.open>1.22,m=h?m+1:0,u++}h&&(u-=m),u>0&&(ztbdays[c].open+=d.open/s.high,ztbdays[c].high+=d.high/s.high,ztbdays[c].low+=d.low/s.high,ztbdays[c].close+=d.close/s.high,ztbdays[c].count++),u>1&&(jlbdays[c].open+=d.open/s.high,jlbdays[c].high+=d.high/s.high,jlbdays[c].low+=d.low/s.high,jlbdays[c].close+=d.close/s.high,jlbdays[c].count++)}}}}for(var n=new gmTdx.tdxDays("999999"),v="",b="",x={},_={},L=32*(n.length-a),k=new Buffer(L),T=0,o=a;o<n.length;o++){var s=new n.get(o),w=""+s.day
if(0==jlbdays[w].ok){if(jlbdays[w].ok=1,ztbdays[w].ok=1,o==a)x={open:9999,high:9999,low:9999,close:9999,count:0,codes:"-"},_={open:9999,high:9999,low:9999,close:9999,count:0,codes:"-"}
else{var F=new n.get(o-1)
x=jlbdays[""+F.day],_=ztbdays[""+F.day]}jlbdays[w].open=0==jlbdays[w].count?x.close:parseFloat((x.close*jlbdays[w].open/jlbdays[w].count).toFixed(2)),jlbdays[w].high=0==jlbdays[w].count?x.close:parseFloat((x.close*jlbdays[w].high/jlbdays[w].count).toFixed(2)),jlbdays[w].low=0==jlbdays[w].count?x.close:parseFloat((x.close*jlbdays[w].low/jlbdays[w].count).toFixed(2)),jlbdays[w].close=0==jlbdays[w].count?x.close:parseFloat((x.close*jlbdays[w].close/jlbdays[w].count).toFixed(2)),ztbdays[w].open=0==ztbdays[w].count?_.close:parseFloat((_.close*ztbdays[w].open/ztbdays[w].count).toFixed(2)),ztbdays[w].high=0==ztbdays[w].count?_.close:parseFloat((_.close*ztbdays[w].high/ztbdays[w].count).toFixed(2)),ztbdays[w].low=0==ztbdays[w].count?_.close:parseFloat((_.close*ztbdays[w].low/ztbdays[w].count).toFixed(2)),ztbdays[w].close=0==ztbdays[w].count?_.close:parseFloat((_.close*ztbdays[w].close/ztbdays[w].count).toFixed(2))}v+=w+"	"+jlbdays[w].open.toFixed(2)+"	"+jlbdays[w].high.toFixed(2)+"	"+jlbdays[w].low.toFixed(2)+"	"+jlbdays[w].close.toFixed(2)+"	"+jlbdays[w].count+"	"+jlbdays[w].count+"	 \r\n",b+=w+"	"+ztbdays[w].open.toFixed(2)+"	"+ztbdays[w].high.toFixed(2)+"	"+ztbdays[w].low.toFixed(2)+"	"+ztbdays[w].close.toFixed(2)+"	"+ztbdays[w].count+"	"+ztbdays[w].count+"	 \r\n",gmAddonIndex.setTdxDay(k,T,s.day,jlbdays[w].open,jlbdays[w].high,jlbdays[w].low,jlbdays[w].close,jlbdays[w].count,jlbdays[w].count,x.close),T++}saveObjectToFile(jlbdays,jlindexdata),saveTextToFile(v,jlindextdx),saveObjectToFile(ztbdays,ztindexdata),saveTextToFile(b,ztindextdx),fs.writeFileSync(jlindextdxfile,k),iToasts.show("成功",!1)},gmAddonIndex.setTdxDay=function(e,t,i,a,n,o,s,r,l,d){var c=4
e.writeUInt32LE(i,32*t+0*c),e.writeUInt32LE(100*a,32*t+1*c),e.writeUInt32LE(100*n,32*t+2*c),e.writeUInt32LE(100*o,32*t+3*c),e.writeUInt32LE(100*s,32*t+4*c),e.writeFloatLE(r,32*t+5*c),e.writeUInt32LE(l,32*t+6*c),e.writeUInt32LE(100*d,32*t+7*c)},gmAddonIndex.genStockData=function(e){for(var t={},i=e.split(","),a=0;a<i.length;a++){var n=i[a]
if(6==n.length){var o=new gmTdx.tdxDays(n)
if(0!=o.length)for(var s=o.length-1;s>o.length-30;s--){var r=new o.get(s),l=new o.get(s-1),d=Math.round(100*(r.open/l.close-1)),c=Math.round(100*(r.high/l.close-1)),g=Math.round(100*(r.low/l.close-1)),u=Math.round(100*(r.close/l.close-1)),h=Math.round(r.amount/1e8),m=""+r.day,p=n+"/"+d+"/"+c+"/"+g+"/"+u+"/"+h
empty(t[m])?t[m]=p:t[m]+=","+p}}}var f=""
for(var y in t)f+=t[y]+"\r\n"
saveTextToFile(f,"d:/stocks.txt")},gmAddonIndex.genBlockData=function(e){}
var gmAllStocks={}
gmAllStocks.items={},gmAllStocks.codes=[],gmAllStocks.noNameList="",gmAllStocks.init=function(){if(gmAllStocks.items=readObjectFromFile(gAllStocksFile),gmAllStocks.codes=[],gmAllStocks.loadAllStocksFromTdxCacheAll(),0==gmAllStocks.codes.length){var e=gConfig.tdxFolder+"/T0002/blocknew/ZXG.blk"
fs.existsSync(e)&&(gAllAFile=e)
for(var t=readTextFromFile(gAllAFile),i=t.split("\r\n"),a=0;a<i.length;a++)7==i[a].length&&gmAllStocks.codes.push(i[a].substr(1))}gmAllStocks.codes.push("399006"),gmAllStocks.codes.push("999999")},gmAllStocks.loadAllStocksFromTdxCache=function(){var e=gConfig.tdxFolder+"/T0002/hq_cache/base.map"
if(fs.existsSync(e)){for(var t=readTextFromFile(e),i=t.split("\r\n"),a=[],n=0;n<i.length;n++){var o=i[n].trim(),s=o.substr(0,1)
10!=o.length||"0"!=s&&"3"!=s&&"6"!=s||a.push(o.substr(0,6))}a.length>1e3&&(gmAllStocks.codes=a)}},gmAllStocks.addUniqueElement=function(e,t){var i=!1
for(k in e)if(e[k]==t){i=!0
break}i||e.push(t)},gmAllStocks.loadAllStocksFromTdxCacheAll=function(){var e=[],t=gConfig.tdxFolder+"/T0002/hq_cache/shm.tnf"
if(fs.existsSync(t)){for(var i=fs.openSync(t,"r"),a=fs.fstatSync(i).size,n=(a-50)/314,o=new Buffer(64),s=0;n>s;s++){fs.readSync(i,o,0,32,314*s+50)
var r=o.toString("ascii",0,6),l=o.slice(23,31),d=iconv.decode(l,"gb2312"),c=r.substr(0,2);("00"==c||"30"==c||"60"==c)&&(gmAllStocks.addUniqueElement(e,r),gmAllStocks.items[r]={n:d})}fs.closeSync(i)}if(t=gConfig.tdxFolder+"/T0002/hq_cache/szm.tnf",fs.existsSync(t)){for(var i=fs.openSync(t,"r"),a=fs.fstatSync(i).size,n=(a-50)/314,o=new Buffer(64),s=0;n>s;s++){fs.readSync(i,o,0,32,314*s+50)
var r=o.toString("ascii",0,6),l=o.slice(23,31),d=iconv.decode(l,"gb2312"),c=r.substr(0,2);("00"==c||"30"==c||"60"==c)&&(gmAllStocks.addUniqueElement(e,r),gmAllStocks.items[r]={n:d})}fs.closeSync(i)}e.length>1e3&&(gmAllStocks.codes=e)},gmAllStocks.startGetName=function(){gmAllStocks.noNameList=""},gmAllStocks.codeToSymbol=function(e){var t=e
return"0"==e.substr(0,1)||"3"==e.substr(0,1)?t="sz"+e:"6"==e.substr(0,1)&&(t="sh"+e),t},gmAllStocks.getName=function(e){return void 0!==gmAllStocks.items[e]&&"N"!=gmAllStocks.items[e].n.substr(0,1)?gmAllStocks.items[e].n:gmAllStocks.noNameList.length>3e3?e+"-":(e=gmAllStocks.codeToSymbol(e),gmAllStocks.noNameList+=""==gmAllStocks.noNameList?e:","+e,"")},gmAllStocks.endGetName=function(){return},gmAllStocks.getAllStocksFromSina=function(){var lt=void 0===gConfig.lastUpdateAllStocksDate?0:gConfig.lastUpdateAllStocksDate,nt=parseInt((new Date).Format("yyyyMMdd"))
if(!(lt>=nt)){var myurl="http://vip.stock.finance.sina.com.cn/quotes_service/api/json_v2.php/Market_Center.getHQNodeData?num=5000&sort=changepercent&asc=1&node=hs_a&symbol=&_s_r_a=page&page=1"
http.get(myurl,function(e){e.setEncoding("binary")}).on("data",function(data){var dutf=iconv.decode(data,"gbk"),as=eval(dutf)
if("object"==typeof as&&null!=as){for(var allastr="",i=0;i<as.length;i++)gmAllStocks.items[as[i].code]={n:as[i].name},allastr+=("sh"==as[i].symbol.substr(0,2)?"1":"0")+as[i].code+"\r\n"
iToasts.show("成功更新A股所有股票资料",!1),gConfig.lastUpdateAllStocksDate=nt,gmConfig.save(),saveTextToFile(allastr,gAllAFile),saveObjectToFile(gmAllStocks.items,gAllStocksFile)}}).on("error",function(e){console.log("错误："+e.message)})}}
var $=function(e){return document.getElementById(e)},$$=function(e){return document.querySelectorAll(e)},isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},jAjax=function(){this.XMLHttpReq=null
var e=this
this.onData=function(e){},this.onError=function(e){},this.init=function(){try{this.XMLHttpReq=new ActiveXObject("Msxml2.XMLHTTP")}catch(e){try{this.XMLHttpReq=new ActiveXObject("Microsoft.XMLHTTP")}catch(e){this.XMLHttpReq=new XMLHttpRequest}}},this.postform=function(e,t,i){var a=document.getElementById(e),n=a.action,o=new FormData(a)
this.onData=t,this.onError=i,this.init(),this.XMLHttpReq.open("POST",n,!0),this.XMLHttpReq.onreadystatechange=this.processResponse,this.XMLHttpReq.send(o)},this.post=function(e,t,i,a){this.onData=i,this.onError=a,this.init(),this.XMLHttpReq.open("POST",e,!0),this.XMLHttpReq.onreadystatechange=this.processResponse,this.XMLHttpReq.send(t)},this.cpmf_post=function(e,t,i,a){this.onData=i,this.onError=a,this.init(),this.XMLHttpReq.open("POST",e,!0),this.XMLHttpReq.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"),this.XMLHttpReq.setRequestHeader("Accept","application/json, text/javascript, */*; q=0.01"),this.XMLHttpReq.setRequestHeader("X-Requested-With","XMLHttpRequest"),this.XMLHttpReq.onreadystatechange=this.processResponse,this.XMLHttpReq.send(t)},this.json_get=function(e,t,i){this.onData=t,this.onError=i,this.init(),this.XMLHttpReq.open("GET",e,!0),this.XMLHttpReq.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"),this.XMLHttpReq.setRequestHeader("Accept","application/json, text/javascript, */*; q=0.01"),this.XMLHttpReq.setRequestHeader("X-Requested-With","XMLHttpRequest"),this.XMLHttpReq.onreadystatechange=this.processResponse,this.XMLHttpReq.send(null)},this.binary_get=function(e,t,i){this.onData=t,this.onError=i,this.init(),this.XMLHttpReq.open("GET",e,!0),this.XMLHttpReq.responseType="arraybuffer",this.XMLHttpReq.onreadystatechange=this.processBinaryResponse,this.XMLHttpReq.send(null)},this.get=function(e,t,i){this.onData=t,this.onError=i,this.init(),this.XMLHttpReq.open("GET",e,!0),this.XMLHttpReq.onreadystatechange=this.processResponse,this.XMLHttpReq.send(null)},this.processResponse=function(){if(4==e.XMLHttpReq.readyState)if(200==e.XMLHttpReq.status){var t=e.XMLHttpReq.responseText
try{t=window.decodeURI(t)}catch(i){t=unescape(t)}e.onData(t)}else e.onError()},this.processBinaryResponse=function(){if(4==e.XMLHttpReq.readyState)if(200==e.XMLHttpReq.status){var t=e.XMLHttpReq.response,i=new Uint8Array(t)
e.onData(i)}else e.onError()}},_connkeylen=20,_keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",encJson=function(e){for(var t=new Base64,i="",a=0;_connkeylen>a;a++){var n=Math.ceil(62*Math.random())
i+=_keyStr[n]}var o=t.encode(JSON.stringify(e))
return o=i.substring(0,7)+o+i.substring(6,16)},decJson=function(e){var t=new Base64,i=e.substring(7,e.length-10),a=t.decode(i)
return JSON.parse(a)},LOADMORE_CACHE=0,LOADMORE_NORMAL=1,LOADMORE_FORCELOAD=2,LOADMORE_REFRESH=3,iDlgManager=function(){this.dlgs={},this.dlgIndex=0,this.zIndex=999,this.confirm=function(e,t,i,a,n){this.dlgIndex++,this.zIndex++
var o="dlg"+this.dlgIndex
a=a||function(){}
var s=n||"确定"
this.dlgs[o]=new confirmDlg(this.zIndex,o,e,t,i,a,s)},this.show=function(e,t){this.dlgIndex++,this.zIndex++
var i="dlg"+this.dlgIndex
this.dlgs[i]=new messageDlg(this.zIndex,i,e,t)},this.onCancel=function(e){popuplist.pop(e),getIgDlgs().removeChild($(e)),this.dlgs[e].onCancel(),this.dlgs[e]=null},this.onOk=function(e){this.dlgs[e].onOk(),popuplist.pop(e),getIgDlgs().removeChild($(e)),this.dlgs[e]=null}},getIgDlgs=function(){var e=$("igdlgs")
if(null==e){var t=document.createElement("div")
t.id="igdlgs",document.body.appendChild(t),e=$("igdlgs")}return e},toasts_offset=70,iToast=function(){this.index=99999,this.show=function(e,t,i){duration=2e3,toasts_offset=40>toasts_offset?70:toasts_offset-5,i||(i=toasts_offset+"%")
var a=t?"background:rgba(0,0,0,.7);color:red;":"background:rgba(0,0,0,.7);color:#fff;",n=document.createElement("div")
n.innerHTML="<span style='border-radius:3px; box-shadow:5px 5px 5px rgba(0,0,0,.6);"+a+"padding:3px 10px;'>"+e+"</span>",n.style.cssText="position:fixed; left:10px;top:"+i+";right:10px; font-size:14px; text-align:center;z-index:"+this.index,document.body.appendChild(n),setTimeout(function(){var e=1
n.style.webkitTransition="-webkit-transform "+e+"s ease-in, opacity "+e+"s ease-in",n.style.opacity="0",setTimeout(function(){document.body.removeChild(n)},1e3*e)},duration)}}
Date.prototype.format=function(e){var t={"M+":this.getMonth()+1,"d+":this.getDate(),"h+":this.getHours(),"m+":this.getMinutes(),"s+":this.getSeconds(),"w+":this.getDay(),"q+":Math.floor((this.getMonth()+3)/3),S:this.getMilliseconds()};/(y+)/.test(e)&&(e=e.replace(RegExp.$1,(this.getFullYear()+"").substr(4-RegExp.$1.length)))
for(var i in t)RegExp("("+i+")").test(e)&&(e=e.replace(RegExp.$1,1==RegExp.$1.length?t[i]:("00"+t[i]).substr((""+t[i]).length)))
return e}
var getQueryString=function(e){var t=RegExp("(^|&)"+e+"=([^&]*)(&|$)","i"),i=window.location.search.substr(1).match(t)
return null!=i?unescape(i[2]):null},disableForMS=function(e,t){e.disabled=!0,setTimeout(function(){e.disabled=!1},t)},iToasts=new iToast,iDlgs=new iDlgManager,popuplist=new iPopupList,gmConfig={},gConfig={maxGuxingDays:360,tdxFolder:"c:/tdx"}
gmConfig.init=function(){gConfig=readObjectFromFile(gConfigFile),gConfig.enableTickVol=void 0===gConfig.enableTickVol?!1:gConfig.enableTickVol,gConfig.maxAmountCount=void 0===gConfig.maxAmountCount?12:gConfig.maxAmountCount,$("maxAmountCount").value=gConfig.maxAmountCount,gConfig.maxLongtouCount=void 0===gConfig.maxLongtouCount?12:gConfig.maxLongtouCount,$("maxLongtouCount").value=gConfig.maxLongtouCount,$("cfgTdxFolder").value=void 0===gConfig.tdxFolder?"c:/new_tdx":gConfig.tdxFolder,gConfig.rsn=void 0===gConfig.rsn?"":gConfig.rsn,gConfig.maxGuxingDays=void 0===gConfig.maxGuxingDays?360:gConfig.maxGuxingDays,$("cfgGuxingDays").value=gConfig.maxGuxingDays,$("cfgShowShiZhi").checked=void 0===gConfig.cfgShowShiZhi?!1:gConfig.cfgShowShiZhi,$("btnFupanDrawShizhi").style.display=$("cfgShowShiZhi").checked?"inline-block":"none",$("cfgShowPriFupan").checked=void 0===gConfig.cfgShowPriFupan?!1:gConfig.cfgShowPriFupan,$("cfgShowQusiStock").checked=void 0===gConfig.cfgShowQusiStock?!1:gConfig.cfgShowQusiStock,$("cfgShowGaokaiStock").checked=void 0===gConfig.cfgShowGaokaiStock?!0:gConfig.cfgShowGaokaiStock,$("cfgShowMaxAmount").checked=void 0===gConfig.cfgShowMaxAmount?!1:gConfig.cfgShowMaxAmount,$("cfgDFupanStartDate").value=void 0===gConfig.cfgDFupanStartDate?"2016-10-01":gConfig.cfgDFupanStartDate,$("startdate").value=$("cfgDFupanStartDate").value,$("cfgShowLTStocks").checked=void 0===gConfig.cfgShowLTStocks?!0:gConfig.cfgShowLTStocks,gConfig.cfgTFupanKLineBarCount=void 0===gConfig.cfgTFupanKLineBarCount?50:gConfig.cfgTFupanKLineBarCount,$("cfgTFupanKLineBarCount").value=gConfig.cfgTFupanKLineBarCount,gConfig.cfgTFKLineRatio=void 0===gConfig.cfgTFKLineRatio?45:gConfig.cfgTFKLineRatio,$("cfgTFKLineRatio").value=gConfig.cfgTFKLineRatio,gConfig.cfgTFMaxWidth=void 0===gConfig.cfgTFMaxWidth?1300:gConfig.cfgTFMaxWidth,$("cfgTFMaxWidth").value=gConfig.cfgTFMaxWidth,gConfig.cfgTFMaxHeight=void 0===gConfig.cfgTFMaxHeight?700:gConfig.cfgTFMaxHeight,$("cfgTFMaxHeight").value=gConfig.cfgTFMaxHeight,gConfig.cfgTFWaterMark=void 0===gConfig.cfgTFWaterMark?"":gConfig.cfgTFWaterMark,$("cfgTFWaterMark").value=gConfig.cfgTFWaterMark,gConfig.cfgLhbShowTicai=void 0===gConfig.cfgLhbShowTicai?!0:gConfig.cfgLhbShowTicai
var e=$("cfgLhbShowTicai")
empty(e)||(e.checked=gConfig.cfgLhbShowTicai),gConfig.cfgLhbUserName=void 0===gConfig.cfgLhbUserName?"Saraswati":gConfig.cfgLhbUserName,e=$("cfgLhbUserName"),empty(e)||(e.value=gConfig.cfgLhbUserName),gConfig.cfgLhbType=void 0===gConfig.cfgLhbType?0:gConfig.cfgLhbType,0==gConfig.cfgLhbType?$("cfgLhbType0").checked=!0:1==gConfig.cfgLhbType?$("cfgLhbType1").checked=!0:2==gConfig.cfgLhbType&&($("cfgLhbType2").checked=!0),gConfig.cfgLhbGroupId=void 0===gConfig.cfgLhbGroupId?0:gConfig.cfgLhbGroupId,$("cfgLhbGroupId").value=gConfig.cfgLhbGroupId,gConfig.cfgTcglLastUpdateTime=void 0===gConfig.cfgTcglLastUpdateTime?"2018-01-01 09:30:00":gConfig.cfgTcglLastUpdateTime,gConfig.cfgHSLastUpdateTime=void 0===gConfig.cfgHSLastUpdateTime?"2018-01-01 09:30:00":gConfig.cfgHSLastUpdateTime,gConfig.cfgGltcType=void 0===gConfig.cfgGltcType?0:gConfig.cfgGltcType,0==gConfig.cfgGltcType?$("cfgGltcType0").checked=!0:1==gConfig.cfgGltcType?$("cfgGltcType1").checked=!0:2==gConfig.cfgGltcType&&($("cfgGltcType2").checked=!0),gConfig.cfgGltcGroupId=void 0===gConfig.cfgGltcGroupId?0:gConfig.cfgGltcGroupId,$("cfgGltcGroupId").value=gConfig.cfgGltcGroupId,gConfig.hqSpeed=void 0===gConfig.hqSpeed?5:gConfig.hqSpeed,$("hqSpeed").value=gConfig.hqSpeed,gConfig.zsInterval=void 0===gConfig.zsInterval?5:gConfig.zsInterval,$("cfgZsInterval").value=gConfig.zsInterval,gConfig.cfgStockListCount=void 0===gConfig.cfgStockListCount?100:gConfig.cfgStockListCount,$("cfgStockListCount").value=gConfig.cfgStockListCount,gConfig.cfgKLineBarCount=void 0===gConfig.cfgKLineBarCount?40:gConfig.cfgKLineBarCount,$("cfgKLineBarCount").value=gConfig.cfgKLineBarCount,gConfig.cfgTdxZXG=void 0===gConfig.cfgTdxZXG?!1:gConfig.cfgTdxZXG,$("cfgTdxZXG").value=gConfig.cfgTdxZXG},gmConfig.save=function(){gConfig.maxGuxingDays=parseInt($("cfgGuxingDays").value),gConfig.maxAmountCount=parseInt($("maxAmountCount").value),gConfig.maxLongtouCount=parseInt($("maxLongtouCount").value)
var e=$("cfgTdxFolder").value,t=!1
gConfig.tdxFolder!=e&&(t=!0,e.indexOf(".exe")==e.length-4&&(e=e.substr(0,e.lastIndexOf("\\"))),e=e.replace(/\"/g,"")),gConfig.tdxFolder=e
var i=gConfig.tdxFolder+"/T0002"
return fs.existsSync(i)?(gConfig.cfgLhbShowTicai=$("cfgLhbShowTicai").checked,gConfig.cfgLhbUserName=$("cfgLhbUserName").value,$("cfgLhbType0").checked?gConfig.cfgLhbType=0:$("cfgLhbType1").checked?gConfig.cfgLhbType=1:$("cfgLhbType2").checked&&(gConfig.cfgLhbType=2),gConfig.cfgLhbGroupId=$("cfgLhbGroupId").value,gmLhb.getGroupId(),gConfig.cfgGltcType=void 0===gConfig.cfgGltcType?0:gConfig.cfgGltcType,$("cfgGltcType0").checked?gConfig.cfgGltcType=0:$("cfgGltcType1").checked?gConfig.cfgGltcType=1:$("cfgGltcType2").checked&&(gConfig.cfgGltcType=2),gConfig.cfgGltcGroupId=$("cfgGltcGroupId").value,gConfig.cfgShowShiZhi=$("cfgShowShiZhi").checked,$("btnFupanDrawShizhi").style.display=$("cfgShowShiZhi").checked?"inline-block":"none",gConfig.cfgShowPriFupan=$("cfgShowPriFupan").checked,gConfig.cfgShowQusiStock=$("cfgShowQusiStock").checked,gConfig.cfgShowGaokaiStock=$("cfgShowGaokaiStock").checked,gConfig.cfgShowMaxAmount=$("cfgShowMaxAmount").checked,gConfig.cfgDFupanStartDate=$("cfgDFupanStartDate").value,gConfig.cfgShowLTStocks=$("cfgShowLTStocks").checked,gConfig.cfgTFupanKLineBarCount=parseInt($("cfgTFupanKLineBarCount").value),gConfig.cfgTFKLineRatio=parseInt($("cfgTFKLineRatio").value),gConfig.cfgTFMaxWidth=parseInt($("cfgTFMaxWidth").value),gConfig.cfgTFMaxHeight=parseInt($("cfgTFMaxHeight").value),gConfig.cfgTFWaterMark=$("cfgTFWaterMark").value,gConfig.hqSpeed=parseInt($("hqSpeed").value),gConfig.zsInterval=parseInt($("cfgZsInterval").value),gConfig.cfgKLineBarCount=parseInt($("cfgKLineBarCount").value),gConfig.cfgTdxZXG=$("cfgTdxZXG").checked,gConfig.cfgStockListCount=parseInt($("cfgStockListCount").value),saveObjectToFile(gConfig,gConfigFile),fs.existsSync(i)&&t?void initApp():(gmTradeFupan.init(),void iToasts.show("已成功保存设置",!1))):void iDlgs.show("系统提示","通达信目录不正确，请右键点击通达信图标-属性，复制起始目录，按CTRL+V即可粘贴。修改成功后重启软件即可生效。对于Win10、Win8系统以及部分Win7以上操作系统无法保存设置的，请关闭软件，右键点软件图标--属性--兼容性，勾选“以兼容模式运行这个程序(Windows XP)”，以及“以管理员身份运行此程序”，确定后再次运行即可。")}
var gmFupan={}
gmFupan.myFupanDays={},gmFupan.init=function(){alldays=readObjectFromFile(gFupanFile),gmFupan.myFupanDays=readObjectFromFile(gMyFupanFile),gmFupan.alreadyFupan=!1
var e=new Date,t=new Date
t.setDate(t.getDate()-90),$("enddate").value=e.format("yyyy-MM-dd"),gmFupan.autoUpdateFupan(),gmFupan.listFupan()},gmFupan.autoUpdateFupan=function(){if(!gmFupan.alreadyFupan){var e=new Date,t=parseInt(e.Format("hhmm"))
if(!(e.getDay()>0&&e.getDay()<6&&1546>t)){var i=new gmTdx.tdxDays("999999")
if(0==i.length)return void iToasts.show("请用指定的通达信下载盘后日线数据",!0)
var a=new i.get(i.length-1),n=""+a.day
tsstock.getLiveDataFromSina("sh000001",function(e){var t=e.date.replace(/\-/g,"")
if(n==t){if(!empty(alldays[n]))return void(gmFupan.alreadyFupan=!0)
for(var i=parseInt(n),a=i;a>=20170101;a--){var o=""+a
if(o in alldays)break
i=o}iDlgs.confirm("系统提示","<b>请完成涨停数据复盘（"+i+"至"+n+"）</b><br><br><span style='color:red'>注：根据电脑配置不同，可能花费2-20秒不等，请耐心等待</span>",function(){delayRunPrompt(100,function(){gmFupan.tdx_fupan(i,n)})},function(){})}else iDlgs.show("请下载盘后数据","您当前的通达信数据下载至："+n+" ，请补全盘后数据至"+t)})}}},gmFupan.updateTickInfo=function(e){},gmFupan.tdx_fupan=function(e,t){var i="",a="",n="",o="",s="",r=gmTdx.getLastTradeDay(),l=new gmTdx.tdxDays("999999")
if(l.length>0){var d=new l.get(l.length-1)
r=d.day}gmAllStocks.startGetName()
for(var c=0;c<gmAllStocks.codes.length;c++){var g=gmAllStocks.codes[c],u=gmAllStocks.getName(g)
if(""!=u){var l=new gmTdx.tdxDays(g)
if(0!=l.length){if(gmGuxing.updateGuxing(g,l),1==l.length||"N"==u.substr(0,1)||"Ｎ"==u.substr(0,2)){var h=gmTdx.codeToTdxSymbol(g);-1==n.indexOf(h)&&(n=h+"\r\n"+n)}var m=gmTdx.getDayIndex(l,t)
m=m>=l.length?l.length-1:m
for(var p=m;p>0;p--){var d=new l.get(p),f=new l.get(p-1)
if(d.day>=e&&d.day<=t){var y=""+d.day
if(y in alldays&&1!=alldays[y].ok||(alldays[y]={},alldays[y].zt=0,alldays[y].kb=0,alldays[y].dt=0,alldays[y].zxtc=0,alldays[y].crcount=0,alldays[y].zth=0,alldays[y].ztc=0,alldays[y].lts=[],alldays[y].kbs=[],alldays[y].qss=[],alldays[y].gks=[],alldays[y].tas=[],alldays[y].newhighs=0,alldays[y].ok=0),"999999"==g){alldays[y].shzf=(100*(d.close/f.close-1)).toFixed(2),alldays[y].sha=Math.round(d.amount/1e8)
continue}if("399006"==g){alldays[y].cybzf=(100*(d.close/f.close-1)).toFixed(2),alldays[y].cyba=Math.round(d.amount/1e8)
for(var v=0,b=0,x=0,_=0,L=0,k=0,T=0,w=0,F=p;F>0;F--){var S=new l.get(F)
if(v+=S.close,p>F&&(b+=S.close),p-F==9&&(x=v/10),p-F==19&&(_=v/20),p-F==29&&(L=v/30),p-F==10&&(k=b/10),p-F==20&&(T=b/20),p-F==30){w=b/30
break}}alldays[y].cybma=(x<d.close?30:0)+(_<d.close?30:0)+(L<d.close?30:0)+(x>k?20:0)+(_>T?20:0)+(L>w?20:0)
continue}if(r==y&&(l.length<30&&d.high==d.low||1==l.length)&&d.amount<1e7){var h=gmTdx.codeToTdxSymbol(g);-1==n.indexOf(h)&&(n=h+"\r\n"+n)}if(p-2>=0){var A,C,D
if(A=new l.get(p-2),gmTdx.isRiseLimit(f.high,A.close)&&f.high!=f.low&&(alldays[y].zth+=d.high/f.close-1,alldays[y].ztc+=d.close/f.close-1,alldays[y].crcount++,d.clode>f.close),e==t&&gmTdx.isRiseLimit(f.close,A.close)&&f.high!=f.low){var h=gmTdx.codeToTdxSymbol(g);-1==s.indexOf(h)&&(s=h+"\r\n"+s)}if(e==t&&p-3>=0&&(C=new l.get(p-3),gmTdx.isRiseLimit(A.close,C.close)&&A.high!=A.low)){var h=gmTdx.codeToTdxSymbol(g);-1==s.indexOf(h)&&(s=s+h+"\r\n")}if(e==t&&p-4>=0&&(D=new l.get(p-4),gmTdx.isRiseLimit(C.close,D.close)&&C.high!=C.low)){var h=gmTdx.codeToTdxSymbol(g);-1==s.indexOf(h)&&(s=s+h+"\r\n")}}if(p==m&&m>4&&gmTdx.isRiseLimit(d.high,f.close))for(var F=p-1;F>0;F--){var z=new l.get(F),I=new l.get(F-1)
if(!gmTdx.isRiseLimit(z.close,I.close))break
if(z.amount>2e8||z.high!=z.low){var M=gmTdx.codeToTdxSymbol(g);-1==o.indexOf(M)&&(o+=M+"\r\n")
break}}var H=gmFupan.getMa(l,p,5)
if(d.close>H&&(d.amount>2e8||gmTdx.isRiseLimit(d.close,f.close))){for(var q=0,v=0,b=0,j=0,G=0,H=0,O=0,x=0,_=0,L=0,k=0,T=0,w=0,F=p;F>0;F--){var S=new l.get(F)
if(v+=S.close,p>F&&(b+=S.close),p-F==4&&(H=v/5),p-F==9&&(x=v/10),p-F==19&&(_=v/20),p-F==29&&(L=v/30),p-F==39&&(j=v/40),p-F==5&&(O/=5),p-F==10&&(k=b/10),p-F==20&&(T=b/20),p-F==30&&(w=b/30),p-F==40){G=b/40
break}10>p-F&&(q=S.amount>q?S.amount:q)}if(q>4e8&&d.close>H&&H>O&&x>k&&_>T&&L>w&&j>G&&H>x&&x>_&&_>L&&L>j){for(var B=0,E=0,F=p;F>0;F--){var z=new l.get(F),I=new l.get(F-1),N=gmFupan.getMa(l,F,5)
if(!(z.close>N))break
z.high==z.low&&E++,B++}B-=E
var R={c:g,qs:B,v:parseFloat((d.amount/1e8).toFixed(2))}
if(B>1){for(var P=!1,U=0;U<alldays[y].qss.length;U++)if(B>alldays[y].qss[U].qs||B==alldays[y].qss[U].qs&&R.v>alldays[y].qss[U].v){alldays[y].qss.splice(U,0,R),P=!0
break}P||alldays[y].qss.push(R)}}}if(p-3>0){var I=new l.get(p-2)
new l.get(p-3)
if(d.open/f.close>1&&f.amount>5e7){for(var V=100*(d.open/f.close-1),X=100*(d.close/f.close-1),K={c:g,open:parseFloat(V.toFixed(2)),close:parseFloat(X.toFixed(2)),v:parseFloat((d.amount/1e8).toFixed(2))},P=!1,U=0;U<alldays[y].gks.length;U++)if(V>alldays[y].gks[U].open){alldays[y].gks.splice(U,0,K),P=!0
break}!P&&alldays[y].gks.length<gConfig.maxLongtouCount&&alldays[y].gks.push(K)}}if(gmTdx.isRiseLimit(d.close,f.close)){for(var Z=0,Q=d.close==d.open,E=0,F=p;F>0;F--){var z=new l.get(F),I=new l.get(F-1)
if(!gmTdx.isRiseLimit(z.close,I.close))break
Q=z.high==z.low||I.close/I.open>1.23||z.close/z.open>1.23,E=Q?E+1:0,Z++}Q&&(Z-=E),alldays[y].zt+=Z>0?1:0
var W={c:g,lb:Z,v:parseFloat((d.amount/1e8).toFixed(2))}
if(Z>0){for(var P=!1,U=0;U<alldays[y].lts.length;U++)if(Z>alldays[y].lts[U].lb||Z==alldays[y].lts[U].lb&&W.v>alldays[y].lts[U].v){alldays[y].lts.splice(U,0,W),P=!0
break}P||alldays[y].lts.push(W)}}else if(gmTdx.isRiseLimit(d.high,f.close)&&d.high>d.close){alldays[y].kb++
for(var Z=0,Q=!1,E=0,F=p;F>0;F--){var z=new l.get(F),I=new l.get(F-1)
if(!gmTdx.isRiseLimit(z.high,I.close))break
Q=z.high==z.low||I.high/I.open>1.23||z.high/z.open>1.23,E=Q?E+1:0,Z++}Q&&(Z-=E)
var Y={c:g,lb:Z,zf:parseFloat((100*(d.close/f.close-1)).toFixed(2)),v:parseFloat((d.amount/1e8).toFixed(2))}
if(Z>0){for(var P=!1,U=0;U<alldays[y].kbs.length;U++)if(Z>alldays[y].kbs[U].lb||Z==alldays[y].kbs[U].lb&&Y.v>alldays[y].kbs[U].v){alldays[y].kbs.splice(U,0,Y),P=!0
break}P||alldays[y].kbs.push(Y)}}else gmTdx.isFallLimit(d.close,f.close)&&alldays[y].dt++
var J=Math.round(d.amount/1e8),ee={c:g,a:J}
if(alldays[y].tas.length<1)alldays[y].tas.push(ee)
else{for(var te=!1,U=0;U<alldays[y].tas.length;U++)if(J>=alldays[y].tas[U].a){alldays[y].tas.splice(U,0,ee),alldays[y].tas.length>gConfig.maxAmountCount&&alldays[y].tas.splice(gConfig.maxAmountCount),te=!0
break}!te&&alldays[y].tas.length<gConfig.maxAmountCount&&alldays[y].tas.push(ee)}}else if(d.day<e)break}}}}gmAllStocks.endGetName(),i="",a=""
for(y in alldays){if(0==alldays[y].ok&&(alldays[y].ok=1,alldays[y].zth=(100*alldays[y].zth/alldays[y].crcount).toFixed(2),alldays[y].ztc=(100*alldays[y].ztc/alldays[y].crcount).toFixed(2)),r==y){for(var U=0;U<alldays[y].lts.length;U++){var M=gmTdx.codeToTdxSymbol(alldays[y].lts[U].c);-1==i.indexOf(M)&&(i+=M+"\r\n")}for(var U=0;U<alldays[y].kbs.length;U++){var M=gmTdx.codeToTdxSymbol(alldays[y].kbs[U].c);-1==a.indexOf(M)&&(a+=M+"\r\n")}}void 0!==alldays[y].lts&&alldays[y].lts.length>gConfig.maxLongtouCount&&alldays[y].lts.splice(gConfig.maxLongtouCount),void 0!==alldays[y].kbs&&alldays[y].kbs.length>gConfig.maxLongtouCount&&alldays[y].kbs.splice(gConfig.maxLongtouCount),void 0!==alldays[y].qss&&alldays[y].qss.length>gConfig.maxLongtouCount&&alldays[y].qss.splice(gConfig.maxLongtouCount),void 0!==alldays[y].gks&&alldays[y].gks.length>gConfig.maxLongtouCount&&alldays[y].gks.splice(gConfig.maxLongtouCount)}if(t>=r&&i.length>10){var ie=gConfig.tdxFolder+"/T0002/blocknew/ZT.blk",ae=gConfig.tdxFolder+"/T0002/blocknew/KB.blk",ne=(gConfig.tdxFolder+"/T0002/blocknew/QRZT.blk",gConfig.tdxFolder+"/T0002/blocknew/QRKB.blk",gConfig.tdxFolder+"/T0002/blocknew/JQZT.blk"),oe=gConfig.tdxFolder+"/T0002/blocknew/JL.blk",se=gConfig.tdxFolder+"/T0002/blocknew/QS.blk",re=gConfig.tdxFolder+"/T0002/blocknew/DDXG.blk"
r==t&&fs.writeFileSync(re,n),fs.writeFileSync(ne,s),fs.writeFileSync(se,gmFupan.getQuSiBlock(alldays[""+r])),fs.writeFileSync(ie,i),fs.writeFileSync(ae,a),fs.writeFileSync(oe,o)}saveObjectToFile(alldays,gFupanFile),saveObjectToFile(gxCache,gGuxingFile),e==t&&gConfig.enableTickVol&&(gmAddonIndex.calcIndex(),gmAddonIndex.calcHYIndex(),gmAddonIndex.calcLbAndQsIndex()),iToasts.show("复盘成功",!1),gmGuxing.loadTdxBlocks(),gmFupan.listFupan(),gmTcgl.changeTab(gmTcgl.currentTab),gmTcgl.listHotStocks($("btnListTcglFromServer"))},gmFupan.getMa=function(e,t,i){for(var a=0,n=t;n>0;n--){var o=new e.get(n)
if(a+=o.close,t-n==i-1)return a/i}return 0},gmFupan.saveAlldays=function(){var e=JSON.stringify(alldays)
fs.writeFileSync(gFupanFile,e)},gmFupan.doFupanToday=function(){if(null==userinfo)return void popuplist.push("divuserlogin")
if(!checkvuser())return void popuplist.push("divuserbindsn")
var e=(new Date,gmTdx.getLastTradeDay())
iDlgs.confirm("系统提示","<b>确定要复盘今日数据吗（"+e+"）？</b><br><span style='color:red'>注：相同日期仅需复盘计算一次即可，然后可点查询查看，请勿重复复盘。<br>根据电脑配置不同，可能花费2-20秒不等，请耐心等待</span>",function(){delayRunPrompt(100,function(){gmFupan.tdx_fupan(e,e)})},function(){})},gmFupan.doFupan=function(){return null==userinfo?void popuplist.push("divuserlogin"):checkvuser()?void iDlgs.confirm("系统提示","<b>确定要复盘指定日期吗？</b><br><span style='color:red'>注：相同日期仅需复盘计算一次即可，然后可点查询查看，请勿重复复盘。<br>根据电脑配置不同，可能花费2-20秒不等，请耐心等待</span>",function(){var e=parseInt($("startdate").value.replace(/\-/g,"")),t=parseInt($("enddate").value.replace(/\-/g,""))
delayRunPrompt(100,function(){gmFupan.tdx_fupan(e,t)})},function(){}):void popuplist.push("divuserbindsn")},gmFupan.listFupan=function(){var e=parseInt($("startdate").value.replace(/\-/g,"")),t=parseInt($("enddate").value.replace(/\-/g,"")),i=JSON.parse(JSON.stringify(gmFupan.myMoneyOptionTemplate)),a=999999999,n=-1e4,o=1,s=1
gmAllStocks.startGetName()
for(var r=null,l="",d=e;t>=d;d++){var c=""+d
if(c in alldays){var g=alldays[c],u={}
c in gmFupan.myFupanDays&&(u=gmFupan.myFupanDays[c])
var h=parseInt(void 0===u.mymoney?0:u.mymoney),m=0
if(null!=r){var p=void 0===r.mymoney?0:r.mymoney,f=parseInt(void 0===u.mymoneychange?0:u.mymoneychange),y=h-f
y>0&&p>0&&(m=100*(y/p-1))}h>0&&(i.xAxis[0].data.push(c),o*=1+m/100,i.series[0].data.push(o),null!=r&&(s*=1+parseFloat(g.shzf)/100),i.series[1].data.push(s),a=a>o?o:a,a=a>s?s:a,n=o>n?o:n,n=s>n?s:n)
var v=parseInt(g.zt+10+10*parseFloat(g.zth)+10*parseFloat(g.ztc)),b=g.cybma>=100,x=v>=400||v>=150&&g.cybma>=50,_=(parseFloat(g.zth)+parseFloat(g.ztc)>=7,b?"background:#616571; ":x?"background:#616571; ":""),L=g.cybzf>3?"stockcolorred":g.cybzf<-3?"stockcolorgreen":"",k=gmFupan.getLongtouStr(g,u),T="<td >"+gmFupan.getKaibanStr(g)+"</td>",w=gmFupan.getQuSiStr(g,u),F=gmFupan.getGaoKaiStr(g)
r=u
var S=m>0?"stockcolorred":"stockcolorgreen",A=""
if(1==gConfig.cfgShowMaxAmount){for(var C="",D=0,z=0;z<g.tas.length;z++){var I=g.tas[z].c,M=gmAllStocks.getName(I)
C+=Math.round(g.tas[z].a)+"亿"+M+" 	",(z+1)%3==0&&(C+="<br>"),z>0&&(D+=g.tas[z].a)}D=Math.round(D),A="<td style='width:260px;text-align:left;'>"+C+"</td>"}var H=0,q=0
if(void 0!==g.qss)for(var z=0;z<g.qss.length;z++)H+=g.qss[z].qs
for(var z=0;z<g.lts.length;z++)q+=g.lts[z].lb*g.lts[z].lb
qsstyle=140>H?"":" class='stockcolorred'",lbstyle=50>q?"":" class='stockcolorred'",k+="|"+q,w+="|"+H,w=gConfig.cfgShowQusiStock?"<td "+qsstyle+">"+w+"</td>":"",F=gConfig.cfgShowGaokaiStock?"<td>"+F+"</td>":""
var j="<td></td>"
void 0!==gmTcgl.publicHS[c]&&(j="<td>"+gmTcgl.publicHS[c]+"</td>")
var G="",O="<td></td>"
void 0!==gmTcgl.publicTCS[c]&&(O="<td>"+gmTcgl.publicTCS[c]+"</td>")
var B=void 0!==gmTcgl.publicTHSZT[c]?"<br><span class='minbtn' onmouseover='gmFupan.toggleShowThsZTFupan(this,\""+c+"\")' onmouseout='gmFupan.toggleShowThsZTFupan(this,\""+c+"\")'>涨停表</span>":""
h=f>0?h+"<br><span class='stockcolorred'>(资金+"+f+")</span>":0>f?h+"<br><span style='color:green'>(资金"+f+")</span>":h
var E=gConfig.cfgShowShiZhi?"<td >"+h+"</td><td class='"+S+"'>"+m.toFixed(2)+"%</td>":"",N=gConfig.cfgShowPriFupan?"<td>"+(void 0===u.bankuai?"":u.bankuai)+"</td><td  >"+(void 0===u.fupan?"":u.fupan)+"</td><td >"+(void 0===u.mystocks?"":u.mystocks)+"</td>":"",R="<tr style='"+_+"'><td>"+d+B+"</td><td class='stockcolorred'>"+g.zt+"</td><td>"+g.kb+"</td><td>"+g.dt+"</td><td>"+g.zth+"%</td><td>"+g.ztc+"%</td><td>"+g.sha+"亿</td><td class='"+L+"'>"+g.shzf+"%</td>"+A+"<td "+lbstyle+">"+k+"</td>"+T+F+j+G+O+w+N+E+"<td><span class='minbtn' onclick='gmFupan.modifyFupan("+d+")'>修改</span></td></tr>"
l=R+l}}var P=""
1==gConfig.cfgShowMaxAmount&&(P="<th style='min-width:250px;'>个股成交</th>")
var U=gConfig.cfgShowGaokaiStock?"<th  style='width:300px;'>高开股</th>":"",V="<th  style='width:120px;'>人气股</th>",X="",K="<th  style='width:120px;'>热门题材</th>",Z=gConfig.cfgShowQusiStock?"<th  style='width:260px;'>趋势股</th>":"",Q=gConfig.cfgShowShiZhi?"<th style='width:80px;'>收盘市值</th><th>当日收益</th>":"",W=gConfig.cfgShowPriFupan?"<th style='width:100px;'>强势板块</th><th style='width:260px;'>复盘说明</th><th style='width:100px;'>当日持股</th>":""
l="<tr><th style='width:70px;'>日期</th><th style='width:40px;'>涨停</th><th style='width:40px;'>开板</th><th style='width:40px;'>跌停</th><th style='width:60px;'>次日高</th><th style='width:60px;'>次日收</th><th style='width:60px;'>沪指额</th><th style='width:60px;'>沪指涨</th>"+P+"<th  style='width:260px;'>连板股</th><th  style='width:260px;'>开板股</th>"+U+V+X+K+Z+W+Q+"<th>操作</th></tr>"+l,gmAllStocks.endGetName(),$("tablefupan").innerHTML=l,iToasts.show("加载完毕",!1)
var Y=a,J=n
n-1>1-a?Y=2-n:J=2-a,i.yAxis[0].min=Y,i.yAxis[0].max=J,i.yAxis[1].min=100*(Y-1),i.yAxis[1].max=100*(J-1),i.yAxis[0].axisLabel.formatter=function(e){return e.toFixed(2)},i.yAxis[1].axisLabel.formatter=function(e){return e.toFixed(2)+"%"}
var ee=echarts.init($("divMyMoneyChart"))
JSON.stringify(i)
ee.setOption(i)},gmFupan.toggleShowThsZTFupan=function(e,t){var i=$("divZtFupanThs")
if("block"==i.style.display)return void(i.style.display="none")
$("imgThsZtFp").src=gmTcgl.publicTHSZT[t]
var a=document.documentElement.clientHeight-40
i.style.height=a+"px",i.style.top="20px",i.style.display="block"},gmFupan.getQuSiBlock=function(e){if(void 0===e.qss)return""
for(var t="",i=0;i<e.qss.length;i++)t+=gmTdx.codeToTdxSymbol(e.qss[i].c)+"\r\n"
return t},gmFupan.getGaoKaiStr=function(e){if(void 0===e.gks)return""
for(var t="",i=0,a=0,n=0;n<e.gks.length;n++){i+=e.gks[n].open,a+=e.gks[n].close
var o=gmAllStocks.getName(e.gks[n].c)
t+=e.gks[n].open.toFixed(1)+"%"+o+"/"}i/=e.gks.length,a/=e.gks.length
var s=Math.abs(a-i)>2&&3>a?"stockcolorgreen":a-i>0?"stockcolorred":""
return"<span class='"+s+"'>"+t+"均"+i.toFixed(2)+"%&gt;收"+a.toFixed(2)+"%</span>"},gmFupan.getQuSiStr=function(e,t){if(void 0===e.qss)return""
var i=""
if(void 0===t.qusi||""==t.qusi){i=""
for(var a=0,n=0;n<e.qss.length;n++){var o=gmAllStocks.getName(e.qss[n].c)
a!=e.qss[n].qs?(a=e.qss[n].qs,i+=(""==i?"":", ")+a+"天"+o):i+="/"+o}return i}return void 0===t.qusi?"":t.qusi},gmFupan.getLongtouStr=function(e,t){var i=""
if(void 0===t.longtou||""==t.longtou){i=""
for(var a=0,n=0;n<e.lts.length;n++){var o=gmAllStocks.getName(e.lts[n].c)
a!=e.lts[n].lb?(a=e.lts[n].lb,i+=(""==i?"":", ")+a+"板"+o):i+="/"+o}return i}return void 0===t.longtou?"":t.longtou},gmFupan.getKaibanStr=function(e){if(void 0===e.kbs)return""
for(var t="",i=0,a=0;a<e.kbs.length;a++){var n=gmAllStocks.getName(e.kbs[a].c)
i!=e.kbs[a].lb?(i=e.kbs[a].lb,t+=(""==t?"":", ")+i+"板"+n):t+="/"+n}return t},gmFupan.modifyFupan=function(e){if(e=""+e,e in alldays){var t=alldays[e],i={}
e in gmFupan.myFupanDays?i=gmFupan.myFupanDays[e]:gmFupan.myFupanDays[e]=i,$("frmmodify").style.display="block",$("spday").innerHTML="修改复盘内容"+e+"：",$("modify_mystocks").value=void 0===i.mystocks?"":i.mystocks
var a=gmFupan.getLongtouStr(t,i)
$("modify_longtou").value=a,$("modify_bankuai").value=void 0===i.bankuai?"":i.bankuai,$("modify_fupan").value=void 0===i.fupan?"":i.fupan,$("modify_mymoney").value=void 0===i.mymoney?0:i.mymoney,$("modify_mymoneychange").value=void 0===i.mymoneychange?0:i.mymoneychange,$("myfupan_modify_confirm").onclick=function(){i.mystocks=$("modify_mystocks").value,a!=$("modify_longtou").value&&(i.longtou=$("modify_longtou").value),i.bankuai=$("modify_bankuai").value,i.fupan=$("modify_fupan").value,i.mymoney=parseInt($("modify_mymoney").value),i.mymoneychange=parseInt($("modify_mymoneychange").value),$("frmmodify").style.display="none",saveObjectToFile(gmFupan.myFupanDays,gMyFupanFile),iToasts.show("修改成功",!1),gmFupan.listFupan()}}},gmFupan.showMyMoneyChart=function(e){$("divMyMoneyChartWrapper").style.display="block"==$("divMyMoneyChartWrapper").style.display?"none":"block",e.innerHTML="block"==$("divMyMoneyChartWrapper").style.display?"关闭资金曲线图":"绘制资金曲线图","block"==$("divMyMoneyChartWrapper").style.display&&gmFupan.listFupan()},gmFupan.myMoneyOptionTemplate={backgroundColor:"#fff",title:{text:"资金曲线图",padding:[2,0,2,40],itemGap:0,textStyle:{color:"#ff8289",fontSize:14}},tooltip:{show:!1,trigger:"axis"},legend:{data:["总收益率","上证指数"]},grid:{x:100,y:30,x2:65,y2:60,borderWidth:0},dataZoom:{show:!1},calculable:!1,xAxis:[{type:"category",boundaryGap:!1,splitLine:{show:!1},splitArea:{show:!0},axisLabel:{textStyle:{color:"#999"}},data:[]}],yAxis:[{type:"value",splitLine:{show:!1},splitArea:{show:!0},axisLabel:{textStyle:{color:"#ff8289"},precision:0}},{type:"value",splitLine:{show:!1},splitArea:{show:!1},axisLabel:{textStyle:{color:"#ff8289"},precision:2}}],series:[{name:"总资产",type:"line",data:[]},{name:"上证指数",type:"line",data:[]}]}
var gmGuxing={}
gmGuxing.queryHistoryCache=[],gmGuxing.init=function(){gmGuxing.currentTab=$("gxTabZTG"),gxCache=readObjectFromFile(gGuxingFile),gmGuxing.loadTdxBlocks(),gmGuxing.changeTab(gmGuxing.currentTab)},gmGuxing.loadTdxBlocks=function(){gmGuxing.zxgCache=gmGuxing.readTdxBlock("ZXG"),gmGuxing.kbgCache=gmGuxing.readTdxBlock("KB"),gmGuxing.ztgCache=gmGuxing.readTdxBlock("ZT")},gmGuxing.readTdxBlock=function(e){var t=gConfig.tdxFolder+"/T0002/blocknew/"+e+".blk"
if(fs.existsSync(t)){for(var i=fs.readFileSync(t,{encoding:"utf8"}),a=i.split("\r\n"),n=0;n<a.length;n++)7==a[n].length&&(a[n]=a[n].substr(1))
return a}return[]},gmGuxing.onkeydown=function(){13==event.keyCode&&gmGuxing.calcGuxing()},gmGuxing.changeTab=function(e){switch(gmGuxing.currentTab.className="tab",gmGuxing.currentTab=e,gmGuxing.currentTab.className="tabselected",e.getAttribute("id")){case"gxTabHistory":gmGuxing.listGuxing(gmGuxing.queryHistoryCache)
break
case"gxTabZXG":gmGuxing.listGuxing(gmGuxing.zxgCache)
break
case"gxTabZTG":gmGuxing.loadTdxBlocks(),gmGuxing.listGuxing(gmGuxing.ztgCache)
break
case"gxTabKBG":gmGuxing.listGuxing(gmGuxing.kbgCache)}},gmGuxing.listGuxing=function(e){for(var t="<tr style='text-align:center;'><th style='min-width:55px;'>代码</th><th style='min-width:60px;'>名称</th><th style='min-width:45px;'>股性</th><th style='min-width:60px;'>龙头气质</th><th style='min-width:60px;'>最高连板</th><th style='min-width:45px;'>涨停</th><th style='min-width:45px;'>开板</th><th style='min-width:55px;'>开板率</th><th style='min-width:45px;'>跌停</th><th style='min-width:230px;'>涨停次日平均</th><th style='min-width:230px;'>开板次日平均</th></tr>",i=0;i<e.length;i++)if(code=e[i],6==code.length&&(gx=gmGuxing.getGuxing(code),null!=gx)){var a="开"+gx.ztn.o+"% 低"+gx.ztn.l+"% 高"+gx.ztn.h+"% 收"+gx.ztn.c+"%",n="开"+gx.kbn.o+"% 低"+gx.kbn.l+"% 高"+gx.kbn.h+"% 收"+gx.kbn.c+"%",o=parseFloat((100*gx.kb/(gx.zt+gx.kb+.01)).toFixed(2)),s=gmGuxing.getGxValue(gx),r=gmGuxing.getGxColor(s)
r=empty(r)?"":"font-weight:bold;color:"+r
var l=gmAllStocks.getName(code)
t+="<tr style='"+r+"'><td>"+code+"</td><td>"+l+"</td><td>"+s+"</td><td>"+gx.lt+"</td><td>"+gx.lb+"</td><td>"+gx.zt+"</td><td>"+gx.kb+"</td><td>"+o+"%</td><td>"+gx.dt+"</td><td>"+a+"</td><td>"+n+"</td></tr>"}$("tableguxing").innerHTML=t},gmGuxing.getGxValue=function(e){var t=3*e.lb,i=e.lt+t+e.zt+Math.round(e.ztn.o+e.ztn.h)
return 0>i?1:i},gmGuxing.getGxColor=function(e){var t=""
return e>=80?t="red;":e>=45?t="#ff8289;":e>=30&&(t="#00c1de;"),t},gmGuxing.calcGuxing=function(){var e=$("gxStockCode").value
if(6!=e.length)return iToasts.show("请输入要计算的股票代码",!0),void $("gxStockCode").focus()
var t=gmGuxing.getGuxing(e)
return null==t?void iToasts.show("计算失败，未找到该股票。请输入完整的股票代码，或检查是否已用通达信下载该股票历史数据",!0):($("gxStockCode").value="",gmGuxing.queryHistoryCache.splice(0,0,e),gmGuxing.queryHistoryCache.length>30&&gmGuxing.queryHistoryCache.splice(30,30),void gmGuxing.changeTab($("gxTabHistory")))},gmGuxing.getGuxing=function(e){var t={zt:0,kb:0,dt:0,lb:0,ztn:{o:0,l:0,h:0,c:0},kbn:{o:0,l:0,h:0,c:0},lt:0}
return 6!=e.length?t:void 0!==gxCache[e]?gxCache[e]:t},gmGuxing.updateGuxing=function(e,t){var i={zt:0,kb:0,dt:0,lb:0,ztn:{o:0,l:0,h:0,c:0},kbn:{o:0,l:0,h:0,c:0},lt:0}
if(i.day=parseInt((new Date).Format("yyyyMMdd")),0==t.length)return gxCache[e]=i,0
for(var a=0,n=0,o=0,s=0,r=t.length-1;r>0&&r>t.length-gConfig.maxGuxingDays;r--){var l=new t.get(r),d=new t.get(r-1)
if(r==t.length-1?s=l.high:o=o>l.high?o:l.high,gmTdx.isRiseLimit(l.close,d.close)){for(var c=0,g=l.close==l.open,u=0,h=r;h>0;h--){var m=new t.get(h),p=new t.get(h-1)
if(!gmTdx.isRiseLimit(m.close,p.close))break
g=m.high==m.low||p.close/p.open>1.22||m.close/m.open>1.22,u=g?u+1:0,c++}if(g&&(c-=u),c>0&&r+1<t.length){i.zt+=c>0?1:0
var f=new t.get(r+1)
f.close/l.close>.89&&(i.ztn.o+=f.open/l.close-1,i.ztn.l+=f.low/l.close-1,i.ztn.h+=f.high/l.close-1,i.ztn.c+=f.close/l.close-1,a++),i.lb=i.lb>c?i.lb:c
var y=""+l.day
if(void 0!==alldays[y]){for(var v=alldays[y].lts,b=0,x=0;x<v.length;x++)v[x].lb>c&&b++
3>=b?i.lt+=2:10>=b?i.lt+=1:alldays[y].zt<30?i.lt+=.5:alldays[y].zt<100?i.lt+=.25:alldays[y].zt<300&&(i.lt+=.125)}}}else if(gmTdx.isRiseLimit(l.high,d.close)&&l.high>l.close){if(r+1<t.length){i.kb++
var f=new t.get(r+1)
f.close/l.close>.89&&(i.kbn.o+=f.open/l.close-1,i.kbn.l+=f.low/l.close-1,i.kbn.h+=f.high/l.close-1,i.kbn.c+=f.close/l.close-1,n++)}}else gmTdx.isFallLimit(l.close,d.close)&&i.dt++}return i.kb>0&&(i.kbn.o=parseFloat((100*i.kbn.o/n).toFixed(2)),i.kbn.l=parseFloat((100*i.kbn.l/n).toFixed(2)),i.kbn.h=parseFloat((100*i.kbn.h/n).toFixed(2)),i.kbn.c=parseFloat((100*i.kbn.c/n).toFixed(2))),i.zt>0&&(i.ztn.o=parseFloat((100*i.ztn.o/a).toFixed(2)),i.ztn.l=parseFloat((100*i.ztn.l/a).toFixed(2)),i.ztn.h=parseFloat((100*i.ztn.h/a).toFixed(2)),i.ztn.c=parseFloat((100*i.ztn.c/a).toFixed(2))),i.lt=Math.round(i.lt),gxCache[e]=i,s>=o&&t.length>30?1:0},gmGuxing.updateTdx=function(e){if(null==userinfo)return void popuplist.push("divuserlogin")
if(!checkvuser())return void popuplist.push("divuserbindsn")
var t="|789|",i="|788|",a="|787|",n="|786|",o="|784|",s="|785|",r="",l=gConfig.tdxFolder+"/T0002/signals/extern_user.txt"
if(fs.existsSync(l))for(var d=fs.readFileSync(l),c=iconv.decode(d,"gbk"),g=c.split("\r\n"),u=0;u<g.length;u++)-1==g[u].indexOf(t)&&-1==g[u].indexOf(i)&&-1==g[u].indexOf(a)&&-1==g[u].indexOf(n)&&-1==g[u].indexOf(o)&&-1==g[u].indexOf(o)&&(r+=g[u]+"\r\n")
var h=""+gmTcgl.getGroupId()
for(var m in gxCache){var p=gxCache[m],f=parseFloat((100*p.kb/(p.zt+p.kb+.01)).toFixed(2)),y=gmGuxing.getGxValue(p),v="6"==m.substr(0,1)?"1":"0",b=v+"|"+m+t
b+="股性"+y+" 龙头气质"+p.lt+" 最高连板"+p.lb+" 涨停数"+p.zt+" 开板数"+p.kb+" 开板率"+f+"% 涨停次日开"+p.ztn.o+"% 低"+p.ztn.l+"% 高"+p.ztn.h+"% 收"+p.ztn.c+"% |"+y+".0\r\n"
var x=void 0===gmTcgl.publicGnxx[h].items[m]?{gn:"",xx:"",user:"",mt:"0"}:gmTcgl.publicGnxx[h].items[m],_=void 0===x.gn?"":x.gn,L=void 0===x.xx?"":x.xx
b+=v+"|"+m+i+_.replace("|"," ")+"|0.0\r\n",b+=v+"|"+m+a+L.replace("|"," ")+"|0.0\r\n",empty(x.sd784)||(b+=v+"|"+m+o+x.sd784.replace("|"," ")+"|0.0\r\n"),empty(x.sd785)||(b+=v+"|"+m+s+x.sd785.replace("|"," ")+"|0.0\r\n"),r+=b}var k=iconv.encode(r,"gbk")
fs.writeFileSync(l,k),iToasts.show("所有个股的股性及概念题材已成功同步到通达信，请在通达信中点击菜单-系统-断开行情连接并重新连接行情即可生效，或重新启动通达信也可生效",!1)}
var gmHqreappear={}
gmHqreappear.init=function(){gmHqreappear.currentTab=$("gtabzflist"),gmHqreappear.createLocalId(),$("hqreaday").value=gmTdx.getLastTradeDay("yyyy-MM-dd"),gmHqreappear.status="STOP",gmHqreappear.stockCode="000025",gmHqreappear.perMin=60,gmHqreappear.lastTime=(new Date).getTime(),gmHqreappear.currentIndex=-2,gmHqreappear.minutesCount=gmHqreappear.perMin,disableButton($("btnStop")),disableButton($("btnBackward")),disableButton($("btnForward")),gmHqreappear.onResize(),setInterval(gmHqreappear.onTimer,100),gmHqreappear.ddlog(),gmHqreappear.initTableHeaders(),gmHqreappear.type=0},gmHqreappear.testThs=function(){gConfig.tdxFolder="C:/同花顺软件/同花顺/"
var e=new gmThs.tdxDayMinutes("000025","20161216")
console.log(e.length)},gmHqreappear.showTab=function(e,t){return"STOP"==gmHqreappear.status?void iToasts.show("请先点击开始回放按钮，加载数据后方可切换",!0):(gmHqreappear.currentTab.className="tab",gmHqreappear.currentTab=e,e.className="tabselected",gmHqreappear.type=t,void gmHqreappear.updateMinute())},gmHqreappear.start=function(){return null==userinfo?void popuplist.push("divuserlogin"):checkvuser()?void("STOP"==gmHqreappear.status?iDlgs.confirm("系统提示","<b>确定要回放指定日期吗？</b><br>回放行情需要加载全部3600多只股票的当日行情数据，根据电脑配置不同，可能花费2-20秒不等，请耐心等待。注意，下载的分时数据越大，则加载会越慢。",function(){delayRunPrompt(100,function(){gmHqreappear.currentTime=new Date($("hqreaday").value+" 09:30:00"),gmHqreappear.currentIndex=-1,gmHqreappear.hqSpeed=parseInt($("hqSpeed").value),gmHqreappear.hqSpeed=gmHqreappear.hqSpeed<1?1:gmHqreappear.hqSpeed,gmHqreappear.zsInterval=parseInt(gConfig.zsInterval)
var e=gmHqreappear.currentTime.Format("yyyyMMdd")
return gmHqreappear.dataExists(e)?(gmHqreappear.minutesCount=window.localId==gConfig.rsn?4*gmHqreappear.perMin:gmHqreappear.perMin,gmHqreappear.checkLocalId(),gmHqreappear.onResize(),gmHqreappear.loadAllStocks(e),gmHqreappear.selectStock("000025"),enableButton($("btnStop")),enableButton($("btnBackward")),enableButton($("btnForward")),gmHqreappear.status="START",void($("btnStart").innerHTML="暂停")):void iDlgs.show("系统提示","请先用通达信下载（该日及前一日）的日线和1分钟线数据。")})},function(){}):"START"==gmHqreappear.status?(gmHqreappear.status="PAUSE",$("btnStart").innerHTML="继续"):"PAUSE"==gmHqreappear.status&&(gmHqreappear.hqSpeed=parseInt($("hqSpeed").value),gmHqreappear.hqSpeed=gmHqreappear.hqSpeed<1?1:gmHqreappear.hqSpeed,gmHqreappear.status="START",$("btnStart").innerHTML="暂停")):void popuplist.push("divuserbindsn")},gmHqreappear.stop=function(){var e=$("btnStop")
e.disabled||(disableButton(e),disableButton($("btnBackward")),disableButton($("btnForward")),gmHqreappear.status="STOP",$("btnStart").innerHTML="开始回放")},gmHqreappear.backward=function(){gmHqreappear.currentIndex<1||"STOP"==gmHqreappear.status||(gmHqreappear.currentIndex--,gmHqreappear.updateMinute())},gmHqreappear.forward=function(){gmHqreappear.currentIndex>=gmHqreappear.minutesCount-1||"STOP"==gmHqreappear.status||(gmHqreappear.currentIndex++,gmHqreappear.updateMinute())},gmHqreappear.onStockCodeKeyDown=function(){13==event.keyCode&&"STOP"!=gmHqreappear.status&&gmHqreappear.selectStock($("hqStockCode").value)},gmHqreappear.selectStock=function(e){if(!(gmHqreappear.currentIndex<-1)){if(e=e.trim(),6!=e.length)return void iToasts.show("请输入完整的股票代码（6位数字）",!0)
var t=""
if("6"==e.substr(0,1)||"9"==e.substr(0,1)||"8"==e.substr(0,1)?t=gConfig.tdxFolder+"/vipdoc/sh/minline/sh"+e+".lc1":("3"==e.substr(0,1)||"0"==e.substr(0,1))&&(t=gConfig.tdxFolder+"/vipdoc/sz/minline/sz"+e+".lc1"),!fs.existsSync(t))return void iToasts.show("请先用通达信下载该股的日线和1分钟线数据："+e,!0)
gmHqreappear.stockCode=e,gmHqreappear.stockKLine=new gmTdx.tdxDays(e)
var i=gmHqreappear.codeToTdxIndex(e),a=gmHqreappear.currentTime.Format("yyyyMMdd")
gmHqreappear.stockTickLine=new gmTdx.tdxDayMinutes(e,a),gmHqreappear.stockTickLine.name=gmAllStocks.getName(e),gmHqreappear.indexTickLine=new gmTdx.tdxDayMinutes(i,a),gmHqreappear.indexTickLine.name=gmAllStocks.getName(i),gmHqreappear.showStock()}},gmHqreappear.showStock=function(){gmHqreappear.showKLine("tsStockKline"),gmHqreappear.showTickLine(gmHqreappear.stockTickLine,"tsStockTickline"),gmHqreappear.showTickLine(gmHqreappear.indexTickLine,"tsIndexTickline")},gmHqreappear.getMas=function(e,t){for(var i=0,a={ma5:0,ma10:0,ma20:0,ma30:0},n=t;n>0;n--){var o=new e.get(n)
if(i+=o.close/100,t-n==4&&(a.ma5=i/5),t-n==9&&(a.ma10=i/10),t-n==19&&(a.ma20=i/20),t-n==29){a.ma30=i/30
break}}return a},gmHqreappear.getStartDateIndex=function(e,t){for(var i=1,a=e.length-1;a>=i;){var n=parseInt((i+a)/2),o=new e.get(n)
if(t==o.day)return n
t<o.day?a=n-1:i=n+1}return e.length},gmHqreappear.showTickLine=function(e,t){if(-1!=gmHqreappear.currentIndex){for(var i=gmHqreappear.initTicklineOption(),a=0,n=0,o=999999,s=0,r=0,l=0,d=0,c=0;c<=gmHqreappear.currentIndex;c++){var g=e.get(c),u=parseFloat((d/(100*l)).toFixed(2))
i.series[0].data.push(g.close),i.series[1].data.push(u),i.series[2].data.push(g.volume),o=o<g.low?o:g.low,s=s>g.high?s:g.high,l+=g.volume,d+=g.amount,r=g.volume>r?g.volume:r,0==c&&(a=g.open),c==gmHqreappear.currentIndex&&(n=g.close)}var h=d
d>1e8?h=(d/1e8).toFixed(2)+"亿":d>1e4&&(h=(d/1e4).toFixed(2)+"万"),h=0!=h?" 成交额:"+h:"",cprice=" 现价:"+n.toFixed(2),a=" 今开:"+(100*(a/e.preclose-1)).toFixed(2)+"%",n=" 涨幅:"+(100*(n/e.preclose-1)).toFixed(2)+"%",i.title.text=e.code+" "+e.name+cprice+a+n+h
var m=o,p=s
s-e.preclose>e.preclose-o?m=2*e.preclose-s:p=2*e.preclose-o,i.yAxis[0].min=m-3*(p-m)/6.6,i.yAxis[0].max=p,i.yAxis[1].min=0,i.yAxis[1].max=10*r/3
var f=99999
i.series[1].markLine.data.push([{label:"0.00%",xAxis:0,yAxis:e.preclose},{xAxis:f,yAxis:e.preclose}]),i.series[1].markLine.data.push([{label:e.preclose.toFixed(2),xAxis:f,yAxis:e.preclose},{xAxis:0,yAxis:e.preclose}]),i.series[0].markLine.data.push([{label:(100*(p/e.preclose-1)).toFixed(2)+"%",xAxis:239,yAxis:p},{xAxis:f,yAxis:p}]),i.series[0].markLine.data.push([{label:p.toFixed(2),xAxis:1,yAxis:p},{xAxis:0,yAxis:p}])
var y=(p+e.preclose)/2
i.series[0].markLine.data.push([{label:(100*(y/e.preclose-1)).toFixed(2)+"%",xAxis:0,yAxis:y},{xAxis:f,yAxis:y}]),i.series[0].markLine.data.push([{label:y.toFixed(2),xAxis:f,yAxis:y},{xAxis:0,yAxis:y}])
var v=(m+e.preclose)/2
i.series[0].markLine.data.push([{label:(100*(v/e.preclose-1)).toFixed(2)+"%",xAxis:0,yAxis:v},{xAxis:f,yAxis:v}]),i.series[0].markLine.data.push([{label:v.toFixed(2),xAxis:f,yAxis:v},{xAxis:0,yAxis:v}])
var b=r>1e4?(r/1e4).toFixed(1)+"万":r
i.series[2].markLine.data.push([{label:b,xAxis:f,yAxis:r},{xAxis:0,yAxis:r}]),i.series[0].markLine.itemStyle.normal.label.formatter=function(e,t,i){return e.data.label},i.series[1].markLine.itemStyle.normal.label.formatter=function(e,t,i){return e.data.label},i.series[2].markLine.itemStyle.normal.label.formatter=function(e,t,i){return e.data.label},i.series[0].markPoint.itemStyle.normal.label.formatter=function(e,t,i){return e.data.label},i.series[1].markPoint.itemStyle.normal.label.formatter=function(e,t,i){return e.data.label}
var x=echarts.init($(t))
x.setOption(i)}},gmHqreappear.showKLine=function(e){var t=gmHqreappear.stockKLine,i=parseInt(gmHqreappear.currentTime.Format("yyyyMMdd")),a=deepCopy(gmHqreappear.tsstockKLineOptionTemplate)
a.title.text=gmHqreappear.stockTickLine.code+" "+gmHqreappear.stockTickLine.name+"(日线,未复权) MA(5,10,20)"
var n=gConfig.cfgKLineBarCount,o=999999,s=0,r=9999999999,l=0,d=gmHqreappear.getStartDateIndex(t,i)
d=d-n>0?d-n:1
for(var c=d;c<t.length;c++){var g=new t.get(c),u={}
if(a.xAxis[0].data.push(""+g.day),g.day>=i)for(var h=999999,m=0,p=0,f=0,y=0;y<=gmHqreappear.currentIndex;y++){var v=gmHqreappear.stockTickLine.get(y)
h=h<v.low?h:v.low,m=m>v.high?m:v.high,p+=v.volume,f+=v.amount,0==y&&(u.open=parseFloat(v.open.toFixed(2))),y==gmHqreappear.currentIndex&&(u.low=parseFloat(h.toFixed(2)),u.high=parseFloat(m.toFixed(2)),u.close=parseFloat(v.close.toFixed(2)),u.volume=parseInt(p),u.amount=parseInt(f))}else u.low=parseFloat((g.low/100).toFixed(2)),u.high=parseFloat((g.high/100).toFixed(2)),u.open=parseFloat((g.open/100).toFixed(2)),u.close=parseFloat((g.close/100).toFixed(2)),u.volume=parseInt(g.volume/100),u.amount=parseInt(g.amount)
o=u.low<o?u.low:o,s=u.high>s?u.high:s,l=u.volume>l?u.volume:l,r=u.volume<r?u.volume:r
var b=gmHqreappear.getMas(t,c)
if(a.series[0].data.push(parseFloat(b.ma5.toFixed(2))),a.series[1].data.push(parseFloat(b.ma10.toFixed(2))),a.series[2].data.push(parseFloat(b.ma20.toFixed(2))),a.series[3].data.push([u.open,u.close,u.low,u.high]),u.close>u.open)var p={value:u.volume,itemStyle:{normal:{color:"darkred"}}}
else var p={value:u.volume,itemStyle:{normal:{color:"darkcyan"}}}
if(a.series[4].data.push(p),g.day>=i)break}a.yAxis[0].min=o-3*(s-o)/7,a.yAxis[0].max=s,a.yAxis[1].min=0,a.yAxis[1].max=10*l/3,a.series[0].markPoint.itemStyle.normal.label.formatter=function(e,t,i){return e.data.label},a.series[1].markPoint.itemStyle.normal.label.formatter=function(e,t,i){return e.data.label}
var x=echarts.init($(e))
x.setOption(a)},gmHqreappear.onTimer=function(){if("START"==gmHqreappear.status&&!((new Date).getTime()-gmHqreappear.lastTime<1e3*gmHqreappear.hqSpeed)){if(gmHqreappear.lastTime=(new Date).getTime(),gmHqreappear.currentIndex+1>=gmHqreappear.minutesCount?(gmHqreappear.stop(),gmHqreappear.minutesCount==1*gmHqreappear.perMin):gmHqreappear.currentIndex++,gmHqreappear.updateMinute(),gmHqreappear.currentIndex<120)var e=new Date("2016-10-10 09:30:00").addMinutes(gmHqreappear.currentIndex)
else var e=new Date("2016-10-10 13:00:00").addMinutes(gmHqreappear.currentIndex-120)
$("currentTime").innerHTML=e.Format("hh:mm"),console.log("耗时："+((new Date).getTime()-gmHqreappear.lastTime))}},gmHqreappear.onResize=function(){var e=$("tableLeftList1BottomHead"),t=$("tableLeftList1BottomContainer")
e.style.top=t.offsetTop+80+"px"},gmHqreappear.dataExists=function(e){var t=new gmTdx.tdxDayMinutes("999999",e)
return t.length>0},gmHqreappear.dlgReg=function(){iDlgs.confirm("注册提示","您好，请输入正确的软件序列号（与电脑绑定），若要购买软件序列号，请至软件网站：<a href='#' onclick=\"openurl('http://dada.suopo.org')\">http://www.dadayouzi,com</a>",function(){openurl("http://www.dadayouzi,com/")},function(){},"购买注册版")},gmHqreappear.loadZXGStocks=function(){gZXGFile=gConfig.cfgTdxZXG?gConfig.tdxFolder+"/T0002/blocknew/ZXG.blk":gAppFolder+"/dadadata/JQ.blk",gmHqreappear.zxgStocks=[]
for(var e=readTextFromFile(gZXGFile),t=e.split("\r\n"),i=0;i<t.length;i++)if(7==t[i].length){var a=t[i].substr(1)
gmHqreappear.zxgStocks.push({code:a})}},gmHqreappear.loadAllStocks=function(e){gmHqreappear.loadZXGStocks(),gmHqreappear.allStocks=[],gmHqreappear.ztStocks=[]
for(var t=0;t<gmAllStocks.codes.length;t++){var i=gmAllStocks.codes[t]
if("999999"!=i&&"399006"!=i){var a=gmAllStocks.getName(i)
if(""!=a){var n=new gmTdx.tdxDayMinutes(i,e)
0!=n.length&&(n.name=a,n.code=i,gmHqreappear.allStocks.push(n),0!=n.preclose2&&gmTdx.isRiseLimit(100*n.preclose,100*n.preclose2)&&gmHqreappear.ztStocks.push({code:i}))}}}},gmHqreappear.codeToTdxIndex=function(e){return"002"==e.substr(0,3)?"399005":"3"==e.substr(0,1)?"399006":"0"==e.substr(0,1)?"399001":("6"==e.substr(0,1),"999999")},gmHqreappear.initTableHeaders=function(){$("tableLeftList1TopHead").options={col:"zf",order:"desc"},$("tableLeftList1BottomHead").options={col:"zs",order:"desc"}},gmHqreappear.updateMinute=function(){if("STOP"!=gmHqreappear.status){for(var e={maxCount:100,items:[]},t={maxCount:100,items:[]},i=(new Date).getTime(),a=$("tableLeftList1TopHead").options,n=$("tableLeftList1BottomHead").options,o=0;o<gmHqreappear.allStocks.length;o++){var s=gmHqreappear.allStocks[o],r=s.get(gmHqreappear.currentIndex)
r.zf=100*(r.close/s.preclose-1),r.zf=r.zf>11?0:r.zf,r.zf=r.zf<-11?0:r.zf,r.kp=100*(s.open/s.preclose-1),r.kp=r.kp>11?0:r.kp,r.kp=r.kp<-11?0:r.kp
try{var l=gmHqreappear.currentIndex-gmHqreappear.zsInterval<0?0:gmHqreappear.currentIndex-gmHqreappear.zsInterval,d=s.get(l)}catch(c){console.log("code:"+s.code+", preindex:"+l+", currentIndex:"+gmHqreappear.currentIndex)}r.zs=100*(r.close/d.close-1),r.code=s.code,r.name=s.name
for(var g=0,u=0;u<=gmHqreappear.currentIndex;u++){var h=s.get(u)
g+=h.amount}r.amt=g,gmHqreappear.addListItem(e,0,r,a),gmHqreappear.addListItem(t,gmHqreappear.type,r,n)}console.log("for耗时："+((new Date).getTime()-i))
var m=(new Date).getTime()
gmHqreappear.createTableHtml(e,0,"tableLeftList1Top"),gmHqreappear.createTableHtml(t,gmHqreappear.type,"tableLeftList1Bottom"),console.log("insertHtml耗时："+((new Date).getTime()-m)),gmHqreappear.showStock()}},gmHqreappear.toggleListOrder=function(e){if("STOP"==gmHqreappear.status)return void iToasts.show("请先点击开始回放按钮，加载数据后方可切换",!0)
var t=e.parentElement.parentElement.parentElement,i=e.getAttribute("tid")
t.options.col==i?t.options.order="asc"==t.options.order?"desc":"asc":t.options.order="desc"
var a=t.getAttribute("id"),n=document.querySelector("#"+a+" th[tid='"+t.options.col+"']")
n.innerHTML=n.innerHTML.slice(0,-1),n.style.color="#fff",t.options.col=i,e.style.color="#f00",e.innerHTML+="asc"==t.options.order?"↑":"↓",gmHqreappear.updateMinute()},gmHqreappear.addListItem=function(e,t,i,a){if(1==t){for(var n=!1,o=0;o<gmHqreappear.zxgStocks.length;o++)if(gmHqreappear.zxgStocks[o].code==i.code){n=!0
break}if(!n)return}if(2==t){for(var n=!1,o=0;o<gmHqreappear.ztStocks.length;o++)if(gmHqreappear.ztStocks[o].code==i.code){n=!0
break}if(!n)return}for(var s=a.col,r=a.order,l=!1,d=e.items.length>e.maxCount?e.maxCount:e.items.length,c=0;d>c;c++)if("zf"==s&&"asc"==r&&i.zf<e.items[c].zf||"zf"==s&&"desc"==r&&i.zf>e.items[c].zf||"zs"==s&&"asc"==r&&i.zs<e.items[c].zs||"zs"==s&&"desc"==r&&i.zs>e.items[c].zs||"dm"==s&&"asc"==r&&i.code<e.items[c].code||"dm"==s&&"desc"==r&&i.code>e.items[c].code||"mc"==s&&"asc"==r&&i.name<e.items[c].name||"mc"==s&&"desc"==r&&i.name>e.items[c].name||"xj"==s&&"asc"==r&&i.close<e.items[c].close||"xj"==s&&"desc"==r&&i.close>e.items[c].close||"je"==s&&"asc"==r&&i.amt<e.items[c].amt||"je"==s&&"desc"==r&&i.amt>e.items[c].amt||"kp"==s&&"asc"==r&&i.kp<e.items[c].kp||"kp"==s&&"desc"==r&&i.kp>e.items[c].kp){e.items.splice(c,0,i),l=!0
break}!l&&e.items.length<e.maxCount&&e.items.push(i)},gmHqreappear.createTableHtml=function(e,t,i){for(var a="<tr><th style='width:40px;'>序号</th><th style='width:50px;'>代码</th><th style='width:60px;'>名称</th><th style='width:55px;'>现价</th><th style='width:50px;color:red'>%涨幅</th><th style='width:50px;'>%涨速</th><th style='width:60px;'>金额</th><th style='width:50px;'>%开盘</th></tr>",n="",o=0;o<e.maxCount&&o<e.items.length;o++){var s=e.items[o],r=s.zf>0?"color:red;":s.zf<0?"color:#129352;":"",l=s.zs>0?"color:red;":s.zs<0?"color:#129352;":"",d=s.kp>0?"color:red;":s.zs<0?"color:#129352;":"",c=1==t?"<span class='minbtn' onclick='gmHqreappear.removeZXG(\""+s.code+"\")'>删</span>":o+1
n+="<tr onclick='gmHqreappear.selectStock(\""+s.code+"\")'><td>"+c+"</td><td>"+s.code+"</td><td>"+s.name+"</td><td style='"+r+"'>"+s.close.toFixed(2)+"</td><td style='"+r+"'>"+s.zf.toFixed(2)+"</td><td style='"+l+"'>"+s.zs.toFixed(2)+"</td><td>"+(s.amt/1e8).toFixed(2)+"亿</td><td style='"+d+"'>"+s.kp.toFixed(2)+"</td></tr>"}$(i).innerHTML=a+n},gmHqreappear.createZXGTableHtml=function(e,t,i,a){for(var n="",o=0;o<e.length;o++)if(void 0!==e[o].stock){var s=e[o].stock,r=s.zf>0?"color:red;":s.zf<0?"color:#129352;":"",l=s.zs>0?"color:red;":s.zs<0?"color:#129352;":"",d=t?"<span class='minbtn' onclick='gmHqreappear.removeZXG(\""+s.code+"\")'>删</span>":o+1
n+="<tr onclick='gmHqreappear.selectStock(\""+s.code+"\")'><td>"+d+"</td><td>"+s.code+"</td><td>"+s.name+"</td><td style='"+r+"'>"+s.close.toFixed(2)+"</td><td style='"+r+"'>"+s.zf.toFixed(2)+"</td><td style='"+l+"'>"+s.zs.toFixed(2)+"</td></tr>"}$(i).innerHTML=a+n},gmHqreappear.addToZXGList=function(e,t){for(var i=0;i<e.length;i++)if(e[i].code==t.code){e[i].stock=t
break}},gmHqreappear.codeToTdxSymbol=function(e){return"0"==e.substr(0,1)||"3"==e.substr(0,1)?"0"+e:"1"+e},gmHqreappear.removeZXG=function(e){for(var t=0;t<gmHqreappear.zxgStocks.length;t++)if(gmHqreappear.zxgStocks[t].code==e){gmHqreappear.zxgStocks.splice(t,1)
break}for(var i="",t=0;t<gmHqreappear.zxgStocks.length;t++)i+=gmHqreappear.codeToTdxSymbol(gmHqreappear.zxgStocks[t].code)+"\r\n"
saveTextToFile(i,gZXGFile),gmHqreappear.updateMinute()},gmHqreappear.addZXG=function(){for(var e=gmHqreappear.stockCode,t=0;t<gmHqreappear.zxgStocks.length;t++)if(gmHqreappear.zxgStocks[t].code==e)return void iToasts.show("该股已在您的自选股中",!1)
gmHqreappear.zxgStocks.push({code:e})
for(var i="",t=0;t<gmHqreappear.zxgStocks.length;t++)i+=gmHqreappear.codeToTdxSymbol(gmHqreappear.zxgStocks[t].code)+"\r\n"
saveTextToFile(i,gZXGFile),iToasts.show("已加入自选股："+e,!1),gmHqreappear.updateMinute()},gmHqreappear.toggleSettings=function(){$("tssettingsWrapper").style.display="block"==$("tssettingsWrapper").style.display?"none":"block"},gmHqreappear.createLocalId=function(){var e="88:ec:a3:46:f9:6b"
window.localId=mycryp("m|"+e+"|m")},gmHqreappear.checkLocalId=function(){return gmHqreappear.minutesCount=4*gmHqreappear.perMin,!0},gmHqreappear.ddlog=function(){return!0},gmHqreappear.fixScroll=function(e,t,i){for(var a=document.getElementById(t),n=document.getElementById(e).cloneNode(!0),o=(n.rows.length,n.rows.length);o>i;o--)n.deleteRow(i)
var s=document.createElement("div")
a.appendChild(s),s.appendChild(n),s.style.position="absolute",s.style.backgroundColor="#cfc",s.style.display="block",s.style.left=0,s.style.top="0px",a.onscroll=function(){s.style.top=this.scrollTop+"px"}},gmHqreappear.setInvalidTips=function(e){$("snInvalidTips").innerHTML="本次通信密钥："+e},gmHqreappear.tsstockKLineOptionTemplate={backgroundColor:"#1e2327",animation:!1,title:{text:"Title",padding:[2,0,2,20],itemGap:0,textStyle:{color:"#fff",fontSize:12}},tooltip:{show:!1,trigger:"axis"},grid:{x:30,y:30,x2:20,y2:30,borderWidth:0},calculable:!1,xAxis:[{type:"category",boundaryGap:!1,splitLine:{show:!1},axisLine:{show:!1},axisLabel:{textStyle:{color:"#999"}},data:[]}],yAxis:[{type:"value",min:0,max:15,splitLine:{show:!1},axisLine:{show:!1},axisLabel:{show:!1}},{type:"value",min:0,max:600,splitLine:{show:!1},axisLine:{show:!1},axisLabel:{show:!1}}],series:[{name:"MA5",type:"line",symbol:"none",itemStyle:{normal:{lineStyle:{color:"white",width:1}}},data:[],markPoint:{clickable:!1,itemStyle:{normal:{color:"rgba(250,0,0,.5)",borderWidth:0,label:{}}},data:[]}},{name:"MA10",type:"line",symbol:"none",itemStyle:{normal:{lineStyle:{color:"yellow",width:1}}},data:[],markPoint:{clickable:!1,itemStyle:{normal:{color:"rgba(0,0,250,.5)",borderWidth:0,label:{}}},data:[]}},{name:"MA20",type:"line",symbol:"none",itemStyle:{normal:{lineStyle:{color:"pink",width:1}}},data:[]},{name:"价格",type:"k",data:[],symbol:"none",itemStyle:{normal:{color:"darkred",color0:"darkcyan",lineStyle:{width:2,color:"darkred",color0:"darkcyan"}},emphasis:{color:"black",color0:"white"}}},{name:"成交量",type:"bar",barMaxWidth:6,yAxisIndex:1,symbol:"none",itemStyle:{normal:{color:"#999"}},data:[]}]},gmHqreappear.initTicklineOption=function(){for(var e=deepCopy(gmHqreappear.tsstockTicklineOptionTemplate),t=new Date((new Date).Format("yyyy/MM/dd")+" 09:30:00"),i=0;240>i;i++)e.xAxis[0].data[i]=t.Format("hh:mm"),"11:29"==e.xAxis[0].data[i]&&t.addMinutes(90),t.addMinutes(1)
return e},gmHqreappear.tsstockTicklineOptionTemplate={backgroundColor:"#1e2327",animation:!1,title:{text:"Title",padding:[2,0,2,40],itemGap:0,textStyle:{color:"#fff",fontSize:12}},tooltip:{show:!1,trigger:"axis"},grid:{x:50,y:30,x2:50,y2:30,borderWidth:0},calculable:!1,xAxis:[{type:"category",boundaryGap:!1,splitLine:{show:!1},splitArea:{show:!0},axisLine:{show:!1},axisLabel:{textStyle:{color:"#999"},interval:29},data:[]}],yAxis:[{type:"value",min:0,max:15,splitLine:{show:!1},axisLine:{show:!1},axisLabel:{show:!1}},{type:"value",min:0,max:600,splitLine:{show:!1},axisLine:{show:!1},axisLabel:{show:!1}}],series:[{name:"price",type:"line",symbol:"none",itemStyle:{normal:{lineStyle:{color:"white",width:1}}},data:[],markPoint:{clickable:!1,itemStyle:{normal:{color:"rgba(250,0,0,.5)",borderWidth:0,label:{}}},data:[]},markLine:{symbolSize:0,clickable:!1,itemStyle:{normal:{color:"#999",lineStyle:{color:"rgba(50,50,50,.5",width:1,type:"dashed"},label:{formatter:function(e,t,i){return console.log(e.data),e.data.label}}}},data:[]}},{name:"avgPrice",type:"line",symbol:"none",itemStyle:{normal:{lineStyle:{color:"yellow",width:1}}},data:[],markPoint:{clickable:!1,itemStyle:{normal:{color:"rgba(0,0,250,.5)",borderWidth:0,label:{}}},data:[]},markLine:{symbolSize:0,clickable:!1,itemStyle:{normal:{color:"#fff",lineStyle:{color:"#1e2327",width:1,type:"solid"},label:{formatter:function(e,t,i){return console.log(e.data),e.data.label}}}},data:[]}},{name:"成交量",type:"bar",barMaxWidth:2,yAxisIndex:1,symbol:"none",itemStyle:{normal:{color:"#999"}},data:[],markLine:{symbolSize:0,clickable:!1,itemStyle:{normal:{color:"#ccc",lineStyle:{color:"#1e2327",width:1,type:"solid"},label:{formatter:function(e,t,i){return console.log(e.data),e.data.label}}}},data:[]}}]},function(e){"use strict"
var t="jsMind",i="0.4a",a="hizzgdev@163.com",n=function(){},o="undefined"==typeof console?{log:n,debug:n,error:n,warn:n,info:n}:console
if(void 0===e[t]){var s=e.document,r=function(e){return s.getElementById(e)},l=function(e){return s.createElement(e)},d=function(e,t){e.hasChildNodes()?e.firstChild.nodeValue=t:e.appendChild(s.createTextNode(t))},c=function(e,t){e.innerHTML=t}
"function"!=typeof String.prototype.startsWith&&(String.prototype.startsWith=function(e){return this.slice(0,e.length)===e})
var g={container:"",editable:!1,theme:null,mode:"full",support_html:!0,view:{hmargin:100,vmargin:50,line_width:2,line_color:"#555"},layout:{hspace:30,vspace:20,pspace:13},default_event_handle:{enable_mousedown_handle:!0,enable_click_handle:!0,enable_dblclick_handle:!0},shortcut:{enable:!0,handles:{},mapping:{addchild:45,addbrother:13,editnode:113,delnode:46,toggle:32,left:37,up:38,right:39,down:40}}},u=function(e){u.current=this,this.version=i
var t={}
u.util.json.merge(t,g),u.util.json.merge(t,e),null!=t.container&&0!=t.container.length&&(this.options=t,this.inited=!1,this.mind=null,this.event_handles=[],this.init())}
u.direction={left:-1,center:0,right:1},u.event_type={show:1,resize:2,edit:3,select:4},u.node=function(e,t,i,a,n,s,r,l){return e?"number"!=typeof t?void o.error("invalid node index"):(void 0===l&&(l=!0),this.id=e,this.index=t,this.topic=i,this.data=a||{},this.isroot=n,this.parent=s,this.direction=r,this.expanded=!!l,this.children=[],void(this._data={})):void o.error("invalid nodeid")},u.node.compare=function(e,t){var i=0,a=e.index,n=t.index
return i=a>=0&&n>=0?a-n:-1==a&&-1==n?0:-1==a?1:-1==n?-1:0},u.node.inherited=function(e,t){if(e&&t){if(e.id===t.id)return!0
if(e.isroot)return!0
for(var i=e.id,a=t;!a.isroot;)if(a=a.parent,a.id===i)return!0}return!1},u.node.prototype={get_location:function(){var e=this._data.view
return{x:e.abs_x,y:e.abs_y}},get_size:function(){var e=this._data.view
return{w:e.width,h:e.height}}},u.mind=function(){this.name=null,this.author=null,this.version=null,this.root=null,this.selected=null,this.nodes={}},u.mind.prototype={get_node:function(e){return e in this.nodes?this.nodes[e]:null},set_root:function(e,t,i){null==this.root&&(this.root=new u.node(e,0,t,i,!0),this._put_node(this.root))},add_node:function(e,t,i,a,n,s,r){if(!u.util.is_node(e))return this.add_node(this.get_node(e),t,i,a,n,s,r)
var l=n||-1
if(e){var d=null
if(e.isroot){var c=u.direction.right
if(isNaN(s)){for(var g=e.children,h=g.length,m=0,p=0;h>p;p++)g[p].direction===u.direction.left?m--:m++
c=h>1&&m>0?u.direction.left:u.direction.right}else c=s!=u.direction.left?u.direction.right:u.direction.left
d=new u.node(t,l,i,a,!1,e,c,r)}else d=new u.node(t,l,i,a,!1,e,e.direction,r)
return this._put_node(d)?(e.children.push(d),this._reindex(e)):(o.error("fail, the nodeid '"+d.id+"' has been already exist."),d=null),d}return o.error("fail, the [node_parent] can not be found."),null},insert_node_before:function(e,t,i,a){if(!u.util.is_node(e))return this.insert_node_before(this.get_node(e),t,i,a)
if(e){var n=e.index-.5
return this.add_node(e.parent,t,i,a,n)}return o.error("fail, the [node_before] can not be found."),null},get_node_before:function(e){if(!e)return null
if(!u.util.is_node(e))return this.get_node_before(this.get_node(e))
if(e.isroot)return null
var t=e.index-2
return t>=0?e.parent.children[t]:null},insert_node_after:function(e,t,i,a){if(!u.util.is_node(e))return this.insert_node_after(this.get_node(e),t,i,a)
if(e){var n=e.index+.5
return this.add_node(e.parent,t,i,a,n)}return o.error("fail, the [node_after] can not be found."),null},get_node_after:function(e){if(!e)return null
if(!u.util.is_node(e))return this.get_node_after(this.get_node(e))
if(e.isroot)return null
var t=e.index,i=e.parent.children
return i.length>=t?e.parent.children[t]:null},move_node:function(e,t,i,a){return u.util.is_node(e)?(i||(i=e.parent.id),this._move_node(e,t,i,a)):this.move_node(this.get_node(e),t,i,a)},_flow_node_direction:function(e,t){void 0===t?t=e.direction:e.direction=t
for(var i=e.children.length;i--;)this._flow_node_direction(e.children[i],t)},_move_node_internal:function(e,t){if(e&&t)if("_last_"==t)e.index=-1,this._reindex(e.parent)
else if("_first_"==t)e.index=0,this._reindex(e.parent)
else{var i=t?this.get_node(t):null
null!=i&&null!=i.parent&&i.parent.id==e.parent.id&&(e.index=i.index-.5,this._reindex(e.parent))}return e},_move_node:function(e,t,i,a){if(e&&i){if(e.parent.id!=i){for(var n=e.parent.children,o=n.length;o--;)if(n[o].id==e.id){n.splice(o,1)
break}e.parent=this.get_node(i),e.parent.children.push(e)}e.parent.isroot?a==jsMind.direction.left?e.direction=a:e.direction=u.direction.right:e.direction=e.parent.direction,this._move_node_internal(e,t),this._flow_node_direction(e)}return e},remove_node:function(e){if(!u.util.is_node(e))return this.remove_node(this.get_node(e))
if(!e)return o.error("fail, the node can not be found"),!1
if(e.isroot)return o.error("fail, can not remove root node"),!1
null!=this.selected&&this.selected.id==e.id&&(this.selected=null)
for(var t=e.children,i=t.length;i--;)this.remove_node(t[i])
t.length=0
for(var a=e.parent.children,n=a.length;n--;)if(a[n].id==e.id){a.splice(n,1)
break}delete this.nodes[e.id]
for(var s in e)delete e[s]
return e=null,!0},_put_node:function(e){return e.id in this.nodes?!1:(this.nodes[e.id]=e,!0)},_reindex:function(e){if(e instanceof u.node){e.children.sort(u.node.compare)
for(var t=0;t<e.children.length;t++)e.children[t].index=t+1}}},u.format={node_tree:{example:{meta:{name:t,author:a,version:i},format:"node_tree",data:{id:"root",topic:"jsMind Example"}},get_mind:function(e){var t=u.format.node_tree,i=new u.mind
return i.name=e.meta.name,i.author=e.meta.author,i.version=e.meta.version,t._parse(i,e.data),i},get_data:function(e){var t=u.format.node_tree,i={}
return i.meta={name:e.name,author:e.author,version:e.version},i.format="node_tree",i.data=t._buildnode(e.root),i},_parse:function(e,t){var i=u.format.node_tree,a=i._extract_data(t)
if(e.set_root(t.id,t.topic,a),"children"in t)for(var n=t.children,o=0;o<n.length;o++)i._extract_subnode(e,e.root,n[o])},_extract_data:function(e){var t={}
for(var i in e)"id"!=i&&"topic"!=i&&"children"!=i&&"direction"!=i&&"expanded"!=i&&(t[i]=e[i])
return t},_extract_subnode:function(e,t,i){var a=u.format.node_tree,n=a._extract_data(i),o=null
t.isroot&&(o="left"==i.direction?u.direction.left:u.direction.right)
var s=e.add_node(t,i.id,i.topic,n,null,o,i.expanded)
if("children"in i)for(var r=i.children,l=0;l<r.length;l++)a._extract_subnode(e,s,r[l])},_buildnode:function(e){var t=u.format.node_tree
if(e instanceof u.node){var i={id:e.id,topic:e.topic,expanded:e.expanded}
if(e.parent&&e.parent.isroot&&(i.direction=e.direction==u.direction.left?"left":"right"),null!=e.data){var a=e.data
for(var n in a)i[n]=a[n]}var o=e.children
if(o.length>0){i.children=[]
for(var s=0;s<o.length;s++)i.children.push(t._buildnode(o[s]))}return i}}},node_array:{example:{meta:{name:t,author:a,version:i},format:"node_array",data:[{id:"root",topic:"jsMind Example",isroot:!0}]},get_mind:function(e){var t=u.format.node_array,i=new u.mind
return i.name=e.meta.name,i.author=e.meta.author,i.version=e.meta.version,t._parse(i,e.data),i},get_data:function(e){var t=u.format.node_array,i={}
return i.meta={name:e.name,author:e.author,version:e.version},i.format="node_array",i.data=[],t._array(e,i.data),i},_parse:function(e,t){var i=u.format.node_array,a=t.slice(0)
a.reverse()
var n=i._extract_root(e,a)
n?i._extract_subnode(e,n,a):o.error("root node can not be found")},_extract_root:function(e,t){for(var i=u.format.node_array,a=t.length;a--;)if("isroot"in t[a]&&t[a].isroot){var n=t[a],o=i._extract_data(n)
return e.set_root(n.id,n.topic,o),t.splice(a,1),n.id}return null},_extract_subnode:function(e,t,i){for(var a=u.format.node_array,n=i.length,o=null,s=null,r=0;n--;)if(o=i[n],o.parentid==t){s=a._extract_data(o)
var l=null,d=o.direction
d&&(l="left"==d?u.direction.left:u.direction.right),e.add_node(t,o.id,o.topic,s,null,l,o.expanded),i.splice(n,1),r++
var c=a._extract_subnode(e,o.id,i)
c>0&&(n=i.length,r+=c)}return r},_extract_data:function(e){var t={}
for(var i in e)"id"!=i&&"topic"!=i&&"parentid"!=i&&"isroot"!=i&&"direction"!=i&&"expanded"!=i&&(t[i]=e[i])
return t},_array:function(e,t){var i=u.format.node_array
i._array_node(e.root,t)},_array_node:function(e,t){var i=u.format.node_array
if(e instanceof u.node){var a={id:e.id,topic:e.topic,expanded:e.expanded}
if(e.parent&&(a.parentid=e.parent.id),e.isroot&&(a.isroot=!0),e.parent&&e.parent.isroot&&(a.direction=e.direction==u.direction.left?"left":"right"),null!=e.data){var n=e.data
for(var o in n)a[o]=n[o]}t.push(a)
for(var s=e.children.length,r=0;s>r;r++)i._array_node(e.children[r],t)}}},freemind:{example:{meta:{name:t,author:a,version:i},format:"freemind",data:'<map version="1.0.1"><node ID="root" TEXT="freemind Example"/></map>'},get_mind:function(e){var t=u.format.freemind,i=new u.mind
i.name=e.meta.name,i.author=e.meta.author,i.version=e.meta.version
var a=e.data,n=t._parse_xml(a),o=t._find_root(n)
return t._load_node(i,null,o),i},get_data:function(e){var t=u.format.freemind,i={}
i.meta={name:e.name,author:e.author,version:e.version},i.format="freemind"
var a=[]
return a.push('<map version="1.0.1">'),t._buildmap(e.root,a),a.push("</map>"),i.data=a.join(" "),i},_parse_xml:function(e){var t=null
if(window.DOMParser){var i=new DOMParser
t=i.parseFromString(e,"text/xml")}else t=new ActiveXObject("Microsoft.XMLDOM"),t.async=!1,t.loadXML(e)
return t},_find_root:function(e){for(var t=e.childNodes,i=null,a=null,n=0;n<t.length;n++)if(a=t[n],1==a.nodeType&&"map"==a.tagName){i=a
break}if(i){var o=i.childNodes
i=null
for(var n=0;n<o.length;n++)if(a=o[n],1==a.nodeType&&"node"==a.tagName){i=a
break}}return i},_load_node:function(e,t,i){var a=u.format.freemind,n=i.getAttribute("ID"),o=i.getAttribute("TEXT")
if(null==o)for(var s=i.childNodes,r=null,l=0;l<s.length;l++)if(r=s[l],1==r.nodeType&&"richcontent"===r.tagName){o=r.textContent
break}var d=a._load_attributes(i),c="expanded"in d?"true"==d.expanded:!0
delete d.expanded
var g=i.getAttribute("POSITION"),h=null
g&&(h="left"==g?u.direction.left:u.direction.right),t?e.add_node(t,n,o,d,null,h,c):e.set_root(n,o,d)
for(var m=i.childNodes,p=null,l=0;l<m.length;l++)p=m[l],1==p.nodeType&&"node"==p.tagName&&a._load_node(e,n,p)},_load_attributes:function(e){for(var t=e.childNodes,i=null,a={},n=0;n<t.length;n++)i=t[n],1==i.nodeType&&"attribute"===i.tagName&&(a[i.getAttribute("NAME")]=i.getAttribute("VALUE"))
return a},_buildmap:function(e,t){var i=u.format.freemind,a=null
e.parent&&e.parent.isroot&&(a=e.direction===u.direction.left?"left":"right"),t.push("<node"),t.push('ID="'+e.id+'"'),a&&t.push('POSITION="'+a+'"'),t.push('TEXT="'+e.topic+'">'),t.push('<attribute NAME="expanded" VALUE="'+e.expanded+'"/>')
var n=e.data
if(null!=n)for(var o in n)t.push('<attribute NAME="'+o+'" VALUE="'+n[o]+'"/>')
for(var s=e.children,r=0;r<s.length;r++)i._buildmap(s[r],t)
t.push("</node>")}}},u.util={is_node:function(e){return e instanceof u.node},ajax:{_xhr:function(){var e=null
if(window.XMLHttpRequest)e=new XMLHttpRequest
else try{e=new ActiveXObject("Microsoft.XMLHTTP")}catch(t){}return e},_eurl:function(e){return encodeURIComponent(e)},request:function(e,t,i,a,n){var s=u.util.ajax,r=null,l=[]
for(k in t)l.push(s._eurl(k)+"="+s._eurl(t[k]))
l.length>0&&(r=l.join("&"))
var d=s._xhr()
d&&(d.onreadystatechange=function(){if(4==d.readyState)if(200==d.status||0==d.status){if("function"==typeof a){var e=u.util.json.string2json(d.responseText)
a(null!=e?e:d.responseText)}}else"function"==typeof n?n(d):o.error("xhr request failed.",d)},i=i||"GET",d.open(i,e,!0),d.setRequestHeader("If-Modified-Since","0"),"POST"==i?(d.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=utf-8"),d.send(r)):d.send())},get:function(e,t){return u.util.ajax.request(e,{},"GET",t)},post:function(e,t,i){return u.util.ajax.request(e,t,"POST",i)}},dom:{add_event:function(e,t,i){e.addEventListener?e.addEventListener(t,i,!1):e.attachEvent("on"+t,i)}},canvas:{bezierto:function(e,t,i,a,n){e.beginPath(),e.moveTo(t,i),e.bezierCurveTo(t+2*(a-t)/3,i,t,n,a,n),e.stroke()},lineto:function(e,t,i,a,n){e.beginPath(),e.moveTo(t,i),e.lineTo(a,n),e.stroke()},clear:function(e,t,i,a,n){e.clearRect(t,i,a,n)}},file:{read:function(e,t){var i=new FileReader
i.onload=function(){"function"==typeof t&&t(this.result,e.name)},i.readAsText(e)},save:function(t,i,a){var n
if("function"==typeof e.Blob)n=new Blob([t],{type:i})
else{var o=e.BlobBuilder||e.MozBlobBuilder||e.WebKitBlobBuilder||e.MSBlobBuilder,r=new o
r.append(t),n=r.getBlob(i)}if(navigator.msSaveBlob)navigator.msSaveBlob(n,a)
else{var d=e.URL||e.webkitURL,c=d.createObjectURL(n),g=l("a")
if("download"in g){g.style.visibility="hidden",g.href=c,g.download=a,s.body.appendChild(g)
var u=s.createEvent("MouseEvents")
u.initEvent("click",!0,!0),g.dispatchEvent(u),s.body.removeChild(g)}else location.href=c}}},json:{json2string:function(e){if(JSON)try{var t=JSON.stringify(e)
return t}catch(i){return null}},string2json:function(e){if(JSON)try{var t=JSON.parse(e)
return t}catch(i){return null}},merge:function(e,t){for(var i in t)i in e?"object"!=typeof e[i]||"[object object]"!=Object.prototype.toString.call(e[i]).toLowerCase()||e[i].length?e[i]=t[i]:u.util.json.merge(e[i],t[i]):e[i]=t[i]
return e}},uuid:{newid:function(){return((new Date).getTime().toString(16)+Math.random().toString(16).substr(2)).substr(2,16)}},text:{is_empty:function(e){return e?0==e.replace(/\s*/,"").length:!0}}},u.prototype={init:function(){if(!this.inited){this.inited=!0
var e=this.options,t={mode:e.mode,hspace:e.layout.hspace,vspace:e.layout.vspace,pspace:e.layout.pspace},i={container:e.container,support_html:e.support_html,hmargin:e.view.hmargin,vmargin:e.view.vmargin,line_width:e.view.line_width,line_color:e.view.line_color}
this.data=new u.data_provider(this),this.layout=new u.layout_provider(this,t),this.view=new u.view_provider(this,i),this.shortcut=new u.shortcut_provider(this,e.shortcut),this.data.init(),this.layout.init(),this.view.init(),this.shortcut.init(),this._event_bind(),u.init_plugins(this)}},enable_edit:function(){this.options.editable=!0},disable_edit:function(){this.options.editable=!1},enable_event_handle:function(e){this.options.default_event_handle["enable_"+e+"_handle"]=!0},disable_event_handle:function(e){this.options.default_event_handle["enable_"+e+"_handle"]=!1},get_editable:function(){return this.options.editable},set_theme:function(e){var t=this.options.theme
this.options.theme=e?e:null,t!=this.options.theme&&(this.view.reset_theme(),this.view.reset_custom_style())},_event_bind:function(){this.view.add_event(this,"mousedown",this.mousedown_handle),this.view.add_event(this,"click",this.click_handle),this.view.add_event(this,"dblclick",this.dblclick_handle)},mousedown_handle:function(e){if(this.options.default_event_handle.enable_mousedown_handle){var t=e.target||event.srcElement,i=this.view.get_binded_nodeid(t)
i?this.select_node(i):this.select_clear()}},click_handle:function(e){if(this.options.default_event_handle.enable_click_handle){var t=e.target||event.srcElement,i=this.view.is_expander(t)
if(i){var a=this.view.get_binded_nodeid(t)
a&&this.toggle_node(a)}}},dblclick_handle:function(e){if(this.options.default_event_handle.enable_dblclick_handle&&this.get_editable()){var t=e.target||event.srcElement,i=this.view.get_binded_nodeid(t)
i&&this.begin_edit(i)}},begin_edit:function(e){return u.util.is_node(e)?this.get_editable()?void(e?this.view.edit_node_begin(e):o.error("the node can not be found")):void o.error("fail, this mind map is not editable."):this.begin_edit(this.get_node(e))},end_edit:function(){this.view.edit_node_end()},toggle_node:function(e){if(!u.util.is_node(e))return this.toggle_node(this.get_node(e))
if(e){if(e.isroot)return
this.view.save_location(e),this.layout.toggle_node(e),this.view.relayout(),this.view.restore_location(e)}else o.error("the node can not be found.")},expand_node:function(e){if(!u.util.is_node(e))return this.expand_node(this.get_node(e))
if(e){if(e.isroot)return
this.view.save_location(e),this.layout.expand_node(e),this.view.relayout(),this.view.restore_location(e)}else o.error("the node can not be found.")},collapse_node:function(e){if(!u.util.is_node(e))return this.collapse_node(this.get_node(e))
if(e){if(e.isroot)return
this.view.save_location(e),this.layout.collapse_node(e),this.view.relayout(),this.view.restore_location(e)}else o.error("the node can not be found.")},expand_all:function(){this.layout.expand_all(),this.view.relayout()},collapse_all:function(){this.layout.collapse_all(),this.view.relayout()},expand_to_depth:function(e){this.layout.expand_to_depth(e),this.view.relayout()},_reset:function(){this.view.reset(),this.layout.reset(),this.data.reset()},_show:function(e){var t=e||u.format.node_array.example
return this.mind=this.data.load(t),this.mind?(o.debug("data.load ok"),this.view.load(),o.debug("view.load ok"),this.layout.layout(),o.debug("layout.layout ok"),this.view.show(!0),o.debug("view.show ok"),void this.invoke_event_handle(u.event_type.show,{data:[e]})):void o.error("data.load error")},show:function(e){this._reset(),this._show(e)},get_meta:function(){return{name:this.mind.name,author:this.mind.author,version:this.mind.version}},get_data:function(e){var t=e||"node_tree"
return this.data.get_data(t)},get_root:function(){return this.mind.root},get_node:function(e){return this.mind.get_node(e)},add_node:function(e,t,i,a){if(this.get_editable()){var n=this.mind.add_node(e,t,i,a)
return n&&(this.view.add_node(n),this.layout.layout(),this.view.show(!1),this.view.reset_node_custom_style(n),this.expand_node(e),this.invoke_event_handle(u.event_type.edit,{evt:"add_node",data:[e.id,t,i,a],node:t})),n}return o.error("fail, this mind map is not editable"),null},insert_node_before:function(e,t,i,a){if(this.get_editable()){var n=u.util.is_node(e)?e.id:e,s=this.mind.insert_node_before(e,t,i,a)
return s&&(this.view.add_node(s),this.layout.layout(),this.view.show(!1),this.invoke_event_handle(u.event_type.edit,{evt:"insert_node_before",data:[n,t,i,a],node:t})),s}return o.error("fail, this mind map is not editable"),null},insert_node_after:function(e,t,i,a){if(this.get_editable()){var n=this.mind.insert_node_after(e,t,i,a)
return n&&(this.view.add_node(n),this.layout.layout(),this.view.show(!1),this.invoke_event_handle(u.event_type.edit,{evt:"insert_node_after",data:[e.id,t,i,a],node:t})),n}return o.error("fail, this mind map is not editable"),null},remove_node:function(e){if(!u.util.is_node(e))return this.remove_node(this.get_node(e))
if(!this.get_editable())return void o.error("fail, this mind map is not editable")
if(!e)return o.error("fail, node can not be found"),!1
if(e.isroot)return o.error("fail, can not remove root node"),!1
var t=e.id,i=e.parent.id,a=this.get_node(i)
this.view.save_location(a),this.view.remove_node(e),this.mind.remove_node(e),this.layout.layout(),this.view.show(!1),this.view.restore_location(a),this.invoke_event_handle(u.event_type.edit,{evt:"remove_node",data:[t],node:i})},update_node:function(e,t){if(!this.get_editable())return void o.error("fail, this mind map is not editable")
if(!u.util.text.is_empty(t)){var i=this.get_node(e)
if(i){if(i.topic===t)return o.info("nothing changed"),void this.view.update_node(i)
i.topic=t,this.view.update_node(i),this.layout.layout(),this.view.show(!1),this.invoke_event_handle(u.event_type.edit,{evt:"update_node",data:[e,t],node:e})}}},move_node:function(e,t,i,a){if(!this.get_editable())return void o.error("fail, this mind map is not editable")
var n=this.mind.move_node(e,t,i,a)
n&&(this.view.update_node(n),this.layout.layout(),this.view.show(!1),this.invoke_event_handle(u.event_type.edit,{evt:"move_node",data:[e,t,i,a],node:e}))},select_node:function(e){return u.util.is_node(e)?void(e&&this.layout.is_visible(e)&&(this.mind.selected=e,e&&this.view.select_node(e))):this.select_node(this.get_node(e))},get_selected_node:function(){return this.mind?this.mind.selected:null},select_clear:function(){this.mind&&(this.mind.selected=null,this.view.select_clear())},is_node_visible:function(e){return this.layout.is_visible(e)},find_node_before:function(e){if(!u.util.is_node(e))return this.find_node_before(this.get_node(e))
if(!e||e.isroot)return null
var t=null
if(e.parent.isroot)for(var i=e.parent.children,a=null,n=null,o=0;o<i.length;o++)n=i[o],e.direction===n.direction&&(e.id===n.id&&(t=a),a=n)
else t=this.mind.get_node_before(e)
return t},find_node_after:function(e){if(!u.util.is_node(e))return this.find_node_after(this.get_node(e))
if(!e||e.isroot)return null
var t=null
if(e.parent.isroot){for(var i=e.parent.children,a=!1,n=null,o=0;o<i.length;o++)if(n=i[o],e.direction===n.direction){if(a){t=n
break}e.id===n.id&&(a=!0)}}else t=this.mind.get_node_after(e)
return t},set_node_color:function(e,t,i){if(!this.get_editable())return o.error("fail, this mind map is not editable"),null
var a=this.mind.get_node(e)
a&&(t&&(a.data["background-color"]=t),i&&(a.data["foreground-color"]=i),this.view.reset_node_custom_style(a))},set_node_font_style:function(e,t,i,a){if(!this.get_editable())return o.error("fail, this mind map is not editable"),null
var n=this.mind.get_node(e)
n&&(t&&(n.data["font-size"]=t),i&&(n.data["font-weight"]=i),a&&(n.data["font-style"]=a),this.view.reset_node_custom_style(n),this.view.update_node(n),this.layout.layout(),this.view.show(!1))},set_node_background_image:function(e,t,i,a,n){if(!this.get_editable())return o.error("fail, this mind map is not editable"),null
var s=this.mind.get_node(e)
s&&(t&&(s.data["background-image"]=t),i&&(s.data.width=i),a&&(s.data.height=a),n&&(s.data["background-rotation"]=n),this.view.reset_node_custom_style(s),this.view.update_node(s),this.layout.layout(),this.view.show(!1))},set_node_background_rotation:function(e,t){if(!this.get_editable())return o.error("fail, this mind map is not editable"),null
var i=this.mind.get_node(e)
if(i){if(!i.data["background-image"])return o.error("fail, only can change rotation angle of node with background image"),null
i.data["background-rotation"]=t,this.view.reset_node_custom_style(i),this.view.update_node(i),this.layout.layout(),this.view.show(!1)}},resize:function(){this.view.resize()},add_event_listener:function(e){"function"==typeof e&&this.event_handles.push(e)},invoke_event_handle:function(t,i){var a=this
e.setTimeout(function(){a._invoke_event_handle(t,i)},0)},_invoke_event_handle:function(e,t){for(var i=this.event_handles.length,a=0;i>a;a++)this.event_handles[a](e,t)}},u.data_provider=function(e){this.jm=e},u.data_provider.prototype={init:function(){o.debug("data.init")},reset:function(){o.debug("data.reset")},load:function(e){var t=null,i=null
return t="object"==typeof e?e.format?e.format:"node_tree":"freemind","node_array"==t?i=u.format.node_array.get_mind(e):"node_tree"==t?i=u.format.node_tree.get_mind(e):"freemind"==t&&(i=u.format.freemind.get_mind(e)),i},get_data:function(e){var t=null
return"node_array"==e?t=u.format.node_array.get_data(this.jm.mind):"node_tree"==e?t=u.format.node_tree.get_data(this.jm.mind):"freemind"==e?t=u.format.freemind.get_data(this.jm.mind):o.error("unsupported "+e+" format"),t}},u.layout_provider=function(e,t){this.opts=t,this.jm=e,this.isside="side"==this.opts.mode,this.bounds=null,this.cache_valid=!1},u.layout_provider.prototype={init:function(){o.debug("layout.init")},reset:function(){o.debug("layout.reset"),this.bounds={n:0,s:0,w:0,e:0}},layout:function(){o.debug("layout.layout"),this.layout_direction(),this.layout_offset()},layout_direction:function(){this._layout_direction_root()},_layout_direction_root:function(){var e=this.jm.mind.root,t=null
"layout"in e._data?t=e._data.layout:(t={},e._data.layout=t)
var i=e.children,a=i.length
if(t.direction=u.direction.center,t.side_index=0,this.isside)for(var n=a;n--;)this._layout_direction_side(i[n],u.direction.right,n)
else for(var n=a,o=null;n--;)o=i[n],o.direction==u.direction.left?this._layout_direction_side(o,u.direction.left,n):this._layout_direction_side(o,u.direction.right,n)},_layout_direction_side:function(e,t,i){var a=null
"layout"in e._data?a=e._data.layout:(a={},e._data.layout=a)
var n=e.children,o=n.length
a.direction=t,a.side_index=i
for(var s=o;s--;)this._layout_direction_side(n[s],t,s)},layout_offset:function(){var e=this.jm.mind.root,t=e._data.layout
t.offset_x=0,t.offset_y=0,t.outer_height=0
for(var i=e.children,a=i.length,n=[],o=[],s=null;a--;)s=i[a],s._data.layout.direction==u.direction.right?o.unshift(s):n.unshift(s)
t.left_nodes=n,t.right_nodes=o,t.outer_height_left=this._layout_offset_subnodes(n),t.outer_height_right=this._layout_offset_subnodes(o),this.bounds.e=e._data.view.width/2,this.bounds.w=0-this.bounds.e,this.bounds.n=0,this.bounds.s=Math.max(t.outer_height_left,t.outer_height_right)},_layout_offset_subnodes:function(e){for(var t=0,i=e.length,a=i,n=null,o=0,s=null,r=0,l=null;a--;)n=e[a],s=n._data.layout,null==l&&(l=n.parent._data),o=this._layout_offset_subnodes(n.children),n.expanded||(o=0,this.set_visible(n.children,!1)),o=Math.max(n._data.view.height,o),s.outer_height=o,s.offset_y=r-o/2,s.offset_x=this.opts.hspace*s.direction+l.view.width*(l.layout.direction+s.direction)/2,n.parent.isroot||(s.offset_x+=this.opts.pspace*s.direction),r=r-o-this.opts.vspace,t+=o
i>1&&(t+=this.opts.vspace*(i-1)),a=i
for(var d=t/2;a--;)n=e[a],n._data.layout.offset_y+=d
return t},_layout_offset_subnodes_height:function(e){for(var t=0,i=e.length,a=i,n=null,o=0,s=null,r=0,l=null;a--;)n=e[a],s=n._data.layout,null==l&&(l=n.parent._data),o=this._layout_offset_subnodes_height(n.children),n.expanded||(o=0),o=Math.max(n._data.view.height,o),s.outer_height=o,s.offset_y=r-o/2,r=r-o-this.opts.vspace,t+=o
i>1&&(t+=this.opts.vspace*(i-1)),a=i
for(var d=t/2;a--;)n=e[a],n._data.layout.offset_y+=d
return t},get_node_offset:function(e){var t=e._data.layout,i=null
if("_offset_"in t&&this.cache_valid?i=t._offset_:(i={x:-1,y:-1},t._offset_=i),-1==i.x||-1==i.y){var a=t.offset_x,n=t.offset_y
if(!e.isroot){var o=this.get_node_offset(e.parent)
a+=o.x,n+=o.y}i.x=a,i.y=n}return i},get_node_point:function(e){var t=e._data.view,i=this.get_node_offset(e),a={}
return a.x=i.x+t.width*(e._data.layout.direction-1)/2,a.y=i.y-t.height/2,a},get_node_point_in:function(e){var t=this.get_node_offset(e)
return t},get_node_point_out:function(e){var t=e._data.layout,i=null
if("_pout_"in t&&this.cache_valid?i=t._pout_:(i={x:-1,y:-1},t._pout_=i),-1==i.x||-1==i.y)if(e.isroot)i.x=0,i.y=0
else{var a=e._data.view,n=this.get_node_offset(e)
i.x=n.x+(a.width+this.opts.pspace)*e._data.layout.direction,i.y=n.y}return i},get_expander_point:function(e){var t=this.get_node_point_out(e),i={}
return e._data.layout.direction==u.direction.right?i.x=t.x-this.opts.pspace:i.x=t.x,i.y=t.y-Math.ceil(this.opts.pspace/2),i},get_min_size:function(){var e=this.jm.mind.nodes,t=null,i=null
for(var a in e)t=e[a],i=this.get_node_point_out(t),i.x>this.bounds.e&&(this.bounds.e=i.x),i.x<this.bounds.w&&(this.bounds.w=i.x)
return{w:this.bounds.e-this.bounds.w,h:this.bounds.s-this.bounds.n}},toggle_node:function(e){e.isroot||(e.expanded?this.collapse_node(e):this.expand_node(e))},expand_node:function(e){e.expanded=!0,this.part_layout(e),this.set_visible(e.children,!0)},collapse_node:function(e){e.expanded=!1,this.part_layout(e),this.set_visible(e.children,!1)},expand_all:function(){var e,t=this.jm.mind.nodes,i=0
for(var a in t)e=t[a],e.expanded||(e.expanded=!0,i++)
if(i>0){var n=this.jm.mind.root
this.part_layout(n),this.set_visible(n.children,!0)}},collapse_all:function(){var e,t=this.jm.mind.nodes,i=0
for(var a in t)e=t[a],e.expanded&&!e.isroot&&(e.expanded=!1,i++)
if(i>0){var n=this.jm.mind.root
this.part_layout(n),this.set_visible(n.children,!0)}},expand_to_depth:function(e,t,i){if(!(1>e))for(var a=t||this.jm.mind.root.children,n=i||1,o=a.length,s=null;o--;)s=a[o],e>n&&(s.expanded||this.expand_node(s),this.expand_to_depth(e,s.children,n+1)),n==e&&s.expanded&&this.collapse_node(s)},part_layout:function(e){var t=this.jm.mind.root
if(t){var i=t._data.layout
e.isroot?(i.outer_height_right=this._layout_offset_subnodes_height(i.right_nodes),i.outer_height_left=this._layout_offset_subnodes_height(i.left_nodes)):e._data.layout.direction==u.direction.right?i.outer_height_right=this._layout_offset_subnodes_height(i.right_nodes):i.outer_height_left=this._layout_offset_subnodes_height(i.left_nodes),this.bounds.s=Math.max(i.outer_height_left,i.outer_height_right),this.cache_valid=!1}},set_visible:function(e,t){for(var i=e.length,a=null,n=null;i--;)a=e[i],n=a._data.layout,a.expanded?this.set_visible(a.children,t):this.set_visible(a.children,!1),a.isroot||(a._data.layout.visible=t)},is_expand:function(e){return e.expanded},is_visible:function(e){var t=e._data.layout
return"visible"in t&&!t.visible?!1:!0}},u.view_provider=function(e,t){this.opts=t,this.jm=e,this.layout=e.layout,this.container=null,this.e_panel=null,this.e_nodes=null,this.e_canvas=null,this.canvas_ctx=null,this.size={w:0,h:0},this.selected_node=null,this.editing_node=null},u.view_provider.prototype={init:function(){if(o.debug("view.init"),this.container=r(this.opts.container),!this.container)return void o.error("the options.view.container was not be found in dom")
this.e_panel=l("div"),this.e_canvas=l("canvas"),this.e_nodes=l("jmnodes"),this.e_editor=l("input"),this.e_panel.className="jsmind-inner",this.e_panel.appendChild(this.e_canvas),this.e_panel.appendChild(this.e_nodes),this.e_editor.className="jsmind-editor",this.e_editor.type="text",this.actualZoom=1,this.zoomStep=.1,this.minZoom=.5,this.maxZoom=2
var e=this
u.util.dom.add_event(this.e_editor,"keydown",function(t){var i=t||event
13==i.keyCode&&(e.edit_node_end(),i.stopPropagation())}),u.util.dom.add_event(this.e_editor,"blur",function(t){e.edit_node_end()}),this.container.appendChild(this.e_panel),this.init_canvas()},add_event:function(e,t,i){u.util.dom.add_event(this.e_nodes,t,function(t){var a=t||event
i.call(e,a)})},get_binded_nodeid:function(e){if(null==e)return null
var t=e.tagName.toLowerCase()
return"jmnodes"==t||"body"==t||"html"==t?null:"jmnode"==t||"jmexpander"==t?e.getAttribute("nodeid"):this.get_binded_nodeid(e.parentElement)},is_expander:function(e){return"jmexpander"==e.tagName.toLowerCase()},reset:function(){o.debug("view.reset"),this.selected_node=null,this.clear_lines(),this.clear_nodes(),this.reset_theme()},reset_theme:function(){var e=this.jm.options.theme
e?this.e_nodes.className="theme-"+e:this.e_nodes.className=""},reset_custom_style:function(){var e=this.jm.mind.nodes
for(nodeid in e)this.reset_node_custom_style(e[nodeid])},load:function(){o.debug("view.load"),this.init_nodes()},expand_size:function(){var e=this.layout.get_min_size(),t=e.w+2*this.opts.hmargin,i=e.h+2*this.opts.vmargin,a=this.e_panel.clientWidth,n=this.e_panel.clientHeight
t>a&&(a=t),i>n&&(n=i),this.size.w=a,this.size.h=n},init_canvas:function(){var e=this.e_canvas.getContext("2d")
this.canvas_ctx=e},init_nodes_size:function(e){var t=e._data.view
t.width=t.element.clientWidth,t.height=t.element.clientHeight},init_nodes:function(){var e=this.jm.mind.nodes,t=s.createDocumentFragment()
for(var i in e)this.create_node_element(e[i],t)
this.e_nodes.appendChild(t)
for(var i in e)this.init_nodes_size(e[i])},add_node:function(e){this.create_node_element(e,this.e_nodes),this.init_nodes_size(e)},create_node_element:function(e,t){var i=null
"view"in e._data?i=e._data.view:(i={},e._data.view=i)
var a=l("jmnode")
if(e.isroot)a.className="root"
else{var n=l("jmexpander")
d(n,"-"),n.setAttribute("nodeid",e.id),n.style.visibility="hidden",t.appendChild(n),i.expander=n}e.topic&&(this.opts.support_html?c(a,e.topic):d(a,e.topic)),a.setAttribute("nodeid",e.id),a.style.visibility="hidden",this._reset_node_custom_style(a,e.data),t.appendChild(a),i.element=a},remove_node:function(e){null!=this.selected_node&&this.selected_node.id==e.id&&(this.selected_node=null),null!=this.editing_node&&this.editing_node.id==e.id&&(e._data.view.element.removeChild(this.e_editor),this.editing_node=null)
for(var t=e.children,i=t.length;i--;)this.remove_node(t[i])
if(e._data.view){var a=e._data.view.element,n=e._data.view.expander
this.e_nodes.removeChild(a),this.e_nodes.removeChild(n),e._data.view.element=null,e._data.view.expander=null}},update_node:function(e){var t=e._data.view,i=t.element
e.topic&&(this.opts.support_html?c(i,e.topic):d(i,e.topic)),t.width=i.clientWidth,t.height=i.clientHeight},select_node:function(e){this.selected_node&&(this.selected_node._data.view.element.className=this.selected_node._data.view.element.className.replace(/\s*selected\s*/i,""),this.reset_node_custom_style(this.selected_node)),e&&(this.selected_node=e,e._data.view.element.className+=" selected",this.clear_node_custom_style(e))},select_clear:function(){this.select_node(null)},get_editing_node:function(){return this.editing_node},is_editing:function(){return!!this.editing_node},edit_node_begin:function(e){if(e.topic){null!=this.editing_node&&this.edit_node_end(),this.editing_node=e
var t=e._data.view,i=t.element,a=e.topic,n=getComputedStyle(i)
this.e_editor.value=a,this.e_editor.style.width=i.clientWidth-parseInt(n.getPropertyValue("padding-left"))-parseInt(n.getPropertyValue("padding-right"))+"px",i.innerHTML="",i.appendChild(this.e_editor),i.style.zIndex=5,this.e_editor.focus(),this.e_editor.select()}},edit_node_end:function(){if(null!=this.editing_node){var e=this.editing_node
this.editing_node=null
var t=e._data.view,i=t.element,a=this.e_editor.value
i.style.zIndex="auto",i.removeChild(this.e_editor),u.util.text.is_empty(a)||e.topic===a?this.opts.support_html?c(i,e.topic):d(i,e.topic):this.jm.update_node(e.id,a)}},get_view_offset:function(){var e=this.layout.bounds,t=(this.size.w-e.e-e.w)/2,i=this.size.h/2
return{x:t,y:i}},resize:function(){this.e_canvas.width=1,this.e_canvas.height=1,this.e_nodes.style.width="1px",this.e_nodes.style.height="1px",this.expand_size(),this._show()},_show:function(){this.e_canvas.width=this.size.w,this.e_canvas.height=this.size.h,this.e_nodes.style.width=this.size.w+"px",this.e_nodes.style.height=this.size.h+"px",this.show_nodes(),this.show_lines(),this.jm.invoke_event_handle(u.event_type.resize,{data:[]})},zoomIn:function(){return this.setZoom(this.actualZoom+this.zoomStep)},zoomOut:function(){return this.setZoom(this.actualZoom-this.zoomStep)},setZoom:function(e){if(e<this.minZoom||e>this.maxZoom)return!1
this.actualZoom=e
for(var t=0;t<this.e_panel.children.length;t++)this.e_panel.children[t].style.transform="scale("+e+")"
return this.show(!0),!0},_center_root:function(){var e=this.e_panel.clientWidth,t=this.e_panel.clientHeight
if(this.size.w>e){var i=this.get_view_offset()
this.e_panel.scrollLeft=i.x-e/2}this.size.h>t&&(this.e_panel.scrollTop=(this.size.h-t)/2)},show:function(e){o.debug("view.show"),this.expand_size(),this._show(),e&&this._center_root()},relayout:function(){this.expand_size(),this._show()},save_location:function(e){var t=e._data.view
t._saved_location={x:parseInt(t.element.style.left)-this.e_panel.scrollLeft,y:parseInt(t.element.style.top)-this.e_panel.scrollTop}},restore_location:function(e){var t=e._data.view
this.e_panel.scrollLeft=parseInt(t.element.style.left)-t._saved_location.x,this.e_panel.scrollTop=parseInt(t.element.style.top)-t._saved_location.y},clear_nodes:function(){var e=this.jm.mind
if(null!=e){var t=e.nodes,i=null
for(var a in t)i=t[a],i._data.view.element=null,i._data.view.expander=null
this.e_nodes.innerHTML=""}},show_nodes:function(){var e=this.jm.mind.nodes,t=null,i=null,a=null,n=null,o=null,s="-",r=null,l=this.get_view_offset()
for(var c in e)t=e[c],r=t._data.view,i=r.element,a=r.expander,this.layout.is_visible(t)?(this.reset_node_custom_style(t),n=this.layout.get_node_point(t),r.abs_x=l.x+n.x,r.abs_y=l.y+n.y,i.style.left=l.x+n.x+"px",i.style.top=l.y+n.y+"px",i.style.display="",i.style.visibility="visible",!t.isroot&&t.children.length>0&&(s=t.expanded?"-":"+",o=this.layout.get_expander_point(t),a.style.left=l.x+o.x+"px",a.style.top=l.y+o.y+"px",a.style.display="",a.style.visibility="visible",d(a,s)),t.isroot||0!=t.children.length||(a.style.display="none",a.style.visibility="hidden")):(i.style.display="none",a.style.display="none")},reset_node_custom_style:function(e){this._reset_node_custom_style(e._data.view.element,e.data)},_reset_node_custom_style:function(e,t){if("background-color"in t&&(e.style.backgroundColor=t["background-color"]),"foreground-color"in t&&(e.style.color=t["foreground-color"]),"width"in t&&(e.style.width=t.width+"px"),"height"in t&&(e.style.height=t.height+"px"),"font-size"in t&&(e.style.fontSize=t["font-size"]+"px"),"font-weight"in t&&(e.style.fontWeight=t["font-weight"]),"font-style"in t&&(e.style.fontStyle=t["font-style"]),"background-image"in t){var i=t["background-image"]
if(i.startsWith("data")&&t.width&&t.height){var a=new Image
a.onload=function(){var t=l("canvas")
t.width=e.clientWidth,t.height=e.clientHeight
var i=this
if(t.getContext){var a=t.getContext("2d")
a.drawImage(i,2,2,e.clientWidth,e.clientHeight)
var n=t.toDataURL()
e.style.backgroundImage="url("+n+")"}},a.src=i}else e.style.backgroundImage="url("+i+")"
e.style.backgroundSize="99%","background-rotation"in t&&(e.style.transform="rotate("+t["background-rotation"]+"deg)")}},clear_node_custom_style:function(e){var t=e._data.view.element
t.style.backgroundColor="",t.style.color=""},_draw_background:function(e){var t=e||this.canvas_ctx,i=document.getElementById(this.opts.container).style.backgroundColor
t.fillStyle=i,t.beginPath(),u.util.canvas.rect(t,0,0,t.canvas.clientWidth,t.canvas.clientHeight,2),t.closePath(),t.fill()},clear_lines:function(e){var t=e||this.canvas_ctx
u.util.canvas.clear(t,0,0,this.size.w,this.size.h),this._draw_background(e)},show_lines:function(e){this.clear_lines(e)
var t=this.jm.mind.nodes,i=null,a=null,n=null,o=this.get_view_offset()
for(var s in t)i=t[s],i.isroot||"visible"in i._data.layout&&!i._data.layout.visible||(a=this.layout.get_node_point_in(i),n=this.layout.get_node_point_out(i.parent),this.draw_line(n,a,o,e))},draw_line:function(e,t,i,a){var n=a||this.canvas_ctx
n.strokeStyle=this.opts.line_color,n.lineWidth=this.opts.line_width,n.lineCap="round",u.util.canvas.bezierto(n,e.x+i.x,e.y+i.y,t.x+i.x,t.y+i.y)}},u.shortcut_provider=function(e,t){this.jm=e,this.opts=t,this.mapping=t.mapping,this.handles=t.handles,this._mapping={}},u.shortcut_provider.prototype={init:function(){u.util.dom.add_event(s,"keydown",this.handler.bind(this)),this.handles.addchild=this.handle_addchild,this.handles.addbrother=this.handle_addbrother,this.handles.editnode=this.handle_editnode,this.handles.delnode=this.handle_delnode,this.handles.toggle=this.handle_toggle,this.handles.up=this.handle_up,this.handles.down=this.handle_down,this.handles.left=this.handle_left,this.handles.right=this.handle_right
for(var e in this.mapping)this.mapping[e]&&e in this.handles&&(this._mapping[this.mapping[e]]=this.handles[e])},enable_shortcut:function(){this.opts.enable=!0},disable_shortcut:function(){this.opts.enable=!1},handler:function(e){if(!this.jm.view.is_editing()){var t=e||event
if(!this.opts.enable)return!0
var i=t.keyCode
i in this._mapping&&this._mapping[i].call(this,this.jm,e)}},handle_addchild:function(e,t){var i=e.get_selected_node()
if(i){var a=u.util.uuid.newid(),n=e.add_node(i,a,"New Node")
n&&(e.select_node(a),e.begin_edit(a))}},handle_addbrother:function(e,t){var i=e.get_selected_node()
if(i&&!i.isroot){var a=u.util.uuid.newid(),n=e.insert_node_after(i,a,"New Node")
n&&(e.select_node(a),e.begin_edit(a))}},handle_editnode:function(e,t){var i=e.get_selected_node()
i&&e.begin_edit(i)},handle_delnode:function(e,t){var i=e.get_selected_node()
i&&!i.isroot&&(e.select_node(i.parent),e.remove_node(i))},handle_toggle:function(e,t){var i=t||event,a=e.get_selected_node()
a&&(e.toggle_node(a.id),i.stopPropagation(),i.preventDefault())},handle_up:function(e,t){var i=t||event,a=e.get_selected_node()
if(a){var n=e.find_node_before(a)
if(!n){var o=e.find_node_before(a.parent)
o&&o.children.length>0&&(n=o.children[o.children.length-1])}n&&e.select_node(n),i.stopPropagation(),i.preventDefault()}},handle_down:function(e,t){var i=t||event,a=e.get_selected_node()
if(a){var n=e.find_node_after(a)
if(!n){var o=e.find_node_after(a.parent)
o&&o.children.length>0&&(n=o.children[0])}n&&e.select_node(n),i.stopPropagation(),i.preventDefault()}},handle_left:function(e,t){this._handle_direction(e,t,u.direction.left)},handle_right:function(e,t){this._handle_direction(e,t,u.direction.right)},_handle_direction:function(e,t,i){var a=t||event,n=e.get_selected_node(),o=null
if(n){if(n.isroot){for(var s=n.children,r=[],l=0;l<s.length;l++)s[l].direction===i&&r.push(l)
o=s[r[Math.floor((r.length-1)/2)]]}else if(n.direction===i){var r=n.children,d=r.length
d>0&&(o=r[Math.floor((d-1)/2)])}else o=n.parent
o&&e.select_node(o),a.stopPropagation(),a.preventDefault()}}},u.plugin=function(e,t){this.name=e,this.init=t},u.plugins=[],u.register_plugin=function(e){e instanceof u.plugin&&u.plugins.push(e)},u.init_plugins=function(t){e.setTimeout(function(){u._init_plugins(t)},0)},u._init_plugins=function(e){for(var t=u.plugins.length,i=null,a=0;t>a;a++)i=u.plugins[a].init,"function"==typeof i&&i(e)},u.show=function(e,t){var i=new u(e)
return i.show(t),i},e[t]=u}}(window),function(e){"use strict"
var t="jsMind",i=e[t]
if(i&&void 0===i.screenshot){var a=e.document,n=function(e){return a.createElement(e)},o=function(e,t){return e.getPropertyValue(t)},s=function(e){var t=o(e,"visibility"),i=o(e,"display")
return"hidden"!==t&&"none"!==i},r=i.util.canvas
r.rect=function(e,t,i,a,n,o){2*o>a&&(o=a/2),2*o>n&&(o=n/2),e.moveTo(t+o,i),e.arcTo(t+a,i,t+a,i+n,o),e.arcTo(t+a,i+n,t,i+n,o),e.arcTo(t,i+n,t,i,o),e.arcTo(t,i,t+a,i,o)},r.text_multiline=function(e,t,i,a,n,o,s){var r="",l=t.length,d=t.split(""),c=null
e.textAlign="left",e.textBaseline="top"
for(var g=0;l>g;g++)c=r+d[g],e.measureText(c).width>n&&g>0?(e.fillText(r,i,a),r=d[g],a+=s):r=c
e.fillText(r,i,a)},r.text_ellipsis=function(e,t,i,a,n,o){var s=a+o/2,t=r.fittingString(e,t,n)
e.textAlign="left",e.textBaseline="middle",e.fillText(t,i,s,n)},r.fittingString=function(e,t,i){var a=e.measureText(t).width,n="…",o=e.measureText(n).width
if(i>=a||o>=a)return t
for(var s=t.length;a>=i-o&&s-- >0;)t=t.substring(0,s),a=e.measureText(t).width
return t+n},r.image=function(e,t,i,a,n,o,s,l,d){var c=new Image
c.onload=function(){e.save(),e.translate(i,a),e.save(),e.beginPath(),r.rect(e,0,0,n,o,s),e.closePath(),e.clip(),e.translate(n/2,o/2),e.rotate(l*Math.PI/180),e.drawImage(c,-n/2,-o/2),e.restore(),e.restore(),d()},c.src=t},i.screenshot=function(e){this.jm=e,this.canvas_elem=null,this.canvas_ctx=null,this._inited=!1},i.screenshot.prototype={init:function(){if(!this._inited){console.log("init")
var e=n("canvas"),t=e.getContext("2d")
this.canvas_elem=e,this.canvas_ctx=t,this.jm.view.e_panel.appendChild(e),this._inited=!0,this.resize()}},shoot:function(e){this.init(),this._watermark()
var t=this
this._draw(function(){e&&e(t),t.clean()})},shootDownload:function(){this.shoot(function(e){e._download()})},shootAsDataURL:function(e){this.shoot(function(t){e(t.canvas_elem.toDataURL())})},resize:function(){this._inited&&(this.canvas_elem.width=this.jm.view.size.w,this.canvas_elem.height=this.jm.view.size.h)},clean:function(){var e=this.canvas_elem
this.canvas_ctx.clearRect(0,0,e.width,e.height)},_draw:function(e){var t=this.canvas_ctx
t.textAlign="left",t.textBaseline="top",this._draw_lines(),this._draw_nodes(e)},_watermark:function(){var t=this.canvas_elem,i=this.canvas_ctx
i.textAlign="right",i.textBaseline="bottom",i.fillStyle="#000",i.font="11px Verdana,Arial,Helvetica,sans-serif",i.fillText("hizzgdev.github.io/jsmind",t.width-5.5,t.height-2.5),i.textAlign="left",i.fillText(e.location,5.5,t.height-2.5)},_draw_lines:function(){this.jm.view.show_lines(this.canvas_ctx)},_draw_nodes:function(t){function i(){console.log("check_node_ready"+new Date)
var o=!0
for(var s in n)a=n[s],o&=a.ready
o?e.setTimeout(t,200):e.setTimeout(i,200)}var a,n=this.jm.mind.nodes
for(var o in n)a=n[o],this._draw_node(a)
i()},_draw_node:function(e){var t=this.canvas_ctx,i=e._data.view,a=i.element
a=a.firstChild
var n=getComputedStyle(a)
if(!s(n))return void(e.ready=!0)
var l=o(n,"background-color"),d=parseInt(o(n,"border-top-left-radius")),c=o(n,"color"),g=parseInt(o(n,"padding-left")),u=parseInt(o(n,"padding-right")),h=parseInt(o(n,"padding-top")),m=parseInt(o(n,"padding-bottom")),p=o(n,"text-overflow"),f=o(n,"font-style")+" "+o(n,"font-variant")+" "+o(n,"font-weight")+" "+o(n,"font-size")+"/"+o(n,"line-height")+" "+o(n,"font-family"),y={x:i.abs_x,y:i.abs_y,w:i.width+1,h:i.height+1},v={x:y.x+g,y:y.y+h,w:y.w-g-u,h:y.h-h-m}
if(t.font=f,t.fillStyle=l,t.beginPath(),r.rect(t,y.x,y.y,y.w,y.h,d),t.closePath(),t.fill(),t.fillStyle=c,"background-image"in e.data){var b=o(n,"background-image").slice(5,-2)
e.ready=!1
var x=0
"background-rotation"in e.data&&(x=e.data["background-rotation"]),r.image(t,b,y.x,y.y,y.w,y.h,d,x,function(){e.ready=!0})}if("ellipsis"===p)r.text_ellipsis(t,a.innerText,v.x,v.y,v.w,v.h)
else{var _=parseInt(o(n,"line-height"))
t.textAlign="left",t.textBaseline="top"
for(var L=a.innerHTML.split("<br>"),k=0;k<L.length;k++){var T=L[k].replace(/<[^>]+>/g,"")
t.fillText(T,v.x,v.y+k*_,v.w)}}i.expander&&this._draw_expander(i.expander),"background-image"in e.data||(e.ready=!0)},_draw_expander:function(e){var t=this.canvas_ctx,i=getComputedStyle(e)
if(s(i)){var a=o(i,"left"),n=o(i,"top"),r=(o(i,"font"),parseInt(a)),l=parseInt(n),d="+"===e.innerHTML
t.lineWidth=1,t.beginPath(),t.arc(r+7,l+7,5,0,2*Math.PI,!0),t.moveTo(r+10,l+7),t.lineTo(r+4,l+7),d&&(t.moveTo(r+7,l+4),t.lineTo(r+7,l+10)),t.closePath(),t.stroke()}},_download:function(){var e=this.canvas_elem,t=this.jm.mind.name+".png"
if(navigator.msSaveBlob&&e.msToBlob){var i=e.msToBlob()
navigator.msSaveBlob(i,t)}else{var o=this.canvas_elem.toDataURL(),s=n("a")
if("download"in s){s.style.visibility="hidden",s.href=o,s.download=t,a.body.appendChild(s)
var r=a.createEvent("MouseEvents")
r.initEvent("click",!0,!0),s.dispatchEvent(r),a.body.removeChild(s)}else location.href=o}},jm_event_handle:function(e,t){e===i.event_type.resize&&this.resize()}}
var l=new i.plugin("screenshot",function(e){var t=new i.screenshot(e)
e.screenshot=t,e.shoot=function(){t.shoot()},e.add_event_listener(function(e,i){t.jm_event_handle.call(t,e,i)})})
i.register_plugin(l)}}(window)
var gmLhb={}
gmLhb.qqLhbReason={"070001":"日涨幅7%","070002":"日跌幅7%","070003":"日振幅15%","070004":"日换手20%","070005":"三日涨幅20%","070006":"三日跌幅20%","070007":"三日涨幅12%","070008":"三日跌幅12%","070009":"新股","070022":"融资买入50%","070014":"5日均换手增30倍","01":"日涨幅7%","02":"日跌幅7%","03":"日振幅15%","04":"日换手20%","05":"三日涨幅20%","06":"三日跌幅20%","07":"三日涨幅12%","08":"三日跌幅12%","09":"新股",11:"无涨跌幅限制的证券",14:"5日均换手增30倍",22:"融资买入50%",28:"融资买入50%",33:"退市整理期","001":"涨幅偏离值达7%的证券","002":"跌幅偏离值达7%的证券","003":"振幅值达15%的证券","004":"换手率达20%的证券","005":"连续三个交易日内，涨幅偏离值累计达20%的证券","006":"连续三个交易日内，跌幅偏离值累计达20%的证券","007":"连续三个交易日内，涨幅偏离值累计达到15%的ST证券、*ST证券和未完成股改证券","008":"连续三个交易日内，跌幅偏离值累计达到15%的ST证券、*ST证券和未完成股改证券","009":"新股","011":"无价格涨跌幅限制的证券","014":"5日均换手增30倍","022":"融资买入50%","028":"融资买入50%","033":"退市整理期","041":"连续三个交易日内，跌幅偏离值累计达到12%的ST证券、*ST证券和未完成股改证券","042":"连续三个交易日，日均换手率与前五个交易日的日均换手率的比值达到30倍","099":"其它类型"},gmLhb.sinaLhbReason={"01":"日涨幅7%","02":"日跌幅7%","03":"日振幅15%","04":"日换手20%","05":"三日涨幅20%","06":"三日跌幅20%","07":"三日涨幅12%","08":"三日跌幅12%","09":"新股",22:"融资买入50%",14:"5日均换手增30倍"},gmLhb.xqLhbReason={"01":"日涨幅7%","02":"日跌幅7%","03":"日振幅15%","04":"日换手20%","05":"三日涨幅20%","06":"三日跌幅20%","07":"三日涨幅12%","08":"三日跌幅12%","09":"新股",11:"无涨跌幅限制的证券",14:"5日均换手增30倍",22:"融资买入50%",28:"融资买入50%"},gmLhb.init=function(){fs.existsSync(gLhbDaysFolder)||(iToasts.show("创建数据目录："+gLhbDaysFolder),fs.mkdirSync(gLhbDaysFolder)),gmLhb.sourceId="dc",gmLhb.publicApartment=readObjectFromFile(gPublicLhbApartmentFile),gmLhb.privateApartment=readObjectFromFile(gLhbApartmentFile),gmLhb.yzListAndDetails=readObjectFromFile(gLhbDetailsFile),gmLhb.yzListAndDetails.yzList={},gmLhb.lockStockDisplay=!1
var e=gmTdx.getLastTradeDay("yyyy-MM-dd")
$("lhblistday").value=e,gmLhb.enableButtonBySourceId(),gmLhb.lhbShown=!1,gmLhb.getGroupId(),gmLhb.getYzListFromServer(),setTimeout(function(){gmLhb.getYzDetailsFromServer()},1e3)
var t=new jAjax
t.get("https://xueqiu.com/",function(e){},function(){})},gmLhb.refreshLhbYzList=function(e){e.disabled||(disableButton(e),gmLhb.getYzListFromServer(),setTimeout(function(){gmLhb.getYzDetailsFromServer()},1e3),setTimeout(function(){enableButton(e)},3e3))},gmLhb.getGroupId=function(){gmLhb.groupId="0",null==userinfo?gmLhb.groupId="0":1==gConfig.cfgLhbType?gmLhb.groupId=userinfo.UserId:2==gConfig.cfgLhbType&&(gmLhb.groupId=gConfig.cfgLhbGroupId),gmLhb.groupId=""+gmLhb.groupId,void 0===gmLhb.yzListAndDetails[gmLhb.groupId]&&(gmLhb.yzListAndDetails[gmLhb.groupId]={lastUpdateTime:"2017-01-01",currentFPlan:"顶级游资",fPlans:{},yzItems:{}})},gmLhb.getLhbDataFromSina=function(e){if(null==userinfo)return void popuplist.push("divuserlogin")
if(!checkvuser())return void popuplist.push("divuserbindsn")
var t=$("btnUpdateLhbInfo")
"tdx"==e?gmLhb.sourceId="tdx":"dc"==e?gmLhb.sourceId="dc":(gmLhb.sourceId="xq",t=$("btnUpdateLhbInfo2")),t.disabled||iDlgs.confirm("系统提示","确定要获取指定日期的龙虎榜资料吗？",function(){var e=$("lhblistday").value
gmLhb.getLhbListBySourceId(e)},function(){})},gmLhb.enableButtonBySourceId=function(){enableButton($("btnUpdateLhbInfo"))},gmLhb.disableButtonBySourceId=function(){disableButton($("btnUpdateLhbInfo"))},gmLhb.getLhbListBySourceId=function(e){var t=$("btnUpdateLhbInfo")
if(!t.disabled)switch(gmLhb.disableButtonBySourceId(),gmLhb.sourceId){case"tdx":e=e.replace(/\-/g,""),gmLhb.getLhbListFromTdx(e)
break
case"xq":e=e.replace(/\-/g,""),gmLhb.getLhbListFromXq(e)
break
case"sina":gmLhb.getLhbListFromSina(e)
break
case"dc":gmLhb.getLhbListFromDc(e)}},gmLhb.changeTemplate=function(e,t,i){null==gmLhb.currentTemplateBtn&&(gmLhb.currentTemplateBtn=$("btnLhbTempPublic"),e=gmLhb.currentTemplateBtn),gmLhb.currentTemplateBtn.style.backgroundColor="#09c",gmLhb.currentTemplateBtn=e,gmLhb.currentTemplateBtn.style.backgroundColor="#d9534f",gConfig.cfgLhbyouzi=t,empty(i)||gmLhb.listDay()},gmLhb.showCurrentLhb=function(){if(!gmLhb.lhbShown){var e=new Date
if(e.getDay()>0&&e.getDay()<6&&parseInt(e.Format("hhmm"))>1700){var t=gmTdx.getLastTradeDay(),i=gLhbDaysFolder+"/"+t+".txt"
$("lhblistday").value=gmTdx.getLastTradeDay("yyyy-MM-dd"),fs.existsSync(i)?gmLhb.listDay():gmLhb.getLhbListBySourceId($("lhblistday").value)}else $("lhblistday").value=gmTdx.getPreTradeDay("yyyy-MM-dd"),gmLhb.lhbShown||gmLhb.listDay()}},gmLhb.getLhbDataFromQQ=function(){var e=$("btnUpdateLhbInfo")
e.disabled||iDlgs.confirm("系统提示","确定要获取指定时间段的龙虎榜资料吗（请选择较小时间段分批获取，防止中途出现错误。建议一周以内）？",function(){var t=$("lhbstartdate").value.replace(/\-/g,""),i=$("lhbenddate").value.replace(/\-/g,"")
disableButton(e),gmLhb.getLhbListFromQQ(t,i,1)},function(){})},gmLhb.getLhbListFromQQ=function(from,to,page){var btn=$("btnUpdateLhbInfo")
1==page&&(gmLhb.lhbQueue=[],gmLhb.details={})
var lhblisturl="http://stock.finance.qq.com/cgi-bin/sstock/q_lhb_js?t=2&c=&b="+from+"&e="+to+"&p="+page+"&l=&ol=6&o=desc",ajax=new jAjax
ajax.binary_get(lhblisturl,function(d){var dd=new Buffer(d),ddutf=iconv.decode(dd,"gbk")
if(eval(ddutf),"undefined"==typeof oLhbDatas)return void iToasts.show("error")
for(var i=0;i<oLhbDatas._datas.length;i++){var item=oLhbDatas._datas[i],day=item[0].replace(/\-/g,""),code=item[1],name=item[2],reason=item[3],reasoncode=item[4],price=item[5],zf=item[6]
void 0===gmLhb.details[day]&&(gmLhb.details[day]={day:day,stocks:[],items:[]}),-1==gmLhb.details[day].stocks.indexOf(code)&&gmLhb.details[day].stocks.push(code),gmLhb.lhbQueue.push({day:day,code:code,reason:reasoncode})}if(oLhbDatas._curpage<oLhbDatas._pages)gmLhb.getLhbList(from,to,oLhbDatas._curpage+1)
else{if(0==gmLhb.lhbQueue.length)return gmLhb.enableButtonBySourceId(),void iToasts.show("未找到相关数据，请稍后重试",!1)
iToasts.show("已成功获取所有龙虎榜股票列表，共 "+gmLhb.lhbQueue.length+" 只，开始获取详细信息",!1),gmLhb.timer=setInterval(function(){gmLhb.dStatus=0,gmLhb.getDetailsFromQQ()},100)}},function(){gmLhb.enableButtonBySourceId(),iToasts.show("获取龙虎榜信息时出现错误",!0)})},gmLhb.getDetailsFromQQ=function(){if(gmLhb.lhbQueue.length<1&&0==gmLhb.dStatus){gmLhb.enableButtonBySourceId(),clearInterval(gmLhb.timer),iDlgs.show("系统提示","已成功更新指定时间段的龙虎榜资料！",!1)
for(var index in gmLhb.details){var filename=gLhbDaysFolder+"/"+index+".txt"
saveObjectToFile(gmLhb.details[index],filename)}}else{if(gmLhb.lhbQueue.length<1&&2==gmLhb.dStatus)return gmLhb.enableButtonBySourceId(),void clearInterval(gmLhb.timer)
if(!(gmLhb.dStatus>0)){gmLhb.dStatus=1
var sd=gmLhb.lhbQueue.pop(),stocklhburl="http://stock.finance.qq.com/cgi-bin/sstock/q_lhb_xx_js?c="+sd.code+"&b="+sd.day+"&l="+sd.reason,ajax=new jAjax
ajax.binary_get(stocklhburl,function(d){var dd=new Buffer(d),ddutf=iconv.decode(dd,"gbk")
if(eval(ddutf),"undefined"==typeof oLhbxxDatas)return iToasts.show("error"),void(gmLhb.dStatus=2)
if(oLhbxxDatas._datas.length>0){var day=sd.day
void 0===gmLhb.details[day]&&(gmLhb.details[day]={day:day,stocks:[],items:[]})
for(var stocklhb={code:sd.code,name:oLhbxxDatas._datas[0][1],reason:sd.reason,items:[]},i=0;i<oLhbxxDatas._datas.length;i++)stocklhb.items.push([oLhbxxDatas._datas[i][2],parseInt(oLhbxxDatas._datas[i][3]),oLhbxxDatas._datas[i][5],parseInt(oLhbxxDatas._datas[i][6]),parseInt(oLhbxxDatas._datas[i][7])])
gmLhb.details[day].items.push(stocklhb)}gmLhb.dStatus=0},function(){gmLhb.dStatus=2,iToasts.show("获取龙虎榜详细信息出错！",!0)})}}},gmLhb.httpGet=function(e,t,i){var a=require("https")
a.get(e,function(e){console.log("statusCode:",e.statusCode),console.log("headers:",e.headers)
var i=""
e.on("data",function(e){i+=e}),e.on("end",function(){t&&t(i)})}).on("error",function(e){console.error(e),i&&i()})},gmLhb.getLhbDataFromXq=function(){var e=$("btnUpdateLhbInfo")
e.disabled||iDlgs.confirm("系统提示","确定要获取指定日期的龙虎榜资料吗？",function(){var t=$("lhbstartdate").value.replace(/\-/g,""),i=$("lhbenddate").value.replace(/\-/g,"")
disableButton(e),gmLhb.getLhbListFromQQ(t,i,1)},function(){})},gmLhb.getLhbListFromXq=function(e){$("btnUpdateLhbInfo")
gmLhb.lhbQueue=[],gmLhb.details={}
var t="https://xueqiu.com/stock/f10/bizunittrdinfo.json?date="+e,i=new jAjax
i.get(t,function(t){var i=JSON.parse(t)
if(null==i.list)return gmLhb.enableButtonBySourceId(),void iToasts.show("未找到相关数据，请稍后重试",!1)
for(var a=0;a<i.list.length;a++){var n=i.list[a],o=n.symbol.substr(2)
void 0===gmLhb.details[e]&&(gmLhb.details[e]={day:e,stocks:[],items:[]}),-1==gmLhb.details[e].stocks.indexOf(o)&&gmLhb.details[e].stocks.push(o),gmLhb.lhbQueue.push({day:e,code:n.symbol})}return 0==gmLhb.lhbQueue.length?(gmLhb.enableButtonBySourceId(),void iToasts.show("未找到相关数据，请稍后重试",!1)):(iToasts.show("已成功获取所有龙虎榜股票列表，共 "+gmLhb.lhbQueue.length+" 只，开始获取详细信息",!1),void(gmLhb.timer=setInterval(function(){gmLhb.dStatus=0,gmLhb.getDetailsFromXq()},100)))},function(){gmLhb.enableButtonBySourceId(),console.log(JSON.stringify(this)),iToasts.show("获取龙虎榜列表时出现错误",!0)})},gmLhb.getDetailsFromXq=function(){if(gmLhb.lhbQueue.length<1&&0==gmLhb.dStatus){gmLhb.enableButtonBySourceId(),clearInterval(gmLhb.timer),iDlgs.show("系统提示","已成功更新指定时间段的龙虎榜资料！",!1)
for(var e in gmLhb.details){var t=gLhbDaysFolder+"/"+e+".txt"
saveObjectToFile(gmLhb.details[e],t)}return void gmLhb.listDay()}if(gmLhb.lhbQueue.length<1&&2==gmLhb.dStatus)return gmLhb.enableButtonBySourceId(),void clearInterval(gmLhb.timer)
if(!(gmLhb.dStatus>0)){gmLhb.dStatus=1
var i=gmLhb.lhbQueue.pop(),a="https://xueqiu.com/stock/f10/bizunittrdinfo.json?date="+i.day+"&symbol="+i.code,n=new jAjax
n.get(a,function(e){var t=JSON.parse(e),a=i.day
void 0===gmLhb.details[a]&&(gmLhb.details[a]={day:a,stocks:[],items:[]})
for(var n={},o=0;o<t.detail.tqQtBizunittrdinfoBuyList.length;o++){var s=t.detail.tqQtBizunittrdinfoBuyList[o]
if(void 0===n[s.chgtype]&&(n[s.chgtype]={code:t.detail.symbol.substr(2),name:t.detail.name,bcount:0,scount:0,hq:t.detail.tqQtSkdailyprice,reason:s.chgtype,items:[]}),n[s.chgtype].bcount<5){var r=!1
for(var l in n[s.chgtype].items){var d=n[s.chgtype].items[l]
if("SH600425"==i.code&&(i.code2="s"),"B"==d[0]&&d[2]==s.bizsunitname&&d[3]==Math.round(s.buyamt)&&d[4]==Math.round(s.saleamt)){r=!0
break}}if(r)continue
n[s.chgtype].bcount++,n[s.chgtype].items.push(["B",0,s.bizsunitname,Math.round(s.buyamt),Math.round(s.saleamt)])}}for(var o=0;o<t.detail.tqQtBizunittrdinfoSaleList.length;o++){var s=t.detail.tqQtBizunittrdinfoSaleList[o]
if(void 0===n[s.chgtype]&&(n[s.chgtype]={code:t.detail.symbol.substr(2),name:t.detail.name,bcount:0,scount:0,hq:t.detail.tqQtSkdailyprice,reason:s.chgtype,items:[]}),n[s.chgtype].scount<5){var r=!1
for(var l in n[s.chgtype].items){var d=n[s.chgtype].items[l]
if("S"==d[0]&&d[2]==s.bizsunitname&&d[3]==Math.round(s.buyamt)&&d[4]==Math.round(s.saleamt)){r=!0
break}}if(r)continue
n[s.chgtype].scount++,n[s.chgtype].items.push(["S",0,s.bizsunitname,Math.round(s.buyamt),Math.round(s.saleamt)])}}for(var o in n)gmLhb.details[a].items.push(n[o])
gmLhb.dStatus=0},function(){gmLhb.dStatus=2,iToasts.show("获取龙虎榜详细信息出错！",!0)})}},gmLhb.getLhbListFromDc=function(e){gmLhb.lhbQueue=[],gmLhb.details={}
var t="http://m.data.eastmoney.com/api/Lhb/TradeDetailList?gpfw=0&startDate="+e+"&endDate="+e+"&page=1&pagesize=200",i=new jAjax
i.get(t,function(t){var i=JSON.parse(t),a=i.result
if(0==a.length)return gmLhb.enableButtonBySourceId(),void iToasts.show("未找到相关数据，请稍后重试",!1)
var n=e.replace(/\-/g,""),o=gLhbDaysFolder+"/"+n+".txt"
gmLhb.details[n]=readObjectFromFile(o)
for(var s=0;s<a.length;s++){var r=a[s],l=r.SCode
void 0===gmLhb.details[n].stocks&&(gmLhb.details[n]={day:n,stocks:[],items:[]}),-1==gmLhb.details[n].stocks.indexOf(l)&&gmLhb.details[n].stocks.push(l)
for(var d=!1,c=0;c<gmLhb.details[n].items.length;c++)if(gmLhb.details[n].items[c].code==l){d=!0
break}if(!d){for(var c=0;c<gmLhb.lhbQueue.length;c++)if(gmLhb.lhbQueue[c].code==l){d=!0
break}d||gmLhb.lhbQueue.push({day:e,code:r.SCode,name:r.SName,hq:{amount:r.Turnover,hsl:r.Dchratio,zf:r.Chgradio,sella:r.Smoney,buya:r.Bmoney}})}}return gmLhb.lhbQueue.length<1?(gmLhb.enableButtonBySourceId(),void iToasts.show("暂无新数据 ",!1)):(iToasts.show("已获取龙虎榜股票列表，共 "+gmLhb.lhbQueue.length+" 只需要更新，开始获取详细信息",!1),gmLhb.workingThread=0,void(gmLhb.timer=setInterval(function(){gmLhb.getDetailsFromDc()},100)))},function(){gmLhb.enableButtonBySourceId(),console.log(JSON.stringify(this)),iToasts.show("获取龙虎榜列表时出现错误",!0)})},gmLhb.getDetailsFromDc=function(){if(gmLhb.lhbQueue.length<1&&0==gmLhb.workingThread){gmLhb.enableButtonBySourceId(),clearInterval(gmLhb.timer),iDlgs.show("系统提示","已成功更新指定时间段的龙虎榜资料！",!1)
for(var e in gmLhb.details){var t=gLhbDaysFolder+"/"+e+".txt"
saveObjectToFile(gmLhb.details[e],t)}return void gmLhb.listDay()}if(!(gmLhb.lhbQueue.length<1)){gmLhb.workingThread++
var i=gmLhb.lhbQueue.pop(),a="http://data.eastmoney.com/stock/lhb,"+i.day+","+i.code+".html",n=new jAjax
n.get(a,function(e){for(var t=RegExp('<div class="left con-br" style="padding-left:0px;">'+i.day+"[\\S\\s]*?类型：([\\S]*?)<\\/div>([\\S\\s]*?买入前5名)","gim"),a=/<table cellpadding="0" cellspacing="0" class="default_tab stock-detail-tab" id="tab-2">([\S\s]*?)<\/table>/g,n=/<table cellpadding="0" cellspacing="0" class="default_tab tab-2" id="tab-4">([\S\s]*?)买入前5名/g,o=/<tr>\s+<td>\d+<\/td>\s+<td>[\S\s]*?<a href="\/stock\/[\S]*?\.html">(\S*?)<\/a>[\S\s]*?<\/td>\s+<td[\S\s]*?>([0-9\.\%\-\,]+)<\/td>\s+<td[\S\s]*?>([0-9\.\%\-\,]+)<\/td>\s+<td[\S\s]*?>([0-9\.\%\-\,]+)<\/td>/g,s={};rms=t.exec(e);){var r=rms[2],l="099"
for(rv in gmLhb.qqLhbReason)rms[1]==gmLhb.qqLhbReason[rv]&&(l=rv)
void 0===s[l]&&(s[l]={code:i.code,name:i.name,bcount:0,scount:0,hq:i.hq,reason:l,items:[]})
var d=r.match(a),c=r.match(n)
if(empty(d)||empty(c))break
for(;ms=o.exec(d[0]);){var g=ms[1],u=Math.round(1e4*parseFloat(ms[2].replace(/\,/g,""))),h=Math.round(1e4*parseFloat(ms[4].replace(/\,/g,"")))
s[l].bcount++,s[l].items.push(["B",0,g,u,h])}for(;ms=o.exec(c[0]);){var g=ms[1],u=Math.round(1e4*parseFloat(ms[2].replace(/\,/g,""))),h=Math.round(1e4*parseFloat(ms[4].replace(/\,/g,"")))
s[l].scount++,s[l].items.push(["S",0,g,u,h])}}var m=i.day.replace(/\-/g,"")
for(var p in s)(s[p].bcount>0||s[p].scount>0)&&gmLhb.details[m].items.push(s[p])
gmLhb.workingThread--},function(){gmLhb.workingThread--,iToasts.show("获取龙虎榜详细信息出错！",!0)})}},gmLhb.getLhbDataFromTdx=function(){var e=$("btnUpdateLhbInfo")
e.disabled||iDlgs.confirm("系统提示","确定要获取指定日期的龙虎榜资料吗？",function(){var t=$("lhbstartdate").value.replace(/\-/g,"")
disableButton(e),gmLhb.getLhbListFromTdx(t)},function(){})},gmLhb.getLhbListFromTdx=function(e){$("btnUpdateLhbInfo")
gmLhb.lhbQueue=[],gmLhb.details={}
var t="http://page3.tdx.com.cn/TQLEX?Entry=CWServ.SecuInfo",i=new jAjax,a='{"CallName":"f10_zs_jylhb","Params":["1","'+e+'",""]}'
i.post(t,a,function(t){var i=JSON.parse(t)
if(0!=i.ErrorCode||0==i.ResultSets[0].Content.length)return gmLhb.enableButtonBySourceId(),void iToasts.show("未找到相关数据，请稍后重试",!1)
for(var a=0;a<i.ResultSets[0].Content.length;a++){var n=i.ResultSets[0].Content[a],o=n[0]
void 0===gmLhb.details[e]&&(gmLhb.details[e]={day:e,stocks:[],items:[]}),-1==gmLhb.details[e].stocks.indexOf(o)&&gmLhb.details[e].stocks.push(o)
var s={turnrate:0,amount:1e8,pchg:0},r=new gmTdx.tdxDays(o)
if(r.length>0){var l=gmTdx.getDayIndex(r,e)
if(l>=0&&l<r.length){var d=new r.get(l)
s.amount=d.amount}}gmLhb.lhbQueue.push({day:e,code:o,name:n[2],hq:s})}return 0==gmLhb.lhbQueue.length?(gmLhb.enableButtonBySourceId(),void iToasts.show("未找到相关数据，请稍后重试",!1)):(iToasts.show("已成功获取所有龙虎榜股票列表，共 "+gmLhb.lhbQueue.length+" 只，开始获取详细信息",!1),gmLhb.dStatus=0,void(gmLhb.timer=setInterval(function(){gmLhb.getDetailsFromTdx()},30)))},function(){gmLhb.enableButtonBySourceId(),console.log(JSON.stringify(this)),iToasts.show("获取龙虎榜列表时出现错误",!0)})},gmLhb.getDetailsFromTdx=function(){$("btnUpdateLhbInfo")
if(gmLhb.lhbQueue.length<1&&0==gmLhb.dStatus){gmLhb.enableButtonBySourceId(),clearInterval(gmLhb.timer),iDlgs.show("系统提示","已成功更新指定时间段的龙虎榜资料！",!1)
for(var e in gmLhb.details){var t=gLhbDaysFolder+"/"+e+".txt"
saveObjectToFile(gmLhb.details[e],t)}return void gmLhb.listDay()}if(gmLhb.lhbQueue.length<1&&2==gmLhb.dStatus)return gmLhb.enableButtonBySourceId(),void clearInterval(gmLhb.timer)
if(!(gmLhb.dStatus>0)){gmLhb.dStatus=1
var i=gmLhb.lhbQueue.pop(),a="http://page3.tdx.com.cn/TQLEX?Entry=CWServ.SecuInfo",n=new jAjax,o='{"CallName":"f10_zs_jylhb","Params":["2","'+i.day+'","'+i.code+'"]}'
n.post(a,o,function(e){var t=JSON.parse(e),a=i.day
void 0===gmLhb.details[a]&&(gmLhb.details[a]={day:a,stocks:[],items:[]})
for(var n={},o=0;o<t.ResultSets[0].Content.length;o++){var s=t.ResultSets[0].Content[o],r=s[0]
void 0===n[r]&&(n[r]={code:i.code,name:i.name,reason:r,hq:i.hq,items:[]})
for(var l=parseInt(s[2]),d=[s[1],l,s[3],1e4*parseInt(s[4]),1e4*parseInt(s[5])],c=!1,g=0;g<n[r].items.length;g++){var u=n[r].items[g][0]+n[r].items[g][1],h=d[0]+d[1]
if(u>h){n[r].items.splice(g,0,d),c=!0
break}}c||n[r].items.push(d)}for(var o in n)gmLhb.details[a].items.push(n[o])
gmLhb.dStatus=0},function(){gmLhb.dStatus=2,iToasts.show("获取龙虎榜详细信息出错！",!0)})}},gmLhb.getLhbListFromSina=function(e){gmLhb.lhbQueue=[],gmLhb.details={}
var t="http://vip.stock.finance.sina.com.cn/q/go.php/vInvestConsult/kind/lhb/index.phtml?tradedate="+e,i=new jAjax
i.binary_get(t,function(t){for(var i=new Buffer(t),a=iconv.decode(i,"gbk"),n=/showDetail\(\'(\d+)\',\'(\d+)\',\'([0-9\-]+)\',this\)/g;ms=n.exec(a);){var o=ms[1],s=ms[2],r=e.replace(/\-/g,"")
void 0===gmLhb.details[r]&&(gmLhb.details[r]={day:r,stocks:[],items:[]}),-1==gmLhb.details[r].stocks.indexOf(s)&&gmLhb.details[r].stocks.push(s),gmLhb.lhbQueue.push({day:e,code:s,reason:o})}return 0==gmLhb.lhbQueue.length?void iToasts.show("未找到相关数据，请稍后重试",!1):(iToasts.show("已成功获取所有龙虎榜股票列表，共 "+gmLhb.lhbQueue.length+" 只，开始获取详细信息",!1),void(gmLhb.timer=setInterval(function(){gmLhb.dStatus=0,gmLhb.getDetailsFromSina()},100)))},function(){iToasts.show("获取龙虎榜信息时出现错误",!0)})},gmLhb.getDetailsFromSina=function(){var btn=$("btnUpdateLhbInfo")
if(gmLhb.lhbQueue.length<1&&0==gmLhb.dStatus){enableButton(btn),clearInterval(gmLhb.timer),iDlgs.show("系统提示","已成功更新指定时间段的龙虎榜资料！",!1)
for(var index in gmLhb.details){var filename=gLhbDaysFolder+"/"+index+".txt"
saveObjectToFile(gmLhb.details[index],filename)}return void gmLhb.listDay()}if(gmLhb.lhbQueue.length<1&&2==gmLhb.dStatus)return enableButton(btn),void clearInterval(gmLhb.timer)
if(!(gmLhb.dStatus>0)){gmLhb.dStatus=1
var sd=gmLhb.lhbQueue.pop(),stocklhburl="http://vip.stock.finance.sina.com.cn/q/api/jsonp.php/var%20details=/InvestConsultService.getLHBComBSData?symbol="+sd.code+"&tradedate="+sd.day+"&type="+sd.reason,ajax=new jAjax
ajax.binary_get(stocklhburl,function(d){var dd=new Buffer(d),ddutf=iconv.decode(dd,"gbk")
if(eval(ddutf),"undefined"==typeof details)return iToasts.show("error"),void(gmLhb.dStatus=2)
var xqday=sd.day.replace(/\-/g,"")
void 0===gmLhb.details[xqday]&&(gmLhb.details[xqday]={day:xqday,stocks:[],items:[]})
for(var name=gmAllStocks.getName(sd.code),stocklhb={code:sd.code,name:name,reason:sd.reason,items:[]},b=0;b<details.buy.length;b++)stocklhb.items.push(["B",b+1,details.buy[b].comName,parseFloat(details.buy[b].buyAmount).toFixed(2),parseFloat(details.buy[b].sellAmount).toFixed(2)])
for(var b=0;b<details.sell.length;b++)stocklhb.items.push(["S",b+1,details.sell[b].comName,parseFloat(details.sell[b].buyAmount).toFixed(2),parseFloat(details.sell[b].sellAmount).toFixed(2)])
gmLhb.details[xqday].items.push(stocklhb),gmLhb.dStatus=0},function(){gmLhb.dStatus=2,iToasts.show("获取龙虎榜详细信息出错！",!0)})}},gmLhb.showStockLhb=function(e){if(void 0!==gmLhb.lhbday.items){for(var t="",i=0,a=0,n=0;n<gmLhb.lhbday.items.length;n++){var o=gmLhb.lhbday.items[n]
if(o.code==e){var s="",r=gmLhb.qqLhbReason[o.reason]
if(r.indexOf("三")>=0){if(a>0)continue
a++}else{if(i>0)continue
i++}for(var l=0,d=0,c=0,g=0,u=0;u<o.items.length;u++){var h=o.items[u][0],m=(o.items[u][1],o.items[u][2]),p=o.items[u][3],f=o.items[u][4],y=100*p/o.hq.amount,v=100*f/o.hq.amount
l+="B"==h?p:0,d+="S"==h?f:0,c+="B"==h?p:0,g+="S"==h?f:0,p=gmLhb.friendlyAmount(p),f=gmLhb.friendlyAmount(f)
var b=gmLhb.getYouziByApartment(m)
b=jSubString(b,8,!1),b=empty(b)?"":"<span style='border:2px solid red; color:red; padding:1px 2px;'>"+b+"</span>"
var x="B"==h?"background:rgb(252,157,154); color:rgb(3,101,100);":"background:rgb(200,200,169); color:rgb(3,101,100);"
s+="<tr style='"+x+"'><td>"+m+b+"</td><td>"+p+"</td><td>"+y.toFixed(2)+"%</td><td>"+f+"</td><td>"+v.toFixed(2)+"%</td></tr>"}var _=empty(o.hq.turnrate)?"":" 换手率："+o.hq.turnrate.toFixed(2)+"% ",L=empty(o.hq.pchg)?"":" "+o.hq.pchg.toFixed(2)+"% "
t+="<p style='text-align:center;'><b>"+o.code+" "+o.name+L+"</b>（"+r+"）<br>总成交额："+gmLhb.friendlyAmount(o.hq.amount)+_+"<span style='color:red'> 买入："+gmLhb.friendlyAmount(c)+"</span> <span style='color:cyan'> 卖出："+gmLhb.friendlyAmount(g)+"</span> <span style='color:red'> 买入占比："+(100*l/o.hq.amount).toFixed(2)+"%</span> <span style='color:cyan'>卖出占比："+(100*d/o.hq.amount).toFixed(2)+"%</span></p><table class='gridtable' style='margin:10px auto; width:100%;'><tr><th>营业部</th><th>买入</th><th>占比</th><th>卖出</th><th>占比</th></tr>"+s+"</table>"}}var k=$("frmLhbDetails")
k.style.border=gmLhb.lockStockDisplay?"2px solid #f00":"2px solid #333"
var T=600,w="<div style='position:absolute;right:0;top:0;width:30px;height:30px;line-height:30px;text-align:center;color:#fff;cursor:pointer;' title='关闭并取消锁定' onclick='gmLhb.unlockLhbDisplay()'>X</div>"
k.innerHTML=w+t+"<p style='text-align:center;'>按CTRL+ALT+A可用QQ截屏</p>",k.style.display="block"
var F
F=window.innerWidth/2>event.clientX?event.clientX+20:event.clientX-T-40
var S=event.clientY
S+k.clientHeight>window.innerHeight&&(S=window.innerHeight-k.clientHeight,S=30>S?30:S),k.style.top=S+"px",k.style.left=F+"px",k.style.width=T+"px"}},gmLhb.showStockLhb2=function(e){if(void 0!==gmLhb.lhbday.items){for(var t="",i=0;i<gmLhb.lhbday.items.length;i++){var a=gmLhb.lhbday.items[i]
if(a.code==e){for(var n="",o=gmLhb.qqLhbReason[a.reason],s=0;s<a.items.length;s++){var r=a.items[s][0],l=(a.items[s][1],a.items[s][2]),d=a.items[s][3],c=a.items[s][4]
d=gmLhb.friendlyAmount(d),c=gmLhb.friendlyAmount(c)
var g="B"==r?"background:rgb(252,157,154); color:rgb(3,101,100);":"background:rgb(200,200,169); color:rgb(3,101,100);"
n+="<tr style='"+g+"'><td>"+l+"</td><td>"+d+"</td><td>"+c+"</td></tr>"}t+="<p style='text-align:center;'><b>"+a.name+"</b>（"+o+"）</p><table class='gridtable' style='margin:10px auto; width:100%;'><tr><th>营业部</th><th>买入</th><th>卖出</th></tr>"+n+"</table>"}}var u=$("frmLhbDetails"),h=600
u.innerHTML=t+"<p style='text-align:center;'>按CTRL+ALT+A可用QQ截屏</p>",u.style.display="block"
var m
m=window.innerWidth/2>event.clientX?event.clientX+20:event.clientX-h-20
var p=event.clientY
p+u.clientHeight>window.innerHeight&&(p=window.innerHeight-u.clientHeight,p=30>p?30:p),u.style.top=p+"px",u.style.left=m+"px",u.style.width=h+"px"}},gmLhb.toggleLockLhbDisplay=function(){gmLhb.lockStockDisplay=!gmLhb.lockStockDisplay
var e=$("frmLhbDetails")
e.style.border=gmLhb.lockStockDisplay?"2px solid #f00":"2px solid #333"},gmLhb.unlockLhbDisplay=function(){gmLhb.lockStockDisplay=!1,$("frmLhbDetails").style.display="none"},gmLhb.hideStockLhb=function(){gmLhb.lockStockDisplay||($("frmLhbDetails").style.display="none")},gmLhb.friendlyAmount=function(e){var t=parseInt(e)
return isNaN(t)?0:t>1e8?(t/1e8).toFixed(2)+"亿":t>1e6?Math.round(t/1e4)+"万":(t/1e4).toFixed(2)+"万"},gmLhb.screenshot=function(){empty(gmLhb.jsmind)||gmLhb.jsmind.screenshot.shootDownload()},gmLhb.listDay_v2=function(){var e=$("lhblistday").value,t=$("lhblistday").value.replace(/\-/g,"")
if(8==t.length){var i=gLhbDaysFolder+"/"+t+".txt"
if(gmLhb.lhbday=readObjectFromFile(i),void 0===gmLhb.lhbday.day){var a=new Date($("lhblistday").value.replace(/\-/g,"/"))
return 0==a.getDay()||6==a.getDay()?void iToasts.show("非交易日",!1):$("lhblistday").value==(new Date).format("yyyy-MM-dd")&&(new Date).getHours()<16?void iToasts.show("请于16:30后查询当日龙虎榜数据",!1):void gmLhb.getLhbDataFromSina("dc")}gmLhb.lhbShown=!0
for(var n="",o="",s="",r="",l=0;l<gmLhb.lhbday.stocks.length;l++){for(var d=gmLhb.lhbday.stocks[l],c=gmAllStocks.getName(d),g="",u="",h=0;h<gmLhb.lhbday.items.length;h++){var m=gmLhb.lhbday.items[h]
if(m.code==d&&void 0!==m.hq.zf){var p=parseFloat(m.hq.zf)
u=p>=0?"style='background:#d9534f;'":"style='background:darkcyan;'",g=" "+p.toFixed(2)+"%"
break}}var f="<div onmouseover='gmLhb.showStockLhb(\""+d+"\")' onmouseout='gmLhb.hideStockLhb()'  onclick='gmLhb.toggleLockLhbDisplay()' ondblclick='openurl(\"http://data.eastmoney.com/stock/lhb,"+e+","+d+".html\")' class='lhbsbtn' "+u+">"+d+" "+c+g+"</div>"
if("6"==d.substr(0,1))n+=f
else switch(d.substr(0,3)){case"000":s+=f
break
case"002":o+=f
break
default:r+=f}}$("divLhbStockList").innerHTML=n+s+o+r+"<div style='clear:both;'></div>"
var y={meta:{name:t+"大大游资龙虎榜",author:"大大游资复盘工具",version:"4.0"},format:"node_array",data:[{id:"lhbroot",isroot:!0,topic:"<div class='jsmind_root'>"+gConfig.cfgLhbUserName+"<br>大大游资复盘工具<br>"+e+"</div>"},{id:"sub1",parentid:"root",topic:"<div class='jsmind_sub1'>成都帮</div>"},{id:"sub11",parentid:"sub1",topic:"<div class='jsmind_sub2_b'>赛摩电气+6089万</div>"},{id:"sub12",parentid:"sub1",topic:"<div class='jsmind_sub2_s'>徐家汇-4800万</div>"},{id:"sub13",parentid:"sub1",topic:"<div class='jsmind_sub2_b'>南方航空+1.69亿</div>"}]},v={container:"divLhbApartmentList",editable:!1,theme:"dada",view:{hmargin:20,vmargin:10,line_width:1,line_color:"#666"},layout:{hspace:20,vspace:10,pspace:13}},b=0,x=0,_=""+gmTcgl.getGroupId(),L=gmLhb.yzListAndDetails[gmLhb.groupId].fPlans[gmLhb.yzListAndDetails[gmLhb.groupId].currentFPlan]
for(var k in L){var T=L[k],w=void 0===gmLhb.yzListAndDetails[gmLhb.groupId].yzItems[T]?{ShortName:"",Apartments:"",YzId:"0",ModifyTime:"",NickName:""}:gmLhb.yzListAndDetails[gmLhb.groupId].yzItems[T],F=b>=x?"right":"left"
y.data.push({id:"lhbam"+k,parentid:"lhbroot",direction:F,topic:"<div class='jsmind_sub1' ondblclick='gmLhb.modifyYzDetails(this, \""+T+"\")'>"+w.ShortName+"</div>"})
for(var l=0;l<gmLhb.lhbday.items.length;l++)for(var m=gmLhb.lhbday.items[l],S=0;S<m.items.length;S++){var A=m.items[S][0],C=(m.items[S][1],m.items[S][2]),D=m.items[S][3],z=m.items[S][4],I=""
if(gConfig.cfgLhbShowTicai){var M=void 0===gmTcgl.publicGnxx[_].items[m.code]?{gn:"",xx:"",user:"",mt:"0"}:gmTcgl.publicGnxx[_].items[m.code]
I=""==M.gn?"":"<span style='color:#ccc;'>("+M.gn+")</span>"}if(!("B"==A&&1e6>D||"S"==A&&1e6>z||(C=C.replace(/\d/g,""),null==w.Apartments.match(RegExp(C+"\\s"))))){var H="";("070005"==m.reason||"070006"==m.reason||"070007"==m.reason||"070008"==m.reason||"05"==m.reason||"06"==m.reason||"07"==m.reason||"08"==m.reason||"005"==m.reason||"006"==m.reason||"007"==m.reason||"008"==m.reason||"041"==m.reason||"042"==m.reason)&&(H="[3日]"),I+=H
var q=""
"B"==A?(D=gmLhb.friendlyAmount(D),q="<div class='jsmind_sub2_b'  onclick='gmLhb.toggleLockLhbDisplay()' ondblclick='openurl(\"http://data.eastmoney.com/stock/lhb,"+e+","+m.code+".html\")' onmouseover='gmLhb.showStockLhb(\""+m.code+"\")' onmouseout='gmLhb.hideStockLhb()' class='lhbbuy'>"+m.name+"+"+D+I+"</div>"):(z=gmLhb.friendlyAmount(z),q="<div class='jsmind_sub2_s' onclick='gmLhb.toggleLockLhbDisplay()' ondblclick='openurl(\"http://data.eastmoney.com/stock/lhb,"+e+","+m.code+".html\")' onmouseover='gmLhb.showStockLhb(\""+m.code+"\")' onmouseout='gmLhb.hideStockLhb()' class='lhbsell'>"+m.name+"-"+z+I+"</div>"),"right"==F?x++:b++
var j=!1
for(var G in y.data)if(y.data[G].parentid=="lhbam"+k&&y.data[G].topic==q){j=!0
break}j||y.data.push({id:"lhb"+k+"_"+l+"_"+S,bs:A,code:m.code,parentid:"lhbam"+k,topic:q})}}"right"==F?x++:b++}var O=$("divLhbApartmentList")
O.style.height="600px",O.style.width="600px",gmLhb.jsmind=empty(gmLhb.jsmind)?new jsMind(v):gmLhb.jsmind,gmLhb.jsmind.show(y),O.style.height=O.firstChild.lastChild.clientHeight+30+"px",O.style.width=O.firstChild.lastChild.clientWidth+30+"px"}},gmLhb.getYouziByApartment=function(e){var t=gmLhb.yzListAndDetails[gmLhb.groupId].fPlans[gmLhb.yzListAndDetails[gmLhb.groupId].currentFPlan]
for(var i in t){var a=t[i],n=void 0===gmLhb.yzListAndDetails[gmLhb.groupId].yzItems[a]?{ShortName:"",Apartments:"",YzId:"0",ModifyTime:"",NickName:""}:gmLhb.yzListAndDetails[gmLhb.groupId].yzItems[a]
if(null!=n.Apartments.match(RegExp(e+"\\s")))return n.ShortName}return""},gmLhb.listDay=function(){return void gmLhb.listDay_v2()},gmLhb.removeApartment=function(e){iDlgs.confirm("系统提示","确定要删除该游资吗？",function(){gmLhb.apartment=gConfig.cfgLhbyouzi?gmLhb.publicApartment:gmLhb.privateApartment,""!=e&&e in gmLhb.apartment&&(delete gmLhb.apartment[e],saveObjectToFile(gmLhb.apartment,gLhbApartmentFile),$("frmModifyLhbApartment").style.display="none",gmLhb.listDay(),iToasts.show("已更新游资信息",!1))},function(){})},gmLhb.addApartment=function(){gmLhb.modifyApartment("")},gmLhb.modifyApartment=function(e){gmLhb.apartment=gConfig.cfgLhbyouzi?gmLhb.publicApartment:gmLhb.privateApartment
var t={}
""!=e&&e in gmLhb.apartment?(t=gmLhb.apartment[e],$("modifyLhbTitle").innerHTML="修改游资信息："+t.lhbaname):(e=(new Date).Format("yyyyMMddhhmmss"),$("modifyLhbTitle").innerHTML="添加需要跟踪的游资"),$("frmModifyLhbApartment").style.display="block",$("modify_lhbaname").value=void 0===t.lhbaname?"":t.lhbaname,$("modify_lhbastyle").value=void 0===t.lhbastyle?"":t.lhbastyle,$("modify_lhbapartments").value=void 0===t.lhbapartments?"":t.lhbapartments,$("lhb_modify_confirm").onclick=function(){return gConfig.cfgLhbyouzi?void iDlgs.show("系统提示","您当前使用的是共享版游资席位，无法添加和修改。请选择自定义版来添加个修改"):void iDlgs.confirm("修改游资席位","确定要修改该游资的席位资料吗？",function(){t.lhbaname=$("modify_lhbaname").value,t.lhbastyle=$("modify_lhbastyle").value,t.lhbapartments=$("modify_lhbapartments").value
var i=RegExp("\n$")
i.test(this)||(t.lhbapartments+="\n"),$("frmModifyLhbApartment").style.display="none",gmLhb.apartment[e]=t,saveObjectToFile(gmLhb.apartment,gLhbApartmentFile),iToasts.show("已保存跟踪游资信息",!1)},function(){})},$("lhb_modify_remove").onclick=function(){gmLhb.removeApartment(e)}},gmLhb.showLhbMind=function(e){$("btnLhbshowAptsAndGroup").style.backgroundColor="#09c",$("btnLhbshowLhbMind").style.backgroundColor="#28B5D6",$("divLhbYzDetailsAndGroup").style.display="none",$("divLhbApartmentList").style.display="block",gmLhb.listDay()},gmLhb.showAptsAndGroup=function(){$("btnLhbshowLhbMind").style.backgroundColor="#09c",$("btnLhbshowAptsAndGroup").style.backgroundColor="#28B5D6",$("divLhbYzDetailsAndGroup").style.display="block",$("divLhbApartmentList").style.display="none",void 0===gmLhb.yzListAndDetails[gmLhb.groupId].fPlans[gmLhb.yzListAndDetails[gmLhb.groupId].currentFPlan]&&(gmLhb.yzListAndDetails[gmLhb.groupId].currentFPlan="全部游资")
var e=$("divLhbFPlans")
e.innerHTML=""
for(id in gmLhb.yzListAndDetails[gmLhb.groupId].fPlans){var t=document.createElement("div")
if(t.className="lhbyzli",t.setAttribute("fpid",id),t.innerHTML='<input type="radio" name="lhbyzfollow" onclick="gmLhb.changeCurrentFPlan(this)"/>'+id+'<span class="minbtn"  onclick="gmLhb.removeFollowPlan(this)">删除</span>',e.appendChild(t),id==gmLhb.yzListAndDetails[gmLhb.groupId].currentFPlan){var i=document.querySelector('#divLhbFPlans div[fpid="'+id+'"] input')
empty(i)||(i.checked=!0,t.className="lhbyzliselected")}}e=$("divLhbYzList"),e.innerHTML=""
for(id in gmLhb.yzListAndDetails.yzList){var a=gmLhb.yzListAndDetails.yzList[id],n=void 0===gmLhb.yzListAndDetails[gmLhb.groupId].yzItems[a.YzId]?{YzId:"0",ModifyTime:"",NickName:""}:gmLhb.yzListAndDetails[gmLhb.groupId].yzItems[a.YzId],t=document.createElement("div")
if(t.className="lhbyzli",t.setAttribute("yzid",a.YzId),t.innerHTML='<span class="lhbyzlititle">'+a.Name+'</span> <span class="time">'+n.NickName+'</span><br><input type="checkbox" onchange="this.parentElement.className=this.checked?\'lhbyzliselected\':\'lhbyzli\'"/>关注<span class="minbtn" onclick="gmLhb.modifyYzDetails(this)"/>修改</span><span class="minbtn" onclick="gmLhb.deleteYzDetailsToServer(this)">删除</span> <span class="time">'+n.ModifyTime+"</span>",e.appendChild(t),gmLhb.yzListAndDetails[gmLhb.groupId].fPlans[gmLhb.yzListAndDetails[gmLhb.groupId].currentFPlan].indexOf(a.YzId)>-1){var i=document.querySelector('#divLhbYzList div[yzid="'+a.YzId+'"] input')
empty(i)||(i.checked=!0,t.className="lhbyzliselected")}}},gmLhb.changeCurrentFPlan=function(e){var t=e.parentElement.getAttribute("fpid")
gmLhb.yzListAndDetails[gmLhb.groupId].currentFPlan=t,saveObjectToFile(gmLhb.yzListAndDetails,gLhbDetailsFile),gmLhb.showAptsAndGroup()},gmLhb.saveFollowPlan=function(e){var t=e
void 0===e&&(t=document.querySelector('#divLhbFPlans input[type="radio"]:checked').parentElement.getAttribute("fpid")),gmLhb.yzListAndDetails[gmLhb.groupId].currentFPlan=t
var i=document.querySelectorAll('#divLhbYzList input[type="checkbox"]:checked')
gmLhb.yzListAndDetails[gmLhb.groupId].fPlans[t]=[]
for(var a=0;a<i.length;a++){var n=i[a].parentElement.getAttribute("yzid")
gmLhb.yzListAndDetails[gmLhb.groupId].fPlans[t].push(n)}saveObjectToFile(gmLhb.yzListAndDetails,gLhbDetailsFile),iToasts.show("数据已保存",!1)},gmLhb.addFollowPlan=function(){iDlgs.confirm("另存关注方案","请输入新的关注方案名称：<input type='text' id='iptNewFPName' style='border:1px solid #666;'/>",function(){if(checkField("iptNewFPName",2,32,"请输入方案名称（2-12字）")){var e=$("iptNewFPName").value
gmLhb.saveFollowPlan(e),gmLhb.showAptsAndGroup()}},function(){})},gmLhb.removeFollowPlan=function(e){var t=e.parentElement.getAttribute("fpid")
iDlgs.confirm("系统提示","确定要删除该关注方案["+t+"]吗？",function(){delete gmLhb.yzListAndDetails[gmLhb.groupId].fPlans[t],gmLhb.showAptsAndGroup()},function(){})},gmLhb.modifyYzDetails=function(e,t){var i=empty(t)?0:t
i=empty(i)?e.parentElement.getAttribute("yzid"):i
var a=void 0===gmLhb.yzListAndDetails[gmLhb.groupId].yzItems[i]?{ShortName:"",Description:"",Apartments:""}:gmLhb.yzListAndDetails[gmLhb.groupId].yzItems[i],n=""
for(id in gmLhb.yzListAndDetails.yzList){var o=gmLhb.yzListAndDetails.yzList[id]
if(o.YzId==i){n=o.Name
break}}$("modifyLhbTitle").innerHTML=n,$("frmModifyLhbApartment").style.display="block",$("modify_lhbaname").value=a.ShortName,$("modify_lhbastyle").value=a.Description,$("modify_lhbapartments").value=a.Apartments,$("lhb_modify_confirm").onclick=function(){iDlgs.confirm("修改游资席位","确定要修改该游资的席位资料吗？",function(){var e=$("modify_lhbaname").value,t=$("modify_lhbastyle").value,a=$("modify_lhbapartments").value
gmLhb.updateYzDetailsToServer(i,e,t,a),$("frmModifyLhbApartment").style.display="none"},function(){})}},gmLhb.getYzListFromServer=function(){var e={act:"lhbyzlist"},t=new iAjax
t.get(gdadalhburl,e,function(e){0==e.error?(gmLhb.yzListAndDetails.yzList=e.items,iToasts.show("已从服务器获取"+e.items.length+"位游资信息",!1),gmLhb.showAptsAndGroup()):iToasts.show("获取游资列表失败",!0)})},gmLhb.addYzToServer=function(){iDlgs.confirm("申请添加新游资","请输入新的游资名称：<input type='text' id='iptNewYzName' style='border:1px solid #666;'/>",function(){if(checkField("iptNewYzName",2,64,"请输入游资名称（2-30字）")){var e=$("iptNewYzName").value,t={act:"lhbyzadd",yzname:e},i=new iAjax
i.get(gdadalhburl,t,function(e){0==e.error?(iToasts.show("添加游资成功（等待管理员审核）",!1),gmLhb.getYzListFromServer()):iToasts.show("申请添加游资失败",!0)})}},function(){})},gmLhb.getYzDetailsFromServer=function(){var e={act:"lhbyzdlist",groupId:gmLhb.groupId,lastUpdateTime:gmLhb.yzListAndDetails[gmLhb.groupId].lastUpdateTime},t=new iAjax
t.get(gdadalhburl,e,function(e){if(0==e.error){for(var t=0;t<e.items.length;t++){var i=e.items[t]
gmLhb.yzListAndDetails[gmLhb.groupId].yzItems[i.YzId]=i}gmLhb.yzListAndDetails[gmLhb.groupId].lastUpdateTime=(new Date).Format("yyyy-MM-dd hh:mm:ss"),iToasts.show("已从服务器获取"+e.items.length+"条新的游资席位信息",!1),saveObjectToFile(gmLhb.yzListAndDetails,gLhbDetailsFile)}else iToasts.show("获取游资席位资料失败",!0)})},gmLhb.updateYzDetailsToServer=function(e,t,i,a){"\n"!=a.substr(a.length-1,1)&&(a+="\n")
var n={act:"lhbyzdupdate",yzid:e,sname:t,desc:i,apts:a},o=new iAjax
o.get(gdadalhburl,n,function(e){0==e.error?(iToasts.show("修改游资席位信息成功",!1),gmLhb.getYzDetailsFromServer()):iToasts.show("更新游资席位信息失败",!0)})},gmLhb.deleteYzDetailsToServer=function(e){e.disabled||iDlgs.confirm("系统提示","确定要删除该游资席位信息吗？注意，只能删除自己更新的数据。",function(){disableButton(e)
var t=e.parentElement.getAttribute("yzid"),i={act:"lhbyzdremove",yzid:t},a=new iAjax
a.get(gdadalhburl,i,function(t){enableButton(e),0==t.error?(iToasts.show("删除游资席位信息成功",!1),gmLhb.getYzDetailsFromServer()):iToasts.show("删除游资席位信息失败",!0)},function(){enableButton(e)})},function(){})}
var _DEBUG_=!1,_DINGZHI_1=!1,liveValues={},getLiveValuesthreadCount=0,getLiveValuesIndex=0,liveValuesDayfile,isLoadFromLocal=!1,realGetLiveValues=function(e){if(getLiveValuesthreadCount=0,parseInt((new Date).Format("yyyyMMdd"))==getLastTradeDay()&&parseInt((new Date).Format("hhmm"))<930)return void iToasts.show("尚未开市",!1)
var t=tdxFolder+"/T0002/blocknew/ZXG.blk"
t=_DEBUG_?tdxFolder+"/T0002/blocknew/ALLA.blk":hex.applicationDirectoryPath+"/data/ALLA.blk"
var i=fs.readFileSync(t,{encoding:"utf8"}),a=i.split("\r\n")
initLiveValues(),getLiveValuesIndex=a.length
var n=setInterval(function(){if(!(getLiveValuesthreadCount>10)){if(getLiveValuesIndex--,0>getLiveValuesIndex)return void clearInterval(n)
var t=a[getLiveValuesIndex]
if(7==t.length){var i="0"==t.substr(0,1)?"sz"+t.substr(1):"sh"+t.substr(1)
getLiveValuesthreadCount++,parseInt(e)==getLastTradeDay()?getLiveMinline(i):getHistoryMinline(e,i)}}},100)},getLiveNews=function(e){var t=new jAjax,a="http://api3.finance.ifeng.com/live/getlist?level=1&dist=1&page="+e
strdata="",t.json_get(a,function(e){var t=null
try{t=JSON.parse(e)}catch(a){}if(null==t)return void iToasts.show("解析错误",!0)
var n="<table class='gridtable' style='width:1000px;background:#f0f0f0; padding:10px; margin:10px auto;'>"
for(i in t.data){var o=t.data[i]
n+="<tr style='background:#fff;color:#f22a2a;font-weight:bold;'><td style='width:150px;color:#999;font-size:14px;'>"+new Date(1e3*o.time).Format("yyyy-MM-dd hh:mm:ss")+"</td><td style='text-align:left;line-height:25px;color:#666;font-size:16px;'>"+o.title+"</td></tr>"}n+="</table>",$("liveNews").innerHTML=n},function(){iToasts.show("联网失败",!0)})},gmSelector=function(e,t){},gmTcgl={}
gmTcgl.queryHistoryCache=[],gmTcgl.init=function(){gmTcgl.currentTab=$("tcglTabZTG"),gmTcgl.currentTab2=$("tcglTab2List"),gmTcgl.publicGnxx=readObjectFromFile(gPublicGnxxFile),gmTcgl.publicHS=readObjectFromFile(gPublicHSFile),gmTcgl.publicHSTDX=readObjectFromFile(gPublicHSTDXFile),gmTcgl.publicTCS=readObjectFromFile(gPublicTCSFile),gmTcgl.publicTHSZT=readObjectFromFile(gPublicTHSZTFile),gmTcgl.updateZJGX(),gmTcgl.changeTab(gmTcgl.currentTab)},gmTcgl.onkeydown=function(){13==event.keyCode&&gmTcgl.query()},gmTcgl.changeTab=function(e){switch(gmTcgl.currentTab.className="tab",gmTcgl.currentTab=e,gmTcgl.currentTab.className="tabselected",$("divTcglHistory").style.display="none",e.getAttribute("id")){case"tcglTabHistory":$("divTcglHistory").style.display="block"
break
case"tcglTabZJGX":gmTcgl.list(gmTcgl.listZJGX)
break
case"tcglTabZXG":gmTcgl.list(gmGuxing.zxgCache),gmTcgl.drawMind(gmGuxing.zxgCache,"大大游资自选股导图")
break
case"tcglTabZTG":gmGuxing.loadTdxBlocks(),gmTcgl.list(gmGuxing.ztgCache),gmTcgl.drawMind(gmGuxing.ztgCache,"大大游资涨停股导图")
break
case"tcglTabKBG":gmTcgl.list(gmGuxing.kbgCache),gmTcgl.drawMind(gmGuxing.kbgCache,"大大游资开板股导图")}},gmTcgl.showMind=function(){"block"==$("divTcglMindList").style.display?($("divTcglMindList").style.display="none",$("tabletcgl").style.display="block",$("btnTcglShowMind").innerHTML="绘制思维导图",$("btnTcglShowMind").style.backgroundColor="crimson"):($("divTcglMindList").style.display="block",$("tabletcgl").style.display="none",$("btnTcglShowMind").innerHTML="关闭思维导图",$("btnTcglShowMind").style.backgroundColor="darkcyan","tcglTabZTG"==gmTcgl.currentTab.getAttribute("id")?gmTcgl.drawMind(gmGuxing.ztgCache,"大大游资涨停股导图"):"tcglTabKBG"==gmTcgl.currentTab.getAttribute("id")?gmTcgl.drawMind(gmGuxing.kbgCache,"大大游资开板股导图"):"tcglTabZXG"==gmTcgl.currentTab.getAttribute("id")&&gmTcgl.drawMind(gmGuxing.zxgCache,"大大游资自选股导图"))},gmTcgl.screenshot=function(){empty(gmTcgl.jsmind)||gmTcgl.jsmind.screenshot.shootDownload()},gmTcgl.changeTab2=function(e){switch(gmTcgl.currentTab2.className="tab",gmTcgl.currentTab2=e,gmTcgl.currentTab2.className="tabselected",e.getAttribute("id")){case"tcglTab2List":$("divTcglMindList").style.display="none",$("tabletcgl").style.display="block"
break
case"tcglTab2Mind":$("divTcglMindList").style.display="block",$("tabletcgl").style.display="none","tcglTabZTG"==gmTcgl.currentTab.getAttribute("id")?gmTcgl.drawMind(gmGuxing.ztgCache):"tcglTabKBG"==gmTcgl.currentTab.getAttribute("id")&&gmTcgl.drawMind(gmGuxing.kbgCache)}},gmTcgl.updateZJGX=function(e){maxCount=e||100,gmTcgl.listZJGX=[]
var t=gmTcgl.getGroupId(),i=gmTcgl.publicGnxx[""+t].items
for(var a in i){for(var n=i[a],o=!1,s=0;s<gmTcgl.listZJGX.length;s++){var r=gmTcgl.listZJGX[s],l=void 0===i[r]?{gn:"",xx:"",user:""}:i[r]
if(void 0!==n.mt&&(void 0===l.mt||n.mt>l.mt)){gmTcgl.listZJGX.splice(s,0,a),o=!0
break}}o||gmTcgl.listZJGX.push(a)}gmTcgl.listZJGX.splice(maxCount,1e4)},gmTcgl.getGroupId=function(){var e=0
return null==userinfo?e=0:1==gConfig.cfgGltcType?e=userinfo.UserId:2==gConfig.cfgGltcType&&(e=gConfig.cfgGltcGroupId),void 0===gmTcgl.publicGnxx[""+e]&&(gmTcgl.publicGnxx[""+e]={lastUpdateTime:"2017-01-01",items:{}}),e},gmTcgl.listTcgl=function(e){if(null==userinfo)return void popuplist.push("divuserlogin")
if(!checkvuser())return void popuplist.push("divuserbindsn")
if(!e.disabled){disableButton(e)
var t=new iAjax,i=""+gmTcgl.getGroupId(),a="2017-01-01"
void 0!==gmTcgl.publicGnxx[i]&&(a=gmTcgl.publicGnxx[i].lastUpdateTime)
var n={act:"listTcgl",groupId:i,lastUpdateTime:a}
t.get(gdadaurl,n,function(t){if(enableButton(e),0==t.error&&t.items.length>0){gmTcgl.publicGnxx[i].lastUpdateTime=(new Date).Format("yyyy-MM-dd hh:mm:ss")
for(var a=0;a<t.items.length;a++){var n=t.items[a],o=void 0===gmTcgl.publicGnxx[i].items[n.Code]?{gn:"",xx:""}:gmTcgl.publicGnxx[i].items[n.Code]
o.gn=n.Ticai,o.xx=n.XiaoXi,o.user=n.NickName,o.mt=n.ModifyTime,o.sd784=n.Sd784,o.sd785=n.Sd785,gmTcgl.publicGnxx[i].items[n.Code]=o}saveObjectToFile(gmTcgl.publicGnxx,gPublicGnxxFile),gmTcgl.changeTab(gmTcgl.currentTab),gmTcgl.updateZJGX(),iToasts.show("已更新 "+t.items.length+" 条题材数据",!1)}else iToasts.show("暂无新题材数据",!1)
gmTcgl.listHotStocks(e)},function(){enableButton(e)})}},gmTcgl.listHotStocks=function(e){disableButton(e)
var t=new iAjax,i={act:"listHotStocks",lastUpdateTime:gConfig.cfgHSLastUpdateTime}
t.get(gdadaurl,i,function(t){if(enableButton(e),0==t.error&&(t.items.length>0||t.tcs.length>0||t.thszt.length>0||t.hstdx.length>0)){for(var i=0;i<t.items.length;i++){var a=t.items[i]
gmTcgl.publicHS[a.day]=a.names}for(var i=0;i<t.hstdx.length;i++){var a=t.hstdx[i]
gmTcgl.publicHSTDX[a.day]=a.names}for(var i=0;i<t.tcs.length;i++){var a=t.tcs[i]
gmTcgl.publicTCS[a.day]=a.ticais}for(var i=0;i<t.thszt.length;i++){var a=t.thszt[i]
gmTcgl.publicTHSZT[a.day]=a.url}gConfig.cfgHSLastUpdateTime=(new Date).addMinutes(-1).Format("yyyy-MM-dd hh:mm:ss"),saveObjectToFile(gConfig,gConfigFile),saveObjectToFile(gmTcgl.publicHS,gPublicHSFile),saveObjectToFile(gmTcgl.publicHSTDX,gPublicHSTDXFile),saveObjectToFile(gmTcgl.publicTCS,gPublicTCSFile),saveObjectToFile(gmTcgl.publicTHSZT,gPublicTHSZTFile),gmFupan.listFupan(),iToasts.show("已更新 "+(t.items.length+t.hstdx.length+t.tcs.length+t.thszt.length)+" 条数据",!1)}else iToasts.show("暂无新数据",!1)},function(){enableButton(e)})},gmTcgl.uploadHotStocks=function(){for(var e=readTextFromFile(gConfig.tdxFolder+"/T0002/blocknew/RQ.blk"),t=e.split("\n"),i=0,a="",n="",o=0;o<t.length;o++)if(8==t[o].length){var s=t[o].substr(1,6),r=gmAllStocks.getName(s)
if(a+=""==a?r:","+r,n+=""==n?s:","+s,i++,i>=10)break}if(i>0){var l=new iAjax,d={act:"uploadHotStocks",stocks:a,codes:n}
l.get(gdadaurl,d,function(e){0==e.error?iToasts.show("success",!1):iToasts.show("failed",!0)},function(){iToasts.show("failed2",!0)})}},gmTcgl.updateTcgl=function(e,t,i,a,n){if(null==userinfo)return void popuplist.push("divuserlogin")
if(!checkvuser())return void popuplist.push("divuserbindsn")
var o=new iAjax,s={act:"updateTcgl",code:e,ticai:t,xiaoxi:i,sd784:a,sd785:n}
o.get(gdadaurl,s,function(e){0==e.error&&e.count>0?iToasts.show("更新成功",!1):iToasts.show("更新失败",!0),gmTcgl.listTcgl($("btnListTcglFromServer"))},function(){iToasts.show("更新失败",!0)})},gmTcgl.query=function(e,t){if(!e.disabled){var i=0,a=0
if("bystock"==t){if(i=$("tcglStockCode").value,6!=i.length)return iToasts.show("请输入要查询的股票的完整代码",!0),void $("tcglStockCode").focus()
$("tcglStockCode").value=""}else a=$("tcglhistorydate").value
disableButton($("btnTcglQueryByDate")),disableButton($("btnTcglQueryByStock"))
var n=new iAjax,o={act:"queryTcgl",code:i,day:a}
n.get(gdadaurl,o,function(e){if(enableButton($("btnTcglQueryByDate")),enableButton($("btnTcglQueryByStock")),0==e.error){iToasts.show("查询成功",!1)
for(var t="<tr style='text-align:center;'><th style='min-width:40px;'>序号</th><th style='min-width:55px;'>代码</th><th style='min-width:60px;'>名称</th><th style='min-width:90px;'>日期</th><th style='min-width:60px;'>涨停时间</th><th style='min-width:60px;'>连板数</th><th style='min-width:150px;'>概念题材</th><th style='max-width:300px;'>重要公告消息</th></tr>",i=0;i<e.items.length;i++){var a=e.items[i],n="00:00:00"==a.zttime?"开板":a.zttime,o="00:00:00"==a.zttime?"#51555f":"09:25:00"==a.zttime?"#616675":"#717682"
t+="<tr style='background:"+o+"'><td>"+(i+1)+"</td><td>"+a.code+"</td><td>"+a.name+"</td><td>"+a.day+"</td><td>"+n+"</td><td>"+a.lb+"</td><td>"+a.ticai+"</td><td>"+a.xiaoxi+"</td></tr>"}$("tabletcglhistory").innerHTML=t}else iToasts.show("无查询结果",!0)},function(){enableButton($("btnTcglQueryByDate")),enableButton($("btnTcglQueryByStock")),iToasts.show("查询失败",!0)})}},gmTcgl.list=function(e){for(var t="<tr style='text-align:center;'><th style='min-width:55px;'>代码</th><th style='min-width:60px;'>名称</th><th style='min-width:100px;'>概念题材</th><th style='max-width:300px;'>重要公告消息</th><th style='min-width:200px;'>自定义数据</th><th style='min-width:90px;'>复盘人</th><th style='width:130px;'>更新时间</th><th style='min-width:50px;'>操作</th></tr>",i=""+gmTcgl.getGroupId(),a=0;a<e.length;a++)if(code=e[a],6==code.length&&(gx=gmGuxing.getGuxing(code),null!=gx)){var n=parseFloat((100*gx.kb/(gx.zt+gx.kb+.01)).toFixed(2)),o=3*gx.lb,s=gx.zt<6?0:20-Math.round(n),r=gx.lt+o+gx.zt+Math.round(gx.ztn.o+gx.ztn.h)+s
r=0>r?1:r
var l="",d=gmAllStocks.getName(code),c=void 0===gmTcgl.publicGnxx[i].items[code]?{gn:"",xx:"",user:"",mt:"0"}:gmTcgl.publicGnxx[i].items[code],g=void 0===c.sd784?"":c.sd784,u=void 0===c.sd785?"":c.sd785
t+="<tr style='"+l+"'><td>"+code+"</td><td>"+d+"</td><td>"+c.gn+"</td><td>"+c.xx+"</td><td>784："+g+"<br>785："+u+"</td><td>"+c.user+"</td><td>"+c.mt+"</td><td><span class='minbtn' onclick='gmTcgl.modifyTicai(\""+code+"\")'>修改</span></td></tr>"}$("tabletcgl").innerHTML=t},gmTcgl.modifyTicai=function(e){var t=""+gmTcgl.getGroupId(),i=void 0===gmTcgl.publicGnxx[t].items[e]?{gn:"",xx:"",mt:"0",user:""}:gmTcgl.publicGnxx[t].items[e]
$("titleModifyTicai").innerHTML="修改个股概念题材："+e,$("frmModifyTicai").style.display="block",$("modify_ticai").value=void 0===i.gn?"":i.gn,$("modify_xiaoxi").value=void 0===i.xx?"":i.xx,$("modify_tdxsd785").value=void 0===i.sd785?"":i.sd785,$("modify_tdxsd784").value=void 0===i.sd784?"":i.sd784,$("modify_ticai").focus(),$("ticai_modify_confirm").onclick=function(){var t=$("modify_ticai").value,a=$("modify_xiaoxi").value,n=$("modify_tdxsd785").value,o=$("modify_tdxsd784").value
return t==i.gn&&a==i.xx&&xt==i.xt&&n==i.sd785&&o==i.sd784?void($("frmModifyTicai").style.display="none"):($("frmModifyTicai").style.display="none",i.gn=t,i.xx=a,i.sd784=o,i.sd785=n,gmTcgl.updateTcgl(e,t,a,o,n),void gmTcgl.changeTab(gmTcgl.currentTab))}},gmTcgl.drawMind=function(e,t){if("none"!=$("divTcglMindList").style.display){var i=gmTdx.getLastTradeDay(),a=new gmTdx.tdxDays("999999")
if(a.length>0){var n=new a.get(a.length-1)
i=n.day}for(var o={meta:{name:i+t,author:"大大游资辅助工具",version:"3.3"},format:"node_array",data:[{id:"tcglroot",isroot:!0,topic:"<div class='jsmind_root'>"+gConfig.cfgLhbUserName+"<br>"+t+"<br>"+i+"</div>"}]},s={container:"divTcglMindList",editable:!1,theme:"dada",view:{hmargin:20,vmargin:10,line_width:1,line_color:"#666"},layout:{hspace:20,vspace:10,pspace:13}},r={},l=0;l<e.length;l++){var d=e[l]
if(6==d.length){var c=gmGuxing.getGuxing(d)
if(null!=c){var g=gmGuxing.getGxValue(c),u=gmAllStocks.getName(d),h=""+gmTcgl.getGroupId(),m=void 0===gmTcgl.publicGnxx[h].items[d]?{gn:"",xx:"",mt:"0",user:""}:gmTcgl.publicGnxx[h].items[d]
if(!empty(m.gn)){var p="",f=new gmTdx.tdxDayMinutes(d,i)
if(240==f.length)for(var y=new Date((new Date).Format("yyyy/MM/dd")+" 09:30:00"),v=0;v<f.length;v++){var b=f.get(v),x=y.Format("hh:mm")
if(gmTdx.isZT(b.high,f.preclose)){p=x,"09:30"==x&&b.open==b.high&&(p="09:25")
break}"11:29"==x&&y.addMinutes(90),y.addMinutes(1)}var _=0,L=0,a=new gmTdx.tdxDays(d)
if(a.length>0){var n=new a.get(a.length-1)
_=n.amount
for(var k=n.close==n.open,T=0,w=a.length-1;w>0;w--){var F=new a.get(w),S=new a.get(w-1)
if(!gmTdx.isRiseLimit(F.close,S.close))break
k=F.high==F.low||S.close/S.open>1.22||F.close/F.open>1.22,T=k?T+1:0,L++}k&&(L-=T)}for(var A=m.gn.split(/[,\s\+]/),C=0;C<A.length;C++){var D=A[C].trim()
if(!(2>D)){empty(r[D])&&(r[D]=[])
for(var z={code:d,name:u,zttime:p,amount:_,gxsum:g,lbcount:L},I=!1,w=0;w<r[D].length;w++){var M=r[D][w]
if(!empty(M.zttime)&&M.zttime>p){r[D].splice(w,0,z),I=!0
break}}I||r[D].push(z)}}}}}}var H=0,q=0,j=0
for(var D in r){var G=r[D]
j++
var O=H>=q?"right":"left"
o.data.push({id:"tcgl_"+j,parentid:"tcglroot",direction:O,topic:"<div class='jsmind_sub1'>"+D+"</div>"})
for(var C=0;C<G.length;C++){var a=G[C],B=0==C?"color:#fff; background:#d9534f;":"color:#fff;background:darkcyan"
C>0&&a.lbcount>=3&&(B="color:#fff;background:darkmagenta")
var E=empty(a.zttime)?"":"/"+a.zttime,N="<div class='jsmind_sub2_b' style='font-size:13px;padding:2px 5px;"+B+"'>"+a.code+" "+a.name+"/"+gmLhb.friendlyAmount(a.amount)+"/"+a.lbcount+"板"+E+"</div>"
o.data.push({id:"tcgl_"+j+"_"+C,parentid:"tcgl_"+j,topic:N}),"right"==O?q++:H++}"right"==O?q++:H++}var R=$("divTcglMindList")
R.style.height="600px",R.style.width="600px",gmTcgl.jsmind=empty(gmTcgl.jsmind)?new jsMind(s):gmTcgl.jsmind,gmTcgl.jsmind.show(o),R.style.height=R.firstChild.lastChild.clientHeight+30+"px",R.style.width=R.firstChild.lastChild.clientWidth+30+"px"
var P=parseInt((window.innerWidth-R.firstChild.lastChild.clientWidth)/2)
R.style.left=P+"px"}}
var gmTdx={}
gmTdx.getLastTradeDay=function(e){var t=new Date
0==t.getDay()&&t.addDays(-2),6==t.getDay()&&t.addDays(-1),e=e||"yyyyMMdd"
var i=t.Format(e)
return i},gmTdx.getPreTradeDay=function(e){var t=new Date
t.addDays(-1),0==t.getDay()&&t.addDays(-2),6==t.getDay()&&t.addDays(-1),e=e||"yyyyMMdd"
var i=t.Format(e)
return i},gmTdx.isZT=function(e,t){if(0==t)return!1
t=Math.round(100*t)
var i=Math.round(1.1*t),a=Math.round(100*e)
return a==i},gmTdx.isRiseLimit=function(e,t){if(0==t)return!1
var i=Math.round(1.1*t)
return Math.round(e)==i},gmTdx.codeToTdxSymbol=function(e){var t=e
return"0"==e.substr(0,1)||"3"==e.substr(0,1)?t="0"+e:("6"==e.substr(0,1)||"8"==e.substr(0,1)||"9"==e.substr(0,1))&&(t="1"+e),t},gmTdx.isFallLimit=function(e,t){if(0==t)return!1
var i=Math.round(.9*t)
return e==i},gmTdx.GetTradeTime=function(){var e=new Date,t=e.getHours(),i=e.getMinutes(),a=parseInt(e.Format("hhmm")),n=0
return a>930&&1300>a?(a>1130&&(t=11,i=30),n=60*(t-9)+i-30):n=a>=1300&&1500>=a?120+60*(t-13)+i:240,n},gmTdx.tdxDays=function(e){var t=32,i=""
"6"==e.substr(0,1)||"9"==e.substr(0,1)||"8"==e.substr(0,1)?i=gConfig.tdxFolder+"/vipdoc/sh/lday/sh"+e+".day":("3"==e.substr(0,1)||"0"==e.substr(0,1))&&(i=gConfig.tdxFolder+"/vipdoc/sz/lday/sz"+e+".day")
var a=null
this.length=0,this.code=e,fs.existsSync(i)&&(a=fs.readFileSync(i),this.length=a.length/t),this.get=function(e){var t=4
this.day=a.readUInt32LE(32*e+0*t),this.open=a.readUInt32LE(32*e+1*t),this.high=a.readUInt32LE(32*e+2*t),this.low=a.readUInt32LE(32*e+3*t),this.close=a.readUInt32LE(32*e+4*t),this.amount=a.readFloatLE(32*e+5*t),this.volume=a.readUInt32LE(32*e+6*t),this.preclose=a.readUInt32LE(32*e+7*t)}},gmTdx.tdxDay=function(e,t){var i=gmTdx.getDayIndex(e,t)
if(i>=0&&i<e.length){var a=new e.get(i)
return a}return{}},gmTdx.getDayIndex=function(e,t){for(var i=1,a=e.length-1;a>=i;){var n=parseInt((i+a)/2),o=new e.get(n)
if(t==o.day)return n
t<o.day?a=n-1:i=n+1}return e.length},gmTdx.tdxMinutes=function(e){var t=32,i=""
"6"==e.substr(0,1)?i=gConfig.tdxFolder+"/vipdoc/sh/minline/sh"+e+".lc1":("3"==e.substr(0,1)||"0"==e.substr(0,1))&&(i=gConfig.tdxFolder+"/vipdoc/sz/minline/sz"+e+".lc1")
var a=this
this.data=null,this.length=0,fs.existsSync(i)&&(this.data=fs.readFileSync(i),this.length=this.data.length/t),this.get=function(e){var t=4,i={},n=a.data.readUInt16LE(32*e),o=Math.floor(n/2048)+2004,s=Math.floor(n%2048/100),r=n%2048%100
return i.day=""+o+("0"+s).substr(-2)+("0"+r).substr(-2),i.startMinutes=a.data.readUInt16LE(32*e+16),i.open=a.data.readFloatLE(32*e+1*t),i.high=a.data.readFloatLE(32*e+2*t),i.low=a.data.readFloatLE(32*e+3*t),i.close=a.data.readFloatLE(32*e+4*t),i.amount=a.data.readFloatLE(32*e+5*t),i.volume=parseInt(a.data.readUInt32LE(32*e+6*t)/100),i.preclose=a.data.readUInt32LE(32*e+7*t),i}},gmTdx.getDayMinutesIndex=function(e,t,i){var a=32
try{var n=fs.fstatSync(e).size/(240*a)}catch(o){return console.log(o.name+o.message),-1}for(var s=1,r=n-1,l=new Buffer(a);r>=s;){var d=parseInt((s+r)/2)
fs.readSync(e,l,0,a,240*d*a)
var c=l.readUInt16LE(0),g=Math.floor(c/2048)+2004,u=Math.floor(c%2048/100),h=c%2048%100,m=""+g+("0"+u).substr(-2)+("0"+h).substr(-2)
if(m==i)return d
m>i?r=d-1:s=d+1}return-1},gmTdx.tdxDayMinutes=function(e,t){var i=this
this.get=function(e){var t=4,a=i.data.readUInt16LE(32*e),n=Math.floor(a/2048)+2004,o=Math.floor(a%2048/100),s=a%2048%100,r={}
return r.day=""+n+("0"+o).substr(-2)+("0"+s).substr(-2),r.startMinutes=i.data.readUInt16LE(32*e+16),r.open=i.data.readFloatLE(32*e+1*t),r.high=i.data.readFloatLE(32*e+2*t),r.low=i.data.readFloatLE(32*e+3*t),r.close=i.data.readFloatLE(32*e+4*t),r.amount=i.data.readFloatLE(32*e+5*t),r.volume=parseInt(i.data.readUInt32LE(32*e+6*t)/100),r.preclose=i.data.readUInt32LE(32*e+7*t),r}
var a=32,n=""
if("6"==e.substr(0,1)||"9"==e.substr(0,1)||"8"==e.substr(0,1)?n=gConfig.tdxFolder+"/vipdoc/sh/minline/sh"+e+".lc1":("3"==e.substr(0,1)||"0"==e.substr(0,1))&&(n=gConfig.tdxFolder+"/vipdoc/sz/minline/sz"+e+".lc1"),this.code=e,this.data=null,this.length=0,this.preclose=0,this.preclose2=0,fs.existsSync(n)){var o=fs.openSync(n,"r"),s=gmTdx.getDayMinutesIndex(o,e,t)
if(-1!=s){var r=241*a,l=new Buffer(r)
fs.readSync(o,l,0,r,(240*s-1)*a),fs.closeSync(o),this.data=l
var d=this.get(0)
this.preclose=d.close,this.data=l.slice(a),this.length=240
var c=this.get(0)
return void(this.open=c.open)}fs.closeSync(o),this.data=null,this.length=0}},gmTdx.getGuxing=function(e){var t=e.length-240
t=1>t?1:t
for(var i=0,a=t;a<e.length;a++){var n=e.get(a),o=new e.get(a-1)
isRiseLimit(n.high,o.close)&&n.high!=n.close&&i++}},gmTdx.addUniqueElement=function(e,t){var i=!1
for(k in e)if(e[k]==t){i=!0
break}i||e.push(t)},gmTdx.getAllStockCodes=function(){var e=gConfig.tdxFolder+"/T0002/hq_cache/base.map"
if(fs.existsSync(e)){for(var t=readTextFromFile(e),i=t.split("\r\n"),a=[],n=0;n<i.length;n++){var o=i[n].trim(),s=o.substr(0,1)
10!=o.length||"0"!=s&&"3"!=s&&"6"!=s||a.push(o.substr(0,6))}a.length>1e3&&(gmTdx.codes=a)}},gmTdx.getAllStocks=function(){var e=[],t=gConfig.tdxFolder+"/T0002/hq_cache/shm.tnf"
if(fs.existsSync(t)){for(var i=fs.openSync(t,"r"),a=fs.fstatSync(i).size,n=(a-50)/314,o=new Buffer(64),s=0;n>s;s++){fs.readSync(i,o,0,32,314*s+50)
var r=o.toString("ascii",0,6),l=o.slice(23,31),d=iconv.decode(l,"gb2312"),c=r.substr(0,2);("00"==c||"30"==c||"60"==c)&&(gmTdx.addUniqueElement(e,r),gmTdx.items[r]={n:d})}fs.closeSync(i)}if(t=gConfig.tdxFolder+"/T0002/hq_cache/szm.tnf",fs.existsSync(t)){for(var i=fs.openSync(t,"r"),a=fs.fstatSync(i).size,n=(a-50)/314,o=new Buffer(64),s=0;n>s;s++){fs.readSync(i,o,0,32,314*s+50)
var r=o.toString("ascii",0,6),l=o.slice(23,31),d=iconv.decode(l,"gb2312"),c=r.substr(0,2);("00"==c||"30"==c||"60"==c)&&(gmTdx.addUniqueElement(e,r),gmTdx.items[r]={n:d})}fs.closeSync(i)}e.length>1e3&&(gmTdx.codes=e)},gmTdx.getBlockInfo=function(){var e={items:{}},t=gConfig.tdxFolder+"/T0002/hq_cache/block_fg.dat"
if(fs.existsSync(t))for(var i=fs.openSync(t,"r"),a=fs.fstatSync(i).size,n=(a-84-302)/2813,o=new Buffer(2813),s=0;n>s;s++){fs.readSync(i,o,0,2813,2813*s+84+302)
var r=o.slice(0,8)
r=iconv.decode(r,"gb2312"),r=r.replace(/\u0000/g,"")
for(var l=o.readUInt16LE(9),d=o.readUInt16LE(11),c={name:r,count:l,level:d,stocks:[]},g=0;l>g;g++){var u=o.toString("ascii",13+7*g,13+7*g+6)
c.stocks.push(u),void 0===e.items[u]&&(e.items[u]={blocks:[]}),e.items[u].blocks.push(r)}}var t=gConfig.tdxFolder+"/T0002/hq_cache/block_gn.dat"
if(fs.existsSync(t))for(var i=fs.openSync(t,"r"),a=fs.fstatSync(i).size,n=(a-84-302)/2813,o=new Buffer(2813),s=0;n>s;s++){fs.readSync(i,o,0,2813,2813*s+84+302)
var r=o.slice(0,8)
r=iconv.decode(r,"gb2312"),r=r.replace(/\u0000/g,"")
for(var l=o.readUInt16LE(9),d=o.readUInt16LE(11),c={name:r,count:l,level:d,stocks:[]},g=0;l>g;g++){var u=o.toString("ascii",13+7*g,13+7*g+6)
c.stocks.push(u),void 0===e.items[u]&&(e.items[u]={blocks:[]}),e.items[u].blocks.push(r)}}var t=gConfig.tdxFolder+"/incon.dat",i=fs.openSync(t,"r"),a=fs.fstatSync(i).size,o=new Buffer(a)
fs.readSync(i,o,0,a,0)
for(var h=iconv.decode(o,"gb2312"),m=readTextFromFile(gConfig.tdxFolder+"/T0002/hq_cache/tdxhy.cfg"),p=m.split("\n"),s=0;s<p.length;s++){var f=p[s]
if(sl=f.split("|"),4==sl.length){var u=sl[1],y=sl[2],v=RegExp(y.substr(0,3)+"\\|(\\S+)","gi")
if(ms=v.exec(h)){var b=ms[1]
if(void 0===e.items[u]&&(e.items[u]={blocks:[]}),e.items[u].blocks.push(b),y.length>4){var v=RegExp(y.substr(0,5)+"\\|(\\S+)","gi")
if(ms=v.exec(h)){var b=ms[1]
if(e.items[u].blocks.push(b),y.length>6){var v=RegExp(y.substr(0,7)+"\\|(\\S+)","gi")
if(ms=v.exec(h)){var b=ms[1]
e.items[u].blocks.push(b)}}}}}}}var x="c:/tdxblock.txt"
saveObjectToFile(e,x)}
var gmTdxConnector={}
gmTdxConnector.init=function(){http.createServer(function(e,t){try{t.writeHeader(200,{"Content-Type":"text/html;charset=utf-8"}),gmTdxConnector.handleRequest(e,t)}catch(i){try{var a="exception"
t.end(a)}catch(i){t.end("exception 2")}}}).listen(8087)},gmTdxConnector.handleRequest=function(e,t){for(var i=url.parse(e.url).query,a=/(\w+)=(\w+)/g,n={};ms=a.exec(i);)n[ms[1]]=ms[2]
if(void 0!==n.act){var o="error"
switch(n.act){case"gx":if(void 0!==n.code){var s=gmGuxing.getGuxing(n.code)
if(null!=s){var r=parseFloat((100*s.kb/(s.zt+s.kb+.01)).toFixed(0)),l=3*s.lb,d=s.lt+l+s.zt+(20-Math.round(r))+Math.round(s.ztn.o+s.ztn.h)
d=0>d?1:d
var c="white"
d>=70?c="red":d>=50?c="lightpink":d>=30&&(c="lightgreen")
var g=gmAllStocks.getName(n.code),u="http://data.eastmoney.com/stock/lhb/"+n.code+".html",h="http://guba.eastmoney.com/list,"+n.code+".html",m="<span style='cursor:pointer;padding:2px;background:#666;color:#fff;' onclick='window.open(\""+u+"\")'>龙虎榜</span>"+g+"<span style='margin-left:3px;cursor:pointer;padding:2px;background:#666;color:#fff;' onclick='window.open(\""+h+"\")'>东财股吧</span> "
o="<html><body style='width:100%;margin:0;padding:0;' scroll=no><div style='width:100%;height:70px;line-height:20px;font-size:12px;text-align:center;background:#111;color:"+c+";margin:0;padding:0;'>"+m+"<div style='text-align:center;font-size:14px;'>股性"+d+" 开板率"+r+"%</div><div style='text-align:center;'>龙头"+s.lt+" 连板"+s.lb+" 涨停"+s.zt+" 开板"+s.kb+" 跌停"+s.dt+"</div></div></body></html>",$("gxStockCode").value=n.code,gmGuxing.calcGuxing()}}break
case"sellstock":break
case"ccinfo":}t.end(o)}else t.end("error request")}
var gmThs={}
gmThs.tdxDays=function(e){var t=72,i=56,a=""
"6"==e.substr(0,1)||"9"==e.substr(0,1)||"8"==e.substr(0,1)?a=gConfig.tdxFolder+"/history/shase/day/"+e+".day":("3"==e.substr(0,1)||"0"==e.substr(0,1))&&(a=gConfig.tdxFolder+"/history/sznse/day/"+e+".day")
var n=null
this.length=0,this.code=e,fs.existsSync(a)&&(n=fs.readFileSync(a),this.length=(n.length-t)/i),this.get=function(e){var a=4
this.day=n.readUInt32LE(e*i+0*a+t),this.open=n.readUInt32LE(e*i+1*a+t),this.high=n.readUInt32LE(e*i+2*a+t),this.low=n.readUInt32LE(e*i+3*a+t),this.close=n.readUInt32LE(e*i+4*a+t),this.amount=n.readFloatLE(e*i+5*a+t),this.volume=n.readUInt32LE(e*i+6*a+t),this.preclose=n.readUInt32LE(e*i+7*a+t)}},gmThs.tdxDayMinutes=function(e,t){var i=this
this.get=function(e){var t=4,a=i.dayLength,n=i.data.readUInt32LE(e*a+i.headerLength),o=Math.floor(n/2048)+2004,s=Math.floor(n%2048/100),r=n%2048%100,l={}
return l.day=""+o+("0"+s).substr(-2)+("0"+r).substr(-2),l.open=i.data.readFloatLE(e*a+1*t+i.headerLength),l.high=i.data.readFloatLE(e*a+2*t+i.headerLength),l.low=i.data.readFloatLE(e*a+3*t+i.headerLength),l.close=i.data.readFloatLE(e*a+4*t+i.headerLength),l.amount=i.data.readFloatLE(e*a+5*t+i.headerLength),l.volume=parseInt(i.data.readUInt32LE(e*a+6*t+i.headerLength)/100),l},this.headerLength=56,this.dayLength=40
var a=""
if("6"==e.substr(0,1)||"9"==e.substr(0,1)||"8"==e.substr(0,1)?a=gConfig.tdxFolder+"/history/shase/min/"+e+".min":("3"==e.substr(0,1)||"0"==e.substr(0,1))&&(a=gConfig.tdxFolder+"/history/sznse/min/"+e+".min"),this.code=e,this.data=null,this.length=0,this.preclose=0,fs.existsSync(a)){this.data=fs.readFileSync(a),this.length=(this.data.length-this.headerLength)/this.dayLength
for(var n=0;n<this.length;n+=240){var o=this.get(n)
if(o.day==t){if(0==n||n+240>this.length)break
var s=this.get(n-1)
if(this.preclose=s.close,this.preclose2=0,n-240-1>=0){var r=this.get(n-240-1)
this.preclose2=r.close}var l=new Buffer(240*this.dayLength)
return this.data.copy(l,this.headerLength,n*this.dayLength,(n+240)*this.dayLength),this.data=l,this.length=240,void(this.headerLength=0)}}this.data=null,this.length=0}}
var gmTradeFupan={}
gmTradeFupan.trades=[],gmTradeFupan.tradeIndex=0,gmTradeFupan.init=function(){initMemoMove($("divBuyMemo")),initMemoMove($("divSellMemo")),initMemoMove($("divIndexBuyMemo")),initMemoMove($("divIndexSellMemo")),initMemoMove($("divWaterMark")),$("tsfupanStockKline").style.width=gConfig.cfgTFKLineRatio+"%",$("tsfupanIndexKline").style.width=gConfig.cfgTFKLineRatio+"%",$("tsfupanStockTicklineBuy").style.width=98-gConfig.cfgTFKLineRatio+"%",$("tsfupanStockTicklineSell").style.width=98-gConfig.cfgTFKLineRatio+"%",$("divBuyMemo").style.left=gConfig.cfgTFKLineRatio+5+"%",$("divBuyMemo").style.width=90-gConfig.cfgTFKLineRatio+"%",$("divSellMemo").style.left=gConfig.cfgTFKLineRatio+5+"%",$("divSellMemo").style.width=90-gConfig.cfgTFKLineRatio+"%",$("divWaterMark").innerHTML=gConfig.cfgTFWaterMark,gmTradeFupan.useCount=0
var e=window.innerWidth-40
e=e>gConfig.cfgTFMaxWidth?gConfig.cfgTFMaxWidth:e,$("tsCharts").style.width=e+"px",$("stockHeader").style.width=e-50+"px",gmTradeFupan.chartWidth=parseInt(e)
var t=window.innerHeight-40
t=t>gConfig.cfgTFMaxHeight?gConfig.cfgTFMaxHeight:t,gmTradeFupan.chartHeight=parseInt(t),t=parseInt((t-100)/2)
var i=t+"px"
$("btnMemoBuy").style.top=t-50+"px",$("btnMemoSell").style.top=2*t-50+"px",$("divBuyMemo").style.top=t-150+"px",$("divSellMemo").style.top=2*t-150+"px",$("divIndexBuyMemo").style.top=2*t-200+"px",$("divIndexSellMemo").style.top=2*t-150+"px",$("tsfupanStockKline").style.height=i,$("tsfupanStockTicklineBuy").style.height=i,$("tsfupanIndexKline").style.height=i,$("tsfupanStockTicklineSell").style.height=i,gmTradeFupan.lockShowGroups=!1,gmTradeFupan.lockShowLists=!1,gmTradeFupan.yzListAndDetails=readObjectFromFile(gTFDetailsFile),gmTradeFupan.yzListAndDetails.yzList={}},gmTradeFupan.toggleShowGroups=function(e){gmTradeFupan.lockShowGroups=!gmTradeFupan.lockShowGroups,gmTradeFupan.lockShowGroups?(e.style.border="1px solid white",$("divTfGroups").style.border="1px solid white",iToasts.show("窗口已锁定",!1)):(e.style.border="",$("divTfGroups").style.border="",iToasts.show("窗口已解锁",!1))},gmTradeFupan.toggleShowLists=function(e){gmTradeFupan.lockShowLists=!gmTradeFupan.lockShowLists,gmTradeFupan.lockShowLists?(e.style.border="1px solid white",$("divTfLists").style.border="1px solid white",iToasts.show("窗口已锁定",!1)):(e.style.border="",$("divTfLists").style.border="",iToasts.show("窗口已解锁",!1))},gmTradeFupan.getYzListFromServer=function(){var e={act:"tfyzlist",lastUpdateTime:gmTradeFupan.yzListAndDetails.lastUpdateTime},t=new iAjax
t.get(gdadatfurl,e,function(e){if(0==e.error){gmTradeFupan.yzListAndDetails.yzList=e.items
for(var t=0;t<e.ditems.length;t++){var i=e.ditems[t]
void 0===gmTradeFupan.yzListAndDetails.yzItems[i.YzId]&&(gmTradeFupan.yzListAndDetails.yzItems[i.YzId]={}),gmTradeFupan.yzListAndDetails.yzItems[i.YzId]=i}gmTradeFupan.yzListAndDetails.lastUpdateTime=(new Date).Format("yyyy-MM-dd hh:mm:ss"),gmTradeFupan.showAptsAndGroup()}else iToasts.show("获取游资列表失败",!0)})},gmTradeFupan.showGroup=function(e,t){$("divTfLists").style.display="block"},gmTradeFupan.modifyGroup=function(e,t){var i=empty(t)?0:t
i=empty(i)?e.parentElement.getAttribute("yzid"):i
var a=void 0===gmTradeFupan.yzListAndDetails.yzItems[i]?{ShortName:"",Description:""}:gmTradeFupan.yzListAndDetails.yzItems[i],n=""
for(id in gmTradeFupan.yzListAndDetails.yzList){var o=gmTradeFupan.yzListAndDetails.yzList[id]
if(o.YzId==i){n=o.Name
break}}$("frmModifyTfGroup").style.display="block",$("modifyTfGroupTitle").innerHTML=n,$("modify_tfaname").value=a.ShortName,$("modify_tfastyle").value=a.Description,$("btnConfirmModifyTfGroup").onclick=function(){iDlgs.confirm("修改或添加游资高手分组","确定要修改或添加游资高手资料吗？",function(){var e=$("modify_tfaname").value,t=$("modify_tfastyle").value
gmTradeFupan.updateYzDetailsToServer(i,e,t),$("frmModifyLhbApartment").style.display="none"},function(){})}},gmTradeFupan.updateYzDetailsToServer=function(e,t,i){var a={act:"tfyzdupdate",TfYzId:e,sname:t,desc:i},n=new iAjax
n.get(gdadatfurl,a,function(e){0==e.error?(iToasts.show("修改游资高手资料成功",!1),gmTradeFupan.getYzListFromServer()):iToasts.show("更新游资高手资料失败",!0)})},gmTradeFupan.uploadJGD=function(){var e=$("stockCode").value,t=$("buyTimes").value,i=$("sellTimes").value
tsstock.currentStockCode=e
var a=$("stockBuyDate").value.replace(/\-/g,"/"),n=$("stockSellDate").value.replace(/\-/g,"/"),o=parseFloat($("stockBuyPrice").value),s=parseFloat($("stockSellPrice").value),r={act:"tfjgdupload",TfYzId:TfYzId,stockcode:e,buytimes:t,selltimes:i,buydate:a,selldate:n,buyprice:o,sellprice:s},l=new iAjax
l.get(gdadatfurl,r,function(e){0==e.error?(iToasts.show("上传成功",!1),gmTradeFupan.getYzListFromServer()):iToasts.show("上传失败",!0)})},gmTradeFupan.deleteJGD=function(e){var t={act:"tfjgddelete",jgdid:e},i=new iAjax
i.get(gdadatfurl,t,function(e){0==e.error?(iToasts.show("删除交割单成功",!1),gmTradeFupan.getYzListFromServer()):iToasts.show("删除失败",!0)})},gmTradeFupan.showGroupsAndOrders=function(){var e=$("divTfGroupList")
e.innerHTML=""
for(id in gmLhb.yzListAndDetails.yzList){var t=document.createElement("div")
if(t.className="lhbyzli",t.setAttribute("fpid",id),t.innerHTML='<input type="radio" name="lhbyzfollow" onclick="gmLhb.changeCurrentFPlan(this)"/>'+id+'<span class="minbtn"  onclick="gmLhb.removeFollowPlan(this)">删除</span>',e.appendChild(t),id==gmLhb.yzListAndDetails[gmLhb.groupId].currentFPlan){var i=document.querySelector('#divLhbFPlans div[fpid="'+id+'"] input')
empty(i)||(i.checked=!0,t.className="lhbyzliselected")}}e=$("divLhbYzList"),e.innerHTML=""
for(id in gmLhb.yzListAndDetails.yzList){var a=gmLhb.yzListAndDetails.yzList[id],n=void 0===gmLhb.yzListAndDetails[gmLhb.groupId].yzItems[a.YzId]?{YzId:"0",ModifyTime:"",NickName:""}:gmLhb.yzListAndDetails[gmLhb.groupId].yzItems[a.YzId],t=document.createElement("div")
if(t.className="lhbyzli",t.setAttribute("yzid",a.YzId),t.innerHTML='<span class="lhbyzlititle">'+a.Name+'</span> <span class="time">'+n.NickName+'</span><br><input type="checkbox" onchange="this.parentElement.className=this.checked?\'lhbyzliselected\':\'lhbyzli\'"/>关注<span class="minbtn" onclick="gmLhb.modifyYzDetails(this)"/>修改</span><span class="minbtn" onclick="gmLhb.deleteYzDetailsToServer(this)">删除</span> <span class="time">'+n.ModifyTime+"</span>",e.appendChild(t),gmLhb.yzListAndDetails[gmLhb.groupId].fPlans[gmLhb.yzListAndDetails[gmLhb.groupId].currentFPlan].indexOf(a.YzId)>-1){var i=document.querySelector('#divLhbYzList div[yzid="'+a.YzId+'"] input')
empty(i)||(i.checked=!0,t.className="lhbyzliselected")}}},gmTradeFupan.SelectTradeRecord=function(e){if(0==gmTradeFupan.trades.length)return void iToasts.show("请先打开成交记录TXT文件",!0)
gmTradeFupan.tradeIndex++,gmTradeFupan.tradeIndex>gmTradeFupan.trades.length&&(gmTradeFupan.tradeIndex=1)
var t=gmTradeFupan.trades[gmTradeFupan.tradeIndex-1]
$("stockCode").value=t.code,$("stockBuyDate").value=t.buyday,$("stockSellDate").value=t.sellday,$("stockBuyPrice").value=t.buyprice,$("stockSellPrice").value=t.sellprice,$("buyTimes").value=t.buytimes,$("sellTimes").value=t.selltimes,e.innerHTML=gmTradeFupan.tradeIndex+"/"+gmTradeFupan.trades.length,iToasts.show("已选择交易记录："+t.code+t.name,!1)},gmTradeFupan.loadDataFromTxt=function(e){var t=" ",i="C:/Users/Administrator/Desktop/wt.txt",a=readTextFromFile(i),n=fs.readFileSync(i)
a=iconv.decode(n,"gb2312")
for(var o=a.split("\r\n"),s=[],r=0;r<o.length;r++){for(var l=o[r],d=l.split(t),c=0;c<d.length;c++)(d[c]==t||0==d[c].length)&&(d.splice(c,1),c--)
var g=d[3],u=/^[0-9]{6}$/
!empty(g)&&u.test(g)&&s.push(d)}for(gmTradeFupan.trades=[];s.length>0;){for(var h={code:"",name:"",buyday:"",sellday:"",buypos:[],sellpos:[]},r=0;r<s.length;r++){var m=s[r],p=m[11],f=m[12],y=f.substr(0,5).replace(":","")
parseInt(y)<930&&(y="930")
var v=m[3],b=m[4],x=parseFloat(m[8]).toFixed(2),_=parseInt(m[9]),L=m[5]
""!=h.code||"买入"==L?""!=h.code||"买入"!=L?v!=h.code||p!=h.buyday||"买入"!=L?v!=h.code||""!=h.sellday||"卖出"!=L?v!=h.code||p!=h.sellday||"卖出"!=L||(h.sellpos.push({ttime:f,tprice:x,tcount:_,ttimestr:y}),s.splice(r,1),r--):(h.sellday=p,h.sellpos.push({ttime:f,tprice:x,tcount:_,ttimestr:y}),s.splice(r,1),r--):(h.buypos.push({ttime:f,tprice:x,tcount:_,ttimestr:y}),s.splice(r,1),r--):(h.code=v,h.name=b,h.buyday=p,h.buypos.push({ttime:f,tprice:x,tcount:_,ttimestr:y}),s.splice(r,1),r--):(s.splice(r,1),r--)}if(""!=h.code){for(var _=0,k=0,T="",r=0;r<h.buypos.length;r++)_+=h.buypos[r].tcount,k+=h.buypos[r].tcount*h.buypos[r].tprice,T+=h.buypos[r].ttimestr+" "
h.buyprice=(k/_).toFixed(2),h.buytimes=T,_=0,k=0,T=""
for(var r=0;r<h.sellpos.length;r++)_+=h.sellpos[r].tcount,k+=h.sellpos[r].tcount*h.sellpos[r].tprice,T+=h.sellpos[r].ttimestr+" "
h.sellprice=(k/_).toFixed(2),h.selltimes=T,gmTradeFupan.trades.push(h)}}gmTradeFupan.trades.length>0&&(gmTradeFupan.tradeIndex=0,gmTradeFupan.SelectTradeRecord($("btntsSelectTradeRecord")))}
var tsstock={}
tsstock.getHistoryKlineFromThs=function(e){var t=new Date(e.buydate),i=new Date(e.selldate),a=(new Date).addDays(-2).Format("yyyyMMdd"),n=(new Date).daysDiff(i)
n>60&&(a=new Date(e.selldate).addDays(15).Format("yyyyMMdd")),t=parseInt(t.Format("yyyyMMdd")),i=parseInt(i.Format("yyyyMMdd"))
var o=e.stock.code
o=e.isGetIndex?tsstock.codeToIndexSymbol(o):tsstock.codeToSymbol(o)
var s="https://gupiao.baidu.com/api/stocks/stockdaybar?from=pc&os_ver=1&cuid=xxx&vv=100&format=json&stock_code="+o+"&start="+a+"&count="+e.datacount+"&fq_type=no",r=new jAjax
r.get(s,function(a){var n=JSON.parse(a),o=tsstock.deepCopy(tsstock.tsstockKLineOptionTemplate)
if(o.title.text=e.stock.name+" "+e.stock.code,e.isGetIndex&&(o.title.text+="    （大大游资辅助工具 - by saraswati）"),"object"!=typeof n||0!=n.errorNo)return void iToasts.show("parse error",!0)
for(var s=999999,r=0,l=9999999999,d=0,c=n.mashData.length-1;c>-1;c--){var g=n.mashData[c]
o.xAxis[0].data.push(g.date)
var u=parseFloat(g.kline.low.toFixed(2)),h=parseFloat(g.kline.high.toFixed(2)),m=parseFloat(g.kline.open.toFixed(2)),p=parseFloat(g.kline.close.toFixed(2)),f=parseInt(g.kline.volume/100),y={}
if(y.open=m,y.high=h,y.close=p,y.low=u,y.volume=f,y.amount=parseInt(g.kline.amount),y.preClose=parseFloat(g.kline.preClose.toFixed(2)),s=s>u?u:s,r=h>r?h:r,d=f>d?f:d,l=l>f?f:l,o.series[0].data.push(parseFloat(g.ma5.avgPrice.toFixed(2))),o.series[1].data.push(parseFloat(g.ma10.avgPrice.toFixed(2))),o.series[2].data.push(parseFloat(g.ma20.avgPrice.toFixed(2))),o.series[3].data.push([m,p,u,h]),g.date==t){f={value:f,itemStyle:{normal:{color:"red"}}}
var v=n.mashData.length-1-c
e.isGetIndex||tsstock.getHistoryTickline(e,e.buydate,e.buyprice,y,e.TBChartDivId),o.series[0].markPoint.data.push({label:"B",xAxis:v,yAxis:1.005*h})}else if(g.date==i){f={value:f,itemStyle:{normal:{color:"blue"}}}
var v=n.mashData.length-1-c
e.isGetIndex||tsstock.getHistoryTickline(e,e.selldate,e.sellprice,y,e.TSChartDivId),o.series[1].markPoint.data.push({label:"S",xAxis:v,yAxis:1.005*h})}else f=p>m?{value:f,itemStyle:{normal:{color:"darkred"}}}:{value:f,itemStyle:{normal:{color:"darkcyan"}}}
o.series[4].data.push(f)}o.yAxis[0].min=s-3*(r-s)/7,o.yAxis[0].max=r,o.yAxis[1].min=0,o.yAxis[1].max=10*d/3,o.series[0].markPoint.itemStyle.normal.label.formatter=function(e,t,i){return e.data.label},o.series[1].markPoint.itemStyle.normal.label.formatter=function(e,t,i){return e.data.label}
var b=echarts.init($(e.KChartDivId))
b.setOption(o)},function(){iToasts.show("error",!0)})},tsstock.getMas=function(e,t){for(var i=0,a={ma5:0,ma10:0,ma20:0,ma30:0},n=t;n>0;n--){var o=new e.get(n)
if(i+=o.close/100,t-n==4&&(a.ma5=i/5),t-n==9&&(a.ma10=i/10),t-n==19&&(a.ma20=i/20),t-n==29){a.ma30=i/30
break}}return a},tsstock.getStartDateIndex=function(e,t){for(var i=1,a=e.length-1;a>=i;){var n=parseInt((i+a)/2),o=new e.get(n)
if(t==o.day)return n
t<o.day?a=n-1:i=n+1}return e.length},tsstock.getHistoryKlineFromTdx=function(e){var t=parseInt(new Date(e.buydate).Format("yyyyMMdd")),i=parseInt(new Date(e.selldate).Format("yyyyMMdd")),a=e.stock.code,n=new gmTdx.tdxDays(a)
if(0==n.length)return iToasts.show("未找到该股票。请检查是否已用通达信下载该股数据",!0),null
var o=deepCopy(tsstock.tsstockKLineOptionTemplate)
o.title.text=e.stock.name+" "+e.stock.code,e.isGetIndex&&(o.title.text+="    （大大游资复盘工具 - by 大大唐）")
var s=gConfig.cfgTFupanKLineBarCount,r=0,l=999999,d=0,c=9999999999,g=0,u=tsstock.getStartDateIndex(n,t)
u=u-s>0?u-s:1
for(var h=u;h<n.length;h++){var m=new n.get(h)
if(m.day>i&&r++,r>5)break
var p=new n.get(h-1)
o.xAxis[0].data.push(""+m.day)
var f={}
f.low=parseFloat((m.low/100).toFixed(2)),f.high=parseFloat((m.high/100).toFixed(2)),f.open=parseFloat((m.open/100).toFixed(2)),f.close=parseFloat((m.close/100).toFixed(2)),f.volume=parseInt(m.volume/100),f.amount=parseInt(m.amount),f.preClose=parseFloat((p.close/100).toFixed(2)),l=f.low<l?f.low:l,d=f.high>d?f.high:d,g=f.volume>g?f.volume:g,c=f.volume<c?f.volume:c
var y=tsstock.getMas(n,h)
if(o.series[0].data.push(parseFloat(y.ma5.toFixed(2))),o.series[1].data.push(parseFloat(y.ma10.toFixed(2))),o.series[2].data.push(parseFloat(y.ma20.toFixed(2))),o.series[3].data.push([f.open,f.close,f.low,f.high]),m.day==t){var v={value:f.volume,itemStyle:{normal:{color:"red"}}}
e.isGetIndex||tsstock.getHistoryTicklineFromTdx(e,e.buydate,e.buyprice,f,e.TBChartDivId),o.series[0].markPoint.data.push({label:"B",xAxis:""+m.day,yAxis:1.005*f.high})}else if(m.day==i){var v={value:f.volume,itemStyle:{normal:{color:"blue"}}}
e.isGetIndex||tsstock.getHistoryTicklineFromTdx(e,e.selldate,e.sellprice,f,e.TSChartDivId),o.series[1].markPoint.data.push({label:"S",xAxis:""+m.day,yAxis:1.005*f.high})}else if(f.close>f.open)var v={value:f.volume,itemStyle:{normal:{color:"darkred"}}}
else var v={value:f.volume,itemStyle:{normal:{color:"darkcyan"}}}
o.series[4].data.push(v)}o.yAxis[0].min=l-3*(d-l)/7,o.yAxis[0].max=d,o.yAxis[1].min=0,o.yAxis[1].max=10*g/3,o.series[0].markPoint.itemStyle.normal.label.formatter=function(e,t,i){return e.data.label},o.series[1].markPoint.itemStyle.normal.label.formatter=function(e,t,i){return e.data.label}
var b=echarts.init($(e.KChartDivId))
b.setOption(o)},tsstock.getHistoryTicklineFromTdx=function(e,t,i,a,n){var o=e.stock.code
e.isGetIndex&&(o=tsstock.codeToTdxIndex(o))
var s=new gmTdx.tdxDayMinutes(o,new Date(t).Format("yyyyMMdd"))
if(240!=s.length)return iToasts.show("无法找到通达信1分钟数据，尝试从服务器下载分时数据",!1),void tsstock.getHistoryTickline(e,t,i,a,n)
var r=new Date(t).Format("yyyy-MM-dd"),l=tsstock.initTicklineOption(),d=(100*(a.open/a.preClose-1)).toFixed(2),c=(100*(a.close/a.preClose-1)).toFixed(2),g=a.amount
a.amount>1e8?g=(a.amount/1e8).toFixed(2)+"亿":a.amount>1e4&&(g=(a.amount/1e4).toFixed(2)+"万"),e.isGetIndex?l.title.text=e.stock.code+" "+e.stock.name+" "+r+" 开:"+d+"% 收:"+c+"% 成交额:"+g:e.buydate==t?l.title.text="买入 "+e.stock.code+" "+e.stock.name+" "+r+" 开:"+d+"% 收:"+c+"% 成交额:"+g:l.title.text="卖出 "+e.stock.code+" "+e.stock.name+" "+r+" 开:"+d+"% 收:"+c+"% 成交额:"+g
for(var u=(a.low,a.high,0),h=0,m=0,p=0,f=0;f<s.length;f++){var y=s.get(f),v=parseInt(l.xAxis[0].data[f].replace(":",""))
p=0,m+=y.amount,h+=y.volume,u=y.volume>u?y.volume:u
var b=parseFloat((m/(100*h)).toFixed(2))
l.series[0].data.push(y.close),l.series[1].data.push(b),l.series[2].data.push(y.volume),e.buydate==t&&-1!=e.buytimes.indexOf(v)?l.series[0].markPoint.data.push({label:"B",xAxis:f,yAxis:y.close}):e.selldate==t&&-1!=e.selltimes.indexOf(v)&&l.series[1].markPoint.data.push({label:"S",xAxis:f,yAxis:y.close})}var x=a.low,_=a.high
a.high-a.preClose>a.preClose-a.low?x=2*a.preClose-a.high:_=2*a.preClose-a.low,l.yAxis[0].min=x-3*(_-x)/6.6,l.yAxis[0].max=_,l.yAxis[1].min=0,l.yAxis[1].max=10*u/3
var L=99999
l.series[1].markLine.data.push([{label:"0.00%",xAxis:0,yAxis:a.preClose},{xAxis:L,yAxis:a.preClose}]),l.series[1].markLine.data.push([{label:a.preClose.toFixed(2),xAxis:L,yAxis:a.preClose},{xAxis:0,yAxis:a.preClose}]),l.series[0].markLine.data.push([{label:(100*(_/a.preClose-1)).toFixed(2)+"%",xAxis:239,yAxis:_},{xAxis:L,yAxis:_}]),l.series[0].markLine.data.push([{label:_.toFixed(2),xAxis:1,yAxis:_},{xAxis:0,yAxis:_}])
var k=(_+a.preClose)/2
l.series[0].markLine.data.push([{label:(100*(k/a.preClose-1)).toFixed(2)+"%",xAxis:0,yAxis:k},{xAxis:L,yAxis:k}]),l.series[0].markLine.data.push([{label:k.toFixed(2),xAxis:L,yAxis:k},{xAxis:0,yAxis:k}])
var T=(x+a.preClose)/2
l.series[0].markLine.data.push([{label:(100*(T/a.preClose-1)).toFixed(2)+"%",xAxis:0,yAxis:T},{xAxis:L,yAxis:T}]),l.series[0].markLine.data.push([{label:T.toFixed(2),xAxis:L,yAxis:T},{xAxis:0,yAxis:T}])
var w={normal:{lineStyle:{color:e.buydate==t?"darkred":"darkcyan",width:1,type:"solid"}}}
l.series[1].markLine.data.push([{label:"成交价",xAxis:0,yAxis:i,itemStyle:w},{xAxis:L,yAxis:i,itemStyle:w}]),l.series[1].markLine.data.push([{label:i.toFixed(2),xAxis:1,yAxis:i,itemStyle:w},{xAxis:0,yAxis:i,itemStyle:w}])
var F=u>1e4?(u/1e4).toFixed(1)+"万":u
l.series[2].markLine.data.push([{label:F,xAxis:L,yAxis:u},{xAxis:0,yAxis:u}]),l.series[0].markLine.itemStyle.normal.label.formatter=function(e,t,i){return e.data.label},l.series[1].markLine.itemStyle.normal.label.formatter=function(e,t,i){return e.data.label},l.series[2].markLine.itemStyle.normal.label.formatter=function(e,t,i){return e.data.label},l.series[0].markPoint.itemStyle.normal.label.formatter=function(e,t,i){return e.data.label},l.series[1].markPoint.itemStyle.normal.label.formatter=function(e,t,i){return e.data.label}
var S=echarts.init($(n))
S.setOption(l),iToasts.show("done",!1),enableButton($("stockCreateImage"))},tsstock.getHistoryTickline_min=function(e,t,i,a,n){var o=e.stock.code
o=e.isGetIndex?tsstock.codeToIndexSymbol(o):tsstock.codeToSymbol(o)
var s=new Date(t).Format("yyyy-MM-dd"),r=gAppFolder+"/dadadata/m1cache/"+o+"-"+s+".min",l=readObjectFromFile(r)
if(l.length>10)tsstock.realGetHistoryTickline_min(e,t,i,a,n,s,l)
else{var d="https://finance.sina.com.cn/realstock/company/"+o+"/hisdata/"+new Date(t).Format("yyyy")+"/"+new Date(t).Format("MM")+".js",c=new jAjax
c.get(d,function(o){for(var l=/(IC\S*?)[",]{1}/g;ms=l.exec(o);){var d=ms[1],c=tsstock.xh5_S_KLC_D(d),g=c[0].date.Format("yyyy-MM-dd")
if(g==s){saveObjectToFile(c,r),tsstock.realGetHistoryTickline_min(e,t,i,a,n,s,c)
break}}},function(){iToasts.show("error",!0),enableButton($("stockCreateImage"))})}},tsstock.realGetHistoryTickline_min=function(e,t,i,a,n,o,s){var r=tsstock.initTicklineOption(),l=(100*(a.open/a.preClose-1)).toFixed(2),d=(100*(a.close/a.preClose-1)).toFixed(2),c=a.amount
a.amount>1e8?c=(a.amount/1e8).toFixed(2)+"亿":a.amount>1e4&&(c=(a.amount/1e4).toFixed(2)+"万"),e.isGetIndex?r.title.text=e.stock.code+" "+e.stock.name+" "+o+" 开:"+l+"% 收:"+d+"% 成交额:"+c:e.buydate==t?r.title.text="买入 "+e.stock.code+" "+e.stock.name+" "+o+" 开:"+l+"% 收:"+d+"% 成交额:"+c:r.title.text="卖出 "+e.stock.code+" "+e.stock.name+" "+o+" 开:"+l+"% 收:"+d+"% 成交额:"+c
for(var g=(a.low,a.high,0),u=0,h=1,m=0;m<r.xAxis[0].data.length;m++){var u=parseInt(s[h].volume/100)
0==m&&(u+=parseInt(s[0].volume/100))
var p=parseInt(r.xAxis[0].data[m].replace(":",""))
g=u>g?u:g,r.series[0].data.push(s[h].price),r.series[1].data.push(s[h].avg_price),r.series[2].data.push(u),e.buydate==t&&-1!=e.buytimes.indexOf(p)?r.series[0].markPoint.data.push({label:"B",xAxis:m,yAxis:s[h].price}):e.selldate==t&&-1!=e.selltimes.indexOf(p)&&r.series[1].markPoint.data.push({label:"S",xAxis:m,yAxis:s[h].price}),h++,119==m&&h++}var f=a.low,y=a.high
a.high-a.preClose>a.preClose-a.low?f=2*a.preClose-a.high:y=2*a.preClose-a.low,r.yAxis[0].min=f-3*(y-f)/6.6,r.yAxis[0].max=y,r.yAxis[1].min=0,r.yAxis[1].max=10*g/3
var v=99999
r.series[1].markLine.data.push([{label:"0.00%",xAxis:0,yAxis:a.preClose},{xAxis:v,yAxis:a.preClose}]),r.series[1].markLine.data.push([{label:a.preClose.toFixed(2),xAxis:v,yAxis:a.preClose},{xAxis:0,yAxis:a.preClose}]),r.series[0].markLine.data.push([{label:(100*(y/a.preClose-1)).toFixed(2)+"%",xAxis:239,yAxis:y},{xAxis:v,yAxis:y}]),r.series[0].markLine.data.push([{label:y.toFixed(2),xAxis:1,yAxis:y},{xAxis:0,yAxis:y}])
var b=(y+a.preClose)/2
r.series[0].markLine.data.push([{label:(100*(b/a.preClose-1)).toFixed(2)+"%",xAxis:0,yAxis:b},{xAxis:v,yAxis:b}]),r.series[0].markLine.data.push([{label:b.toFixed(2),xAxis:v,yAxis:b},{xAxis:0,yAxis:b}])
var x=(f+a.preClose)/2
r.series[0].markLine.data.push([{label:(100*(x/a.preClose-1)).toFixed(2)+"%",xAxis:0,yAxis:x},{xAxis:v,yAxis:x}]),r.series[0].markLine.data.push([{label:x.toFixed(2),xAxis:v,yAxis:x},{xAxis:0,yAxis:x}])
var _={normal:{lineStyle:{color:e.buydate==t?"#ff8289":"#00c1de",width:1,type:"solid"}}}
r.series[1].markLine.data.push([{label:"成交价",xAxis:0,yAxis:i,itemStyle:_},{xAxis:v,yAxis:i,itemStyle:_}]),r.series[1].markLine.data.push([{label:i.toFixed(2),xAxis:1,yAxis:i,itemStyle:_},{xAxis:0,yAxis:i,itemStyle:_}])
var L=g>1e4?(g/1e4).toFixed(1)+"万":g
r.series[2].markLine.data.push([{label:L,xAxis:v,yAxis:g},{xAxis:0,yAxis:g}]),r.series[0].markLine.itemStyle.normal.label.formatter=function(e,t,i){return e.data.label},r.series[1].markLine.itemStyle.normal.label.formatter=function(e,t,i){return e.data.label},r.series[2].markLine.itemStyle.normal.label.formatter=function(e,t,i){return e.data.label},r.series[0].markPoint.itemStyle.normal.label.formatter=function(e,t,i){return e.data.label},r.series[1].markPoint.itemStyle.normal.label.formatter=function(e,t,i){return e.data.label}
var k=echarts.init($(n))
k.setOption(r),iToasts.show("done",!1),enableButton($("stockCreateImage"))},tsstock.getHistoryTickline_xls=function(e,t,i,a,n){var o=e.stock.code
o=e.isGetIndex?tsstock.codeToIndexSymbol(o):tsstock.codeToSymbol(o)
var s=new Date(t).Format("yyyy-MM-dd"),r=gAppFolder+"/dadadata/m1cache/"+o+"-"+s+".txt",l=readTextFromFile(r)
if(""!=l)tsstock.realGetHistoryTickline(e,t,i,a,n,s,l)
else{var d="http://market.finance.sina.com.cn/downxls.php?date="+s+"&symbol="+o,c=new jAjax
c.binary_get(d,function(o){var l=new Buffer(o),d=iconv.decode(l,"gb2312")
saveTextToFile(d,r),tsstock.realGetHistoryTickline(e,t,i,a,n,s,d)},function(){iToasts.show("error",!0),enableButton($("stockCreateImage"))})}},tsstock.getHistoryTickline=function(e,t,i,a,n){return void tsstock.getHistoryTickline_min(e,t,i,a,n)},tsstock.getFullpages=function(e,t,i,a,n,o,s,r,l,d){var c="http://market.finance.sina.com.cn/transHis.php?page="+i+"&date="+a+"&symbol="+n,g=new jAjax
g.get(c,function(c){var g=/<tbody>([\S\s]+)<\/tbody>/g
if(ms=g.exec(c)){var u=ms[1]
if(u=u.replace(/<tr ><th>/gi,""),u=u.replace(/<\/th><td>/gi,"	"),u=u.replace(/<\/td><td>/gi,"	"),u=u.replace(/<\/td><th><h6>/gi,"	"),u=u.replace(/<\/td><th><h5>/gi,"	"),u=u.replace(/<\/td><th><h1>/gi,"	"),u=u.replace(/<\/h6><\/th><\/tr>/gi,""),u=u.replace(/<\/h5><\/th><\/tr>/gi,""),u=u.replace(/<\/h1><\/th><\/tr>/gi,""),u.length<10)return enableButton($("stockCreateImage")),saveTextToFile(t,e),void tsstock.realGetHistoryTickline(o,s,r,l,d,a,t)
t+=u.replace(/^(\s*)/g,""),i++,tsstock.getFullpages(e,t,i,a,n,o,s,r,l,d)}else iToasts.show("error",!0),enableButton($("stockCreateImage"))},function(){iToasts.show("error",!0),enableButton($("stockCreateImage"))})},tsstock.realGetHistoryTickline=function(e,t,i,a,n,o,s){var r=tsstock.initTicklineOption(),l=(100*(a.open/a.preClose-1)).toFixed(2),d=(100*(a.close/a.preClose-1)).toFixed(2),c=a.amount
a.amount>1e8?c=(a.amount/1e8).toFixed(2)+"亿":a.amount>1e4&&(c=(a.amount/1e4).toFixed(2)+"万"),e.isGetIndex?r.title.text=e.stock.code+" "+e.stock.name+" "+o+" 开:"+l+"% 收:"+d+"% 成交额:"+c:e.buydate==t?r.title.text="买入 "+e.stock.code+" "+e.stock.name+" "+o+" 开:"+l+"% 收:"+d+"% 成交额:"+c:r.title.text="卖出 "+e.stock.code+" "+e.stock.name+" "+o+" 开:"+l+"% 收:"+d+"% 成交额:"+c
for(var g=s.split("\n"),u=g.length-1,h=(a.low,a.high,0),m=0,p=0,f=0,y=0,v=0;v<r.xAxis[0].data.length;v++){var b=parseInt(r.xAxis[0].data[v].replace(":",""))
for(y=0;u>=0;){var x=g[u].split("	")
if(6==x.length){var _=parseInt(x[0].substr(0,5).replace(":",""))
if(930>_?_=930:1130==_?_=1129:1500==_?_=1459:1300>_&&_>1130&&(_=1300),b!=_)break
f=parseFloat(x[1]),y+=parseInt(x[3]),m+=parseInt(x[3]),p+=parseInt(x[4]),u--}else u--}h=y>h?y:h
var L=parseFloat((p/(100*m)).toFixed(2))
r.series[0].data.push(f),r.series[1].data.push(L),r.series[2].data.push(y),e.buydate==t&&-1!=e.buytimes.indexOf(b)?r.series[0].markPoint.data.push({label:"B",xAxis:v,yAxis:f}):e.selldate==t&&-1!=e.selltimes.indexOf(b)&&r.series[1].markPoint.data.push({label:"S",xAxis:v,yAxis:f})}var k=a.low,T=a.high
a.high-a.preClose>a.preClose-a.low?k=2*a.preClose-a.high:T=2*a.preClose-a.low,r.yAxis[0].min=k-3*(T-k)/6.6,r.yAxis[0].max=T,r.yAxis[1].min=0,r.yAxis[1].max=10*h/3
var w=99999
r.series[1].markLine.data.push([{label:"0.00%",xAxis:0,yAxis:a.preClose},{xAxis:w,yAxis:a.preClose}]),r.series[1].markLine.data.push([{label:a.preClose.toFixed(2),xAxis:w,yAxis:a.preClose},{xAxis:0,yAxis:a.preClose}]),r.series[0].markLine.data.push([{label:(100*(T/a.preClose-1)).toFixed(2)+"%",xAxis:239,yAxis:T},{xAxis:w,yAxis:T}]),r.series[0].markLine.data.push([{label:T.toFixed(2),xAxis:1,yAxis:T},{xAxis:0,yAxis:T}])
var F=(T+a.preClose)/2
r.series[0].markLine.data.push([{label:(100*(F/a.preClose-1)).toFixed(2)+"%",xAxis:0,yAxis:F},{xAxis:w,yAxis:F}]),r.series[0].markLine.data.push([{label:F.toFixed(2),xAxis:w,yAxis:F},{xAxis:0,yAxis:F}])
var S=(k+a.preClose)/2
r.series[0].markLine.data.push([{label:(100*(S/a.preClose-1)).toFixed(2)+"%",xAxis:0,yAxis:S},{xAxis:w,yAxis:S}]),r.series[0].markLine.data.push([{label:S.toFixed(2),xAxis:w,yAxis:S},{xAxis:0,yAxis:S}])
var A={normal:{lineStyle:{color:e.buydate==t?"#ff8289":"#00c1de",width:1,type:"solid"}}}
r.series[1].markLine.data.push([{label:"成交价",xAxis:0,yAxis:i,itemStyle:A},{xAxis:w,yAxis:i,itemStyle:A}]),r.series[1].markLine.data.push([{label:i.toFixed(2),xAxis:1,yAxis:i,itemStyle:A},{xAxis:0,yAxis:i,itemStyle:A}])
var C=h>1e4?(h/1e4).toFixed(1)+"万":h
r.series[2].markLine.data.push([{label:C,xAxis:w,yAxis:h},{xAxis:0,yAxis:h}]),r.series[0].markLine.itemStyle.normal.label.formatter=function(e,t,i){return e.data.label},r.series[1].markLine.itemStyle.normal.label.formatter=function(e,t,i){return e.data.label},r.series[2].markLine.itemStyle.normal.label.formatter=function(e,t,i){return e.data.label},r.series[0].markPoint.itemStyle.normal.label.formatter=function(e,t,i){return e.data.label},r.series[1].markPoint.itemStyle.normal.label.formatter=function(e,t,i){return e.data.label}
var D=echarts.init($(n))
D.setOption(r),iToasts.show("done",!1),enableButton($("stockCreateImage"))},tsstock.getLiveDataFromSina=function(e,t){var i=/(\d{6})=\"(.+?),(.+?)\"/g,a="http://hq.sinajs.cn/list="+e,n=new jAjax
n.get(a,function(e){if(ms=i.exec(e)){var a=ms[3].split(","),n={name:ms[2],code:ms[1],open:parseFloat(a[0]),preclose:parseFloat(a[1]),close:parseFloat(a[2]),high:parseFloat(a[3]),low:parseFloat(a[4]),buyprice_1:parseFloat(a[5]),sellprice_1:parseFloat(a[6]),volume:parseInt(a[7]),amount:parseInt(a[8]),bvol_1:parseInt(a[9]/100),bprice_1:parseFloat(a[10]).toFixed(2),bvol_2:parseInt(a[11]/100),bprice_2:parseFloat(a[12]).toFixed(2),bvol_3:parseInt(a[13]/100),bprice_3:parseFloat(a[14]).toFixed(2),bvol_4:parseInt(a[15]/100),bprice_4:parseFloat(a[16]).toFixed(2),bvol_5:parseInt(a[17]/100),bprice_5:parseFloat(a[18]).toFixed(2),svol_1:parseInt(a[19]/100),sprice_1:parseFloat(a[20]).toFixed(2),svol_2:parseInt(a[21]/100),sprice_2:parseFloat(a[22]).toFixed(2),svol_3:parseInt(a[23]/100),sprice_3:parseFloat(a[24]).toFixed(2),svol_4:parseInt(a[25]/100),sprice_4:parseFloat(a[26]).toFixed(2),svol_5:parseInt(a[27]/100),sprice_5:parseFloat(a[28]).toFixed(2),date:a[29],time:a[30],tick:a[31]}
t(n)}else iToasts.show("failed!",!0)})}
var allStocksTemp={}
tsstock.getAllStocksFromSina=function(fromsina){if(fromsina)tsstock.realGetAllStocksFromSina(allStocksTemp,1)
else{var alldaysstr=fs.readFileSync(gAppFolder+"/data/Market_Center.txt",{encoding:"utf8"}),as=eval(alldaysstr)
if("object"==typeof as&&as.length>1e3){for(var i=0;i<as.length;i++){var symbol=as[i].symbol
symbol in allStocks||(allStocks[symbol]={}),allStocks[symbol].code=as[i].code,allStocks[symbol].name=as[i].name}alldaysstr=JSON.stringify(allStocks),fs.writeFileSync(gAllStocksFile,alldaysstr)}}},tsstock.realGetAllStocksFromSina=function(ass,page){var url="http://vip.stock.finance.sina.com.cn/quotes_service/api/json_v2.php/Market_Center.getHQNodeData?num=500&sort=changepercent&asc=1&node=hs_a&symbol=&_s_r_a=page&page="+page,ajax=new jAjax
ajax.binary_get(url,function(d){var dd=new Buffer(d),ddutf=iconv.decode(dd,"gb2312"),as=eval(ddutf)
if("object"==typeof as&&null!=as){for(var i=0;i<as.length;i++)ass[as[i].code]={n:as[i].name}
tsstock.realGetAllStocksFromSina(ass,page+1)}else iToasts.show("成功更新A股所有股票资料",!1),allStocks=allStocksTemp,gConfig.lastUpdateAllStocksDate=(new Date).Format("yyyyMMdd"),gmConfig.save(),saveObjectToFile(allStocksTemp,gAllStocksFile)})},tsstock.getAllStocksFromTHS=function(e,t){var i="http://www.iwencai.net/stockpick/search?typed=1&preParams=&ts=1&f=1&qs=result_rewrite&selfsectsn=&querytype=&searchfilter=&tid=stockpick&w=",a=i+" 涨停",n=new jAjax
n.get(a,function(e){var t=/\"token\"\:\"(\w+?)\"\,/
if(ms=t.exec(e))for(var i=(ms[1],0);100>i;i++){new jAjax}else iToasts.show("解析错误",!0)},function(){iToasts.show("连接服务器失败",!0)})
var o=i+" 成交额",s=new jAjax
s.get(o,function(e){},function(){})},tsstock.getZDTStocksFromTHS=function(e){},tsstock.codeToSymbol=function(e){var t=e
return"0"==e.substr(0,1)||"3"==e.substr(0,1)?t="sz"+e:"6"==e.substr(0,1)&&(t="sh"+e),t},tsstock.codeToIndexSymbol=function(e){return"002"==e.substr(0,3)?"sz399005":"3"==e.substr(0,1)?"sz399006":"0"==e.substr(0,1)?"sz399001":("6"==e.substr(0,1),"sh000001")},tsstock.codeToTdxIndex=function(e){return"002"==e.substr(0,3)?"399005":"3"==e.substr(0,1)?"399006":"0"==e.substr(0,1)?"399001":("6"==e.substr(0,1),"999999")},tsstock.tsstockKLineOptionTemplate={backgroundColor:"#333744",title:{text:"Title",padding:[2,0,2,20],itemGap:0,textStyle:{color:"#fff",fontSize:12}},tooltip:{show:!1,trigger:"axis"},grid:{x:30,y:30,x2:20,y2:30,borderWidth:0},calculable:!1,xAxis:[{type:"category",boundaryGap:!1,splitLine:{show:!1},axisLine:{show:!1},axisLabel:{textStyle:{color:"#999"}},data:[]}],yAxis:[{type:"value",min:0,max:15,splitLine:{show:!1},axisLine:{show:!1},axisLabel:{show:!1}},{type:"value",min:0,max:600,splitLine:{show:!1},axisLine:{show:!1},axisLabel:{show:!1}}],series:[{name:"MA5",type:"line",symbol:"none",itemStyle:{normal:{lineStyle:{color:"white",width:1}}},data:[],markPoint:{clickable:!1,itemStyle:{normal:{color:"rgba(250,0,0,.5)",borderWidth:0,label:{}}},data:[]}},{name:"MA10",type:"line",symbol:"none",itemStyle:{normal:{lineStyle:{color:"yellow",width:1}}},data:[],markPoint:{clickable:!1,itemStyle:{normal:{color:"rgba(0,0,250,.5)",borderWidth:0,label:{}}},data:[]}},{name:"MA20",type:"line",symbol:"none",itemStyle:{normal:{lineStyle:{color:"pink",width:1}}},data:[]},{name:"价格",type:"k",data:[],symbol:"none",itemStyle:{normal:{color:"darkred",color0:"darkcyan",lineStyle:{width:2,color:"darkred",color0:"darkcyan"}},emphasis:{color:"black",color0:"white"}}},{name:"成交量",type:"bar",barMaxWidth:6,yAxisIndex:1,symbol:"none",itemStyle:{normal:{color:"#999"}},data:[]}]},tsstock.initTicklineOption=function(){for(var e=deepCopy(tsstock.tsstockTicklineOptionTemplate),t=new Date((new Date).Format("yyyy/MM/dd")+" 09:30:00"),i=0;241>i;i++)e.xAxis[0].data[i]=t.Format("hh:mm"),"11:29"==e.xAxis[0].data[i]&&t.addMinutes(90),t.addMinutes(1)
return e},tsstock.tsstockTicklineOptionTemplate={backgroundColor:"#333744",title:{text:"Title",padding:[2,0,2,40],itemGap:0,textStyle:{color:"#fff",fontSize:12}},tooltip:{show:!1,trigger:"axis"},grid:{x:50,y:30,x2:50,y2:30,borderWidth:0},calculable:!1,xAxis:[{type:"category",boundaryGap:!1,splitLine:{show:!1},splitArea:{show:!0},axisLine:{show:!1},axisLabel:{textStyle:{color:"#999"},interval:29},data:[]}],yAxis:[{type:"value",min:0,max:15,splitLine:{show:!1},axisLine:{show:!1},axisLabel:{show:!1}},{type:"value",min:0,max:600,splitLine:{show:!1},axisLine:{show:!1},axisLabel:{show:!1}}],series:[{name:"price",type:"line",symbol:"none",itemStyle:{normal:{lineStyle:{color:"white",width:1}}},data:[],markPoint:{clickable:!1,itemStyle:{normal:{color:"rgba(250,0,0,.5)",borderWidth:0,label:{}}},data:[]},markLine:{symbolSize:0,clickable:!1,itemStyle:{normal:{color:"#999",lineStyle:{color:"rgba(50,50,50,.5",width:1,type:"dashed"},label:{formatter:function(e,t,i){return console.log(e.data),e.data.label}}}},data:[]}},{name:"avgPrice",type:"line",symbol:"none",itemStyle:{normal:{lineStyle:{color:"yellow",width:1}}},data:[],markPoint:{clickable:!1,itemStyle:{normal:{color:"rgba(0,0,250,.5)",borderWidth:0,label:{}}},data:[]},markLine:{symbolSize:0,clickable:!1,itemStyle:{normal:{color:"#fff",lineStyle:{color:"#333744",width:1,type:"solid"},label:{formatter:function(e,t,i){return console.log(e.data),e.data.label}}}},data:[]}},{name:"成交量",type:"bar",barMaxWidth:2,yAxisIndex:1,symbol:"none",itemStyle:{normal:{color:"#999"}},data:[],markLine:{symbolSize:0,clickable:!1,itemStyle:{normal:{color:"#ccc",lineStyle:{color:"#333744",width:1,type:"solid"},label:{formatter:function(e,t,i){return console.log(e.data),e.data.label}}}},data:[]}}]},tsstock.xh5_S_KLC_D=function(e){var t,i,a,n,o,s,r,l=864e5,d=7657,c=[],g=[],u=~(3<<30),h=1<<30,m=[0,3,5,6,9,10,12,15,17,18,20,23,24,27,29,30],p=Math,f=function(){var l,d
for(l=0;64>l;l++)g[l]=p.pow(2,l),26>l&&(c[l]=y(l+65),c[l+26]=y(l+97),10>l&&(c[l+52]=y(l+48)))
for(c.push("+","/"),c=c.join(""),i=e.split(""),a=i.length,l=0;a>l;l++)i[l]=c.indexOf(i[l])
return n={},t=s=0,o={},d=_([12,6]),r=63^d[1],{_1479:w,_136:T,_200:k,_139:F,_197:S}["_"+d[0]]||function(){return[]}},y=String.fromCharCode,v=function(e){return e==={}._},b=function(){var e,t
for(e=x(),t=1;;){if(!x())return t*(2*e-1)
t++}},x=function(){var e
return t>=a?0:(e=i[t]&1<<s,s++,s>=6&&(s-=6,t++),!!e)},_=function(e,n,o){var r,l,d,c,u
for(l=[],d=0,n||(n=[]),o||(o=[]),r=0;r<e.length;r++)if(c=e[r],d=0,c){if(t>=a)return l
if(e[r]<=0)d=0
else if(e[r]<=30){for(;u=6-s,u=c>u?u:c,d|=(i[t]>>s&(1<<u)-1)<<e[r]-c,s+=u,s>=6&&(s-=6,t++),c-=u,!(0>=c););n[r]&&d>=g[e[r]-1]&&(d-=g[e[r]])}else d=_([30,e[r]-30],[0,n[r]]),o[r]||(d=d[0]+d[1]*g[30])
l[r]=d}else l[r]=0
return l},L=function(e){var t,i,a,o
for(e>1&&(t=0),t=0;e>t;t++)n.d++,a=n.d%7,(3==a||4==a)&&(n.d+=5-a)
return i=new Date,o=60*i.getTimezoneOffset()*1e3,i.setTime((d+n.d)*l+o),i.setHours(i.getHours()+8),i},k=function(){var e,i,o,s,l
if(r>=1)return[]
for(n.d=_([18],[1])[0]-1,o=_([3,3,30,6]),n.p=o[0],n.ld=o[1],n.cd=o[2],n.c=o[3],n.m=p.pow(10,n.p),n.pc=n.cd/n.m,i=[],e=0;s={d:1},x()&&(o=_([3])[0],0==o?s.d=_([6])[0]:1==o?(n.d=_([18])[0],s.d=0):s.d=o),l={date:L(s.d)},x()&&(n.ld+=b()),o=_([3*n.ld],[1]),n.cd+=o[0],l.close=n.cd/n.m,i.push(l),!(t>=a)&&(t!=a-1||63&(n.c^e+1));e++);return i[0].prevclose=n.pc,i},T=function(){var e,i,o,s,l,d,c,g,u,h,m
if(r>=2)return[]
for(c=[],u={v:"volume",p:"price",a:"avg_price"},n.d=_([18],[1])[0]-1,g={date:L(1)},o=_(1>r?[3,3,4,1,1,1,5]:[4,4,4,1,1,1,3]),e=0;7>e;e++)n[["la","lp","lv","tv","rv","zv","pp"][e]]=o[e]
for(n.m=p.pow(10,n.pp),r>=1?(o=_([3,3]),n.c=o[0],o=o[1]):(o=5,n.c=2),n.pc=_([6*o])[0],g.pc=n.pc/n.m,n.cp=n.pc,n.da=0,n.sa=n.sv=0,e=0;!(t>=a)&&(t!=a-1||7&(n.c^e));e++){for(l={},s={},h=n.tv?x():1,i=0;3>i;i++)if(m=["v","p","a"][i],(h?x():0)&&(o=b(),n["l"+m]+=o),d="v"==m&&n.rv?x():1,o=_([3*n["l"+m]+("v"==m?7*d:0)],[!!i])[0]*(d?1:100),s[m]=o,"v"==m){if(!(l[u[m]]=o)&&241>e&&(n.zv?!x():1)){s.p=0
break}}else"a"==m&&(n.da=(1>r?0:n.da)+s.a)
n.sv+=s.v,l[u.p]=(n.cp+=s.p)/n.m,n.sa+=s.v*n.cp,l[u.a]=v(s.a)?e?c[e-1][u.a]:l[u.p]:n.sv?((p.floor((n.sa*(2e3/n.m)+n.sv)/n.sv)>>1)+n.da)/1e3:l[u.p]+n.da/1e3,c.push(l)}return c[0].date=g.date,c[0].prevclose=g.pc,c},w=function(){var e,t,i,a,o,s,l
if(r>=1)return[]
for(n.lv=0,n.ld=0,n.cd=0,n.cv=[0,0],n.p=_([6])[0],n.d=_([18],[1])[0]-1,n.m=p.pow(10,n.p),o=_([3,3]),n.md=o[0],n.mv=o[1],e=[];o=_([6]),o.length;){if(i={c:o[0]},a={},i.d=1,32&i.c)for(;;){if(o=_([6])[0],63==(16|o)){l=16&o?"x":"u",o=_([3,3]),i[l+"_d"]=o[0]+n.md,i[l+"_v"]=o[1]+n.mv
break}if(32&o){s=8&o?"d":"v",l=16&o?"x":"u",i[l+"_"+s]=(7&o)+n["m"+s]
break}if(s=15&o,0==s?i.d=_([6])[0]:1==s?(n.d=s=_([18])[0],i.d=0):i.d=s,!(16&o))break}a.date=L(i.d)
for(s in{v:0,d:0})v(i["x_"+s])||(n["l"+s]=i["x_"+s]),v(i["u_"+s])&&(i["u_"+s]=n["l"+s])
for(i.l_l=[i.u_d,i.u_d,i.u_d,i.u_d,i.u_v],l=m[15&i.c],1&i.u_v&&(l=31-l),16&i.c&&(i.l_l[4]+=2),t=0;5>t;t++)l&1<<4-t&&i.l_l[t]++,i.l_l[t]*=3
i.d_v=_(i.l_l,[1,0,0,1,1],[0,0,0,0,1]),s=n.cd+i.d_v[0],a.open=s/n.m,a.high=(s+i.d_v[1])/n.m,a.low=(s-i.d_v[2])/n.m,a.close=(s+i.d_v[3])/n.m,o=i.d_v[4],"number"==typeof o&&(o=[o,o>=0?0:-1]),n.cd=s+i.d_v[3],l=n.cv[0]+o[0],n.cv=[l&u,n.cv[1]+o[1]+!!((n.cv[0]&u)+(o[0]&u)&h)],a.volume=(n.cv[0]&h-1)+n.cv[1]*h,e.push(a)}return e},F=function(){var e,t,i,a
if(r>1)return[]
for(n.l=0,a=-1,n.d=_([18])[0]-1,i=_([18])[0];n.d<i;)t=L(1),0>=a?(x()&&(n.l+=b()),a=_([3*n.l],[0])[0]+1,e||(e=[t],a--)):e.push(t),a--
return e},S=function(){var e,i,o,s
if(r>=1)return[]
for(n.f=_([6])[0],n.c=_([6])[0],o=[],n.dv=[],n.dl=[],e=0;e<n.f;e++)n.dv[e]=0,n.dl[e]=0
for(e=0;!(t>=a)&&(t!=a-1||7&(n.c^e));e++){for(s=[],i=0;i<n.f;i++)x()&&(n.dl[i]+=b()),n.dv[i]+=_([3*n.dl[i]],[1])[0],s[i]=n.dv[i]
o.push(s)}return o}
return f()()}
var gmUpdate={}
gmUpdate.init=function(){gmUpdate.updateApp()},gmUpdate.updateApp=function(){var ajax1=new jAjax
ajax1.get(host+"/update/ddmain.js",function(d){try{eval(d)}catch(e){console.log(e.description)}},function(){})}
var userinfo=null,http=require("http"),url=require("url"),path=require("path"),iconv={},request={},utility={},copy={},syncreq={},alldays={},gxCache={},gVersionCode=4.4,innerVersion=18100901,gCurrentTab=null,gCurrentStock={},gAppFolder=path.dirname(process.execPath)
gAppFolder="undefined"==typeof hex?"E:/stock/dadayouzi/ddyouzi":gAppFolder
var gAppFolderH=gAppFolder+"/dadayouzi",gFupanFile=gAppFolder+"/dadadata/fupandata.txt",gMyFupanFile=gAppFolder+"/dadadata/myfupandata.txt",gGuxingFile=gAppFolder+"/dadadata/mygxdata.txt",gAllStocksFile=gAppFolder+"/dadadata/allstocks.txt",gAllAFile=gAppFolder+"/dadadata/ALLA.blk",gConfigFile=gAppFolder+"/dadadata/myconfig.txt",gGnxxFile=gAppFolder+"/dadadata/mygnxx.txt",gPublicGnxxFile=gAppFolder+"/dadadata/plcmygnxx.txt",gPublicHSFile=gAppFolder+"/dadadata/plchs.txt",gPublicHSTDXFile=gAppFolder+"/dadadata/plchstdx.txt",gPublicTCSFile=gAppFolder+"/dadadata/plctcs.txt",gPublicTHSZTFile=gAppFolder+"/dadadata/plcthszt.txt",gLhbApartmentFile=gAppFolder+"/dadadata/mylhbapartment.txt",gPublicLhbApartmentFile=gAppFolder+"/dadadata/plclhbapartment.txt",gLhbDaysFile=gAppFolder+"/dadadata/mylhbdays.txt",gLhbDaysFolder=gAppFolder+"/dadadata/lhbdays",gLhbYzListAndGroupFile=gAppFolder+"/dadadata/lhbyzlistandgroup.txt",gLhbDetailsFile=gAppFolder+"/dadadata/lhbdetails.txt",gTFDetailsFile=gAppFolder+"/dadadata/tfdetails.txt",MAX_LONGTOU_COUNT=15,gMaxAmountCount=10,gMaxGuxingDays=360,m5crypto="md5",fs=require("fs"),host="http://www.dadayouzi.com",gdadaurl="/dada.php",gdadalhburl="/dadalhb.php",gdadatfurl="/dadatf.php"
window.onload=function(){try{var e=gAppFolderH+"/iconv-lite"
iconv=require(e)}catch(t){iToasts.show(t.name+": "+t.message)}var i=gAppFolder+"/dadadata"
fs.existsSync(i)||(iToasts.show("创建数据目录："+i),fs.mkdirSync(i)),laydate.render({elem:"#hqreaday",theme:"#333744"}),laydate.render({elem:"#marketDataDate",theme:"#333744"}),laydate.render({elem:"#startdate",theme:"#333744"}),laydate.render({elem:"#enddate",theme:"#333744"}),laydate.render({elem:"#cfgDFupanStartDate",theme:"#333744"}),laydate.render({elem:"#tcglhistorydate",theme:"#333744"}),laydate.render({elem:"#stockBuyDate",theme:"#333744"}),laydate.render({elem:"#stockSellDate",theme:"#333744"}),laydate.render({elem:"#lhblistday",theme:"#333744",done:function(e,t){gmLhb.listDay()}}),copyDefaultDataFile(gLhbApartmentFile),copyDefaultDataFile(gFupanFile),copyDefaultDataFile(gGuxingFile),copyDefaultDataFile(gAllStocksFile),copyDefaultDataFile(gAllAFile),copyDefaultDataFile(gConfigFile),gCurrentTab=$("gtabfupan"),initApp()}
var gmUser={groupId:0,permissions:"",username:"noname"},deepCopy=function(e){return JSON.parse(JSON.stringify(e))},mergeFiles=function(e,t){var i=e+"/dadayouzi/jsapp",a="",n=fs.readdirSync(i)
n.forEach(function(e){var t=path.join(i,e)
t.indexOf(".js")==t.length-3&&(a+=readTextFromFile(t))}),a=a.replace("mergeFiles(gAppFolder, 'E:/stock/dadayouzi/release'); return;",""),saveTextToFile(a,t+"/dadayouzi/jsapp2/hqlib600.js"),a=readTextFromFile(e+"/dadayouzi/dada.html"),pos1=a.indexOf("<!--REPLACE START-->"),pos2=a.indexOf("<!--REPLACE END-->"),sstr=a.substring(pos1,pos2+18),newstr=a.replace(sstr,"<script type='text/javascript' src='jsapp2/hqlib600.js'></script>"),saveTextToFile(newstr,t+"/dadayouzi/dada.html"),iDlgs.show("message","done!")}
