From 1ee294e2b6cb9953adb9dcccf4d3fcc7eca24c2c Mon Sep 17 00:00:00 2001 From: Tal Ater Date: Mon, 7 May 2018 14:14:01 +0300 Subject: [PATCH] Bumped to version 2.6.1 --- README.md | 6 +++--- demo/index.html | 2 +- dist/annyang.js | 2 +- dist/annyang.js.map | 2 +- dist/annyang.min.js | 4 ++-- package-lock.json | 2 +- package.json | 2 +- sites/facebook.min.js | 4 ++-- sites/geektime.min.js | 4 ++-- src/annyang.js | 2 +- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 45fa3be..27e51a7 100644 --- a/README.md +++ b/README.md @@ -16,10 +16,10 @@ annyang has no dependencies, weighs just 2 KB, and is free to use and modify und ## Hello World -It's as easy as adding [one javascript file](//cdnjs.cloudflare.com/ajax/libs/annyang/2.6.0/annyang.min.js) to your document, and defining the commands you want. +It's as easy as adding [one javascript file](//cdnjs.cloudflare.com/ajax/libs/annyang/2.6.1/annyang.min.js) to your document, and defining the commands you want. ````html - + + \n * ````\n *\n * ### Using Regular Expressions in commands\n * For advanced commands, you can pass a regular expression object, instead of\n * a simple string command.\n *\n * This is done by passing an object containing two properties: `regexp`, and\n * `callback` instead of the function.\n *\n * #### Examples:\n * ````javascript\n * var calculateFunction = function(month) { console.log(month); }\n * var commands = {\n * // This example will accept any word as the \"month\"\n * 'calculate :month stats': calculateFunction,\n * // This example will only accept months which are at the start of a quarter\n * 'calculate :quarter stats': {'regexp': /^calculate (January|April|July|October) stats$/, 'callback': calculateFunction}\n * }\n ````\n *\n */\n"]} \ No newline at end of file +{"version":3,"sources":["../src/annyang.js"],"names":["root","factory","define","amd","annyang","module","exports","window","undefined","SpeechRecognition","webkitSpeechRecognition","mozSpeechRecognition","msSpeechRecognition","oSpeechRecognition","commandsList","recognition","callbacks","start","error","end","soundstart","result","resultMatch","resultNoMatch","errorNetwork","errorPermissionBlocked","errorPermissionDenied","autoRestart","lastStartedAt","autoRestartCount","debugState","debugStyle","pauseListening","isListening","optionalParam","optionalRegex","namedParam","splatParam","escapeRegExp","commandToRegExp","command","replace","match","optional","RegExp","invokeCallbacks","args","forEach","callback","apply","context","isInitialized","logMessage","text","extraParameters","indexOf","console","log","initIfNeeded","init","registerCommand","originalPhrase","push","parseResults","results","commandText","i","length","trim","j","l","currentCommand","exec","parameters","slice","commands","resetCommands","abort","maxAlternatives","continuous","location","protocol","lang","onstart","onsoundstart","onerror","event","Date","getTime","onend","timeSinceLastStart","setTimeout","paused","onresult","SpeechRecognitionResult","resultIndex","k","transcript","addCommands","options","e","message","pause","resume","debug","newState","setLanguage","language","cb","phrase","hasOwnProperty","regexp","source","removeCommands","commandsToRemove","Array","isArray","filter","addCallback","type","removeCallback","compareWithCallbackParameter","callbackType","getSpeechRecognizer","trigger","sentences"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACC,WAAUA,IAAV,EAAgBC,OAAhB,EAAyB;AACxB;;AACA,MAAI,OAAOC,MAAP,KAAkB,UAAlB,IAAgCA,OAAOC,GAA3C,EAAgD;AAAE;AAChDD,WAAO,EAAP,EAAW,YAAY;AACrB,aAAQF,KAAKI,OAAL,GAAeH,QAAQD,IAAR,CAAvB;AACD,KAFD;AAGD,GAJD,MAIO,IAAI,QAAOK,MAAP,yCAAOA,MAAP,OAAkB,QAAlB,IAA8BA,OAAOC,OAAzC,EAAkD;AAAE;AACzDD,WAAOC,OAAP,GAAiBL,QAAQD,IAAR,CAAjB;AACD,GAFM,MAEA;AAAE;AACPA,SAAKI,OAAL,GAAeH,QAAQD,IAAR,CAAf;AACD;AACF,CAXA,EAWC,OAAOO,MAAP,KAAkB,WAAlB,GAAgCA,MAAhC,YAXD,EAWgD,UAAUP,IAAV,EAAgBQ,SAAhB,EAA2B;AAC1E;;AAEA;;;;;;;;;;AAUA,MAAIJ,OAAJ;;AAEA;AACA,MAAIK,oBAAoBT,KAAKS,iBAAL,IACAT,KAAKU,uBADL,IAEAV,KAAKW,oBAFL,IAGAX,KAAKY,mBAHL,IAIAZ,KA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D;AAGA;AACA,WAAK,IAAI0E,YAAT,IAAyB1G,SAAzB,EAAoC;AAClC,YAAIA,UAAU8F,cAAV,CAAyBY,YAAzB,CAAJ,EAA4C;AAC1C;AACA,cAAIH,SAAS/G,SAAT,IAAsB+G,SAASG,YAAnC,EAAiD;AAC/C;AACA,gBAAI1E,aAAaxC,SAAjB,EAA4B;AAC1BQ,wBAAU0G,YAAV,IAA0B,EAA1B;AACD,aAFD,MAEO;AACL;AACA1G,wBAAU0G,YAAV,IAA0B1G,UAAU0G,YAAV,EAAwBL,MAAxB,CAA+BI,4BAA/B,CAA1B;AACD;AACF;AACF;AACF;AACF,KA3ZO;;AA6ZR;;;;;;;AAOAxF,iBAAa,uBAAW;AACtB,aAAOA,gBAAe,CAACD,cAAvB;AACD,KAtaO;;AAwaR;;;;;;;AAOA2F,yBAAqB,+BAAW;AAC9B,aAAO5G,WAAP;AACD,KAjbO;;AAmbR;;;;;;;;;;;;;;;;;;;AAmBA6G,aAAS,iBAASC,SAAT,EAAoB;AAC3B,UAAG,CAACzH,QAAQ6B,WAAR,EAAJ,EAA2B;AACzB,YAAIH,UAAJ,EAAgB;AACd,cAAI,CAACG,YAAL,EAAkB;AAChBmB,uBAAW,yCAAX;AACD,WAFD,MAEO;AACLA,uBAAW,qCAAX;AACD;AACF;AACD;AACD;;AAED,UAAI,CAAC+D,MAAMC,OAAN,CAAcS,SAAd,CAAL,EAA+B;AAC7BA,oBAAY,CAACA,SAAD,CAAZ;AACD;;AAED9D,mBAAa8D,SAAb;AACD;AAvdO,GAAV;;AA0dA,SAAOzH,OAAP;AAED,CAjmBA,CAAD;;AAmmBA","file":"annyang.js","sourcesContent":["//! annyang\n//! version : 2.6.1\n//! author : Tal Ater @TalAter\n//! license : MIT\n//! https://www.TalAter.com/annyang/\n(function (root, factory) {\n 'use strict';\n if (typeof define === 'function' && define.amd) { // AMD + global\n define([], function () {\n return (root.annyang = factory(root));\n });\n } else if (typeof module === 'object' && module.exports) { // CommonJS\n module.exports = factory(root);\n } else { // Browser globals\n root.annyang = factory(root);\n }\n}(typeof window !== 'undefined' ? window : this, function (root, undefined) {\n 'use strict';\n\n /**\n * # Quick Tutorial, Intro and Demos\n *\n * The quickest way to get started is to visit the [annyang homepage](https://www.talater.com/annyang/).\n *\n * For a more in-depth look at annyang, read on.\n *\n * # API Reference\n */\n\n var annyang;\n\n // Get the SpeechRecognition object, while handling browser prefixes\n var SpeechRecognition = root.SpeechRecognition ||\n root.webkitSpeechRecognition ||\n root.mozSpeechRecognition ||\n root.msSpeechRecognition ||\n root.oSpeechRecognition;\n\n // Check browser support\n // This is done as early as possible, to make it as fast as possible for unsupported browsers\n if (!SpeechRecognition) {\n return null;\n }\n\n var commandsList = [];\n var recognition;\n var callbacks = { start: [], error: [], end: [], soundstart: [], result: [], resultMatch: [], resultNoMatch: [], errorNetwork: [], errorPermissionBlocked: [], errorPermissionDenied: [] };\n var autoRestart;\n var lastStartedAt = 0;\n var autoRestartCount = 0;\n var debugState = false;\n var debugStyle = 'font-weight: bold; color: #00f;';\n var pauseListening = false;\n var isListening = false;\n\n // The command matching code is a modified version of Backbone.Router by Jeremy Ashkenas, under the MIT license.\n var optionalParam = /\\s*\\((.*?)\\)\\s*/g;\n var optionalRegex = /(\\(\\?:[^)]+\\))\\?/g;\n var namedParam = /(\\(\\?)?:\\w+/g;\n var splatParam = /\\*\\w+/g;\n var escapeRegExp = /[\\-{}\\[\\]+?.,\\\\\\^$|#]/g;\n var commandToRegExp = function(command) {\n command = command.replace(escapeRegExp, '\\\\$&')\n .replace(optionalParam, '(?:$1)?')\n .replace(namedParam, function(match, optional) {\n return optional ? match : '([^\\\\s]+)';\n })\n .replace(splatParam, '(.*?)')\n .replace(optionalRegex, '\\\\s*$1?\\\\s*');\n return new RegExp('^' + command + '$', 'i');\n };\n\n // This method receives an array of callbacks to iterate over, and invokes each of them\n var invokeCallbacks = function(callbacks, ...args) {\n callbacks.forEach(function(callback) {\n callback.callback.apply(callback.context, args);\n });\n };\n\n var isInitialized = function() {\n return recognition !== undefined;\n };\n\n // method for logging in developer console when debug mode is on\n var logMessage = function(text, extraParameters) {\n if (text.indexOf('%c') === -1 && !extraParameters) {\n console.log(text);\n } else {\n console.log(text, extraParameters || debugStyle);\n }\n };\n\n var initIfNeeded = function() {\n if (!isInitialized()) {\n annyang.init({}, false);\n }\n };\n\n var registerCommand = function(command, callback, originalPhrase) {\n commandsList.push({ command, callback, originalPhrase });\n if (debugState) {\n logMessage('Command successfully loaded: %c'+originalPhrase, debugStyle);\n }\n };\n\n var parseResults = function(results) {\n invokeCallbacks(callbacks.result, results);\n var commandText;\n // go over each of the 5 results and alternative results received (we've set maxAlternatives to 5 above)\n for (let i = 0; i {\n for (let i = 0; i\n * var commands = {\n * // annyang will capture anything after a splat (*) and pass it to the function.\n * // e.g. saying \"Show me Batman and Robin\" will call showFlickr('Batman and Robin');\n * 'show me *tag': showFlickr,\n *\n * // A named variable is a one word variable, that can fit anywhere in your command.\n * // e.g. saying \"calculate October stats\" will call calculateStats('October');\n * 'calculate :month stats': calculateStats,\n *\n * // By defining a part of the following command as optional, annyang will respond\n * // to both: \"say hello to my little friend\" as well as \"say hello friend\"\n * 'say hello (to my little) friend': greeting\n * };\n *\n * var showFlickr = function(tag) {\n * var url = 'http://api.flickr.com/services/rest/?tags='+tag;\n * $.getJSON(url);\n * }\n *\n * var calculateStats = function(month) {\n * $('#stats').text('Statistics for '+month);\n * }\n *\n * var greeting = function() {\n * $('#greeting').text('Hello!');\n * }\n * \n * ````\n *\n * ### Using Regular Expressions in commands\n * For advanced commands, you can pass a regular expression object, instead of\n * a simple string command.\n *\n * This is done by passing an object containing two properties: `regexp`, and\n * `callback` instead of the function.\n *\n * #### Examples:\n * ````javascript\n * var calculateFunction = function(month) { console.log(month); }\n * var commands = {\n * // This example will accept any word as the \"month\"\n * 'calculate :month stats': calculateFunction,\n * // This example will only accept months which are at the start of a quarter\n * 'calculate :quarter stats': {'regexp': /^calculate (January|April|July|October) stats$/, 'callback': calculateFunction}\n * }\n ````\n *\n */\n"]} \ No newline at end of file diff --git a/dist/annyang.min.js b/dist/annyang.min.js index 6ea9cd4..9e0b8e7 100644 --- a/dist/annyang.min.js +++ b/dist/annyang.min.js @@ -1,11 +1,11 @@ "use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e}; //! annyang -//! version : 2.6.0 +//! version : 2.6.1 //! author : Tal Ater @TalAter //! license : MIT //! https://www.TalAter.com/annyang/ //! annyang -//! version : 2.6.0 +//! version : 2.6.1 //! author : Tal Ater @TalAter //! license : MIT //! https://www.TalAter.com/annyang/ diff --git a/package-lock.json b/package-lock.json index 6ab2e6d..b197340 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "annyang", - "version": "2.6.0", + "version": "2.6.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index bd6078d..2cd0a25 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "annyang", - "version": "2.6.0", + "version": "2.6.1", "description": "A javascript library for adding voice commands to your site, using speech recognition", "keywords": [ "annyang", diff --git a/sites/facebook.min.js b/sites/facebook.min.js index b4d914c..f6d895e 100644 --- a/sites/facebook.min.js +++ b/sites/facebook.min.js @@ -1,11 +1,11 @@ "use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e}; //! annyang -//! version : 2.6.0 +//! version : 2.6.1 //! author : Tal Ater @TalAter //! license : MIT //! https://www.TalAter.com/annyang/ //! annyang -//! version : 2.6.0 +//! version : 2.6.1 //! author : Tal Ater @TalAter //! license : MIT //! https://www.TalAter.com/annyang/ diff --git a/sites/geektime.min.js b/sites/geektime.min.js index 0d66fd4..af8cb8d 100644 --- a/sites/geektime.min.js +++ b/sites/geektime.min.js @@ -1,11 +1,11 @@ "use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e}; //! annyang -//! version : 2.6.0 +//! version : 2.6.1 //! author : Tal Ater @TalAter //! license : MIT //! https://www.TalAter.com/annyang/ //! annyang -//! version : 2.6.0 +//! version : 2.6.1 //! author : Tal Ater @TalAter //! license : MIT //! https://www.TalAter.com/annyang/ diff --git a/src/annyang.js b/src/annyang.js index 22e678a..3c5cd9b 100644 --- a/src/annyang.js +++ b/src/annyang.js @@ -1,5 +1,5 @@ //! annyang -//! version : 2.6.0 +//! version : 2.6.1 //! author : Tal Ater @TalAter //! license : MIT //! https://www.TalAter.com/annyang/