]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#553] removed googlenews plug-in and ripped out translate support in the subtitle... t553
authorChristopher De Cairos <chris.decairos@gmail.com>
Fri, 22 Jul 2011 18:50:20 +0000 (14:50 -0400)
committerChristopher De Cairos <chris.decairos@gmail.com>
Fri, 22 Jul 2011 18:50:20 +0000 (14:50 -0400)
plugins/googlenews/popcorn.googlenews.html [deleted file]
plugins/googlenews/popcorn.googlenews.js [deleted file]
plugins/googlenews/popcorn.googlenews.unit.html [deleted file]
plugins/googlenews/popcorn.googlenews.unit.js [deleted file]
plugins/subtitle/popcorn.subtitle.html
plugins/subtitle/popcorn.subtitle.js
plugins/subtitle/popcorn.subtitle.unit.html
plugins/subtitle/popcorn.subtitle.unit.js

diff --git a/plugins/googlenews/popcorn.googlenews.html b/plugins/googlenews/popcorn.googlenews.html
deleted file mode 100755 (executable)
index a35a344..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-  <title>Popcorn google Map Plug-in Demo</title>
-  
-  <script src="../../popcorn.js"></script>
-
-  <script src="popcorn.googlenews.js"></script>
-  <script>
-    document.addEventListener('DOMContentLoaded', function () {
-      var p = Popcorn('#video')
-      .volume(0)
-      .play() 
-      .googlenews({
-        start: 0, // seconds
-        end: 20, // seconds
-        topic: 'Oil Spill',
-        target: 'newsdiv'
-      } )
-      .googlenews({
-        start: 25, // seconds
-        end: 30, // seconds
-        topic: 'Village Telco',
-        target: 'newsdiv'
-      } );
-    }, false);
-  </script>
-</head>
-<body>
-  <h1 id="qunit-header">Popcorn google News Plug-in Demo</h1>
-  <p> Google News topic will appear at 0 seconds and disappear at 20 seconds.</p>
-  <p> Google News topic will appear at 25 seconds and disappear at 30 seconds.</p>
-  <div>
-    <video id='video' 
-      controls 
-      width= '250px'
-      poster="../../test/poster.png"> 
-
-      <source id='mp4'
-        src="../../test/trailer.mp4"
-        type='video/mp4; codecs="avc1, mp4a"'> 
-
-      <source id='ogv'
-        src="../../test/trailer.ogv"
-        type='video/ogg; codecs="theora, vorbis"'> 
-
-      <p>Your user agent does not support the HTML5 Video element.</p> 
-
-    </video> 
-  </div>
-  <div id="newsdiv"></div>
-</body>
-</html>
diff --git a/plugins/googlenews/popcorn.googlenews.js b/plugins/googlenews/popcorn.googlenews.js
deleted file mode 100755 (executable)
index fb808cf..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-// PLUGIN: Google News
-
-(function (Popcorn) {
-
-  var scriptLoaded = false,
-      scriptLoading = false,
-      callBack     = function( data ) {
-
-        if ( typeof google !== 'undefined' && google.load ) {
-
-          google.load("elements", "1", {packages : ["newsshow"], callback: function() {scriptLoaded = true;}});
-        } else {
-
-          setTimeout( function() {
-
-            callBack( data );
-          }, 1);
-        }
-      };
-
-  /**
-   * Google News popcorn plug-in 
-   * Displays Google News information on a topic in a targeted div.
-   * Options parameter will need a start, end and target.
-   * Optional parameters are topic. topic defaults to "top stories"
-   * Start is the time that you want this plug-in to execute
-   * End is the time that you want this plug-in to stop executing
-   * Target is the id of the document element that the content is
-   *  appended to, this target element must exist on the DOM
-   * Topic is the topic of news articles you want to display.
-   * 
-   * @param {Object} options
-   * 
-   * Example:
-     var p = Popcorn('#video')
-        .googlenews({
-          start:          5,                 // seconds, mandatory
-          end:            15,                // seconds, mandatory
-          topic:          'oil spill',       // optional
-          target:         'newsdiv'        // mandatory
-        } )
-   *
-   */
-  Popcorn.plugin( "googlenews" , {
-
-      manifest: {
-        about:{
-          name:    "Popcorn Google News Plugin",
-          version: "0.1",
-          author:  "Scott Downe",
-          website: "http://scottdowne.wordpress.com/"
-        },
-        options:{
-          start    : {elem:'input', type:'text', label:'In'},
-          end      : {elem:'input', type:'text', label:'Out'},
-          target   : 'news-container',
-          topic     : {elem:'select', type:'text', label:'Type'}
-        }
-      },
-      _setup : function( options ) {
-      
-        if ( !scriptLoading ) {
-
-          scriptLoading = true;
-          Popcorn.getScript( "http://www.google.com/jsapi", callBack );
-        }
-
-        options.container = document.createElement( 'div' );
-        var container = document.createElement( 'div' );
-        if ( document.getElementById( options.target ) ) {
-          document.getElementById( options.target ).appendChild( options.container );
-          options.container.appendChild( container );
-        }
-
-        var readyCheck = setInterval(function() {
-          if ( !scriptLoaded ) {
-            return;
-          }
-          clearInterval( readyCheck );
-
-          options.newsShow = new google.elements.NewsShow( container, {
-            format : "300x250",
-            queryList : [
-              { q: options.topic || "Top Stories" }
-            ]
-          } );
-
-        }, 5);
-
-        options.container.style.display = "none";
-
-      },
-      /**
-       * @member googlenews 
-       * The start function will be executed when the currentTime 
-       * of the video  reaches the start time provided by the 
-       * options variable
-       */
-      start: function( event, options ){
-        options.container.setAttribute( 'style', 'display:inline' );
-      },
-      /**
-       * @member googlenews 
-       * The end function will be executed when the currentTime 
-       * of the video  reaches the end time provided by the 
-       * options variable
-       */
-      end: function( event, options ){
-        options.container.setAttribute( 'style', 'display:none' );
-      },
-      _teardown: function( options ) {
-        // google news does not like this, throws an error "a is null"
-        // doesn't hurt popcorn, and only happens once
-        document.getElementById( options.target ) && document.getElementById( options.target ).removeChild( options.container );
-        options.newsShow = null;
-      }
-  });
-
-})( Popcorn );
diff --git a/plugins/googlenews/popcorn.googlenews.unit.html b/plugins/googlenews/popcorn.googlenews.unit.html
deleted file mode 100755 (executable)
index bf77bca..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-  <title>Popcorn Google News Plug-in Test</title>
-  <link rel="stylesheet" href="../../test/qunit/qunit.css" type="text/css" media="screen">
-  <script src="../../test/qunit/qunit.js"></script>
-  <!-- 
-    do not move - this must be called immediately prior to 
-    popcorn-api-draft.js
-  -->
-  
-  <script src="../../popcorn.js"></script>
-  
-  <script src="popcorn.googlenews.js"></script>
-  <script src="popcorn.googlenews.unit.js"></script>
-</head>
-<body>
-  <h1 id="qunit-header">Popcorn Google News Plugin</h1>
-  <h2 id="qunit-banner"></h2>
-  <div id="qunit-testrunner-toolbar"></div>
-  <h2 id="qunit-userAgent"></h2>
-  <ol id="qunit-tests"></ol>
-  <div id="qunit-fixture">  </div>
-  
-  <video id='video' 
-    controls preload='none' 
-    width= '250px'
-    poster="../../test/poster.png"> 
-
-    <source id='mp4'
-      src="../../test/trailer.mp4"
-      type='video/mp4; codecs="avc1, mp4a"'> 
-
-    <source id='ogv'
-      src="../../test/trailer.ogv"
-      type='video/ogg; codecs="theora, vorbis"'> 
-
-    <p>Your user agent does not support the HTML5 Video element.</p> 
-
-  </video>
-  <div id="googlenewsdiv"></div>
-</body>
-</html>
diff --git a/plugins/googlenews/popcorn.googlenews.unit.js b/plugins/googlenews/popcorn.googlenews.unit.js
deleted file mode 100755 (executable)
index a41c634..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-test( "Popcorn google news Plugin", function () {
-  
-  var popped = Popcorn( "#video" ),
-      expects = 8, 
-      count = 0,
-      setupId,
-      googlenewsdiv = document.getElementById( "googlenewsdiv" );
-
-  expect(expects);
-  
-  function plus() {
-    if ( ++count===expects ) {
-      start();
-    }
-  }
-  
-  stop();
-   
-  ok ( "googlenews" in popped, "googlenews is a method of the popped instance" );
-  plus();
-  
-  equals ( googlenewsdiv.innerHTML, "", "initially, there is nothing inside the googlenewsdiv" );
-  plus();
-  
-  popped.googlenews({
-    start: 0, // seconds
-    end: 2, // seconds
-    topic: "Oil Spill",
-    target: "googlenewsdiv"
-  })
-  .googlenews({
-    start: 2, // seconds
-    end: 4, // seconds
-    topic: "Village Telco",
-    target: "googlenewsdiv"
-  })
-  .volume( 0 );
-
-  setupId = popped.getLastTrackEventId();
-    
-  popped.exec( 0, function() {
-    equals( googlenewsdiv.childElementCount, 2, "googlenewsdiv now has two inner elements" );
-    plus();
-    equals( googlenewsdiv.children[0].style.display , "inline", "first googlenews is visible on the page" );
-    plus();
-  });
-  
-  popped.exec( 3, function() {
-    equals( googlenewsdiv.children[1].style.display , "inline", "second googlenews is visible on the page" );
-    plus();
-  });
-  
-  popped.exec( 4, function() {
-    equals( googlenewsdiv.children[1].style.display , "none", "second googlenews is no longer visible on the page" );
-    plus();
-    equals( googlenewsdiv.children[0].style.display , "none", "first googlenews is no longer visible on the page" );
-    plus();
-
-    popped.pause().removeTrackEvent( setupId );
-    ok( !googlenewsdiv.children[1], "removed google news was properly destroyed" );
-    plus();
-  });
-  
-  popped.play();
-
-});
index c01a405d52389af15698433cfaa87ef5371f3fcb..bba8e96585b003c46f28c665f040d22ae86d514d 100755 (executable)
         start: 5, // seconds
         end: 15, // seconds
         text: 'this is the first subtitle of 2011',
