日期:2014-05-17  浏览次数:20816 次

页面定时刷新实时数据


(function () {
this._get = function (__stringId) {
return document.getElementById(__stringId);
};
this._set = function (__objectTarget, __stringProperty, __objectValue) {
if (__stringProperty.indexOf(".") != -1) {
var __arrayProperty = __stringProperty.split(".");
__stringProperty = __arrayProperty.pop();
for (var i in __arrayProperty) {
__objectTarget = __objectTarget[__arrayProperty[i]];
}
}
if (__objectTarget[__stringProperty] != __objectValue) {
__objectTarget[__stringProperty] = __objectValue;
}
};
this._random = function () {
return (new Date()).getTime() + Math.random().toString().replace("0.", "");
};
this._bind = function (__functionBind, __argumentsBind) {
var __this = this;
return function () {
var __arguments = null;
if (typeof __argumentsBind != "undefined") {
for (var i = 0; i < arguments.length; i++) {
__argumentsBind.push(arguments[i]);
}
__arguments = __argumentsBind;
}
else {
__arguments = arguments;
}
return __functionBind.apply(__this, __arguments);
};
};
this._load = function (__stringUrl, __functionCallback, __stringCharset) {
var __elementScript = document.createElement("script");
__elementScript.type = "text/javascript";
if (typeof __stringCharset != "undefined") {
__elementScript.charset = __stringCharset;
}
__elementScript._functionCallback = typeof __functionCallback != "undefined" ? __functionCallback : new Function();
__elementScript[document.all ? "onreadystatechange" : "onload"] = function () {
if (document.all && this.readyState != "loaded" && this.readyState != "complete") {return;}
this._functionCallback(this);
this._functionCallback = null;
this[document.all ? "onreadystatechange" : "onload"] = null;
this.parentNode.removeChild(this);
};
__elementScript.src = __stringUrl;
document.getElementsByTagName("head")[0].appendChild(__elementScript);
};
this._set = function (__objectTarget, __stringProperty, __objectValue) {
if (__stringProperty.indexOf(".") != -1) {
var __arrayProperty = __stringProperty.split(".");
__stringProperty = __arrayProperty.pop();
for (var i in __arrayProperty) {
__objectTarget = __objectTarget[__arrayProperty[i]];
}
}
if (__objectTarget[__stringProperty] != __objectValue) {
__objectTarget[__stringProperty] = __objectValue;
}
};
this._update = function () {
this._load("http://hq.sinajs.cn/rn=" + this._random() + "&list=" + this._stringTimeCode + ",s_" + this._arrayCode.join(",s_"), this._bind(function () {
for (var i in this._arrayCode) {
var __stringKey = "hq_str_s_" + this._arrayCode[i];
var __elementPrice = this._get(this._stringPricePre