summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@araneo.org>2015-09-08 10:44:52 +0200
committerTimotej Lazar <timotej.lazar@araneo.org>2015-09-08 10:44:52 +0200
commit34d740e4d9435a954be5b683d73da6a544d7669b (patch)
tree610c3e7f6e855546a8f9b7cde16f8d3279416d4a /js
parent3752341cf43043fe89742baff35ad74df9fe0f4d (diff)
Process templates in popover hints
Diffstat (limited to 'js')
-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 () {});