Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #19541 > unrolled thread

What is a suitable solution for doing what I want

Started by"Tony" <tony.johansson@inport.com>
First post2013-04-30 13:07 +0200
Last post2013-04-30 13:43 +0200
Articles 2 — 1 participant

Back to article view | Back to comp.lang.javascript


Contents

  What is a suitable solution for doing what I want "Tony" <tony.johansson@inport.com> - 2013-04-30 13:07 +0200
    Re: What is a suitable solution for doing what I want "Tony" <tony.johansson@inport.com> - 2013-04-30 13:43 +0200

#19541 — What is a suitable solution for doing what I want

From"Tony" <tony.johansson@inport.com>
Date2013-04-30 13:07 +0200
SubjectWhat is a suitable solution for doing what I want
Message-ID<klo8g3$c1e$1@dont-email.me>
I have this functionAddSlot below that is called three times for each ship 
that must pass a bridge that must be opened. We call this a booking
I create three div.
The first div that is created represent the start opening time of the bridge 
and the endtime  represent when the bridge is fully open.
The second div that is created represent the startTime when the ship can 
start to pass the bridge and the endtime represent when the ship has passed 
the bridge.
The third div that is created represent the start closing time of a bridge 
and the endtime  represent when when the bridge is fully closed.
An example.
So the first div could have starttime 2013-04-22 15:10  and end time 
2013-04-22 15:41
So the first div could have starttime 2013-04-22 15:41  and end time 
2013-04-22 16:00
So the first div could have starttime 2013-04-22 16:00  and end time 
2013-04-22 16:20

As you can see you never any time gap because the end time is the same as 
start time
Each call to this AddSlot function pass two times it's the StartTime and the 
Endtime.

I have add an event handler called Test_hover() that is called when I hover 
of one of the divs.
What I want is that no matter which of the three div I hover over I must get 
the starttime for the first created div
and the end time fir the third created div.

Is it anyone that might have any suggestion for a solution to my problem ?

function AddSlot(track, type, minStart, minEnd, confirmed)
  {
      var unit;

      //Check the status for the selected interval
      if (currentInterval == "Interval.RdoHour")
          unit = track.offsetWidth / (8 * 60);
      else if (currentInterval == "Interval.RdoHalv")
          unit = track.offsetWidth / (4 * 60);
      else if (currentInterval == "Interval.RdoKvart")
          unit = track.offsetWidth / (2 * 60);

      //Create a div element
      slot = document.createElement("div");
      slot.setAttribute("onmouseover", "Test_hover(this)");

      //Set additional attribute
      if (confirmed)
      {
          slot.setAttribute("style", "background-color:#00FF00; 
border-left:1px solid black;  border-right:1px solid black; text-align: 
center");
      }
      else
      {
          slot.setAttribute("style", "background-color:#FF0000; 
border-left:1px solid black;  border-right:1px solid black; text-align: 
center");
      }

      //Add an attribute class
      slot.className = "slot " + type;

      // Set the start pos and width for the new element slot
      slot.style.left = Math.round(unit * minStart) + "px";
      slot.style.width = Math.round(unit * (minEnd - minStart)) + "px";


      //Check if we have reached the max boundry on the right side of the 
element
      // If we have done that change the width to the maximum boundry
      if (Math.round(unit * minStart) + Math.round(unit * (minEnd - 
minStart)) > 480 * unit && currentInterval == "Interval.RdoHour")
      {
         slot.style.width = unit * 480 - Math.round(unit * minStart) + "px";
      }
      else if (Math.round(unit * minStart) + Math.round(unit * (minEnd - 
minStart)) > 240 * unit && currentInterval == "Interval.RdoHalv")
      {
         slot.style.width = unit * 240 - Math.round(unit * minStart) + "px";
      }
      else if (Math.round(unit * minStart) + Math.round(unit * (minEnd - 
minStart)) > 120 * unit && currentInterval == "Interval.RdoKvart")
      {
         slot.style.width = unit * 120 - Math.round(unit * minStart) +"px";
      }

      track.appendChild(slot);
  }

//Tony 

[toc] | [next] | [standalone]


#19543

From"Tony" <tony.johansson@inport.com>
Date2013-04-30 13:43 +0200
Message-ID<kloaia$na8$1@dont-email.me>
In reply to#19541

"Tony"  wrote in message news:klo8g3$c1e$1@dont-email.me...

I have this functionAddSlot below that is called three times for each ship
that must pass a bridge that must be opened. We call this a booking
I create three div.
The first div that is created represent the start opening time of the bridge
and the endtime  represent when the bridge is fully open.
The second div that is created represent the startTime when the ship can
start to pass the bridge and the endtime represent when the ship has passed
the bridge.
The third div that is created represent the start closing time of a bridge
and the endtime  represent when when the bridge is fully closed.
An example.
So the first div could have starttime 2013-04-22 15:10  and end time
2013-04-22 15:41
So the first div could have starttime 2013-04-22 15:41  and end time
2013-04-22 16:00
So the first div could have starttime 2013-04-22 16:00  and end time
2013-04-22 16:20

As you can see you never any time gap because the end time is the same as
start time
Each call to this AddSlot function pass two times it's the StartTime and the
Endtime.

I have add an event handler called Test_hover() that is called when I hover
of one of the divs.
What I want is that no matter which of the three div I hover over I must get
the starttime for the first created div
and the end time fir the third created div.

Is it anyone that might have any suggestion for a solution to my problem ?

function AddSlot(track, type, minStart, minEnd, confirmed)
  {
      var unit;

      //Check the status for the selected interval
      if (currentInterval == "Interval.RdoHour")
          unit = track.offsetWidth / (8 * 60);
      else if (currentInterval == "Interval.RdoHalv")
          unit = track.offsetWidth / (4 * 60);
      else if (currentInterval == "Interval.RdoKvart")
          unit = track.offsetWidth / (2 * 60);

      //Create a div element
      slot = document.createElement("div");
      slot.setAttribute("onmouseover", "Test_hover(this)");

      //Set additional attribute
      if (confirmed)
      {
          slot.setAttribute("style", "background-color:#00FF00;
border-left:1px solid black;  border-right:1px solid black; text-align:
center");
      }
      else
      {
          slot.setAttribute("style", "background-color:#FF0000;
border-left:1px solid black;  border-right:1px solid black; text-align:
center");
      }

      //Add an attribute class
      slot.className = "slot " + type;

      // Set the start pos and width for the new element slot
      slot.style.left = Math.round(unit * minStart) + "px";
      slot.style.width = Math.round(unit * (minEnd - minStart)) + "px";


      //Check if we have reached the max boundry on the right side of the
element
      // If we have done that change the width to the maximum boundry
      if (Math.round(unit * minStart) + Math.round(unit * (minEnd -
minStart)) > 480 * unit && currentInterval == "Interval.RdoHour")
      {
         slot.style.width = unit * 480 - Math.round(unit * minStart) + "px";
      }
      else if (Math.round(unit * minStart) + Math.round(unit * (minEnd -
minStart)) > 240 * unit && currentInterval == "Interval.RdoHalv")
      {
         slot.style.width = unit * 240 - Math.round(unit * minStart) + "px";
      }
      else if (Math.round(unit * minStart) + Math.round(unit * (minEnd -
minStart)) > 120 * unit && currentInterval == "Interval.RdoKvart")
      {
         slot.style.width = unit * 120 - Math.round(unit * minStart) +"px";
      }

      track.appendChild(slot);
  }

//Tony

I think I use an attribute that will solve my problem

//Tony 

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web