Archive for December, 2007

M MouseEvent.initMouseEvent() (Method) MouseEvent.initMouseEvent() (Method) After creating (X web hosting)

Monday, December 17th, 2007

M MouseEvent.initMouseEvent() (Method) MouseEvent.initMouseEvent() (Method) After creating a MouseEventobject, it must be initialised with this method call. Availability: DOM level 2 JavaScript 1.5 Netscape 6.0 JavaScript syntax: N myMouseEvent.initMouseEvent(aType, aBubble, aCancel, aView, aDetail, aScrnX, aScrnY, aClntX, aClntY, aCtrl, anAlt, aShift, aMeta, aButton, aRelTarg) aType A string value describing the event type aBubble A boolean flag indicating whether the event can bubble aCancel A boolean flag indicating whether the event can be cancelled aView A reference to an AbstractView object aDetail A value describing the event detail aScrnX A screen X coordinate value aScrnY A screen Y coordinate value aClntX A client X coordinate value aClntY A client Y coordinate value aCtrl A boolean value indicating the state of the control key anAlt A boolean value indicating the state of the alt key aShift A boolean value indicating the state of the shift key aMeta A boolean value indicating the state of the meta key aButton A numeric value indicating which button is being emulated Argument list: aRelTarg A reference to an EventTarget object A new event object is manufactured by calling the DocumentEvent.createEvent() method. That event should have been defined with a type specified as “MouseEvent”. If it was, then it will support an initMouseEvent()method. This must be called before the event is dispatched otherwise the event object will not contain enough information for the event dispatcher/handler to make sense of it and route it to the correct target objects. Two boolean argument values define whether the event will be allowed to be cancelled and what type of propagation to use (bubbleor capture). The view argument refers to an AbstractView object which DOM level 2 describes and which may not yet be well supported by any browser. The detail value can be used to pass context information into the event handling chain. The screen and client coordinate values are measured in pixels and must be specified as numeric values. Five boolean values then define the state of keyboard keys when the event was assumed to be triggered. Finally a reference to a related target object is passed. See also: AbstractView object, EventTarget object, UIEvent.initUIEvent() 1461

JavaScript Programmer’s Reference MouseEvent.clientY (Property) (Web site construction) Mouse position relative

Saturday, December 15th, 2007

JavaScript Programmer’s Reference MouseEvent.clientY (Property) Mouse position relative to the web page. DOM level 2 JavaScript 1.5 Netscape 6.0 Availability: Property/method value type: JavaScript syntax: This is the vertical position of the mouse when the event was triggered. The position is calculated relative to the visible document area within the window or frame the mouse was positioned in when the event triggered. Number primitive myMouseEvent.clientY N See also: Event.clientY Property attributes: ReadOnly. MouseEvent.ctrlKey (Property) A Boolean value that represents the state of the [control] key. DOM level 2 JavaScript 1.5 Netscape 6.0 Availability: Property/method value type: JavaScript syntax: Boolean primitive myMouseEvent.ctrlKey N When an event is being processed, you may want to know the state of the [control] key on the keyboard. This Boolean property returns true when the [control] key is pressed and false when it is not. This property reflects the state of the [control] key at the instant when the event was triggered. The user may have released the key in the meantime so you should not assume that if the [control] key was pressed earlier on that it is still pressed when the event handler is being executed. See also: Event.ctrlKey Property attributes: ReadOnly. 1460

M MouseEvent.clientX (Property) Third party mice can

Saturday, December 15th, 2007

M MouseEvent.clientX (Property) Third party mice can be added to Apple Macintosh systems to provide multiple (2 or 3) button functionality but they are by no means commonplace and it is probably safe to assume only a 1 button mouse on the Macintosh platform. The values for the buttons are defined to cope with 1, 2 or 3 button mice. The following values correspond with mouse buttons: . 0 No mouse button was pressed when the event was triggered . 1 The left button was pressed . 2 The right button was pressed . 3 The middle button was pressed See also: Event.button, Event.which Property attributes: ReadOnly. MouseEvent.clientX (Property) Mouse position relative to the web page. DOM level 2 JavaScript 1.5 Netscape 6.0 Availability: Property/method value type: JavaScript syntax: N Number primitive myMouseEvent.clientX This is the horizontal position of the mouse when the event was triggered. The position is calculated relative to the visible document area within the window or frame the mouse was positioned in when the event triggered. See also: Event.clientX Property attributes: ReadOnly. 1459

