var results; function playVideo(id) { var vp = document.getElementById('videoplayer'); vp.innerHTML = ''; // wipe it clean document.getElementById('overlay').style.display = vp.style.display = 'block'; var player = GvideoSearch.createPlayer(results[id], "playerwidget"); var close = document.createElement("div"); var ahref = document.createElement("a"); ahref.setAttribute("href", "javascript:void(0);"); ahref.setAttribute("id", "close"); ahref.onclick = clearPlayer; ahref.appendChild(document.createTextNode("close")); close.appendChild(ahref); vp.replaceChild(player, vp.firstChild); vp.appendChild(close); } GSearch.setOnLoadCallback(function() { doSearch(); setupOverlay(); }); function doSearch(narrow) { var term, escapedterm; if (narrow) { term = narrow; escapedterm = escape(term); } else { term = 'most recent videos'; escapedterm = ''; } var videolink = ''; var videoSearch = new GvideoSearch(); videoSearch.setResultOrder(GSearch.ORDER_BY_DATE); videoSearch.setResultSetSize(GSearch.LARGE_RESULTSET); videoSearch.setNoHtmlGeneration(); videoSearch.setSearchCompleteCallback(null, function() { var output; if (videoSearch.results.length == 0) { output = '

No results found for: ' + term + '

Try again, or check out the most recent tech talk videos

'; } else { output = '
Search Results for: ' + videolink + term + '
'; results = videoSearch.results; var totalVideos = videoSearch.results.length; for (var x=0; x < totalVideos; x++) { var result = videoSearch.results[x]; var nicerDate = new Date(); nicerDate.setTime(Date.parse(result.published)); var duration = parseInt(result.duration / 60) var dateFormatted = (nicerDate.getMonth()+1) + '/' + nicerDate.getDate() + '/' + nicerDate.getFullYear(); var snippet = stripToAbstract(result.content); var playUrl = ''; var entry = ''; if ( (x % 2) == 0) { output += '' + entry; } else { output += entry + ''; } } if (totalVideos % 2 == 1) { // odd, so a tr is left over output += ''; } output += '
' + playUrl + '' + result.titleNoFormatting + ' Video
' + playUrl + result.titleNoFormatting + '
Recorded on ' + dateFormatted + ' view on GV
Duration: ' + duration + ' mins

' + snippet + '

' + videolink + 'View all results for: ' + term + ' »
'; } document.getElementById('videoresults').innerHTML = output; }); var searchterm = 'user:"Google engEDU"'; if (narrow) { searchterm = searchterm + ' ' + narrow; } videoSearch.execute(searchterm); }; function setupOverlay() { var xScroll, yScroll; if (window.innerHeight && window.scrollMaxY) { xScroll = document.body.scrollWidth; yScroll = window.innerHeight + window.scrollMaxY; } else if (document.body.scrollHeight > document.body.offsetHeight){ xScroll = document.body.scrollWidth; yScroll = document.body.scrollHeight; } else { xScroll = document.body.offsetWidth; yScroll = document.body.offsetHeight; } var windowWidth, windowHeight; if (self.innerHeight) { windowWidth = self.innerWidth; windowHeight = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { windowWidth = document.documentElement.clientWidth; windowHeight = document.documentElement.clientHeight; } else if (document.body) { windowWidth = document.body.clientWidth; windowHeight = document.body.clientHeight; } if (yScroll < windowHeight){ pageHeight = windowHeight; } else { pageHeight = yScroll; } if (xScroll < windowWidth){ pageWidth = windowWidth; } else { pageWidth = xScroll; } var overlay = document.getElementById('overlay'); overlay.style.height = pageHeight; overlay.style.width = pageWidth; //overlay.onclick = clearPlayer; } function stripToAbstract(snippet) { var index = snippet.indexOf('ABSTRACT'); return (index > 0) ? snippet.substring(index + 8) : snippet; } function clearPlayer() { document.getElementById('overlay').style.display = document.getElementById('videoplayer').style.display = 'none'; }