Sensor API: Difference between revisions

6 bytes removed ,  9 September 2011
no edit summary
No edit summary
No edit summary
Line 17: Line 17:
     attribute Function onSensorAvailable;
     attribute Function onSensorAvailable;
}
}
interface Sensor : EventTarget {
interface Sensor : EventTarget {
readonly attribute DOMString type;            // Vocabulary to be defined ("Acceleration", "AmbientLight")
readonly attribute DOMString type;            // Vocabulary to be defined ("Acceleration", "AmbientLight")
Line 23: Line 22:
// Another method to retrieve capabilities??
// Another method to retrieve capabilities??
}
}
interface SensorSession : EventTarget {
interface SensorSession : EventTarget {
     readonly attribute Sensor sensor;
     readonly attribute Sensor sensor;
Line 43: Line 41:
     attribute Function onError;
     attribute Function onError;
}
}
interface SensorData {
interface SensorData {
     readonly attribute any value;
     readonly attribute any value;
}
}
// New DOM Event 'sensordata'
// New DOM Event 'sensordata'
interface SensorDataEvent : Event {
interface SensorDataEvent : Event {
Line 56: Line 52:
                                 in SensorData data);
                                 in SensorData data);
}
}
interface SensorWatchOptions {
interface SensorWatchOptions {
     attribute  any highThreshold; // High threshold. If the sensor value is higher a data event will be raised
     attribute  any highThreshold; // High threshold. If the sensor value is higher a data event will be raised
Line 71: Line 66:
   window.console.log('Acceleration along the x axis: ' + e.value.x);
   window.console.log('Acceleration along the x axis: ' + e.value.x);
}
}
var watchOptions =  { interval = 1.0 } // Every one millisecond
var watchOptions =  { interval = 1.0 } // Every one millisecond
session.watch(watchOptions);
session.watch(watchOptions);
172

edits