A-Z browsing
This commit is contained in:
@@ -103,12 +103,32 @@ object RatingsManager: Runnable {
|
||||
if (aga && ratingsHandlers[Ratings.AGA]!!.active) mask = mask or Ratings.AGA.flag
|
||||
if (egf && ratingsHandlers[Ratings.EGF]!!.active) mask = mask or Ratings.EGF.flag
|
||||
if (ffg && ratingsHandlers[Ratings.FFG]!!.active) mask = mask or Ratings.FFG.flag
|
||||
val matches = index.match(needle, mask, country)
|
||||
return matches.map { it -> players[it] }.toCollection(Json.MutableArray())
|
||||
return if (needle == "*") {
|
||||
sortedPlayers(mask, country)
|
||||
} else {
|
||||
val matches = index.match(needle, mask, country)
|
||||
matches.map { it -> players[it] }.toCollection(Json.MutableArray())
|
||||
}
|
||||
} finally {
|
||||
updateLock.readLock().unlock()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun sortedPlayers(mask: Int, country: String?): Json.Array {
|
||||
val cntry = country?.let { it.uppercase(Locale.ROOT) }
|
||||
val orig = Ratings.values().filter { (it.flag and mask) != 0 }.map { it.name }.toSet()
|
||||
return players.filter {
|
||||
val player = it as Json.Object
|
||||
(cntry == null || cntry == player.getString("country")) && orig.contains(player.getString("origin"))
|
||||
}.sortedWith { a,b ->
|
||||
val left = a as Json.Object
|
||||
val right = b as Json.Object
|
||||
val cmp = left.getString("name")!!.compareTo(right.getString("name")!!)
|
||||
if (cmp == 0) left.getString("firstname")!!.compareTo(right.getString("firstname")!!)
|
||||
else cmp
|
||||
}.toCollection(Json.MutableArray())
|
||||
}
|
||||
|
||||
val index = PlayerIndex()
|
||||
}
|
||||
|
@@ -21,19 +21,19 @@ function searchResultShown() {
|
||||
|
||||
function search(needle) {
|
||||
needle = needle.trim();
|
||||
if (needle && needle.length > 2) {
|
||||
if (needle && (needle === '*' || needle.length > 2)) {
|
||||
let form = $('#player-form')[0];
|
||||
let search = {
|
||||
needle: needle,
|
||||
aga: form.val('aga'),
|
||||
// aga: form.val('aga'),
|
||||
egf: form.val('egf'),
|
||||
ffg: form.val('ffg'),
|
||||
}
|
||||
let country = form.val('countryFilter');
|
||||
if (country) search.countryFilter = country;
|
||||
let searchFormState = {
|
||||
countryFilter: country ? true : false,
|
||||
aga: search.aga,
|
||||
countryFilter: !!country,
|
||||
// aga: search.aga,
|
||||
egf: search.egf,
|
||||
ffg: search.ffg
|
||||
};
|
||||
@@ -92,7 +92,7 @@ function addPlayers() {
|
||||
let status = form.val('final') || false;
|
||||
form.reset();
|
||||
// initial search checkboxes position
|
||||
['countryFilter', 'aga', 'egf', 'ffg'].forEach(id => {
|
||||
['countryFilter', /* 'aga', */ 'egf', 'ffg'].forEach(id => {
|
||||
let value = store(id);
|
||||
let ctl = $(`#${id}`);
|
||||
if (value !== null && typeof(value) !== 'undefined' && ctl.length) {
|
||||
@@ -253,7 +253,7 @@ onLoad(() => {
|
||||
});
|
||||
let searchFormState = store('searchFormState')
|
||||
if (searchFormState) {
|
||||
for (let id of ["countryFilter", "aga", "egf", "ffg"]) {
|
||||
for (let id of ["countryFilter", /* "aga", */ "egf", "ffg"]) {
|
||||
let ctl = $(`#${id}`);
|
||||
if (ctl.length) {
|
||||
ctl[0].checked = searchFormState[id];
|
||||
@@ -410,4 +410,7 @@ onLoad(() => {
|
||||
}));
|
||||
bulkUpdate(players);
|
||||
});
|
||||
$('#browse-players').on('click', e => {
|
||||
search('*');
|
||||
});
|
||||
});
|
||||
|
@@ -84,12 +84,13 @@
|
||||
</div>
|
||||
</div>
|
||||
#end
|
||||
<div class="ten wide field">
|
||||
<div class="eight wide field">
|
||||
<div class="ui icon input">
|
||||
<input id="needle" name="needle" type="text" placeholder="Search...">
|
||||
<i id="clear-search" class="clickable close icon"></i>
|
||||
</div>
|
||||
</div>
|
||||
#* Disabled
|
||||
<div class="two wide field">
|
||||
<div class="toggle">
|
||||
<input id="aga" name="aga" type="checkbox" value="true"/>
|
||||
@@ -99,6 +100,7 @@
|
||||
<label>AGA</label>
|
||||
</div>
|
||||
</div>
|
||||
*#
|
||||
<div class="two wide field">
|
||||
<div class="toggle">
|
||||
<input id="egf" name="egf" type="checkbox" checked value="true"/>
|
||||
@@ -117,6 +119,11 @@
|
||||
<label>FFG</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="two wide field">
|
||||
<button id="browse-players" type="button" class="ui basic icon button">
|
||||
<i class="sort alphabet down icon"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div id="search-result"></div>
|
||||
</div>
|
||||
<div class="two stackable fields">
|
||||
|
Reference in New Issue
Block a user