var lineWidth = 200;
|
var leftNUmber = 0;
|
var messageLefWidth = 5;
|
var checkPoint = 0;
|
sgworld = window.external.createSgworld();
|
var arr = [];
|
var rturl = "";
|
$(function () {
|
var urlNewPathName = "";
|
if (getUrlParam("tm") != "") {
|
arr = getUrlParam("tm").split("+");
|
rturl = localStorage.getItem("rootUrl");
|
var titleName = rturl.substring(rturl.lastIndexOf("\\") + 1, rturl.length);
|
if (localStorage.getItem("CheckPointYear") == "" | localStorage.getItem("CheckPointYear") == null | localStorage.getItem("CheckPointYear") == "undefined") {
|
//var maxYear = Math.max.apply(null, arr);
|
var arr = arr.sort(asc);
|
//alert(arr);
|
urlNewPathName = rturl + "\\" + arr[arr.length-1];
|
checkPoint = arr.length - 1;
|
} else {
|
urlNewPathName = rturl + "\\" + localStorage.getItem("CheckPointYear");
|
checkPoint = arr.indexOf(localStorage.getItem("CheckPointYear"));
|
}
|
//关闭已经打开的图层
|
sgworld.ProjectTree.SetVisibility("", false);
|
sgworld.ProjectTree.SetVisibility(sgworld.ProjectTree.FindItem("qinghai"), true);
|
sgworld.ProjectTree.SetVisibility(sgworld.ProjectTree.FindItem(urlNewPathName), true);
|
//飞到打开的点
|
// alert(urlNewPathName + "\\" + arr[checkPoint]);
|
var currentId = sgworld.ProjectTree.FindItem(urlNewPathName + "\\" + arr[checkPoint]);
|
if (currentId == "") {
|
var groupId = sgworld.ProjectTree.FindItem(urlNewPathName);
|
while (groupId) {
|
var groupState = sgworld.ProjectTree.IsGroup(groupId);
|
if (groupState) {
|
groupId = sgworld.ProjectTree.GetNextItem(groupId, 11);
|
} else {
|
break;
|
}
|
}
|
sgworld.Navigate.FlyTo(groupId);
|
} else {
|
sgworld.Navigate.FlyTo(currentId);
|
}
|
//文本赋值
|
$(".tname").empty();
|
$(".tname").append(titleName);
|
$(".tyear").empty();
|
$(".tyear").append("(" + (checkPoint + 1) + "/" + arr.length + ")" + arr[checkPoint] + "年");
|
init();
|
}
|
|
|
})
|
|
function init() {
|
//如果数组为空
|
if (arr.length == 0) {
|
//关闭时间轴弹窗
|
return false;
|
}
|
|
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);
|
sgworld.ProjectTree.SetVisibility("", false);
|
sgworld.ProjectTree.SetVisibility(sgworld.ProjectTree.FindItem("qinghai"), true);
|
sgworld.ProjectTree.SetVisibility(sgworld.ProjectTree.FindItem(rturl + "\\" + year), true);
|
|
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 + "年");
|
}
|
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);
|
|
|
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;
|
}
|
|
}
|
|
|
}
|