JavaScript Programmer’s Reference MouseEvent.altKey (Property) A Boolean value

Friday, December 14th, 2007

JavaScript Programmer’s Reference MouseEvent.altKey (Property) A Boolean value that represents the state of the [alt] key. DOM level 2 JavaScript 1.5 Netscape 6.0 Availability: Property/method value type: JavaScript syntax: N Boolean primitive myMouseEvent.altKey When an event is being processed, you may want to know the state of the [alt] key on the keyboard. This Boolean property returns true when the [alt]key is pressed and falsewhen it is not. This property reflects the state of the [alt] key at the instant when the event was triggered. The user may have released the [alt] key in the meantime so you should not assume that if the [alt] key was pressed earlier on that it is still pressed when the event handler is being executed. Warnings: . The key may not always be labelled “ALT” on the keyboard. See also: Event.altKey Property attributes: ReadOnly. MouseEvent.button (Property) The mouse button that was pressed to trigger the event. DOM level 2 JavaScript 1.5 Netscape 6.0 Availability: Property/method value type: JavaScript syntax: N Number primitive myMouseEvent.button If you need to determine which mouse button was pressed to trigger the event, this property will contain a value to indicate the button. Note that on a Macintosh, this value is meaningless as there is only one button on an Apple Macintosh mouse. 1458

M MouseEvent object (Object/DOM) This kind of

Thursday, December 13th, 2007

M MouseEvent object (Object/DOM) This kind of event is a scenario where event bubbling is likely to be useful because the mouse may click on a pixel sized item which is a child of the object that is really receiving a higher level event. See also: AbstractView object, Event object, Implementation.hasFeature(), onClick, onMouseDown, onMouseMove, onMouseOut, onMouseOver, onMouseUp, UIEvent object Property JavaScript JScript Nav IE Opera DOM Notes altKey 1.5 + 6.0 + 2 + Warning, ReadOnly bubbles 1.5 + 6.0 + 2 + - button 1.5 + 6.0 + 2 + ReadOnly cancelable 1.5 + 6.0 + 2 + - clientX 1.5 + 6.0 + 2 + ReadOnly clientY 1.5 + 6.0 + 2 + ReadOnly cllientX 1.5 + 6.0 + 2 + - ctrlKey 1.5 + 6.0 + 2 + ReadOnly currentTarget 1.5 + 6.0 + 2 + - detail 1.5 + 6.0 + 2 + - eventPhase 1.5 + 6.0 + 2 + - metaKey 1.5 + 6.0 + 2 + Warning, ReadOnly relatedTarget 1.5 + 6.0 + 2 + ReadOnly screenX 1.5 + 6.0 + 2 + ReadOnly screenY 1.5 + 6.0 + 2 + ReadOnly shiftKey 1.5 + 6.0 + 2 + ReadOnly target 1.5 + 6.0 + 2 + - timeStamp 1.5 + 6.0 + 2 + - type 1.5 + 6.0 + 2 + - view 1.5 + 6.0 + 2 + - Method JavaScript JScript Nav IE Opera DOM Notes initEvent() 1.5 + 6.0 + 2 + - initMouseEvent() 1.5 + 6.0 + 2 + - initUIEvent() 1.5 + 6.0 + 2 + - preventDefault() 1.5 + 6.0 + 2 + - stopPropagation() 1.5 + 6.0 + 2 + - 1457

JavaScript Programmer’s Reference Note that some of these (Professional web hosting)

Wednesday, December 12th, 2007

