Some more work on history slider working
This commit is contained in:
parent
ba24ca0bf6
commit
3cfe23f795
@ -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-right">
|
<div class="text-center">
|
||||||
<input id="history" type="text" data-slider-max="20" data-slider-step="1">
|
<input id="history" style="width: 90%" type="text" data-slider-max="0">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var ctx = {};
|
var ctx = {};
|
||||||
|
var log = [];
|
||||||
|
|
||||||
function onAdjust(name, value) {
|
function onAdjust(name, value) {
|
||||||
ctx.searchParams[name] = value;
|
ctx.searchParams[name] = value;
|
||||||
@ -41,13 +42,8 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
$.getJSON('/search', query, function(results) {
|
$.getJSON('/search', query, function(results) {
|
||||||
var hintData = {};
|
saveSnapshot(results);
|
||||||
for (var keyword in results.columns) {
|
outputSnapshot(results);
|
||||||
hintData[keyword] = results.columns[keyword].hints;
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.grapher.setColumnHints(hintData);
|
|
||||||
outputResults(results.items, results.count);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,7 +74,8 @@
|
|||||||
ctx.grapher.setColumns(results.columns);
|
ctx.grapher.setColumns(results.columns);
|
||||||
ctx.grapher.setValueChangedListener(onAdjust);
|
ctx.grapher.setValueChangedListener(onAdjust);
|
||||||
|
|
||||||
outputResults(results.items, results.count);
|
saveSnapshot(results);
|
||||||
|
outputMatches(results.items, results.count);
|
||||||
|
|
||||||
$('#query').text(keywords.join(', '));
|
$('#query').text(keywords.join(', '));
|
||||||
$('#useLocalScale').click(function() {
|
$('#useLocalScale').click(function() {
|
||||||
@ -138,11 +135,30 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function onHistory(arg) {
|
function onSelectSnapshot() {
|
||||||
|
var snapshot = $('#history').slider('getValue');
|
||||||
|
outputSnapshot(log[snapshot]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function outputResults(results, count) {
|
function saveSnapshot(results) {
|
||||||
|
log.push(results);
|
||||||
|
|
||||||
|
var history = $('#history').slider();
|
||||||
|
history.slider('setAttribute', 'max', log.length - 1);
|
||||||
|
history.slider('setValue', log.length - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
function outputSnapshot(results) {
|
||||||
|
var hintData = {};
|
||||||
|
for (var keyword in results.columns) {
|
||||||
|
hintData[keyword] = results.columns[keyword].hints;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.grapher.setColumnHints(hintData);
|
||||||
|
outputMatches(results.items, results.count);
|
||||||
|
}
|
||||||
|
|
||||||
|
function outputMatches(results, count) {
|
||||||
var searchResultCnt = String(results.length);
|
var searchResultCnt = String(results.length);
|
||||||
if (results.length < count) {
|
if (results.length < count) {
|
||||||
searchResultCnt += ' of ' + count;
|
searchResultCnt += ' of ' + count;
|
||||||
@ -195,7 +211,7 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#history').on('slideStop', onHistory);
|
$('#history').on('slideStop', onSelectSnapshot);
|
||||||
$('#learnKeyword').click(onLearn);
|
$('#learnKeyword').click(onLearn);
|
||||||
$('#keywordToLearn').bind('input', function() {
|
$('#keywordToLearn').bind('input', function() {
|
||||||
$('#learnKeyword').prop('disabled', !$(this).val());
|
$('#learnKeyword').prop('disabled', !$(this).val());
|
||||||
|
Loading…
Reference in New Issue
Block a user