Renaming things
This commit is contained in:
parent
201c2e49ce
commit
cfaded9896
@ -59,6 +59,7 @@ func executeQuery(rw http.ResponseWriter, req *http.Request) {
|
||||
response := jsonQueryResponse{
|
||||
Count: len(foundEntries),
|
||||
Columns: make(map[string]jsonColumn),
|
||||
MinScore: request.MinScore,
|
||||
Records: make([]jsonRecord, 0)}
|
||||
|
||||
for name, value := range features {
|
||||
|
@ -99,7 +99,7 @@
|
||||
var _name = params.name;
|
||||
var _valueTrans = params.data.value;
|
||||
var _bracketTrans = params.data.bracket;
|
||||
var _onValueChanged = params.onValueChanged;
|
||||
var _onStateChanged = params.onStateChanged;
|
||||
var _range = params.range;
|
||||
var _scale = params.scale;
|
||||
var _elements = {};
|
||||
@ -324,13 +324,25 @@
|
||||
return colorStops;
|
||||
}
|
||||
|
||||
function updateValue(value, bracket) {
|
||||
_data.value = _range.clamp(value);
|
||||
function updateState(value, bracket) {
|
||||
var updateBracket = bracket !== null;
|
||||
var updateValue = value !== null;
|
||||
|
||||
if (updateBracket) {
|
||||
_data.bracket.max = _range.clamp(bracket.max);
|
||||
_data.bracket.min = _range.clamp(bracket.min);
|
||||
}
|
||||
|
||||
if (_onValueChanged) {
|
||||
_onValueChanged(_name, _data.value, _data.bracket);
|
||||
if (updateValue) {
|
||||
_data.value = _range.clamp(value);
|
||||
}
|
||||
|
||||
if (_onStateChanged) {
|
||||
_onStateChanged(
|
||||
_name,
|
||||
updateValue ? _data.value : null,
|
||||
updateBracket ? _data.bracket : null
|
||||
);
|
||||
}
|
||||
|
||||
animateIndicator(_valueTrans, _data.value);
|
||||
@ -431,7 +443,7 @@
|
||||
function indicatorClick(event, x, y) {
|
||||
var rect = _canvas.node.getBoundingClientRect();
|
||||
|
||||
updateValue(indicatorToValue(y - rect.top), _data.bracket);
|
||||
updateState(indicatorToValue(y - rect.top), null);
|
||||
}
|
||||
|
||||
function bracketClick(event, x, y) {
|
||||
@ -442,7 +454,7 @@
|
||||
dist = Math.min(dist, Math.abs(_range.max - mid));
|
||||
dist = Math.min(dist, Math.abs(_range.min - mid));
|
||||
|
||||
updateValue(_data.value, {max: mid + dist, min: mid - dist});
|
||||
updateState(_data.value, {max: mid + dist, min: mid - dist});
|
||||
}
|
||||
|
||||
this.update = function(data, scale) {
|
||||
@ -477,7 +489,7 @@
|
||||
var _range = new Range(-1.0, 1.0);
|
||||
var _useLocalScale = params.useLocalScale || false;
|
||||
var _displayType = params.displayType || 'density';
|
||||
var _onValueChanged = params.onValueChanged;
|
||||
var _onStateChanged = params.onStateChanged;
|
||||
|
||||
function processHintParameters(columns) {
|
||||
var displayTypes = {compatibility: 'compatibility', density: 'count'};
|
||||
@ -535,7 +547,7 @@
|
||||
}
|
||||
else {
|
||||
_columns[name] = new Column({
|
||||
onValueChanged: _onValueChanged,
|
||||
onStateChanged: _onStateChanged,
|
||||
range: _range,
|
||||
canvas: _canvas,
|
||||
data: columnData,
|
||||
|
@ -25,8 +25,9 @@
|
||||
|
||||
var _ctx = {};
|
||||
|
||||
function onAdjust(name, value, bracket) {
|
||||
function onStateChanged(name, value, bracket) {
|
||||
_ctx.query.features[name] = value;
|
||||
_ctx.query.bracket = bracket === null ? null : {name: name, bracket: bracket};
|
||||
|
||||
$.post('/query', JSON.stringify(_ctx.query), function(results) {
|
||||
saveSnapshot(results);
|
||||
@ -77,6 +78,7 @@
|
||||
function onSearch() {
|
||||
_ctx.query = {
|
||||
features: _ctx.query.features || {},
|
||||
bracket: null,
|
||||
sortKey: _ctx.sortKey,
|
||||
sortAsc: _ctx.sortAsc,
|
||||
profile: getProfile(),
|
||||
@ -97,7 +99,7 @@
|
||||
if (!_.has(_ctx, 'grapher')) {
|
||||
_ctx.grapher = new grapher.Grapher({
|
||||
canvas: new Snap('#svg'),
|
||||
onValueChanged: onAdjust,
|
||||
onStateChanged: onStateChanged,
|
||||
displayType: $('#displayType').val(),
|
||||
useLocalScale: $('#useLocalScale').is(':checked')
|
||||
});
|
||||
@ -138,6 +140,9 @@
|
||||
}
|
||||
|
||||
function outputSnapshot(results, omitValues) {
|
||||
_ctx.query.minScore = results.minScore;
|
||||
$('#minScore').val(results.minScore);
|
||||
|
||||
var columns = {};
|
||||
for (var name in results.columns) {
|
||||
var column = results.columns[name];
|
||||
|
7
types.go
7
types.go
@ -37,6 +37,7 @@ type jsonGeoData struct {
|
||||
}
|
||||
|
||||
type jsonQueryRequest struct {
|
||||
Bracket *jsonNamedBracket `json:"bracket"`
|
||||
Features featureMap `json:"features"`
|
||||
Geo *jsonGeoData `json:"geo"`
|
||||
MaxResults int `json:"maxResults"`
|
||||
@ -78,9 +79,15 @@ type jsonBracket struct {
|
||||
Max float64 `json:"max"`
|
||||
}
|
||||
|
||||
type jsonNamedBracket struct {
|
||||
Bracket string `json:"bracket"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type jsonQueryResponse struct {
|
||||
Columns map[string]jsonColumn `json:"columns"`
|
||||
Count int `json:"count"`
|
||||
MinScore float64 `json:"minScore"`
|
||||
Records []jsonRecord `json:"records"`
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user