]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
fixed plugin and the unit tests
authorAnna Sobiepanek <annaopensource@gmail.com>
Sun, 5 Dec 2010 22:02:26 +0000 (17:02 -0500)
committerAnna Sobiepanek <annaopensource@gmail.com>
Sun, 5 Dec 2010 22:02:26 +0000 (17:02 -0500)
plugins/webpage/popcorn.webpage.js
plugins/webpage/popcorn.webpage.unit.html
plugins/webpage/popcorn.webpage.unit.js

index b5825523bc8c62e5fce946275546256118db5c22..259fe11cd8f21c7625d199e28e5f9a7751c9cecd 100644 (file)
     // set the style of the iframe
     iframe.setAttribute('width', "100%");
     iframe.setAttribute('height', "100%");
-    
-    
-    
+    iframe.id= options.id;
+    iframe.src = options.src;
+    var temp  = document.getElementById( options.target );
+        
     // get the options that the user included
     if ( typeof options === "object" && "join" in options ) {
       page = options;
       // loop threw all of the webpages 
       Popcorn.forEach(page, function ( thispage ) {
                
-        var temp  = document.getElementById( thispage.target );
-        iframe.setAttribute('id', thispage.id);
+        
         var exists  = document.getElementById( thispage.id );
         
         if ( this.currentTime() >= thispage.start && !exists &&  this.currentTime() <= thispage.end) {
           //div.innerHTML = div.innerHTML + thispage.html;
           // set the source of the webpage that this plugin should display
-          iframe.setAttribute('src', thispage.src);
+          
           temp.appendChild(iframe);
         }
 
@@ -49,6 +49,8 @@
         }
       }, this);
     });
+    
+    return this;
   });
 
 })(Popcorn);
\ No newline at end of file
index 8b2f866419ab3d30fea92834c51290d241ad375e..7ae70c97155f2ecc77ffc4b68f652de493a9fea1 100644 (file)
@@ -45,6 +45,6 @@
     <p>Your user agent does not support the HTML5 Video element.</p> 
 
   </video> 
-  
+<div id="webpagediv"></div>  
 </body>
 </html>
index d4825664fc2910089fa12675272cb415530e417d..b5f2f189bbd74657e1f88c1235228bcdc81f2d6c 100644 (file)
@@ -1,38 +1,39 @@
 test("Popcorn Webpage Plugin", function () {
   
+  var popped = Popcorn("#video")
+      expects = 2, 
+      count = 0
+    ;
   
-  // needs expectation
-
-  var popped = Popcorn("#video"),
-      expects = 4,
-      count = 0;
-      
   expect(expects);
-      
-  function plus (){
-    if(++count === expects){
-      stop();
+  
+  function plus() {
+    if( ++count===expects) {
+      start();
     }
   }
   
+  stop();
+  
+  
+  ok( 'webpages' in popped, "webpages is a mehtod of the popped instance");
+  plus();
+  
   popped.webpages({
       id: "webpages-a", 
-      start: 0, // seconds
-      end: 5, // seconds
+      start: 1, // seconds
+      end: 30, // seconds
       src: 'http://www.webmademovies.org',
       target: 'webpagediv'
-    });
-    
-  popped.play();
+    }).play();
   
   
-  ok( 'data' in popped, "popped has the data prop and therefore is a Popcorn object" )
   
-  ok( 'webpages' in popped, "webpages is a mehtod of the popped instance");
+  setTimeout(function() {
+    ok( !!document.getElementsByTagName('iframe')[0], "iframe was created" );
+    plus();
+  }, 5000);
+  
   
-  ok( typeof popped.webpages === "function" , "webpages is a function");
   
-  popped.exec(2, function(){
-    ok( document.getElementById('webpages-a') , "iframe exists");  
-  })
 });