Changeset 2886900
- Timestamp:
- 03/25/2023 06:29:02 PM (3 years ago)
- Location:
- voice-search-for-woocommerce
- Files:
-
- 55 added
- 9 edited
-
tags/2.0.0 (added)
-
tags/2.0.0/LICENSE.txt (added)
-
tags/2.0.0/classes (added)
-
tags/2.0.0/classes/languages (added)
-
tags/2.0.0/classes/languages/languages.php (added)
-
tags/2.0.0/classes/plugin-languages (added)
-
tags/2.0.0/classes/plugin-languages/vswc_de_DE.php (added)
-
tags/2.0.0/classes/plugin-languages/vswc_en_EN.php (added)
-
tags/2.0.0/classes/plugin.php (added)
-
tags/2.0.0/classes/settings-page.php (added)
-
tags/2.0.0/classes/vswc-admin-notices.php (added)
-
tags/2.0.0/composer.json (added)
-
tags/2.0.0/css (added)
-
tags/2.0.0/css/settings (added)
-
tags/2.0.0/css/settings/vswc-settings.css (added)
-
tags/2.0.0/css/voice-search-for-woocommerce.css (added)
-
tags/2.0.0/images (added)
-
tags/2.0.0/images/speak2web_logo.png (added)
-
tags/2.0.0/images/vswc-close-icon.svg (added)
-
tags/2.0.0/images/vswc-widget-mic-black.svg (added)
-
tags/2.0.0/images/vswc-widget-mic.svg (added)
-
tags/2.0.0/images/vswc-widget-search-icon.svg (added)
-
tags/2.0.0/images/vswc_check.svg (added)
-
tags/2.0.0/images/vswc_mic.svg (added)
-
tags/2.0.0/images/vswc_uncheck.svg (added)
-
tags/2.0.0/js (added)
-
tags/2.0.0/js/recorderjs (added)
-
tags/2.0.0/js/recorderjs/vswc.audio-recorder-worker.js (added)
-
tags/2.0.0/js/recorderjs/vswc.audio-recorder.js (added)
-
tags/2.0.0/js/settings (added)
-
tags/2.0.0/js/settings/vswc-settings.js (added)
-
tags/2.0.0/js/voice-search-for-woocommerce.js (added)
-
tags/2.0.0/js/vswc.audio-input-handler.js (added)
-
tags/2.0.0/js/vswc.speech-handler.js (added)
-
tags/2.0.0/js/vswc.text-library.js (added)
-
tags/2.0.0/languages (added)
-
tags/2.0.0/languages/de_DE.mo (added)
-
tags/2.0.0/languages/de_DE.po (added)
-
tags/2.0.0/languages/voice-search-for-woocommerce.pot (added)
-
tags/2.0.0/lib (added)
-
tags/2.0.0/lib/requirements-check.php (added)
-
tags/2.0.0/lib/wp-stack-plugin.php (added)
-
tags/2.0.0/readme.txt (added)
-
tags/2.0.0/short_phrases (added)
-
tags/2.0.0/short_phrases/general (added)
-
tags/2.0.0/short_phrases/general/.gitkeep (added)
-
tags/2.0.0/short_phrases/random (added)
-
tags/2.0.0/short_phrases/random/.gitkeep (added)
-
tags/2.0.0/short_phrases/silence.mp3 (added)
-
tags/2.0.0/voice-search-for-woocommerce.php (added)
-
tags/2.0.0/widgets (added)
-
tags/2.0.0/widgets/oembed-widget.php (added)
-
trunk/classes/plugin.php (modified) (7 diffs)
-
trunk/classes/settings-page.php (modified) (13 diffs)
-
trunk/composer.json (modified) (1 diff)
-
trunk/css/voice-search-for-woocommerce.css (modified) (3 diffs)
-
trunk/js/voice-search-for-woocommerce.js (modified) (12 diffs)
-
trunk/js/vswc.speech-handler.js (modified) (2 diffs)
-
trunk/js/vswc.text-library.js (modified) (2 diffs)
-
trunk/readme.txt (modified) (4 diffs)
-
trunk/short_phrases/silence.mp3 (added)
-
trunk/voice-search-for-woocommerce.php (modified) (3 diffs)
-
trunk/widgets (added)
-
trunk/widgets/oembed-widget.php (added)
Legend:
- Unmodified
- Added
- Removed
-
voice-search-for-woocommerce/trunk/classes/plugin.php
r2783035 r2886900 52 52 * Plugin version. 53 53 */ 54 const VERSION = ' 1.0.2';54 const VERSION = '2.0.0'; 55 55 56 56 /** … … 128 128 add_action( 'admin_notices', function(){ 129 129 ?> <div class="notice notice-error is-dismissible"> 130 <p> <?php echo esc_html(self::$vswc_admin_notice_logo); ?>131 <br/> <?php echo esc_html(VSWC_LANGUAGE_LIBRARY['other']['nonHttpsNotice']); ?>130 <p> <?php echo wp_kses_post(self::$vswc_admin_notice_logo); ?> 131 <br/> <?php echo wp_kses_post(VSWC_LANGUAGE_LIBRARY['other']['nonHttpsNotice']); ?> 132 132 </p> 133 133 </div> … … 156 156 ?> 157 157 <div class="notice notice-warning is-dismissible"> 158 <p> <?php echo esc_html(self::$vswc_admin_notice_logo); ?>158 <p> <?php echo wp_kses_post(self::$vswc_admin_notice_logo); ?> 159 159 <br/> 160 <?php echo esc_html("<b>".VSWC_LANGUAGE_LIBRARY['other']['nonChromeNotice']['warning']."</b>".VSWC_LANGUAGE_LIBRARY['other']['nonChromeNotice']['thisPlugin']); ?>161 <a target="blank" href="https://speak2web.com/plugin/#plan"><?php echo esc_html(VSWC_LANGUAGE_LIBRARY['other']['nonChromeNotice']['goPro']); ?></a><?php echo esc_html(VSWC_LANGUAGE_LIBRARY['other']['nonChromeNotice']['supportMoreBrowsers']); ?>160 <?php echo wp_kses_post("<b>".VSWC_LANGUAGE_LIBRARY['other']['nonChromeNotice']['warning']."</b>".VSWC_LANGUAGE_LIBRARY['other']['nonChromeNotice']['thisPlugin']); ?> 161 <a target="blank" href="https://speak2web.com/plugin/#plan"><?php echo wp_kses_post(VSWC_LANGUAGE_LIBRARY['other']['nonChromeNotice']['goPro']); ?></a><?php echo wp_kses_post(VSWC_LANGUAGE_LIBRARY['other']['nonChromeNotice']['supportMoreBrowsers']); ?> 162 162 </p> 163 163 </div> … … 344 344 } 345 345 346 wp_localize_script( 'vswc.text-library', 'vswcSelectedLanguage', self::$vswc_selected_language);347 346 wp_localize_script( 'vswc.text-library', '_vswcSttLanguageContext', $vswc_stt_language_context); 348 347 wp_localize_script( 'vswc.text-library', '_vswcTextPhrases', VswcLanguage::$textual_phrases[self::$vswc_selected_language]); 349 348 350 wp_localize_script( 'vswc.text-library', 'vswcImagesPath', self::$vswc_url . 'images/');351 wp_localize_script( 'vswc.text-library', '_vswcPath', VSWC_PLUGIN['ABS_URL']);352 349 353 350 $count_nonce = wp_create_nonce( 'service_call_count' ); … … 362 359 $protocol = sanitize_text_field((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://"); 363 360 $domainName = sanitize_text_field($_SERVER['SERVER_NAME']); 364 wp_localize_script( 'vswc.text-library', 'vswcCurrentHostName', $protocol.$domainName); 365 366 wp_localize_script( 'vswc.text-library', 'vswcWorkerPath', $this->get_url(). 'js/recorderjs/vswc.audio-recorder-worker'.self::$vswc_file_type.'.js'); 361 362 wp_add_inline_script( 'vswc.text-library', 'vswcWorkerPath ='.json_encode($this->get_url(). 'js/recorderjs/vswc.audio-recorder-worker'.self::$vswc_file_type.'.js')); 367 363 368 364 $vswc_floating_mic = get_option(Voice_Search_For_WooCommerce_Settings_Page::BASIC_CONFIG_OPTION_NAMES['floating_mic'], null); 369 365 $vswc_floating_mic = self::vswc_sanitize_variable_for_local_script($vswc_floating_mic); 370 wp_localize_script( 'vswc.text-library', 'vswcFloatingMic', $vswc_floating_mic);371 wp_localize_script( 'vswc.text-library', 'vswcSelectedMicPosition', self::$vswc_floating_mic_position);372 366 373 367 wp_localize_script( 'vswc.text-library', 'voice_search_for_woocommerce', array( … … 384 378 } 385 379 386 wp_localize_script( 'vswc.text-library', 'vswcMicListenTimeoutDuration', $vswc_mic_listening_timeout);387 wp_localize_script( 'vswc.text-library', 'vswcXApiKey', self::$vswc_api_access_key);388 380 389 381 $vswc_current_value = get_option('vswc_current_value', "0"); … … 402 394 $vswc_mute_audio_phrases = get_option(Voice_Search_For_WooCommerce_Settings_Page::BASIC_CONFIG_OPTION_NAMES['mute_audio_phrases'], null); 403 395 $vswc_mute_audio_phrases = self::vswc_sanitize_variable_for_local_script($vswc_mute_audio_phrases); 404 wp_localize_script( 'vswc.text-library', '_vswcMuteAudioPhrases', $vswc_mute_audio_phrases); 396 397 $vswc_single_click = get_option(Voice_Search_For_WooCommerce_Settings_Page::BASIC_CONFIG_OPTION_NAMES['single_click'], null); 398 $vswc_single_click = self::vswc_sanitize_variable_for_local_script($vswc_single_click); 399 400 $vswc_elementor = get_option(Voice_Search_For_WooCommerce_Settings_Page::BASIC_CONFIG_OPTION_NAMES['elementor_mic'], null); 401 $vswc_elementor = self::vswc_sanitize_variable_for_local_script($vswc_elementor); 402 403 $vswc_array = array( 404 "vswcSelectedLanguage" => self::$vswc_selected_language, 405 "vswcImagesPath" => self::$vswc_url . 'images/', 406 "_vswcPath" => VSWC_PLUGIN['ABS_URL'], 407 "vswcCurrentHostName" => $protocol.$domainName, 408 "vswcFloatingMic" => $vswc_floating_mic, 409 "vswcSelectedMicPosition" => self::$vswc_floating_mic_position, 410 "vswcMicListenTimeoutDuration" => $vswc_mic_listening_timeout, 411 "vswcXApiKey" => self::$vswc_api_access_key, 412 "_vswcMuteAudioPhrases" => $vswc_mute_audio_phrases, 413 "_vswcSingleClick" => $vswc_single_click, 414 "_vswcElementor" => $vswc_elementor, 415 416 ); 417 wp_localize_script( 'vswc.text-library', 'vswc', $vswc_array); 405 418 406 419 //################################################################################ -
voice-search-for-woocommerce/trunk/classes/settings-page.php
r2783021 r2886900 11 11 'floating_mic' => 'vswc_floating_mic', 12 12 'floating_mic_position' => 'vswc_floating_mic_position', 13 'mute_audio_phrases' => 'vswc_mute_audio_phrases' 13 'mute_audio_phrases' => 'vswc_mute_audio_phrases', 14 'single_click' => 'vswc_single_click', 15 'elementor_mic' => 'vswc_elementor' 14 16 ); 15 17 … … 21 23 private $vswc_all_languages = array(); 22 24 private $vswc_mute_audio_phrases = null; 25 private $vswc_single_click = null; 26 private $vswc_elementor = null; 23 27 24 28 /** … … 343 347 $this->vswc_all_languages = VswcLanguage::get_all_languages(); 344 348 $this->vswc_all_languages = isset($this->vswc_all_languages) ? $this->vswc_all_languages : array('en-US' => array(VswcLanguage::NAME => 'English (United States)', VswcLanguage::LANG_CODE => 'en-US')); 345 349 346 350 // For mute audio phrases 347 351 $this->vswc_mute_audio_phrases = strip_tags(stripslashes(get_option(self::BASIC_CONFIG_OPTION_NAMES['mute_audio_phrases'], null))); 348 ?> 352 // For single click 353 $this->vswc_single_click = strip_tags(stripslashes(get_option(self::BASIC_CONFIG_OPTION_NAMES['single_click'], null))); 354 // For Elementor 355 $this->vswc_elementor = strip_tags(stripslashes(get_option(self::BASIC_CONFIG_OPTION_NAMES['elementor_mic'], null))); 356 ?> 349 357 <div class="wrap"> 350 358 <div id="vswcavigationSettingsWrapper"> … … 374 382 <table id="vswcavigationBasicConfHeaderTable"> 375 383 <tr> 376 <th><h4><u><?php echo esc_html(VSWC_LANGUAGE_LIBRARY['basicConfig']['basicConfiguration']); ?></u></h4></th>384 <th><h4><u><?php echo wp_kses_post(VSWC_LANGUAGE_LIBRARY['basicConfig']['basicConfiguration']); ?></u></h4></th> 377 385 </tr> 378 386 </table> … … 380 388 <div class="vswc-setting-basic-config-column-2"> 381 389 <div class="vswc-basic-config-sub-row"> 382 <div><?php echo esc_html(VSWC_LANGUAGE_LIBRARY['basicConfig']['selectLanguage']); ?>390 <div><?php echo wp_kses_post(VSWC_LANGUAGE_LIBRARY['basicConfig']['selectLanguage']); ?> 383 391 <select id="vswcLanguage" class="vswc-language" name="<?php echo esc_attr(self:: BASIC_CONFIG_OPTION_NAMES['selected_language']); ?>"> 384 392 <?php … … 387 395 <option 388 396 <?php selected($langCode, $this->vswc_selected_language);?> 389 value=<?php echo esc_html($langCode);?>><?php echo esc_html($lang[VswcLanguage::NAME]);?>397 value=<?php echo wp_kses_post($langCode);?>><?php echo wp_kses_post($lang[VswcLanguage::NAME]);?> 390 398 </option> 391 399 <?php … … 402 410 <input 403 411 type="text" 404 name="<?php echo esc_html(self::BASIC_CONFIG_OPTION_NAMES['license_key']); ?>"412 name="<?php echo wp_kses_post(self::BASIC_CONFIG_OPTION_NAMES['license_key']); ?>" 405 413 id="vswcavigationLicenseKey" 406 414 placeholder="<?php echo esc_attr(VSWC_LANGUAGE_LIBRARY['basicConfig']['copyYourLicenseKey']); ?>" 407 value="<?php echo esc_html($this->vswc_license_key); ?>"/>415 value="<?php echo wp_kses_post($this->vswc_license_key); ?>"/> 408 416 </div> 409 417 <?php if (strlen($this->vswc_license_key) == 32) … … 420 428 <div class="vswc-dotted-border"> 421 429 <label for="<?php echo esc_attr(self::BASIC_CONFIG_OPTION_NAMES['floating_mic_position']); ?>"> 422 <b><?php echo esc_html(VSWC_LANGUAGE_LIBRARY['basicConfig']['floatingMicOptions']); ?></b>430 <b><?php echo wp_kses_post(VSWC_LANGUAGE_LIBRARY['basicConfig']['floatingMicOptions']); ?></b> 423 431 </label><br><br> 424 432 <label for="vswcFloatingMic"> … … 426 434 id="vswcFloatingMic" 427 435 type='checkbox' 428 name="<?php echo esc_html(self::BASIC_CONFIG_OPTION_NAMES['floating_mic']); ?>"436 name="<?php echo wp_kses_post(self::BASIC_CONFIG_OPTION_NAMES['floating_mic']); ?>" 429 437 value="yes" <?php checked('yes', $this->vswc_floating_mic);?> 430 > <?php echo esc_html(VSWC_LANGUAGE_LIBRARY['basicConfig']['floatingMic']); ?>438 > <?php echo wp_kses_post(VSWC_LANGUAGE_LIBRARY['basicConfig']['floatingMic']); ?> 431 439 </label><br> 432 <div><?php echo esc_html(VSWC_LANGUAGE_LIBRARY['basicConfig']['selectFloatingMicPosition']); ?> <select id="vswcFloatingMicPosition" name="<?php echo esc_attr(self:: BASIC_CONFIG_OPTION_NAMES['floating_mic_position']); ?>">440 <div><?php echo wp_kses_post(VSWC_LANGUAGE_LIBRARY['basicConfig']['selectFloatingMicPosition']); ?> <select id="vswcFloatingMicPosition" name="<?php echo esc_attr(self:: BASIC_CONFIG_OPTION_NAMES['floating_mic_position']); ?>"> 433 441 <option value="Middle Right" <?php selected('Middle Right', $this->vswc_floating_mic_position);?>>Middle Right</option> 434 442 <option value="Middle Left" <?php selected('Middle Left', $this->vswc_floating_mic_position);?>>Middle Left</option> … … 447 455 class="vswc-autotimeout-mic" 448 456 type='number' 449 name="<?php echo esc_html(self::BASIC_CONFIG_OPTION_NAMES['mic_listening_timeout']); ?>"457 name="<?php echo wp_kses_post(self::BASIC_CONFIG_OPTION_NAMES['mic_listening_timeout']); ?>" 450 458 min="8" 451 459 max="20" … … 453 461 onKeyup="vswcResetTimeoutDefaultValue(this, event)" 454 462 onKeydown="vswcValidateTimeoutValue(this, event)" 455 value="<?php echo esc_html($this->vswc_mic_listening_timeout); ?>"456 /> <?php echo esc_html(VSWC_LANGUAGE_LIBRARY['basicConfig']['autoTimeoutDuration']); ?></span>463 value="<?php echo wp_kses_post($this->vswc_mic_listening_timeout); ?>" 464 /> <?php echo wp_kses_post(VSWC_LANGUAGE_LIBRARY['basicConfig']['autoTimeoutDuration']); ?></span> 457 465 </div> 458 466 <div class="vswc-basic-config-sub-row"> … … 461 469 id="vswcMuteAudioPhrases" 462 470 type='checkbox' 463 name="<?php echo esc_html(self::BASIC_CONFIG_OPTION_NAMES['mute_audio_phrases']); ?>"471 name="<?php echo wp_kses_post(self::BASIC_CONFIG_OPTION_NAMES['mute_audio_phrases']); ?>" 464 472 value="yes" <?php checked('yes', $this->vswc_mute_audio_phrases);?> 465 > <?php echo esc_html(VSWC_LANGUAGE_LIBRARY['basicConfig']['muteAudioPhrases']); ?>473 > <?php echo wp_kses_post(VSWC_LANGUAGE_LIBRARY['basicConfig']['muteAudioPhrases']); ?> 466 474 </label> 467 475 </div> 476 <div class="vswc-basic-config-sub-row"> 477 <label for="vswcSingleClick"> 478 <input 479 id="vswcSingleClick" 480 type='checkbox' 481 name="<?php echo wp_kses_post(self::BASIC_CONFIG_OPTION_NAMES['single_click']); ?>" 482 value="yes" <?php checked('yes', $this->vswc_single_click);?> 483 > Enable single click transcription. 484 </label> 485 </div> 486 <div class="vswc-basic-config-sub-row"> 487 <label for="vswcElementorSettings"> 488 <input 489 id="vswcElementorSettings" 490 type='checkbox' 491 name="<?php echo wp_kses_post(self::BASIC_CONFIG_OPTION_NAMES['elementor_mic']); ?>" 492 value='yes' <?php checked('yes', $this->vswc_elementor);?> 493 > Enable Elementor. 494 </label> 495 </div> 468 496 </div> 469 470 497 <div class="vswc-setting-basic-config-column-3 vswc-basic-config-sub-row"> 471 498 <?php … … 499 526 register_setting('vswc-basic-config-settings-group', self::BASIC_CONFIG_OPTION_NAMES['floating_mic_position']); 500 527 register_setting('vswc-basic-config-settings-group', self::BASIC_CONFIG_OPTION_NAMES['mute_audio_phrases']); 528 register_setting('vswc-basic-config-settings-group', self::BASIC_CONFIG_OPTION_NAMES['single_click']); 529 register_setting('vswc-basic-config-settings-group', self::BASIC_CONFIG_OPTION_NAMES['elementor_mic']); 501 530 } 502 531 } -
voice-search-for-woocommerce/trunk/composer.json
r2783035 r2886900 2 2 "name": "speak2web/voice-search-for-woocommerce", 3 3 "description": "Allows user to use voice input to perform a product search on WooCommerce WP pages.", 4 "version": " 1.0.2",4 "version": "2.0.0", 5 5 "type": "wordpress-plugin", 6 6 "license": "GPL-2.0+", -
voice-search-for-woocommerce/trunk/css/voice-search-for-woocommerce.css
r2771841 r2886900 4 4 * Copyright (c) 2019 speak2web 5 5 */ 6 7 .my-icon-wrapper i { 8 position: relative; 9 z-index: 10; 10 } 11 12 #pulse, #pulse-rate { 13 position: absolute; 14 top: -4px; 15 border-radius: 50%; 16 z-index: -1; 17 } 18 19 #pulse-rate { 20 opacity: .5; 21 animation-name: listen; 22 animation-duration: 2s; 23 animation-iteration-count: infinite; 24 -webkit-animation-name: listen; 25 -webkit-animation-duration: 2s; 26 -webkit-animation-iteration-count: infinite; 27 } 28 29 @keyframes listen { 30 0% {transform: scale(1.0);} 31 20% {transform: scale(1.2);} 32 40% {transform: scale(1.4);} 33 50% {transform: scale(1.6);} 34 60% {transform: scale(1.4);} 35 80% {transform: scale(1.2);} 36 100% {transform: scale(1.0);} 37 } 38 39 @-webkit-keyframes listen { 40 0% {-webkit-transform: scale(1.0);} 41 20% {-webkit-transform: scale(1.2);} 42 40% {-webkit-transform: scale(1.4);} 43 50% {-webkit-transform: scale(1.6);} 44 60% {-webkit-transform: scale(1.4);} 45 80% {-webkit-transform: scale(1.2);} 46 100% {-webkit-transform: scale(1.0);} 47 } 48 6 49 .voice-search-for-woocommerce-wrapper { 7 50 display: inline-block; … … 10 53 .voice-search-for-woocommerce-wrapper input { margin: 0; } 11 54 .voice-search-for-woocommerce-button { 12 position: absolute ;55 position: absolute !important; 13 56 margin-left: 5px; 14 57 top: 0; 58 right: 0; 15 59 float: right; 16 60 height: 30px !important; … … 63 107 } 64 108 .vswc-mic-band { 65 -webkit-transform: scaleX(-1);66 -ms-transform: scaleX(-1);67 transform: scaleX(-1);109 -webkit-transform: matrix(1, 0, 0, 1, 0, 0); 110 -ms-transform: matrix(1, 0, 0, 1, 0, 0); 111 transform: matrix(1, 0, 0, 1, 0, 0); 68 112 } 69 113 .vswc-hide-element{ display: none !important; } -
voice-search-for-woocommerce/trunk/js/voice-search-for-woocommerce.js
r2771841 r2886900 13 13 var vswcMicListenAutoTimeoutDuration = null; 14 14 15 if (typeof(vswc MicListenTimeoutDuration) != 'undefined' &&vswcMicListenTimeoutDuration !== null) {16 vswcMicListenAutoTimeoutDuration = parseInt(vswc MicListenTimeoutDuration);15 if (typeof(vswc.vswcMicListenTimeoutDuration) != 'undefined' && vswc.vswcMicListenTimeoutDuration !== null) { 16 vswcMicListenAutoTimeoutDuration = parseInt(vswc.vswcMicListenTimeoutDuration); 17 17 vswcMicListenAutoTimeoutDuration = isNaN(vswcMicListenAutoTimeoutDuration) ? 8 : vswcMicListenAutoTimeoutDuration; 18 18 } else { … … 192 192 // Add mic image icon 193 193 var vswcMicIcon = document.createElement('img'); 194 vswcMicIcon.setAttribute('src', vswc ImagesPath + 'vswc_mic.svg');194 vswcMicIcon.setAttribute('src', vswc.vswcImagesPath + 'vswc_mic.svg'); 195 195 vswcMicIcon.setAttribute('class', 'vswc-mic-image'); 196 196 … … 418 418 function listenEvent() { 419 419 // If API system key is unavailable then acknowledge service unavailability and stop voice navigation. 420 if (!(typeof (vswc XApiKey) != 'undefined' &&vswcXApiKey !== null)) {420 if (!(typeof (vswc.vswcXApiKey) != 'undefined' && vswc.vswcXApiKey !== null)) { 421 421 // Play 'unavailable' playback 422 422 vswcAudioPlayer.configure(vswcAlternativeResponse['unavailable']); 423 423 vswcAudioPlayer.play(); 424 425 424 return false; 426 425 } … … 521 520 522 521 // Load floating mic with search bar 523 if (vswcFloatingMic && vswcFloatingMic === 'yes') {524 522 //############################# Floating mic - Widget ################################### 525 523 let vswcDocFragment = document.createDocumentFragment(); … … 529 527 let vswcWrapperMicPositionClass = 'vswc-widget-wrapper-middle-right'; 530 528 let vswcChatWrapperMicPositionClass = 'vswc-widget-chat-wrapper-middle-right'; 531 let vswcMicPosition = vswc SelectedMicPosition ?vswcSelectedMicPosition.toLowerCase() : 'middle right';529 let vswcMicPosition = vswc.vswcSelectedMicPosition ? vswc.vswcSelectedMicPosition.toLowerCase() : 'middle right'; 532 530 533 531 switch (vswcMicPosition) { … … 575 573 // Create and append mic icon/image to mic wrapper 576 574 let vswcWidgetMicImg = document.createElement('img'); 577 vswcWidgetMicImg.setAttribute('src', vswc ImagesPath + 'vswc-widget-mic-black.svg');575 vswcWidgetMicImg.setAttribute('src', vswc.vswcImagesPath + 'vswc-widget-mic-black.svg'); 578 576 vswcWidgetMic.appendChild(vswcWidgetMicImg); 579 577 … … 631 629 // Create a widget toggle button wrapper 632 630 let vswcWidgetToggleButton = document.createElement('a'); 633 vswcWidgetToggleButton.setAttribute('id', 'vswcWidgetToggleButton'); 634 vswcWidgetToggleButton.setAttribute('class', 'vswc-widget-button'); 631 635 632 636 633 // Create toggle button icon element 637 634 let vswcWidgetIcon = document.createElement('div'); 638 vswcWidgetIcon.setAttribute('class', 'vswc-widget-icon vswc-widget-toggle-button vswc-toggle-btn-mic'); 639 640 // Append toggle button icon to toggle button wrapper 641 vswcWidgetToggleButton.appendChild(vswcWidgetIcon); 635 636 if(vswc.vswcFloatingMic && vswc.vswcFloatingMic === 'yes'){ 637 vswcWidgetToggleButton.setAttribute('id', 'vswcWidgetToggleButton'); 638 vswcWidgetToggleButton.setAttribute('class', 'vswc-widget-button'); 639 vswcWidgetIcon.setAttribute('class', 'vswc-widget-icon vswc-widget-toggle-button vswc-toggle-btn-mic'); 640 // Append toggle button icon to toggle button wrapper 641 vswcWidgetToggleButton.appendChild(vswcWidgetIcon); 642 } 642 643 643 644 // Append chat wrapper and toggle button to widget wrapper 644 vswcWidgetWrapper.appendChild(vswcWidgetChatWrapper) ;645 vswcWidgetWrapper.appendChild(vswcWidgetChatWrapper) 645 646 vswcWidgetWrapper.appendChild(vswcWidgetToggleButton); 646 647 … … 661 662 let widget_ignore_onend; 662 663 663 if ('webkitSpeechRecognition' in window && vswcClientInfo['chrome'] === true) { 664 /** 665 * Function for add pulse animation in elementor mic 666 * 667 */ 668 function vswcElementorMicPulseAnimation(vswcElementorMicElement) { 669 let size = 0, left = 0; 670 if (vswcElementorMicElement.clientHeight >= 80) { 671 size = vswcElementorMicElement.clientHeight + 15; 672 left = -(size / 6); 673 } if (vswcElementorMicElement.clientHeight >= 60) { 674 size = vswcElementorMicElement.clientHeight + 12; 675 left = -(size / 5); 676 } else if (vswcElementorMicElement.clientHeight >= 30) { 677 size = vswcElementorMicElement.clientHeight + 10; 678 left = -(size / 4); 679 } else { 680 size = vswcElementorMicElement.clientHeight + 8; 681 left = -(size / 3.5); 682 } 683 684 685 const vswcPulse = document.createElement('div'); 686 vswcPulse.setAttribute('id', 'pulse'); 687 vswcPulse.setAttribute('class', 'pulse-color'); 688 vswcPulse.style.width = size + 'px'; 689 vswcPulse.style.height = size + 'px'; 690 vswcPulse.style.left = left + 'px'; 691 692 const vswcPulseRate = document.createElement('div'); 693 vswcPulseRate.setAttribute('id', 'pulse-rate'); 694 vswcPulseRate.setAttribute('class', 'pulse-color'); 695 vswcPulseRate.style.width = size + 'px'; 696 vswcPulseRate.style.height = size + 'px'; 697 vswcPulseRate.style.left = left + 'px'; 698 699 return { vswcPulse, vswcPulseRate }; 700 } 701 702 function enableElementor(){ 703 const vswcFloatigMic = document.getElementById('flt-mic') 704 if( vswcFloatigMic != null){ 705 const vswcElementorMicColor = vswcFloatigMic.getElementsByClassName('my-icon-wrapper')[0].getElementsByTagName('i')[0]; 706 const vswcPulseItem = vswcElementorMicPulseAnimation(vswcElementorMicColor); 707 if ('webkitSpeechRecognition' in window && vswcClientInfo['chrome'] === true) { 708 let widgetRecognition = new webkitSpeechRecognition(); 709 widgetRecognition.continuous = true; 710 widgetRecognition.interimResults = true; 711 712 widgetRecognition.onstart = function () { 713 widgetRecognizing = true; 714 }; 715 716 widgetRecognition.onerror = function (event) { 717 vswcFloatigMic.classList.remove('listening'); 718 widgetRecognizing = false; 719 vswcElementorMicColor.classList.remove('my-icon-animation-wrapper'); 720 vswcElementorMicColor.removeChild(vswcPulseItem['vswcPulse']); 721 vswcElementorMicColor.removeChild(vswcPulseItem['vswcPulseRate']); 722 723 if (event.error == 'no-speech') { 724 // Play feature unavailable playback 725 vswcAudioPlayer.configure(vswcAlternativeResponse['notAudible']); 726 vswcAudioPlayer.play(); 727 728 widget_ignore_onend = true; 729 } 730 731 if (event.error == 'audio-capture') { 732 widget_ignore_onend = true; 733 } 734 735 if (event.error == 'not-allowed') { 736 widget_ignore_onend = true; 737 } 738 }; 739 740 function widgetProcessEnd() { 741 widgetRecognizing = false; 742 743 if (widget_ignore_onend) { return; } 744 745 widgetFinalTranscript = widget_final_transcript; 746 vswcFloatigMic.classList.remove('listening'); 747 vswcElementorMicColor.classList.remove('my-icon-animation-wrapper'); 748 vswcElementorMicColor.removeChild(vswcPulseItem['vswcPulse']); 749 vswcElementorMicColor.removeChild(vswcPulseItem['vswcPulseRate']); 750 751 752 if (typeof(widgetFinalTranscript) != 'undefined' && widgetFinalTranscript.length != 0) { 753 vswcWidgetSearch.value = widgetFinalTranscript; 754 755 // Play 'basic' playback 756 vswcAudioPlayer.configure(vswcAlternativeResponse['basic'], function(){ 757 vswcWidgetForm.submit(); 758 }); 759 vswcAudioPlayer.play(); 760 } else { 761 // Play 'notAudible' playback 762 vswcAudioPlayer.configure(vswcAlternativeResponse['notAudible']); 763 vswcAudioPlayer.play(); 764 765 vswcWidgetSearch.placeholder = vswcMessages['ask']; 766 } 767 } 768 769 widgetRecognition.onend = function () { 770 if (isAndroid) { widgetProcessEnd(); } 771 }; 772 773 widgetRecognition.onresult = function (event) { 774 let interim_transcript = ''; 775 if (typeof (event.results) == 'undefined') { 776 widgetRecognition.onend = null; 777 widgetRecognition.stop(); 778 779 // Play 'micConnect' playback 780 vswcAudioPlayer.configure(vswcAlternativeResponse['micConnect']); 781 vswcAudioPlayer.play(); 782 return; 783 } 784 785 let eventResultsLength = event.results.length; 786 787 for (let i = event.resultIndex; i < eventResultsLength; ++i) { 788 if (event.results[i].isFinal) { 789 widget_final_transcript = event.results[i][0].transcript; 790 791 if (isAndroid == false) { 792 widgetProcessEnd(); 793 widgetRecognition.stop(); 794 } 795 } else { 796 interim_transcript += event.results[i][0].transcript; 797 } 798 } 799 }; 800 vswcFloatigMic.addEventListener(vswcMicEventToListen, function (event) { 801 802 if (vswcAnyOtherMicListening(vswcFloatigMic.getAttribute('id'), vswcFloatigMic) === true) return; 803 804 if (widgetRecognizing) { 805 // To clear pre-existing mic reset timeout if any. (Based on duration from settings) 806 vswcClearMicResetTimeout(); 807 808 // Stop ongoing playback if nay 809 if (vswcAudioPlayer.isPlaying()) { 810 vswcAudioPlayer.stop(); 811 } 812 813 if (isAndroid == false) { 814 widgetProcessEnd(); 815 widgetRecognition.stop(); 816 } 817 } else { 818 vswcFloatigMic.classList.add('listening'); 819 vswcElementorMicColor.classList.add('my-icon-animation-wrapper'); 820 vswcElementorMicColor.appendChild(vswcPulseItem['vswcPulse']); 821 vswcElementorMicColor.appendChild(vswcPulseItem['vswcPulseRate']); 822 event.preventDefault(); 823 824 // Stop ongoing playback if nay 825 if (vswcAudioPlayer.isPlaying()) { 826 vswcAudioPlayer.stop(); 827 } 828 829 widgetFinalTranscript = ''; 830 widgetRecognizing = true; 831 widgetRecognition.lang = !!vswcSttLanguageContext['gcp']['stt'] ? vswcSttLanguageContext['gcp']['langCode'] : 'en-US'; 832 widgetRecognition.start(); 833 widget_ignore_onend = false; 834 835 // To clear pre-existing mic reset timeout if any. (Based on duration from settings) 836 vswcClearMicResetTimeout(); 837 838 // To set new mic reset timeout. (Based on duration from settings) 839 window.vswcMicTimeoutIdentifier = setTimeout(function(){ 840 let updatedClassList = vswcFloatigMic.classList; 841 842 if (updatedClassList && updatedClassList.contains('listening')) { 843 vswcFloatigMic.click(); 844 } 845 }, vswcMicListenAutoTimeoutDuration); 846 } 847 }); 848 } else { 849 //CODE FOR BROWSERS THAT DO NOT SUPPORT STT NATIVLY 850 // MUST USE THE BUILT IN MICROPHONE 851 vswcFloatigMic.addEventListener(vswcMicEventToListen, function (event) { 852 853 /** 854 * Audio element's play method must be invoked in exact influence of user gesture to avoid auto play restriction 855 * 856 */ 857 if ( 858 vswcClientInfo.ios === true 859 || (vswcClientInfo.iosSafari && !vswcClientInfo.chrome && !vswcClientInfo.firefox) 860 || (vswcClientInfo.windows && vswcClientInfo.firefox) 861 ) { 862 vswcAudioPlayer.configure(vswcSilenceSoundPath); 863 vswcAudioPlayer.play(); 864 } 865 866 if (vswcAnyOtherMicListening(vswcFloatigMic.getAttribute('id'), vswcFloatigMic) === true) return; 867 868 // Deny recording if microphone is not accessible 869 if (!vswcAudioRecorder || !vswcAudioContext) { 870 vswcInitAudio(function (a) { 871 if (!vswcAudioRecorder || !vswcAudioContext) { 872 vswcWidgetSearch.placeholder = vswcMessages['micNotAccessible']; 873 return false; 874 } else { 875 widgetListenEvent(); 876 } 877 }); 878 } else { 879 widgetListenEvent(); 880 } 881 882 function widgetListenEvent() { 883 // If API system key is unavailable then acknowledge service unavailability and stop voice navigation. 884 if (!(typeof (vswc.vswcXApiKey) != 'undefined' && vswc.vswcXApiKey !== null)) { 885 // Play 'unavailable' playback 886 vswcAudioPlayer.configure(vswcAlternativeResponse['unavailable']); 887 vswcAudioPlayer.play(); 888 889 return false; 890 } 891 892 // User ending recording by clicking back mic 893 if (widgetRecognizing) { 894 // To clear pre-existing mic reset timeout if any. (Based on duration from settings) 895 vswcClearMicResetTimeout(); 896 897 // Stop recorder 898 vswcAudioRecorder.stop(); 899 900 // Stop access to audio resource 901 vswcStopAudio(); 902 903 // Stop ongoing playback if nay 904 if (vswcAudioPlayer.isPlaying()) { 905 vswcAudioPlayer.stop(); 906 } 907 908 //replace recording with mic icon 909 vswcFloatigMic.classList.remove('listening'); 910 vswcElementorMicColor.classList.remove('my-icon-animation-wrapper'); 911 vswcElementorMicColor.removeChild(vswcPulseItem['vswcPulse']); 912 vswcElementorMicColor.removeChild(vswcPulseItem['vswcPulseRate']); 913 914 vswcWidgetSearch.placeholder = vswcMessages['transcribeText']; 915 916 vswcAudioRecorder.getBuffers(function (buffers) { 917 if (!!vswcSttLanguageContext['gcp']['stt']) { 918 vswcAudioRecorder.exportMonoWAV(function(blob){ 919 vswcAudioRecorder.convertBlobToBase64(blob).then(function(resultedBase64){ 920 vswcGcpStt(resultedBase64).then(function(transcriptResult){ 921 vswcWidgetSearch.value = transcriptResult; 922 923 // Play 'basic' playback 924 vswcAudioPlayer.configure(vswcAlternativeResponse['basic'], function(){ 925 vswcWidgetForm.submit(); 926 }); 927 vswcAudioPlayer.play(); 928 }).catch(function(error) { 929 // Play 'notAudible' playback 930 vswcAudioPlayer.configure(vswcAlternativeResponse['notAudible']); 931 vswcAudioPlayer.play(); 932 933 vswcWidgetSearch.placeholder = vswcMessages['ask']; 934 }) 935 }).catch(function(error){ 936 // Play 'notAudible' playback 937 vswcAudioPlayer.configure(vswcAlternativeResponse['notAudible']); 938 vswcAudioPlayer.play(); 939 940 vswcWidgetSearch.placeholder = vswcMessages['ask']; 941 }); 942 }); 943 } else { 944 // Play 'notAudible' playback 945 vswcAudioPlayer.configure(vswcAlternativeResponse['notAudible']); 946 vswcAudioPlayer.play(); 947 vswcWidgetSearch.placeholder = vswcMessages['ask']; 948 } 949 }); 950 951 widgetRecognizing = false; 952 return; 953 } else {// User started recording by clicking mic 954 vswcFloatigMic.classList.add('listening'); 955 vswcElementorMicColor.classList.add('my-icon-animation-wrapper'); 956 vswcElementorMicColor.appendChild(vswcPulseItem['vswcPulse']); 957 vswcElementorMicColor.appendChild(vswcPulseItem['vswcPulseRate']); 958 event.preventDefault(); 959 960 // Stop ongoing playback if nay 961 if (vswcAudioPlayer.isPlaying()) { 962 vswcAudioPlayer.stop(); 963 } 964 965 widgetFinalTranscript = ''; 966 967 widgetRecognizing = true; 968 vswcAudioRecorder.clear(); 969 vswcAudioRecorder.record(vswcFloatigMic); 970 971 // To clear pre-existing mic reset timeout if any. (Based on duration from settings) 972 vswcClearMicResetTimeout(); 973 974 // To set new mic reset timeout. (Based on duration from settings) 975 window.vswcMicTimeoutIdentifier = setTimeout(function(){ 976 let updatedClassList = vswcFloatigMic.classList; 977 978 if (updatedClassList && updatedClassList.contains('listening')) { 979 vswcFloatigMic.click(); 980 } 981 }, vswcMicListenAutoTimeoutDuration); 982 } 983 } 984 }, false); 985 } 986 }} 987 988 function enableSingleClick(){ 989 vswcWidgetWrapper.classList.remove('vswcWidgetChatWrapper'); 990 if ('webkitSpeechRecognition' in window && vswcClientInfo['chrome'] === true) { 991 let widgetRecognition = new webkitSpeechRecognition(); 992 widgetRecognition.continuous = true; 993 widgetRecognition.interimResults = true; 994 995 widgetRecognition.onstart = function () { 996 widgetRecognizing = true; 997 }; 998 999 widgetRecognition.onerror = function (event) { 1000 vswcWidgetToggleButton.classList.remove('listening'); 1001 widgetRecognizing = false; 1002 1003 if (event.error == 'no-speech') { 1004 // Play feature unavailable playback 1005 vswcAudioPlayer.configure(vswcAlternativeResponse['notAudible']); 1006 vswcAudioPlayer.play(); 1007 1008 widget_ignore_onend = true; 1009 vswcWidgetSearch.placeholder = vswcMessages['unableToHear']; 1010 } 1011 1012 if (event.error == 'audio-capture') { 1013 widget_ignore_onend = true; 1014 vswcWidgetSearch.placeholder = vswcMessages['micNotAccessible']; 1015 } 1016 1017 if (event.error == 'not-allowed') { 1018 widget_ignore_onend = true; 1019 vswcWidgetSearch.placeholder = vswcMessages['browserDenyMicAccess']; 1020 } 1021 }; 1022 1023 function widgetProcessEnd() { 1024 widgetRecognizing = false; 1025 1026 if (widget_ignore_onend) { return; } 1027 1028 widgetFinalTranscript = widget_final_transcript; 1029 vswcWidgetToggleButton.classList.remove('listening'); 1030 1031 if (typeof(widgetFinalTranscript) != 'undefined' && widgetFinalTranscript.length != 0) { 1032 vswcWidgetSearch.value = widgetFinalTranscript; 1033 1034 // Play 'basic' playback 1035 vswcAudioPlayer.configure(vswcAlternativeResponse['basic'], function(){ 1036 vswcWidgetForm.submit(); 1037 }); 1038 vswcAudioPlayer.play(); 1039 } else { 1040 // Play 'notAudible' playback 1041 vswcAudioPlayer.configure(vswcAlternativeResponse['notAudible']); 1042 vswcAudioPlayer.play(); 1043 1044 vswcWidgetSearch.placeholder = vswcMessages['ask']; 1045 } 1046 } 1047 1048 widgetRecognition.onend = function () { 1049 if (isAndroid) { widgetProcessEnd(); } 1050 }; 1051 1052 widgetRecognition.onresult = function (event) { 1053 let interim_transcript = ''; 1054 if (typeof (event.results) == 'undefined') { 1055 widgetRecognition.onend = null; 1056 widgetRecognition.stop(); 1057 vswcWidgetSearch.placeholder = vswcMessages['unableToHear']; 1058 1059 // Play 'micConnect' playback 1060 vswcAudioPlayer.configure(vswcAlternativeResponse['micConnect']); 1061 vswcAudioPlayer.play(); 1062 return; 1063 } 1064 1065 let eventResultsLength = event.results.length; 1066 1067 for (let i = event.resultIndex; i < eventResultsLength; ++i) { 1068 if (event.results[i].isFinal) { 1069 widget_final_transcript = event.results[i][0].transcript; 1070 1071 if (isAndroid == false) { 1072 widgetProcessEnd(); 1073 widgetRecognition.stop(); 1074 } 1075 } else { 1076 interim_transcript += event.results[i][0].transcript; 1077 } 1078 } 1079 }; 1080 1081 vswcWidgetToggleButton.addEventListener(vswcMicEventToListen, function (event) { 1082 if (vswcAnyOtherMicListening(vswcWidgetToggleButton.getAttribute('id'), vswcWidgetToggleButton) === true) return; 1083 1084 if (widgetRecognizing) { 1085 // To clear pre-existing mic reset timeout if any. (Based on duration from settings) 1086 vswcClearMicResetTimeout(); 1087 1088 // Stop ongoing playback if nay 1089 if (vswcAudioPlayer.isPlaying()) { 1090 vswcAudioPlayer.stop(); 1091 } 1092 1093 if (isAndroid == false) { 1094 widgetProcessEnd(); 1095 widgetRecognition.stop(); 1096 } 1097 } else { 1098 vswcWidgetToggleButton.classList.add('listening'); 1099 event.preventDefault(); 1100 1101 // Stop ongoing playback if nay 1102 if (vswcAudioPlayer.isPlaying()) { 1103 vswcAudioPlayer.stop(); 1104 } 1105 1106 widgetFinalTranscript = ''; 1107 widgetRecognizing = true; 1108 widgetRecognition.lang = !!vswcSttLanguageContext['gcp']['stt'] ? vswcSttLanguageContext['gcp']['langCode'] : 'en-US'; 1109 widgetRecognition.start(); 1110 widget_ignore_onend = false; 1111 1112 // To clear pre-existing mic reset timeout if any. (Based on duration from settings) 1113 vswcClearMicResetTimeout(); 1114 1115 // To set new mic reset timeout. (Based on duration from settings) 1116 window.vswcMicTimeoutIdentifier = setTimeout(function(){ 1117 let updatedClassList = vswcWidgetToggleButton.classList; 1118 1119 if (updatedClassList && updatedClassList.contains('listening')) { 1120 vswcWidgetToggleButton.click(); 1121 } 1122 }, vswcMicListenAutoTimeoutDuration); 1123 } 1124 }); 1125 } else { 1126 //CODE FOR BROWSERS THAT DO NOT SUPPORT STT NATIVLY 1127 // MUST USE THE BUILT IN MICROPHONE 1128 vswcWidgetToggleButton.addEventListener(vswcMicEventToListen, function (event) { 1129 /** 1130 * Audio element's play method must be invoked in exact influence of user gesture to avoid auto play restriction 1131 * 1132 */ 1133 if ( 1134 vswcClientInfo.ios === true 1135 || (vswcClientInfo.iosSafari && !vswcClientInfo.chrome && !vswcClientInfo.firefox) 1136 || (vswcClientInfo.windows && vswcClientInfo.firefox) 1137 ) { 1138 vswcAudioPlayer.configure(vswcSilenceSoundPath); 1139 vswcAudioPlayer.play(); 1140 } 1141 1142 if (vswcAnyOtherMicListening(vswcWidgetToggleButton.getAttribute('id'), vswcWidgetToggleButton) === true) return; 1143 1144 // Deny recording if microphone is not accessible 1145 if (!vswcAudioRecorder || !vswcAudioContext) { 1146 vswcInitAudio(function (a) { 1147 if (!vswcAudioRecorder || !vswcAudioContext) { 1148 vswcWidgetSearch.placeholder = vswcMessages['micNotAccessible']; 1149 return false; 1150 } else { 1151 widgetListenEvent(); 1152 } 1153 }); 1154 } else { 1155 widgetListenEvent(); 1156 } 1157 1158 function widgetListenEvent() { 1159 // If API system key is unavailable then acknowledge service unavailability and stop voice navigation. 1160 if (!(typeof (vswc.vswcXApiKey) != 'undefined' && vswc.vswcXApiKey !== null)) { 1161 // Play 'unavailable' playback 1162 vswcAudioPlayer.configure(vswcAlternativeResponse['unavailable']); 1163 vswcAudioPlayer.play(); 1164 1165 return false; 1166 } 1167 1168 // User ending recording by clicking back mic 1169 if (widgetRecognizing) { 1170 // To clear pre-existing mic reset timeout if any. (Based on duration from settings) 1171 vswcClearMicResetTimeout(); 1172 1173 // Stop recorder 1174 vswcAudioRecorder.stop(); 1175 1176 // Stop access to audio resource 1177 vswcStopAudio(); 1178 1179 // Stop ongoing playback if nay 1180 if (vswcAudioPlayer.isPlaying()) { 1181 vswcAudioPlayer.stop(); 1182 } 1183 1184 //replace recording with mic icon 1185 vswcWidgetToggleButton.classList.remove('listening'); 1186 1187 vswcWidgetSearch.placeholder = vswcMessages['transcribeText']; 1188 1189 vswcAudioRecorder.getBuffers(function (buffers) { 1190 if (!!vswcSttLanguageContext['gcp']['stt']) { 1191 vswcAudioRecorder.exportMonoWAV(function(blob){ 1192 vswcAudioRecorder.convertBlobToBase64(blob).then(function(resultedBase64){ 1193 vswcGcpStt(resultedBase64).then(function(transcriptResult){ 1194 vswcWidgetSearch.value = transcriptResult; 1195 1196 // Play 'basic' playback 1197 vswcAudioPlayer.configure(vswcAlternativeResponse['basic'], function(){ 1198 vswcWidgetForm.submit(); 1199 }); 1200 vswcAudioPlayer.play(); 1201 }).catch(function(error) { 1202 // Play 'notAudible' playback 1203 vswcAudioPlayer.configure(vswcAlternativeResponse['notAudible']); 1204 vswcAudioPlayer.play(); 1205 1206 vswcWidgetSearch.placeholder = vswcMessages['ask']; 1207 }) 1208 }).catch(function(error){ 1209 // Play 'notAudible' playback 1210 vswcAudioPlayer.configure(vswcAlternativeResponse['notAudible']); 1211 vswcAudioPlayer.play(); 1212 1213 vswcWidgetSearch.placeholder = vswcMessages['ask']; 1214 }); 1215 }); 1216 } else { 1217 // Play 'notAudible' playback 1218 vswcAudioPlayer.configure(vswcAlternativeResponse['notAudible']); 1219 vswcAudioPlayer.play(); 1220 vswcWidgetSearch.placeholder = vswcMessages['ask']; 1221 } 1222 }); 1223 1224 widgetRecognizing = false; 1225 return; 1226 } else {// User started recording by clicking mic 1227 vswcWidgetToggleButton.classList.add('listening'); 1228 event.preventDefault(); 1229 1230 // Stop ongoing playback if nay 1231 if (vswcAudioPlayer.isPlaying()) { 1232 vswcAudioPlayer.stop(); 1233 } 1234 1235 widgetFinalTranscript = ''; 1236 1237 widgetRecognizing = true; 1238 vswcAudioRecorder.clear(); 1239 vswcAudioRecorder.record(vswcWidgetToggleButton); 1240 1241 // To clear pre-existing mic reset timeout if any. (Based on duration from settings) 1242 vswcClearMicResetTimeout(); 1243 1244 // To set new mic reset timeout. (Based on duration from settings) 1245 window.vswcMicTimeoutIdentifier = setTimeout(function(){ 1246 let updatedClassList = vswcWidgetToggleButton.classList; 1247 1248 if (updatedClassList && updatedClassList.contains('listening')) { 1249 vswcWidgetToggleButton.click(); 1250 } 1251 }, vswcMicListenAutoTimeoutDuration); 1252 } 1253 } 1254 }, false); 1255 }} 1256 1257 function disableSingleClick(){ 1258 if ('webkitSpeechRecognition' in window && vswcClientInfo['chrome'] === true) { 664 1259 let widgetRecognition = new webkitSpeechRecognition(); 665 1260 widgetRecognition.continuous = true; … … 834 1429 function widgetListenEvent() { 835 1430 // If API system key is unavailable then acknowledge service unavailability and stop voice navigation. 836 if (!(typeof (vswc XApiKey) != 'undefined' &&vswcXApiKey !== null)) {1431 if (!(typeof (vswc.vswcXApiKey) != 'undefined' && vswc.vswcXApiKey !== null)) { 837 1432 // Play 'unavailable' playback 838 1433 vswcAudioPlayer.configure(vswcAlternativeResponse['unavailable']); … … 894 1489 vswcAudioPlayer.configure(vswcAlternativeResponse['notAudible']); 895 1490 vswcAudioPlayer.play(); 896 897 1491 vswcWidgetSearch.placeholder = vswcMessages['ask']; 898 1492 } … … 930 1524 } 931 1525 }, false); 1526 }} 1527 1528 if (vswcIsElementor == true){ 1529 enableElementor() 1530 } 1531 1532 if (vswcIsSingleClick ==true){ 1533 enableSingleClick() 1534 } 1535 1536 else { 1537 disableSingleClick() 932 1538 } 933 1539 … … 966 1572 */ 967 1573 function vswcToggleWidgetElements() { 968 vswcToggleClass('.vswc-widget-toggle-button', 'vswc-toggle-btn-mic'); 969 vswcToggleClass('.vswc-widget-toggle-button', 'vswc-toggle-btn-close'); 970 vswcToggleClass('.vswc-widget-toggle-button', 'vswc-widget-active'); 971 vswcToggleClass('.vswc-widget-toggle-button', 'vswc-widget-visible'); 972 vswcToggleClass('#vswcWidgetToggleButton', 'vswc-widget-float'); 973 vswcToggleClass('.vswc-widget-chat-wrapper', 'vswc-widget-visible'); 974 vswcToggleClass('.vswc-widget-button', 'vswc-widget-visible'); 1574 if (vswcIsSingleClick == true){ 1575 vswcToggleClass('.vswc-widget-toggle-button', 'vswc-toggle-btn-mic'); 1576 vswcToggleClass('.vswc-widget-toggle-button', 'vswc-toggle-btn-close'); 1577 vswcToggleClass('.vswc-widget-toggle-button', 'vswc-widget-active'); 1578 vswcToggleClass('.vswc-widget-toggle-button', 'vswc-widget-visible'); 1579 vswcToggleClass('#vswcWidgetToggleButton', 'vswc-widget-float'); 1580 vswcToggleClass('.vswc-widget-button', 'vswc-widget-visible'); 1581 } 1582 1583 else{ 1584 vswcToggleClass('.vswc-widget-toggle-button', 'vswc-toggle-btn-mic'); 1585 vswcToggleClass('.vswc-widget-toggle-button', 'vswc-toggle-btn-close'); 1586 vswcToggleClass('.vswc-widget-toggle-button', 'vswc-widget-active'); 1587 vswcToggleClass('.vswc-widget-toggle-button', 'vswc-widget-visible'); 1588 vswcToggleClass('#vswcWidgetToggleButton', 'vswc-widget-float'); 1589 vswcToggleClass('.vswc-widget-chat-wrapper', 'vswc-widget-visible'); 1590 vswcToggleClass('.vswc-widget-button', 'vswc-widget-visible'); 1591 } 975 1592 } 976 }977 1593 })(); 978 1594 }; -
voice-search-for-woocommerce/trunk/js/vswc.speech-handler.js
r2783021 r2886900 12 12 var respTimeOut = false; 13 13 var errcnt = 0; 14 let vswcHostName = typeof(vswc CurrentHostName) != 'undefined' ?vswcCurrentHostName : null;14 let vswcHostName = typeof(vswc.vswcCurrentHostName) != 'undefined' ? vswc.vswcCurrentHostName : null; 15 15 16 16 /** … … 29 29 if (pathOfFile) { 30 30 let partialFilePath = !!vswcIsMuteSimon ? vswcSilenceSoundPath : pathOfFile; 31 this.htmlAudioElement.src = _vswcPath + partialFilePath;31 this.htmlAudioElement.src = vswc._vswcPath + partialFilePath; 32 32 this.htmlAudioElement.preload = 'auto'; 33 33 this.lastFilePath = pathOfFile; -
voice-search-for-woocommerce/trunk/js/vswc.text-library.js
r2771841 r2886900 12 12 // PLUGIN LANGUAGE 13 13 //#################################### 14 var vswcTypeOfSelectedLanguage = (typeof(vswc SelectedLanguage) != 'undefined' && vswcSelectedLanguage !== null) ?vswcSelectedLanguage.trim() : 'English';15 var vswcSelectedLang = (typeof(vswc SelectedLanguage) != 'undefined' && vswcSelectedLanguage !== null) ?vswcSelectedLanguage.trim() : 'en-US';14 var vswcTypeOfSelectedLanguage = (typeof(vswc.vswcSelectedLanguage) != 'undefined' && vswc.vswcSelectedLanguage !== null) ? vswc.vswcSelectedLanguage.trim() : 'English'; 15 var vswcSelectedLang = (typeof(vswc.vswcSelectedLanguage) != 'undefined' && vswc.vswcSelectedLanguage !== null) ? vswc.vswcSelectedLanguage.trim() : 'en-US'; 16 16 17 17 var vswcIsSttLangCtx = typeof _vswcSttLanguageContext != 'undefined' && !!_vswcSttLanguageContext && _vswcSttLanguageContext instanceof Object ? true : false; … … 157 157 var vswcWidgetMessages = _vswcTextPhrases['vswcWidgetMessages']; 158 158 159 var vswcIsMuteSimon = typeof _vswcMuteAudioPhrases != 'undefined' && !!_vswcMuteAudioPhrases && _vswcMuteAudioPhrases == 'yes' ? true : false; 159 var vswcIsMuteSimon = typeof vswc._vswcMuteAudioPhrases != 'undefined' && !! vswc._vswcMuteAudioPhrases && vswc._vswcMuteAudioPhrases == 'yes' ? true : false; 160 var vswcIsSingleClick = typeof vswc._vswcSingleClick != 'undefined' && !! vswc._vswcSingleClick && vswc._vswcSingleClick == 'yes' ? true : false; 161 var vswcIsElementor = typeof vswc._vswcElementor != 'undefined' && !! vswc._vswcElementor && vswc._vswcElementor == 'yes' ? true : false; -
voice-search-for-woocommerce/trunk/readme.txt
r2783035 r2886900 1 1 === Voice Search For WooCommerce === 2 2 Contributors: mspanwa2 3 Tags: voice search, wooCommerce, iOS voice search, Microsoft Edge voice search, multi platform voice search, voice, AI, speech, FireFox voice search, api, 3 Tags: voice search, wooCommerce, iOS voice search, Microsoft Edge voice search, multi platform voice search, voice, AI, speech, FireFox voice search, api, elementor, page builder 4 4 Requires at least: 2.6 5 Tested up to: 6. 0.15 Tested up to: 6.1.1 6 6 Requires PHP: 5.3 7 Stable tag: 1.0.27 Stable tag: 2.0.0 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html 10 10 11 12 = ELEMENTOR PAGE BUILDER SUPPORT NOW INCLUDED = 13 14 Place a microphone anywhere on your site. Control the icon, color, and other advanced design features when deploying this exciting new feature. 15 11 16 Add an universal, multi lingual voice search to wooCommerce web pages. This plugin will add voice search ability to all wooCommerce web pages. Simply click the microphone and dictate your search terms. 12 17 The plugin will automatically detect end of speech and submit your search to the wooCommerce store. 13 18 14 15 19 Add voice search to your WooCommerce store. This simple, fast, and intuitive plugin helps your shoppers find what they're looking for with the ultimate in accessibility - their voice. Our plugin supports 130 languages and follows stringest ethical and privacy guidelines to protect your shoppers privacy while delivering the highest levels of security to your store. 16 20 … … 21 25 = ETHICAL PRIVACY FOCUSED VOICE ASSISTANCE & SEARCH FOR YOUR WEBSITE = 22 26 23 This plugin adds voice search features to your website that optimize user experience. Upon installation you'll be able to choose from 130+ languages we support and instantly add a microphone to every search bar as well as a floating icon to every page .27 This plugin adds voice search features to your website that optimize user experience. Upon installation you'll be able to choose from 130+ languages we support and instantly add a microphone to every search bar as well as a floating icon to every page or place a microphone widget using Elementor to enable voice search on your WooCommerce shop. 24 28 25 29 Our service helps you to stay compliant with privacy regulations because we do not store or retain any user generated content or personally identifying information. As one of the earliest members and contributors to The Open Voice Network, a Community of The Linux Foundation, we have made it our goal to deliver services in voice tech that meet even the most demanding standards and guidelines. … … 191 195 192 196 197 Elementor: 198 ++++++++++++++++++++++++++++++++++++++++++ 199 Steps to enable Elementor on voice-seatch-for-woocommerce plugin- 200 201 1. In admin page of your website on the left navigation bar- 202 Plugins -> Add New and search and install "Elementor Website Builder" 203 204 2. Head over to Plugins -> Installed Plugins and activate both the "Elementor Website Builder" and "Voice Search For WooCommerce". 205 206 3. Head over to "Voice Search For WooCommerce" -> Settings and check mark "Enable Elementor" settings. 207 (Note - Currently Elementor works conditionally with our flaoting mic widget, if single click is enabled, elementor wont work. This can be changed as per requirements) 208 209 4. Now Elementor is active! Go to any page and select option "Edit with Elementor" option. It will open up a widget toolbox on the left side. 210 211 5. Search for "Floating Mic Widget" and place it anywhere on the webpage! User can currently customise its color and icon. 212 213 193 214 194 215 speak2web Voice Search Service: … … 218 239 = 1.0.2 = 219 240 * Address merge Issue 241 242 = 2.0.0 = 243 * Added Elementor support 244 * Upgraded to Wordpress 6.1.1 245 * Upgraded to PHP 8.0 246 * Upgraded to WooCommerce 7.4.1 -
voice-search-for-woocommerce/trunk/voice-search-for-woocommerce.php
r2783035 r2886900 3 3 * Plugin Name: Voice Search For WooCommerce 4 4 * Description: Allows any serach box on the page to be searchable via voice. 5 * Version: 1.0.25 * Version: 2.0.0 6 6 * Author: speak2web 7 7 * Author URI: https://speak2web.com/ … … 9 9 * Domain Path: /languages 10 10 * WC requires at least: 2.2 11 * WC tested up to: 4.5.211 * WC tested up to: 7.4.1 12 12 */ 13 13 … … 41 41 )); 42 42 43 class Vswc_Elementor_widget { 44 45 private static $instance = null; 46 47 48 public static function instance() { 49 if ( is_null( self::$instance ) ) { 50 self::$instance = new self(); 51 } 52 53 return self::$instance; 54 } 55 56 57 private function include_widgets_files() { 58 require_once( __DIR__ . '/widgets/oembed-widget.php' ); 59 } 60 61 public function register_widgets() { 62 // It's now safe to include Widgets files. 63 $this->include_widgets_files(); 64 65 // Register the plugin widget classes. 66 \Elementor\Plugin::instance()->widgets_manager->register( new \Vswc_Elementor_Floating_Mic_Widget() ); 67 } 68 69 public function register_categories($elements_manager){ 70 $elements_manager->add_category( 71 'speak2web', 72 [ 73 'title' => __('Speak2web', 'myWidget'), 74 'icon' => 'fa fa-plug' 75 ] 76 ); 77 } 78 79 public function __construct() { 80 // Register the widgets. 81 add_action( 'elementor/widgets/register', array( $this, 'register_widgets' ) ); 82 add_action( 'elementor/elements/categories_registered', array( $this, 'register_categories' ) ); 83 84 } 85 } 86 Vswc_Elementor_widget::instance(); 87 43 88 if ( $voice_search_for_woocommerce_requirements_check->passes() ) { 44 89 $vswc_client_info = array(
Note: See TracChangeset
for help on using the changeset viewer.