summaryrefslogtreecommitdiff
path: root/js/codeq
diff options
context:
space:
mode:
Diffstat (limited to 'js/codeq')
-rw-r--r--js/codeq/hint.js45
1 files changed, 18 insertions, 27 deletions
diff --git a/js/codeq/hint.js b/js/codeq/hint.js
index c22f39f..6b8d12f 100644
--- a/js/codeq/hint.js
+++ b/js/codeq/hint.js
@@ -41,10 +41,11 @@
typeHandlers = {
'static': function (type, template, serverHint) {
- var jqContainer, jqButton, promise, i, lastIndex;
+ var args = serverHint.args,
+ jqContainer, jqButton, i, lastIndex;
if (template instanceof Array) { // unwrap the template if there's only one
if (template.length == 0) template = '';
- else if (template.length == 1) template = template[0] + '';
+ else if (template.length == 1) template = template[0] + ''; // it must be a string
}
if (template instanceof Array) {
codeq.log.debug('Processing an array of static hints');
@@ -52,34 +53,24 @@
jqButton = $('<button type="button">More...</button>'); // TODO: translate "more"
jqHints.append(jqContainer);
lastIndex = template.length - 1;
- promise = Q();
- for (i = 0; i <= lastIndex; i++) {
- promise = promise.then((function (tmpl, index) {
- return Q.Promise(function (resolve, reject) {
- var message = processTemplate(tmpl, serverHint.args),
- onClick;
- jqContainer.append('<div class="hint-static">' + message + '</div>');
- if (index < lastIndex) {
- onClick = function () {
- jqButton.off('click', onClick);
- jqButton.remove();
- resolve();
- };
- jqContainer.append(jqButton);
- jqButton.on('click', onClick);
- }
- else {
- resolve();
- }
- });
- })(template[i], i));
- }
- promise.done();
+ jqContainer.append('<div class="hint-static">' + processTemplate(template[0], args) + '</div>');
+ jqContainer.append(jqButton);
+ i = 1;
+ jqButton.on('click', function () {
+ var jqNext = $('<div class="hint-static">' + processTemplate(template[i], args) + '</div>');
+ i++;
+ if (i < lastIndex) {
+ jqButton.before(jqNext);
+ }
+ else {
+ jqButton.remove();
+ jqContainer.append(jqNext);
+ }
+ });
}
else {
codeq.log.debug('Processing a single static hint');
- var message = processTemplate(template, serverHint.args);
- jqHints.append('<div class="hint-static">' + message + '</div>');
+ jqHints.append('<div class="hint-static">' + processTemplate(template, args) + '</div>');
}
// no hint cleaner here, a static hint remains on the screen
},