-        language: "en",
-        languagesrc: "language",
-        accessibilitysrc: "accessibility"
       } )
       .subtitle({
         start: 20, // seconds
         end: 45, // seconds
         text: 'this is the second subtitle of 2011',
-        language: "en",
-        languagesrc: "language",
-        accessibilitysrc: "accessibility"
       } )
 
     }, false);
 
     </video> 
   </div>
-  <h2>Choose your language</h2>
-    <select id="language">
-      <option value="zh" selected="selected">Chinese</option>
-      <option value="en">English</option>
-      <option value="fr">French</option>
-      <option value="de">German</option>
-      <option value="it">Italian</option>
-      <option value="ja">Japanese</option>
-      <option value="ko">Korean</option>
-      <option value="fa">Persian</option>
-      <option value="pl">Polish</option>
-      <option value="pt">Portuguese</option>
-      <option value="es">Spanish</option>
-    </select>
-    <div>
-      with help from <a href="http://google.com/translate">Google Translate</a><br />
-      <input type="checkbox" id="accessibility" checked="checked" />All subtitles (accessibility)
-    </div>
 
 </body>
 </html>
index 4d9c718b615a188a2f86a1e0a4ee5471d3bf8f58..ceff46e793b22c8def5cbe59e3cc154a9430932a 100755 (executable)
@@ -2,25 +2,7 @@
 
 (function ( Popcorn ) {
 
-  var scriptLoaded = false,
-      i = 0,
-      callBack = function( data ) {
-
-        if ( window.google && google.load ) {
-
-          google.load( "language", "1", { 
-            callback: function() {
-              scriptLoaded = true; 
-            }
-          });
-        } else {
-
-          setTimeout( function() {
-
-            callBack( data );
-          }, 1);
-        }
-      },
+  var i = 0,
       createDefaultContainer = function( context ) {
 
         var ctxContainer = context.container = document.createElement( "div" ),
@@ -50,8 +32,6 @@
         context.media.parentNode.appendChild( ctxContainer );
       };
 
-  Popcorn.getScript( "http://www.google.com/jsapi", callBack );
-
   /**
    * Subtitle popcorn plug-in 
    * Displays a subtitle over the video, or in the target div
    *  appended to, this target element must exist on the DOM
    * Text is the text of the subtitle you want to display.
    *
-   * Language is the expected language the subtitle text is in
-   * Languagesrc is the target id of the element that contains 
-   *  the language value ("en", "fr", etc.) to translate the text into
-   *  example:
-   *  <select id="language">
-   *    <option value="zh" selected="selected">Chinese</option>
-   *    <option value="en">English</option>
-   *    <option value="fr">French</option>
-   *    <option value="de">German</option>
-   *    <option value="it">Italian</option>
-   *    <option value="ja">Japanese</option>
-   *    <option value="ko">Korean</option>
-   *    <option value="fa">Persian</option>
-   *    <option value="pl">Polish</option>
-   *    <option value="pt">Portuguese</option>
-   *    <option value="es">Spanish</option>
-   *  </select>
-   * Accessibilitysrc is the target id of a checkbox element
-   *  checked means show all subtitles regardless of language and languagesrc
-   *  not checked means only translate if language and languagesrc are different
-   *  if no accessibilitysrc exists, default is to display all subtitles regardless
-   * 
    * @param {Object} options
    * 
    * Example:
           end:              15,                // seconds, mandatory
           text:             'Hellow world',    // optional
           target:           'subtitlediv',     // optional
-          language:         'en',              // optional
-          languagesrc:      'language',        // optional
-          accessibilitysrc: 'accessibility'    // optional
         } )
    *
    */
 
-  // translates whatever is in options.container into selected language
-  var translate = function( options, text ) {
-
-    options.selectedLanguage = options.languageSrc.options[ options.languageSrc.selectedIndex ].value;
-    google.language.translate( text, "", options.selectedLanguage, function( result ) {
-      
-      for( var k = 0, children = options.container.children, len = children.length; k < len; k++ ) {
-        if ( children[ k ].style.display === "inline" ) {   
-          children[ k ].innerHTML = result.translation;    
-        }  
-      }
-
-    });
-  };
-
   Popcorn.plugin( "subtitle" , {
     
       manifest: {
       },
 
       _setup: function( options ) {
-        var newdiv = document.createElement( "div" ),
-            accessibility = document.getElementById( options.accessibilitysrc );
+        var newdiv = document.createElement( "div" );
 
-        newdiv.id = "subtitle-" + i;
+        newdiv.id = "subtitle-" + i++;
         newdiv.style.display = "none";
-        i++;
 
         // Creates a div for all subtitles to use
         ( !this.container && ( !options.target || options.target === "subtitle-container" ) ) && 
         options.showSubtitle = function() {
           options.innerContainer.innerHTML = options.text;
         };
-        options.toggleSubtitles = function() {};
-        
-        var readyCheck = setInterval(function() {
-          if ( !scriptLoaded ) {
-            return;
-          }
-          clearInterval( readyCheck );
-
-          if ( options.languagesrc ) {
-            options.showSubtitle = translate;
-            options.languageSrc = document.getElementById( options.languagesrc );
-            options.selectedLanguage = options.languageSrc.options[ options.languageSrc.selectedIndex ].value;
-
-            if ( !this.languageSources ) {
-              this.languageSources = {};
-            }
-
-            if ( !this.languageSources[ options.languagesrc ] ) {
-              this.languageSources[ options.languagesrc ] = {};
-            }
-
-            if ( !this.languageSources[ options.languagesrc ][ options.target ] ) {
-              this.languageSources[ options.languagesrc ][ options.target ] = true;
-
-              options.languageSrc.addEventListener( "change", function() {
-
-                options.toggleSubtitles();
-
-                for( var k = 0, children = options.container.children, len = children.length; k < len; k++ ) {
-                  if ( children[ k ].style.display === "inline" ) {   
-                    options.showSubtitle( options, children[ k ].innerHTML );   
-                  }  
-                }
-
-              }, false );
-
-            }
-
-          }
-          if ( accessibility ) {
-            options.accessibility = accessibility;
-
-            options.toggleSubtitles = function() {
-
-              options.selectedLanguage = options.languageSrc.options[ options.languageSrc.selectedIndex ].value;
-
-              if ( options.accessibility.checked || options.selectedLanguage !== ( options.language || "") ) {
-
-                options.display = "inline";
-                options.container.style.display = options.display;
-              } else if ( options.selectedLanguage === ( options.language || "") ) {
-
-                options.display = "none";
-                options.container.style.display = options.display;
-              }
-            };
-
-            options.accessibility.addEventListener( "change", options.toggleSubtitles, false );
-
-            // initiate it once to set starting state
-            options.toggleSubtitles();
-          }
-        }, 5);
-
       },
       /**
        * @member subtitle 
index 05ff6db2196ee51586afc48e880080dc2fa26f6f..ff84ce35cb1e6de743d3d7edde4c4f42480bc5cc 100755 (executable)
     <p>Your user agent does not support the HTML5 Video element.</p> 
 
   </video> 
-  <h2>Choose your language</h2>
-  <select id="language">
-    <option value="en" selected="selected">English</option>
-  </select>
-  <div>
-    with help from <a href="http://google.com/translate">Google Translate</a><br />
-    <input type="checkbox" id="accessibility" checked="checked" />All subtitles (accessibility)
-  </div>
 </body>
 </html>
index a0f9328182746d0f766a73aed2bf68e69dab9d0f..8101cc547bf96a03022e767dbce8ca59f3a8cf2c 100755 (executable)
@@ -2,7 +2,7 @@ test("Popcorn Subtitle Plugin", function () {
  
   var popped = Popcorn( "#video" ),
       popped2 = Popcorn( "#video2" ),
-      expects = 16,
+      expects = 12,
       count = 0,
       subTop = 9001,
       subLeft = 9001,
@@ -26,25 +26,16 @@ test("Popcorn Subtitle Plugin", function () {
       start: 0,
       end: 2,
       text: 'this is the first subtitle of 2011',
-      language: "en",
-      languagesrc: "language",
-      accessibilitysrc: "accessibility"
     } )
   .subtitle({
       start: 2,
       end: 4,
       text: 'this is the second subtitle of 2011',
-      language: "en",
-      languagesrc: "language",
-      accessibilitysrc: "accessibility"
     } )
   .subtitle({
       start: 5,
       end: 7,
       text: 'this is the third subtitle of 2011',
-      language: "en",
-      languagesrc: "language",
-      accessibilitysrc: "accessibility"
     } )
     .volume(0)
     .play();
@@ -124,31 +115,6 @@ test("Popcorn Subtitle Plugin", function () {
     popped.media.play();
  
   });
- 
-  popped.exec( 6, function() {
-
-    popped.media.play();
-
-    equals (subtitlediv.style.display, "inline", "subtitles being displayed with accessiblity on" );
-    plus();
-
-    // turn accessibility off
-    document.getElementById( "accessibility" ).click();
-
-    equals (subtitlediv.style.display, "none", "subtitles not being displayed with accessiblity off" );
-    plus();
-
-    // turn accessibility back on
-    document.getElementById( "accessibility" ).click();
-
-    equals (subtitlediv.style.display, "inline", "subtitles being displayed with accessiblity back on" );
-    plus();
-
-    equals (subtitlediv.children[ 2 ].innerHTML, "this is the third subtitle of 2011", "subtitle displaying correct information" );
-    plus();
-    popped.media.play();
-   
-  });
 
   popped.exec( 8, function() {
     popped.pause();