Thursday, December 1, 2011

Javascript current date and time drop downs

This full code provides to show current date and time.

function getDoubleDigitValue(i) {
 if (i < 10) {
  return "0" + i;
 }
 return i;
}
The above utility function that pre fill with '0' if value is a digit.
function getNumberOfDaysInMonth(monthName) {
  switch (monthName) {
      case "Jan":
      case "Mar":
      case "May":
      case "Jul":
      case "Aug":
      case "Oct":
      case "Dec":
          return 31;
          break;
      case "Apr":
      case "Jun":
      case "Sep": 
      case "Nov":
          return 30;
          break;
      case "Feb":
          var today = new Date();
          var yearfield = document.getElementById("yearList");
          var selectedYear =yearfield.
                            options[yearfield.selectedIndex].
                            text;
          var isLeap = new Date(selectedYear,1,29).getDate() == 29;
          if (isLeap) {
              return 29;
          }
          return 28;
          break;
      default:
          return 10;
          break;
  }
}
The above javascript function provides getting correct number of days in each month.

var monthtext=['Jan','Feb','Mar','Apr','May','Jun',
              'Jul','Aug','Sep','Oct','Nov','Dec'];

function populatedropdown(dayfield, monthfield, yearfield, 
                          hourfield, minutefield)
{
  var today = new Date();
  var dayfield = document.getElementById(dayfield);
  var monthfield = document.getElementById(monthfield);
  var yearfield = document.getElementById(yearfield);
  var hourfield = document.getElementById(hourfield);
  var minutefield = document.getElementById(minutefield); 
 
  //Set day
  var numOfDaysInThisMonth = getNumberOfDaysInMonth(
                             monthtext[today.getMonth()]);
  for (var i=0; i<numOfDaysInThisMonth; i++) {
      dayfield.options[i]=new Option(i+1, i+1);
  }
  dayfield.options[today.getDate() - 1].selected = true;

  //Set month
  for (var m=0; m<12; m++) {
      monthfield.options[m]=new Option(
                                monthtext[m], 
                                monthtext[m]);
  }
  monthfield.options[today.getMonth()]=new 
                                       Option(
                                       monthtext[today.getMonth()],
                                       monthtext[today.getMonth()], 
                                       true, true) ;
  //Set Year
  var thisyear=today.getFullYear();
  for (var y=0; y<20; y++){
      yearfield.options[y]=new Option(thisyear, thisyear);
      thisyear+=1;
  }
  yearfield.options[0]=new Option(today.getFullYear(),
                                        today.getFullYear(), 
                                        true, true);
  //Set Hour 
  for (var i=0; i<24; i++) {
      hourfield.options[i]=new Option(
                               getDoubleDigitValue(i), i);
  }
  hourfield.options[today.getHours()]=new 
                                      Option(
                                      getDoubleDigitValue(
                                      today.getHours()), 
                                      today.getHours(), 
                                      true, true) ;
  //Set minute
  for (var i=0; i<60; i++) {
      minutefield.options[i]=new Option(getDoubleDigitValue(i), i);
  }
  minutefield.options[today.getMinutes()]=new 
                                          Option(
                                          getDoubleDigitValue(
                                          today.getMinutes()), 
                                          today.getMinutes(), 
                                          true, true);
}
The above javascript function provides current day, month, year, hour and minute values and populates the whole drop down with the current date and time values. And below part is a little jQuery code that provides running of populate function when the page is ready (onload).
$(document).ready(function() { 
 
 if($("#dayList").length > 0) {
  populatedropdown("dayList", "monthList", "yearList", 
                                 "hourList", "minuteList");  
 } 
}
The last part is html part.
 <select id="dayList"> </select>
 <select id="monthList"> </select>
 <select id="yearList"> </select>
 <select id="hourList"> </select>
 <select id="minuteList"> </select>

history of Virtual Reality


As for the general definition of virtual reality is an artificial environment that is experienced through sensory stimuli (such as images and sounds) provided by a computer and in which their actions partly determine what happens in the environment. The most important key in the definition of VR is "interactivity". The heart of VR is based on interactive principles between the real and the virtual world. In Virtual Reality environments or applications, the contribution of each of the five human senses are roughly; sight 70%, hearing 20%, smell 5%, touch 4% and taste 1%. So this values show clearly that simulation of visual system plays the leading role of VR research. The second most important sense is hearing. Smell and taste are not considered yet in most virtual reality systems because of its marginal role and the difficulty in implementing. 

The first sample of virtual reality is not derived from computer world. In 1956, Morton Heilig who was a filmmaker began designing the first multisensory virtual experiences. In addition to the projected image the Sensorama provided sounds, smells, haptic sensation, and even a breeze to simulate movement. This was the first approach to create a virtual reality system and had all the characteristics of this environment, but it was not interactive. 

Ivan Sutherland proposed the first ultimate solution of virtual reality of computer world. The Ultimate Display: an artificial world construction concept that included interactive graphics, force-feedback, sound, smell and taste. 

1968, the first virtual reality system realized in hardware, not in concept. Ivan Sutherland constructs a device considered as the first Head Mounted Display (HMD), with appropriate head tracking. He put a stereo vision has been updated correctly according to the position of the user’s head size and orientation. 

1967- 1980’s the first prototype of a force-feedback system is University of North Caroline’s Haptic Systems also known as Grope. Grope-I employed 2-D movable platform and has provided particle feedback. Grope-II, 1978, extended 6D with three force and three torque. Grope III, late 80’s, introduced the Argonne Remote Manipulator, a 6DOF (degree of freedom) force reflective teleoperator. 

1975, Ken Knowlton’s Virtual Push-buttons that includes partially-silvered mirror over keyboard and programmable labels. 

1975, Large Expanse, Extra Perspective (LEEP) The combined system gave a very wide field of view stereoscopic image.
Videoplace; the first virtual environment created in 1975 by Myron Krueger – “a conceptual environment, with no existence”. In this system the silhouettes of the users grabbed by the cameras were projected on a large screen. Participants had the opportunity to interact with others through the techniques of image processing that determines its position in the 2D screen space.
Thomas Furness developed in 1982 the Visually Coupled Airborne Systems Simulator that an advanced flight simulator.
Patented in 1983, Grimes’ Digital Data Entry Glove had finger flex sensors, tactile sensors at the fingertips, orientation sensing and wrist-positioning sensors.
Between 1987 and 1990’s British Aerospace proposed Virtual Cockpit, Virtual Environment Configurable Training Aids (VECTA) Real and Virtual Environment Configurable Training Aids (RAVECTA).
1990’s W Industries developed Location-based entertainment.
University of North Carolina proposed wide-area optical tracking system
CAVE presented in 1992 (CAVE Automatic Virtual Environment) is a virtual reality and scientific visualization system. Instead of using a HMD it projects stereo- scopic images on the walls of room (user must wear LCD shutter glasses). This approach ensures superior quality and resolution of the images seen and wider field of view compared to HMD based systems. 
Augmented Reality (AR) a technology that “presents a virtual world that enriches, rather than replaces the real world”. This is accomplished by means of see-through HMD that superimposes virtual objects in real three-dimensional.