1
This commit is contained in:
Alex Yatskov 2014-07-28 16:48:24 +09:00
parent 696049aa76
commit 195a6a4043
5 changed files with 7 additions and 6 deletions

View File

@ -2,6 +2,7 @@
var app = { }; var app = { };
function outputResults(results, maxResults) { function outputResults(results, maxResults) {
$('#results').empty(); $('#results').empty();
$('#count').text(results.length); $('#count').text(results.length);
@ -51,14 +52,13 @@ function onSearch() {
app.hintSteps = params.hintSteps; app.hintSteps = params.hintSteps;
app.maxResults = params.maxResults; app.maxResults = params.maxResults;
app.grapher = new Grapher('grapher', new goog.math.Range(-1.0, 1.0), true, true); app.grapher = new Grapher('grapher', app.searchRange, true, true);
app.grapher.setColumns(results.columns); app.grapher.setColumns(results.columns);
app.grapher.setValueChangedListener(onAdjust); app.grapher.setValueChangedListener(onAdjust);
outputResults(results.items, params.maxResults); outputResults(results.items, params.maxResults);
$('#query').text(params.keyword); $('#query').text(params.keyword);
$('#useLocalScale').click(function() { $('#useLocalScale').click(function() {
var useLocalScale = $('#useLocalScale').is(':checked'); var useLocalScale = $('#useLocalScale').is(':checked');
app.grapher.setUseLocalScale(useLocalScale); app.grapher.setUseLocalScale(useLocalScale);
@ -67,7 +67,6 @@ function onSearch() {
var useRelativeScale = $('#useRelativeScale').is(':checked'); var useRelativeScale = $('#useRelativeScale').is(':checked');
app.grapher.setUseRelativeScale(useRelativeScale); app.grapher.setUseRelativeScale(useRelativeScale);
}); });
$('#input').fadeOut(function() { $('#input').fadeOut(function() {
$('#output').fadeIn(); $('#output').fadeIn();
}); });

View File

@ -543,7 +543,7 @@ function Grapher(canvas, range, useLocalScale, useRelativeScale) {
this.useLocalScale = useLocalScale; this.useLocalScale = useLocalScale;
this.useRelativeScale = useRelativeScale; this.useRelativeScale = useRelativeScale;
this.canvas = new fabric.StaticCanvas(canvas); this.canvas = new fabric.StaticCanvas(canvas);
this.range = range; this.range = new goog.math.Range(range.min, range.max);
this.padding = 10; this.padding = 10;
this.indexMap = {}; this.indexMap = {};
this.columns = []; this.columns = [];

View File

@ -55,10 +55,10 @@
<div class="row" style="padding: 10px;"> <div class="row" style="padding: 10px;">
<canvas id="grapher" width="500" height="550"></canvas><br> <canvas id="grapher" width="500" height="550"></canvas><br>
<label class="checkbox-inline"> <label class="checkbox-inline">
<input type="checkbox" id="useLocalScale" name="useLocalScale"> Use local scale <input type="checkbox" id="useLocalScale" name="useLocalScale" checked="checked"> Use local scale
</label> </label>
<label class="checkbox-inline"> <label class="checkbox-inline">
<input type="checkbox" id="useRelativeScale" name="useRelativeScale"> Use relative scale <input type="checkbox" id="useRelativeScale" name="useRelativeScale" checked="checked"> Use relative scale
</label> </label>
</div> </div>
</div> </div>

View File

@ -4,6 +4,7 @@ var _ = require('underscore');
var db_keywords = require('./keywords.json'); var db_keywords = require('./keywords.json');
var db_data = require('./data.json'); var db_data = require('./data.json');
function innerProduct(values1, values2) { function innerProduct(values1, values2) {
var result = 0; var result = 0;

View File

@ -5,6 +5,7 @@
var express = require('express'); var express = require('express');
var search = require('./db/search.js'); var search = require('./db/search.js');
function main() { function main() {
var app = express(); var app = express();