Add instant search to the market list
This commit is contained in:
13
static/js/market.js
Normal file
13
static/js/market.js
Normal 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;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
@@ -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>
|
||||
|
Reference in New Issue
Block a user