Skip to content

Commit

Permalink
Minior: Add "help-button" to search result as well
Browse files Browse the repository at this point in the history
  • Loading branch information
haakonnessjoen committed Jan 12, 2019
1 parent 86680c5 commit 63ddc6c
Showing 1 changed file with 37 additions and 15 deletions.
52 changes: 37 additions & 15 deletions public/instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,22 @@ $(function() {
socket.emit('instance_get');
socket.emit('instance_status_get');

function show_module_help(name) {
socket.emit('instance_get_help', name);
socket.once('instance_get_help:result', function (err, result) {
if (err) {
alert('Error getting help text');
return;
}
if (result) {
var $helpModal = $('#helpModal');
$helpModal.find('.modal-title').html('Help for ' + name);
$helpModal.find('.modal-body').html(result);
$helpModal.modal();
}
});
}

function updateInstanceStatus() {
for (var x in instance_status) {
var s = instance_status[x];
Expand Down Expand Up @@ -154,19 +170,7 @@ $(function() {

(function (name) {
$tr.find('.instance_help').click(function () {
socket.emit('instance_get_help', name);
socket.once('instance_get_help:result', function (err, result) {
if (err) {
alert('Error getting help text');
return;
}
if (result) {
var $helpModal = $('#helpModal');
$helpModal.find('.modal-title').html('Help for ' + name);
$helpModal.find('.modal-body').html(result);
$helpModal.modal();
}
});
show_module_help(name);
});
})(list[n].instance_type);

Expand Down Expand Up @@ -202,9 +206,27 @@ $(function() {
var $button = $('<a role="button" class="btn btn-primary text-white">Add</a>');
$x.prepend($button);
$x.data('id', x);
$x.click(function(e) {

var $help = $('<div class="instance_help"><i class="fa fa-question-circle"></i></div>')

for (var y in instance.module) {
if (instance.module[y].name == x) {
if (instance.module[y].help) {
$x.append($help);
}
}
}
$help.click(function (e) {
e.stopPropagation();
e.preventDefault();
var id = $(this).parents('div').first().data('id');

show_module_help(id);
});

$button.click(function(e) {
e.preventDefault();
var instance_type = $(this).data('id');
var instance_type = $(this).parents('div').first().data('id');
socket.emit('instance_add', instance_type );
$aisr.html("");
$aisf.val("");
Expand Down

0 comments on commit 63ddc6c

Please sign in to comment.