1

Cleanup of client code

This commit is contained in:
Alex Yatskov 2015-03-25 20:25:27 +09:00
parent 2d378e83c9
commit c920a5ac70
3 changed files with 12 additions and 14 deletions

View File

@ -92,7 +92,7 @@
</div>
<div class="panel-body">
<script id="template" type="text/x-handlers-template">
{{#if results}}
{{#if records}}
<table class="table table-striped table-condensed">
<thead>
<tr>
@ -104,7 +104,7 @@
<th>Score</th>
</tr>
</thead>
{{#each results}}
{{#each records}}
<tr>
<td><a href="javascript:accessReview({{id}});">{{name}}</a></td>
<td>{{distanceToUser}} km</td>
@ -117,7 +117,7 @@
</table>
{{/if}}
</script>
<div id="results"></div>
<div id="records"></div>
</div>
</div>

View File

@ -307,7 +307,7 @@
var _canvas = params.canvas;
var _columns = {};
var _data = {};
var _range = new Range(params.range.min || -1.0, params.range.max || 1.0);
var _range = new Range(-1.0, 1.0);
var _steps = params.steps || 20;
var _useLocalScale = params.useLocalScale || false;
var _displayType = params.displayType || 'density';
@ -320,7 +320,7 @@
for (var name in columns) {
var column = columns[name];
for (var i = 0, count = column.hints.length; i < count; ++i) {
column.hints[i].rating = column.hints[i].stats[statKey];
column.hints[i].rating = column.hints[i][statKey];
}
}
}

View File

@ -63,7 +63,6 @@
function onSearch() {
_ctx.query = {
features: _ctx.query.features || {},
range: {min: -1.0, max: 1.0},
profile: getProfile(),
walkingDist: parseFloat($('#walkingDist').val()),
minScore: parseFloat($('#minScore').val()),
@ -83,7 +82,6 @@
_ctx.grapher = new grapher.Grapher({
canvas: new Snap('#svg'),
steps: _ctx.query.hintSteps,
range: _ctx.query.range,
onValueChanged: onAdjust,
displayType: $('#displayType').val(),
useLocalScale: $('#useLocalScale').is(':checked')
@ -132,21 +130,21 @@
}
_ctx.grapher.setColumns(columns);
outputMatches(results.items, results.count);
outputMatches(results.records, results.count);
}
function outputMatches(results, count) {
var searchResultCnt = String(results.length);
if (results.length < count) {
function outputMatches(records, count) {
var searchResultCnt = String(records.length);
if (records.length < count) {
searchResultCnt += ' of ' + count;
}
$('#resultCount').text(searchResultCnt);
var template = Handlebars.compile($('#template').html());
$('#results').empty();
$('#results').append(template({results: results}));
$('#records').empty();
$('#records').append(template({records: records}));
if (results.length === 0) {
if (records.length === 0) {
$('#resultPanel').slideUp();
}
else {