Skip to content
Browse files

Merge branch 'master' of https://github.com/akariv/gov-watch into iso…

…tope
  • Loading branch information...
2 parents 557511d + 00eae76 commit d4fc9a809f610d9c7e892680bedc6c22c0be5745 @mushon committed
Showing with 63 additions and 46 deletions.
  1. +27 −16 src/gov-watch.iced
  2. +2 −2 src/static/html/index.html
  3. +34 −28 src/static/js/gov-watch.js
View
43 src/gov-watch.iced
@@ -170,7 +170,7 @@ setup_searchbox = ->
if $(this).val() == ""
show_watermark(true)
$("#searchbar").submit -> false
-
+
source = []
for tag in all_tags
source.push({type:"tag",title:tag})
@@ -179,12 +179,12 @@ setup_searchbox = ->
$("#searchbox").typeahead
source: source
items: 20
- matcher: (item) -> ~item.title.indexOf(this.query)
+ matcher: (item) -> ~item.title.indexOf(this.query)
valueof: (item) -> item.title
- selected: (val) ->
+ selected: (val) ->
search_term = val
update_history()
- highlighter: (item) ->
+ highlighter: (item) ->
highlighted_title = item.title.replace( new RegExp('(' + this.query + ')', 'ig'), ($1, match) -> '<strong>' + match + '</strong>' )
if item.type == "subject"
return highlighted_title
@@ -241,7 +241,7 @@ process_data = ->
)
# Update the document with rendered HTML
$("#items").html(html)
-
+
$(".item").each ->
# current status
implementation_status = $(this).attr('implementation-status')
@@ -258,17 +258,28 @@ process_data = ->
timeline_items = $(this).find(".timeline .timeline-point")
timeline_items.tsort({attr:'data-duedate',order:'asc'})
timeline_items = $(this).find(".timeline .timeline-point")
- len = timeline_items.length
- if len == 1
- stops = 1
- else
- stops = 75 / (len-1)
- for i in [0..len]
- timeline_item = $(timeline_items[i])
- timeline_item.css("top",(10+i*stops)+"%")
- timeline_item.tooltip({delay: {show:0,hide:1000},placement:'bottom',title:timeline_item.html()})
- timeline_item.html('')
-
+
+ max_numeric_date = 0
+ min_numeric_date = 2100 * 372
+ timeline_items.each( ->
+ date = $(this).attr('data-duedate')
+ date = date.split('/')
+ [year,month,day] = (parseInt(d) for d in date)
+ numeric_date = (year * 372) + ((month-1) * 31) + (day-1)
+ if numeric_date == NaN
+ numeric_date = 2012 * 372
+ if numeric_date > max_numeric_date
+ max_numeric_date = numeric_date + 1
+ if numeric_date < min_numeric_date
+ min_numeric_date = numeric_date
+ $(this).attr('data-duedate-numeric',numeric_date)
+ )
+ timeline_items.each( ->
+ date = parseInt($(this).attr('data-duedate-numeric'))
+ percent = (date - min_numeric_date) / (max_numeric_date - min_numeric_date) * 75.0 + 10
+ $(this).css("top",percent+"%")
+ )
+
# Allow the DOM to sync
await setTimeout((defer _),50)
View
4 src/static/html/index.html
@@ -33,7 +33,7 @@
<script type="text/html" name="item">
{{#items}}
-<div class="item span" rel="{{slug}}" {{#gov}} title="{{recommendation}}" cost="{{budget_cost_millions}}" implementation-status="{{implementation_status}}">
+<div class="item span" rel="{{slug}}" {{#gov}} title="{{recommendation}}" cost="{{budget.millions}}" implementation-status="{{implementation_status}}">
<div class="item-body">
<div class="tags">
@@ -156,7 +156,7 @@ <h2 class="buxa-header"> <!-- add class: good/bad -->
<!-- <p><a class="btn primary large">למדו עוד &raquo;</a></p> -->
<form id="searchbar" action="#">
<fieldset id='search'>
- <input id="searchbox" class="xlarge" type="text" size="30" name="xlInput">
+ <input id="searchbox" class="xlarge" type="text" size="30" autocomplete="off" name="xlInput">
<div id="filters">
<select id="books" name="normalSelect"></select>
<!--select id="chapters" name="normalSelect"></select-->
View
62 src/static/js/gov-watch.js
@@ -299,7 +299,7 @@
});
$("#items").html(html);
$(".item").each(function() {
- var i, implementation_status, len, pad, stops, timeline_item, timeline_items, today, _j, _results;
+ var implementation_status, max_numeric_date, min_numeric_date, pad, timeline_items, today;
implementation_status = $(this).attr('implementation-status');
if (implementation_status === 'STUCK' || implementation_status === 'WORKAROUND') {
$(this).find('.buxa-header').addClass('bad');
@@ -323,27 +323,33 @@
order: 'asc'
});
timeline_items = $(this).find(".timeline .timeline-point");
- len = timeline_items.length;
- if (len === 1) {
- stops = 1;
- } else {
- stops = 75 / (len - 1);
- }
- _results = [];
- for (i = _j = 0; 0 <= len ? _j <= len : _j >= len; i = 0 <= len ? ++_j : --_j) {
- timeline_item = $(timeline_items[i]);
- timeline_item.css("top", (10 + i * stops) + "%");
- timeline_item.tooltip({
- delay: {
- show: 0,
- hide: 1000
- },
- placement: 'bottom',
- title: timeline_item.html()
- });
- _results.push(timeline_item.html(''));
- }
- return _results;
+ max_numeric_date = 0;
+ min_numeric_date = 2100 * 372;
+ timeline_items.each(function() {
+ var d, date, day, month, numeric_date, year, _ref;
+ date = $(this).attr('data-duedate');
+ date = date.split('/');
+ _ref = (function() {
+ var _j, _len2, _results;
+ _results = [];
+ for (_j = 0, _len2 = date.length; _j < _len2; _j++) {
+ d = date[_j];
+ _results.push(parseInt(d));
+ }
+ return _results;
+ })(), year = _ref[0], month = _ref[1], day = _ref[2];
+ numeric_date = (year * 372) + ((month - 1) * 31) + (day - 1);
+ if (numeric_date === NaN) numeric_date = 2012 * 372;
+ if (numeric_date > max_numeric_date) max_numeric_date = numeric_date + 1;
+ if (numeric_date < min_numeric_date) min_numeric_date = numeric_date;
+ return $(this).attr('data-duedate-numeric', numeric_date);
+ });
+ return timeline_items.each(function() {
+ var date, percent;
+ date = parseInt($(this).attr('data-duedate-numeric'));
+ percent = (date - min_numeric_date) / (max_numeric_date - min_numeric_date) * 75.0 + 10;
+ return $(this).css("top", percent + "%");
+ });
});
(function(__iced_k) {
__iced_deferrals = new iced.Deferrals(__iced_k, {
@@ -357,7 +363,7 @@
return __iced_deferrals.ret = arguments[0];
};
})(),
- lineno: 272
+ lineno: 283
})), 50);
__iced_deferrals._fulfill();
})(function() {
@@ -451,7 +457,7 @@
return __iced_deferrals.ret = arguments[0];
};
})(),
- lineno: 344
+ lineno: 355
})));
} else {
__iced_deferrals.defer({
@@ -460,7 +466,7 @@
return __iced_deferrals.ret = arguments[0];
};
})(),
- lineno: 347
+ lineno: 358
});
}
__iced_deferrals._fulfill();
@@ -477,7 +483,7 @@
return __iced_deferrals.ret = arguments[0];
};
})(),
- lineno: 347
+ lineno: 358
})), 1000);
__iced_deferrals._fulfill();
})(function() {
@@ -495,7 +501,7 @@
return __iced_deferrals.ret = arguments[0];
};
})(),
- lineno: 350
+ lineno: 361
})), 1000);
__iced_deferrals._fulfill();
})(function() {
@@ -556,7 +562,7 @@
return __iced_deferrals.ret = arguments[0];
};
})(),
- lineno: 389
+ lineno: 400
})), 1000);
__iced_deferrals._fulfill();
})(function() {

0 comments on commit d4fc9a8

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