Skip to content

Commit

Permalink
fix getBlock recursive issue
Browse files Browse the repository at this point in the history
  • Loading branch information
chxj1992 committed Oct 17, 2017
1 parent b06c677 commit 3dbcafc
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions js/kline.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var Kline = function (option) {

this.element = "#kline_container";
this.chartMgr = null;
this.G_HTTP_REQUEST = null;
Expand Down Expand Up @@ -83,20 +84,23 @@ Kline.prototype = {
var KlineIns = null;


var KlineTrade = function () {
var KlineTrade = function (option) {

this.browerState = 0;
this.tradeDate = new Date();
this.tradesLimit = 20;
this.lastDepth = null;
this.depthShowSize = 15;
this.priceDecimalDigits = 6;
this.amountDecimalDigits = 4;
this.symbol = null;
this.curPrice = null;
this.title = "";

Object.assign(this, option);
};

KlineTrade.prototype = {
browerState: 0,
tradeDate: new Date(),
tradesLimit: 100,
lastDepth: null,
depthShowSize: 15,
priceDecimalDigits: 6,
amountDecimalDigits: 4,
symbol: null,
curPrice: null,
title: "",

reset: function (symbol) {
this.symbol = symbol;
Expand Down Expand Up @@ -407,7 +411,7 @@ KlineTrade.prototype = {
return gbids;
},
getBlock: function (b, scale) {
if (b > scale) {
if (b > scale || b <= 0) {
return scale;
} else {
scale = scale / 10;
Expand Down Expand Up @@ -457,7 +461,7 @@ KlineTrade.prototype = {
}
return [amount1, amount2];
},
dateFormatTf:function(i){
dateFormatTf: function (i) {
return (i < 10 ? '0' : '') + i;
},
};
Expand Down Expand Up @@ -8973,7 +8977,7 @@ function requestOverSocket() {
}
KlineIns.timer = setTimeout(function () {
RequestData(true);
}, KlineIns.intervalTime);
}, 1000);
}

function requestOverHttp() {
Expand Down Expand Up @@ -9119,6 +9123,9 @@ function setHttpRequestParam(mark_from, range, limit, since) {
str += "&limit=" + limit;
else
str += "&since=" + since;
if (KlineTradeIns.tradeDate.getTime() != 0) {
str += "&prevTradeTime=" + KlineTradeIns.tradeDate.getTime()
}
return str;
}

Expand Down Expand Up @@ -9498,8 +9505,8 @@ function socketConnect() {
requestSuccessHandler(JSON.parse(res.body));
});
}, function () {
console.log("reconnect in 5 seconds ...");
setTimeout(function () {
console.log("reconnect in 5 seconds");
socketConnect();
}, 5000);
});
Expand Down

0 comments on commit 3dbcafc

Please sign in to comment.