Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

with scroll following video played + christmas keyword suggestion + u…

…ri hash monitoring
  • Loading branch information...
commit 8f44961af26f32388401842399b6ae0ed60127f7 1 parent 48249e2
Evangenieur authored December 24, 2012
47  public/javascripts/hvidio.coffee
@@ -13,6 +13,7 @@ $close = $("#close")
13 13
 $header = $("#header")
14 14
 $hashtags = $('#hashtags')
15 15
 $clickjack = $("#clickjack")
  16
+num_vdo_by_row = null
16 17
 window.hvidio =
17 18
   init: ->
18 19
     
@@ -25,15 +26,24 @@ window.hvidio =
25 26
     loader.setDensity 32
26 27
     loader.setRange 0.6
27 28
     loader.setSpeed 1
28  
-    
29  
-    # load the hashtag
30  
-    if window.location.hash
31  
-      setTimeout (->
32  
-        $("#keyword").val window.location.hash.substr(1)
33  
-        $("#form").submit()
34  
-      ), 200
35  
-    else
36  
-      $keyword.focus()
  29
+
  30
+    last_search = null    
  31
+
  32
+    # Hash Check
  33
+    setInterval ->
  34
+      search_term = if window.location.hash
  35
+          unescape window.location.hash.substr(1).replace("+", " ")
  36
+        else
  37
+          null
  38
+      if last_search isnt search_term
  39
+        if search_term isnt $("#keyword").val()
  40
+          $("#keyword").val search_term
  41
+          $("#form").submit()
  42
+        hvidio.search search_term
  43
+        last_search = search_term
  44
+    , 100
  45
+
  46
+    $keyword.focus()
37 47
 
38 48
     jQuery.timeago.settings.allowFuture = true
39 49
     
@@ -75,8 +85,7 @@ window.hvidio =
75 85
     $form.on "submit", (e) ->
76 86
       keyword = $keyword.val()
77 87
       $hashtags.remove()
78  
-      hvidio.search keyword
79  
-      window.location.hash = "#" + keyword
  88
+      window.location.hash = "#" + escape(keyword.replace(" ", "+")).replace("%23", "#")
80 89
       e.preventDefault()
81 90
 
82 91
     #keyCodes
@@ -336,9 +345,17 @@ window.hvidio =
336 345
 
337 346
   play: (embed, delay) ->
338 347
     $results.find(".video").removeClass "current"
339  
-    $results.find("a[href=\"" + embed + "\"]").closest(".video").addClass "current"
  348
+    $currentVdo = $results.find("a[href=\"" + embed + "\"]").closest(".video")
  349
+    $currentVdo.blur() if  $(":focus")[0]?.nodeName is "INPUT"
  350
+    $currentVdo.addClass "current"
  351
+    $currentVdo.blur() 
  352
+
  353
+    try 
  354
+      $results.mCustomScrollbar "scrollTo", pos.top
  355
+    catch e
  356
+      console.log e
340 357
     
341  
-    dom_id = $results.find("a[href=\"" + embed + "\"]").closest(".video").attr "id"
  358
+    dom_id = $currentVdo.attr "id"
342 359
     
343 360
     video = _(@videos[@keyword]).find (vdo) -> 
344 361
       vdo.dom_id is dom_id
@@ -389,6 +406,10 @@ window.hvidio =
389 406
     ew = $results.find("li").outerWidth(true)
390 407
     rw = (Math.floor(mw / ew)) * ew
391 408
     $results.find(".video-list").width rw
  409
+
  410
+
  411
+    $(".video:eq(0)").each (v) ->
  412
+
392 413
     
393 414
     hvidio.hashtags()
394 415
 
6  views/index.jade
@@ -32,11 +32,11 @@ block content
32 32
                 | Why not try one of there?
33 33
             ul 
34 34
                 li
35  
-                    a(href="ladygaga") #ladygaga
  35
+                    a(href="#christmas") #Christmas
36 36
                 li
37  
-                    a(href="newtown") #newtown
  37
+                    a(href="#santaclaus") #SantaClaus
38 38
                 li
39  
-                    a(href="hurricane") #hurricane
  39
+                    a(href="disneyland") Disneyland
40 40
 
41 41
     script#videosTemplate(type='text/template')
42 42
         |  <ul id="video-list-<%= search %>" class="video-list">

0 notes on commit 8f44961

Please sign in to comment.
Something went wrong with that request. Please try again.