Review comment fixes, style fixes.

This commit is contained in:
David Humphrey 2011-02-17 16:48:31 -05:00
Родитель 3dd0e3cd84
Коммит 9edd9fcc5c
2 изменённых файлов: 36 добавлений и 26 удалений

Просмотреть файл

@ -10,6 +10,9 @@
document.addEventListener('DOMContentLoaded', function () { document.addEventListener('DOMContentLoaded', function () {
output = document.getElementById('output'); output = document.getElementById('output');
var $ = function( id ) {
return document.getElementById( id.substring( 1 ) );
};
var p = Popcorn('#video') var p = Popcorn('#video')
@ -17,7 +20,7 @@
start: 1, start: 1,
end: 3, end: 3,
onStart: function( options ) { onStart: function( options ) {
output.innerHTML = 'Test 1 - onStart (no onEnd)'; $('#test1').innerHTML = 'Yes';
} }
}) })
@ -25,10 +28,10 @@
start: 5, start: 5,
end: 8, end: 8,
onStart: function( options ) { onStart: function( options ) {
output.innerHTML = 'Test 2 - onStart'; $('#test2a').innerHTML = 'Yes';
}, },
onEnd: function ( options ) { onEnd: function ( options ) {
output.innerHTML = 'Test 2 - onEnd'; $('#test2b').innerHTML = 'Yes';
} }
}) })
@ -36,13 +39,16 @@
start: 10, start: 10,
end: 14, end: 14,
onStart: function( options ) { onStart: function( options ) {
output.innerHTML = 'Test 3 - onStart [Frames: '; $('#test3a').innerHTML = 'Yes';
},
onFrame: function ( options ) {
output.innerHTML += '.';
}, },
onFrame: (function() {
var count = 0;
return function ( options ) {
$('#test3b').innerHTML = 'Yes (count = ' + ++count + ')';
}
})(),
onEnd: function ( options ) { onEnd: function ( options ) {
output.innerHTML += '] Test 3 - onEnd'; $('#test3c').innerHTML = 'Yes';
} }
}) })
@ -76,7 +82,15 @@
</div> </div>
<div style="width:700px"> <div style="width:700px">
<div>Code Plugin Output</div> <div>Code Plugin Output</div>
<div id="output" style="position:relative;float:left;width:300px;height:400px"></div> <table cellpadding="5px">
<tr><th>Test</th><th>Completed</th></tr>
<tr><td>Test 1 - onStart (1s)</td><td><span id="test1">No</span></td></tr>
<tr><td>Test 2a - onStart (5s)</td><td><span id="test2a">No</span></td></tr>
<tr><td>Test 2b - onEnd (8s)</td><td><span id="test2b">No</span></td></tr>
<tr><td>Test 3a - onStart (10s)</td><td><span id="test3a">No</span></td></tr>
<tr><td>Test 3b - onFrame (10s-14s)</td><td><span id="test3b">No</span></td></tr>
<tr><td>Test 3c - onEnd (14s)</td><td><span id="test3c">No</span></td></tr>
</table>
</div> </div>
</body> </body>
</html> </html>

Просмотреть файл

@ -28,7 +28,7 @@
* Example: * Example:
var p = Popcorn('#video') var p = Popcorn('#video')
/* onStart function only // onStart function only
.code({ .code({
start: 1, start: 1,
end: 4, end: 4,
@ -37,7 +37,7 @@
} }
}) })
/* onStart + onEnd only // onStart + onEnd only
.code({ .code({
start: 6, start: 6,
end: 8, end: 8,
@ -49,7 +49,7 @@
} }
}) })
/* onStart, onEnd, onFrame // onStart, onEnd, onFrame
.code({ .code({
start: 10, start: 10,
end: 14, end: 14,
@ -68,7 +68,7 @@
* *
*/ */
Popcorn.plugin( "code" , function() { Popcorn.plugin( 'code' , function() {
function get( name, options ) { function get( name, options ) {
return options._instance[name]; return options._instance[name];
@ -82,20 +82,16 @@
var step = ( function() { var step = ( function() {
var buildFrameRunner = function( runner ) { var buildFrameRunner = function( runner ) {
var _runner = runner;
return function( f, options ) { return function( f, options ) {
var _options = options;
var _f = function() { var _f = function() {
f(); f();
if ( get( 'running', _options ) ) { if ( get( 'running', options ) ) {
_runner( _f ); runner( _f );
} }
}; };
_f(); _f();
}; };
}; };
@ -116,10 +112,10 @@
return { return {
manifest: { manifest: {
about: { about: {
name: "Popcorn Code Plugin", name: 'Popcorn Code Plugin',
version: "0.1", version: '0.1',
author: "David Humphrey (@humphd)", author: 'David Humphrey (@humphd)',
website: "http://vocamus.net/dave" website: 'http://vocamus.net/dave'
}, },
options: { options: {
start: {elem:'input', type:'text', label:'In'}, start: {elem:'input', type:'text', label:'In'},
@ -133,15 +129,15 @@
_setup : function( options ) { _setup : function( options ) {
if ( !options.onStart || !( typeof options.onStart === 'function' ) ) { if ( !options.onStart || !( typeof options.onStart === 'function' ) ) {
throw "Popcorn Code Plugin Error: onStart must be a function."; throw 'Popcorn Code Plugin Error: onStart must be a function.';
} }
if ( options.onEnd && !( typeof options.onEnd === 'function' ) ) { if ( options.onEnd && !( typeof options.onEnd === 'function' ) ) {
throw "Popcorn Code Plugin Error: onEnd must be a function."; throw 'Popcorn Code Plugin Error: onEnd must be a function.';
} }
if ( options.onFrame && !( typeof options.onFrame === 'function' ) ) { if ( options.onFrame && !( typeof options.onFrame === 'function' ) ) {
throw "Popcorn Code Plugin Error: onFrame must be a function."; throw 'Popcorn Code Plugin Error: onFrame must be a function.';
} }
options._instance = { running: false }; options._instance = { running: false };