Skip to content

Commit

Permalink
Change default example video and fix a bug with global score calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
Betree committed Jan 25, 2018
1 parent 0fdfc9c commit cbedff1
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ else
exit 1
fi

surge ${REMOTE}
surge -d ${REMOTE} -p ./dist
6 changes: 3 additions & 3 deletions dist/test/html5.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ <h2><a href="/"><= Back to index</a></h2>
<hr/>
<br/>
<div id="video" style="display: block; width: 800px; height: 450px; position: relative;">
<video controls width="800" height="450" poster="https://thinkerview.com/wp-content/uploads/Cedric-villani-1024x576.jpg">
<source src="//thinkerview.com/podcast-download/1958/cedric-villani-intelligence-artificielle-perspectives-futures.mp4?ref=videoplayer&amp;res=240"
<video controls width="800" height="450" poster="https://thinkerview.com/wp-content/uploads/FredericTaddei-1024x576.jpg">
<source src="//thinkerview.com/podcast-download/1983/frederic-taddei-limites-debat.mp4?ref=videoplayer&res=360"
type="video/mp4">
</video>
</div>
Expand All @@ -24,7 +24,7 @@ <h2>Activation Toggle</h2>
window.CaptainFactOverlayConfig = {
injector: {
videosSelector: () => [document.getElementById('video')],
urlExtractor: video => "https://www.youtube.com/watch?v=LMRdn_MQWXM",
urlExtractor: video => "https://www.youtube.com/watch?v=3HgwtHenFWs",
getPlayer: (video, adapters) => new adapters.HTML5(video.querySelector('video')),
onOffToggleSelector: () => document.getElementsByClassName('toggle-btn-container')
}
Expand Down
2 changes: 1 addition & 1 deletion dist/test/no_video.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h2>Activation Toggle</h2>
window.CaptainFactOverlayConfig = {
injector: {
videosSelector: () => [document.getElementById('video')],
urlExtractor: video => "https://www.youtube.com/watch?v=LMRdn_MQWXM",
urlExtractor: video => "https://www.youtube.com/watch?v=3HgwtHenFWs",
getPlayer: (video, adapters) => null,
onOffToggleSelector: () => document.getElementsByClassName('toggle-btn-container')
},
Expand Down
10 changes: 4 additions & 6 deletions dist/test/videojs.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ <h2><a href="/"><= Back to index</a></h2>
<hr/>
<br/>
<video id="video" class="video-js vjs-default-skin" controls preload="auto" width="800" height="450"
poster="https://thinkerview.com/wp-content/uploads/Cedric-villani-1024x576.jpg"
poster="https://thinkerview.com/wp-content/uploads/FredericTaddei-1024x576.jpg"
data-setup='{"playbackRates": [1, 1.2, 1.5, 1.7, 2], "seek_param": "time"}'>
<source src="//thinkerview.com/podcast-download/1958/cedric-villani-intelligence-artificielle-perspectives-futures.mp4?ref=videoplayer&amp;res=240"
type="video/mp4" label="240p" res="240" default="">
<source src="//thinkerview.com/podcast-download/1958/cedric-villani-intelligence-artificielle-perspectives-futures.mp4?ref=videoplayer&amp;res=360"
<source src="//thinkerview.com/podcast-download/1983/frederic-taddei-limites-debat.mp4?ref=videoplayer&res=360"
type="video/mp4" label="360p" res="360" default="">
<source src="//thinkerview.com/podcast-download/1958/cedric-villani-intelligence-artificielle-perspectives-futures.mp4?ref=videoplayer&amp;res=480"
<source src="//thinkerview.com/podcast-download/1983/frederic-taddei-limites-debat.mp4?ref=videoplayer&res=480"
type="video/mp4" label="480p" res="480" default="">
</video>
<script src="testlibs/video.js"></script>
Expand All @@ -35,7 +33,7 @@ <h2>A second toggle <small>(just for the lulz)</small></h2>
window.CaptainFactOverlayConfig = {
injector: {
videosSelector: () => [document.getElementById('video')],
urlExtractor: video => "https://www.youtube.com/watch?v=LMRdn_MQWXM",
urlExtractor: video => "https://www.youtube.com/watch?v=3HgwtHenFWs",
getPlayer: (video, adapters) => new adapters.HTML5(video.querySelector('video')),
onOffToggleSelector: () => document.getElementsByClassName('toggle-btn-container')
},
Expand Down
6 changes: 3 additions & 3 deletions dist/test/youtube.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ <h1>Youtube video (iframe), facts in a separate block</h1>
<h2><a href="/"><= Back to index</a></h2>
<hr/><br/>
<iframe id="video" type="text/html" width="640" height="360"
src="https://www.youtube.com/embed/LMRdn_MQWXM?enablejsapi=1"
src="https://www.youtube.com/embed/3HgwtHenFWs?enablejsapi=1"
frameborder="0"></iframe>
<div>
<h2>Facts</h2>
Expand All @@ -27,15 +27,15 @@ <h2>Activation Toggle</h2>
let player = null
function onYouTubeIframeAPIReady() {
player = new YT.Player(video, {
videoId: 'LMRdn_MQWXM',
videoId: '3HgwtHenFWs',
events: {onReady: initialize}
});
}
function initialize() {
new window.CaptainFactOverlayInjector({
injector: {
videosSelector: document => [video],
urlExtractor: video => "https://www.youtube.com/watch?v=LMRdn_MQWXM",
urlExtractor: video => "https://www.youtube.com/watch?v=3HgwtHenFWs",
onOffToggleSelector: () => document.getElementsByClassName('toggle-btn-container'),
factsInjector: (mountFunc, video, facts) => mountFunc(document.getElementById('facts-container'), facts),
getPlayer: (video, adapters) => new adapters.Youtube(player),
Expand Down
11 changes: 8 additions & 3 deletions src/components/CFButton/CFButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,14 @@ export class CFButton extends React.PureComponent {
// TODO This should be in Redux
if (!this.props.statement)
return 0
return this.props.statement.comments.reduce((score, comment) =>
score + (comment.approve ? comment.score : -comment.score)
, 0)

return this.props.statement.comments.reduce((score, comment) => {
if (comment.approve === true)
return score + Math.max(comment.score, 0)
else if (comment.approve === false)
return score - Math.max(comment.score, 0)
return score
}, 0)
}
}

Expand Down
4 changes: 2 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ module.exports = (env='dev') => {
// Default config
const config = {
entry: {
'captain-fact-overlay-injector': './src/index.js'
'captain-fact-overlay-injector': './src/index.js',
'captain-fact-overlay-injector.min': './src/index.js'
},
devtool: 'inline-source-map',
devServer: {contentBase: './dist', port: 3342},
Expand Down Expand Up @@ -67,7 +68,6 @@ module.exports = (env='dev') => {
// Production override
if (isProd) {
delete config.devtool
config.entry['captain-fact-overlay-injector.min'] = './src/index.js'
config.plugins = COMMON_PLUGINS.concat([
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
Expand Down

0 comments on commit cbedff1

Please sign in to comment.