JavaScript Programmer’s Reference Note that some of these events are triggered in multiples as a result of a single action. For example, as a mouse button is pressed, a mouse-down event is fired. As it is released, a mouse-up and a click event are fired. A clickevent is only fired once for each mouse-down and mouse-up pair. A double-click requires two down-up cycles within quick succession but the mouse-down and mouse-upevents will also fire. The DOM standard refines the event model and creates a specific object class to handle Mouse Events. The event model will evolve as more browsers take on the DOM specified model. See also: onClick, onDblClick, onMouseDown, onMouseDrag, onMouseMove, onMouseOut, onMouseOver, onMouseUp MouseEvent object (Object/DOM) This is part of the DOM level 2 mouse event set. DOM level 2 JavaScript 1.5 Netscape 6.0 Availability: JavaScript syntax: myMouseEvent = new MouseEvent() N Object properties: altKey, bubbles, button, cancelable, clientX, clientY, cllientX, ctrlKey, currentTarget, detail, eventPhase, metaKey, relatedTarget, screenX, screenY, shiftKey, target, timeStamp, type, view initEvent(), initMouseEvent(), initUIEvent(), Object methods: preventDefault(), stopPropagation() The availability of the MouseEventobject handling can be determined with the Implementation.hasFeature() method call. The available set of events is defined by HTML 4.0 and DOM level 0 with some additional events having been added. These event types are enumerated in the DOM level 2 specification and are: . click . mousedown . mouseup . mouseover . mousemove . mouseout The contextual information is carried in the detail property which is inherited from the UIEvent object. This value is incremented for each complete mouse click cycle but is reset to zero if the mouse is moved, even if that happens between mousedown and mouseup. 1456

M Month number (Time calculation) Cross-references: ECMA (Christian web host)

Wednesday, December 12th, 2007

M Month number (Time calculation) Cross-references: ECMA 262 edition 2 section 15.9.1.4 ECMA 262 edition 3 section 15.9.1.4 Month number (Time calculation) A date and time algorithm. Availability: Property/method value type: ECMAScript edition 2 Number primitive In ECMA compliant implementations, months are identified by an integer in the range 0 to 11, inclusive. The month number is calculated by taking the number of the day at the target time and then taking the day number at the start of that year. The difference is the day number within the year, which can then be used via a compare and lookup mechanism to deduce the month. The InLeapYear() method comes into play to offset the day number by one when it is a leap year. See also: Day number, Day within year, Month from time, Time range Cross-references: ECMA 262 edition 2 section 15.9.1.4 ECMA 262 edition 3 section 15.9.1.4 MotionBlur() (Filter/visual) An enhanced motion blur artefact that replaces the older Blur() filter functionality. Availability: JScript 5.5 Internet Explorer 5.5 Refer to: filter MotionBlur() Mouse events (Definition) Mouse events are part of the browser’s event handling complex and are triggered by physical interaction with the mouse. These events correspond to user actions as the mouse is moved over various elements on the screen or as the user clicks the mouse buttons. 1455

JavaScript Programmer’s Reference return ii; } } return (My space web page)

Tuesday, December 11th, 2007

JavaScript Programmer’s Reference return ii; } } return 12; } // Work out day number within year based on time value function dayWithinYear(aMilliseconds) { var myDayNumber = dayNumber(aMilliseconds); var myYearFromTime = yearFromTime(aMilliseconds); var myDayFromYear = dayFromYear(myYearFromTime); var myDayWithinYear = myDayNumber myDayFromYear; return myDayWithinYear; } // Return year number based on time value function yearFromTime(aMilliseconds) { var myStartYear = 1970; while(timeFromYear(myStartYear) < myMilliseconds) { myStartYear++ } return myStartYear-1; } // Work out milliseconds at start of year function timeFromYear(aYear) { var myTime = msPerDay * dayFromYear(aYear); return myTime; } // Work out day number from milliseconds function dayNumber(aMillisecondTime) { var myDay = Math.floor(aMillisecondTime/msPerDay); return myDay; } // Day from year function function dayFromYear(aYear) { var myDay = 365 * (aYear 1970) + Math.floor((aYear 1969) / 4) - Math.floor((aYear 1901) / 100) + Math.floor((aYear 1601) / 400); return myDay; } // Flag a leap year with a Boolean value function inLeapYear(aYear) { if((aYear % 4) != 0) { return false; } if(((aYear % 100) != 0) || ((aYear % 400) == 0)) { return true; } return false; } See also: Date from time, Date number, Day from year, Day number, Day within year, Month number, Year from time 1454

