Skip to content
Browse files

add date filter

  • Loading branch information...
1 parent 028cc8c commit 92d3dba7912febd56d7cc5be4b79b6777024519b @zhengjia committed May 22, 2011
Showing with 31 additions and 9 deletions.
  1. +24 −8 public/unwatch.js
  2. +7 −1 views/unwatch.erb
View
32 public/unwatch.js
@@ -7,17 +7,33 @@ $(document).ready(function(){
type: "POST",
dataType: "text",
url: "/unwatch/" + $(this).data('username') + '/' + $(this).data('repo'),
- statusCode: {
- 200: function(msg){
- $("#notice").html(msg);
- $(that).parent().parent().hide();
- },
- 503: function(msg){
- $("#notice").html("Error occured");
- }
+ success: function(msg){
+ $("#notice").html(msg);
+ $(that).parent().parent().remove();
+ },
+ error:function(xhr, ajaxOptions, thrownError){
+ $("#notice").html(xhr.responseText);
}
});
return false;
})
+ $('#datePicker').datepicker();
+ $("#datePicker").bind("change", function(){
+ $('tr').show()
+ var date_str = $(this).val()
+ var date = Date.parse(date_str)
+ if( jQuery.trim( date_str ) != "" ){
+ $(".pushDate").each(function(){
+ if(Date.parse( $(this).text() ) < date){
+ $(this).parent().hide();
+ }
+ })
+ }
+ else{
+ $('tr').show()
+ }
+
+ });
+
})
View
8 views/unwatch.erb
@@ -1,15 +1,21 @@
<html>
<head>
<link type="text/css" rel="stylesheet" href="/css/blue/style.css">
+ <link type="text/css" rel="stylesheet" href="/css/jquery-ui/jquery-ui-1.8.13.custom.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.js"></script>
+ <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js"></script>
<script>window.jQuery || document.write(unescape('%3Cscript src="/jquery.js"%3E%3C/script%3E'))</script>
+ <script>window.jQuery || document.write(unescape('%3Cscript src="/jquery-ui.min.js"%3E%3C/script%3E'))</script>
<script src="/jquery.tablesorter.min.js"></script>
<script src="/unwatch.js"></script>
</head>
<body>
<div id="notice" style="width: 100%; background-color: #EAE9E4"></div>
<div>Username: <%= @username %></div>
<div>
+ Repositories pushed before: <input type="text" id="datePicker" />
+ </div>
+ <div>
<table class="tablesorter">
<thead>
<tr>
@@ -30,7 +36,7 @@
<td><%= repository["owner"]%></td>
<td><%= repository["watchers"]%></td>
<td><%= repository["forks"]%></td>
- <td><%= Time.parse(repository["pushed_at"]).strftime("%m/%d/%Y") %></td>
+ <td class='pushDate'><%= Time.parse(repository["pushed_at"]).strftime("%m/%d/%Y") %></td>
<td><a href='#' data-username='<%= repository["owner"]%>' data-repo='<%= repository["name"] %>' class="unwatchLink">Unwatch</td>
</tr>
<% end %>

0 comments on commit 92d3dba

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