Page MenuHomePhabricator
Paste P2062

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

Authored by eugeneegbe on Jun 29 2017, 11:58 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..b006e70
--- 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
@@ -211,24 +185,23 @@
/**
* Start playing the first utterance and display loader button
*/
-
- 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();
-
- // 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%' );
- $playStopButton.addClass( 'ext-wikispeech-button-with-rotator' );
- };
+ this.play = function () {
+ var $playStopButton = $( '#ext-wikispeech-play-stop-button' );
+ self.playUtterance( $( '#utterance-0' ) );
+ $playStopButton.removeClass( 'ext-wikispeech-play' );
+ };
+
+ /**
+ * Add the stack which contains the spinner to the playstopButton.
+ */
+ this.addStackToPlayStopButton = function () {
+ $('#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' );
+ $( '#stack' ).css( 'font-size', '48%' );
+ };
/**
* Play the audio for an utterance.
@@ -240,10 +213,29 @@
*/
this.playUtterance = function ( $utterance ) {
+ var $readyState, $audio, $playStopButton;
+ $playStopButton = $( '#ext-wikispeech-play-stop-button' );
self.stopUtterance( $currentUtterance );
$currentUtterance = $utterance;
$utterance.children( 'audio' ).trigger( 'play' );
self.highlightUtterance( $utterance );
+
+ // We get the readyState of the current Utterance audio
+ $audio = $currentUtterance.children( 'audio' );
+ $readyState = $audio.prop( 'readyState' );
+
+ $playStopButton.removeClass( 'ext-wikispeech-play' );
+ $playStopButton.addClass( 'ext-wikispeech-stop' );
+
+ if ( $readyState >= 2 ) {
+ self.addStackToPlayStopButton();
+ $( '.waiting' ).css( 'visibility', 'hidden' );
+ self.addCanplayAndCaplaythroughListeners( $audio );
+ }else{
+ // We create the playStop button with stack here
+ self.addStackToPlayStopButton();
+ $( '.waiting' ).css( 'visibility', 'show' );
+ }
};
/**
@@ -434,6 +426,55 @@
};
/**
+ * 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 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
index 3e100fd..8cfb3e4
--- a/tests/qunit/ext.wikispeech.test.js
+++ b/tests/qunit/ext.wikispeech.test.js
@@ -488,11 +488,6 @@
);
assert.strictEqual(
$( '#ext-wikispeech-play-stop-button' )
- .hasClass( 'ext-wikispeech-button-with-rotator' ),
- true
- );
- assert.strictEqual(
- $( '#ext-wikispeech-play-stop-button' )
.hasClass( 'ext-wikispeech-play' ),
false
);