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

Commit

Permalink
FIX: Prompt search & tag usage
Browse files Browse the repository at this point in the history
  • Loading branch information
MCStreetguy committed Jul 28, 2017
1 parent a96715e commit b56a289
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
#### Features
- Snippet tag functionalities
#### Improvements
-

#### Patches
- Debug output
- Search prompt


---
Expand Down
2 changes: 1 addition & 1 deletion lib/icon-helper.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lib/snippet-injector.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ export default {
var elem = new Snippet(JSON.parse(storage.retrieveFile(currentValue.replace('.json',''))));
listitems.push({
title: elem.getTitle(),
uid: elem.getUID()
uid: elem.getUID(),
tags: elem.getTags()
});
icons.push(elem.getLang());
});
Expand Down
16 changes: 12 additions & 4 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,15 @@ export default class Util {
var text = edit.getText();
$('#prompt-list').find('.list-item, .notice').remove();
var filteredItems = options.listItems.filter(function(element) {
element = element.toLowerCase();
text = text.toLowerCase();
if(text !== '' && text !== ' ' && text !== null && text !== undefined) {
return (element.indexOf(text) > -1 ? true : false);
var title = element.title.toLowerCase();
var tags = element.tags.join(' ').toLowerCase();
if(text.startsWith('#')) {
return (tags.indexOf(text.split('#').join('')) > -1 ? true : false);
} else {
return (title.indexOf(text) > -1 ? true : false);
}
} else {
return true;
}
Expand All @@ -159,14 +164,17 @@ export default class Util {
listDOMstring += IconHelper.getIconTag('default');
}
}
listDOMstring += '<p class="value">';
listDOMstring += currentValue;
listDOMstring += '<p class="value" data-id="'+currentValue.uid+'">';
listDOMstring += currentValue.title;
listDOMstring += '</p></li>';
});
} else {
listDOMstring += '<li class="notice"><i>'+options.nothingfound+'</i></li>';
}
$('#prompt-list').append(listDOMstring);
if(options.icons.length > 0) {
IconHelper.colorize('colored-svg');
}
});
var handleCancel = function(e) {
window.removeEventListener('keyup',handleKey,true);
Expand Down

0 comments on commit b56a289

Please sign in to comment.