summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--js/prolog.js20
-rw-r--r--js/python.js20
2 files changed, 24 insertions, 16 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 () {});
diff --git a/js/python.js b/js/python.js
index df23773..dd346c4 100644
--- a/js/python.js
+++ b/js/python.js
@@ -136,20 +136,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 () {
@@ -188,7 +192,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 () {});