0.0.1-beta-0.1.8 • Published 9 years ago

butler.js v0.0.1-beta-0.1.8

Weekly downloads
4
License
MIT
Repository
github
Last release
9 years ago

###What is Butler?

Butler.js is the voice driven, portable butler for your personal needs.

You can easily customize it to your needs and he will never betray you.

Butler is developed with the aim of making life simpler for developers and designers, specifically in debugging/drafting.

What you would have done before through the keyboard and scripts can now be done by commanding Butler by voice.

With a bit of healthy humor and fun.

Join the chat at https://gitter.im/720kb/butler

###Why Butler?

Many libraries offer the possibility to activate voice commands, Butler offers the same but it starts with already defined commands that can help you debugging or anyway to have fun while debugging and make your life simpler in the browser daily routine.

Plus you have the ability to write your own plugins (and this is very easy) to expand the abilities of Butler at your leisure.

###Installation

####HTML

<!DOCTYPE html>
<html>
<head>
<script src="../path/to/butler.min.js"></script>
</head>

####Bower

bower install butler.js

####Npm

npm install butler.js

###Usage

document.addEventListener("DOMContentLoaded", function() {
  Butler.start();
});

###Demo Live demo

Commands

Default voice commands you can abuse of. (many others are coming...)

####Butler Common commands for Butler

CommandResult
Butler speakTurn on Butler voice
Butler silenceTurn off Butler voice

####Selector Commands to select, visualize and manipulate the DOM elements

CommandResult
Selector onTurn on selector highlighter
Selector offTurn off selector highlighter
Selector nextSelect next element in the DOM
Selector backSelect previous element in the DOM
Selector next id :detection:Select next element in the DOM by detected id value
Selector next class :detection:Select next element in the DOM by detected class name
Selector next tag :detection:Select next element by detected tag name
Selector back id :detection:Select previous element by detected id value
Selector back class :detection:Select next element by detected class name
Selector back tag :detection:Select next element by detected tag name
Selector add class :detection:Add detected class name to the current selected DOM element
Selector remove class :detection:Remove detected class name from the current selected DOM element
Selector add id :detection:Add detected id value to the current selected DOM element
Selector put value :detection:Add detected value to the current selected DOM element (helpful for inputs)
Selector insert text :detection:Insert detected text inside the current selected DOM element
Selector empty textRemove all the text from the current selected DOM element
Selector copy textCopy all the text from the current selected DOM element
Selector paste textPaste the previously copied text to the current selected DOM element
Selector make editableMake the current selected DOM element editable
Selector not editableMake the current selected DOM element not editable
Selector make disabledMake the current selected DOM element disabled
Selector not disabledMake the current selected DOM element not disabled
Selector cloneClone the current selected DOM element
Selector append cloneAppend the cloned element to the current selected DOM element
Selector prepend clonePrepend the cloned element to the current selected DOM element
Selector deleteDelete the current selected DOM element
Selector hideHide the current selected DOM element
Selector showShow the current selected DOM element
Selector let me chooseSelect yourself which DOM element by clicking the element
Selector whichShow and alert the current selected DOM element informations

####Trigger

Commands to trigger events and actions

CommandResult
Trigger clickTrigger click on the current selected DOM element
Trigger focusTrigger focus on the current selected DOM element
Trigger fadeTrigger fade on the current selected DOM element
Trigger pinTrigger pin on the current selected DOM element
Trigger blurTrigger blur on the current selected DOM element
Trigger submitTrigger submit on the current selected DOM element
Trigger selectTrigger select on the current selected DOM element
Trigger changeTrigger change on the current selected DOM element
Trigger showTrigger show on the current selected DOM element
Trigger resetTrigger reset on the current selected DOM element
Trigger playTrigger play on the current selected DOM element
Trigger pauseTrigger play on the current selected DOM element
Trigger mouse overTrigger mouseover on the current selected DOM element
Trigger mouse upTrigger mouseup on the current selected DOM element
Trigger mouse downTrigger mousedown on the current selected DOM element
Trigger mouse leaveTrigger mouseover on the current selected DOM element
Trigger mouse moveTrigger mousemove on the current selected DOM element
Trigger mouse enterTrigger mouseenter on the current selected DOM element
Trigger mouse outTrigger mouseout on the current selected DOM element
Trigger dragTrigger drag on the current selected DOM element
Trigger drag startTrigger dragstart on the current selected DOM element
Trigger drag endTrigger dragend on the current selected DOM element
Trigger drag enterTrigger dragenter on the current selected DOM element
Trigger drag leaveTrigger dragleave on the current selected DOM element
Trigger drag overTrigger dragmove on the current selected DOM element
Trigger dropTrigger drop on the current selected DOM element
Trigger touch startTrigger touchstart on the current selected DOM element
Trigger touch endTrigger touchend on the current selected DOM element
Trigger touch enterTrigger touchenter on the current selected DOM element
Trigger touch leaveTrigger touchleave on the current selected DOM element
Trigger touch moveTrigger touchmove on the current selected DOM element
Trigger touch cancelTrigger touchcancel on the current selected DOM element
Trigger scroll yTrigger Y scroll on the current selected DOM element
Trigger scroll xTrigger X scroll on the current selected DOM element

