various search improvements

This commit is contained in:
Thibault Duplessis 2012-09-06 18:52:34 +02:00
parent ea6f281cfa
commit 309157305f
9 changed files with 45 additions and 38 deletions

View file

@ -361,7 +361,7 @@ case class DbGame(
def averageUsersElo = userElos match { def averageUsersElo = userElos match {
case a :: b :: Nil Some((a + b) / 2) case a :: b :: Nil Some((a + b) / 2)
case a :: Nil Some(a) case a :: Nil Some(a + 1200) / 2
case Nil None case Nil None
} }

View file

@ -60,7 +60,7 @@ case class SearchData(
dateMax: Option[String], dateMax: Option[String],
status: Option[Int], status: Option[Int],
sortField: String = Sorting.default.field, sortField: String = Sorting.default.field,
sortOrder: String = Sorting.default.field) { sortOrder: String = Sorting.default.order) {
lazy val query = Query( lazy val query = Query(
usernames = (~usernames).split(" ").toList map clean filter (_.nonEmpty), usernames = (~usernames).split(" ").toList map clean filter (_.nonEmpty),

View file

@ -52,7 +52,7 @@ case class Query(
date map Game.dateFormatter.print filters fields.date, date map Game.dateFormatter.print filters fields.date,
averageElo filters fields.date, averageElo filters fields.date,
hasAiFilters, hasAiFilters,
aiLevel filters fields.ai, (hasAi | true).fold(aiLevel filters fields.ai, Nil),
toFilters(variant, fields.variant), toFilters(variant, fields.variant),
toFilters(rated, fields.rated), toFilters(rated, fields.rated),
toFilters(opening, fields.opening), toFilters(opening, fields.opening),

View file

@ -7,7 +7,7 @@ import com.traackr.scalastic.elasticsearch.SearchParameterTypes.FieldSort
case class Sorting(field: String, order: String) { case class Sorting(field: String, order: String) {
def fieldSort = FieldSort( def fieldSort = FieldSort(
field = (Sorting.fields contains field).fold(field, Sorting.default.field), field = (Sorting.fieldKeys contains field).fold(field, Sorting.default.field),
order = (order.toLowerCase == "asc").fold(SortOrder.ASC, SortOrder.DESC) order = (order.toLowerCase == "asc").fold(SortOrder.ASC, SortOrder.DESC)
) )
} }
@ -19,6 +19,8 @@ object Sorting {
Game.fields.turns -> "Turns", Game.fields.turns -> "Turns",
Game.fields.averageElo -> "Average ELO") Game.fields.averageElo -> "Average ELO")
def fieldKeys = fields map (_._1)
val orders = List(SortOrder.ASC, SortOrder.DESC) map { s s.toString -> s.toString } val orders = List(SortOrder.ASC, SortOrder.DESC) map { s s.toString -> s.toString }
val default = Sorting(Game.fields.date, "desc") val default = Sorting(Game.fields.date, "desc")

View file

@ -7,7 +7,7 @@ import play.api.templates.Html
trait AssetHelper { trait AssetHelper {
val assetVersion = 70 val assetVersion = 71
def cssTag(name: String) = css("stylesheets/" + name) def cssTag(name: String) = css("stylesheets/" + name)

View file

@ -54,11 +54,11 @@ moreCss = moreCss) {
<th> <th>
<label for="@form("hasAi").id">Opponent</label> <label for="@form("hasAi").id">Opponent</label>
</th> </th>
<td class="single"> <td class="single opponent">
@select(form("hasAi"), Query.hasAis, "Human or Computer".some) @select(form("hasAi"), Query.hasAis, "Human or Computer".some)
</td> </td>
</tr> </tr>
<tr> <tr class="aiLevel">
<th> <th>
<label for="@form("aiLevel").id">Stockfish level</label> <label for="@form("aiLevel").id">Stockfish level</label>
</th> </th>

View file

@ -17,4 +17,9 @@ $(function() {
$('body').trigger('lichess.content_loaded'); $('body').trigger('lichess.content_loaded');
}); });
}); });
var $form = $("form.search");
$form.find(".opponent select").change(function() {
$form.find(".aiLevel").toggle($(this).val() == 1);
}).trigger("change");
}); });

View file

