Page MenuHomePhabricator
Paste P2061

Diff of Wikispeech lexicon project changes to check for value in $currentUtterrance
ActivePublic

Authored by eugeneegbe on Jun 21 2017, 11:06 PM.
diff --git a/.gitignore b/.gitignore
old mode 100644
new mode 100755
diff --git a/.gitreview b/.gitreview
old mode 100644
new mode 100755
diff --git a/.jscsrc b/.jscsrc
old mode 100644
new mode 100755
diff --git a/.jshintignore b/.jshintignore
old mode 100644
new mode 100755
diff --git a/.jshintrc b/.jshintrc
old mode 100644
new mode 100755
diff --git a/.stylelintrc b/.stylelintrc
old mode 100644
new mode 100755
diff --git a/COPYING.txt b/COPYING.txt
old mode 100644
new mode 100755
diff --git a/CREDITS.txt b/CREDITS.txt
old mode 100644
new mode 100755
diff --git a/Doxyfile b/Doxyfile
old mode 100644
new mode 100755
diff --git a/Gruntfile.js b/Gruntfile.js
old mode 100644
new mode 100755
diff --git a/Hooks.php b/Hooks.php
old mode 100644
new mode 100755
diff --git a/Wikispeech.alias.php b/Wikispeech.alias.php
old mode 100644
new mode 100755
diff --git a/composer.json b/composer.json
old mode 100644
new mode 100755
diff --git a/extension.json b/extension.json
old mode 100644
new mode 100755
diff --git a/i18n/en.json b/i18n/en.json
old mode 100644
new mode 100755
diff --git a/i18n/qqq.json b/i18n/qqq.json
old mode 100644
new mode 100755
diff --git a/includes/CleanedContent.php b/includes/CleanedContent.php
old mode 100644
new mode 100755
diff --git a/includes/Cleaner.php b/includes/Cleaner.php
old mode 100644
new mode 100755
diff --git a/includes/HtmlGenerator.php b/includes/HtmlGenerator.php
old mode 100644
new mode 100755
diff --git a/includes/Segmenter.php b/includes/Segmenter.php
old mode 100644
new mode 100755
diff --git a/jsduck.json b/jsduck.json
old mode 100644
new mode 100755
diff --git a/lib/font-awesome-4.7.0/HELP-US-OUT.txt b/lib/font-awesome-4.7.0/HELP-US-OUT.txt
old mode 100644
new mode 100755
diff --git a/lib/font-awesome-4.7.0/css/font-awesome.css b/lib/font-awesome-4.7.0/css/font-awesome.css
old mode 100644
new mode 100755
diff --git a/lib/font-awesome-4.7.0/css/font-awesome.min.css b/lib/font-awesome-4.7.0/css/font-awesome.min.css
old mode 100644
new mode 100755
diff --git a/lib/font-awesome-4.7.0/fonts/FontAwesome.otf b/lib/font-awesome-4.7.0/fonts/FontAwesome.otf
old mode 100644
new mode 100755
diff --git a/lib/font-awesome-4.7.0/fonts/fontawesome-webfont.eot b/lib/font-awesome-4.7.0/fonts/fontawesome-webfont.eot
old mode 100644
new mode 100755
diff --git a/lib/font-awesome-4.7.0/fonts/fontawesome-webfont.svg b/lib/font-awesome-4.7.0/fonts/fontawesome-webfont.svg
old mode 100644
new mode 100755
diff --git a/lib/font-awesome-4.7.0/fonts/fontawesome-webfont.ttf b/lib/font-awesome-4.7.0/fonts/fontawesome-webfont.ttf
old mode 100644
new mode 100755
diff --git a/lib/font-awesome-4.7.0/fonts/fontawesome-webfont.woff b/lib/font-awesome-4.7.0/fonts/fontawesome-webfont.woff
old mode 100644
new mode 100755
diff --git a/lib/font-awesome-4.7.0/fonts/fontawesome-webfont.woff2 b/lib/font-awesome-4.7.0/fonts/fontawesome-webfont.woff2
old mode 100644
new mode 100755
diff --git a/lib/font-awesome-4.7.0/less/animated.less b/lib/font-awesome-4.7.0/less/animated.less
old mode 100644
new mode 100755
diff --git a/lib/font-awesome-4.7.0/less/bordered-pulled.less b/lib/font-awesome-4.7.0/less/bordered-pulled.less
old mode 100644
new mode 100755
diff --git a/lib/font-awesome-4.7.0/less/core.less b/lib/font-awesome-4.7.0/less/core.less
old mode 100644
new mode 100755
diff --git a/lib/font-awesome-4.7.0/less/fixed-width.less b/lib/font-awesome-4.7.0/less/fixed-width.less
old mode 100644
new mode 100755
diff --git a/lib/font-awesome-4.7.0/less/font-awesome.less b/lib/font-awesome-4.7.0/less/font-awesome.less
old mode 100644
new mode 100755
diff --git a/lib/font-awesome-4.7.0/less/icons.less b/lib/font-awesome-4.7.0/less/icons.less
old mode 100644
new mode 100755
diff --git a/lib/font-awesome-4.7.0/less/larger.less b/lib/font-awesome-4.7.0/less/larger.less
old mode 100644
new mode 100755
diff --git a/lib/font-awesome-4.7.0/less/list.less b/lib/font-awesome-4.7.0/less/list.less
old mode 100644
new mode 100755
diff --git a/lib/font-awesome-4.7.0/less/mixins.less b/lib/font-awesome-4.7.0/less/mixins.less
old mode 100644
new mode 100755
diff --git a/lib/font-awesome-4.7.0/less/path.less b/lib/font-awesome-4.7.0/less/path.less
old mode 100644
new mode 100755
diff --git a/lib/font-awesome-4.7.0/less/rotated-flipped.less b/lib/font-awesome-4.7.0/less/rotated-flipped.less
old mode 100644
new mode 100755
diff --git a/lib/font-awesome-4.7.0/less/screen-reader.less b/lib/font-awesome-4.7.0/less/screen-reader.less
old mode 100644
new mode 100755
diff --git a/lib/font-awesome-4.7.0/less/stacked.less b/lib/font-awesome-4.7.0/less/stacked.less
old mode 100644
new mode 100755
diff --git a/lib/font-awesome-4.7.0/less/variables.less b/lib/font-awesome-4.7.0/less/variables.less
old mode 100644
new mode 100755
diff --git a/lib/font-awesome-4.7.0/scss/_animated.scss b/lib/font-awesome-4.7.0/scss/_animated.scss
old mode 100644
new mode 100755
diff --git a/lib/font-awesome-4.7.0/scss/_bordered-pulled.scss b/lib/font-awesome-4.7.0/scss/_bordered-pulled.scss
old mode 100644
new mode 100755
diff --git a/lib/font-awesome-4.7.0/scss/_core.scss b/lib/font-awesome-4.7.0/scss/_core.scss
old mode 100644
new mode 100755
diff --git a/lib/font-awesome-4.7.0/scss/_fixed-width.scss b/lib/font-awesome-4.7.0/scss/_fixed-width.scss
old mode 100644
new mode 100755
diff --git a/lib/font-awesome-4.7.0/scss/_icons.scss b/lib/font-awesome-4.7.0/scss/_icons.scss
old mode 100644
new mode 100755
diff --git a/lib/font-awesome-4.7.0/scss/_larger.scss b/lib/font-awesome-4.7.0/scss/_larger.scss
old mode 100644
new mode 100755
diff --git a/lib/font-awesome-4.7.0/scss/_list.scss b/lib/font-awesome-4.7.0/scss/_list.scss
old mode 100644
new mode 100755
diff --git a/lib/font-awesome-4.7.0/scss/_mixins.scss b/lib/font-awesome-4.7.0/scss/_mixins.scss
old mode 100644
new mode 100755
diff --git a/lib/font-awesome-4.7.0/scss/_path.scss b/lib/font-awesome-4.7.0/scss/_path.scss
old mode 100644
new mode 100755
diff --git a/lib/font-awesome-4.7.0/scss/_rotated-flipped.scss b/lib/font-awesome-4.7.0/scss/_rotated-flipped.scss
old mode 100644
new mode 100755
diff --git a/lib/font-awesome-4.7.0/scss/_screen-reader.scss b/lib/font-awesome-4.7.0/scss/_screen-reader.scss
old mode 100644
new mode 100755
diff --git a/lib/font-awesome-4.7.0/scss/_stacked.scss b/lib/font-awesome-4.7.0/scss/_stacked.scss
old mode 100644
new mode 100755
diff --git a/lib/font-awesome-4.7.0/scss/_variables.scss b/lib/font-awesome-4.7.0/scss/_variables.scss
old mode 100644
new mode 100755
diff --git a/lib/font-awesome-4.7.0/scss/font-awesome.scss b/lib/font-awesome-4.7.0/scss/font-awesome.scss
old mode 100644
new mode 100755
diff --git a/modules/ext.wikispeech.css b/modules/ext.wikispeech.css
old mode 100644
new mode 100755
index 3c145b3..a528108
--- a/modules/ext.wikispeech.css
+++ b/modules/ext.wikispeech.css
@@ -19,7 +19,7 @@
.ext-wikispeech-stop:after {
font-family: 'Fontawesome';
- content: '\f04d';
+ content: none;
}
.ext-wikispeech-skip-ahead-word:after {
diff --git a/modules/ext.wikispeech.js b/modules/ext.wikispeech.js
old mode 100644
new mode 100755
index 1d0059d..0566571
--- a/modules/ext.wikispeech.js
+++ b/modules/ext.wikispeech.js
@@ -130,32 +130,6 @@
};
/**
- * Add a <i></i> item to the stack
- * @param id The id of the item
- * @param cssClass The name of the CSS class to add the Item
- */
-
- this.addI = function ( id, cssClass ) {
- var $i = $( '<i></i>' )
- .attr( 'id', id )
- .addClass( cssClass );
- $( '#stack' ).append( $i );
- };
-
- /**
- * Add a span to the to the play button
- * @param id The id of the item
- * @param cssClass The name of the CSS class to add the Item
- */
-
- this.addSpan = function ( id, cssClass ) {
- var $span = $( '<span></span>' )
- .attr( 'id', id )
- .addClass( cssClass );
- $( '#ext-wikispeech-play-stop-button' ).append( $span );
- };
-
- /**
* Add a button that takes the user to another page.
*
* The button gets the link destination from a supplied
@@ -213,20 +187,37 @@
*/
this.play = function () {
- var $playStopButton = $( '#ext-wikispeech-play-stop-button' );
- self.playUtterance( $( '#utterance-0' ) );
- $playStopButton.removeClass( 'ext-wikispeech-play' );
-
- // We discard all the children of the play stop button to add the span freely
- $playStopButton.empty();
+ var $playStopButton, $audio, $readyState;
+
+ $playStopButton = $( '#ext-wikispeech-play-stop-button' );
+ $audio = $currentUtterance.children( 'audio' );
+ $readyState = $audio.prop( 'readyState' );
+
+ console.log($readyState);
+
+ if ( $readyState === 0 ) {
+ // In this case the audio is not ready and cannot be played
+ self.addStackToPlayStopButton();
+ $( '.waiting' ).css( 'visibility', 'show' );
+ $playStopButton.addClass( 'ext-wikispeech-stop' );
+
+ } else if ( $readyState === 1 ) {
+ // we remove the handlers from the audio property if the audio is played
+ // first time
+ $audio.off( 'canplay' );
+ $audio.off( 'canplaythrough' );
+
+ } else if ( $readyState >= 2 ) {
+ // We add the canplay and canplaythrough listeners to the audio property
+ $( '.waiting' ).css( 'visibility', 'hidden' );
+ self.addCanplayAndCaplaythroughListeners( $audio );
+ self.playUtterance( $( '#utterance-0' ) );
- // We add the span and list containing the loader to the button
- this.addSpan( 'stack', 'fa fa-stack' );
- this.addI( 'ext-wikispeech-load-item-one', 'fa fa-stack-1x fa-stop' );
- this.addI( 'ext-wikispeech-load-item-two', 'waiting fa fa-stack-2x' );
- $( '#ext-wikispeech-load-item-two' ).addClass( 'fa-spinner fa-spin' );
- $( '#ext-wikispeech-load-item-two' ).css( 'color', 'red' );
- $( '#stack' ).css( 'font-size', '47%' );
+ } else {
+ self.addStackToPlayStopButton();
+ $( '.waiting' ).css( 'visibility', 'hidden' );
+ $playStopButton.addClass( 'ext-wikispeech-stop' );
+ }
$playStopButton.addClass( 'ext-wikispeech-button-with-rotator' );
};
@@ -434,6 +425,72 @@
};
/**
+ * m a element to the button stack.
+ * @param id The id of the item.
+ * @param cssClass The name of the CSS class to add the item.
+ */
+
+ this.addElementToPlayStopButtonStack = function ( id, cssClass ) {
+ var $i = $( '<i></i>' )
+ .attr( 'id', id )
+ .addClass( cssClass );
+ $( '#stack' ).append( $i );
+ };
+
+ /**
+ * Add a span to the to the play button.
+ * @param id The id of the item.
+ * @param cssClass The name of the CSS class to add the item.
+ */
+
+ this.addSpanToPlayStopButton = function ( id, cssClass ) {
+ var $span, $button;
+ $button = $( '#ext-wikispeech-play-stop-button' );
+ $span = $( '<span></span>' )
+ .attr( 'id', id )
+ .addClass( cssClass );
+ $button.append( $span );
+ $button.on( 'click', function () {
+ $( '.waiting' ).css( 'visibility', 'show' );
+ $button.addClass( 'ext-wikispeech-play' );
+ } );
+ };
+
+ /**
+ * Add a stack to the main play-stop button.
+ */
+
+ this.addStackToPlayStopButton = function () {
+
+ // We add the span and list containing the loader to the button
+ $( '#stack' ).remove();
+ this.addSpanToPlayStopButton( 'stack', 'fa fa-stack' );
+ this.addElementToPlayStopButtonStack( 'ext-wikispeech-load-item-one', 'fa fa-stack-2x fa-play' );
+ this.addElementToPlayStopButtonStack( 'ext-wikispeech-load-item-two', 'waiting fa fa-stack-2x fa-spinner fa-spin' );
+ $( '#ext-wikispeech-load-item-two' ).css( 'color', 'red' );
+ $( '.waiting' ).css( 'visibility', 'show' );
+
+ $( '#stack' ).css( 'font-size', '47%' );
+ };
+
+ /**
+ * Add canplay and canplaythrough listeners for the audio
+ */
+
+ this.addCanplayAndCaplaythroughListeners = function ( audioElement ) {
+ var $element = audioElement;
+ $element.on( 'canplay', function () {
+
+ $( '.waiting' ).css( 'visibility', 'hidden' );
+ } );
+
+ $element.on( 'canplaythrough', function () {
+
+ $( '.waiting' ).css( 'visibility', 'hidden' );
+ } );
+ };
+
+ /**
* Stop playing the utterance currently playing.
*/
diff --git a/package.json b/package.json
old mode 100644
new mode 100755
diff --git a/phpcs.xml b/phpcs.xml
old mode 100644
new mode 100755
diff --git a/specials/SpecialWikispeech.php b/specials/SpecialWikispeech.php
old mode 100644
new mode 100755
diff --git a/tests/phpunit/CleanerTest.php b/tests/phpunit/CleanerTest.php
old mode 100644
new mode 100755
diff --git a/tests/phpunit/HtmlGeneratorTest.php b/tests/phpunit/HtmlGeneratorTest.php
old mode 100644
new mode 100755
diff --git a/tests/phpunit/SegmenterTest.php b/tests/phpunit/SegmenterTest.php
old mode 100644
new mode 100755
diff --git a/tests/phpunit/Util.php b/tests/phpunit/Util.php
old mode 100644
new mode 100755
diff --git a/tests/qunit/ext.wikispeech.test.js b/tests/qunit/ext.wikispeech.test.js
old mode 100644
new mode 100755