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


Groups > comp.lang.javascript > #19541

What is a suitable solution for doing what I want

From "Tony" <tony.johansson@inport.com>
Newsgroups comp.lang.javascript
Subject What is a suitable solution for doing what I want
Date 2013-04-30 13:07 +0200
Organization A noiseless patient Spider
Message-ID <klo8g3$c1e$1@dont-email.me> (permalink)

Show all headers | View raw


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 

Back to comp.lang.javascript | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

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

csiph-web