Search Results

Search found 3 results on 1 pages for 'zaius'.

Page 1/1 | 1 

  • Hidden youtube player loses its methods

    - by zaius
    I'm controlling a embedded youtube chromeless player with javascript, and I want to hide it occasionally by setting display: none. However, when I show the player again, it loses its youtube methods. For example: <script> swfobject.embedSWF("http://www.youtube.com/apiplayer?enablejsapi=1&playerapiid=player", "player", "425", "356", "8", null, null, {allowScriptAccess: "always"}, {id: 'player'} ); var player = null; function onYouTubePlayerReady(playerId) { player = document.getElementById(playerId); player.addEventListener('onStateChange', 'playerStateChanged'); } function hidePlayer() { player.pauseVideo(); player.style.display = 'none'; } function showPlayer() { player.style.display = 'block'; player.playVideo(); } </script> <a href="#" onClick="hidePlayer();">hide</a> <a href="#" onClick="showPlayer();">show</a> <div id="player"></div> Calling hidePlayer followed by showPlayer gives this error on the playVideo call: Uncaught TypeError: Object #<an HTMLObjectElement> has no method 'playVideo' The only solution I can find is to use visibility: hidden, but that is messing with my page layout. Any other solutions out there?

    Read the article

  • Simplify my menu animation code

    - by zaius
    I've got a bunch of 'project' divs that I want to expand when they're clicked on. If there's already a project open, I want to hide it before I slide out the new one. I also want to stop clicks on an already open project from closing and then opening it again. Here's an example of what I mean (warning - wrote the code in the browser): $('.projects').click(function() { var clicked_project = $(this); if (clicked_project.is(':visible')) { clicked_project.height(10).slideUp(); return; } var visible_projects = $('.projects:visible'); if (visible_projects.size() > 0) { visible_projects.height(10).slideUp(function() { clicked_project.slideDown(); }); } else { clicked_project.slideDown(); } }); Really, my big issue is with the second part - it sucks that I have to use that if/else - I should just be able to make the callback run instantly if there aren't any visible_projects. I would think this would be a pretty common task, and I'm sure there's a simplification I'm missing. Any suggestions appreciated!

    Read the article

  • Speeding up a group by date query on a big table in postgres

    - by zaius
    I've got a table with around 20 million rows. For arguments sake, lets say there are two columns in the table - an id and a timestamp. I'm trying to get a count of the number of items per day. Here's what I have at the moment. SELECT DATE(timestamp) AS day, COUNT(*) FROM actions WHERE DATE(timestamp) >= '20100101' AND DATE(timestamp) < '20110101' GROUP BY day; Without any indices, this takes about a 30s to run on my machine. Here's the explain analyze output: GroupAggregate (cost=675462.78..676813.42 rows=46532 width=8) (actual time=24467.404..32417.643 rows=346 loops=1) -> Sort (cost=675462.78..675680.34 rows=87021 width=8) (actual time=24466.730..29071.438 rows=17321121 loops=1) Sort Key: (date("timestamp")) Sort Method: external merge Disk: 372496kB -> Seq Scan on actions (cost=0.00..667133.11 rows=87021 width=8) (actual time=1.981..12368.186 rows=17321121 loops=1) Filter: ((date("timestamp") >= '2010-01-01'::date) AND (date("timestamp") < '2011-01-01'::date)) Total runtime: 32447.762 ms Since I'm seeing a sequential scan, I tried to index on the date aggregate CREATE INDEX ON actions (DATE(timestamp)); Which cuts the speed by about 50%. HashAggregate (cost=796710.64..796716.19 rows=370 width=8) (actual time=17038.503..17038.590 rows=346 loops=1) -> Seq Scan on actions (cost=0.00..710202.27 rows=17301674 width=8) (actual time=1.745..12080.877 rows=17321121 loops=1) Filter: ((date("timestamp") >= '2010-01-01'::date) AND (date("timestamp") < '2011-01-01'::date)) Total runtime: 17038.663 ms I'm new to this whole query-optimization business, and I have no idea what to do next. Any clues how I could get this query running faster?

    Read the article

1