Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Smilie autocomplete search box
// ==UserScript==
// @name SASmilieSearch
// @namespace forums.somethingawful.com
// @version 0.1.5
// @description Smilie autocomplete search box
// @author Me
// @match http://forums.somethingawful.com/misc.php?action=showsmilies
// @match https://forums.somethingawful.com/misc.php?action=showsmilies
// @grant none
// ==/UserScript==
(function() {
'use strict';
$('h2').after('<input type="text" id="box" />');
$('#box').autocomplete({
source: $.map($('li.smilie'), function(el) {
var code = el.textContent.replace(/\n/g, ''),
img = el.lastElementChild.cloneNode();
return {
label: code + ' ' + img.title + ' ',
value: code,
img: img
};
})
}).data('ui-autocomplete')._renderItem = function(ul, item) {
return $('<li>')
.attr('data-value', item.value)
.append(item.label)
.append(item.img)
.appendTo(ul);
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.