M Month from time (Time calculation) The (Web server type)

Monday, December 10th, 2007

M Month from time (Time calculation) The month value is worked out with this formulaic framework: MonthFromTime(t) = lookup according to DayWithinYear(t) falling into a range according to the following table: Greater than Less than Month Name 000 031 0 January 031 059 + InLeapYear(t) 1 February 059 + InLeapYear(t) 090 + InLeapYear(t) 2 March 090 + InLeapYear(t) 120 + InLeapYear(t) 3 April 120 + InLeapYear(t) 151 + InLeapYear(t) 4 May 151 + InLeapYear(t) 181 + InLeapYear(t) 5 June 181 + InLeapYear(t) 212 + InLeapYear(t) 6 July 212 + InLeapYear(t) 243 + InLeapYear(t) 7 August 243 + InLeapYear(t) 273 + InLeapYear(t) 8 September 273 + InLeapYear(t) 304 + InLeapYear(t) 9 October 304 + InLeapYear(t) 334 + InLeapYear(t) 10 November 334 + InLeapYear(t) 365 + InLeapYear(t) 11 December Note that MonthFromTime(0) is 0 which corresponds to Thursday, 01-January-1970. Example code: // Work out a month number from a time value 1453 var msPerDay = 86400000; var myMilliseconds = Number(new Date()); document.write(monthFromDayNumber(myMilliseconds)); // Month from day number function monthFromDayNumber(aMillisecondTime) { var myMonthLookup = new Array(); var myDayWithinYear = dayWithinYear(aMillisecondTime); var myYearFromTime = yearFromTime(aMillisecondTime); var myLeapNumber = +inLeapYear(myYearFromTime); myMonthLookup[0] = 0; myMonthLookup[1] = 31; myMonthLookup[2] = 59 + myLeapNumber; myMonthLookup[3] = 90 + myLeapNumber; myMonthLookup[4] = 120 + myLeapNumber; myMonthLookup[5] = 151 + myLeapNumber; myMonthLookup[6] = 181 + myLeapNumber; myMonthLookup[7] = 212 + myLeapNumber; myMonthLookup[8] = 243 + myLeapNumber; myMonthLookup[9] = 273 + myLeapNumber; myMonthLookup[10] = 304 + myLeapNumber; myMonthLookup[11] = 334 + myLeapNumber; for(var ii=0; ii<12; ii++) { if(myDayWithinYear < myMonthLookup[ii]) {

JavaScript Programmer’s Reference Modulo (Operator/multiplicative) Modulo operations are

Sunday, December 9th, 2007

JavaScript Programmer’s Reference Modulo (Operator/multiplicative) Modulo operations are called remainder in JavaScript. They may also be called modulus. See also: Days in year, Multiplicative expression, Remainder (%) Money (Definition) A locale specific value. See also: Localization, Currency symbol Month from time (Time calculation) A date and time algorithm defined by ECMAScript. Availability: Property/method value type: ECMAScript edition 2 Number primitive In an ECMA compliant implementation, given a time measured in milliseconds from 01-January1970 UTC, the month number can be calculated from the value. The formula for calculating day number is shown here: Day(t) = floor(t/msPerDay), where: t = an instant in time measured in milliseconds relative to 01-January-1970 UTC. msPerDay = 86400000 All non-leap years have 365 days with the usual number of days in each month. Leap years have an extra day in February. The calculation shown below uses known leap years and non-leap years to adjust the day numbers and yield the day number of the first day of the given year and then use that to work out the time in milliseconds when the year started: DayFromYear(y) = 365 * (y 1970) + floor((y 1969) / 4) - floor((y 1901) / 100) + floor((y 1601) / 400) TimeFromYear(y) = msPerDay * DayFromYear(y) YearFromTime(t) = The largest integer y to make TimeFromYear(y) less than or equal to t. DayWithinYear(t) = Day(t) DayFromYear(YearFromTime(t)) 1452