@ -4,7 +4,7 @@ body.dark {
color: #909090; color: #909090;
} }
body.dark a, body.dark a,
body.dark a:visited { body.dark a:visited {
color: #909090; color: #909090;
} }
@ -81,7 +81,8 @@ body.dark form.translation_form input,
body.dark div.locale_menu a, body.dark div.locale_menu a,
body.dark div.adv_chart, body.dark div.adv_chart,
body.dark #top .dropdown, body.dark #top .dropdown,
body.dark div.lichess_overboard p.explanations body.dark div.lichess_overboard p.explanations,
body.dark form.search
{ {
border-color: #3e3e3e; border-color: #3e3e3e;
} }
@ -99,7 +100,7 @@ body.dark #top ul.language_links a:hover
color: #b0b0b0; color: #b0b0b0;
} }
body.dark #site_title, body.dark #site_title,
body.dark #site_baseline, body.dark #site_baseline,
body.dark div.anon_chat a.user_link, body.dark div.anon_chat a.user_link,
body.dark div.undertable a.user_link, body.dark div.undertable a.user_link,
@ -112,9 +113,9 @@ body.dark #site_title span.extension {
color: #707070; color: #707070;
} }
body.dark #top a.goto_nav:hover, body.dark #top a.goto_nav:hover,
body.dark #top a.toggle:hover, body.dark #top a.toggle:hover,
body.dark #top a.bgpicker:hover, body.dark #top a.bgpicker:hover,
body.dark a#sound_state:hover, body.dark a#sound_state:hover,
body.dark #top .dropdown, body.dark #top .dropdown,
body.dark #top .shown a.toggle { body.dark #top .shown a.toggle {
@ -164,15 +165,12 @@ body.dark div.lichess_overboard {
body.dark div.lichess_overboard.game_config { body.dark div.lichess_overboard.game_config {
box-shadow: 0 0 20px #d0d0d0; box-shadow: 0 0 20px #d0d0d0;
} }
body.dark div.game_config .optional_config {
background: #343434;
}
body.dark div.lichess_table_not_started { body.dark div.lichess_table_not_started {
box-shadow: none; box-shadow: none;
background: none; background: none;
} }
body.dark div.lichess_table a.lichess_button:hover, body.dark div.lichess_table a.lichess_button:hover,
body.dark div.lichess_table a.lichess_button.active { body.dark div.lichess_table a.lichess_button.active {
box-shadow: 0 0 9px #d85000; box-shadow: 0 0 9px #d85000;
border: 1px solid #d85000; border: 1px solid #d85000;
@ -204,7 +202,9 @@ body.dark div.content_box_inter,
body.dark #GameText tr:nth-child(even), body.dark #GameText tr:nth-child(even),
body.dark table.translations tbody tr:nth-child(even), body.dark table.translations tbody tr:nth-child(even),
body.dark form.translation_form div.message:nth-child(even), body.dark form.translation_form div.message:nth-child(even),
body.dark div.content_box table.datatable tr:nth-child(odd) body.dark div.content_box table.datatable tr:nth-child(odd),
body.dark div.game_config .optional_config,
body.dark form.search
{ {
background: #343434; background: #343434;
} }
@ -219,7 +219,7 @@ body.dark #lichess_forum div.post .message,
body.dark #GameText a.move, body.dark #GameText a.move,
body.dark form.translation_form div.message label, body.dark form.translation_form div.message label,
body.dark div.content_box h1, body.dark div.content_box h1,
body.dark div.hooks a body.dark div.hooks a
{ {
color: #b0b0b0; color: #b0b0b0;
} }
@ -263,14 +263,14 @@ body.dark div.checkmateFen div.lmcs:hover {
} }
/* soft inactive gradient */ /* soft inactive gradient */
body.dark #top, body.dark #top,
body.dark div.lichess_chat_top, body.dark div.lichess_chat_top,
body.dark div.undertable_top, body.dark div.undertable_top,
body.dark .button, body.dark .button,
body.dark .button:visited, body.dark .button:visited,
body.dark .ui-state-default, body.dark .ui-state-default,
body.dark div.content_box_top, body.dark div.content_box_top,
body.dark div.hooks tr, body.dark div.hooks tr,
body.dark a.translation_call, body.dark a.translation_call,
body.dark div.notification, body.dark div.notification,
body.dark div.locale_menu a body.dark div.locale_menu a
@ -297,15 +297,15 @@ body.dark .button:hover
background: linear-gradient(top , #505050, #202020) repeat scroll 0 0 #505050; background: linear-gradient(top , #505050, #202020) repeat scroll 0 0 #505050;
} }
/* active gradient */ /* active gradient */
body.dark #top a.goto_nav.active, body.dark #top a.goto_nav.active,
body.dark .button.active, body.dark .button.active,
body.dark .button.active:hover, body.dark .button.active:hover,
body.dark .ui-state-active, body.dark .ui-state-active,
body.dark .ui-widget-header, body.dark .ui-widget-header,
body.dark div.pagination span.current, body.dark div.pagination span.current,
body.dark #top span.new_messages.unread, body.dark #top span.new_messages.unread,
body.dark div.hooks td.action:hover, body.dark div.hooks td.action:hover,
body.dark div.hooks table.empty_table tr:hover, body.dark div.hooks table.empty_table tr:hover,
body.dark div.progressbar.flashy div, body.dark div.progressbar.flashy div,
body.dark div.locale_menu a.active body.dark div.locale_menu a.active
{ {

View file

@ -1,8 +1,8 @@
form.search { form.search {
margin-top: 10px; margin-top: 10px;
padding: 10px 25px; padding: 10px 25px;
background: #343434; background: #f4f4f4;
border: 1px solid #3e3e3e; border: 1px solid #e4e4e4;
} }
form.search td { form.search td {