Confirmed users
716
edits
(→API) |
|||
Line 2: | Line 2: | ||
partial interface Navigator { | partial interface Navigator { | ||
void addIdleObserver(IdleObserver); | |||
void removeIdleObserver(IdleObserver); | |||
}; | }; | ||
[NoInterfaceObject] | |||
attribute Function | interface IdleObserver { | ||
attribute Function | attribute long time; // seconds | ||
attribute Function onidle; | |||
attribute Function onactive; | |||
}; | }; | ||
Using this APi would look something like: | |||
navigator.addIdleObserver({ time: 4, onidle: myIdleHandler, onactive: myActiveHandler}); | |||
This will call the myIdleHandler function once the user has been inactive for 4 seconds. Once the user goes active again we'd call the myActiveHandler function. You can of course use any means of producing the object passed to the function, such as: | |||
navigator.addIdleObserver(new WidgetUpdateThingy(...)); | |||
navigator.addIdleObserver(getIdleObserver()); | |||
== Security/Privacy considerations == | == Security/Privacy considerations == |