1

Misc cleanup

This commit is contained in:
Alex Yatskov 2014-09-20 18:11:13 +09:00
parent 720d80ae64
commit 931877a4d2
2 changed files with 34 additions and 23 deletions

View File

@ -95,12 +95,21 @@
function onForget() { function onForget() {
$('#forgetKeyword').prop('disabled', true); $('#forgetKeyword').prop('disabled', true);
var query = { $('#forgetError').slideUp(function() {
keyword: $('#keywordToForget').val() var query = {
}; keyword: $('#keywordToForget').val()
};
$.getJSON('/node/removeKeyword', query, function(results) { $.getJSON('/node/removeKeyword', query, function(results) {
$('#forgetDialog').modal('hide'); if (results.success) {
$('#forgetDialog').modal('hide');
}
else {
$('#forgetError').slideDown(function() {
$('#forgetKeyword').prop('disabled', false);
});
}
});
}); });
} }
@ -127,7 +136,6 @@
ready: function() { ready: function() {
$('#keywordsToSearch').selectpicker(); $('#keywordsToSearch').selectpicker();
$('#keywordToForget').selectpicker();
$.getJSON('/node/getKeywords', function(keywords) { $.getJSON('/node/getKeywords', function(keywords) {
$('#searchKeywords').click(onSearch); $('#searchKeywords').click(onSearch);
@ -145,15 +153,13 @@
$('#forgetKeyword').click(onForget); $('#forgetKeyword').click(onForget);
$('#forgetDialog').on('show.bs.modal', function() { $('#forgetDialog').on('show.bs.modal', function() {
$.getJSON('/node/getKeywords', function(keywords) { $.getJSON('/node/getKeywords', function(keywords) {
$('#keywordToForget').empty(); $('#forgetKeyword').prop('disabled', keywords.length === 0);
for (var i = 0, count = keywords.length; i < count; ++i) { for (var i = 0, count = keywords.length; i < count; ++i) {
$('#keywordToForget').append($('<option></option>', { $('#keywordToForget').append($('<option></option>', {
value: keywords[i], value: keywords[i],
text: keywords[i] text: keywords[i]
})); }));
} }
$('#keywordToForget').selectpicker('refresh');
$('#forgetKeyword').prop('disabled', keywords.length === 0);
}); });
}); });

View File

@ -10,34 +10,35 @@
</head> </head>
<body> <body>
<div class="container"> <div class="container">
<!-- busy spinner -->
<div class="page-header"> <div class="page-header">
<h1><img id="spinner" class="pull-right" src="images/spinner.gif" style="display: none;" width="32" height="32">Reactive Search</h1> <h1><img id="spinner" class="pull-right" src="images/spinner.gif" style="display: none;" width="32" height="32">Reactive Search</h1>
</div> </div>
<!-- Query Selector --> <!-- query input -->
<div id="input" class="form-horizontal"> <div id="input" class="form-horizontal">
<div class="form-group"> <div class="form-group">
<label for="keywordsToSearch" class="col-md-2 control-label">Keywords</label> <label for="keywordsToSearch" class="col-md-2 control-label">Keywords</label>
<div class="col-md-10"> <div class="col-md-10">
<select id="keywordsToSearch" class="form-control" multiple="multiple" data-max-options="4" data-live-search="data-live-search" name="keywordsToSearch"></select> <select id="keywordsToSearch" class="form-control" multiple="multiple" data-max-options="4" data-live-search="data-live-search"></select>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="minScore" class="col-md-2 control-label">Minimum score</label> <label for="minScore" class="col-md-2 control-label">Minimum score</label>
<div class="col-md-10"> <div class="col-md-10">
<input class="form-control" type="number" step="any" value="0.25" id="minScore" name="minScore"> <input class="form-control" type="number" step="any" value="0.25" id="minScore">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="hintSteps" class="col-md-2 control-label">Hint steps</label> <label for="hintSteps" class="col-md-2 control-label">Hint steps</label>
<div class="col-md-10"> <div class="col-md-10">
<input class="form-control" type="number" value="20" id="hintSteps" name="hintSteps"> <input class="form-control" type="number" value="20" id="hintSteps">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="maxResults" class="col-md-2 control-label">Max results</label> <label for="maxResults" class="col-md-2 control-label">Max results</label>
<div class="col-md-10"> <div class="col-md-10">
<input class="form-control" type="number" value="100" id="maxResults" name="maxResults"> <input class="form-control" type="number" value="100" id="maxResults">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -49,17 +50,17 @@
</div> </div>
</div> </div>
<!-- Options Dialog --> <!-- options dialog -->
<div class="modal fade" id="optionsDialog" tabindex="-1"> <div class="modal fade" id="optionsDialog" tabindex="-1">
<div class="modal-dialog modal-sm"> <div class="modal-dialog modal-sm">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"><big>Visualization Options</big></div> <div class="modal-header"><big>Visualization Options</big></div>
<div class="modal-body"> <div class="modal-body">
<div class="checkbox"> <div class="checkbox">
<label><input type="checkbox" id="useLocalScale" name="useLocalScale" checked="checked">Use local scale</label> <label><input type="checkbox" id="useLocalScale" checked="checked">Use local scale</label>
</div> </div>
<div class="checkbox"> <div class="checkbox">
<label><input type="checkbox" id="useRelativeScale" name="useRelativeScale" checked="checked">Use relative scale</label> <label><input type="checkbox" id="useRelativeScale" checked="checked">Use relative scale</label>
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
@ -69,7 +70,7 @@
</div> </div>
</div> </div>
<!-- Learn Dialog --> <!-- learn keyword dialog -->
<div class="modal fade" id="learnDialog" tabindex="-1"> <div class="modal fade" id="learnDialog" tabindex="-1">
<div class="modal-dialog modal-sm"> <div class="modal-dialog modal-sm">
<div class="modal-content"> <div class="modal-content">
@ -77,9 +78,9 @@
<div class="modal-body"> <div class="modal-body">
<div class="form-group"> <div class="form-group">
<label for="keyword" class="control-label">Learn keyword as</label> <label for="keyword" class="control-label">Learn keyword as</label>
<input class="form-control" type="text" id="keywordToLearn" name="keyword"> <input class="form-control" type="text" id="keywordToLearn">
</div> </div>
<div class="alert alert-danger" id="learnError" style="display: none;">Error writing keyword to database</div> <div class="alert alert-danger" id="learnError" style="display: none;">Unable to learn keyword</div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<div class="btn-group"> <div class="btn-group">
@ -91,7 +92,7 @@
</div> </div>
</div> </div>
<!-- Forget Dialog --> <!-- forget keyword dialog -->
<div class="modal fade" id="forgetDialog" tabindex="-1"> <div class="modal fade" id="forgetDialog" tabindex="-1">
<div class="modal-dialog modal-sm"> <div class="modal-dialog modal-sm">
<div class="modal-content"> <div class="modal-content">
@ -99,8 +100,9 @@
<div class="modal-body"> <div class="modal-body">
<div class="form-group"> <div class="form-group">
<label for="keywordToForget">Keyword to forget</label> <label for="keywordToForget">Keyword to forget</label>
<select id="keywordToForget" class="form-control" data-live-search="data-live-search" name="keywordToForget"></select> <select id="keywordToForget" class="form-control"></select>
</div> </div>
<div class="alert alert-danger" id="forgetError" style="display: none;">Unable to forget keyword</div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<div class="btn-group"> <div class="btn-group">
@ -112,8 +114,9 @@
</div> </div>
</div> </div>
<!-- Semantic Tweaker --> <!-- query output -->
<div id="output" style="display: none;"> <div id="output" style="display: none;">
<!-- semantic tweaker -->
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<big>Semantic tweaks to <span id="query" class="text-primary"></span></big> <big>Semantic tweaks to <span id="query" class="text-primary"></span></big>
@ -127,6 +130,8 @@
<canvas id="grapher" width="800" height="550"></canvas> <canvas id="grapher" width="800" height="550"></canvas>
</div> </div>
</div> </div>
<!-- result listing -->
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"><big>Query results (<span id="count" class="text-primary"></span>)</big></div> <div class="panel-heading"><big>Query results (<span id="count" class="text-primary"></span>)</big></div>
<div style="padding: 10px;"> <div style="padding: 10px;">