pluotsorbet/midp/device_control.js

29 строки
898 B
JavaScript
Исходник Обычный вид История

2014-11-27 03:04:47 +03:00
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
'use strict';
Native.create("com/nokia/mid/ui/DeviceControl.startVibra.(IJ)V", function(freq, longDuration) {
2014-11-27 03:04:47 +03:00
// If method is called during a previously called vibration that has been
// activated from this method, the previous vibration is stopped and the new
// one is activated using the new set of parameters.
navigator.vibrate(0);
// Value 0 can be used for detecting whether or not there is a vibration device.
if (freq === 0) {
return;
}
var duration = longDuration.toNumber();
if (freq < 0 || freq > 100 || duration < 0) {
throw new $.newIllegalArgumentException();
2014-11-27 03:04:47 +03:00
}
navigator.vibrate(duration);
});
Native.create("com/nokia/mid/ui/DeviceControl.stopVibra.()V", function() {
navigator.vibrate(0);
});