1

Work on server

This commit is contained in:
Alex Yatskov 2014-07-28 11:52:30 +09:00
parent 42aee030e1
commit ba8685b2a8
3 changed files with 76 additions and 69 deletions

View File

@ -147,77 +147,82 @@ function onAdjust(name, value) {
outputResults(results, wa.maxResults);
}
function onQuery() {
var query = $('#query').val();
var minScore = parseInt($('#minScore').val()) || 1.0;
var hintSteps = parseInt($('#hintSteps').val()) || 20;
var maxResults = parseInt($('#maxResults').val()) || 100;
var useLocalScale = true;
var useRelativeScale = true;
console.assert(query in DATA_KEYWORDS);
var queryParams = DATA_KEYWORDS[query];
var searchRange = new goog.math.Range(-1.0, 1.0);
var graphColumns = {};
for (var feature in queryParams) {
var hints = searchBuildHints(
queryParams,
minScore,
feature,
searchRange,
hintSteps
);
graphColumns[feature] = {
'color': '#607080',
'value': queryParams[feature],
'hints': hints,
'steps': hintSteps
}
}
window.adjuster = {
queryParams: queryParams,
searchRange: searchRange,
hintSteps: hintSteps,
minScore: minScore,
maxResults: maxResults
function onSearch() {
var params = {
'keyword': $('#keyword').val(),
'minScore': parseInt($('#minScore').val()),
'hintSteps': parseInt($('#hintSteps').val()),
'maxResults': parseInt($('#maxResults').val()),
'useLocalScale': true,
'useRelativeScale': true
};
window.grapher = new Grapher('grapher', searchRange, useLocalScale, useRelativeScale);
window.grapher.setColumns(graphColumns);
window.grapher.setValueChangedListener(onAdjust);
$.getJSON('/node/search', params, function(results) {
alert('searched');
});
var results = searchData(queryParams, minScore);
outputResults(results, maxResults);
// var queryParams = DATA_KEYWORDS[query];
// var searchRange = new goog.math.Range(-1.0, 1.0);
// var graphColumns = {};
$('#keyword').text(query);
$('#useLocalScale').prop('checked', useLocalScale);
$('#useRelativeScale').prop('checked', useRelativeScale);
$('#useLocalScale').click(function() {
var useLocalScale = $('#useLocalScale').is(':checked');
window.grapher.setUseLocalScale(useLocalScale);
});
$('#useRelativeScale').click(function() {
var useRelativeScale = $('#useRelativeScale').is(':checked');
window.grapher.setUseRelativeScale(useRelativeScale);
});
$('#input').fadeOut(function() {
$('#output').fadeIn();
});
// for (var feature in queryParams) {
// var hints = searchBuildHints(
// queryParams,
// minScore,
// feature,
// searchRange,
// hintSteps
// );
// graphColumns[feature] = {
// 'color': '#607080',
// 'value': queryParams[feature],
// 'hints': hints,
// 'steps': hintSteps
// }
// }
// window.adjuster = {
// queryParams: queryParams,
// searchRange: searchRange,
// hintSteps: hintSteps,
// minScore: minScore,
// maxResults: maxResults
// };
// window.grapher = new Grapher('grapher', searchRange, useLocalScale, useRelativeScale);
// window.grapher.setColumns(graphColumns);
// window.grapher.setValueChangedListener(onAdjust);
// var results = searchData(queryParams, minScore);
// outputResults(results, maxResults);
// $('#query').text(query);
// $('#useLocalScale').prop('checked', useLocalScale);
// $('#useRelativeScale').prop('checked', useRelativeScale);
// $('#useLocalScale').click(function() {
// var useLocalScale = $('#useLocalScale').is(':checked');
// window.grapher.setUseLocalScale(useLocalScale);
// });
// $('#useRelativeScale').click(function() {
// var useRelativeScale = $('#useRelativeScale').is(':checked');
// window.grapher.setUseRelativeScale(useRelativeScale);
// });
// $('#input').fadeOut(function() {
// $('#output').fadeIn();
// });
}
$(document).ready(function() {
$.getJSON('/node/hscd/keywords', function(keywords) {
$.getJSON('/node/keywords', function(keywords) {
for (var i = 0; i < keywords.length; ++i) {
$('#query').append($('<option></option>', {
$('#keyword').append($('<option></option>', {
'value': keywords[i],
'text': keywords[i]
}));
}
$('#search').prop('disabled', false);
$('#search').click(onSearch);
});
});

View File

@ -15,9 +15,9 @@
<div id="input">
<form class="form-horizontal">
<div class="form-group">
<label for="query" class="col-md-2 control-label">Keyword</label>
<label for="keyword" class="col-md-2 control-label">Keyword</label>
<div class="col-md-10">
<select id="query" class="form-control" name="query"></select>
<select id="keyword" class="form-control" name="keyword"></select>
</div>
</div>
<div class="form-group">
@ -51,7 +51,7 @@
<div id="output" style="display: none;">
<form>
<div class="panel panel-default">
<div class="panel-heading"><big>Semantic tweaks to <span id="keyword" class="text-primary"></span></big></div>
<div class="panel-heading"><big>Semantic tweaks to <span id="query" class="text-primary"></span></big></div>
<div class="row" style="padding: 10px;">
<canvas id="grapher" width="500" height="550"></canvas><br>
<label class="checkbox-inline">

View File

@ -7,14 +7,16 @@ var _ = require('underscore');
function main() {
var app = express();
var router = express.Router();
router.use('/keywords', function(req, res, next) {
app.use('/keywords', function(req, res) {
console.log('Requesting keywords');
res.json(_.keys(keywords));
});
app.use('/hscd', router);
app.use('/search', function(req, res) {
console.log(req.query);
});
app.listen(3000);
}