diff options
author | raylu <raylu@gridium.com> | 2013-10-22 19:09:51 -0700 |
---|---|---|
committer | raylu <raylu@gridium.com> | 2013-10-22 19:09:51 -0700 |
commit | 1b81975f1fb3d1341cad30061dc195581e2264b6 (patch) | |
tree | d60317c056391c100c1bffd09e0db5ce98909460 /web/static/js/search.js | |
parent | c7056a2e0d0a61b65199d8d0b5e7b79fb51c3de7 (diff) | |
download | ykill-1b81975f1fb3d1341cad30061dc195581e2264b6.tar.xz |
search for alliance and characters too
Diffstat (limited to 'web/static/js/search.js')
-rw-r--r-- | web/static/js/search.js | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/web/static/js/search.js b/web/static/js/search.js index 1bb2d51..7b72526 100644 --- a/web/static/js/search.js +++ b/web/static/js/search.js @@ -1,15 +1,26 @@ window.addEvent('domready', function() { document.title += ' - search'; ykill.api('/search' + document.location.search, function(results) { - var corps = $('corps'); - results.corporations.each(function(corp) { - corps.adopt( - new Element('a', { - 'html': corp.corporation_name, - 'href': '/corporation/' + corp.corporation_id, - }), - new Element('br') + var wrapper = $('wrapper'); + Object.each(results, function(list, key) { + if (!list.length) + return; + var div = new Element('div').grab( + new Element('h2', {'html': key[0].toUpperCase() + key.substr(1)}) ); + var key_singular = key.substr(0, key.length-1) + var name_key = key_singular + '_name'; + var id_key = key_singular + '_id'; + list.each(function(entity) { + div.adopt( + new Element('a', { + 'html': entity[name_key], + 'href': '/' + key_singular + '/' + entity[id_key], + }), + new Element('br') + ); + }); + wrapper.grab(div); }); }); }); |