summaryrefslogtreecommitdiff
path: root/timeline.php
diff options
context:
space:
mode:
Diffstat (limited to 'timeline.php')
-rw-r--r--timeline.php257
1 files changed, 127 insertions, 130 deletions
diff --git a/timeline.php b/timeline.php
index c7c658d4bf..259566bb88 100644
--- a/timeline.php
+++ b/timeline.php
@@ -43,6 +43,7 @@ var ob=null;
var Y=0;
var X=0;
var oldx=0;
+var oldlinew;
var personnum=0;
var type=0;
var state=0;
@@ -53,12 +54,9 @@ function ageMD(divbox, num) {
ob=divbox;
personnum=num;
type=0;
- if (N) {
- X=ob.offsetLeft;
- Y=ob.offsetTop;
- } else {
- X=ob.offsetLeft;
- Y=ob.offsetTop;
+ X=ob.offsetLeft;
+ Y=ob.offsetTop;
+ if (!N) {
oldx = event.clientX + document.documentElement.scrollLeft;
}
}
@@ -69,143 +67,142 @@ function factMD(divbox, num, mean) {
personnum=num;
boxmean = mean;
type=1;
+ oldx=ob.offsetLeft;
if (N) {
- oldx=ob.offsetLeft;
oldlinew=0;
- }
- else {
- oldx = ob.offsetLeft;
+ } else {
oldlinew = event.clientX + document.documentElement.scrollLeft;
}
}
function MM(e) {
- if (ob) {
- tldiv = document.getElementById("timeline_chart");
- if (type==0) {
- // age boxes
- newy = 0;
- newx = 0;
- if (N) {
- newy = e.pageY - tldiv.offsetTop;
- newx = e.pageX - tldiv.offsetLeft;
- if (oldx==0) oldx=newx;
- }
- else {
- newy = event.clientY + document.documentElement.scrollTop - tldiv.offsetTop;
- newx = event.clientX + document.documentElement.scrollLeft - tldiv.offsetLeft;
- }
- if ((newy >= topy-bheight/2)&&(newy<=bottomy)) newy = newy;
- else if (newy < topy-bheight/2) newy = topy-bheight/2;
- else newy = (bottomy-1);
- ob.style.top = newy+"px";
- tyear = ((newy+bheight-4 - topy) + scale)/scale + baseyear
- year = Math.floor(tyear);
- month = Math.floor((tyear*12)-(year*12));
- day = Math.floor((tyear*365)-(year*365 + month*30));
- mstamp = (year*365)+(month*30)+day;
- bdstamp = (birthyears[personnum]*365)+(birthmonths[personnum]*30)+birthdays[personnum];
- daydiff = mstamp - bdstamp;
- ba = 1;
- if (daydiff < 0 ) {
- ba = -1;
- daydiff = (bdstamp - mstamp);
- }
- yage = Math.floor(daydiff / 365);
- mage = Math.floor((daydiff-(yage*365))/30);
- dage = Math.floor(daydiff-(yage*365)-(mage*30));
- if (dage<0) mage = mage -1;
- if (dage<-30) {
- dage = 30+dage;
- }
- if (mage<0) yage = yage-1;
- if (mage<-11) {
- mage = 12+mage;
- }
- yearform = document.getElementById('yearform'+personnum);
- ageform = document.getElementById('ageform'+personnum);
- yearform.innerHTML = year+" "+month+" <?php echo utf8_substr(WT_I18N::translate('Month:'), 0, 1); ?> "+day+" <?php echo utf8_substr(WT_I18N::translate('Day:'), 0, 1); ?>";
- if (ba*yage>1 || ba*yage<-1 || ba*yage==0)
- ageform.innerHTML = (ba*yage)+" <?php echo utf8_substr(WT_I18N::translate('years'), 0, 1); ?> "+(ba*mage)+" <?php echo utf8_substr(WT_I18N::translate('Month:'), 0, 1); ?> "+(ba*dage)+" <?php echo utf8_substr(WT_I18N::translate('Day:'), 0, 1); ?>";
- else ageform.innerHTML = (ba*yage)+" <?php echo utf8_substr(WT_I18N::translate('Year:'), 0, 1); ?> "+(ba*mage)+" <?php echo utf8_substr(WT_I18N::translate('Month:'), 0, 1); ?> "+(ba*dage)+" <?php echo utf8_substr(WT_I18N::translate('Day:'), 0, 1); ?>";
- var line = document.getElementById('ageline'+personnum);
- temp = newx-oldx;
- if (textDirection=='rtl') temp = temp * -1;
- line.style.width=(line.width+temp)+"px";
- oldx=newx;
- return false;
+ if (!ob) {
+ return true;
+ }
+ var tldiv = document.getElementById("timeline_chart");
+ var newx = 0, newy = 0;
+ if (type==0) {
+ // age boxes
+ if (N) {
+ newy = e.pageY - tldiv.offsetTop;
+ newx = e.pageX - tldiv.offsetLeft;
+ if (oldx==0) oldx=newx;
+ }
+ else {
+ newy = event.clientY + document.documentElement.scrollTop - tldiv.offsetTop;
+ newx = event.clientX + document.documentElement.scrollLeft - tldiv.offsetLeft;
+ }
+ if ((newy >= topy-bheight/2)&&(newy<=bottomy)) newy = newy;
+ else if (newy < topy-bheight/2) newy = topy-bheight/2;
+ else newy = (bottomy-1);
+ ob.style.top = newy+"px";
+ var tyear = ((newy+bheight-4 - topy) + scale)/scale + baseyear;
+ var year = Math.floor(tyear);
+ var month = Math.floor((tyear*12)-(year*12));
+ var day = Math.floor((tyear*365)-(year*365 + month*30));
+ var mstamp = (year*365)+(month*30)+day;
+ var bdstamp = (birthyears[personnum]*365)+(birthmonths[personnum]*30)+birthdays[personnum];
+ var daydiff = mstamp - bdstamp;
+ var ba = 1;
+ if (daydiff < 0 ) {
+ ba = -1;
+ daydiff = (bdstamp - mstamp);
+ }
+ var yage = Math.floor(daydiff / 365);
+ var mage = Math.floor((daydiff-(yage*365))/30);
+ var dage = Math.floor(daydiff-(yage*365)-(mage*30));
+ if (dage<0) mage = mage -1;
+ if (dage<-30) {
+ dage = 30+dage;
+ }
+ if (mage<0) yage = yage-1;
+ if (mage<-11) {
+ mage = 12+mage;
+ }
+ var yearform = document.getElementById('yearform'+personnum);
+ var ageform = document.getElementById('ageform'+personnum);
+ yearform.innerHTML = year+" "+month+" <?php echo utf8_substr(WT_I18N::translate('Month:'), 0, 1); ?> "+day+" <?php echo utf8_substr(WT_I18N::translate('Day:'), 0, 1); ?>";
+ if (ba*yage>1 || ba*yage<-1 || ba*yage==0)
+ ageform.innerHTML = (ba*yage)+" <?php echo utf8_substr(WT_I18N::translate('years'), 0, 1); ?> "+(ba*mage)+" <?php echo utf8_substr(WT_I18N::translate('Month:'), 0, 1); ?> "+(ba*dage)+" <?php echo utf8_substr(WT_I18N::translate('Day:'), 0, 1); ?>";
+ else ageform.innerHTML = (ba*yage)+" <?php echo utf8_substr(WT_I18N::translate('Year:'), 0, 1); ?> "+(ba*mage)+" <?php echo utf8_substr(WT_I18N::translate('Month:'), 0, 1); ?> "+(ba*dage)+" <?php echo utf8_substr(WT_I18N::translate('Day:'), 0, 1); ?>";
+ var line = document.getElementById('ageline'+personnum);
+ var temp = newx-oldx;
+ if (textDirection=='rtl') temp = temp * -1;
+ line.style.width=(line.width+temp)+"px";
+ oldx=newx;
+ return false;
+ } else {
+ // fact boxes
+ var linewidth;
+ if (N) {
+ newy = e.pageY - tldiv.offsetTop;
+ newx = e.pageX - tldiv.offsetLeft;
+ if (oldx==0) oldx=newx;
+ linewidth = e.pageX;
} else {
- newy = 0;
- newx = 0;
- if (N) {
- newy = e.pageY - tldiv.offsetTop;
- newx = e.pageX - tldiv.offsetLeft;
- if (oldx==0) oldx=newx;
- linewidth = e.pageX;
+ newy = event.clientY + document.documentElement.scrollTop - tldiv.offsetTop;
+ newx = event.clientX + document.documentElement.scrollLeft - tldiv.offsetLeft;
+ linewidth = event.clientX + document.documentElement.scrollLeft;
+ }
+ // get diagnal line box
+ dbox = document.getElementById('dbox'+personnum);
+ var etopy, ebottomy;
+ // set up limits
+ if (boxmean-175 < topy) etopy = topy;
+ else etopy = boxmean-175;
+ if (boxmean+175 > bottomy) ebottomy = bottomy;
+ else ebottomy = boxmean+175;
+ // check if in the bounds of the limits
+ if ((newy >= etopy)&&(newy<=ebottomy)) newy = newy;
+ else if (newy < etopy) newy = etopy;
+ else if (newy >ebottomy) newy = ebottomy;
+ // calculate the change in Y position
+ var dy = newy-ob.offsetTop;
+ // check if we are above the starting point and switch the background image
+ if (newy < boxmean) {
+ if (textDirection=='ltr') {
+ dbox.style.backgroundImage = "url('<?php echo $WT_IMAGES["dline"]; ?>')";
+ dbox.style.backgroundPosition = "0% 100%";
} else {
- newy = event.clientY + document.documentElement.scrollTop - tldiv.offsetTop;
- newx = event.clientX + document.documentElement.scrollLeft - tldiv.offsetLeft;
- linewidth = event.clientX + document.documentElement.scrollLeft;
+ dbox.style.backgroundImage = "url('<?php echo $WT_IMAGES["dline2"]; ?>')";
+ dbox.style.backgroundPosition = "0% 0%";
}
- // get diagnal line box
- dbox = document.getElementById('dbox'+personnum);
- // set up limits
- if (boxmean-175 < topy) etopy = topy;
- else etopy = boxmean-175;
- if (boxmean+175 > bottomy) ebottomy = bottomy;
- else ebottomy = boxmean+175;
- // check if in the bounds of the limits
- if ((newy >= etopy)&&(newy<=ebottomy)) newy = newy;
- else if (newy < etopy) newy = etopy;
- else if (newy >ebottomy) newy = ebottomy;
- // calculate the change in Y position
- dy = newy-ob.offsetTop;
- // check if we are above the starting point and switch the background image
- if (newy < boxmean) {
- if (textDirection=='ltr') {
- dbox.style.backgroundImage = "url('<?php echo $WT_IMAGES["dline"]; ?>')";
- dbox.style.backgroundPosition = "0% 100%";
- } else {
- dbox.style.backgroundImage = "url('<?php echo $WT_IMAGES["dline2"]; ?>')";
- dbox.style.backgroundPosition = "0% 0%";
- }
- dy = (-1)*dy;
- state=1;
- dbox.style.top = (newy+bheight/3)+"px";
+ dy = (-1)*dy;
+ state=1;
+ dbox.style.top = (newy+bheight/3)+"px";
+ } else {
+ if (textDirection=='ltr') {
+ dbox.style.backgroundImage = "url('<?php echo $WT_IMAGES["dline2"]; ?>')";
+ dbox.style.backgroundPosition = "0% 0%";
} else {
- if (textDirection=='ltr') {
- dbox.style.backgroundImage = "url('<?php echo $WT_IMAGES["dline2"]; ?>')";
- dbox.style.backgroundPosition = "0% 0%";
- } else {
- dbox.style.backgroundImage = "url('<?php echo $WT_IMAGES["dline"]; ?>')";
- dbox.style.backgroundPosition = "0% 100%";
- }
-
- dbox.style.top = (boxmean+(bheight/3))+"px";
- state=0;
+ dbox.style.backgroundImage = "url('<?php echo $WT_IMAGES["dline"]; ?>')";
+ dbox.style.backgroundPosition = "0% 100%";
}
- // the new X posistion moves the same as the y position
- if (textDirection=='ltr') newx = dbox.offsetLeft+Math.abs(newy-boxmean);
- else newx = dbox.offsetRight+Math.abs(newy-boxmean);
- // set the X position of the box
- if (textDirection=='ltr') ob.style.left=newx+"px";
- else ob.style.right=newx+"px";
- // set new top positions
- ob.style.top = newy+"px";
- // get the width for the diagnal box
- newwidth = (ob.offsetLeft-dbox.offsetLeft);
- // set the width
- dbox.style.width=newwidth+"px";
- if (textDirection=='rtl') dbox.style.right = (dbox.offsetRight - newwidth) + 'px';
- dbox.style.height=newwidth+"px";
- // change the line width to the change in the mouse X position
- line = document.getElementById('boxline'+personnum);
- if (oldlinew!=0) line.width=line.width+(linewidth-oldlinew);
- oldlinew = linewidth;
- oldx=newx;
- oldstate=state;
- return false;
+
+ dbox.style.top = (boxmean+(bheight/3))+"px";
+ state=0;
}
+ // the new X posistion moves the same as the y position
+ if (textDirection=='ltr') newx = dbox.offsetLeft+Math.abs(newy-boxmean);
+ else newx = dbox.offsetRight+Math.abs(newy-boxmean);
+ // set the X position of the box
+ if (textDirection=='ltr') ob.style.left=newx+"px";
+ else ob.style.right=newx+"px";
+ // set new top positions
+ ob.style.top = newy+"px";
+ // get the width for the diagnal box
+ var newwidth = (ob.offsetLeft-dbox.offsetLeft);
+ // set the width
+ dbox.style.width=newwidth+"px";
+ if (textDirection=='rtl') dbox.style.right = (dbox.offsetRight - newwidth) + 'px';
+ dbox.style.height=newwidth+"px";
+ // change the line width to the change in the mouse X position
+ line = document.getElementById('boxline'+personnum);
+ if (oldlinew!=0) line.width=line.width+(linewidth-oldlinew);
+ oldlinew = linewidth;
+ oldx=newx;
+ oldstate=state;
+ return false;
}
}