Skip to content
This repository was archived by the owner on Dec 12, 2021. It is now read-only.

Commit 9f044ec

Browse files
committed
FIX: search prompt improvement & smaller bug fix
1 parent 70bba68 commit 9f044ec

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

lib/snippet-injector.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,13 @@ export default {
6565
var filenames = storage.retrieveFiles();
6666
if(filenames.length > 0) {
6767
var snippets = new Array();
68-
filenames.forEach(function(currentValue) {
69-
snippets.push(new Snippet(JSON.parse(storage.retrieveFile(currentValue.replace('.snippet.json','')))));
70-
});
7168
var listitems = new Array();
7269
var icons = new Array();
73-
snippets.forEach(function(currentValue) {
74-
listitems.push(currentValue.getTitle());
75-
icons.push(IconHelper.getIconTag(currentValue.getLang()));
70+
filenames.forEach(function(currentValue) {
71+
var elem = new Snippet(JSON.parse(storage.retrieveFile(currentValue.replace('.snippet.json',''))));
72+
snippets.push(elem);
73+
listitems.push(elem.getTitle());
74+
icons.push(elem.getLang());
7675
});
7776

7877
const searchPrompt = Util.promptSearch({

lib/util.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export default class Util {
107107
listDOMstring += '<li class="list-item">';
108108
if(options.icons.length > 0) {
109109
if(options.icons[index]!==undefined&&options.icons[index]!==null&&typeof options.icons[index] === 'string') {
110-
listDOMstring += options.icons[index];
110+
listDOMstring += IconHelper.getIconTag(options.icons[index]);
111111
} else {
112112
listDOMstring += IconHelper.getIconTag('default');
113113
}
@@ -136,13 +136,21 @@ export default class Util {
136136
});
137137
var listDOMstring = '';
138138
if(filteredItems.length > 0) {
139-
filteredItems.forEach(function(currentValue) {
140-
listDOMstring += '<li class="list-item"><p class="value">';
139+
filteredItems.forEach(function(currentValue,index) {
140+
listDOMstring += '<li class="list-item">';
141+
if(options.icons.length > 0) {
142+
if(options.icons[index]!==undefined&&options.icons[index]!==null&&typeof options.icons[index] === 'string') {
143+
listDOMstring += IconHelper.getIconTag(options.icons[index]);
144+
} else {
145+
listDOMstring += IconHelper.getIconTag('default');
146+
}
147+
}
148+
listDOMstring += '<p class="value">';
141149
listDOMstring += currentValue;
142150
listDOMstring += '</p></li>';
143151
});
144152
} else {
145-
listDOMstring += '<p class="notice"><i>'+options.nothingfound+'</i></p>';
153+
listDOMstring += '<li class="notice"><i>'+options.nothingfound+'</i></li>';
146154
}
147155
$('#prompt-list').append(listDOMstring);
148156
});

0 commit comments

Comments
 (0)