####Window

Commands to manipulate, trigger window events and actions

CommandResult
Window scroll yTrigger window Y scroll
Window scroll xTrigger window X scroll
Window sizeAlert window dimensions

####Location Commands to manipulate, navigate urls and history

CommandResult
Location refreshLocation refresh
Location backGo to previous location url
Location forwardGo to next location url
Location hashbangAdd hashbang at the end of the location url

####Navigator

Commands to manipulate, trigger window.navigator

CommandResult
Navigator go onlineSet online status
Navigator go offlineSet offline status
Navigator vibrateVibrate device
Navigator whichShow and alert navigator informations

####Browser

Commands to manipulate and interact with the browser

CommandResult
Browser clean cookiesClean browser cookies
Browser clean session storageClean browser session storage
Browser clean local storageClean browser local storage

###i18n Butler can be used in various languages available here (Soon there will be more languages)

If you want Butler to understand italian language for example, just include the i18n italian file after butler main file:

<script src="butler.min.js"></script>
<script src="butler.it_IT.js"></script>

This way all the default commands gets translated to italian, you can check translations for each i18n file from their README file

###Tools Butler exposes some good stuff you can interact with.

You can check them all by:

window.console.info(Butler);

####Butler.Highlighter Highlighter is the Butler selector (taken from Highlighter.js), is the DOM surfer who take trace of the selected and current elements.

window.console.info('Which element are you on Butler?', Butler.Highlighter.element);

####Butler.Clipboard Clipboard is where Butler saves the last copied text and/or cloned element.

window.console.info('What you copied or cloned Butler?', Butler.Clipboard);

####Butler.Voice Voice is the Butler voice, simple.

Butler.Voice.volume = 0.5;
Butler.Voice.play();

####Butler.Commands Commands is the Object containing all the default Butler voice commands.

window.console.info('Which commands do you know Butler?', Butler.Commands);

If you need some of them to be run just do:

var ButlerCommand = Butler.Commands['selector on'];
ButlerCommand();

###Events Available events

document.addEventListner('Butler:start', function (data) {
	console.info('Butler is started and microfone is allowed', data);
});

document.addEventListner('Butler:end', function (data) {
	console.info('Butler has stopped working', data);
});

document.addEventListner('Butler:detection', function (data) {
	console.info('Butler has new detections', data);
});

document.addEventListner('Butler:detection-match', function (data) {
	console.log('Butler detection is matching', data);
});

document.addEventListner('Butler:detection-not-match', function (data) {
	console.log('Butler detection is not matching', data);
});

document.addEventListner('Butler:error', function (error) {
	console.error('Butler returned an error', error);
});

###Plugins Writing a plugin is very simple, all you have to do is to define new commands using the plug() method.

If you want to access Butler tools have a look here

####Plugin commands Please refer to annyang documentation to define new commands

Example

butler.plugin.js

document.addEventListener("DOMContentLoaded", function () {
   Butler.plug({
    'do something when i say this sentence': function callback(){
       window.alert('You said that sentence');
    }
  });
});

index.html

<head>
<script src="butler.min.js"></script>
<script src="butler.plugin.js"></script>
<script>
document.addEventListener("DOMContentLoaded", function () {
  Butler.start();
});
</script>
</head>

Now all the butler.plugin.js defined commands and callbacks are plugged and can be used.

###Debug Enable debug mode

document.addEventListener("DOMContentLoaded", function () {
  Butler.start({
   'debug':true
  });
});

###Browser Support

Google Chrome (latest versions)

http://caniuse.com/#feat=web-speech

###Contributing

We would be pleased if you help to develop and grow the project more and more.

The goal is to make the life of programmers and designers more simple and fun, so any suggestion, PR, and specially plugin is welcome and appreciated a lot.

Thank you.

###License The MIT License (MIT)

Copyright (c) 2015 Filippo Oretti, Dario Andrei

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

####Gtk

  • Not ready for a production project
  • Default commands may be changed or modified at any time, others will come soon
  • The Speech Detection is still very slow sometimes, using https:// will be slighty faster
  • If you have multiple tabs working on speech recognition and microphone there will be problems, please use Butler on a single browser tab and close the other tabs that are asking for your microphone

####Thank you