1.0.0 • Published 10 years ago
browserapi v1.0.0
browserapi
A wrapper tool for next generation browser apis like vibration, fullscreen, and etc.
###Supported APIs
- Geolocation
- fetch
- Fullscreen API
- Battery
- ServiceWorker
- DeviceOrientation
- Vibrate
- AudioContext
####Geolocation
browserapi.get('geolocation')((geolocation) => {
geolocation.getCurrentPosition(function (data) {
console.dir(data); //successfully get the Geoposition data
}, function (err) {
console.dir(err); // logs the error stack
}, {
enableHighAccuracy: true,
timeout: 5000,
maximumAge: 0
}); //options while getting geolocation data
});####fetch
browserapi.get('fetch')((fetch) => {
fetch(new Request('<URL>')).then(function (data) {
console.dir(data);
});
});#####Fullscreen API
browserapi.get('fullScreen')(document.querySelector('body'), (fullScreen) => {
console.dir(fullScreen);
});#####Note : This method invocation prints "Failed to execute 'requestFullScreen' on 'Element': API can only be initiated by a user gesture.". Since the security concerns, it only can be triggered by a user event like click or etc.
####Battery
browserapi.get('battery')((battery) => {
console.dir(battery);
});####ServiceWorker
browserapi.get('serviceWorker')((serviceWorker) => {
console.dir(instance);
});####localStorage
browserapi.get('localStorage')((localStorage) => {
localStorage.setItem('some_data', '{some_data : "yes, cool..."}');
console.dir(localStorage.getItem('some_data'));
});####deviceOrientation
browserapi.get('deviceOrientation')((deviceOrientation) => {
console.dir(deviceOrientation);
});####vibrate
browserapi.get('vibrate')((vibrate) => {
navigator['vibrate'](1000);
});####audioContext
browserapi.get('audioContext')((audioContext) => {
console.dir(audioContext);
});1.0.0
10 years ago