var rb = new rightBottomDatlog();
|
var lineWidth = 0;
|
var leftNUmber = 0;
|
var messageLefWidth = 5;
|
var checkPoint = 0;
|
sgworld = window.external.createSgworld();
|
var arr = [];
|
var rturl = "";
|
$(function () {
|
var tableName = getUrlParam("Type"); //decodeURI(getUrlParam("Type"));
|
$.ajax({
|
url: "../../Ashx/Secondcommon.ashx",
|
type: "post",
|
data: { Action: "GetTime", Table: tableName },
|
dataType: "json",
|
async: false,
|
success: function (result) {
|
rturl = localStorage.getItem("pathName");
|
$.each(result, function (index, value) {
|
arr.push(value.Year);
|
});
|
if (arr.length > 0) {
|
window.external.closeDialog("右下");
|
window.external.createPmDialogDock("右下", url + "chart/chartDLDZ.html?MaxTime=" + arr[arr.length - 1] + "&title=" + decodeURI(getUrlParam("title")), rb.width, rb.height, rb.top, rb.left, rb.bottom, rb.right);
|
}
|
if (arr.length <= 1) {
|
//关闭当前时间轴
|
setTimeout(function () {
|
window.external.closeDialog("左下");
|
}, 100)
|
|
return false;
|
} else {
|
//文本赋值
|
$(".tname").empty();
|
$(".tname").append(decodeURI(getUrlParam("title")));
|
$(".tyear").empty();
|
$(".tyear").append("(" + (checkPoint + 1) + "/" + arr.length + ")" + arr[checkPoint] + "年");
|
checkPoint = arr.length - 1;
|
init();
|
|
}
|
}
|
});
|
|
})
|
|
function init() {
|
//如果数组为空
|
if (arr.length == 0) {
|
//关闭时间轴弹窗
|
return false;
|
}
|
var w = document.getElementById('line').clientWidth;
|
lineWidth = ((w - (w * 0.25)) / arr.length);
|
var timeZlineHTml = "";
|
var mmessageHtml = "";
|
for (var m = 0; m < arr.length; m++) {
|
timeZlineHTml += '<div class="eline" style="margin-left:' + m * lineWidth +
|
'px;width:' + lineWidth + 'px" ></div><div class="point" data-year="' + arr[m] + '" style="margin-left:' + (m + 1) *
|
lineWidth + 'px"></div>';
|
mmessageHtml += '<div class="pmessage" style="margin-left:' + ((m + 1) * lineWidth - messageLefWidth) + 'px">' + arr[
|
m] +
|
'</div>';
|
}
|
if (arr.length > 0) {
|
timeZlineHTml += '<div class="eline" style="margin-left:' + (arr.length * lineWidth) +
|
'px"></div>';
|
}
|
$(".timeZline").empty();
|
$(".timeZline").append(timeZlineHTml + '<div class="eline" style="margin-left:' + m * lineWidth + 'px;width:' + lineWidth + 'px" >)</div>')
|
$(".mmessage").empty();
|
$(".mmessage").append(mmessageHtml);
|
|
|
$(".timeZline").find(".point").eq(checkPoint).append("<img src='img/zhou.png' />");
|
DivClick();
|
leftNUmber = -checkPoint * lineWidth;
|
console.log("initNUmber:" + leftNUmber);
|
//判断div长度是否能容纳时间轴的长度
|
var divWidth = $(".line").width();
|
if (divWidth >= arr.length * lineWidth) {
|
return;
|
} else {
|
|
$(".timeZline").css("margin-left", "" + leftNUmber + "px");
|
$(".mmessage").css("margin-left", "" + leftNUmber - messageLefWidth + "px");
|
}
|
//设置轴的宽度
|
$(".eline").width(lineWidth);
|
}
|
|
|
function DivClick() {
|
var year = "";
|
$(".pre").click(function () {
|
Pre();
|
});
|
|
$(".next").click(function () {
|
Next();
|
});
|
|
$(".bf").click(function () {
|
bf();
|
});
|
|
//点击差号
|
$(".tclose").click(function () {
|
window.external.closeDialog("左下");
|
});
|
//上一步
|
function Pre() {
|
//如果定时器在运行,清除定时器
|
if (setTime != null) {
|
window.clearInterval(setTime);
|
$(".bf").attr("src", "./img/bf.png");
|
if (checkPoint > 0) {
|
checkPoint--;
|
}
|
setTime = null;
|
}
|
$(".tyear").empty();
|
bfstate = false;
|
if (checkPoint == 0) {
|
year = $(".timeZline").find(".point").eq(checkPoint).attr("data-year");
|
$(".tyear").append("(" + (checkPoint + 1) + "/" + arr.length + ")" + year + "年");
|
return false;
|
} else {
|
$(".point").empty();
|
$(".timeZline").find(".point").eq(checkPoint - 1).append("<img src='img/zhou.png' />");
|
year = $(".timeZline").find(".point").eq(checkPoint - 1).attr("data-year");
|
$(".tyear").append("(" + checkPoint + "/" + arr.length + ")" + year + "年");
|
checkPoint = checkPoint - 1;
|
}
|
// localStorage.setItem("CheckPointYear", year);
|
window.external.closeDialog("右下");
|
window.external.createPmDialogDock("右下", url + "chart/chartDLDZ.html?MaxTime=" + year + "&title=" + decodeURI(getUrlParam("title")), rb.width, rb.height, rb.top, rb.left, rb.bottom, rb.right);
|
window.external.InvokeScript("右上", "GetYX", year);
|
window.external.closeDialog("右中");
|
|
var divWidth = $(".line").width();
|
if (divWidth >= arr.length * lineWidth) {
|
return false;
|
} else {
|
if (leftNUmber == 0 | leftNUmber > 0) {
|
return false;
|
} else {
|
$(".timeZline").css("margin-left", "" + (leftNUmber + lineWidth) + "px");
|
$(".mmessage").css("margin-left", "" + (leftNUmber + lineWidth - messageLefWidth) + "px");
|
leftNUmber = leftNUmber + lineWidth;
|
}
|
}
|
|
}
|
|
//下一步
|
function Next() {
|
if (setTime != null) {
|
window.clearInterval(setTime);
|
$(".bf").attr("src", "./img/bf.png");
|
if (checkPoint > 0) {
|
checkPoint--;
|
}
|
setTime = null;
|
}
|
bfstate = false;
|
|
$(".point").empty();
|
$(".tyear").empty();
|
if ((checkPoint + 1) >= (arr.length - 1)) {
|
$(".timeZline").find(".point").eq(arr.length - 1).append("<img src='img/zhou.png' />");
|
checkPoint = arr.length - 1;
|
year = $(".timeZline").find(".point").eq(arr.length - 1).attr("data-year");
|
|
$(".tyear").append("(" + arr.length + "/" + arr.length + ")" + year + "年");
|
} else {
|
$(".timeZline").find(".point").eq(checkPoint + 1).append("<img src='img/zhou.png' />");
|
checkPoint = checkPoint + 1;
|
year = $(".timeZline").find(".point").eq(checkPoint).attr("data-year");
|
|
$(".tyear").append("(" + (checkPoint + 1) + "/" + arr.length + ")" + year + "年");
|
}
|
window.external.closeDialog("右下");
|
window.external.createPmDialogDock("右下", url + "chart/chartDLDZ.html?MaxTime=" + year + "&title=" + decodeURI(getUrlParam("title")), rb.width, rb.height, rb.top, rb.left, rb.bottom, rb.right);
|
window.external.InvokeScript("右上", "GetYX", year);
|
window.external.closeDialog("右中");
|
|
|
var divWidth = $(".line").width();
|
if (divWidth >= arr.length * lineWidth) {
|
return false;
|
} else {
|
if ((Math.abs(leftNUmber) + $(".timeZline").width()) >= arr.length * (lineWidth)) {
|
return false;
|
} else {
|
$(".timeZline").css("margin-left", "" + (leftNUmber - lineWidth) + "px");
|
$(".mmessage").css("margin-left", "" + (leftNUmber - lineWidth - messageLefWidth) + "px");
|
leftNUmber = leftNUmber - lineWidth;
|
}
|
}
|
|
}
|
|
var bfstate = false;
|
var setTime = null;
|
|
function bf() {
|
if (bfstate == false) {
|
//图标发生改变
|
$(".bf").attr("src", "./img/zt.png");
|
leftNUmber = lineWidth;
|
checkPoint = 0;
|
setTime = setInterval(function () {
|
var temNumber = 0;
|
$(".point").empty();
|
$(".tyear").empty();
|
if (checkPoint > (arr.length - 1)) {
|
checkPoint = 0;
|
}
|
$(".timeZline").find(".point").eq(checkPoint).append("<img src='img/zhou.png' />");
|
year = $(".timeZline").find(".point").eq(checkPoint).attr("data-year");
|
$(".tyear").append("(" + (checkPoint + 1) + "/" + arr.length + ")" + year + "年");
|
if ((Math.abs(leftNUmber) + $(".timeZline").width()) >= arr.length * (lineWidth)) {
|
leftNUmber = lineWidth;
|
$(".timeZline").css("margin-left", "" + (leftNUmber - lineWidth) + "px");
|
$(".mmessage").css("margin-left", "" + (leftNUmber - lineWidth - messageLefWidth) + "px");
|
// temNumber=lineWidth;
|
} else {
|
$(".timeZline").css("margin-left", "" + (leftNUmber - lineWidth) + "px");
|
$(".mmessage").css("margin-left", "" + (leftNUmber - lineWidth - messageLefWidth) + "px");
|
temNumber = leftNUmber - lineWidth;
|
}
|
|
localStorage.setItem("CheckPointYear", year);
|
sgworld.ProjectTree.SetVisibility("", false);
|
sgworld.ProjectTree.SetVisibility(sgworld.ProjectTree.FindItem("qinghai"), true);
|
sgworld.ProjectTree.SetVisibility(sgworld.ProjectTree.FindItem(rturl + "\\" + year), true);
|
leftNUmber = temNumber;
|
|
checkPoint++;
|
}, 3000);
|
bfstate = true;
|
} else {
|
$(".bf").attr("src", "./img/bf.png");
|
if (setTime != null) {
|
window.clearInterval(setTime);
|
if (checkPoint > 0) {
|
checkPoint--;
|
}
|
setTime = null;
|
}
|
bfstate = false;
|
}
|
|
}
|
|
|
}
|