diff --git a/images/document-download.png b/images/document-download.png new file mode 100644 index 0000000000..9cceef2486 Binary files /dev/null and b/images/document-download.png differ diff --git a/images/facebook.png b/images/facebook.png new file mode 100644 index 0000000000..f024b7c8ae Binary files /dev/null and b/images/facebook.png differ diff --git a/images/linkedin.png b/images/linkedin.png new file mode 100644 index 0000000000..34261b05e5 Binary files /dev/null and b/images/linkedin.png differ diff --git a/images/twitter.png b/images/twitter.png new file mode 100644 index 0000000000..3d1856f834 Binary files /dev/null and b/images/twitter.png differ diff --git a/js/jquery.cookie.js b/js/jquery.cookie.js new file mode 100644 index 0000000000..6d5974a2c5 --- /dev/null +++ b/js/jquery.cookie.js @@ -0,0 +1,47 @@ +/*! + * jQuery Cookie Plugin + * https://github.com/carhartl/jquery-cookie + * + * Copyright 2011, Klaus Hartl + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://www.opensource.org/licenses/mit-license.php + * http://www.opensource.org/licenses/GPL-2.0 + */ +(function($) { + $.cookie = function(key, value, options) { + + // key and at least value given, set cookie... + if (arguments.length > 1 && (!/Object/.test(Object.prototype.toString.call(value)) || value === null || value === undefined)) { + options = $.extend({}, options); + + if (value === null || value === undefined) { + options.expires = -1; + } + + if (typeof options.expires === 'number') { + var days = options.expires, t = options.expires = new Date(); + t.setDate(t.getDate() + days); + } + + value = String(value); + + return (document.cookie = [ + encodeURIComponent(key), '=', options.raw ? value : encodeURIComponent(value), + options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE + options.path ? '; path=' + options.path : '', + options.domain ? '; domain=' + options.domain : '', + options.secure ? '; secure' : '' + ].join('')); + } + + // key and possibly options given, get cookie... + options = value || {}; + var decode = options.raw ? function(s) { return s; } : decodeURIComponent; + + var pairs = document.cookie.split('; '); + for (var i = 0, pair; pair = pairs[i] && pairs[i].split('='); i++) { + if (decode(pair[0]) === key) return decode(pair[1] || ''); // IE saves cookies with empty string as "c; ", e.g. without "=" as opposed to EOMB, thus pair[1] may be undefined + } + return null; + }; +})(jQuery); diff --git a/js/video_player.js b/js/video_player.js index 507596f8a6..fbf529a8ee 100644 --- a/js/video_player.js +++ b/js/video_player.js @@ -77,8 +77,8 @@ function submit_circuit(circuit_id) { // Video player var load_id = 0; - -var video_speed = 1.0; +var caption_id; +var video_speed = "1.0"; var updateytPlayerInterval; var ajax_videoInterval; @@ -86,8 +86,13 @@ var ajax_videoInterval; function change_video_speed(speed, youtube_id) { new_position = ytplayer.getCurrentTime() * video_speed / speed; video_speed = speed; - ytplayer.loadVideoById(youtube_id, new_position); + ytplayer.loadVideoById(youtube_id, new_position); + syncPlayButton(); log_event("speed", {"new_speed":speed, "clip":youtube_id}); + console.log("setting"); + console.log(speed); + + $.cookie("video_speed", speed, {'expires':3650, 'path':'/'}); } function caption_at(index) { @@ -190,7 +195,7 @@ function onYouTubePlayerReady(playerId) { ytplayer.addEventListener("onError", "onPlayerError"); if((typeof load_id != "undefined") && (load_id != 0)) { var id=load_id; - loadNewVideo(id, 0); + loadNewVideo(caption_id, id, 0); } } @@ -357,11 +362,12 @@ function updateytplayerInfo() { } // functions for the api calls -function loadNewVideo(id, startSeconds) { +function loadNewVideo(cap_id, id, startSeconds) { captions={"start":[0],"end":[0],"text":["Attempting to load captions..."]}; - $.getJSON("/static/subs/"+id+".srt.sjson", function(data) { + $.getJSON("/static/subs/"+cap_id+".srt.sjson", function(data) { captions=data; }); + caption_id = cap_id; load_id = id; //if ((typeof ytplayer != "undefined") && (ytplayer.type=="application/x-shockwave-flash")) { // Try it every time. If we fail, we want the error message for now. @@ -378,6 +384,15 @@ function loadNewVideo(id, startSeconds) { //seekTo(startSeconds); } +function syncPlayButton(){ + var state = getPlayerState(); + if (state == 1 || state == 3) { + $("#video_control").removeClass("play").addClass("pause"); + } else if (state == 2 || state == -1 || state == 0){ + $("#video_control").removeClass("pause").addClass("play"); + } +} + function cueNewVideo(id, startSeconds) { if (ytplayer) { ytplayer.cueVideoById(id, startSeconds);