History slider now more or less working
This commit is contained in:
parent
3cfe23f795
commit
0ae92d1957
@ -126,8 +126,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div style="padding: 10px;">
|
<div style="padding: 10px;">
|
||||||
<canvas id="grapher" width="800" height="550"></canvas>
|
<canvas id="grapher" width="800" height="550"></canvas>
|
||||||
<div class="text-center">
|
<div class="text-center" style="display: none;">
|
||||||
<input id="history" style="width: 90%" type="text" data-slider-max="0">
|
<input id="history" style="width: 90%;" type="text" data-slider-reversed="true" data-slider-max="0">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -94,7 +94,6 @@
|
|||||||
|
|
||||||
function onLearn() {
|
function onLearn() {
|
||||||
$('#learnKeyword').prop('disabled', true);
|
$('#learnKeyword').prop('disabled', true);
|
||||||
|
|
||||||
$('#learnError').slideUp(function() {
|
$('#learnError').slideUp(function() {
|
||||||
var query = {
|
var query = {
|
||||||
keyword: $('#keywordToLearn').val(),
|
keyword: $('#keywordToLearn').val(),
|
||||||
@ -116,7 +115,6 @@
|
|||||||
|
|
||||||
function onForget() {
|
function onForget() {
|
||||||
$('#forgetKeyword').prop('disabled', true);
|
$('#forgetKeyword').prop('disabled', true);
|
||||||
|
|
||||||
$('#forgetError').slideUp(function() {
|
$('#forgetError').slideUp(function() {
|
||||||
var query = {
|
var query = {
|
||||||
keyword: $('#keywordToForget').val()
|
keyword: $('#keywordToForget').val()
|
||||||
@ -136,25 +134,25 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onSelectSnapshot() {
|
function onSelectSnapshot() {
|
||||||
var snapshot = $('#history').slider('getValue');
|
var index = $('#history').slider('getValue');
|
||||||
outputSnapshot(log[snapshot]);
|
outputSnapshot(log[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveSnapshot(results) {
|
function saveSnapshot(results) {
|
||||||
log.push(results);
|
log.push(results);
|
||||||
|
|
||||||
|
var count = log.length;
|
||||||
var history = $('#history').slider();
|
var history = $('#history').slider();
|
||||||
history.slider('setAttribute', 'max', log.length - 1);
|
history.slider('setAttribute', 'max', count - 1);
|
||||||
history.slider('setValue', log.length - 1);
|
history.slider('setValue', count - 1);
|
||||||
|
|
||||||
|
if (count > 1) {
|
||||||
|
$('#history').parent().slideDown();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function outputSnapshot(results) {
|
function outputSnapshot(results) {
|
||||||
var hintData = {};
|
ctx.grapher.updateColumns(results.columns);
|
||||||
for (var keyword in results.columns) {
|
|
||||||
hintData[keyword] = results.columns[keyword].hints;
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.grapher.setColumnHints(hintData);
|
|
||||||
outputMatches(results.items, results.count);
|
outputMatches(results.items, results.count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,8 +277,10 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setHints = function(hints, scale) {
|
this.updateParams = function(params, scale) {
|
||||||
this.hints = hints;
|
this.hints = params.hints;
|
||||||
|
this.value = params.value;
|
||||||
|
this.steps = params.steps;
|
||||||
this.scale = scale;
|
this.scale = scale;
|
||||||
this.updateShapes(true);
|
this.updateShapes(true);
|
||||||
};
|
};
|
||||||
@ -527,22 +529,23 @@
|
|||||||
this.indexMap = {};
|
this.indexMap = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setColumnHints = function(hintData) {
|
this.updateColumns = function(data) {
|
||||||
var scale = 0;
|
var scale = 0;
|
||||||
if (!this.useLocalScale) {
|
if (!this.useLocalScale) {
|
||||||
scale = this.getGlobalScale(hintData);
|
scale = this.getGlobalScale(hintData);
|
||||||
}
|
}
|
||||||
|
|
||||||
var that = this;
|
var that = this;
|
||||||
_.each(hintData, function(hints, name) {
|
_.each(data, function(entry, name) {
|
||||||
var index = that.getColumnIndex(name);
|
var index = that.getColumnIndex(name);
|
||||||
console.assert(index >= 0);
|
console.assert(index >= 0);
|
||||||
|
|
||||||
if (that.useLocalScale) {
|
if (that.useLocalScale) {
|
||||||
scale = that.getLocalScale(hints);
|
scale = that.getLocalScale(entry.hints);
|
||||||
}
|
}
|
||||||
|
|
||||||
that.columns[index].setHints(hints, scale);
|
var column = that.columns[index];
|
||||||
|
column.updateParams(entry, scale);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user