Add instant search to the market list

This commit is contained in:
Trever Fischer
2012-11-17 16:26:42 -05:00
parent 58e4d2d9dd
commit 1158858b7c
2 changed files with 26 additions and 3 deletions

13
static/js/market.js Normal file
View File

@@ -0,0 +1,13 @@
$(document).ready(function() {
$('#market-search').keypress(function() {
var needle = $(this).val().toLowerCase();
$('#market-prices tr.market-item').each(function (idx, item) {
var haystack = $(item).find('[class|="inventory-item"] .name').text().toLowerCase();
if (haystack.search(needle) == -1) {
item.style.display = "none";
} else {
item.style.display = null;
}
});
});
});

View File

@@ -1,19 +1,29 @@
{% extends 'base_simple.html' %}
{% load static %}
{% get_static_prefix as STATIC_PREFIX %}
{% block extrahead %}
<script type="text/javascript" language="javascript" src="{{STATIC_PREFIX}}/js/market.js"></script>
{% endblock %}
{% block title %}The Market{% endblock %}
{% block sectiontitle %}The Market{% endblock %}
{% block content %}
<h2>Market Prices</h2>
<table>
<table id="market-prices">
<tr>
<th colspan="3">
<input type="text" id="market-search"/>
</td>
</tr>
<tr>
<th>Item</th>
<th>High</th>
<th>Low</th>
</tr>
{% for itemData in items %}
<tr>
<td>
<tr class='market-item'>
<td class='item-name'>
<a href="{% url market.views.itemStats itemID=itemData.item.id%}">
{% include 'common/item.html' with item=itemData.item %}
</a>