diff options
Diffstat (limited to 'js/prolog.js')
-rw-r--r-- | js/prolog.js | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/js/prolog.js b/js/prolog.js index d9bcdca..1d30f7c 100644 --- a/js/prolog.js +++ b/js/prolog.js @@ -184,20 +184,24 @@ hintCounter++; return result; }, + processTemplate = function (template, args) { + if (!args) + return template; + return template.replace(/\[%=(\w+)%\]/g, function(match, name) { + return args[name]; + }); + }, hintHandlers = { 'static': function (type, template, serverHint) { codeq.log.debug('Processing static hint'); - if (serverHint.args) { - template = template.replace(/\[%=(\w+)%\]/g, function(match, name) { - return serverHint.args[name]; - }); - } - jqHints.append('<div class="hint-static">' + template + '</div>'); // TODO: incorporate any serverHint.args + var message = processTemplate(template, serverHint.args); + jqHints.append('<div class="hint-static">' + message + '</div>'); // no hint cleaner here, a static hint remains on the screen }, 'popup': function (type, template, serverHint) { codeq.log.debug('Processing popup hint'); - var mark = addMark(serverHint.start, serverHint.end), // add the mark + var message = processTemplate(template, serverHint.args), + mark = addMark(serverHint.start, serverHint.end), // add the mark jqMark = jqEditor.find('.' + mark.className); /* jqPopup = null, onBlur = function () { @@ -236,7 +240,7 @@ mark = null; });*/ - jqMark.popover({content: template, html: true, placement: 'auto bottom', trigger: 'hover focus click', container: 'body'}); + jqMark.popover({content: message, html: true, placement: 'auto bottom', trigger: 'hover focus click', container: 'body'}); hintCleaners.push(function () { if (jqMark) { jqMark.popover('destroy'); jqMark = null; } }); mark.mark.on('', function () {}); |